his_api_controller.go 1.6MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. "github.com/go-ole/go-ole"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  42. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  43. //上传就诊信息-上传明细-结算
  44. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  45. //查询
  46. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  47. //对总账
  48. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  49. //对明细
  50. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  51. //退费,退明细
  52. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  53. //退号
  54. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  55. //退明细
  56. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  57. //上传就诊信息-上传明细-预结算
  58. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  59. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  60. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  61. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  62. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  63. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  64. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  65. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  66. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  67. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  68. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  69. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  70. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  71. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  72. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  73. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  74. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  75. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  76. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  81. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  82. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  83. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  84. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  85. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  86. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  87. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  88. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  89. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  90. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  91. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  92. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  93. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  94. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  95. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  96. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  97. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  98. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  99. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  100. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  101. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  102. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  103. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  107. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  108. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  109. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  110. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  111. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  112. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  113. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  114. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  115. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  116. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  117. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  118. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  119. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  120. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  121. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  122. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  123. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  124. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  125. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  126. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  127. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  128. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  129. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  130. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  131. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  132. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  133. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  134. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  135. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  136. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  137. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  138. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  139. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  140. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  141. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  142. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  143. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  144. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  145. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  146. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  147. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  148. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  149. //库盘和变更
  150. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  151. //删除库盘和变更
  152. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  153. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  154. //药品变更
  155. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  156. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  157. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  158. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  159. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  160. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  161. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  162. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  163. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  164. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  165. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  166. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  167. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  168. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  169. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  170. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  171. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  172. }
  173. func (c *HisApiController) Get3201() {
  174. adminUser := c.GetAdminUserInfo()
  175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  176. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  177. var response Response
  178. if err := json.Unmarshal([]byte(result), &response); err != nil {
  179. fmt.Println("Error decoding JSON:", err)
  180. return
  181. }
  182. }
  183. func (c *HisApiController) TestNet() {
  184. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  185. //return
  186. c.ServeSuccessJSON(map[string]interface{}{
  187. "msg": "成功",
  188. })
  189. }
  190. func (c *HisApiController) Get3508() {
  191. admin_user_id, _ := c.GetInt64("admin_user_id")
  192. drug_id, _ := c.GetInt64("id")
  193. start_time := c.GetString("start_time")
  194. end_time := c.GetString("end_time")
  195. adminUser := c.GetAdminUserInfo()
  196. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  197. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  198. drug, _ := service.GetDrugByID(drug_id)
  199. var struct3508 models.Struct3508
  200. struct3508.OrgName = miConfig.OrgName
  201. struct3508.FixmedinsCode = miConfig.Code
  202. struct3508.AccessKey = miConfig.AccessKey
  203. struct3508.Opter = curRoles.UserName
  204. struct3508.RequestUrl = miConfig.Url
  205. struct3508.Url = miConfig.Url
  206. struct3508.AppId = miConfig.Cainfo
  207. struct3508.AppSecret = miConfig.AppSecret
  208. struct3508.Enckey = miConfig.EncKey
  209. struct3508.SignKey = miConfig.SignKey
  210. struct3508.SecretKey = miConfig.SecretKey
  211. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  212. struct3508.Begndate = start_time
  213. struct3508.Enddate = end_time
  214. result1, result2, _ := service.FJyb3508(struct3508)
  215. saveLog(result1, result2, "3508", "3508")
  216. var res models.Result3508
  217. var respJSON2 map[string]interface{}
  218. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. userJSONBytes2, _ := json.Marshal(respJSON2)
  224. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  227. return
  228. }
  229. if res.Infcode == -1 {
  230. c.ServeSuccessJSON(map[string]interface{}{
  231. "failed_code": -10,
  232. "msg": res.ErrMsg,
  233. })
  234. } else {
  235. c.ServeSuccessJSON(map[string]interface{}{
  236. "info": res.Output,
  237. })
  238. }
  239. }
  240. func (c *HisApiController) Get3509() {
  241. admin_user_id, _ := c.GetInt64("admin_user_id")
  242. drug_id, _ := c.GetInt64("id")
  243. start_time := c.GetString("start_time")
  244. end_time := c.GetString("end_time")
  245. adminUser := c.GetAdminUserInfo()
  246. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  248. drug, _ := service.GetDrugByID(drug_id)
  249. var struct3508 models.Struct3509
  250. struct3508.OrgName = miConfig.OrgName
  251. struct3508.FixmedinsCode = miConfig.Code
  252. struct3508.AccessKey = miConfig.AccessKey
  253. struct3508.Opter = curRoles.UserName
  254. struct3508.RequestUrl = miConfig.Url
  255. struct3508.Url = miConfig.Url
  256. struct3508.AppId = miConfig.Cainfo
  257. struct3508.AppSecret = miConfig.AppSecret
  258. struct3508.Enckey = miConfig.EncKey
  259. struct3508.SignKey = miConfig.SignKey
  260. struct3508.SecretKey = miConfig.SecretKey
  261. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  262. struct3508.Begndate = start_time
  263. struct3508.Enddate = end_time
  264. result1, result2, _ := service.FJyb3509(struct3508)
  265. saveLog(result1, result2, "3509", "3509")
  266. var res models.Result3509
  267. var respJSON2 map[string]interface{}
  268. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  271. return
  272. }
  273. userJSONBytes2, _ := json.Marshal(respJSON2)
  274. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  275. utils.ErrorLog("解析失败:%v", err)
  276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  277. return
  278. }
  279. if res.Infcode == -1 {
  280. c.ServeSuccessJSON(map[string]interface{}{
  281. "failed_code": -10,
  282. "msg": res.ErrMsg,
  283. })
  284. } else {
  285. c.ServeSuccessJSON(map[string]interface{}{
  286. "info": res.Output,
  287. })
  288. }
  289. }
  290. func (c *HisApiController) Get3510() {
  291. admin_user_id, _ := c.GetInt64("admin_user_id")
  292. drug_id, _ := c.GetInt64("id")
  293. start_time := c.GetString("start_time")
  294. end_time := c.GetString("end_time")
  295. adminUser := c.GetAdminUserInfo()
  296. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  297. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  298. drug, _ := service.GetDrugByID(drug_id)
  299. var struct3508 models.Struct3510
  300. struct3508.FixmedinsCode = miConfig.Code
  301. struct3508.OrgName = miConfig.OrgName
  302. struct3508.AccessKey = miConfig.AccessKey
  303. struct3508.Opter = curRoles.UserName
  304. struct3508.RequestUrl = miConfig.Url
  305. struct3508.Url = miConfig.Url
  306. struct3508.AppId = miConfig.Cainfo
  307. struct3508.AppSecret = miConfig.AppSecret
  308. struct3508.Enckey = miConfig.EncKey
  309. struct3508.SignKey = miConfig.SignKey
  310. struct3508.SecretKey = miConfig.SecretKey
  311. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  312. struct3508.Begndate = start_time
  313. struct3508.Enddate = end_time
  314. result1, result2, _ := service.FJyb3510(struct3508)
  315. saveLog(result1, result2, "3510", "3510")
  316. var res models.Result3510
  317. var respJSON2 map[string]interface{}
  318. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  321. return
  322. }
  323. userJSONBytes2, _ := json.Marshal(respJSON2)
  324. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  325. utils.ErrorLog("解析失败:%v", err)
  326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  327. return
  328. }
  329. if res.Infcode == -1 {
  330. c.ServeSuccessJSON(map[string]interface{}{
  331. "failed_code": -10,
  332. "msg": res.ErrMsg,
  333. })
  334. } else {
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "info": res.Output,
  337. })
  338. }
  339. }
  340. func (c *HisApiController) Get3511() {
  341. admin_user_id, _ := c.GetInt64("admin_user_id")
  342. drug_id, _ := c.GetInt64("id")
  343. start_time := c.GetString("start_time")
  344. end_time := c.GetString("end_time")
  345. adminUser := c.GetAdminUserInfo()
  346. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  348. drug, _ := service.GetDrugByID(drug_id)
  349. var struct3508 models.Struct3511
  350. struct3508.FixmedinsCode = miConfig.Code
  351. struct3508.OrgName = miConfig.OrgName
  352. struct3508.AccessKey = miConfig.AccessKey
  353. struct3508.Opter = curRoles.UserName
  354. struct3508.RequestUrl = miConfig.Url
  355. struct3508.Url = miConfig.Url
  356. struct3508.AppId = miConfig.Cainfo
  357. struct3508.AppSecret = miConfig.AppSecret
  358. struct3508.Enckey = miConfig.EncKey
  359. struct3508.SignKey = miConfig.SignKey
  360. struct3508.SecretKey = miConfig.SecretKey
  361. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  362. struct3508.Begndate = start_time
  363. struct3508.Enddate = end_time
  364. result1, result2, _ := service.FJyb3511(struct3508)
  365. saveLog(result1, result2, "3511", "3511")
  366. var res models.Result3511
  367. var respJSON2 map[string]interface{}
  368. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  371. return
  372. }
  373. userJSONBytes2, _ := json.Marshal(respJSON2)
  374. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  375. utils.ErrorLog("解析失败:%v", err)
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  377. return
  378. }
  379. if res.Infcode == -1 {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. } else {
  385. c.ServeSuccessJSON(map[string]interface{}{
  386. "info": res.Output,
  387. })
  388. }
  389. }
  390. func (c *HisApiController) Get3512() {
  391. admin_user_id, _ := c.GetInt64("admin_user_id")
  392. drug_id, _ := c.GetInt64("id")
  393. start_time := c.GetString("start_time")
  394. end_time := c.GetString("end_time")
  395. adminUser := c.GetAdminUserInfo()
  396. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  397. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  398. drug, _ := service.GetDrugByID(drug_id)
  399. var struct3508 models.Struct3512
  400. struct3508.FixmedinsCode = miConfig.Code
  401. struct3508.OrgName = miConfig.OrgName
  402. struct3508.AccessKey = miConfig.AccessKey
  403. struct3508.Opter = curRoles.UserName
  404. struct3508.RequestUrl = miConfig.Url
  405. struct3508.Url = miConfig.Url
  406. struct3508.AppId = miConfig.Cainfo
  407. struct3508.AppSecret = miConfig.AppSecret
  408. struct3508.Enckey = miConfig.EncKey
  409. struct3508.SignKey = miConfig.SignKey
  410. struct3508.SecretKey = miConfig.SecretKey
  411. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  412. struct3508.Begndate = start_time
  413. struct3508.Enddate = end_time
  414. result1, result2, _ := service.FJyb3512(struct3508)
  415. saveLog(result1, result2, "3512", "3512")
  416. var res models.Result3512
  417. var respJSON2 map[string]interface{}
  418. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  421. return
  422. }
  423. userJSONBytes2, _ := json.Marshal(respJSON2)
  424. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == -1 {
  430. c.ServeSuccessJSON(map[string]interface{}{
  431. "failed_code": -10,
  432. "msg": res.ErrMsg,
  433. })
  434. } else {
  435. c.ServeSuccessJSON(map[string]interface{}{
  436. "info": res.Output,
  437. })
  438. }
  439. }
  440. func (c *HisApiController) Get3513() {
  441. admin_user_id, _ := c.GetInt64("admin_user_id")
  442. drug_id, _ := c.GetInt64("id")
  443. start_time := c.GetString("start_time")
  444. end_time := c.GetString("end_time")
  445. adminUser := c.GetAdminUserInfo()
  446. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  447. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  448. drug, _ := service.GetDrugByID(drug_id)
  449. var struct3508 models.Struct3513
  450. struct3508.FixmedinsCode = miConfig.Code
  451. struct3508.OrgName = miConfig.OrgName
  452. struct3508.AccessKey = miConfig.AccessKey
  453. struct3508.Opter = curRoles.UserName
  454. struct3508.RequestUrl = miConfig.Url
  455. struct3508.Url = miConfig.Url
  456. struct3508.AppId = miConfig.Cainfo
  457. struct3508.AppSecret = miConfig.AppSecret
  458. struct3508.Enckey = miConfig.EncKey
  459. struct3508.SignKey = miConfig.SignKey
  460. struct3508.SecretKey = miConfig.SecretKey
  461. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  462. struct3508.Begndate = start_time
  463. struct3508.Enddate = end_time
  464. result1, result2, _ := service.FJyb3513(struct3508)
  465. saveLog(result1, result2, "3513", "3513")
  466. var res models.Result3513
  467. var respJSON2 map[string]interface{}
  468. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  471. return
  472. }
  473. userJSONBytes2, _ := json.Marshal(respJSON2)
  474. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  475. utils.ErrorLog("解析失败:%v", err)
  476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  477. return
  478. }
  479. if res.Infcode == -1 {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "failed_code": -10,
  482. "msg": res.ErrMsg,
  483. })
  484. } else {
  485. c.ServeSuccessJSON(map[string]interface{}{
  486. "info": res.Output,
  487. })
  488. }
  489. }
  490. func (c *HisApiController) Get35081() {
  491. admin_user_id, _ := c.GetInt64("admin_user_id")
  492. drug_id, _ := c.GetInt64("id")
  493. //start_time := c.GetString("start_time")
  494. //end_time := c.GetString("end_time")
  495. page, _ := c.GetInt("page")
  496. adminUser := c.GetAdminUserInfo()
  497. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  498. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  499. drug, _ := service.GetDrugByID(drug_id)
  500. var struct3508 models.Struct35081
  501. struct3508.FixmedinsCode = miConfig.Code
  502. struct3508.OrgName = miConfig.OrgName
  503. struct3508.AccessKey = miConfig.AccessKey
  504. struct3508.Opter = curRoles.UserName
  505. struct3508.RequestUrl = miConfig.Url
  506. struct3508.Url = miConfig.Url
  507. struct3508.AppId = miConfig.Cainfo
  508. struct3508.AppSecret = miConfig.AppSecret
  509. struct3508.Enckey = miConfig.EncKey
  510. struct3508.SignKey = miConfig.SignKey
  511. struct3508.SecretKey = miConfig.SecretKey
  512. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  513. struct3508.PageNum = page
  514. struct3508.PageSize = 10
  515. result1, result2, _ := service.FJyb35081(struct3508)
  516. saveLog(result1, result2, "35081", "35081")
  517. var res models.Result35081
  518. var respJSON2 map[string]interface{}
  519. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  522. return
  523. }
  524. userJSONBytes2, _ := json.Marshal(respJSON2)
  525. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  526. utils.ErrorLog("解析失败:%v", err)
  527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  528. return
  529. }
  530. if res.Infcode == -1 {
  531. c.ServeSuccessJSON(map[string]interface{}{
  532. "failed_code": -10,
  533. "msg": res.ErrMsg,
  534. })
  535. } else {
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "info": res.Output,
  538. })
  539. }
  540. }
  541. func (c *HisApiController) Get35082() {
  542. admin_user_id, _ := c.GetInt64("admin_user_id")
  543. drug_id, _ := c.GetInt64("id")
  544. //start_time := c.GetString("start_time")
  545. //end_time := c.GetString("end_time")
  546. page, _ := c.GetInt("page")
  547. adminUser := c.GetAdminUserInfo()
  548. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  550. drug, _ := service.GetDrugByID(drug_id)
  551. var struct3508 models.Struct35082
  552. struct3508.FixmedinsCode = miConfig.Code
  553. struct3508.OrgName = miConfig.OrgName
  554. struct3508.AccessKey = miConfig.AccessKey
  555. struct3508.Opter = curRoles.UserName
  556. struct3508.RequestUrl = miConfig.Url
  557. struct3508.Url = miConfig.Url
  558. struct3508.AppId = miConfig.Cainfo
  559. struct3508.AppSecret = miConfig.AppSecret
  560. struct3508.Enckey = miConfig.EncKey
  561. struct3508.SignKey = miConfig.SignKey
  562. struct3508.SecretKey = miConfig.SecretKey
  563. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  564. struct3508.PageNum = page
  565. struct3508.PageSize = 10
  566. result1, result2, _ := service.FJyb35082(struct3508)
  567. saveLog(result1, result2, "35082", "35082")
  568. var res models.Result35082
  569. var respJSON2 map[string]interface{}
  570. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  573. return
  574. }
  575. userJSONBytes2, _ := json.Marshal(respJSON2)
  576. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  577. utils.ErrorLog("解析失败:%v", err)
  578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  579. return
  580. }
  581. if res.Infcode == -1 {
  582. c.ServeSuccessJSON(map[string]interface{}{
  583. "failed_code": -10,
  584. "msg": res.ErrMsg,
  585. })
  586. } else {
  587. c.ServeSuccessJSON(map[string]interface{}{
  588. "info": res.Output,
  589. })
  590. }
  591. }
  592. func (c *HisApiController) FJ3501AND3502() {
  593. ids := c.GetString("ids")
  594. admin_user_id, _ := c.GetInt64("admin_user_id")
  595. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  596. id_arr := strings.Split(ids, ",")
  597. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  598. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  599. //库盘
  600. var errs []string
  601. for _, drug := range drugs {
  602. if drug.IsPc == 0 {
  603. var res2 ResultSix
  604. var res3 ResultSix
  605. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  606. var struct3501 models.Struct3501
  607. struct3501.Code = miConfig.Code
  608. struct3501.OrgName = miConfig.OrgName
  609. struct3501.AccessKey = miConfig.AccessKey
  610. struct3501.Opter = roles.UserName
  611. struct3501.RequestUrl = miConfig.Url
  612. struct3501.Url = miConfig.Url
  613. struct3501.AppId = miConfig.Cainfo
  614. struct3501.AppSecret = miConfig.AppSecret
  615. struct3501.Enckey = miConfig.EncKey
  616. struct3501.SignKey = miConfig.SignKey
  617. struct3501.SecretKey = miConfig.SecretKey
  618. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  620. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  621. struct3501.RxFlag = "1"
  622. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  623. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  624. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  625. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  626. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  627. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  628. struct3501.FixmedinsBchno = number
  629. struct3501.DrugTracCodg = drug.DrugCode
  630. memo := make(map[string]interface{})
  631. memo["pric"] = drug.Price
  632. bytesData, _ := json.Marshal(memo)
  633. struct3501.Memo = string(bytesData)
  634. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  635. result1, result2, _ := service.FJyb3501(struct3501)
  636. saveLog(result1, result2, "3501", "3501")
  637. //saveLog(result, requestLog, "2201", "挂号")
  638. var respJSON2 map[string]interface{}
  639. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  642. return
  643. }
  644. userJSONBytes2, _ := json.Marshal(respJSON2)
  645. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  646. utils.ErrorLog("解析失败:%v", err)
  647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  648. return
  649. }
  650. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  651. data := make(map[string]interface{})
  652. data["struct_3501s"] = struct3501
  653. client := &http.Client{}
  654. bytesData, _ := json.Marshal(data)
  655. var req *http.Request
  656. if miConfig.MdtrtareaAdmvs == "320921" {
  657. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  658. } else {
  659. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  660. }
  661. resp, _ := client.Do(req)
  662. defer resp.Body.Close()
  663. body, ioErr := ioutil.ReadAll(resp.Body)
  664. if ioErr != nil {
  665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  666. }
  667. var respJSON map[string]interface{}
  668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. var resSix10265 ResultSix10265 //1101结果
  674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  675. result, _ := json.Marshal(respJSON)
  676. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  677. utils.ErrorLog("解析失败:%v", err)
  678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  679. return
  680. }
  681. res2.InfRefmsgid = resSix10265.InfRefmsgid
  682. res2.Output = resSix10265.Output
  683. res2.ErrMsg = resSix10265.ErrMsg
  684. res2.Cainfo = resSix10265.Cainfo
  685. res2.WarnMsg = resSix10265.WarnMsg
  686. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  687. res2.Infcode = infocode
  688. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  689. data := make(map[string]interface{})
  690. data["struct_3501s"] = struct3501
  691. client := &http.Client{}
  692. bytesData, _ := json.Marshal(data)
  693. var req *http.Request
  694. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  695. resp, _ := client.Do(req)
  696. defer resp.Body.Close()
  697. body, ioErr := ioutil.ReadAll(resp.Body)
  698. if ioErr != nil {
  699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  700. }
  701. var respJSON map[string]interface{}
  702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  705. return
  706. }
  707. var resSix10265 ResultSix10265 //1101结果
  708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  709. result, _ := json.Marshal(respJSON)
  710. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  711. utils.ErrorLog("解析失败:%v", err)
  712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  713. return
  714. }
  715. res2.InfRefmsgid = resSix10265.InfRefmsgid
  716. res2.Output = resSix10265.Output
  717. res2.ErrMsg = resSix10265.ErrMsg
  718. res2.Cainfo = resSix10265.Cainfo
  719. res2.WarnMsg = resSix10265.WarnMsg
  720. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  721. res2.Infcode = infocode
  722. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  723. data := make(map[string]interface{})
  724. data["struct_3501s"] = struct3501
  725. client := &http.Client{}
  726. bytesData, _ := json.Marshal(data)
  727. var req *http.Request
  728. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  729. resp, _ := client.Do(req)
  730. defer resp.Body.Close()
  731. body, ioErr := ioutil.ReadAll(resp.Body)
  732. if ioErr != nil {
  733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  734. }
  735. var respJSON map[string]interface{}
  736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  739. return
  740. }
  741. var resSix10265 ResultSix10265 //1101结果
  742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  743. result, _ := json.Marshal(respJSON)
  744. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  745. utils.ErrorLog("解析失败:%v", err)
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. res2.InfRefmsgid = resSix10265.InfRefmsgid
  750. res2.Output = resSix10265.Output
  751. res2.ErrMsg = resSix10265.ErrMsg
  752. res2.Cainfo = resSix10265.Cainfo
  753. res2.WarnMsg = resSix10265.WarnMsg
  754. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  755. res2.Infcode = infocode
  756. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  757. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  758. saveLog(result1, result2, "3501", "3501")
  759. //saveLog(result, requestLog, "2201", "挂号")
  760. var respJSON2 map[string]interface{}
  761. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. userJSONBytes2, _ := json.Marshal(respJSON2)
  767. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  768. utils.ErrorLog("解析失败:%v", err)
  769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  770. return
  771. }
  772. }
  773. if res2.Infcode != -1 {
  774. drug.IsPc = 1
  775. drug.Bchno = number
  776. drug.PcDate = time.Now().Unix()
  777. err := service.SaveW(drug)
  778. if err == nil {
  779. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  780. var struct3502 models.Struct3502
  781. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  783. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  784. struct3502.FixmedinsCode = miConfig.Code
  785. struct3502.Code = miConfig.Code
  786. struct3502.RxFlag = "0"
  787. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  788. struct3502.OrgName = miConfig.OrgName
  789. struct3502.Opter = roles.UserName
  790. struct3502.AccessKey = miConfig.AccessKey
  791. struct3502.RequestUrl = miConfig.Url
  792. struct3502.SecretKey = miConfig.SecretKey
  793. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  794. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  795. struct3502.Url = miConfig.Url
  796. struct3502.AppId = miConfig.Cainfo
  797. struct3502.AppSecret = miConfig.AppSecret
  798. struct3502.Enckey = miConfig.EncKey
  799. struct3502.SignKey = miConfig.SignKey
  800. struct3502.SecretKey = miConfig.SecretKey
  801. struct3502.DrugTracCodg = drug.DrugCode
  802. struct3502.Memo = ""
  803. struct3502.InvChgType = "108"
  804. struct3502.FixmedinsBchno = bg_number
  805. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  806. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  807. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  808. result11, result22, _ := service.FJyb3502(struct3502)
  809. saveLog(result11, result22, "3502", "3502")
  810. var respJSON3 map[string]interface{}
  811. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. userJSONBytes3, _ := json.Marshal(respJSON3)
  817. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  818. utils.ErrorLog("解析失败:%v", err)
  819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  820. return
  821. }
  822. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  823. data := make(map[string]interface{})
  824. data["struct_3502s"] = struct3502
  825. client := &http.Client{}
  826. bytesData, _ := json.Marshal(data)
  827. var req *http.Request
  828. if miConfig.MdtrtareaAdmvs == "320921" {
  829. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  830. } else {
  831. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  832. }
  833. resp, _ := client.Do(req)
  834. defer resp.Body.Close()
  835. body, ioErr := ioutil.ReadAll(resp.Body)
  836. if ioErr != nil {
  837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  838. }
  839. var respJSON map[string]interface{}
  840. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  843. return
  844. }
  845. var resSix10265 ResultSix10265 //1101结果
  846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  847. result, _ := json.Marshal(respJSON)
  848. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  849. utils.ErrorLog("解析失败:%v", err)
  850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  851. return
  852. }
  853. res3.InfRefmsgid = resSix10265.InfRefmsgid
  854. res3.Output = resSix10265.Output
  855. res3.ErrMsg = resSix10265.ErrMsg
  856. res3.Cainfo = resSix10265.Cainfo
  857. res3.WarnMsg = resSix10265.WarnMsg
  858. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  859. res3.Infcode = infocode
  860. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  861. data := make(map[string]interface{})
  862. data["struct_3502s"] = struct3502
  863. client := &http.Client{}
  864. bytesData, _ := json.Marshal(data)
  865. var req *http.Request
  866. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  867. resp, _ := client.Do(req)
  868. defer resp.Body.Close()
  869. body, ioErr := ioutil.ReadAll(resp.Body)
  870. if ioErr != nil {
  871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  872. }
  873. var respJSON map[string]interface{}
  874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  877. return
  878. }
  879. var resSix10265 ResultSix10265 //1101结果
  880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  881. result, _ := json.Marshal(respJSON)
  882. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  883. utils.ErrorLog("解析失败:%v", err)
  884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  885. return
  886. }
  887. res3.InfRefmsgid = resSix10265.InfRefmsgid
  888. res3.Output = resSix10265.Output
  889. res3.ErrMsg = resSix10265.ErrMsg
  890. res3.Cainfo = resSix10265.Cainfo
  891. res3.WarnMsg = resSix10265.WarnMsg
  892. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  893. res3.Infcode = infocode
  894. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  895. data := make(map[string]interface{})
  896. data["struct_3501s"] = struct3501
  897. client := &http.Client{}
  898. bytesData, _ := json.Marshal(data)
  899. var req *http.Request
  900. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  901. resp, _ := client.Do(req)
  902. defer resp.Body.Close()
  903. body, ioErr := ioutil.ReadAll(resp.Body)
  904. if ioErr != nil {
  905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  906. }
  907. var respJSON map[string]interface{}
  908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. return
  912. }
  913. var resSix10265 ResultSix10265 //1101结果
  914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  915. result, _ := json.Marshal(respJSON)
  916. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  917. utils.ErrorLog("解析失败:%v", err)
  918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  919. return
  920. }
  921. res2.InfRefmsgid = resSix10265.InfRefmsgid
  922. res2.Output = resSix10265.Output
  923. res2.ErrMsg = resSix10265.ErrMsg
  924. res2.Cainfo = resSix10265.Cainfo
  925. res2.WarnMsg = resSix10265.WarnMsg
  926. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  927. res2.Infcode = infocode
  928. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  929. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  930. saveLog(result11, result22, "3502", "3502")
  931. var respJSON3 map[string]interface{}
  932. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. return
  936. }
  937. userJSONBytes3, _ := json.Marshal(respJSON3)
  938. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  939. utils.ErrorLog("解析失败:%v", err)
  940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  941. return
  942. }
  943. }
  944. if res3.Infcode == -1 {
  945. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  946. c.ServeSuccessJSON(map[string]interface{}{
  947. "failed_code": -10,
  948. "msg": res3.ErrMsg,
  949. })
  950. } else {
  951. drug.IsBg = 1
  952. drug.BgBchno = bg_number
  953. service.SaveW(drug)
  954. }
  955. }
  956. } else {
  957. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  958. }
  959. }
  960. //变更
  961. }
  962. if len(errs) == 0 {
  963. c.ServeSuccessJSON(map[string]interface{}{
  964. "msg": "盘存变更成功",
  965. })
  966. } else {
  967. c.ServeSuccessJSON(map[string]interface{}{
  968. "failed_code": -10,
  969. "msg": errs,
  970. })
  971. }
  972. }
  973. func (c *HisApiController) DeletePCandBG() {
  974. ids := c.GetString("ids")
  975. id_arr := strings.Split(ids, ",")
  976. admin_user_id, _ := c.GetInt64("admin_user_id")
  977. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  978. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  979. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  980. var err []string
  981. for _, item := range drugs {
  982. if item.IsPc == 1 && item.IsBg == 1 {
  983. var res FJ3507Result
  984. var res2 FJ3507Result
  985. var struct3507 models.Struct3507
  986. struct3507.FixmedinsBchno = item.Bchno
  987. struct3507.InvDataType = "1"
  988. struct3507.Opter = roles.UserName
  989. struct3507.OrgName = miConfig.OrgName
  990. struct3507.AccessKey = miConfig.AccessKey
  991. struct3507.RequestUrl = miConfig.Url
  992. struct3507.FixmedinsCode = miConfig.Code
  993. struct3507.Code = miConfig.Code
  994. struct3507.SecretKey = miConfig.SecretKey
  995. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  996. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  997. struct3507.Url = miConfig.Url
  998. struct3507.AppId = miConfig.Cainfo
  999. struct3507.AppSecret = miConfig.AppSecret
  1000. struct3507.Enckey = miConfig.EncKey
  1001. struct3507.SignKey = miConfig.SignKey
  1002. struct3507.SecretKey = miConfig.SecretKey
  1003. if miConfig.MdtrtareaAdmvs == "350500" {
  1004. result, result1, _ := service.FJyb3507(struct3507)
  1005. saveLog(result, result1, "3507", "3507")
  1006. var respJSON2 map[string]interface{}
  1007. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. return
  1011. }
  1012. userJSONBytes2, _ := json.Marshal(respJSON2)
  1013. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1014. utils.ErrorLog("解析失败:%v", err)
  1015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1016. return
  1017. }
  1018. } else {
  1019. data := make(map[string]interface{})
  1020. data["struct_3507s"] = struct3507
  1021. client := &http.Client{}
  1022. bytesData, _ := json.Marshal(data)
  1023. var req *http.Request
  1024. if miConfig.MdtrtareaAdmvs == "320921" {
  1025. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1026. } else {
  1027. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1028. }
  1029. resp, _ := client.Do(req)
  1030. defer resp.Body.Close()
  1031. body, ioErr := ioutil.ReadAll(resp.Body)
  1032. if ioErr != nil {
  1033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1034. }
  1035. var respJSON map[string]interface{}
  1036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. var resSix10265 ResultSix10265 //1101结果
  1042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1043. result, _ := json.Marshal(respJSON)
  1044. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1045. utils.ErrorLog("解析失败:%v", err)
  1046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1047. return
  1048. }
  1049. res.InfRefmsgid = resSix10265.InfRefmsgid
  1050. //res.Output = resSix10265.Output
  1051. res.ErrMsg = resSix10265.ErrMsg
  1052. res.Cainfo = resSix10265.Cainfo
  1053. res.WarnMsg = resSix10265.WarnMsg
  1054. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1055. res.Infcode = infocode
  1056. }
  1057. if res.Infcode == 0 {
  1058. item.IsPc = 0
  1059. err2 := service.SaveW(item)
  1060. if err2 == nil {
  1061. var struct3507_2 models.Struct3507
  1062. struct3507_2.OrgName = miConfig.OrgName
  1063. struct3507_2.AccessKey = miConfig.AccessKey
  1064. struct3507_2.RequestUrl = miConfig.Url
  1065. struct3507_2.Opter = roles.UserName
  1066. struct3507_2.FixmedinsCode = miConfig.Code
  1067. struct3507_2.Code = miConfig.Code
  1068. struct3507_2.SecretKey = miConfig.SecretKey
  1069. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1070. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1071. struct3507_2.Url = miConfig.Url
  1072. struct3507_2.AppId = miConfig.Cainfo
  1073. struct3507_2.AppSecret = miConfig.AppSecret
  1074. struct3507_2.Enckey = miConfig.EncKey
  1075. struct3507_2.SignKey = miConfig.SignKey
  1076. struct3507_2.SecretKey = miConfig.SecretKey
  1077. struct3507_2.FixmedinsBchno = item.BgBchno
  1078. struct3507_2.InvDataType = "2"
  1079. if miConfig.MdtrtareaAdmvs == "350500" {
  1080. result11, result22, _ := service.FJyb3507(struct3507_2)
  1081. saveLog(result11, result22, "3507", "3507")
  1082. var respJSON3 map[string]interface{}
  1083. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1086. return
  1087. }
  1088. userJSONBytes3, _ := json.Marshal(respJSON3)
  1089. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1090. utils.ErrorLog("解析失败:%v", err)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. } else {
  1095. data := make(map[string]interface{})
  1096. data["struct_3507s"] = struct3507_2
  1097. client := &http.Client{}
  1098. bytesData, _ := json.Marshal(data)
  1099. var req *http.Request
  1100. if miConfig.MdtrtareaAdmvs == "320921" {
  1101. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1102. } else {
  1103. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1104. }
  1105. resp, _ := client.Do(req)
  1106. defer resp.Body.Close()
  1107. body, ioErr := ioutil.ReadAll(resp.Body)
  1108. if ioErr != nil {
  1109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1110. }
  1111. var respJSON map[string]interface{}
  1112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1115. return
  1116. }
  1117. var resSix10265 ResultSix10265 //1101结果
  1118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1119. result, _ := json.Marshal(respJSON)
  1120. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1121. utils.ErrorLog("解析失败:%v", err)
  1122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1123. return
  1124. }
  1125. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1126. //res2.Output = resSix10265.Output
  1127. res2.ErrMsg = resSix10265.ErrMsg
  1128. res2.Cainfo = resSix10265.Cainfo
  1129. res2.WarnMsg = resSix10265.WarnMsg
  1130. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1131. res2.Infcode = infocode
  1132. }
  1133. if res2.Infcode != -1 {
  1134. item.IsBg = 0
  1135. item.Bchno = ""
  1136. item.BgBchno = ""
  1137. item.PcDate = 0
  1138. service.SaveW(item)
  1139. } else {
  1140. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1141. }
  1142. }
  1143. } else {
  1144. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1145. }
  1146. }
  1147. if item.IsPc == 1 && item.IsBg == 0 {
  1148. var res FJ3507Result
  1149. var struct3507 models.Struct3507
  1150. struct3507.FixmedinsBchno = item.Bchno
  1151. struct3507.InvDataType = "1"
  1152. struct3507.Opter = roles.UserName
  1153. struct3507.FixmedinsCode = miConfig.Code
  1154. struct3507.Code = miConfig.Code
  1155. struct3507.OrgName = miConfig.OrgName
  1156. struct3507.AccessKey = miConfig.AccessKey
  1157. struct3507.RequestUrl = miConfig.Url
  1158. struct3507.SecretKey = miConfig.SecretKey
  1159. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1160. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1161. struct3507.Url = miConfig.Url
  1162. struct3507.AppId = miConfig.Cainfo
  1163. struct3507.AppSecret = miConfig.AppSecret
  1164. struct3507.Enckey = miConfig.EncKey
  1165. struct3507.SignKey = miConfig.SignKey
  1166. struct3507.SecretKey = miConfig.SecretKey
  1167. //result, result1, _ := service.FJyb3507(struct3507)
  1168. //saveLog(result, result1, "3507", "3507")
  1169. if miConfig.MdtrtareaAdmvs == "350500" {
  1170. result, result1, _ := service.FJyb3507(struct3507)
  1171. saveLog(result, result1, "3507", "3507")
  1172. var respJSON2 map[string]interface{}
  1173. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1176. return
  1177. }
  1178. userJSONBytes2, _ := json.Marshal(respJSON2)
  1179. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1180. utils.ErrorLog("解析失败:%v", err)
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. return
  1183. }
  1184. } else {
  1185. data := make(map[string]interface{})
  1186. data["struct_3507s"] = struct3507
  1187. client := &http.Client{}
  1188. bytesData, _ := json.Marshal(data)
  1189. var req *http.Request
  1190. if miConfig.MdtrtareaAdmvs == "320921" {
  1191. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1192. } else {
  1193. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1194. }
  1195. resp, _ := client.Do(req)
  1196. defer resp.Body.Close()
  1197. body, ioErr := ioutil.ReadAll(resp.Body)
  1198. if ioErr != nil {
  1199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1200. }
  1201. var respJSON map[string]interface{}
  1202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. var resSix10265 ResultSix10265 //1101结果
  1208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1209. result, _ := json.Marshal(respJSON)
  1210. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1211. utils.ErrorLog("解析失败:%v", err)
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1213. return
  1214. }
  1215. res.InfRefmsgid = resSix10265.InfRefmsgid
  1216. //res.Output = resSix10265.Output
  1217. res.ErrMsg = resSix10265.ErrMsg
  1218. res.Cainfo = resSix10265.Cainfo
  1219. res.WarnMsg = resSix10265.WarnMsg
  1220. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1221. res.Infcode = infocode
  1222. }
  1223. if res.Infcode == 0 {
  1224. item.IsPc = 0
  1225. item.Bchno = ""
  1226. item.BgBchno = ""
  1227. item.PcDate = 0
  1228. service.SaveW(item)
  1229. } else {
  1230. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1231. }
  1232. }
  1233. if item.IsPc == 0 && item.IsBg == 1 {
  1234. var res FJ3507Result
  1235. var struct3507 models.Struct3507
  1236. struct3507.FixmedinsBchno = item.BgBchno
  1237. struct3507.InvDataType = "2"
  1238. struct3507.Opter = roles.UserName
  1239. struct3507.FixmedinsCode = miConfig.Code
  1240. struct3507.OrgName = miConfig.OrgName
  1241. struct3507.AccessKey = miConfig.AccessKey
  1242. struct3507.RequestUrl = miConfig.Url
  1243. struct3507.SecretKey = miConfig.SecretKey
  1244. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1245. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1246. struct3507.Url = miConfig.Url
  1247. struct3507.AppId = miConfig.Cainfo
  1248. struct3507.AppSecret = miConfig.AppSecret
  1249. struct3507.Enckey = miConfig.EncKey
  1250. struct3507.SignKey = miConfig.SignKey
  1251. struct3507.SecretKey = miConfig.SecretKey
  1252. //result, result1, _ := service.FJyb3507(struct3507)
  1253. //saveLog(result, result1, "3507", "3507")
  1254. if miConfig.MdtrtareaAdmvs == "350500" {
  1255. result, result1, _ := service.FJyb3507(struct3507)
  1256. saveLog(result, result1, "3507", "3507")
  1257. var respJSON2 map[string]interface{}
  1258. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1261. return
  1262. }
  1263. userJSONBytes2, _ := json.Marshal(respJSON2)
  1264. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1265. utils.ErrorLog("解析失败:%v", err)
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1267. return
  1268. }
  1269. } else {
  1270. data := make(map[string]interface{})
  1271. data["struct_3507s"] = struct3507
  1272. client := &http.Client{}
  1273. bytesData, _ := json.Marshal(data)
  1274. var req *http.Request
  1275. if miConfig.MdtrtareaAdmvs == "320921" {
  1276. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1277. } else {
  1278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1279. }
  1280. resp, _ := client.Do(req)
  1281. defer resp.Body.Close()
  1282. body, ioErr := ioutil.ReadAll(resp.Body)
  1283. if ioErr != nil {
  1284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1285. }
  1286. var respJSON map[string]interface{}
  1287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1290. return
  1291. }
  1292. var resSix10265 ResultSix10265 //1101结果
  1293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1294. result, _ := json.Marshal(respJSON)
  1295. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1296. utils.ErrorLog("解析失败:%v", err)
  1297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. return
  1299. }
  1300. res.InfRefmsgid = resSix10265.InfRefmsgid
  1301. //res.Output = resSix10265.Output
  1302. res.ErrMsg = resSix10265.ErrMsg
  1303. res.Cainfo = resSix10265.Cainfo
  1304. res.WarnMsg = resSix10265.WarnMsg
  1305. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1306. res.Infcode = infocode
  1307. }
  1308. if res.Infcode == 0 {
  1309. item.IsBg = 0
  1310. item.Bchno = ""
  1311. item.BgBchno = ""
  1312. item.PcDate = 0
  1313. service.SaveW(item)
  1314. } else {
  1315. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1316. }
  1317. }
  1318. }
  1319. if len(err) == 0 {
  1320. c.ServeSuccessJSON(map[string]interface{}{
  1321. "msg": "删除盘存变更成功",
  1322. })
  1323. } else {
  1324. c.ServeSuccessJSON(map[string]interface{}{
  1325. "failed_code": -10,
  1326. "msg": err,
  1327. })
  1328. }
  1329. }
  1330. func (c *HisApiController) DeleteXSandBG() {
  1331. ids := c.GetString("ids")
  1332. id_arr := strings.Split(ids, ",")
  1333. admin_user_id, _ := c.GetInt64("admin_user_id")
  1334. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1335. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1337. var err []string
  1338. for _, item := range flows {
  1339. if item.IsSale == 1 && item.IsChange == 1 {
  1340. var res FJ3507Result
  1341. var res2 FJ3507Result
  1342. var struct3507 models.Struct3507
  1343. struct3507.FixmedinsBchno = item.Bchno
  1344. struct3507.InvDataType = "4"
  1345. struct3507.Opter = roles.UserName
  1346. struct3507.OrgName = miConfig.OrgName
  1347. struct3507.AccessKey = miConfig.AccessKey
  1348. struct3507.RequestUrl = miConfig.Url
  1349. struct3507.FixmedinsCode = miConfig.Code
  1350. struct3507.SecretKey = miConfig.SecretKey
  1351. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1352. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1353. struct3507.Url = miConfig.Url
  1354. struct3507.AppId = miConfig.Cainfo
  1355. struct3507.AppSecret = miConfig.AppSecret
  1356. struct3507.Enckey = miConfig.EncKey
  1357. struct3507.SignKey = miConfig.SignKey
  1358. struct3507.SecretKey = miConfig.SecretKey
  1359. //result, result1, _ := service.FJyb3507(struct3507)
  1360. //saveLog(result, result1, "3507", "3507")
  1361. if miConfig.MdtrtareaAdmvs == "350500" {
  1362. result, result1, _ := service.FJyb3507(struct3507)
  1363. saveLog(result, result1, "3507", "3507")
  1364. var respJSON2 map[string]interface{}
  1365. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1368. return
  1369. }
  1370. userJSONBytes2, _ := json.Marshal(respJSON2)
  1371. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1372. utils.ErrorLog("解析失败:%v", err)
  1373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1374. return
  1375. }
  1376. } else {
  1377. data := make(map[string]interface{})
  1378. data["struct_3507s"] = struct3507
  1379. client := &http.Client{}
  1380. bytesData, _ := json.Marshal(data)
  1381. var req *http.Request
  1382. if miConfig.MdtrtareaAdmvs == "320921" {
  1383. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1384. } else {
  1385. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1386. }
  1387. resp, _ := client.Do(req)
  1388. defer resp.Body.Close()
  1389. body, ioErr := ioutil.ReadAll(resp.Body)
  1390. if ioErr != nil {
  1391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1392. }
  1393. var respJSON map[string]interface{}
  1394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1397. return
  1398. }
  1399. var resSix10265 ResultSix10265 //1101结果
  1400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1401. result, _ := json.Marshal(respJSON)
  1402. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1403. utils.ErrorLog("解析失败:%v", err)
  1404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1405. return
  1406. }
  1407. res.InfRefmsgid = resSix10265.InfRefmsgid
  1408. //res.Output = resSix10265.Output
  1409. res.ErrMsg = resSix10265.ErrMsg
  1410. res.Cainfo = resSix10265.Cainfo
  1411. res.WarnMsg = resSix10265.WarnMsg
  1412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1413. res.Infcode = infocode
  1414. }
  1415. if res.Infcode == 0 {
  1416. item.IsSale = 0
  1417. item.SaleDate = ""
  1418. item.Bchno = ""
  1419. err2 := service.SaveDF(item)
  1420. if err2 == nil {
  1421. var struct3507_2 models.Struct3507
  1422. struct3507_2.OrgName = miConfig.OrgName
  1423. struct3507_2.AccessKey = miConfig.AccessKey
  1424. struct3507_2.RequestUrl = miConfig.Url
  1425. struct3507_2.Opter = roles.UserName
  1426. struct3507_2.FixmedinsCode = miConfig.Code
  1427. struct3507_2.Code = miConfig.Code
  1428. struct3507_2.SecretKey = miConfig.SecretKey
  1429. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1430. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1431. struct3507_2.Url = miConfig.Url
  1432. struct3507_2.AppId = miConfig.Cainfo
  1433. struct3507_2.AppSecret = miConfig.AppSecret
  1434. struct3507_2.Enckey = miConfig.EncKey
  1435. struct3507_2.SignKey = miConfig.SignKey
  1436. struct3507_2.SecretKey = miConfig.SecretKey
  1437. struct3507_2.FixmedinsBchno = item.BgBchno
  1438. struct3507_2.InvDataType = "2"
  1439. if miConfig.MdtrtareaAdmvs == "350500" {
  1440. result11, result22, _ := service.FJyb3507(struct3507_2)
  1441. saveLog(result11, result22, "3507", "3507")
  1442. var respJSON3 map[string]interface{}
  1443. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1446. return
  1447. }
  1448. userJSONBytes3, _ := json.Marshal(respJSON3)
  1449. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1450. utils.ErrorLog("解析失败:%v", err)
  1451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1452. return
  1453. }
  1454. } else {
  1455. data := make(map[string]interface{})
  1456. data["struct_3507s"] = struct3507_2
  1457. client := &http.Client{}
  1458. bytesData, _ := json.Marshal(data)
  1459. var req *http.Request
  1460. if miConfig.MdtrtareaAdmvs == "320921" {
  1461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1462. } else {
  1463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1464. }
  1465. resp, _ := client.Do(req)
  1466. defer resp.Body.Close()
  1467. body, ioErr := ioutil.ReadAll(resp.Body)
  1468. if ioErr != nil {
  1469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1470. }
  1471. var respJSON map[string]interface{}
  1472. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1475. return
  1476. }
  1477. var resSix10265 ResultSix10265 //1101结果
  1478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1479. result, _ := json.Marshal(respJSON)
  1480. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1481. utils.ErrorLog("解析失败:%v", err)
  1482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1483. return
  1484. }
  1485. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1486. //res.Output = resSix10265.Output
  1487. res2.ErrMsg = resSix10265.ErrMsg
  1488. res2.Cainfo = resSix10265.Cainfo
  1489. res2.WarnMsg = resSix10265.WarnMsg
  1490. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1491. res2.Infcode = infocode
  1492. }
  1493. if res2.Infcode == 0 {
  1494. item.IsChange = 0
  1495. item.BgBchno = ""
  1496. service.SaveDF2(item)
  1497. } else {
  1498. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1499. }
  1500. }
  1501. } else {
  1502. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1503. }
  1504. }
  1505. if item.IsSale == 2 && item.IsChange == 1 {
  1506. var res FJ3507Result
  1507. var res2 FJ3507Result
  1508. var struct3507 models.Struct3507
  1509. struct3507.FixmedinsBchno = item.Bchno
  1510. struct3507.InvDataType = "4"
  1511. struct3507.Opter = roles.UserName
  1512. struct3507.OrgName = miConfig.OrgName
  1513. struct3507.AccessKey = miConfig.AccessKey
  1514. struct3507.RequestUrl = miConfig.Url
  1515. struct3507.FixmedinsCode = miConfig.Code
  1516. struct3507.Code = miConfig.Code
  1517. struct3507.SecretKey = miConfig.SecretKey
  1518. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1519. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1520. struct3507.Url = miConfig.Url
  1521. struct3507.AppId = miConfig.Cainfo
  1522. struct3507.AppSecret = miConfig.AppSecret
  1523. struct3507.Enckey = miConfig.EncKey
  1524. struct3507.SignKey = miConfig.SignKey
  1525. struct3507.SecretKey = miConfig.SecretKey
  1526. //result, result1, _ := service.FJyb3507(struct3507)
  1527. //saveLog(result, result1, "3507", "3507")
  1528. //
  1529. //var respJSON2 map[string]interface{}
  1530. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1531. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. // return
  1534. //}
  1535. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1536. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1537. // utils.ErrorLog("解析失败:%v", err)
  1538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. // return
  1540. //}
  1541. if miConfig.MdtrtareaAdmvs == "350500" {
  1542. result, result1, _ := service.FJyb3507(struct3507)
  1543. saveLog(result, result1, "3507", "3507")
  1544. var respJSON2 map[string]interface{}
  1545. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1548. return
  1549. }
  1550. userJSONBytes2, _ := json.Marshal(respJSON2)
  1551. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1552. utils.ErrorLog("解析失败:%v", err)
  1553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1554. return
  1555. }
  1556. } else {
  1557. data := make(map[string]interface{})
  1558. data["struct_3507s"] = struct3507
  1559. client := &http.Client{}
  1560. bytesData, _ := json.Marshal(data)
  1561. var req *http.Request
  1562. if miConfig.MdtrtareaAdmvs == "320921" {
  1563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1564. } else {
  1565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1566. }
  1567. resp, _ := client.Do(req)
  1568. defer resp.Body.Close()
  1569. body, ioErr := ioutil.ReadAll(resp.Body)
  1570. if ioErr != nil {
  1571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1572. }
  1573. var respJSON map[string]interface{}
  1574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1577. return
  1578. }
  1579. var resSix10265 ResultSix10265 //1101结果
  1580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1581. result, _ := json.Marshal(respJSON)
  1582. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1583. utils.ErrorLog("解析失败:%v", err)
  1584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. return
  1586. }
  1587. res.InfRefmsgid = resSix10265.InfRefmsgid
  1588. //res.Output = resSix10265.Output
  1589. res.ErrMsg = resSix10265.ErrMsg
  1590. res.Cainfo = resSix10265.Cainfo
  1591. res.WarnMsg = resSix10265.WarnMsg
  1592. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1593. res.Infcode = infocode
  1594. }
  1595. if res.Infcode == 0 {
  1596. item.IsSale = 0
  1597. item.SaleDate = ""
  1598. item.Bchno = ""
  1599. err2 := service.SaveDF(item)
  1600. if err2 == nil {
  1601. var struct3507_2 models.Struct3507
  1602. struct3507_2.OrgName = miConfig.OrgName
  1603. struct3507_2.AccessKey = miConfig.AccessKey
  1604. struct3507_2.RequestUrl = miConfig.Url
  1605. struct3507_2.Opter = roles.UserName
  1606. struct3507_2.FixmedinsCode = miConfig.Code
  1607. struct3507_2.Code = miConfig.Code
  1608. struct3507_2.SecretKey = miConfig.SecretKey
  1609. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1610. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1611. struct3507_2.Url = miConfig.Url
  1612. struct3507_2.AppId = miConfig.Cainfo
  1613. struct3507_2.AppSecret = miConfig.AppSecret
  1614. struct3507_2.Enckey = miConfig.EncKey
  1615. struct3507_2.SignKey = miConfig.SignKey
  1616. struct3507_2.SecretKey = miConfig.SecretKey
  1617. struct3507_2.FixmedinsBchno = item.BgBchno
  1618. struct3507_2.InvDataType = "2"
  1619. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1620. //saveLog(result11, result22, "3507", "3507")
  1621. //var respJSON3 map[string]interface{}
  1622. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1623. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1625. // return
  1626. //}
  1627. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1628. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1629. // utils.ErrorLog("解析失败:%v", err)
  1630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. // return
  1632. //}
  1633. if miConfig.MdtrtareaAdmvs == "350500" {
  1634. result11, result22, _ := service.FJyb3507(struct3507_2)
  1635. saveLog(result11, result22, "3507", "3507")
  1636. var respJSON3 map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. userJSONBytes3, _ := json.Marshal(respJSON3)
  1643. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1644. utils.ErrorLog("解析失败:%v", err)
  1645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1646. return
  1647. }
  1648. } else {
  1649. data := make(map[string]interface{})
  1650. data["struct_3507s"] = struct3507_2
  1651. client := &http.Client{}
  1652. bytesData, _ := json.Marshal(data)
  1653. var req *http.Request
  1654. if miConfig.MdtrtareaAdmvs == "320921" {
  1655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. } else {
  1657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1658. }
  1659. resp, _ := client.Do(req)
  1660. defer resp.Body.Close()
  1661. body, ioErr := ioutil.ReadAll(resp.Body)
  1662. if ioErr != nil {
  1663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1664. }
  1665. var respJSON map[string]interface{}
  1666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1669. return
  1670. }
  1671. var resSix10265 ResultSix10265 //1101结果
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1675. utils.ErrorLog("解析失败:%v", err)
  1676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1677. return
  1678. }
  1679. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1680. //res.Output = resSix10265.Output
  1681. res2.ErrMsg = resSix10265.ErrMsg
  1682. res2.Cainfo = resSix10265.Cainfo
  1683. res2.WarnMsg = resSix10265.WarnMsg
  1684. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1685. res2.Infcode = infocode
  1686. }
  1687. if res2.Infcode == 0 {
  1688. item.IsChange = 0
  1689. item.BgBchno = ""
  1690. service.SaveDF2(item)
  1691. } else {
  1692. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1693. }
  1694. }
  1695. } else {
  1696. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1697. }
  1698. }
  1699. if item.IsSale == 1 && item.IsChange == 0 {
  1700. var res FJ3507Result
  1701. var struct3507 models.Struct3507
  1702. struct3507.FixmedinsBchno = item.Bchno
  1703. struct3507.InvDataType = "4"
  1704. struct3507.Opter = roles.UserName
  1705. struct3507.FixmedinsCode = miConfig.Code
  1706. struct3507.Code = miConfig.Code
  1707. struct3507.OrgName = miConfig.OrgName
  1708. struct3507.AccessKey = miConfig.AccessKey
  1709. struct3507.RequestUrl = miConfig.Url
  1710. struct3507.SecretKey = miConfig.SecretKey
  1711. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1712. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1713. struct3507.Url = miConfig.Url
  1714. struct3507.AppId = miConfig.Cainfo
  1715. struct3507.AppSecret = miConfig.AppSecret
  1716. struct3507.Enckey = miConfig.EncKey
  1717. struct3507.SignKey = miConfig.SignKey
  1718. struct3507.SecretKey = miConfig.SecretKey
  1719. //result, result1, _ := service.FJyb3507(struct3507)
  1720. //saveLog(result, result1, "3507", "3507")
  1721. //
  1722. //var respJSON3 map[string]interface{}
  1723. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1724. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. // return
  1727. //}
  1728. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1729. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1730. // utils.ErrorLog("解析失败:%v", err)
  1731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. // return
  1733. //}
  1734. if miConfig.MdtrtareaAdmvs == "350500" {
  1735. result, result1, _ := service.FJyb3507(struct3507)
  1736. saveLog(result, result1, "3507", "3507")
  1737. var respJSON2 map[string]interface{}
  1738. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1741. return
  1742. }
  1743. userJSONBytes2, _ := json.Marshal(respJSON2)
  1744. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1745. utils.ErrorLog("解析失败:%v", err)
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1747. return
  1748. }
  1749. } else {
  1750. data := make(map[string]interface{})
  1751. data["struct_3507s"] = struct3507
  1752. client := &http.Client{}
  1753. bytesData, _ := json.Marshal(data)
  1754. var req *http.Request
  1755. if miConfig.MdtrtareaAdmvs == "320921" {
  1756. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1757. } else {
  1758. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1759. }
  1760. resp, _ := client.Do(req)
  1761. defer resp.Body.Close()
  1762. body, ioErr := ioutil.ReadAll(resp.Body)
  1763. if ioErr != nil {
  1764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1765. }
  1766. var respJSON map[string]interface{}
  1767. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1770. return
  1771. }
  1772. var resSix10265 ResultSix10265 //1101结果
  1773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1774. result, _ := json.Marshal(respJSON)
  1775. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1776. utils.ErrorLog("解析失败:%v", err)
  1777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1778. return
  1779. }
  1780. res.InfRefmsgid = resSix10265.InfRefmsgid
  1781. //res.Output = resSix10265.Output
  1782. res.ErrMsg = resSix10265.ErrMsg
  1783. res.Cainfo = resSix10265.Cainfo
  1784. res.WarnMsg = resSix10265.WarnMsg
  1785. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1786. res.Infcode = infocode
  1787. }
  1788. if res.Infcode == 0 {
  1789. item.IsSale = 0
  1790. item.SaleDate = ""
  1791. service.SaveDF(item)
  1792. } else {
  1793. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1794. }
  1795. }
  1796. if item.IsSale == 2 && item.IsChange == 0 {
  1797. var res FJ3507Result
  1798. var struct3507 models.Struct3507
  1799. struct3507.FixmedinsBchno = item.Bchno
  1800. struct3507.InvDataType = "4"
  1801. struct3507.Opter = roles.UserName
  1802. struct3507.FixmedinsCode = miConfig.Code
  1803. struct3507.Code = miConfig.Code
  1804. struct3507.OrgName = miConfig.OrgName
  1805. struct3507.AccessKey = miConfig.AccessKey
  1806. struct3507.RequestUrl = miConfig.Url
  1807. struct3507.SecretKey = miConfig.SecretKey
  1808. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1809. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1810. struct3507.Url = miConfig.Url
  1811. struct3507.AppId = miConfig.Cainfo
  1812. struct3507.AppSecret = miConfig.AppSecret
  1813. struct3507.Enckey = miConfig.EncKey
  1814. struct3507.SignKey = miConfig.SignKey
  1815. struct3507.SecretKey = miConfig.SecretKey
  1816. //result, result1, _ := service.FJyb3507(struct3507)
  1817. //saveLog(result, result1, "3507", "3507")
  1818. //
  1819. //var respJSON3 map[string]interface{}
  1820. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1821. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. // return
  1824. //}
  1825. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1826. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1827. // utils.ErrorLog("解析失败:%v", err)
  1828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1829. // return
  1830. //}
  1831. if miConfig.MdtrtareaAdmvs == "350500" {
  1832. result, result1, _ := service.FJyb3507(struct3507)
  1833. saveLog(result, result1, "3507", "3507")
  1834. var respJSON2 map[string]interface{}
  1835. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. return
  1839. }
  1840. userJSONBytes2, _ := json.Marshal(respJSON2)
  1841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1842. utils.ErrorLog("解析失败:%v", err)
  1843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1844. return
  1845. }
  1846. } else {
  1847. data := make(map[string]interface{})
  1848. data["struct_3507s"] = struct3507
  1849. client := &http.Client{}
  1850. bytesData, _ := json.Marshal(data)
  1851. var req *http.Request
  1852. if miConfig.MdtrtareaAdmvs == "320921" {
  1853. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1854. } else {
  1855. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1856. }
  1857. resp, _ := client.Do(req)
  1858. defer resp.Body.Close()
  1859. body, ioErr := ioutil.ReadAll(resp.Body)
  1860. if ioErr != nil {
  1861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1862. }
  1863. var respJSON map[string]interface{}
  1864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1867. return
  1868. }
  1869. var resSix10265 ResultSix10265 //1101结果
  1870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1871. result, _ := json.Marshal(respJSON)
  1872. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1873. utils.ErrorLog("解析失败:%v", err)
  1874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1875. return
  1876. }
  1877. res.InfRefmsgid = resSix10265.InfRefmsgid
  1878. //res.Output = resSix10265.Output
  1879. res.ErrMsg = resSix10265.ErrMsg
  1880. res.Cainfo = resSix10265.Cainfo
  1881. res.WarnMsg = resSix10265.WarnMsg
  1882. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1883. res.Infcode = infocode
  1884. }
  1885. if res.Infcode == 0 {
  1886. item.IsSale = 0
  1887. item.SaleDate = ""
  1888. item.Bchno = ""
  1889. service.SaveDF(item)
  1890. } else {
  1891. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1892. }
  1893. }
  1894. if item.IsSale == 0 && item.IsChange == 1 {
  1895. var res FJ3507Result
  1896. var struct3507 models.Struct3507
  1897. struct3507.FixmedinsBchno = item.BgBchno
  1898. struct3507.InvDataType = "2"
  1899. struct3507.Opter = roles.UserName
  1900. struct3507.FixmedinsCode = miConfig.Code
  1901. struct3507.Code = miConfig.Code
  1902. struct3507.OrgName = miConfig.OrgName
  1903. struct3507.AccessKey = miConfig.AccessKey
  1904. struct3507.RequestUrl = miConfig.Url
  1905. struct3507.SecretKey = miConfig.SecretKey
  1906. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1907. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1908. struct3507.Url = miConfig.Url
  1909. struct3507.AppId = miConfig.Cainfo
  1910. struct3507.AppSecret = miConfig.AppSecret
  1911. struct3507.Enckey = miConfig.EncKey
  1912. struct3507.SignKey = miConfig.SignKey
  1913. struct3507.SecretKey = miConfig.SecretKey
  1914. //result, result1, _ := service.FJyb3507(struct3507)
  1915. //saveLog(result, result1, "3507", "3507")
  1916. //
  1917. //var respJSON3 map[string]interface{}
  1918. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1919. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. // return
  1922. //}
  1923. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1924. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1925. // utils.ErrorLog("解析失败:%v", err)
  1926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1927. // return
  1928. //}
  1929. if miConfig.MdtrtareaAdmvs == "350500" {
  1930. result, result1, _ := service.FJyb3507(struct3507)
  1931. saveLog(result, result1, "3507", "3507")
  1932. var respJSON2 map[string]interface{}
  1933. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1936. return
  1937. }
  1938. userJSONBytes2, _ := json.Marshal(respJSON2)
  1939. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1940. utils.ErrorLog("解析失败:%v", err)
  1941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1942. return
  1943. }
  1944. } else {
  1945. data := make(map[string]interface{})
  1946. data["struct_3507s"] = struct3507
  1947. client := &http.Client{}
  1948. bytesData, _ := json.Marshal(data)
  1949. var req *http.Request
  1950. if miConfig.MdtrtareaAdmvs == "320921" {
  1951. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1952. } else {
  1953. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1954. }
  1955. resp, _ := client.Do(req)
  1956. defer resp.Body.Close()
  1957. body, ioErr := ioutil.ReadAll(resp.Body)
  1958. if ioErr != nil {
  1959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1960. }
  1961. var respJSON map[string]interface{}
  1962. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1965. return
  1966. }
  1967. var resSix10265 ResultSix10265 //1101结果
  1968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1969. result, _ := json.Marshal(respJSON)
  1970. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1971. utils.ErrorLog("解析失败:%v", err)
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1973. return
  1974. }
  1975. res.InfRefmsgid = resSix10265.InfRefmsgid
  1976. //res.Output = resSix10265.Output
  1977. res.ErrMsg = resSix10265.ErrMsg
  1978. res.Cainfo = resSix10265.Cainfo
  1979. res.WarnMsg = resSix10265.WarnMsg
  1980. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1981. res.Infcode = infocode
  1982. }
  1983. if res.Infcode == 0 {
  1984. item.IsChange = 0
  1985. item.BgBchno = ""
  1986. service.SaveDF2(item)
  1987. } else {
  1988. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1989. }
  1990. }
  1991. }
  1992. if len(err) == 0 {
  1993. c.ServeSuccessJSON(map[string]interface{}{
  1994. "msg": "删除销售变更成功",
  1995. })
  1996. } else {
  1997. c.ServeSuccessJSON(map[string]interface{}{
  1998. "failed_code": -10,
  1999. "msg": err,
  2000. })
  2001. }
  2002. }
  2003. //func (c *HisApiController) BatchFJ3501AND3502() {
  2004. // //ids := c.GetString("ids")
  2005. // start_time := c.GetString("start_time")
  2006. // end_time := c.GetString("end_time")
  2007. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2008. //
  2009. //
  2010. // timeLayout := "2006-01-02"
  2011. // loc, _ := time.LoadLocation("Local")
  2012. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2013. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2014. //
  2015. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2016. // //id_arr := strings.Split(ids, ",")
  2017. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2018. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2019. // //库盘
  2020. // var errs []string
  2021. // for _, drug := range drugs {
  2022. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2023. // var res2 ResultSix
  2024. // var res3 ResultSix
  2025. //
  2026. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2027. // var struct3501 models.Struct3501
  2028. // struct3501.Code = miConfig.Code
  2029. // struct3501.OrgName = miConfig.OrgName
  2030. // struct3501.AccessKey = miConfig.AccessKey
  2031. // struct3501.Opter = roles.UserName
  2032. // struct3501.RequestUrl = miConfig.Url
  2033. // struct3501.Url = miConfig.Url
  2034. // struct3501.AppId = miConfig.Cainfo
  2035. // struct3501.AppSecret = miConfig.AppSecret
  2036. // struct3501.Enckey = miConfig.EncKey
  2037. // struct3501.SignKey = miConfig.SignKey
  2038. // struct3501.SecretKey = miConfig.SecretKey
  2039. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2041. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2042. // struct3501.RxFlag = "1"
  2043. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2044. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2045. //
  2046. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2047. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2048. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2049. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2050. // struct3501.FixmedinsBchno = number
  2051. // struct3501.DrugTracCodg = drug.DrugCode
  2052. // memo := make(map[string]interface{})
  2053. // memo["pric"] = drug.Price
  2054. // bytesData, _ := json.Marshal(memo)
  2055. // struct3501.Memo = string(bytesData)
  2056. //
  2057. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2058. //
  2059. // result1, result2, _ := service.FJyb3501(struct3501)
  2060. // saveLog(result1, result2, "3501", "3501")
  2061. // //saveLog(result, requestLog, "2201", "挂号")
  2062. //
  2063. // var respJSON2 map[string]interface{}
  2064. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2065. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2067. // return
  2068. // }
  2069. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2070. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2071. // utils.ErrorLog("解析失败:%v", err)
  2072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. // return
  2074. // }
  2075. //
  2076. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2077. // data := make(map[string]interface{})
  2078. // data["struct_3501s"] = struct3501
  2079. // client := &http.Client{}
  2080. // bytesData, _ := json.Marshal(data)
  2081. // var req *http.Request
  2082. // if miConfig.MdtrtareaAdmvs == "320921" {
  2083. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2084. // } else {
  2085. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2086. // }
  2087. //
  2088. // resp, _ := client.Do(req)
  2089. // defer resp.Body.Close()
  2090. // body, ioErr := ioutil.ReadAll(resp.Body)
  2091. // if ioErr != nil {
  2092. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2093. // }
  2094. // var respJSON map[string]interface{}
  2095. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2096. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2098. // return
  2099. // }
  2100. // var resSix10265 ResultSix10265 //1101结果
  2101. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2102. // result, _ := json.Marshal(respJSON)
  2103. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2104. // utils.ErrorLog("解析失败:%v", err)
  2105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2106. // return
  2107. // }
  2108. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2109. // res2.Output = resSix10265.Output
  2110. // res2.ErrMsg = resSix10265.ErrMsg
  2111. // res2.Cainfo = resSix10265.Cainfo
  2112. // res2.WarnMsg = resSix10265.WarnMsg
  2113. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2114. // res2.Infcode = infocode
  2115. //
  2116. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2117. // data := make(map[string]interface{})
  2118. // data["struct_3501s"] = struct3501
  2119. // client := &http.Client{}
  2120. // bytesData, _ := json.Marshal(data)
  2121. // var req *http.Request
  2122. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2123. // resp, _ := client.Do(req)
  2124. // defer resp.Body.Close()
  2125. // body, ioErr := ioutil.ReadAll(resp.Body)
  2126. // if ioErr != nil {
  2127. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2128. // }
  2129. // var respJSON map[string]interface{}
  2130. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2131. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2133. // return
  2134. // }
  2135. // var resSix10265 ResultSix10265 //1101结果
  2136. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2137. // result, _ := json.Marshal(respJSON)
  2138. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2139. // utils.ErrorLog("解析失败:%v", err)
  2140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2141. // return
  2142. // }
  2143. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2144. // res2.Output = resSix10265.Output
  2145. // res2.ErrMsg = resSix10265.ErrMsg
  2146. // res2.Cainfo = resSix10265.Cainfo
  2147. // res2.WarnMsg = resSix10265.WarnMsg
  2148. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2149. // res2.Infcode = infocode
  2150. //
  2151. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2152. // data := make(map[string]interface{})
  2153. // data["struct_3501s"] = struct3501
  2154. // client := &http.Client{}
  2155. // bytesData, _ := json.Marshal(data)
  2156. // var req *http.Request
  2157. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2158. // resp, _ := client.Do(req)
  2159. // defer resp.Body.Close()
  2160. // body, ioErr := ioutil.ReadAll(resp.Body)
  2161. // if ioErr != nil {
  2162. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2163. // }
  2164. // var respJSON map[string]interface{}
  2165. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2166. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2168. // return
  2169. // }
  2170. // var resSix10265 ResultSix10265 //1101结果
  2171. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2172. // result, _ := json.Marshal(respJSON)
  2173. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2174. // utils.ErrorLog("解析失败:%v", err)
  2175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2176. // return
  2177. // }
  2178. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2179. // res2.Output = resSix10265.Output
  2180. // res2.ErrMsg = resSix10265.ErrMsg
  2181. // res2.Cainfo = resSix10265.Cainfo
  2182. // res2.WarnMsg = resSix10265.WarnMsg
  2183. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2184. // res2.Infcode = infocode
  2185. //
  2186. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2187. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2188. // saveLog(result1, result2, "3501", "3501")
  2189. // //saveLog(result, requestLog, "2201", "挂号")
  2190. //
  2191. // var respJSON2 map[string]interface{}
  2192. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2195. // return
  2196. // }
  2197. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2198. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2199. // utils.ErrorLog("解析失败:%v", err)
  2200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. // return
  2202. // }
  2203. //
  2204. // }
  2205. //
  2206. // if res2.Infcode != -1 {
  2207. // drug.IsPc = 1
  2208. // drug.Bchno = number
  2209. // drug.PcDate = time.Now().Unix()
  2210. // err := service.SaveW(drug)
  2211. // if err == nil {
  2212. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2213. // var struct3502 models.Struct3502
  2214. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2216. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2217. // struct3502.FixmedinsCode = miConfig.Code
  2218. // struct3502.Code = miConfig.Code
  2219. //
  2220. // struct3502.RxFlag = "0"
  2221. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2222. // struct3502.OrgName = miConfig.OrgName
  2223. // struct3502.Opter = roles.UserName
  2224. // struct3502.AccessKey = miConfig.AccessKey
  2225. // struct3502.RequestUrl = miConfig.Url
  2226. // struct3502.SecretKey = miConfig.SecretKey
  2227. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2228. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2229. // struct3502.Url = miConfig.Url
  2230. // struct3502.AppId = miConfig.Cainfo
  2231. // struct3502.AppSecret = miConfig.AppSecret
  2232. // struct3502.Enckey = miConfig.EncKey
  2233. // struct3502.SignKey = miConfig.SignKey
  2234. // struct3502.SecretKey = miConfig.SecretKey
  2235. // struct3502.DrugTracCodg = drug.DrugCode
  2236. //
  2237. // struct3502.Memo = ""
  2238. // struct3502.InvChgType = "108"
  2239. // struct3502.FixmedinsBchno = bg_number
  2240. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2241. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2242. //
  2243. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2244. // result11, result22, _ := service.FJyb3502(struct3502)
  2245. // saveLog(result11, result22, "3502", "3502")
  2246. //
  2247. // var respJSON3 map[string]interface{}
  2248. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2249. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2251. // return
  2252. // }
  2253. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2254. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2255. // utils.ErrorLog("解析失败:%v", err)
  2256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2257. // return
  2258. // }
  2259. //
  2260. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2261. // data := make(map[string]interface{})
  2262. // data["struct_3502s"] = struct3502
  2263. // client := &http.Client{}
  2264. // bytesData, _ := json.Marshal(data)
  2265. // var req *http.Request
  2266. // if miConfig.MdtrtareaAdmvs == "320921" {
  2267. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2268. // } else {
  2269. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2270. // }
  2271. //
  2272. // resp, _ := client.Do(req)
  2273. // defer resp.Body.Close()
  2274. // body, ioErr := ioutil.ReadAll(resp.Body)
  2275. // if ioErr != nil {
  2276. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2277. // }
  2278. // var respJSON map[string]interface{}
  2279. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2280. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2282. // return
  2283. // }
  2284. // var resSix10265 ResultSix10265 //1101结果
  2285. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2286. // result, _ := json.Marshal(respJSON)
  2287. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2288. // utils.ErrorLog("解析失败:%v", err)
  2289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2290. // return
  2291. // }
  2292. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2293. // res3.Output = resSix10265.Output
  2294. // res3.ErrMsg = resSix10265.ErrMsg
  2295. // res3.Cainfo = resSix10265.Cainfo
  2296. // res3.WarnMsg = resSix10265.WarnMsg
  2297. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2298. // res3.Infcode = infocode
  2299. //
  2300. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2301. //
  2302. // data := make(map[string]interface{})
  2303. // data["struct_3502s"] = struct3502
  2304. // client := &http.Client{}
  2305. // bytesData, _ := json.Marshal(data)
  2306. // var req *http.Request
  2307. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2308. // resp, _ := client.Do(req)
  2309. // defer resp.Body.Close()
  2310. // body, ioErr := ioutil.ReadAll(resp.Body)
  2311. // if ioErr != nil {
  2312. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2313. // }
  2314. // var respJSON map[string]interface{}
  2315. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2316. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2318. // return
  2319. // }
  2320. // var resSix10265 ResultSix10265 //1101结果
  2321. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2322. // result, _ := json.Marshal(respJSON)
  2323. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2324. // utils.ErrorLog("解析失败:%v", err)
  2325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2326. // return
  2327. // }
  2328. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2329. // res3.Output = resSix10265.Output
  2330. // res3.ErrMsg = resSix10265.ErrMsg
  2331. // res3.Cainfo = resSix10265.Cainfo
  2332. // res3.WarnMsg = resSix10265.WarnMsg
  2333. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2334. // res3.Infcode = infocode
  2335. //
  2336. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2337. //
  2338. // data := make(map[string]interface{})
  2339. // data["struct_3501s"] = struct3501
  2340. // client := &http.Client{}
  2341. // bytesData, _ := json.Marshal(data)
  2342. // var req *http.Request
  2343. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2344. // resp, _ := client.Do(req)
  2345. // defer resp.Body.Close()
  2346. // body, ioErr := ioutil.ReadAll(resp.Body)
  2347. // if ioErr != nil {
  2348. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2349. // }
  2350. // var respJSON map[string]interface{}
  2351. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2352. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2354. // return
  2355. // }
  2356. // var resSix10265 ResultSix10265 //1101结果
  2357. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2358. // result, _ := json.Marshal(respJSON)
  2359. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2360. // utils.ErrorLog("解析失败:%v", err)
  2361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2362. // return
  2363. // }
  2364. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2365. // res2.Output = resSix10265.Output
  2366. // res2.ErrMsg = resSix10265.ErrMsg
  2367. // res2.Cainfo = resSix10265.Cainfo
  2368. // res2.WarnMsg = resSix10265.WarnMsg
  2369. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2370. // res2.Infcode = infocode
  2371. //
  2372. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2373. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2374. // saveLog(result11, result22, "3502", "3502")
  2375. //
  2376. // var respJSON3 map[string]interface{}
  2377. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. // return
  2381. // }
  2382. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2383. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2384. // utils.ErrorLog("解析失败:%v", err)
  2385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2386. // return
  2387. // }
  2388. // }
  2389. // if res3.Infcode == -1 {
  2390. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2391. // c.ServeSuccessJSON(map[string]interface{}{
  2392. // "failed_code": -10,
  2393. // "msg": res3.ErrMsg,
  2394. // })
  2395. // } else {
  2396. // drug.IsBg = 1
  2397. // drug.BgBchno = bg_number
  2398. // service.SaveW(drug)
  2399. // }
  2400. // }
  2401. // } else {
  2402. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2403. // }
  2404. // }
  2405. // //变更
  2406. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2407. // var res3 ResultSix
  2408. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2409. //
  2410. // var struct3502 models.Struct3502
  2411. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2413. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2414. // struct3502.FixmedinsCode = miConfig.Code
  2415. // struct3502.Code = miConfig.Code
  2416. //
  2417. // struct3502.Opter = roles.UserName
  2418. // struct3502.RxFlag = "0"
  2419. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2420. // struct3502.OrgName = miConfig.OrgName
  2421. // struct3502.AccessKey = miConfig.AccessKey
  2422. // struct3502.RequestUrl = miConfig.Url
  2423. // struct3502.SecretKey = miConfig.SecretKey
  2424. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2425. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2426. // struct3502.InvChgType = "108"
  2427. // struct3502.DrugTracCodg = drug.DrugCode
  2428. //
  2429. // struct3502.Url = miConfig.Url
  2430. // struct3502.AppId = miConfig.Cainfo
  2431. // struct3502.AppSecret = miConfig.AppSecret
  2432. // struct3502.Enckey = miConfig.EncKey
  2433. // struct3502.SignKey = miConfig.SignKey
  2434. // struct3502.SecretKey = miConfig.SecretKey
  2435. //
  2436. // struct3502.FixmedinsBchno = bg_number
  2437. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2438. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2439. //
  2440. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2441. // result1, result2, _ := service.FJyb3502(struct3502)
  2442. // saveLog(result1, result2, "3502", "3502")
  2443. // var respJSON3 map[string]interface{}
  2444. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2445. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2447. // return
  2448. // }
  2449. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2450. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2451. // utils.ErrorLog("解析失败:%v", err)
  2452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2453. // return
  2454. // }
  2455. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2456. // data := make(map[string]interface{})
  2457. // data["struct_3502s"] = struct3502
  2458. // client := &http.Client{}
  2459. // bytesData, _ := json.Marshal(data)
  2460. // var req *http.Request
  2461. // if miConfig.MdtrtareaAdmvs == "320921" {
  2462. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2463. // } else {
  2464. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2465. // }
  2466. // resp, _ := client.Do(req)
  2467. // defer resp.Body.Close()
  2468. // body, ioErr := ioutil.ReadAll(resp.Body)
  2469. // if ioErr != nil {
  2470. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2471. // }
  2472. // var respJSON map[string]interface{}
  2473. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2476. // return
  2477. // }
  2478. // var resSix10265 ResultSix10265 //1101结果
  2479. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2480. // result, _ := json.Marshal(respJSON)
  2481. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2482. // utils.ErrorLog("解析失败:%v", err)
  2483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2484. // return
  2485. // }
  2486. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2487. // res3.Output = resSix10265.Output
  2488. // res3.ErrMsg = resSix10265.ErrMsg
  2489. // res3.Cainfo = resSix10265.Cainfo
  2490. // res3.WarnMsg = resSix10265.WarnMsg
  2491. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2492. // res3.Infcode = infocode
  2493. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2494. //
  2495. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2496. //
  2497. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2498. //
  2499. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2500. //
  2501. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2502. // saveLog(result1, result2, "3501", "3501")
  2503. // //saveLog(result, requestLog, "2201", "挂号")
  2504. //
  2505. // var respJSON2 map[string]interface{}
  2506. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2507. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. // return
  2510. // }
  2511. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2512. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2513. // utils.ErrorLog("解析失败:%v", err)
  2514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2515. // return
  2516. // }
  2517. //
  2518. // }
  2519. // if res3.Infcode == -1 {
  2520. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2521. // } else {
  2522. // drug.IsBg = 1
  2523. // drug.BgBchno = bg_number
  2524. // service.SaveW(drug)
  2525. // }
  2526. // }
  2527. // }
  2528. //
  2529. // if len(errs) == 0 {
  2530. // c.ServeSuccessJSON(map[string]interface{}{
  2531. // "msg": "盘存变更成功",
  2532. // })
  2533. // } else {
  2534. // c.ServeSuccessJSON(map[string]interface{}{
  2535. // "failed_code": -10,
  2536. // "msg": errs,
  2537. // })
  2538. // }
  2539. //}
  2540. func (c *HisApiController) DeleteXSandBGTwo() {
  2541. patient_id, _ := c.GetInt64("patient_id")
  2542. admin_user_id, _ := c.GetInt64("admin_user_id")
  2543. times := c.GetString("time", "")
  2544. timeLayout := "2006-01-02"
  2545. loc, _ := time.LoadLocation("Local")
  2546. var stime, etime int64
  2547. if times == "" {
  2548. stime, etime = GetNowTime()
  2549. } else {
  2550. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2551. stime = stmp.Unix()
  2552. etime = stime + 86399
  2553. }
  2554. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2555. var flows []*models.DrugFlow
  2556. for _, item := range advicelist {
  2557. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2558. flows = append(flows, flow...)
  2559. }
  2560. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2561. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2562. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2563. var err []string
  2564. for _, item := range flows {
  2565. if item.IsSale == 1 {
  2566. var res FJ3507Result
  2567. var struct3507 models.Struct3507
  2568. struct3507.FixmedinsBchno = item.Bchno
  2569. struct3507.InvDataType = "4"
  2570. struct3507.Opter = roles.UserName
  2571. struct3507.OrgName = miConfig.OrgName
  2572. struct3507.AccessKey = miConfig.AccessKey
  2573. struct3507.RequestUrl = miConfig.Url
  2574. struct3507.FixmedinsCode = miConfig.Code
  2575. struct3507.SecretKey = miConfig.SecretKey
  2576. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2577. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2578. struct3507.Url = miConfig.Url
  2579. struct3507.AppId = miConfig.Cainfo
  2580. struct3507.AppSecret = miConfig.AppSecret
  2581. struct3507.Enckey = miConfig.EncKey
  2582. struct3507.SignKey = miConfig.SignKey
  2583. struct3507.SecretKey = miConfig.SecretKey
  2584. if miConfig.MdtrtareaAdmvs == "350500" {
  2585. result, result1, _ := service.FJyb3507(struct3507)
  2586. saveLog(result, result1, "3507", "3507")
  2587. var respJSON2 map[string]interface{}
  2588. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2591. return
  2592. }
  2593. userJSONBytes2, _ := json.Marshal(respJSON2)
  2594. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2595. utils.ErrorLog("解析失败:%v", err)
  2596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2597. return
  2598. }
  2599. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2600. data := make(map[string]interface{})
  2601. data["struct_3507s"] = struct3507
  2602. client := &http.Client{}
  2603. bytesData, _ := json.Marshal(data)
  2604. var req *http.Request
  2605. if miConfig.MdtrtareaAdmvs == "320921" {
  2606. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2607. } else {
  2608. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2609. }
  2610. resp, _ := client.Do(req)
  2611. defer resp.Body.Close()
  2612. body, ioErr := ioutil.ReadAll(resp.Body)
  2613. if ioErr != nil {
  2614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2615. }
  2616. var respJSON map[string]interface{}
  2617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2620. return
  2621. }
  2622. var resSix10265 ResultSix10265 //1101结果
  2623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2624. result, _ := json.Marshal(respJSON)
  2625. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2626. utils.ErrorLog("解析失败:%v", err)
  2627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. return
  2629. }
  2630. res.InfRefmsgid = resSix10265.InfRefmsgid
  2631. //res.Output = resSix10265.Output
  2632. res.ErrMsg = resSix10265.ErrMsg
  2633. res.Cainfo = resSix10265.Cainfo
  2634. res.WarnMsg = resSix10265.WarnMsg
  2635. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2636. res.Infcode = infocode
  2637. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2638. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2639. saveLog(result2, result1, "3507", "3507")
  2640. var respJSON2 map[string]interface{}
  2641. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. return
  2645. }
  2646. userJSONBytes2, _ := json.Marshal(respJSON2)
  2647. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2648. utils.ErrorLog("解析失败:%v", err)
  2649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2650. return
  2651. }
  2652. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2653. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2654. saveLog(result2, result1, "3507", "3507")
  2655. var respJSON2 map[string]interface{}
  2656. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. return
  2660. }
  2661. userJSONBytes2, _ := json.Marshal(respJSON2)
  2662. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2663. utils.ErrorLog("解析失败:%v", err)
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2668. result1, result2 := service.Jxyb3507(struct3507)
  2669. saveLog(result2, result1, "3507", "3507")
  2670. var respJSON2 map[string]interface{}
  2671. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2674. return
  2675. }
  2676. userJSONBytes2, _ := json.Marshal(respJSON2)
  2677. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2678. utils.ErrorLog("解析失败:%v", err)
  2679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2680. return
  2681. }
  2682. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2683. result1, result2 := service.AHyb3507(struct3507)
  2684. saveLog(result2, result1, "3507", "3507")
  2685. var respJSON2 map[string]interface{}
  2686. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2689. return
  2690. }
  2691. userJSONBytes2, _ := json.Marshal(respJSON2)
  2692. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2693. utils.ErrorLog("解析失败:%v", err)
  2694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2695. return
  2696. }
  2697. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2698. data := make(map[string]interface{})
  2699. data["struct_3507s"] = struct3507
  2700. client := &http.Client{}
  2701. bytesData, _ := json.Marshal(data)
  2702. var req *http.Request
  2703. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2704. resp, _ := client.Do(req)
  2705. defer resp.Body.Close()
  2706. body, ioErr := ioutil.ReadAll(resp.Body)
  2707. if ioErr != nil {
  2708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2709. }
  2710. var respJSON map[string]interface{}
  2711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2713. }
  2714. var resSix10265 ResultSix10265 //1101结果
  2715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2716. result, _ := json.Marshal(respJSON)
  2717. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2718. utils.ErrorLog("解析失败:%v", err)
  2719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2720. return
  2721. }
  2722. res.InfRefmsgid = resSix10265.InfRefmsgid
  2723. res.ErrMsg = resSix10265.ErrMsg
  2724. res.Cainfo = resSix10265.Cainfo
  2725. res.WarnMsg = resSix10265.WarnMsg
  2726. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2727. res.Infcode = infocode
  2728. }
  2729. if res.Infcode == 0 {
  2730. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2731. item.IsSale = 0
  2732. item.SaleDate = ""
  2733. item.Bchno = ""
  2734. service.SaveDF(item)
  2735. } else {
  2736. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2737. }
  2738. }
  2739. }
  2740. c.ServeSuccessJSON(map[string]interface{}{
  2741. "msg": "删除销售数据成功",
  2742. })
  2743. }
  2744. // 删除
  2745. func (c *HisApiController) DeleteXSandBGThree() {
  2746. id, _ := c.GetInt64("id")
  2747. admin_user_id, _ := c.GetInt64("admin_user_id")
  2748. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2749. var flows []*models.DrugFlow
  2750. for _, item := range advicelist {
  2751. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2752. flows = append(flows, flow...)
  2753. }
  2754. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2755. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2756. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2757. var err []string
  2758. for _, item := range flows {
  2759. if item.IsSale == 1 {
  2760. var res FJ3507Result
  2761. var struct3507 models.Struct3507
  2762. struct3507.FixmedinsBchno = item.Bchno
  2763. struct3507.InvDataType = "4"
  2764. struct3507.Opter = roles.UserName
  2765. struct3507.OrgName = miConfig.OrgName
  2766. struct3507.AccessKey = miConfig.AccessKey
  2767. struct3507.RequestUrl = miConfig.Url
  2768. struct3507.FixmedinsCode = miConfig.Code
  2769. struct3507.SecretKey = miConfig.SecretKey
  2770. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2771. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2772. struct3507.Url = miConfig.Url
  2773. struct3507.AppId = miConfig.Cainfo
  2774. struct3507.AppSecret = miConfig.AppSecret
  2775. struct3507.Enckey = miConfig.EncKey
  2776. struct3507.SignKey = miConfig.SignKey
  2777. struct3507.SecretKey = miConfig.SecretKey
  2778. if miConfig.MdtrtareaAdmvs == "350500" {
  2779. result, result1, _ := service.FJyb3507(struct3507)
  2780. saveLog(result, result1, "3507", "3507")
  2781. var respJSON2 map[string]interface{}
  2782. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2785. return
  2786. }
  2787. userJSONBytes2, _ := json.Marshal(respJSON2)
  2788. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2789. utils.ErrorLog("解析失败:%v", err)
  2790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2791. return
  2792. }
  2793. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2794. data := make(map[string]interface{})
  2795. data["struct_3507s"] = struct3507
  2796. client := &http.Client{}
  2797. bytesData, _ := json.Marshal(data)
  2798. var req *http.Request
  2799. if miConfig.MdtrtareaAdmvs == "320921" {
  2800. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2801. } else {
  2802. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2803. }
  2804. resp, _ := client.Do(req)
  2805. defer resp.Body.Close()
  2806. body, ioErr := ioutil.ReadAll(resp.Body)
  2807. if ioErr != nil {
  2808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2809. }
  2810. var respJSON map[string]interface{}
  2811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2814. return
  2815. }
  2816. var resSix10265 ResultSix10265 //1101结果
  2817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2818. result, _ := json.Marshal(respJSON)
  2819. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2820. utils.ErrorLog("解析失败:%v", err)
  2821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2822. return
  2823. }
  2824. res.InfRefmsgid = resSix10265.InfRefmsgid
  2825. //res.Output = resSix10265.Output
  2826. res.ErrMsg = resSix10265.ErrMsg
  2827. res.Cainfo = resSix10265.Cainfo
  2828. res.WarnMsg = resSix10265.WarnMsg
  2829. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2830. res.Infcode = infocode
  2831. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2832. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2833. saveLog(result2, result1, "3507", "3507")
  2834. var respJSON2 map[string]interface{}
  2835. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2838. return
  2839. }
  2840. userJSONBytes2, _ := json.Marshal(respJSON2)
  2841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2842. utils.ErrorLog("解析失败:%v", err)
  2843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2844. return
  2845. }
  2846. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2847. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2848. saveLog(result2, result1, "3507", "3507")
  2849. var respJSON2 map[string]interface{}
  2850. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2853. return
  2854. }
  2855. userJSONBytes2, _ := json.Marshal(respJSON2)
  2856. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2857. utils.ErrorLog("解析失败:%v", err)
  2858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2859. return
  2860. }
  2861. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2862. result1, result2 := service.Jxyb3507(struct3507)
  2863. saveLog(result2, result1, "3507", "3507")
  2864. var respJSON2 map[string]interface{}
  2865. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2868. return
  2869. }
  2870. userJSONBytes2, _ := json.Marshal(respJSON2)
  2871. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2872. utils.ErrorLog("解析失败:%v", err)
  2873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. return
  2875. }
  2876. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2877. result1, result2 := service.AHyb3507(struct3507)
  2878. saveLog(result2, result1, "3507", "3507")
  2879. var respJSON2 map[string]interface{}
  2880. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2883. return
  2884. }
  2885. userJSONBytes2, _ := json.Marshal(respJSON2)
  2886. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2887. utils.ErrorLog("解析失败:%v", err)
  2888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2889. return
  2890. }
  2891. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2892. data := make(map[string]interface{})
  2893. data["struct_3507s"] = struct3507
  2894. client := &http.Client{}
  2895. bytesData, _ := json.Marshal(data)
  2896. var req *http.Request
  2897. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2898. resp, _ := client.Do(req)
  2899. defer resp.Body.Close()
  2900. body, ioErr := ioutil.ReadAll(resp.Body)
  2901. if ioErr != nil {
  2902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2903. }
  2904. var respJSON map[string]interface{}
  2905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2907. }
  2908. var resSix10265 ResultSix10265 //1101结果
  2909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2910. result, _ := json.Marshal(respJSON)
  2911. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2912. utils.ErrorLog("解析失败:%v", err)
  2913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2914. return
  2915. }
  2916. res.InfRefmsgid = resSix10265.InfRefmsgid
  2917. res.ErrMsg = resSix10265.ErrMsg
  2918. res.Cainfo = resSix10265.Cainfo
  2919. res.WarnMsg = resSix10265.WarnMsg
  2920. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2921. res.Infcode = infocode
  2922. }
  2923. if res.Infcode == 0 {
  2924. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2925. item.IsSale = 0
  2926. item.SaleDate = ""
  2927. item.Bchno = ""
  2928. service.SaveDF(item)
  2929. } else {
  2930. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2931. }
  2932. }
  2933. }
  2934. c.ServeSuccessJSON(map[string]interface{}{
  2935. "msg": "删除销售数据成功",
  2936. })
  2937. }
  2938. // 获取当天起止时间戳
  2939. func GetNowTime() (int64, int64) {
  2940. t := time.Now()
  2941. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2942. timesamp := addTime.Unix()
  2943. return timesamp, timesamp + 86399
  2944. }
  2945. func (c *HisApiController) ChangeDrugfour() {
  2946. patient_id, _ := c.GetInt64("patient_id")
  2947. admin_user_id, _ := c.GetInt64("admin_user_id")
  2948. times := c.GetString("time", "")
  2949. timeLayout := "2006-01-02"
  2950. loc, _ := time.LoadLocation("Local")
  2951. var stime, etime int64
  2952. if times == "" {
  2953. stime, etime = GetNowTime()
  2954. } else {
  2955. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2956. stime = stmp.Unix()
  2957. etime = stime + 86399
  2958. }
  2959. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2960. var flows []*models.DrugFlow
  2961. for _, item := range advicelist {
  2962. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2963. flows = append(flows, flow...)
  2964. }
  2965. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2966. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2967. var err []string
  2968. for _, item := range flows {
  2969. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2970. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2971. if prescription.OrderStatus == 2 {
  2972. if item.IsSale == 0 {
  2973. var res FJ3507Result
  2974. var res3507for10188 FJ3507ResultFor10188
  2975. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2976. //进行商品销售接口
  2977. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2978. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2979. var respJSON3 map[string]interface{}
  2980. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2983. return
  2984. }
  2985. userJSONBytes3, _ := json.Marshal(respJSON3)
  2986. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2987. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2988. utils.ErrorLog("解析失败:%v", err)
  2989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2990. return
  2991. }
  2992. //if res3507for10188.Infcode
  2993. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2994. //res.Output = resSix10265.Output
  2995. res.ErrMsg = res3507for10188.ErrMsg
  2996. res.Cainfo = res3507for10188.Cainfo
  2997. res.WarnMsg = res3507for10188.WarnMsg
  2998. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2999. res.Infcode = infocode
  3000. } else {
  3001. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3002. utils.ErrorLog("解析失败:%v", err)
  3003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3004. return
  3005. }
  3006. }
  3007. if res.Infcode == 0 {
  3008. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3009. item.IsSale = 1
  3010. item.Bchno = number
  3011. item.SaleDate = time.Now().Format("2006-01-02")
  3012. service.SaveDF(item)
  3013. } else {
  3014. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3015. }
  3016. }
  3017. } else { //还没结,提示用户去结算,并药品追溯上传
  3018. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3019. }
  3020. }
  3021. }
  3022. str := strings.Join(err, " ")
  3023. saveLog(str, str, "3505", "3505自动上传日志")
  3024. c.ServeSuccessJSON(map[string]interface{}{
  3025. "status": "1",
  3026. "msg": err,
  3027. })
  3028. }
  3029. func (c *HisApiController) ChangeDrugFive() {
  3030. id, _ := c.GetInt64("id")
  3031. admin_user_id, _ := c.GetInt64("admin_user_id")
  3032. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3033. var flows []*models.DrugFlow
  3034. for _, item := range advicelist {
  3035. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3036. flows = append(flows, flow...)
  3037. }
  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.ConsumableType == 3 { //3为自动出库 7为自动退库
  3043. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3044. if prescription.OrderStatus == 2 {
  3045. if item.IsSale == 0 {
  3046. var res FJ3507Result
  3047. var res3507for10188 FJ3507ResultFor10188
  3048. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3049. //进行商品销售接口
  3050. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3051. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3052. var respJSON3 map[string]interface{}
  3053. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3056. return
  3057. }
  3058. userJSONBytes3, _ := json.Marshal(respJSON3)
  3059. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3060. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3061. utils.ErrorLog("解析失败:%v", err)
  3062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3063. return
  3064. }
  3065. //if res3507for10188.Infcode
  3066. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3067. //res.Output = resSix10265.Output
  3068. res.ErrMsg = res3507for10188.ErrMsg
  3069. res.Cainfo = res3507for10188.Cainfo
  3070. res.WarnMsg = res3507for10188.WarnMsg
  3071. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3072. res.Infcode = infocode
  3073. } else {
  3074. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3075. utils.ErrorLog("解析失败:%v", err)
  3076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3077. return
  3078. }
  3079. }
  3080. if res.Infcode == 0 {
  3081. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3082. item.IsSale = 1
  3083. item.Bchno = number
  3084. item.SaleDate = time.Now().Format("2006-01-02")
  3085. service.SaveDF(item)
  3086. } else {
  3087. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3088. }
  3089. }
  3090. } else { //还没结,提示用户去结算,并药品追溯上传
  3091. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3092. }
  3093. }
  3094. }
  3095. str := strings.Join(err, " ")
  3096. saveLog(str, str, "3505", "3505自动上传日志")
  3097. c.ServeSuccessJSON(map[string]interface{}{
  3098. "status": "1",
  3099. "msg": err,
  3100. })
  3101. }
  3102. //func (c *HisApiController) ChangeDrugfour() {
  3103. // patient_id, _ := c.GetInt64("patient_id")
  3104. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3105. // //id_arr := strings.Split(ids, ",")
  3106. // times := c.GetString("time", "")
  3107. // timeLayout := "2006-01-02"
  3108. // loc, _ := time.LoadLocation("Local")
  3109. // var stime, etime int64
  3110. // if times == "" {
  3111. // stime, etime = GetNowTime()
  3112. // } else {
  3113. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3114. // stime = stmp.Unix()
  3115. // etime = stime + 86399
  3116. // }
  3117. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3118. // var flows []*models.DrugFlow
  3119. // for _, item := range advicelist {
  3120. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3121. // flows = append(flows, flow...)
  3122. // }
  3123. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3124. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3125. // var err []string
  3126. //
  3127. // for _, item := range flows {
  3128. // var res3 ResultSix
  3129. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3130. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3131. // if prescription.OrderStatus == 2 {
  3132. // //已经结算
  3133. // //判断是否已经销售
  3134. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3135. // //是否已经变更 1是 0否
  3136. // if item.IsChange == 0 { //没变更,进行变更操作
  3137. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3138. //
  3139. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3140. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3141. // var respJSON3 map[string]interface{}
  3142. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3143. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3145. // return
  3146. // }
  3147. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3148. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3149. // utils.ErrorLog("解析失败:%v", err)
  3150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3151. // return
  3152. // }
  3153. // if res3.Infcode == 0 {
  3154. // item.IsChange = 1
  3155. // item.BgBchno = bg_number
  3156. // service.SaveDF2(item)
  3157. // } else {
  3158. //
  3159. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3160. // }
  3161. // }
  3162. // } else { //没销售,
  3163. // var res FJ3507Result
  3164. // var res3507for10188 FJ3507ResultFor10188
  3165. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3166. //
  3167. // //进行商品销售接口
  3168. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3169. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3170. // var respJSON3 map[string]interface{}
  3171. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3172. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3174. // return
  3175. // }
  3176. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3177. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3178. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3179. // utils.ErrorLog("解析失败:%v", err)
  3180. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3181. // return
  3182. // }
  3183. // //if res3507for10188.Infcode
  3184. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3185. // //res.Output = resSix10265.Output
  3186. // res.ErrMsg = res3507for10188.ErrMsg
  3187. // res.Cainfo = res3507for10188.Cainfo
  3188. // res.WarnMsg = res3507for10188.WarnMsg
  3189. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3190. // res.Infcode = infocode
  3191. // } else {
  3192. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3193. // utils.ErrorLog("解析失败:%v", err)
  3194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3195. // return
  3196. // }
  3197. //
  3198. // }
  3199. // if res.Infcode == 0 {
  3200. // item.IsSale = 1
  3201. // item.Bchno = number
  3202. // item.SaleDate = time.Now().Format("2006-01-02")
  3203. //
  3204. // err5 := service.SaveDF(item)
  3205. // if err5 == nil {
  3206. // if item.IsChange == 0 { //没变更,进行变更操作
  3207. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3208. //
  3209. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3210. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3211. //
  3212. // var respJSON3 map[string]interface{}
  3213. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3214. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3216. // return
  3217. // }
  3218. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3219. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3220. // utils.ErrorLog("解析失败:%v", err)
  3221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3222. // return
  3223. // }
  3224. // //if res3507for10188.Infcode
  3225. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3226. // //res.Output = resSix10265.Output
  3227. // res3.ErrMsg = res3507for10188.ErrMsg
  3228. // res3.Cainfo = res3507for10188.Cainfo
  3229. // res3.WarnMsg = res3507for10188.WarnMsg
  3230. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3231. // res3.Infcode = infocode
  3232. // } else {
  3233. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3234. // utils.ErrorLog("解析失败:%v", err)
  3235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3236. // return
  3237. // }
  3238. // }
  3239. // if res3.Infcode == 0 {
  3240. // item.IsChange = 1
  3241. // item.BgBchno = bg_number
  3242. // service.SaveDF2(item)
  3243. // } else {
  3244. //
  3245. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3246. // }
  3247. // }
  3248. // }
  3249. // } else {
  3250. //
  3251. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3252. // }
  3253. // }
  3254. //
  3255. // } else { //还没结,提示用户去结算,并药品追溯上传
  3256. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3257. // }
  3258. // }
  3259. // }
  3260. // if len(err) == 0 {
  3261. // c.ServeSuccessJSON(map[string]interface{}{
  3262. // "msg": "销售变更成功",
  3263. // })
  3264. // } else {
  3265. // c.ServeSuccessJSON(map[string]interface{}{
  3266. // "failed_code": -10,
  3267. // "msg": err,
  3268. // })
  3269. // }
  3270. //}
  3271. func (c *HisApiController) ChangeDrug() {
  3272. ids := c.GetString("ids")
  3273. id_arr := strings.Split(ids, ",")
  3274. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3275. admin_user_id, _ := c.GetInt64("admin_user_id")
  3276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3278. var err []string
  3279. for _, item := range flows {
  3280. var res3 ResultSix
  3281. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3282. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3283. if prescription.OrderStatus == 2 {
  3284. //已经结算
  3285. //判断是否已经销售
  3286. if item.IsSale == 1 { //是否已经销售,1是 0否
  3287. //是否已经变更 1是 0否
  3288. if item.IsChange == 0 { //没变更,进行变更操作
  3289. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3290. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3291. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3292. var respJSON3 map[string]interface{}
  3293. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3296. return
  3297. }
  3298. userJSONBytes3, _ := json.Marshal(respJSON3)
  3299. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3300. utils.ErrorLog("解析失败:%v", err)
  3301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3302. return
  3303. }
  3304. if res3.Infcode == 0 {
  3305. item.IsChange = 1
  3306. item.BgBchno = bg_number
  3307. service.SaveDF2(item)
  3308. } else {
  3309. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3310. }
  3311. }
  3312. } else { //没销售,
  3313. var res FJ3507Result
  3314. var res3507for10188 FJ3507ResultFor10188
  3315. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3316. //进行商品销售接口
  3317. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3318. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3319. var respJSON3 map[string]interface{}
  3320. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3323. return
  3324. }
  3325. userJSONBytes3, _ := json.Marshal(respJSON3)
  3326. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3327. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3328. utils.ErrorLog("解析失败:%v", err)
  3329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3330. return
  3331. }
  3332. //if res3507for10188.Infcode
  3333. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3334. //res.Output = resSix10265.Output
  3335. res.ErrMsg = res3507for10188.ErrMsg
  3336. res.Cainfo = res3507for10188.Cainfo
  3337. res.WarnMsg = res3507for10188.WarnMsg
  3338. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3339. res.Infcode = infocode
  3340. } else {
  3341. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3342. utils.ErrorLog("解析失败:%v", err)
  3343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3344. return
  3345. }
  3346. }
  3347. if res.Infcode == 0 {
  3348. item.IsSale = 1
  3349. item.Bchno = number
  3350. item.SaleDate = time.Now().Format("2006-01-02")
  3351. err5 := service.SaveDF(item)
  3352. if err5 == nil {
  3353. if item.IsChange == 0 { //没变更,进行变更操作
  3354. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3355. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3356. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3357. var respJSON3 map[string]interface{}
  3358. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3361. return
  3362. }
  3363. userJSONBytes3, _ := json.Marshal(respJSON3)
  3364. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3365. utils.ErrorLog("解析失败:%v", err)
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3367. return
  3368. }
  3369. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3370. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3371. utils.ErrorLog("解析失败:%v", err)
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3373. return
  3374. }
  3375. //if res3507for10188.Infcode
  3376. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3377. //res.Output = resSix10265.Output
  3378. res3.ErrMsg = res3507for10188.ErrMsg
  3379. res3.Cainfo = res3507for10188.Cainfo
  3380. res3.WarnMsg = res3507for10188.WarnMsg
  3381. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3382. res3.Infcode = infocode
  3383. } else {
  3384. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3385. utils.ErrorLog("解析失败:%v", err)
  3386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3387. return
  3388. }
  3389. }
  3390. if res3.Infcode == 0 {
  3391. item.IsChange = 1
  3392. item.BgBchno = bg_number
  3393. service.SaveDF2(item)
  3394. } else {
  3395. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3396. }
  3397. }
  3398. }
  3399. } else {
  3400. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3401. }
  3402. }
  3403. } else { //还没结算
  3404. var res3507for10188 FJ3507ResultFor10188
  3405. if item.IsChange == 0 { //没变更,进行变更操作
  3406. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3407. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3408. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3409. var respJSON3 map[string]interface{}
  3410. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3413. return
  3414. }
  3415. userJSONBytes3, _ := json.Marshal(respJSON3)
  3416. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3417. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3418. utils.ErrorLog("解析失败:%v", err)
  3419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3420. return
  3421. }
  3422. //if res3507for10188.Infcode
  3423. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3424. //res.Output = resSix10265.Output
  3425. res3.ErrMsg = res3507for10188.ErrMsg
  3426. res3.Cainfo = res3507for10188.Cainfo
  3427. res3.WarnMsg = res3507for10188.WarnMsg
  3428. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3429. res3.Infcode = infocode
  3430. } else {
  3431. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3432. utils.ErrorLog("解析失败:%v", err)
  3433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3434. return
  3435. }
  3436. }
  3437. if res3.Infcode == 0 {
  3438. item.IsChange = 1
  3439. item.BgBchno = bg_number
  3440. service.SaveDF2(item)
  3441. } else {
  3442. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3443. }
  3444. }
  3445. }
  3446. } else if item.ConsumableType == 7 {
  3447. var res3507for10188 FJ3507ResultFor10188
  3448. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3449. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3450. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3451. //判断是否已经销售
  3452. if item.IsSale == 2 { //是否已经销售,1是 0否
  3453. //是否已经变更 1是 0否
  3454. if item.IsChange == 0 { //没变更,进行变更操作
  3455. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3456. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3457. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3458. var respJSON3 map[string]interface{}
  3459. if err := json.Unmarshal([]byte(string(result)), &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. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3473. //res.Output = resSix10265.Output
  3474. res3.ErrMsg = res3507for10188.ErrMsg
  3475. res3.Cainfo = res3507for10188.Cainfo
  3476. res3.WarnMsg = res3507for10188.WarnMsg
  3477. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3478. res3.Infcode = infocode
  3479. } else {
  3480. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3481. utils.ErrorLog("解析失败:%v", err)
  3482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3483. return
  3484. }
  3485. }
  3486. if res3.Infcode == 0 {
  3487. item.IsChange = 1
  3488. item.BgBchno = bg_number
  3489. service.SaveDF2(item)
  3490. } else {
  3491. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3492. }
  3493. }
  3494. } else { //没销售,
  3495. //进行商品销售退货接口
  3496. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3497. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3498. saveLog(result111, result222, "3506", "销售退货")
  3499. var res7 FJ3507Result
  3500. //进行商品销售接口
  3501. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3502. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3503. var respJSON3 map[string]interface{}
  3504. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3507. return
  3508. }
  3509. userJSONBytes3, _ := json.Marshal(respJSON3)
  3510. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3511. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3512. utils.ErrorLog("解析失败:%v", err)
  3513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3514. return
  3515. }
  3516. //if res3507for10188.Infcode
  3517. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3518. //res.Output = resSix10265.Output
  3519. res7.ErrMsg = res3507for10188.ErrMsg
  3520. res7.Cainfo = res3507for10188.Cainfo
  3521. res7.WarnMsg = res3507for10188.WarnMsg
  3522. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3523. res7.Infcode = infocode
  3524. } else {
  3525. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3526. utils.ErrorLog("解析失败:%v", err)
  3527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3528. return
  3529. }
  3530. }
  3531. if res7.Infcode == 0 {
  3532. item.IsSale = 2
  3533. item.SaleDate = item.SaleDate
  3534. item.Bchno = number
  3535. service.SaveDF(item)
  3536. if item.IsChange == 0 { //没变更,进行变更操作
  3537. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3538. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3539. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3540. var respJSON3 map[string]interface{}
  3541. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3544. return
  3545. }
  3546. userJSONBytes3, _ := json.Marshal(respJSON3)
  3547. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3548. // utils.ErrorLog("解析失败:%v", err)
  3549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3550. // return
  3551. //}
  3552. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3553. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3554. utils.ErrorLog("解析失败:%v", err)
  3555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3556. return
  3557. }
  3558. //if res3507for10188.Infcode
  3559. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3560. //res.Output = resSix10265.Output
  3561. res3.ErrMsg = res3507for10188.ErrMsg
  3562. res3.Cainfo = res3507for10188.Cainfo
  3563. res3.WarnMsg = res3507for10188.WarnMsg
  3564. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3565. res3.Infcode = infocode
  3566. } else {
  3567. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3568. utils.ErrorLog("解析失败:%v", err)
  3569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3570. return
  3571. }
  3572. }
  3573. if res3.Infcode == 0 {
  3574. item.IsChange = 1
  3575. item.BgBchno = bg_number
  3576. service.SaveDF2(item)
  3577. } else {
  3578. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3579. }
  3580. }
  3581. } else {
  3582. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3583. }
  3584. }
  3585. } else { //还没结算
  3586. if item.IsChange == 0 { //没变更,进行变更操作
  3587. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3588. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3589. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3590. var respJSON3 map[string]interface{}
  3591. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3594. return
  3595. }
  3596. userJSONBytes3, _ := json.Marshal(respJSON3)
  3597. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3598. // utils.ErrorLog("解析失败:%v", err)
  3599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3600. // return
  3601. //}
  3602. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3603. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3604. utils.ErrorLog("解析失败:%v", err)
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. //if res3507for10188.Infcode
  3609. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3610. //res.Output = resSix10265.Output
  3611. res3.ErrMsg = res3507for10188.ErrMsg
  3612. res3.Cainfo = res3507for10188.Cainfo
  3613. res3.WarnMsg = res3507for10188.WarnMsg
  3614. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3615. res3.Infcode = infocode
  3616. } else {
  3617. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3618. utils.ErrorLog("解析失败:%v", err)
  3619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3620. return
  3621. }
  3622. }
  3623. if res3.Infcode == 0 {
  3624. item.IsChange = 1
  3625. item.BgBchno = bg_number
  3626. service.SaveDF2(item)
  3627. } else {
  3628. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3629. }
  3630. }
  3631. }
  3632. }
  3633. }
  3634. if len(err) == 0 {
  3635. c.ServeSuccessJSON(map[string]interface{}{
  3636. "msg": "销售变更成功",
  3637. })
  3638. } else {
  3639. c.ServeSuccessJSON(map[string]interface{}{
  3640. "failed_code": -10,
  3641. "msg": err,
  3642. })
  3643. }
  3644. }
  3645. func (c *HisApiController) ChangeDrugtwo() {
  3646. //ids := c.GetString("ids")
  3647. //id_arr := strings.Split(ids, ",")
  3648. flows, _ := service.GetNewDrugFlowInfothree123()
  3649. admin_user_id, _ := c.GetInt64("admin_user_id")
  3650. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3651. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3652. var err []string
  3653. for _, item := range flows {
  3654. var res3 ResultSix
  3655. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3656. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3657. if prescription.OrderStatus == 2 {
  3658. //已经结算
  3659. //判断是否已经销售
  3660. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3661. // //是否已经变更 1是 0否
  3662. // if item.IsChange == 0 { //没变更,进行变更操作
  3663. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3664. //
  3665. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3666. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3667. // var respJSON3 map[string]interface{}
  3668. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3669. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3671. // return
  3672. // }
  3673. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3674. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3675. // utils.ErrorLog("解析失败:%v", err)
  3676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3677. // return
  3678. // }
  3679. // if res3.Infcode == 0 {
  3680. // item.IsChange = 1
  3681. // item.BgBchno = bg_number
  3682. // service.SaveDF2(item)
  3683. // } else {
  3684. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3685. // }
  3686. // }
  3687. //}
  3688. //else
  3689. { //没销售,
  3690. var res FJ3507Result
  3691. var res3507for10188 FJ3507ResultFor10188
  3692. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3693. //进行商品销售接口
  3694. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3695. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3696. var respJSON3 map[string]interface{}
  3697. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3700. return
  3701. }
  3702. userJSONBytes3, _ := json.Marshal(respJSON3)
  3703. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3704. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3705. utils.ErrorLog("解析失败:%v", err)
  3706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3707. return
  3708. }
  3709. //if res3507for10188.Infcode
  3710. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3711. //res.Output = resSix10265.Output
  3712. res.ErrMsg = res3507for10188.ErrMsg
  3713. res.Cainfo = res3507for10188.Cainfo
  3714. res.WarnMsg = res3507for10188.WarnMsg
  3715. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3716. res.Infcode = infocode
  3717. } else {
  3718. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3719. utils.ErrorLog("解析失败:%v", err)
  3720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3721. return
  3722. }
  3723. }
  3724. if res.Infcode == 0 {
  3725. item.IsSale = 1
  3726. item.Bchno = number
  3727. item.SaleDate = time.Now().Format("2006-01-02")
  3728. service.SaveDF(item)
  3729. //if err5 == nil {
  3730. // if item.IsChange == 0 { //没变更,进行变更操作
  3731. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3732. //
  3733. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3734. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3735. //
  3736. // var respJSON3 map[string]interface{}
  3737. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3738. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3740. // return
  3741. // }
  3742. //
  3743. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3744. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3745. // utils.ErrorLog("解析失败:%v", err)
  3746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3747. // return
  3748. // }
  3749. // //if res3507for10188.Infcode
  3750. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3751. // //res.Output = resSix10265.Output
  3752. // res3.ErrMsg = res3507for10188.ErrMsg
  3753. // res3.Cainfo = res3507for10188.Cainfo
  3754. // res3.WarnMsg = res3507for10188.WarnMsg
  3755. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3756. // res3.Infcode = infocode
  3757. // } else {
  3758. //
  3759. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3760. // utils.ErrorLog("解析失败:%v", err)
  3761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3762. // return
  3763. // }
  3764. //
  3765. // }
  3766. //
  3767. // if res3.Infcode == 0 {
  3768. // item.IsChange = 1
  3769. // item.BgBchno = bg_number
  3770. // service.SaveDF2(item)
  3771. // } else {
  3772. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3773. // }
  3774. // }
  3775. //}
  3776. } else {
  3777. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3778. }
  3779. }
  3780. } else { //还没结算
  3781. var res3507for10188 FJ3507ResultFor10188
  3782. if item.IsChange == 0 { //没变更,进行变更操作
  3783. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3784. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3785. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3786. var respJSON3 map[string]interface{}
  3787. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3790. return
  3791. }
  3792. userJSONBytes3, _ := json.Marshal(respJSON3)
  3793. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3794. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3795. utils.ErrorLog("解析失败:%v", err)
  3796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3797. return
  3798. }
  3799. //if res3507for10188.Infcode
  3800. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3801. //res.Output = resSix10265.Output
  3802. res3.ErrMsg = res3507for10188.ErrMsg
  3803. res3.Cainfo = res3507for10188.Cainfo
  3804. res3.WarnMsg = res3507for10188.WarnMsg
  3805. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3806. res3.Infcode = infocode
  3807. } else {
  3808. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3809. utils.ErrorLog("解析失败:%v", err)
  3810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3811. return
  3812. }
  3813. }
  3814. if res3.Infcode == 0 {
  3815. item.IsChange = 1
  3816. item.BgBchno = bg_number
  3817. service.SaveDF2(item)
  3818. } else {
  3819. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3820. }
  3821. }
  3822. }
  3823. }
  3824. //if item.ConsumableType == 7 {
  3825. // var res3507for10188 FJ3507ResultFor10188
  3826. //
  3827. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3828. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3829. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3830. // //判断是否已经销售
  3831. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3832. // //是否已经变更 1是 0否
  3833. // if item.IsChange == 0 { //没变更,进行变更操作
  3834. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3835. //
  3836. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3837. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3838. //
  3839. // var respJSON3 map[string]interface{}
  3840. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3841. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. // return
  3844. // }
  3845. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3846. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3847. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3848. // utils.ErrorLog("解析失败:%v", err)
  3849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3850. // return
  3851. // }
  3852. // //if res3507for10188.Infcode
  3853. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3854. // //res.Output = resSix10265.Output
  3855. // res3.ErrMsg = res3507for10188.ErrMsg
  3856. // res3.Cainfo = res3507for10188.Cainfo
  3857. // res3.WarnMsg = res3507for10188.WarnMsg
  3858. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3859. // res3.Infcode = infocode
  3860. // } else {
  3861. //
  3862. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3863. // utils.ErrorLog("解析失败:%v", err)
  3864. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3865. // return
  3866. // }
  3867. //
  3868. // }
  3869. // if res3.Infcode == 0 {
  3870. // item.IsChange = 1
  3871. // item.BgBchno = bg_number
  3872. // service.SaveDF2(item)
  3873. // } else {
  3874. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3875. // }
  3876. // }
  3877. // } else { //没销售,
  3878. // //进行商品销售退货接口
  3879. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3880. //
  3881. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3882. // saveLog(result111, result222, "3506", "销售退货")
  3883. // var res7 FJ3507Result
  3884. //
  3885. // //进行商品销售接口
  3886. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3887. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3888. // var respJSON3 map[string]interface{}
  3889. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3890. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3892. // return
  3893. // }
  3894. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3895. //
  3896. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3897. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3898. // utils.ErrorLog("解析失败:%v", err)
  3899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3900. // return
  3901. // }
  3902. // //if res3507for10188.Infcode
  3903. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3904. // //res.Output = resSix10265.Output
  3905. // res7.ErrMsg = res3507for10188.ErrMsg
  3906. // res7.Cainfo = res3507for10188.Cainfo
  3907. // res7.WarnMsg = res3507for10188.WarnMsg
  3908. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3909. // res7.Infcode = infocode
  3910. // } else {
  3911. //
  3912. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3913. // utils.ErrorLog("解析失败:%v", err)
  3914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3915. // return
  3916. // }
  3917. //
  3918. // }
  3919. // if res7.Infcode == 0 {
  3920. // item.IsSale = 2
  3921. // item.SaleDate = item.SaleDate
  3922. // item.Bchno = number
  3923. // service.SaveDF(item)
  3924. // if item.IsChange == 0 { //没变更,进行变更操作
  3925. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3926. //
  3927. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3928. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3929. //
  3930. // var respJSON3 map[string]interface{}
  3931. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3932. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3934. // return
  3935. // }
  3936. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3937. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3938. // // utils.ErrorLog("解析失败:%v", err)
  3939. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3940. // // return
  3941. // //}
  3942. //
  3943. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3944. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3945. // utils.ErrorLog("解析失败:%v", err)
  3946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3947. // return
  3948. // }
  3949. // //if res3507for10188.Infcode
  3950. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3951. // //res.Output = resSix10265.Output
  3952. // res3.ErrMsg = res3507for10188.ErrMsg
  3953. // res3.Cainfo = res3507for10188.Cainfo
  3954. // res3.WarnMsg = res3507for10188.WarnMsg
  3955. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3956. // res3.Infcode = infocode
  3957. // } else {
  3958. //
  3959. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3960. // utils.ErrorLog("解析失败:%v", err)
  3961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. // return
  3963. // }
  3964. //
  3965. // }
  3966. // if res3.Infcode == 0 {
  3967. // item.IsChange = 1
  3968. // item.BgBchno = bg_number
  3969. // service.SaveDF2(item)
  3970. // } else {
  3971. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3972. // }
  3973. // }
  3974. // } else {
  3975. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3976. // }
  3977. // }
  3978. // } else { //还没结算
  3979. // if item.IsChange == 0 { //没变更,进行变更操作
  3980. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3981. //
  3982. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3983. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3984. //
  3985. // var respJSON3 map[string]interface{}
  3986. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3987. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3989. // return
  3990. // }
  3991. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3992. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3993. // // utils.ErrorLog("解析失败:%v", err)
  3994. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. // // return
  3996. // //}
  3997. //
  3998. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3999. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4000. // utils.ErrorLog("解析失败:%v", err)
  4001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4002. // return
  4003. // }
  4004. // //if res3507for10188.Infcode
  4005. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4006. // //res.Output = resSix10265.Output
  4007. // res3.ErrMsg = res3507for10188.ErrMsg
  4008. // res3.Cainfo = res3507for10188.Cainfo
  4009. // res3.WarnMsg = res3507for10188.WarnMsg
  4010. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4011. // res3.Infcode = infocode
  4012. // } else {
  4013. //
  4014. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4015. // utils.ErrorLog("解析失败:%v", err)
  4016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4017. // return
  4018. // }
  4019. //
  4020. // }
  4021. // if res3.Infcode == 0 {
  4022. // item.IsChange = 1
  4023. // item.BgBchno = bg_number
  4024. // service.SaveDF2(item)
  4025. // } else {
  4026. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4027. // }
  4028. // }
  4029. // }
  4030. //}
  4031. }
  4032. if len(err) == 0 {
  4033. c.ServeSuccessJSON(map[string]interface{}{
  4034. "msg": "销售变更成功",
  4035. })
  4036. } else {
  4037. c.ServeSuccessJSON(map[string]interface{}{
  4038. "failed_code": -10,
  4039. "msg": err,
  4040. })
  4041. }
  4042. }
  4043. func (c *HisApiController) ChangeDrugthree() {
  4044. //ids := c.GetString("ids")
  4045. //id_arr := strings.Split(ids, ",")
  4046. flows, _ := service.GetNewDrugFlowInfothree()
  4047. admin_user_id, _ := c.GetInt64("admin_user_id")
  4048. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4049. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4050. var err []string
  4051. for _, item := range flows {
  4052. var res3 ResultSix
  4053. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4054. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4055. if prescription.OrderStatus == 2 {
  4056. //已经结算
  4057. //判断是否已经销售
  4058. if item.IsSale == 1 { //是否已经销售,1是 0否
  4059. //是否已经变更 1是 0否
  4060. if item.IsChange == 0 { //没变更,进行变更操作
  4061. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4062. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4063. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4064. var respJSON3 map[string]interface{}
  4065. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4068. return
  4069. }
  4070. userJSONBytes3, _ := json.Marshal(respJSON3)
  4071. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4072. utils.ErrorLog("解析失败:%v", err)
  4073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4074. return
  4075. }
  4076. if res3.Infcode == 0 {
  4077. item.IsChange = 1
  4078. item.BgBchno = bg_number
  4079. service.SaveDF2(item)
  4080. } else {
  4081. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4082. }
  4083. }
  4084. } else { //没销售,
  4085. var res FJ3507Result
  4086. var res3507for10188 FJ3507ResultFor10188
  4087. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4088. //进行商品销售接口
  4089. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4090. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4091. var respJSON3 map[string]interface{}
  4092. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4095. return
  4096. }
  4097. userJSONBytes3, _ := json.Marshal(respJSON3)
  4098. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4099. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4100. utils.ErrorLog("解析失败:%v", err)
  4101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4102. return
  4103. }
  4104. //if res3507for10188.Infcode
  4105. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4106. //res.Output = resSix10265.Output
  4107. res.ErrMsg = res3507for10188.ErrMsg
  4108. res.Cainfo = res3507for10188.Cainfo
  4109. res.WarnMsg = res3507for10188.WarnMsg
  4110. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4111. res.Infcode = infocode
  4112. } else {
  4113. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4114. utils.ErrorLog("解析失败:%v", err)
  4115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4116. return
  4117. }
  4118. }
  4119. if res.Infcode == 0 {
  4120. item.IsSale = 1
  4121. item.Bchno = number
  4122. item.SaleDate = time.Now().Format("2006-01-02")
  4123. err5 := service.SaveDF(item)
  4124. if err5 == nil {
  4125. if item.IsChange == 0 { //没变更,进行变更操作
  4126. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4127. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4128. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4129. var respJSON3 map[string]interface{}
  4130. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4133. return
  4134. }
  4135. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4136. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4137. utils.ErrorLog("解析失败:%v", err)
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4139. return
  4140. }
  4141. //if res3507for10188.Infcode
  4142. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4143. //res.Output = resSix10265.Output
  4144. res3.ErrMsg = res3507for10188.ErrMsg
  4145. res3.Cainfo = res3507for10188.Cainfo
  4146. res3.WarnMsg = res3507for10188.WarnMsg
  4147. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4148. res3.Infcode = infocode
  4149. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4150. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4151. utils.ErrorLog("解析失败:%v", err)
  4152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4153. return
  4154. }
  4155. //if res3507for10188.Infcode
  4156. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4157. //res.Output = resSix10265.Output
  4158. res3.ErrMsg = res3507for10188.ErrMsg
  4159. res3.Cainfo = res3507for10188.Cainfo
  4160. res3.WarnMsg = res3507for10188.WarnMsg
  4161. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4162. res3.Infcode = infocode
  4163. } else {
  4164. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4165. utils.ErrorLog("解析失败:%v", err)
  4166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4167. return
  4168. }
  4169. }
  4170. if res3.Infcode == 0 {
  4171. item.IsChange = 1
  4172. item.BgBchno = bg_number
  4173. service.SaveDF2(item)
  4174. } else {
  4175. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4176. }
  4177. }
  4178. }
  4179. } else {
  4180. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4181. }
  4182. }
  4183. } else { //还没结算
  4184. var res3507for10188 FJ3507ResultFor10188
  4185. if item.IsChange == 0 { //没变更,进行变更操作
  4186. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4187. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4188. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4189. var respJSON3 map[string]interface{}
  4190. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4193. return
  4194. }
  4195. userJSONBytes3, _ := json.Marshal(respJSON3)
  4196. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4197. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4198. utils.ErrorLog("解析失败:%v", err)
  4199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4200. return
  4201. }
  4202. //if res3507for10188.Infcode
  4203. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4204. //res.Output = resSix10265.Output
  4205. res3.ErrMsg = res3507for10188.ErrMsg
  4206. res3.Cainfo = res3507for10188.Cainfo
  4207. res3.WarnMsg = res3507for10188.WarnMsg
  4208. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4209. res3.Infcode = infocode
  4210. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4211. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4212. utils.ErrorLog("解析失败:%v", err)
  4213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4214. return
  4215. }
  4216. //if res3507for10188.Infcode
  4217. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4218. //res.Output = resSix10265.Output
  4219. res3.ErrMsg = res3507for10188.ErrMsg
  4220. res3.Cainfo = res3507for10188.Cainfo
  4221. res3.WarnMsg = res3507for10188.WarnMsg
  4222. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4223. res3.Infcode = infocode
  4224. } else {
  4225. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4226. utils.ErrorLog("解析失败:%v", err)
  4227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4228. return
  4229. }
  4230. }
  4231. if res3.Infcode == 0 {
  4232. item.IsChange = 1
  4233. item.BgBchno = bg_number
  4234. service.SaveDF2(item)
  4235. } else {
  4236. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4237. }
  4238. }
  4239. }
  4240. } else if item.ConsumableType == 7 {
  4241. var res3507for10188 FJ3507ResultFor10188
  4242. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4243. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4244. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4245. //判断是否已经销售
  4246. if item.IsSale == 2 { //是否已经销售,1是 0否
  4247. //是否已经变更 1是 0否
  4248. if item.IsChange == 0 { //没变更,进行变更操作
  4249. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4250. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4251. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4252. var respJSON3 map[string]interface{}
  4253. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4256. return
  4257. }
  4258. userJSONBytes3, _ := json.Marshal(respJSON3)
  4259. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4260. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4261. utils.ErrorLog("解析失败:%v", err)
  4262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4263. return
  4264. }
  4265. //if res3507for10188.Infcode
  4266. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4267. //res.Output = resSix10265.Output
  4268. res3.ErrMsg = res3507for10188.ErrMsg
  4269. res3.Cainfo = res3507for10188.Cainfo
  4270. res3.WarnMsg = res3507for10188.WarnMsg
  4271. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4272. res3.Infcode = infocode
  4273. } else {
  4274. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4275. utils.ErrorLog("解析失败:%v", err)
  4276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4277. return
  4278. }
  4279. }
  4280. if res3.Infcode == 0 {
  4281. item.IsChange = 1
  4282. item.BgBchno = bg_number
  4283. service.SaveDF2(item)
  4284. } else {
  4285. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4286. }
  4287. }
  4288. } else { //没销售,
  4289. //进行商品销售退货接口
  4290. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4291. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4292. saveLog(result111, result222, "3506", "销售退货")
  4293. var res7 FJ3507Result
  4294. //进行商品销售接口
  4295. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4296. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4297. var respJSON3 map[string]interface{}
  4298. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. return
  4302. }
  4303. userJSONBytes3, _ := json.Marshal(respJSON3)
  4304. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4305. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4306. utils.ErrorLog("解析失败:%v", err)
  4307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4308. return
  4309. }
  4310. //if res3507for10188.Infcode
  4311. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4312. //res.Output = resSix10265.Output
  4313. res7.ErrMsg = res3507for10188.ErrMsg
  4314. res7.Cainfo = res3507for10188.Cainfo
  4315. res7.WarnMsg = res3507for10188.WarnMsg
  4316. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4317. res7.Infcode = infocode
  4318. } else {
  4319. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4320. utils.ErrorLog("解析失败:%v", err)
  4321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4322. return
  4323. }
  4324. }
  4325. if res7.Infcode == 0 {
  4326. item.IsSale = 2
  4327. item.SaleDate = item.SaleDate
  4328. item.Bchno = number
  4329. service.SaveDF(item)
  4330. if item.IsChange == 0 { //没变更,进行变更操作
  4331. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4332. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4333. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4334. var respJSON3 map[string]interface{}
  4335. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4338. return
  4339. }
  4340. userJSONBytes3, _ := json.Marshal(respJSON3)
  4341. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4342. // utils.ErrorLog("解析失败:%v", err)
  4343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. // return
  4345. //}
  4346. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4347. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4348. utils.ErrorLog("解析失败:%v", err)
  4349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. return
  4351. }
  4352. //if res3507for10188.Infcode
  4353. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4354. //res.Output = resSix10265.Output
  4355. res3.ErrMsg = res3507for10188.ErrMsg
  4356. res3.Cainfo = res3507for10188.Cainfo
  4357. res3.WarnMsg = res3507for10188.WarnMsg
  4358. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4359. res3.Infcode = infocode
  4360. } else {
  4361. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4362. utils.ErrorLog("解析失败:%v", err)
  4363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4364. return
  4365. }
  4366. }
  4367. if res3.Infcode == 0 {
  4368. item.IsChange = 1
  4369. item.BgBchno = bg_number
  4370. service.SaveDF2(item)
  4371. } else {
  4372. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4373. }
  4374. }
  4375. } else {
  4376. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4377. }
  4378. }
  4379. } else { //还没结算
  4380. if item.IsChange == 0 { //没变更,进行变更操作
  4381. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4382. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4383. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4384. var respJSON3 map[string]interface{}
  4385. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4388. return
  4389. }
  4390. userJSONBytes3, _ := json.Marshal(respJSON3)
  4391. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4392. // utils.ErrorLog("解析失败:%v", err)
  4393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. // return
  4395. //}
  4396. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4397. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4398. utils.ErrorLog("解析失败:%v", err)
  4399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4400. return
  4401. }
  4402. //if res3507for10188.Infcode
  4403. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4404. //res.Output = resSix10265.Output
  4405. res3.ErrMsg = res3507for10188.ErrMsg
  4406. res3.Cainfo = res3507for10188.Cainfo
  4407. res3.WarnMsg = res3507for10188.WarnMsg
  4408. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4409. res3.Infcode = infocode
  4410. } else {
  4411. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4412. utils.ErrorLog("解析失败:%v", err)
  4413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4414. return
  4415. }
  4416. }
  4417. if res3.Infcode == 0 {
  4418. item.IsChange = 1
  4419. item.BgBchno = bg_number
  4420. service.SaveDF2(item)
  4421. } else {
  4422. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4423. }
  4424. }
  4425. }
  4426. }
  4427. }
  4428. if len(err) == 0 {
  4429. c.ServeSuccessJSON(map[string]interface{}{
  4430. "msg": "销售变更成功",
  4431. })
  4432. } else {
  4433. c.ServeSuccessJSON(map[string]interface{}{
  4434. "failed_code": -10,
  4435. "msg": err,
  4436. })
  4437. }
  4438. }
  4439. func (c *HisApiController) ChangeDrugTen() {
  4440. start_time_str := c.GetString("start_time")
  4441. end_time_str := c.GetString("end_time")
  4442. //ids := c.GetString("ids")
  4443. //id_arr := strings.Split(ids, ",")
  4444. timeLayout := "2006-01-02"
  4445. loc, _ := time.LoadLocation("Local")
  4446. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4447. recordStartTime := theStartTime.Unix()
  4448. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4449. recordEndTime := theEndTime.Unix()
  4450. //timestamp := int64(1729612800)
  4451. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4452. admin_user_id, _ := c.GetInt64("admin_user_id")
  4453. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4454. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4455. var err []string
  4456. for _, item := range flows {
  4457. var res3 ResultSix
  4458. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4459. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4460. continue
  4461. }
  4462. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4463. continue
  4464. }
  4465. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4466. if prescription.OrderStatus == 2 {
  4467. //已经结算
  4468. //判断 是否已经销售
  4469. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4470. ////是否已经变更 1是 0否
  4471. //if item.IsChange == 0 { //没变更,进行变更操作
  4472. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4473. //
  4474. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4475. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4476. // var respJSON3 map[string]interface{}
  4477. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4478. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4480. // return
  4481. // }
  4482. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4483. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4484. // utils.ErrorLog("解析失败:%v", err)
  4485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4486. // return
  4487. // }
  4488. // if res3.Infcode == 0 {
  4489. // item.IsChange = 1
  4490. // item.BgBchno = bg_number
  4491. // service.SaveDF2(item)
  4492. // } else {
  4493. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4494. // }
  4495. //}
  4496. //} else
  4497. if item.IsSale == 0 { //没销售,
  4498. var res FJ3507Result
  4499. var res3507for10188 FJ3507ResultFor10188
  4500. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4501. //进行商品销售接口
  4502. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4503. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4504. var respJSON3 map[string]interface{}
  4505. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4508. return
  4509. }
  4510. userJSONBytes3, _ := json.Marshal(respJSON3)
  4511. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4512. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4513. utils.ErrorLog("解析失败:%v", err)
  4514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4515. return
  4516. }
  4517. //if res3507for10188.Infcode
  4518. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4519. //res.Output = resSix10265.Output
  4520. res.ErrMsg = res3507for10188.ErrMsg
  4521. res.Cainfo = res3507for10188.Cainfo
  4522. res.WarnMsg = res3507for10188.WarnMsg
  4523. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4524. res.Infcode = infocode
  4525. } else {
  4526. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4527. utils.ErrorLog("解析失败:%v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. }
  4532. if res.Infcode == 0 {
  4533. item.IsSale = 1
  4534. item.Bchno = number
  4535. item.SaleDate = time.Now().Format("2006-01-02")
  4536. err5 := service.SaveDF(item)
  4537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4538. //if err5 == nil {
  4539. //
  4540. // if item.IsChange == 1 { //没变更,进行变更操作
  4541. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4542. //
  4543. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4544. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4545. //
  4546. // var respJSON3 map[string]interface{}
  4547. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4548. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4550. // return
  4551. // }
  4552. //
  4553. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4554. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4555. // utils.ErrorLog("解析失败:%v", err)
  4556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4557. // return
  4558. // }
  4559. // //if res3507for10188.Infcode
  4560. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4561. // //res.Output = resSix10265.Output
  4562. // res3.ErrMsg = res3507for10188.ErrMsg
  4563. // res3.Cainfo = res3507for10188.Cainfo
  4564. // res3.WarnMsg = res3507for10188.WarnMsg
  4565. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4566. // res3.Infcode = infocode
  4567. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4568. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4569. // utils.ErrorLog("解析失败:%v", err)
  4570. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. // return
  4572. // }
  4573. // //if res3507for10188.Infcode
  4574. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4575. // //res.Output = resSix10265.Output
  4576. // res3.ErrMsg = res3507for10188.ErrMsg
  4577. // res3.Cainfo = res3507for10188.Cainfo
  4578. // res3.WarnMsg = res3507for10188.WarnMsg
  4579. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4580. // res3.Infcode = infocode
  4581. //
  4582. // } else {
  4583. //
  4584. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4585. // utils.ErrorLog("解析失败:%v", err)
  4586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4587. // return
  4588. // }
  4589. //
  4590. // }
  4591. //
  4592. // if res3.Infcode == 0 {
  4593. // item.IsChange = 1
  4594. // item.BgBchno = bg_number
  4595. // service.SaveDF2(item)
  4596. // return
  4597. // } else {
  4598. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4599. // }
  4600. // }
  4601. //}
  4602. } else {
  4603. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4604. }
  4605. }
  4606. }
  4607. } else if item.ConsumableType == 7 {
  4608. var res3507for10188 FJ3507ResultFor10188
  4609. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4610. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4611. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4612. //判断是否已经销售
  4613. if item.IsSale == 2 { //是否已经销售,1是 0否
  4614. //是否已经变更 1是 0否
  4615. if item.IsChange == 0 { //没变更,进行变更操作
  4616. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4617. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4618. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4619. var respJSON3 map[string]interface{}
  4620. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4623. return
  4624. }
  4625. userJSONBytes3, _ := json.Marshal(respJSON3)
  4626. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4627. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4628. utils.ErrorLog("解析失败:%v", err)
  4629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4630. return
  4631. }
  4632. //if res3507for10188.Infcode
  4633. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4634. //res.Output = resSix10265.Output
  4635. res3.ErrMsg = res3507for10188.ErrMsg
  4636. res3.Cainfo = res3507for10188.Cainfo
  4637. res3.WarnMsg = res3507for10188.WarnMsg
  4638. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4639. res3.Infcode = infocode
  4640. } else {
  4641. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. }
  4647. if res3.Infcode == 0 {
  4648. item.IsChange = 1
  4649. item.BgBchno = bg_number
  4650. service.SaveDF2(item)
  4651. } else {
  4652. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4653. }
  4654. }
  4655. } else { //没销售,
  4656. //进行商品销售退货接口
  4657. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4658. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4659. saveLog(result111, result222, "3506", "销售退货")
  4660. var res7 FJ3507Result
  4661. //进行商品销售接口
  4662. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4663. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4664. var respJSON3 map[string]interface{}
  4665. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4668. return
  4669. }
  4670. userJSONBytes3, _ := json.Marshal(respJSON3)
  4671. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4672. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4673. utils.ErrorLog("解析失败:%v", err)
  4674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4675. return
  4676. }
  4677. //if res3507for10188.Infcode
  4678. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4679. //res.Output = resSix10265.Output
  4680. res7.ErrMsg = res3507for10188.ErrMsg
  4681. res7.Cainfo = res3507for10188.Cainfo
  4682. res7.WarnMsg = res3507for10188.WarnMsg
  4683. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4684. res7.Infcode = infocode
  4685. } else {
  4686. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4687. utils.ErrorLog("解析失败:%v", err)
  4688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4689. return
  4690. }
  4691. }
  4692. if res7.Infcode == 0 {
  4693. item.IsSale = 2
  4694. item.SaleDate = item.SaleDate
  4695. item.Bchno = number
  4696. service.SaveDF(item)
  4697. if item.IsChange == 0 { //没变更,进行变更操作
  4698. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4699. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4700. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4701. var respJSON3 map[string]interface{}
  4702. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4705. return
  4706. }
  4707. userJSONBytes3, _ := json.Marshal(respJSON3)
  4708. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4709. // utils.ErrorLog("解析失败:%v", err)
  4710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4711. // return
  4712. //}
  4713. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4714. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4715. utils.ErrorLog("解析失败:%v", err)
  4716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4717. return
  4718. }
  4719. //if res3507for10188.Infcode
  4720. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4721. //res.Output = resSix10265.Output
  4722. res3.ErrMsg = res3507for10188.ErrMsg
  4723. res3.Cainfo = res3507for10188.Cainfo
  4724. res3.WarnMsg = res3507for10188.WarnMsg
  4725. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4726. res3.Infcode = infocode
  4727. } else {
  4728. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4729. utils.ErrorLog("解析失败:%v", err)
  4730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4731. return
  4732. }
  4733. }
  4734. if res3.Infcode == 0 {
  4735. item.IsChange = 1
  4736. item.BgBchno = bg_number
  4737. service.SaveDF2(item)
  4738. } else {
  4739. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4740. }
  4741. }
  4742. } else {
  4743. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4744. }
  4745. }
  4746. } else { //还没结算
  4747. if item.IsChange == 0 { //没变更,进行变更操作
  4748. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4749. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4750. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4751. var respJSON3 map[string]interface{}
  4752. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. userJSONBytes3, _ := json.Marshal(respJSON3)
  4758. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4759. // utils.ErrorLog("解析失败:%v", err)
  4760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4761. // return
  4762. //}
  4763. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4764. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4765. utils.ErrorLog("解析失败:%v", err)
  4766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4767. return
  4768. }
  4769. //if res3507for10188.Infcode
  4770. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4771. //res.Output = resSix10265.Output
  4772. res3.ErrMsg = res3507for10188.ErrMsg
  4773. res3.Cainfo = res3507for10188.Cainfo
  4774. res3.WarnMsg = res3507for10188.WarnMsg
  4775. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4776. res3.Infcode = infocode
  4777. } else {
  4778. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4779. utils.ErrorLog("解析失败:%v", err)
  4780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4781. return
  4782. }
  4783. }
  4784. if res3.Infcode == 0 {
  4785. item.IsChange = 1
  4786. item.BgBchno = bg_number
  4787. service.SaveDF2(item)
  4788. } else {
  4789. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4790. }
  4791. }
  4792. }
  4793. }
  4794. }
  4795. if len(err) == 0 {
  4796. c.ServeSuccessJSON(map[string]interface{}{
  4797. "msg": "销售变更成功",
  4798. })
  4799. } else {
  4800. c.ServeSuccessJSON(map[string]interface{}{
  4801. "failed_code": -10,
  4802. "msg": err,
  4803. })
  4804. }
  4805. }
  4806. func ChangeDrugTenone() {
  4807. //ids := c.GetString("ids")
  4808. //id_arr := strings.Split(ids, ",")
  4809. now := time.Now()
  4810. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4811. //timestamp := int64(1729612800)
  4812. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4813. admin_user_id := int64(2463)
  4814. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4815. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4816. var err []string
  4817. for _, item := range flows {
  4818. var res3 ResultSix
  4819. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4820. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4821. continue
  4822. }
  4823. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4824. continue
  4825. }
  4826. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4827. if prescription.OrderStatus == 2 {
  4828. //已经结算
  4829. //判断是否已经销售
  4830. if item.IsSale == 1 { //是否已经销售,1是 0否
  4831. //是否已经变更 1是 0否
  4832. if item.IsChange == 0 { //没变更,进行变更操作
  4833. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4834. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4835. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4836. var respJSON3 map[string]interface{}
  4837. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4839. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4840. return
  4841. }
  4842. userJSONBytes3, _ := json.Marshal(respJSON3)
  4843. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4844. utils.ErrorLog("解析失败:%v", err)
  4845. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4846. return
  4847. }
  4848. if res3.Infcode == 0 {
  4849. item.IsChange = 1
  4850. item.BgBchno = bg_number
  4851. service.SaveDF2(item)
  4852. } else {
  4853. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4854. }
  4855. }
  4856. } else { //没销售,
  4857. var res FJ3507Result
  4858. var res3507for10188 FJ3507ResultFor10188
  4859. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4860. //进行商品销售接口
  4861. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4862. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4863. var respJSON3 map[string]interface{}
  4864. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4866. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. userJSONBytes3, _ := json.Marshal(respJSON3)
  4870. {
  4871. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4872. utils.ErrorLog("解析失败:%v", err)
  4873. return
  4874. }
  4875. //if res3507for10188.Infcode
  4876. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4877. //res.Output = resSix10265.Output
  4878. res.ErrMsg = res3507for10188.ErrMsg
  4879. res.Cainfo = res3507for10188.Cainfo
  4880. res.WarnMsg = res3507for10188.WarnMsg
  4881. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4882. res.Infcode = infocode
  4883. }
  4884. if res.Infcode == 0 {
  4885. item.IsSale = 1
  4886. item.Bchno = number
  4887. item.SaleDate = time.Now().Format("2006-01-02")
  4888. err5 := service.SaveDF(item)
  4889. if err5 == nil {
  4890. if item.IsChange == 1 { //没变更,进行变更操作
  4891. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4892. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4893. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4894. var respJSON3 map[string]interface{}
  4895. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4897. return
  4898. }
  4899. {
  4900. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4901. utils.ErrorLog("解析失败:%v", err)
  4902. return
  4903. }
  4904. //if res3507for10188.Infcode
  4905. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4906. //res.Output = resSix10265.Output
  4907. res3.ErrMsg = res3507for10188.ErrMsg
  4908. res3.Cainfo = res3507for10188.Cainfo
  4909. res3.WarnMsg = res3507for10188.WarnMsg
  4910. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4911. res3.Infcode = infocode
  4912. }
  4913. if res3.Infcode == 0 {
  4914. item.IsChange = 1
  4915. item.BgBchno = bg_number
  4916. service.SaveDF2(item)
  4917. } else {
  4918. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4919. }
  4920. }
  4921. }
  4922. } else {
  4923. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4924. }
  4925. }
  4926. }
  4927. }
  4928. }
  4929. }
  4930. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4931. var struct3502 models.Struct3502
  4932. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4933. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4934. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4935. struct3502.FixmedinsCode = miConfig.Code
  4936. struct3502.Code = miConfig.Code
  4937. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4938. struct3502.Opter = role.UserName
  4939. struct3502.RxFlag = "1"
  4940. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4941. struct3502.OrgName = miConfig.OrgName
  4942. struct3502.AccessKey = miConfig.AccessKey
  4943. struct3502.RequestUrl = miConfig.Url
  4944. struct3502.SecretKey = miConfig.SecretKey
  4945. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4946. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4947. struct3502.Url = miConfig.Url
  4948. struct3502.AppId = miConfig.Cainfo
  4949. struct3502.AppSecret = miConfig.AppSecret
  4950. struct3502.Enckey = miConfig.EncKey
  4951. struct3502.SignKey = miConfig.SignKey
  4952. struct3502.SecretKey = miConfig.SecretKey
  4953. struct3502.InvChgType = chgType
  4954. struct3502.FixmedinsBchno = number
  4955. struct3502.Cnt = strconv.FormatInt(count, 10)
  4956. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4957. //result1, result2, _ := service.FJyb3502(struct3502)
  4958. if miConfig.MdtrtareaAdmvs == "350500" {
  4959. result1, result2, _ := service.FJyb3502(struct3502)
  4960. //saveLog(result1, result2, "3502", "3502")
  4961. return result1, result2
  4962. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4963. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4964. return result1, result2
  4965. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4966. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4967. return result1, result2
  4968. } else {
  4969. data := make(map[string]interface{})
  4970. data["struct_3502s"] = struct3502
  4971. client := &http.Client{}
  4972. bytesData, _ := json.Marshal(data)
  4973. var req *http.Request
  4974. if miConfig.MdtrtareaAdmvs == "320921" {
  4975. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4976. } else {
  4977. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4978. }
  4979. resp, _ := client.Do(req)
  4980. defer resp.Body.Close()
  4981. body, ioErr := ioutil.ReadAll(resp.Body)
  4982. if ioErr != nil {
  4983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4984. }
  4985. var respJSON map[string]interface{}
  4986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4988. }
  4989. //var resSix10265 ResultSix10265 //1101结果
  4990. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4991. result, _ := json.Marshal(respJSON)
  4992. return string(result), ""
  4993. }
  4994. }
  4995. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4996. var struct3505 models.Struct3505
  4997. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4998. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4999. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5000. struct3505.FixmedinsBchno = number
  5001. struct3505.Opter = role.UserName
  5002. struct3505.Bchno = "---"
  5003. struct3505.FixmedinsCode = miConfig.Code
  5004. struct3505.Code = miConfig.Code
  5005. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5006. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5007. struct3505.PrscDrName = roles.UserName
  5008. if org_id == 10191 {
  5009. struct3505.PharName = "刘水山"
  5010. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5011. }
  5012. if org_id == 10188 {
  5013. struct3505.PharName = "李汉清"
  5014. struct3505.PharPracCertNo = "30220200932022010034"
  5015. }
  5016. if org_id == 10217 {
  5017. struct3505.PharName = "张敏"
  5018. struct3505.PharPracCertNo = "30220230432090100108"
  5019. }
  5020. if org_id == 10318 {
  5021. struct3505.PharName = "邹刘阳"
  5022. struct3505.PharPracCertNo = "210441200001378"
  5023. }
  5024. if org_id == 10402 {
  5025. struct3505.PharName = "刘韶健"
  5026. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5027. }
  5028. if org_id == 9919 {
  5029. struct3505.PharName = "周君权"
  5030. struct3505.PharPracCertNo = "089644396094401375"
  5031. }
  5032. if org_id == 10644 {
  5033. struct3505.PharName = "陈金娣"
  5034. struct3505.PharPracCertNo = "20181441500320100066"
  5035. }
  5036. if org_id == 10567 {
  5037. struct3505.PharName = "范小兰"
  5038. struct3505.PharPracCertNo = "0200102079485"
  5039. }
  5040. if org_id == 10721 {
  5041. struct3505.PharName = "孙莉侠"
  5042. struct3505.PharPracCertNo = "060399"
  5043. }
  5044. if org_id == 10726 {
  5045. struct3505.PharName = "彭建福"
  5046. struct3505.PharPracCertNo = "D445281006261"
  5047. }
  5048. if org_id == 10265 {
  5049. struct3505.PharName = "李彩星"
  5050. struct3505.PharPracCertNo = "20171110600110100019"
  5051. }
  5052. if org_id == 10028 {
  5053. struct3505.PharName = "曾细平"
  5054. struct3505.PharPracCertNo = "D440307022134"
  5055. }
  5056. if org_id == 10138 {
  5057. struct3505.PharName = "彭斯遥"
  5058. struct3505.PharPracCertNo = "30220200943042010052"
  5059. }
  5060. if org_id == 10278 {
  5061. struct3505.PharName = "彭斯遥"
  5062. struct3505.PharPracCertNo = "30220200943042010052"
  5063. }
  5064. if org_id == 10610 {
  5065. struct3505.PharName = "彭斯遥"
  5066. struct3505.PharPracCertNo = "30220200943042010052"
  5067. }
  5068. if org_id == 10537 {
  5069. struct3505.PharName = "彭斯遥"
  5070. struct3505.PharPracCertNo = "30220200943042010052"
  5071. }
  5072. if org_id == 9504 {
  5073. struct3505.PharName = "资美红"
  5074. struct3505.PharPracCertNo = "D440904006635"
  5075. }
  5076. if org_id == 10480 {
  5077. struct3505.PharName = "陈思"
  5078. struct3505.PharPracCertNo = "30220240434110010470"
  5079. }
  5080. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5081. struct3505.SetlId = order.SetlId
  5082. struct3505.MdtrtSn = order.MdtrtId
  5083. struct3505.ManuLotnum = drug.BatchNumber
  5084. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5085. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5086. struct3505.RxFlag = "1"
  5087. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5088. struct3505.TrdnFlag = "0"
  5089. } else {
  5090. struct3505.TrdnFlag = "1"
  5091. }
  5092. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5093. struct3505.TrdnFlag = "1"
  5094. }
  5095. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5096. struct3505.TrdnFlag = "0"
  5097. }
  5098. struct3505.RtalDocno = order.Number
  5099. struct3505.PsnCertType = "01"
  5100. struct3505.CertNo = order.Certno
  5101. struct3505.PsnNo = order.PsnNo
  5102. struct3505.PsnName = order.PsnName
  5103. struct3505.Url = miConfig.Url
  5104. struct3505.AppId = miConfig.Cainfo
  5105. struct3505.AppSecret = miConfig.AppSecret
  5106. struct3505.Enckey = miConfig.EncKey
  5107. struct3505.SignKey = miConfig.SignKey
  5108. struct3505.SecretKey = miConfig.SecretKey
  5109. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5110. struct3505.SelRetnCnt = strValue
  5111. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5112. struct3505.SelRetnOpterName = role.UserName
  5113. if order.IsMedicineInsurance == 1 {
  5114. struct3505.MdtrtSetlType = "1"
  5115. } else {
  5116. struct3505.MdtrtSetlType = "2"
  5117. }
  5118. struct3505.OrgName = miConfig.OrgName
  5119. struct3505.AccessKey = miConfig.AccessKey
  5120. struct3505.RequestUrl = miConfig.Url
  5121. struct3505.SecretKey = miConfig.SecretKey
  5122. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5123. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5124. struct3505.Cainfo = miConfig.Cainfo
  5125. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5126. if miConfig.MdtrtareaAdmvs == "350500" {
  5127. result1, result2, _ := service.FJyb3505(struct3505)
  5128. return result1, result2
  5129. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5130. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5131. return result1, result2
  5132. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5133. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5134. return result1, result2
  5135. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5136. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5137. return result1, result2
  5138. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5139. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5140. return result1, result2
  5141. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5142. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5143. return result1, result2
  5144. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5145. data := make(map[string]interface{})
  5146. data["struct_3505s"] = struct3505
  5147. client := &http.Client{}
  5148. bytesData, _ := json.Marshal(data)
  5149. var req *http.Request
  5150. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5151. resp, _ := client.Do(req)
  5152. defer resp.Body.Close()
  5153. body, ioErr := ioutil.ReadAll(resp.Body)
  5154. if ioErr != nil {
  5155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5156. }
  5157. var respJSON map[string]interface{}
  5158. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5160. }
  5161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5162. result, _ := json.Marshal(respJSON)
  5163. return string(result), ""
  5164. } else {
  5165. data := make(map[string]interface{})
  5166. data["struct_3505s"] = struct3505
  5167. client := &http.Client{}
  5168. bytesData, _ := json.Marshal(data)
  5169. var req *http.Request
  5170. if miConfig.MdtrtareaAdmvs == "320921" {
  5171. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5172. } else {
  5173. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5174. }
  5175. resp, _ := client.Do(req)
  5176. defer resp.Body.Close()
  5177. body, ioErr := ioutil.ReadAll(resp.Body)
  5178. if ioErr != nil {
  5179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5180. }
  5181. var respJSON map[string]interface{}
  5182. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5184. }
  5185. //var resSix10265 ResultSix10265 //1101结果
  5186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5187. result, _ := json.Marshal(respJSON)
  5188. return string(result), ""
  5189. }
  5190. }
  5191. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5192. var struct3505 models.Struct3505
  5193. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5194. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5195. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5196. struct3505.FixmedinsBchno = number
  5197. struct3505.Opter = role.UserName
  5198. struct3505.FixmedinsCode = miConfig.Code
  5199. struct3505.Code = miConfig.Code
  5200. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5201. struct3505.PrscDrName = roles.UserName
  5202. if org_id == 10191 {
  5203. struct3505.PharName = "刘水山"
  5204. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5205. }
  5206. if org_id == 10188 {
  5207. struct3505.PharName = "李汉清"
  5208. struct3505.PharPracCertNo = "30220200932022010034"
  5209. }
  5210. if org_id == 10217 {
  5211. struct3505.PharName = "张敏"
  5212. struct3505.PharPracCertNo = "30220230432090100108"
  5213. }
  5214. if org_id == 10318 {
  5215. struct3505.PharName = "邹刘阳"
  5216. struct3505.PharPracCertNo = "210441200001378"
  5217. }
  5218. if org_id == 10402 {
  5219. struct3505.PharName = "刘韶健"
  5220. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5221. }
  5222. if org_id == 9919 {
  5223. struct3505.PharName = "周君权"
  5224. struct3505.PharPracCertNo = "089644396094401375"
  5225. }
  5226. if org_id == 10644 {
  5227. struct3505.PharName = "陈金娣"
  5228. struct3505.PharPracCertNo = "20181441500320100066"
  5229. }
  5230. if org_id == 10567 {
  5231. struct3505.PharName = "范小兰"
  5232. struct3505.PharPracCertNo = "0200102079485"
  5233. }
  5234. if org_id == 10721 {
  5235. struct3505.PharName = "孙莉侠"
  5236. struct3505.PharPracCertNo = "060399"
  5237. }
  5238. if org_id == 10726 {
  5239. struct3505.PharName = "彭建福"
  5240. struct3505.PharPracCertNo = "D445281006261"
  5241. }
  5242. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5243. struct3505.SetlId = order.SetlId
  5244. struct3505.MdtrtSn = order.MdtrtId
  5245. struct3505.ManuLotnum = drug.Number
  5246. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5247. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5248. struct3505.RxFlag = "1"
  5249. struct3505.TrdnFlag = "0"
  5250. struct3505.RtalDocno = order.Number
  5251. struct3505.PsnCertType = "01"
  5252. struct3505.CertNo = order.Certno
  5253. struct3505.PsnNo = order.PsnNo
  5254. struct3505.PsnName = order.PsnName
  5255. struct3505.Url = miConfig.Url
  5256. struct3505.AppId = miConfig.Cainfo
  5257. struct3505.AppSecret = miConfig.AppSecret
  5258. struct3505.Enckey = miConfig.EncKey
  5259. struct3505.SignKey = miConfig.SignKey
  5260. struct3505.SecretKey = miConfig.SecretKey
  5261. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5262. struct3505.SelRetnCnt = strValue
  5263. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5264. struct3505.SelRetnOpterName = role.UserName
  5265. if order.IsMedicineInsurance == 1 {
  5266. struct3505.MdtrtSetlType = "1"
  5267. } else {
  5268. struct3505.MdtrtSetlType = "2"
  5269. }
  5270. struct3505.OrgName = miConfig.OrgName
  5271. struct3505.AccessKey = miConfig.AccessKey
  5272. struct3505.RequestUrl = miConfig.Url
  5273. struct3505.SecretKey = miConfig.SecretKey
  5274. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5275. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5276. struct3505.Cainfo = miConfig.Cainfo
  5277. struct3505.DrugTracCodg = drug.DrugCode
  5278. if miConfig.MdtrtareaAdmvs == "350500" {
  5279. result1, result2, _ := service.FJyb3505(struct3505)
  5280. return result1, result2
  5281. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5282. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5283. return result1, result2
  5284. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5285. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5286. return result1, result2
  5287. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5288. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5289. return result1, result2
  5290. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5291. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5292. return result1, result2
  5293. } else {
  5294. data := make(map[string]interface{})
  5295. data["struct_3505s"] = struct3505
  5296. client := &http.Client{}
  5297. bytesData, _ := json.Marshal(data)
  5298. var req *http.Request
  5299. if miConfig.MdtrtareaAdmvs == "320921" {
  5300. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5301. } else {
  5302. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5303. }
  5304. resp, _ := client.Do(req)
  5305. defer resp.Body.Close()
  5306. body, ioErr := ioutil.ReadAll(resp.Body)
  5307. if ioErr != nil {
  5308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5309. }
  5310. var respJSON map[string]interface{}
  5311. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5313. }
  5314. //var resSix10265 ResultSix10265 //1101结果
  5315. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5316. result, _ := json.Marshal(respJSON)
  5317. return string(result), ""
  5318. }
  5319. }
  5320. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5321. var struct3506 models.Struct3506
  5322. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5323. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5324. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5325. struct3506.FixmedinsCode = miConfig.Code
  5326. struct3506.Code = miConfig.Code
  5327. struct3506.FixmedinsBchno = number
  5328. struct3506.Opter = role.UserName
  5329. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5330. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5331. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5332. struct3506.MdtrtSn = order.MdtrtId
  5333. struct3506.ExpyEnd = ""
  5334. struct3506.RxFlag = "0"
  5335. struct3506.TrdnFlag = "1"
  5336. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5337. struct3506.SelRetnCnt = strValue
  5338. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5339. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5340. struct3506.SelRetnOpterName = role.UserName
  5341. struct3506.OrgName = miConfig.OrgName
  5342. struct3506.AccessKey = miConfig.AccessKey
  5343. struct3506.RequestUrl = miConfig.Url
  5344. struct3506.SecretKey = miConfig.SecretKey
  5345. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5346. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5347. struct3506.Url = miConfig.Url
  5348. struct3506.AppId = miConfig.Cainfo
  5349. struct3506.AppSecret = miConfig.AppSecret
  5350. struct3506.Enckey = miConfig.EncKey
  5351. struct3506.SignKey = miConfig.SignKey
  5352. struct3506.SecretKey = miConfig.SecretKey
  5353. struct3506.DrugTracCodg = drug.DrugCode
  5354. if miConfig.MdtrtareaAdmvs == "350500" {
  5355. result1, result2, _ := service.FJyb3506(struct3506)
  5356. return result1, result2
  5357. } else {
  5358. data := make(map[string]interface{})
  5359. data["struct_3506s"] = struct3506
  5360. client := &http.Client{}
  5361. bytesData, _ := json.Marshal(data)
  5362. var req *http.Request
  5363. if miConfig.MdtrtareaAdmvs == "320921" {
  5364. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5365. } else {
  5366. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5367. }
  5368. resp, _ := client.Do(req)
  5369. defer resp.Body.Close()
  5370. body, ioErr := ioutil.ReadAll(resp.Body)
  5371. if ioErr != nil {
  5372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5373. }
  5374. var respJSON map[string]interface{}
  5375. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5377. }
  5378. //var resSix10265 ResultSix10265 //1101结果
  5379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5380. result, _ := json.Marshal(respJSON)
  5381. return string(result), ""
  5382. }
  5383. }
  5384. func (c *HisApiController) Get1318() {
  5385. adminUser := c.GetAdminUserInfo()
  5386. admin_user_id, _ := c.GetInt64("admin_user_id")
  5387. code := c.GetString("code")
  5388. code = ""
  5389. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5390. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5391. api := ""
  5392. if miConfig.MdtrtareaAdmvs == "320921" {
  5393. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5394. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5395. } else {
  5396. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5397. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5398. }
  5399. resp, requestErr := http.Get(api)
  5400. if requestErr != nil {
  5401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5402. return
  5403. }
  5404. body, ioErr := ioutil.ReadAll(resp.Body)
  5405. if ioErr != nil {
  5406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5408. return
  5409. }
  5410. var respJSON map[string]interface{}
  5411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5414. return
  5415. }
  5416. //var res Result2406
  5417. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5418. result, _ := json.Marshal(respJSON)
  5419. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5420. utils.ErrorLog("解析失败:%v", err)
  5421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5422. return
  5423. }
  5424. if res.Infcode == "0" {
  5425. c.ServeSuccessJSON(map[string]interface{}{
  5426. "result": "",
  5427. })
  5428. } else {
  5429. c.ServeSuccessJSON(map[string]interface{}{
  5430. "failed_code": -10,
  5431. "msg": res.ErrMsg,
  5432. })
  5433. */return
  5434. //}
  5435. }
  5436. func (c *HisApiController) Get2503() {
  5437. adminUser := c.GetAdminUserInfo()
  5438. admin_user_id, _ := c.GetInt64("admin_user_id")
  5439. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5440. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5441. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5442. }
  5443. func (c *HisApiController) Get2406() {
  5444. id, _ := c.GetInt64("id")
  5445. record_time := c.GetString("record_time")
  5446. his_patient_id, _ := c.GetInt64("his_patient_id")
  5447. admin_user_id, _ := c.GetInt64("admin_user_id")
  5448. diagnosis_id := c.GetString("diagnosis")
  5449. timeLayout := "2006-01-02"
  5450. loc, _ := time.LoadLocation("Local")
  5451. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5452. if err != nil {
  5453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5454. return
  5455. }
  5456. recordDateTime := theTime.Unix()
  5457. adminUser := c.GetAdminUserInfo()
  5458. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5459. var config []*models.HisXtDiagnoseConfig
  5460. for _, item := range diagnosis_ids {
  5461. id, _ := strconv.ParseInt(item, 10, 64)
  5462. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5463. config = append(config, &diagnosisConfig)
  5464. }
  5465. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5466. fmt.Println(his_patient_id)
  5467. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5468. //timestamp := time.Now().Unix()
  5469. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5470. var patientPrescription models.HisPrescriptionInfo
  5471. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5472. if patientPrescription.ID == 0 {
  5473. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5474. }
  5475. var res2 Result2406
  5476. if miConfig.MdtrtareaAdmvs == "341203" {
  5477. data := make(map[string]interface{})
  5478. client := &http.Client{}
  5479. data["psn_no"] = his.PsnNo
  5480. data["mdtrt_id"] = his.Number
  5481. data["operator"] = roles.UserName
  5482. data["cert_no"] = his.IdCardNo
  5483. data["org_name"] = miConfig.OrgName
  5484. data["psn_name"] = his.Name
  5485. data["ipt_otp_no"] = his.IptOtpNo
  5486. data["ipt_psn_sp_flag_type"] = "0901"
  5487. data["ipt_psn_sp_flag"] = "1"
  5488. data["fixmedins_code"] = miConfig.Code
  5489. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5490. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5491. data["url"] = miConfig.Url
  5492. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5493. bytesData, _ := json.Marshal(data)
  5494. var req *http.Request
  5495. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5496. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5497. resp, _ := client.Do(req)
  5498. defer resp.Body.Close()
  5499. body, ioErr := ioutil.ReadAll(resp.Body)
  5500. if ioErr != nil {
  5501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5503. return
  5504. }
  5505. var respJSON map[string]interface{}
  5506. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5509. return
  5510. }
  5511. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5512. if status == "0" {
  5513. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5514. c.ServeSuccessJSON(map[string]interface{}{
  5515. "failed_code": -10,
  5516. "msg": err_msg,
  5517. })
  5518. return
  5519. }
  5520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5521. userJSONBytes, _ := json.Marshal(respJSON)
  5522. fmt.Println("log")
  5523. fmt.Println(string(userJSONBytes))
  5524. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5525. utils.ErrorLog("解析失败:%v", err)
  5526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5527. return
  5528. }
  5529. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5530. data := make(map[string]interface{})
  5531. client := &http.Client{}
  5532. data["psn_no"] = his.PsnNo
  5533. data["mdtrt_id"] = his.Number
  5534. data["operator"] = roles.UserName
  5535. data["cert_no"] = his.IdCardNo
  5536. data["org_name"] = miConfig.OrgName
  5537. data["psn_name"] = his.Name
  5538. data["ipt_otp_no"] = his.IptOtpNo
  5539. data["ipt_psn_sp_flag_type"] = "0901"
  5540. data["ipt_psn_sp_flag"] = "1"
  5541. data["fixmedins_code"] = miConfig.Code
  5542. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5543. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5544. data["url"] = miConfig.Url
  5545. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5546. bytesData, _ := json.Marshal(data)
  5547. var req *http.Request
  5548. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5549. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5550. resp, _ := client.Do(req)
  5551. defer resp.Body.Close()
  5552. body, ioErr := ioutil.ReadAll(resp.Body)
  5553. if ioErr != nil {
  5554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5556. return
  5557. }
  5558. var respJSON map[string]interface{}
  5559. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5562. return
  5563. }
  5564. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5565. if status == "0" {
  5566. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5567. c.ServeSuccessJSON(map[string]interface{}{
  5568. "failed_code": -10,
  5569. "msg": err_msg,
  5570. })
  5571. return
  5572. }
  5573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5574. userJSONBytes, _ := json.Marshal(respJSON)
  5575. fmt.Println("log")
  5576. fmt.Println(string(userJSONBytes))
  5577. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5578. utils.ErrorLog("解析失败:%v", err)
  5579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5580. return
  5581. }
  5582. }
  5583. if res2.Infcode != 0 {
  5584. adminUser := c.GetAdminUserInfo()
  5585. errlog := &models.HisOrderError{
  5586. UserOrgId: adminUser.CurrentOrgId,
  5587. Ctime: time.Now().Unix(),
  5588. Mtime: time.Now().Unix(),
  5589. ErrMsg: res2.ErrMsg,
  5590. Status: 1,
  5591. PatientId: id,
  5592. RecordTime: recordDateTime,
  5593. Stage: 3,
  5594. }
  5595. service.CreateErrMsgLog(errlog)
  5596. c.ServeSuccessJSON(map[string]interface{}{
  5597. "failed_code": -10,
  5598. "msg": res2.ErrMsg,
  5599. })
  5600. return
  5601. } else {
  5602. c.ServeSuccessJSON(map[string]interface{}{
  5603. "msg": "上传成功",
  5604. })
  5605. return
  5606. }
  5607. }
  5608. func (c *HisApiController) Get4105() {
  5609. }
  5610. func (c *HisApiController) Post5302() {
  5611. patient_id, _ := c.GetInt64("id")
  5612. admin_user_id, _ := c.GetInt64("admin_user_id")
  5613. p, _ := service.GetHisPatientById(patient_id)
  5614. adminUser := c.GetAdminUserInfo()
  5615. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5616. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5617. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5618. }
  5619. func (c *HisApiController) Get4104() {
  5620. }
  5621. type Output struct {
  5622. CertNo string `json:"certno"`
  5623. PsnName string `json:"psn_name"`
  5624. CardNo string `json:"card_no"`
  5625. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5626. CardSN string `json:"card_sn"`
  5627. PsnCertType string `json:"psn_cert_type"`
  5628. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5629. MdtrtCertType string `json:"mdtrt_cert_type"`
  5630. QRCode string `json:"qrCode"`
  5631. EcToken string `json:"ecToken"`
  5632. }
  5633. type AHResponse struct {
  5634. Body AHBody `json:"body"`
  5635. Code int `json:"code"`
  5636. CSBCode int `json:"csbCode"`
  5637. Message string `json:"message"`
  5638. RequestID string `json:"requestId"`
  5639. State struct{} `json:"state"`
  5640. }
  5641. type AHBody struct {
  5642. ErrMsg string `json:"err_msg"`
  5643. InfRefMsgID string `json:"inf_refmsgid"`
  5644. InfCode int `json:"infcode"`
  5645. Output struct {
  5646. Result []struct {
  5647. BasMednFlag string `json:"bas_medn_flag"`
  5648. ChldMedcFlag string `json:"chld_medc_flag"`
  5649. ChrgitmLv string `json:"chrgitm_lv"`
  5650. Cnt float64 `json:"cnt"`
  5651. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5652. DrtReimFlag string `json:"drt_reim_flag"`
  5653. FeedetlSn string `json:"feedetl_sn"`
  5654. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5655. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5656. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5657. ListSpItemFlag string `json:"list_sp_item_flag"`
  5658. LmtUsedFlag string `json:"lmt_used_flag"`
  5659. MedChrgitmType string `json:"med_chrgitm_type"`
  5660. Memo string `json:"memo"`
  5661. OverlmtAmt float64 `json:"overlmt_amt"`
  5662. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5663. Pric float64 `json:"pric"`
  5664. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5665. SelfpayProp float64 `json:"selfpay_prop"`
  5666. } `json:"result"`
  5667. } `json:"output"`
  5668. }
  5669. type Response struct {
  5670. Output Output `json:"output"`
  5671. Infcode int `json:"infcode"`
  5672. InfRefMsgID string `json:"inf_refmsgid"`
  5673. RefMsgTime string `json:"refmsg_time"`
  5674. RespondTime string `json:"respond_time"`
  5675. ErrMsg string `json:"err_msg"`
  5676. WarnMsg string `json:"warn_msg"`
  5677. SignType string `json:"signtype"`
  5678. CAInfo string `json:"cainfo"`
  5679. }
  5680. func (c *HisApiController) Getquerydata() {
  5681. query_type, _ := c.GetInt64("type")
  5682. refd_setl_flag := c.GetString("refd_setl_flag")
  5683. med_type := c.GetString("med_type")
  5684. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5685. cert_no := c.GetString("cert_no")
  5686. psn_no := c.GetString("psn_no")
  5687. start_time := c.GetString("start_time")
  5688. end_time := c.GetString("end_time")
  5689. page, _ := c.GetInt64("page")
  5690. limit, _ := c.GetInt64("limit")
  5691. var bp models.BusinessParams5262
  5692. bp.RefdSetlFlag = refd_setl_flag
  5693. bp.MedType = med_type
  5694. bp.Certno = cert_no
  5695. bp.Psnno = psn_no
  5696. bp.QBegntime = start_time
  5697. bp.QEndtime = end_time
  5698. if query_type == 1 { //本地
  5699. Post5262(c, bp, page, limit)
  5700. } else { //异地
  5701. Post5267(c, bp, page, limit)
  5702. }
  5703. }
  5704. func (c *HisApiController) Drugscheck() {
  5705. admin_user_id, _ := c.GetInt64("admin_user_id")
  5706. adminUser := c.GetAdminUserInfo()
  5707. var queryResult []QueryResult
  5708. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5709. for _, item := range drugs {
  5710. result := QueryResult{
  5711. ID: item.ID,
  5712. Name: item.DrugName,
  5713. Code: item.MedicalInsuranceNumber,
  5714. List_type_code: "101",
  5715. }
  5716. queryResult = append(queryResult, result)
  5717. }
  5718. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5719. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5720. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5721. for _, item := range queryResult {
  5722. 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)
  5723. }
  5724. }
  5725. func (c *HisApiController) Goodcheck() {
  5726. admin_user_id, _ := c.GetInt64("admin_user_id")
  5727. adminUser := c.GetAdminUserInfo()
  5728. var queryResult []QueryResult
  5729. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5730. for _, item := range goods {
  5731. result := QueryResult{
  5732. ID: item.ID,
  5733. Name: item.GoodName,
  5734. Code: item.SocialSecurityDirectoryCode,
  5735. List_type_code: "301",
  5736. }
  5737. queryResult = append(queryResult, result)
  5738. }
  5739. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5740. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5741. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5742. for _, item := range queryResult {
  5743. 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)
  5744. //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)
  5745. }
  5746. }
  5747. func (c *HisApiController) Projectcheck() {
  5748. admin_user_id, _ := c.GetInt64("admin_user_id")
  5749. adminUser := c.GetAdminUserInfo()
  5750. var queryResult []QueryResult
  5751. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5752. for _, item := range projects {
  5753. result := QueryResult{
  5754. ID: item.ID,
  5755. Name: item.ProjectName,
  5756. Code: item.MedicalCode,
  5757. List_type_code: "201",
  5758. }
  5759. queryResult = append(queryResult, result)
  5760. }
  5761. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5762. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5763. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5764. for _, item := range queryResult {
  5765. 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)
  5766. }
  5767. }
  5768. //func (c *HisApiController)CancleDia(){
  5769. //
  5770. // id, _ := c.GetInt64("id")
  5771. // record_time := c.GetString("record_time")
  5772. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5773. //
  5774. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5775. //
  5776. // diagnosis_id := c.GetString("diagnosis")
  5777. // sick_type, _ := c.GetInt64("sick_type")
  5778. // reg_type, _ := c.GetInt64("p_type")
  5779. // begin_time := c.GetString("begin_time")
  5780. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5781. //
  5782. //
  5783. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5784. //
  5785. // fmt.Println(acct_used_flag)
  5786. //
  5787. //
  5788. // timeLayout := "2006-01-02"
  5789. // loc, _ := time.LoadLocation("Local")
  5790. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5791. // if err != nil {
  5792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5793. // return
  5794. // }
  5795. // recordDateTime := theTime.Unix()
  5796. // adminUser := c.GetAdminUserInfo()
  5797. //
  5798. //
  5799. //
  5800. //
  5801. //
  5802. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5803. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  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. // //if patientPrescription.Do
  5810. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5811. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5812. //
  5813. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5814. //
  5815. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5816. //
  5817. // var config []*models.HisXtDiagnoseConfig
  5818. // for _, item := range diagnosis_ids {
  5819. // id, _ := strconv.ParseInt(item, 10, 64)
  5820. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5821. // config = append(config, &diagnosisConfig)
  5822. // }
  5823. //
  5824. // sickConfig, _ := service.FindSickById(sick_type)
  5825. //
  5826. //
  5827. // data := make(map[string]interface{})
  5828. // client := &http.Client{}
  5829. // data["psn_no"] = his.PsnNo
  5830. // data["mdtrt_id"] = his.Number
  5831. // data["doctor"] = roles.UserName
  5832. // data["department"] = department.Name
  5833. // data["org_name"] = miConfig.OrgName
  5834. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5835. // data["doctor_id"] = doctor_info.DoctorNumber
  5836. // data["new_doctor_name"] = doctor_info.UserName
  5837. // data["fixmedins_code"] = miConfig.Code
  5838. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5839. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5840. // data["secret_key"] = miConfig.SecretKey
  5841. // data["sick_code"] = sickConfig.CountryCode
  5842. // data["sick_name"] = sickConfig.ClassName
  5843. // data["url"] = miConfig.Url
  5844. // data["ak"] = miConfig.AccessKey
  5845. // data["begin_time"] = begin_time
  5846. // data["cainfo"] = miConfig.Cainfo
  5847. // data["is_vaild"] = "0"
  5848. //
  5849. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5850. // data["config"] = config
  5851. // bytesData, _ := json.Marshal(data)
  5852. //
  5853. // var req *http.Request
  5854. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5855. // resp, _ := client.Do(req)
  5856. // defer resp.Body.Close()
  5857. // body, ioErr := ioutil.ReadAll(resp.Body)
  5858. // if ioErr != nil {
  5859. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5860. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5861. // return
  5862. // }
  5863. // var respJSON map[string]interface{}
  5864. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5865. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5867. // return
  5868. // }
  5869. //
  5870. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5871. // userJSONBytes, _ := json.Marshal(respJSON)
  5872. // fmt.Println("log")
  5873. // fmt.Println(string(userJSONBytes))
  5874. //
  5875. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5876. // utils.ErrorLog("解析失败:%v", err)
  5877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5878. // return
  5879. // }
  5880. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5881. // res2.Output = ressix10265.Output
  5882. // res2.ErrMsg = ressix10265.ErrMsg
  5883. // res2.Cainfo = ressix10265.Cainfo
  5884. // res2.WarnMsg = ressix10265.WarnMsg
  5885. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5886. // res2.Infcode = infocode
  5887. //
  5888. //}
  5889. func (c *HisApiController) Get4102() {
  5890. order_id, _ := c.GetInt64("order_id")
  5891. admin_user_id, _ := c.GetInt64("admin_user_id")
  5892. stas_type := c.GetString("stas_type")
  5893. order, _ := service.GetHisOrderByIDTwo(order_id)
  5894. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5895. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5896. var pp models.PublicParams
  5897. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5898. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5899. pp.FixmedinsName = miConfig.OrgName
  5900. pp.FixmedinsCode = miConfig.Code
  5901. pp.RequestUrl = miConfig.Url
  5902. pp.Cainfo = miConfig.Cainfo
  5903. pp.SecretKey = miConfig.SecretKey
  5904. pp.AccessKey = miConfig.AccessKey
  5905. pp.OpterName = curRoles.UserName
  5906. if miConfig.MdtrtareaAdmvs == "350500" {
  5907. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5908. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5909. saveLog(result, request, "4102", "清单确认")
  5910. var dat map[string]interface{}
  5911. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5912. fmt.Println(dat)
  5913. } else {
  5914. fmt.Println(err)
  5915. }
  5916. var empty ResultFourteen
  5917. userJSONBytes, _ := json.Marshal(dat)
  5918. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5919. utils.ErrorLog("解析失败:%v", err)
  5920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5921. return
  5922. }
  5923. if empty.Infcode == 0 {
  5924. c.ServeSuccessJSON(map[string]interface{}{
  5925. "msg": "确认成功",
  5926. })
  5927. return
  5928. }
  5929. } else {
  5930. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5931. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5932. result3, request3 := service.Jxyb4105(pp)
  5933. saveLog(result, request, "4102", "清单确认")
  5934. saveLog(result2, request2, "4103", "清单确认")
  5935. saveLog(result3, request3, "4105", "清单统计")
  5936. var dat map[string]interface{}
  5937. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5938. fmt.Println(dat)
  5939. } else {
  5940. fmt.Println(err)
  5941. }
  5942. var empty ResultFourteen
  5943. userJSONBytes, _ := json.Marshal(dat)
  5944. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5945. utils.ErrorLog("解析失败:%v", err)
  5946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5947. return
  5948. }
  5949. if empty.Infcode == 0 {
  5950. c.ServeSuccessJSON(map[string]interface{}{
  5951. "msg": "确认成功",
  5952. })
  5953. return
  5954. }
  5955. }
  5956. }
  5957. // 对账权限查询
  5958. func (c *HisApiController) Get3260() {
  5959. admin_user_id, _ := c.GetInt64("admin_user_id")
  5960. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5961. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5962. var api string
  5963. var res models.JSResult3260
  5964. if miConfig.MdtrtareaAdmvs == "320921" {
  5965. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5966. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5967. } else {
  5968. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5969. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5970. }
  5971. resp, requestErr := http.Get(api)
  5972. if requestErr != nil {
  5973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5974. return
  5975. }
  5976. body, ioErr := ioutil.ReadAll(resp.Body)
  5977. if ioErr != nil {
  5978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5980. return
  5981. }
  5982. var respJSON map[string]interface{}
  5983. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5986. return
  5987. }
  5988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5989. result, _ := json.Marshal(respJSON)
  5990. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5991. utils.ErrorLog("解析失败:%v", err)
  5992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5993. return
  5994. }
  5995. if res.Infcode == "0" {
  5996. c.ServeSuccessJSON(map[string]interface{}{
  5997. "result": res.Output.Data,
  5998. })
  5999. } else {
  6000. c.ServeSuccessJSON(map[string]interface{}{
  6001. "failed_code": -10,
  6002. "msg": res.ErrMsg,
  6003. })
  6004. return
  6005. }
  6006. }
  6007. func (c *HisApiController) Get3261() {
  6008. admin_user_id, _ := c.GetInt64("admin_user_id")
  6009. //month := c.GetString("month")
  6010. startTime := c.GetString("start_time")
  6011. //endTime, _ := c.GetString("end_time")
  6012. times := strings.Split(startTime, "-")
  6013. stmt_mon := times[0] + times[1]
  6014. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6015. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6016. var api string
  6017. var res models.JSResult3261
  6018. //var res10265 Result5301For10265
  6019. if miConfig.MdtrtareaAdmvs == "320921" {
  6020. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6021. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6022. } else {
  6023. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6024. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6025. }
  6026. resp, requestErr := http.Get(api)
  6027. if requestErr != nil {
  6028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6029. return
  6030. }
  6031. body, ioErr := ioutil.ReadAll(resp.Body)
  6032. if ioErr != nil {
  6033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6035. return
  6036. }
  6037. var respJSON map[string]interface{}
  6038. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6041. return
  6042. }
  6043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6044. result, _ := json.Marshal(respJSON)
  6045. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6046. utils.ErrorLog("解析失败:%v", err)
  6047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6048. return
  6049. }
  6050. if res.Infcode == "0" {
  6051. c.ServeSuccessJSON(map[string]interface{}{
  6052. "result": res.Output,
  6053. })
  6054. } else {
  6055. c.ServeSuccessJSON(map[string]interface{}{
  6056. "failed_code": -10,
  6057. "msg": res.ErrMsg,
  6058. })
  6059. return
  6060. }
  6061. }
  6062. type TempFun struct {
  6063. FundKey string
  6064. FundCode string
  6065. }
  6066. func (c *HisApiController) Get3262() {
  6067. admin_user_id, _ := c.GetInt64("admin_user_id")
  6068. startTime := c.GetString("start_time")
  6069. endTime := c.GetString("end_time")
  6070. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6071. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6072. //timeLayout := "2006-01-02"
  6073. //loc, _ := time.LoadLocation("Local")
  6074. //var theStartTIme int64
  6075. //if len(startTime) > 0 {
  6076. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6077. // if err != nil {
  6078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6079. // return
  6080. // }
  6081. // theStartTIme = theTime.Unix()
  6082. //}
  6083. //var theEndtTIme int64
  6084. //if len(endTime) > 0 {
  6085. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6086. // if err != nil {
  6087. // utils.ErrorLog(err.Error())
  6088. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6089. // return
  6090. // }
  6091. // theEndtTIme = theTime.Unix()
  6092. //}
  6093. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6094. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6095. for _, team := range datas {
  6096. fmt.Println(team.PsnTime)
  6097. for _, team_two := range datas_two {
  6098. fmt.Println(team_two.PsnTime)
  6099. if team.FundKey == team_two.FundKey {
  6100. fmt.Println(team_two.PsnTime)
  6101. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6102. fmt.Println(team.PsnTime)
  6103. }
  6104. }
  6105. }
  6106. fmt.Println("1111")
  6107. fmt.Println(datas)
  6108. fmt.Println("1111")
  6109. var twos []models.FixMonRecDetailFileInTwo
  6110. for _, team := range datas {
  6111. var two models.FixMonRecDetailFileInTwo
  6112. two.MedType = team.MedType
  6113. two.Insutype = team.Insutype
  6114. two.PsnType = team.PsnType
  6115. two.MedType = team.MedType
  6116. two.FixBlngAdmdvs = "999999"
  6117. two.InsuAdmdvs = "555555"
  6118. two.PsnTime = team.PsnTime
  6119. two.PsnCnt = team.PsnCnt
  6120. two.FundKey = team.FundKey
  6121. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6122. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6123. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6124. two.MedfeeSumAmt = ms
  6125. two.InscpAmt = ia
  6126. two.FundPaySumAmt = fps
  6127. twos = append(twos, two)
  6128. }
  6129. //startTime := c.GetString("start_time")
  6130. //endTime, _ := c.GetString("end_time")
  6131. times := strings.Split(startTime, "-")
  6132. stmt_mon := times[0] + times[1]
  6133. var funs []models.FundDetail
  6134. for _, item := range datas {
  6135. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6136. funs = append(funs, fun...)
  6137. }
  6138. var funInfos []models.Fund
  6139. //for _, item := range funs {
  6140. // var rf []models.FundInfo
  6141. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6142. // for _, subitem := range rf {
  6143. // var fund models.Fund
  6144. // fund.FundCode = subitem.FundPayType
  6145. // fund.FundName = subitem.FundPayTypeName
  6146. // fund.FundAmt = subitem.FundPayAmt
  6147. // fund.FundKey = item.FundKey
  6148. // fund.InsuAdmdvs = "555555"
  6149. // fund.FixBlngAdmdvs = "999999"
  6150. // funInfos = append(funInfos, fund)
  6151. // }
  6152. //}
  6153. var tempFuns []TempFun
  6154. for _, funInfo := range funInfos {
  6155. var tempFun TempFun
  6156. tempFun.FundKey = funInfo.FundKey
  6157. tempFun.FundCode = funInfo.FundCode
  6158. tempFuns = append(tempFuns, tempFun)
  6159. }
  6160. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6161. fmt.Println(tempFuns)
  6162. var funInfosTwo []models.Fund
  6163. decimal.DivisionPrecision = 2
  6164. for _, item := range tempFuns {
  6165. var fund models.Fund
  6166. for _, subItem := range funInfos {
  6167. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6168. fund.FundKey = subItem.FundKey
  6169. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6170. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6171. fund.FundName = subItem.FundName
  6172. fund.FundCode = subItem.FundCode
  6173. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6174. }
  6175. }
  6176. funInfosTwo = append(funInfosTwo, fund)
  6177. }
  6178. fmt.Println("funInfosTwo")
  6179. fmt.Println(funInfosTwo)
  6180. var upld_btch string
  6181. var empty models.JSResultEmpty
  6182. data := make(map[string]interface{})
  6183. data["org_name"] = miConfig.OrgName
  6184. data["doctor"] = curRoles.UserName
  6185. data["doctor_name"] = curRoles.UserName
  6186. data["fixmedins_code"] = miConfig.Code
  6187. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6188. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6189. data["secret_key"] = miConfig.SecretKey
  6190. data["url"] = miConfig.Url
  6191. data["ak"] = miConfig.AccessKey
  6192. data["cainfo"] = miConfig.Cainfo
  6193. data["datas"] = twos
  6194. data["fund"] = funInfosTwo
  6195. fmt.Println(twos)
  6196. month := time.Unix(1557042972, 0).Format("1")
  6197. year := time.Now().Format("2006")
  6198. month = time.Now().Format("01")
  6199. day := time.Now().Format("02")
  6200. hour := time.Now().Format("15")
  6201. min := time.Now().Format("04")
  6202. sec := time.Now().Format("05")
  6203. fix_fill_date := year + month + day + hour + min + sec
  6204. data["fix_fill_dept"] = miConfig.OrgName
  6205. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6206. data["fix_fill_psn"] = curRoles.UserName
  6207. data["fix_fill_date"] = fix_fill_date
  6208. data["stmt_loc"] = "2"
  6209. data["setl_mon"] = stmt_mon
  6210. upld_btch = "0"
  6211. data["upld_btch"] = upld_btch
  6212. //fmt.Println(data)
  6213. client := &http.Client{}
  6214. bytesData, _ := json.Marshal(data)
  6215. var req *http.Request
  6216. if miConfig.MdtrtareaAdmvs == "320921" {
  6217. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6218. } else {
  6219. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6220. }
  6221. resp, _ := client.Do(req)
  6222. defer resp.Body.Close()
  6223. body, ioErr := ioutil.ReadAll(resp.Body)
  6224. if ioErr != nil {
  6225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6227. }
  6228. var respJSON map[string]interface{}
  6229. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6232. }
  6233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6234. //fmt.Println(respJSON)
  6235. result, _ := json.Marshal(respJSON)
  6236. //fmt.Println(result)
  6237. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6238. utils.ErrorLog("解析失败:%v", err)
  6239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6240. }
  6241. if empty.Infcode != "0" {
  6242. c.ServeSuccessJSON(map[string]interface{}{
  6243. "failed_code": -10,
  6244. "msg": empty.ErrMsg,
  6245. })
  6246. return
  6247. } else {
  6248. c.ServeSuccessJSON(map[string]interface{}{
  6249. "msg": "上传成功",
  6250. })
  6251. return
  6252. }
  6253. }
  6254. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6255. newArr = make([]TempFun, 0)
  6256. for i := 0; i < len(arr); i++ {
  6257. repeat := false
  6258. for j := i + 1; j < len(arr); j++ {
  6259. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6260. repeat = true
  6261. break
  6262. }
  6263. }
  6264. if !repeat {
  6265. newArr = append(newArr, arr[i])
  6266. }
  6267. }
  6268. return
  6269. }
  6270. func (c *HisApiController) Get3263() {
  6271. admin_user_id, _ := c.GetInt64("admin_user_id")
  6272. startTime := c.GetString("start_time")
  6273. //endTime, _ := c.GetString("end_time")
  6274. times := strings.Split(startTime, "-")
  6275. setl_mon := times[0] + times[1]
  6276. upld_btch := "0"
  6277. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6278. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6279. var result3263 models.JSResult3263
  6280. data := make(map[string]interface{})
  6281. data["org_name"] = miConfig.OrgName
  6282. data["doctor"] = curRoles.UserName
  6283. data["doctor_name"] = curRoles.UserName
  6284. data["fixmedins_code"] = miConfig.Code
  6285. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6286. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6287. data["secret_key"] = miConfig.SecretKey
  6288. data["url"] = miConfig.Url
  6289. data["ak"] = miConfig.AccessKey
  6290. data["cainfo"] = miConfig.Cainfo
  6291. data["setl_mon"] = setl_mon
  6292. data["stmt_loc"] = "2"
  6293. data["upld_btch"] = upld_btch
  6294. client := &http.Client{}
  6295. bytesData, _ := json.Marshal(data)
  6296. var req *http.Request
  6297. if miConfig.MdtrtareaAdmvs == "320921" {
  6298. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6299. } else {
  6300. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6301. }
  6302. resp, _ := client.Do(req)
  6303. defer resp.Body.Close()
  6304. body, ioErr := ioutil.ReadAll(resp.Body)
  6305. if ioErr != nil {
  6306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6308. }
  6309. var respJSON map[string]interface{}
  6310. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6313. }
  6314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6315. fmt.Println(respJSON)
  6316. result, _ := json.Marshal(respJSON)
  6317. fmt.Println(result)
  6318. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6319. utils.ErrorLog("解析失败:%v", err)
  6320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6321. }
  6322. if result3263.Infcode != "0" {
  6323. c.ServeSuccessJSON(map[string]interface{}{
  6324. "failed_code": -10,
  6325. "msg": result3263.ErrMsg,
  6326. })
  6327. return
  6328. } else {
  6329. c.ServeSuccessJSON(map[string]interface{}{
  6330. "list": result3263.Output,
  6331. })
  6332. return
  6333. }
  6334. }
  6335. func (c *HisApiController) Get3264() {
  6336. admin_user_id, _ := c.GetInt64("admin_user_id")
  6337. startTime := c.GetString("start_time")
  6338. //endTime, _ := c.GetString("end_time")
  6339. times := strings.Split(startTime, "-")
  6340. setl_mon := times[0] + times[1]
  6341. upld_btch := "0"
  6342. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6343. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6344. //solidify_id := []
  6345. var result3263 models.JSResult3263
  6346. data := make(map[string]interface{})
  6347. data["org_name"] = miConfig.OrgName
  6348. data["doctor"] = curRoles.UserName
  6349. data["doctor_name"] = curRoles.UserName
  6350. data["fixmedins_code"] = miConfig.Code
  6351. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6352. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6353. data["secret_key"] = miConfig.SecretKey
  6354. data["url"] = miConfig.Url
  6355. data["ak"] = miConfig.AccessKey
  6356. data["cainfo"] = miConfig.Cainfo
  6357. data["setl_mon"] = setl_mon
  6358. data["stmt_loc"] = "2"
  6359. data["upld_btch"] = upld_btch
  6360. client := &http.Client{}
  6361. bytesData, _ := json.Marshal(data)
  6362. var req3263 *http.Request
  6363. if miConfig.MdtrtareaAdmvs == "320921" {
  6364. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6365. } else {
  6366. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6367. }
  6368. resp, _ := client.Do(req3263)
  6369. defer resp.Body.Close()
  6370. body, ioErr := ioutil.ReadAll(resp.Body)
  6371. if ioErr != nil {
  6372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6374. }
  6375. var respJSON3263 map[string]interface{}
  6376. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6379. }
  6380. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6381. fmt.Println(respJSON3263)
  6382. result, _ := json.Marshal(respJSON3263)
  6383. fmt.Println(result)
  6384. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6385. utils.ErrorLog("解析失败:%v", err)
  6386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6387. }
  6388. var ids []string
  6389. for _, item := range result3263.Output {
  6390. ids = append(ids, item.SolidifyID)
  6391. }
  6392. var empty models.JSResultEmpty
  6393. data2 := make(map[string]interface{})
  6394. data2["org_name"] = miConfig.OrgName
  6395. data2["doctor"] = curRoles.UserName
  6396. data2["doctor_name"] = curRoles.UserName
  6397. data2["fixmedins_code"] = miConfig.Code
  6398. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6399. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6400. data2["secret_key"] = miConfig.SecretKey
  6401. data2["url"] = miConfig.Url
  6402. data2["ak"] = miConfig.AccessKey
  6403. data2["cainfo"] = miConfig.Cainfo
  6404. data2["setl_mon"] = setl_mon
  6405. data2["stmt_loc"] = "2"
  6406. data2["upld_btch"] = upld_btch
  6407. data2["solidify_id"] = ids
  6408. client2 := &http.Client{}
  6409. bytesData2, _ := json.Marshal(data2)
  6410. var req *http.Request
  6411. if miConfig.MdtrtareaAdmvs == "320921" {
  6412. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6413. } else {
  6414. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6415. }
  6416. resp2, _ := client2.Do(req)
  6417. defer resp.Body.Close()
  6418. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6419. if ioErr2 != nil {
  6420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6422. }
  6423. var respJSON map[string]interface{}
  6424. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6427. }
  6428. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6429. fmt.Println(respJSON)
  6430. result2, _ := json.Marshal(respJSON)
  6431. fmt.Println(result2)
  6432. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6433. utils.ErrorLog("解析失败:%v", err)
  6434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6435. }
  6436. if empty.Infcode != "0" {
  6437. c.ServeSuccessJSON(map[string]interface{}{
  6438. "failed_code": -10,
  6439. "msg": empty.ErrMsg,
  6440. })
  6441. return
  6442. } else {
  6443. c.ServeSuccessJSON(map[string]interface{}{
  6444. "msg": "",
  6445. })
  6446. return
  6447. }
  6448. }
  6449. func (c *HisApiController) Get3265() {
  6450. admin_user_id, _ := c.GetInt64("admin_user_id")
  6451. startTime := c.GetString("start_time")
  6452. //endTime, _ := c.GetString("end_time")
  6453. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6454. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6455. times := strings.Split(startTime, "-")
  6456. setl_mon := times[0] + times[1]
  6457. var upld_btch string
  6458. upld_btch = "0"
  6459. //var empty models.JSResultEmpty
  6460. var result3265 models.JSResult3264
  6461. var result3263 models.JSResult3263
  6462. data2 := make(map[string]interface{})
  6463. data2["org_name"] = miConfig.OrgName
  6464. data2["doctor"] = curRoles.UserName
  6465. data2["doctor_name"] = curRoles.UserName
  6466. data2["fixmedins_code"] = miConfig.Code
  6467. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6468. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6469. data2["secret_key"] = miConfig.SecretKey
  6470. data2["url"] = miConfig.Url
  6471. data2["ak"] = miConfig.AccessKey
  6472. data2["cainfo"] = miConfig.Cainfo
  6473. data2["setl_mon"] = setl_mon
  6474. data2["stmt_loc"] = "2"
  6475. data2["upld_btch"] = upld_btch
  6476. client2 := &http.Client{}
  6477. bytesData2, _ := json.Marshal(data2)
  6478. var req3263 *http.Request
  6479. if miConfig.MdtrtareaAdmvs == "320921" {
  6480. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6481. } else {
  6482. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6483. }
  6484. resp2, _ := client2.Do(req3263)
  6485. defer resp2.Body.Close()
  6486. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6487. if ioErr2 != nil {
  6488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6490. }
  6491. var respJSON3263 map[string]interface{}
  6492. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6495. }
  6496. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6497. fmt.Println(respJSON3263)
  6498. result2, _ := json.Marshal(respJSON3263)
  6499. fmt.Println(result2)
  6500. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6501. utils.ErrorLog("解析失败:%v", err)
  6502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6503. }
  6504. var ids []string
  6505. for _, item := range result3263.Output {
  6506. ids = append(ids, item.SolidifyID)
  6507. }
  6508. data := make(map[string]interface{})
  6509. data["org_name"] = miConfig.OrgName
  6510. data["doctor"] = curRoles.UserName
  6511. data["doctor_name"] = curRoles.UserName
  6512. data["fixmedins_code"] = miConfig.Code
  6513. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6514. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6515. data["secret_key"] = miConfig.SecretKey
  6516. data["url"] = miConfig.Url
  6517. data["ak"] = miConfig.AccessKey
  6518. data["cainfo"] = miConfig.Cainfo
  6519. data["setl_mon"] = setl_mon
  6520. data["solidify_id"] = ids
  6521. month := time.Unix(1557042972, 0).Format("1")
  6522. year := time.Now().Format("2006")
  6523. month = time.Now().Format("01")
  6524. day := time.Now().Format("02")
  6525. hour := time.Now().Format("15")
  6526. min := time.Now().Format("04")
  6527. sec := time.Now().Format("05")
  6528. fix_fill_date := year + month + day + hour + min + sec
  6529. data["fix_fill_dept"] = miConfig.OrgName
  6530. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6531. data["fix_fill_psn"] = curRoles.UserName
  6532. data["fix_fill_date"] = fix_fill_date
  6533. data["stmt_loc"] = "2"
  6534. data["upld_btch"] = upld_btch
  6535. client := &http.Client{}
  6536. bytesData, _ := json.Marshal(data)
  6537. var req *http.Request
  6538. if miConfig.MdtrtareaAdmvs == "320921" {
  6539. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6540. } else {
  6541. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6542. }
  6543. resp, _ := client.Do(req)
  6544. defer resp.Body.Close()
  6545. body, ioErr := ioutil.ReadAll(resp.Body)
  6546. if ioErr != nil {
  6547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6549. }
  6550. var respJSON map[string]interface{}
  6551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6554. }
  6555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6556. fmt.Println(respJSON)
  6557. result, _ := json.Marshal(respJSON)
  6558. fmt.Println(result)
  6559. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6560. utils.ErrorLog("解析失败:%v", err)
  6561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6562. }
  6563. if result3265.Infcode != "0" {
  6564. c.ServeSuccessJSON(map[string]interface{}{
  6565. "failed_code": -10,
  6566. "msg": result3265.ErrMsg,
  6567. })
  6568. return
  6569. } else {
  6570. c.ServeSuccessJSON(map[string]interface{}{
  6571. "info": result3265.Output,
  6572. })
  6573. return
  6574. }
  6575. }
  6576. func (c *HisApiController) Get3266() {
  6577. admin_user_id, _ := c.GetInt64("admin_user_id")
  6578. startTime := c.GetString("start_time")
  6579. //endTime, _ := c.GetString("end_time")
  6580. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6581. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6582. times := strings.Split(startTime, "-")
  6583. stmt_mon := times[0] + times[1]
  6584. var upld_btch string
  6585. //var empty models.JSResultEmpty
  6586. var result3265 models.JSResult3264
  6587. data := make(map[string]interface{})
  6588. data["org_name"] = miConfig.OrgName
  6589. data["doctor"] = curRoles.UserName
  6590. data["doctor_name"] = curRoles.UserName
  6591. data["fixmedins_code"] = miConfig.Code
  6592. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6593. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6594. data["secret_key"] = miConfig.SecretKey
  6595. data["url"] = miConfig.Url
  6596. data["ak"] = miConfig.AccessKey
  6597. data["cainfo"] = miConfig.Cainfo
  6598. data["setl_mon"] = stmt_mon
  6599. month := time.Unix(1557042972, 0).Format("1")
  6600. year := time.Now().Format("2006")
  6601. month = time.Now().Format("01")
  6602. day := time.Now().Format("02")
  6603. hour := time.Now().Format("15")
  6604. min := time.Now().Format("04")
  6605. sec := time.Now().Format("05")
  6606. fix_fill_date := year + month + day + hour + min + sec
  6607. data["fix_fill_dept"] = miConfig.OrgName
  6608. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6609. data["fix_fill_psn"] = curRoles.UserName
  6610. data["fix_fill_date"] = fix_fill_date
  6611. data["stmt_loc"] = "2"
  6612. upld_btch = "0"
  6613. data["upld_btch"] = upld_btch
  6614. client := &http.Client{}
  6615. bytesData, _ := json.Marshal(data)
  6616. var req *http.Request
  6617. if miConfig.MdtrtareaAdmvs == "320921" {
  6618. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6619. } else {
  6620. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6621. }
  6622. resp, _ := client.Do(req)
  6623. defer resp.Body.Close()
  6624. body, ioErr := ioutil.ReadAll(resp.Body)
  6625. if ioErr != nil {
  6626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6628. }
  6629. var respJSON map[string]interface{}
  6630. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6633. }
  6634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6635. fmt.Println(respJSON)
  6636. result, _ := json.Marshal(respJSON)
  6637. fmt.Println(result)
  6638. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6639. utils.ErrorLog("解析失败:%v", err)
  6640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6641. }
  6642. if result3265.Infcode != "0" {
  6643. c.ServeSuccessJSON(map[string]interface{}{
  6644. "failed_code": -10,
  6645. "msg": result3265.ErrMsg,
  6646. })
  6647. return
  6648. } else {
  6649. c.ServeSuccessJSON(map[string]interface{}{
  6650. "info": result3265.Output,
  6651. })
  6652. return
  6653. }
  6654. }
  6655. func (c *HisApiController) Get3267() {
  6656. admin_user_id, _ := c.GetInt64("admin_user_id")
  6657. startTime := c.GetString("start_time")
  6658. //endTime, _ := c.GetString("end_time")
  6659. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6660. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6661. times := strings.Split(startTime, "-")
  6662. setl_mon := times[0] + times[1]
  6663. var upld_btch string
  6664. //var empty models.JSResultEmpty
  6665. var result3265 models.JSResult3264
  6666. upld_btch = "0"
  6667. data := make(map[string]interface{})
  6668. data["org_name"] = miConfig.OrgName
  6669. data["doctor"] = curRoles.UserName
  6670. data["doctor_name"] = curRoles.UserName
  6671. data["fixmedins_code"] = miConfig.Code
  6672. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6673. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6674. data["secret_key"] = miConfig.SecretKey
  6675. data["url"] = miConfig.Url
  6676. data["ak"] = miConfig.AccessKey
  6677. data["cainfo"] = miConfig.Cainfo
  6678. data["setl_mon"] = setl_mon
  6679. data["stmt_loc"] = "2"
  6680. data["upld_btch"] = upld_btch
  6681. client := &http.Client{}
  6682. bytesData, _ := json.Marshal(data)
  6683. var req *http.Request
  6684. if miConfig.MdtrtareaAdmvs == "320921" {
  6685. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6686. } else {
  6687. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6688. }
  6689. resp, _ := client.Do(req)
  6690. defer resp.Body.Close()
  6691. body, ioErr := ioutil.ReadAll(resp.Body)
  6692. if ioErr != nil {
  6693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6695. }
  6696. var respJSON map[string]interface{}
  6697. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6700. }
  6701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6702. fmt.Println(respJSON)
  6703. result, _ := json.Marshal(respJSON)
  6704. fmt.Println(result)
  6705. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6706. utils.ErrorLog("解析失败:%v", err)
  6707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6708. }
  6709. if result3265.Infcode != "0" {
  6710. c.ServeSuccessJSON(map[string]interface{}{
  6711. "failed_code": -10,
  6712. "msg": result3265.ErrMsg,
  6713. })
  6714. return
  6715. } else {
  6716. c.ServeSuccessJSON(map[string]interface{}{
  6717. "info": result3265.Output.Data,
  6718. })
  6719. return
  6720. }
  6721. }
  6722. func (c *HisApiController) Get3268() {
  6723. admin_user_id, _ := c.GetInt64("admin_user_id")
  6724. startTime := c.GetString("start_time")
  6725. endTime := c.GetString("end_time")
  6726. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6727. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6728. times := strings.Split(startTime, "-")
  6729. setl_mon := times[0] + times[1]
  6730. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6731. var twos []models.FixMonRecDetailFileInTwo
  6732. var funs []models.FundDetail
  6733. for _, item := range datas {
  6734. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6735. funs = append(funs, fun...)
  6736. }
  6737. var funInfos []models.Fund
  6738. //for _, item := range funs {
  6739. // var rf []models.FundInfo
  6740. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6741. // for _, subitem := range rf {
  6742. // var fund models.Fund
  6743. // fund.FundCode = subitem.FundPayType
  6744. // fund.FundName = subitem.FundPayTypeName
  6745. // fund.FundAmt = subitem.FundPayAmt
  6746. // fund.FundKey = item.FundKey
  6747. // fund.InsuAdmdvs = "555555"
  6748. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6749. // funInfos = append(funInfos, fund)
  6750. // }
  6751. //}
  6752. for _, team := range datas {
  6753. var two models.FixMonRecDetailFileInTwo
  6754. two.SetlDate = time.Now().Format("2006-01-02")
  6755. two.MedType = team.MedType
  6756. two.Insutype = team.Insutype
  6757. two.PsnType = team.PsnType
  6758. two.MedType = team.MedType
  6759. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6760. two.InsuAdmdvs = team.InsuAdmdvs
  6761. two.PsnTime = team.PsnTime
  6762. two.PsnCnt = team.PsnCnt
  6763. two.FundKey = team.FundKey
  6764. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6765. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6766. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6767. two.MedfeeSumAmt = ms
  6768. two.InscpAmt = ia
  6769. two.FundPaySumAmt = fps
  6770. twos = append(twos, two)
  6771. }
  6772. var upld_btch string
  6773. upld_btch = "0"
  6774. var empty models.JSResultEmpty
  6775. data := make(map[string]interface{})
  6776. data["org_name"] = miConfig.OrgName
  6777. data["doctor"] = curRoles.UserName
  6778. data["doctor_name"] = curRoles.UserName
  6779. data["fixmedins_code"] = miConfig.Code
  6780. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6782. data["secret_key"] = miConfig.SecretKey
  6783. data["url"] = miConfig.Url
  6784. data["ak"] = miConfig.AccessKey
  6785. data["cainfo"] = miConfig.Cainfo
  6786. data["datas"] = twos
  6787. data["fund"] = funInfos
  6788. data["setl_mon"] = setl_mon
  6789. month := time.Unix(1557042972, 0).Format("1")
  6790. year := time.Now().Format("2006")
  6791. month = time.Now().Format("01")
  6792. day := time.Now().Format("02")
  6793. hour := time.Now().Format("15")
  6794. min := time.Now().Format("04")
  6795. sec := time.Now().Format("05")
  6796. fix_fill_date := year + month + day + hour + min + sec
  6797. data["fix_fill_dept"] = miConfig.OrgName
  6798. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6799. data["fix_fill_psn"] = curRoles.UserName
  6800. data["fix_fill_date"] = fix_fill_date
  6801. data["stmt_loc"] = "2"
  6802. data["upld_btch"] = upld_btch
  6803. client := &http.Client{}
  6804. bytesData, _ := json.Marshal(data)
  6805. var req *http.Request
  6806. if miConfig.MdtrtareaAdmvs == "320921" {
  6807. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6808. } else {
  6809. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6810. }
  6811. resp, _ := client.Do(req)
  6812. defer resp.Body.Close()
  6813. body, ioErr := ioutil.ReadAll(resp.Body)
  6814. if ioErr != nil {
  6815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6817. }
  6818. var respJSON map[string]interface{}
  6819. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6822. }
  6823. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6824. fmt.Println(respJSON)
  6825. result, _ := json.Marshal(respJSON)
  6826. fmt.Println(result)
  6827. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6828. utils.ErrorLog("解析失败:%v", err)
  6829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6830. }
  6831. if empty.Infcode != "0" {
  6832. c.ServeSuccessJSON(map[string]interface{}{
  6833. "failed_code": -10,
  6834. "msg": empty.ErrMsg,
  6835. })
  6836. return
  6837. } else {
  6838. c.ServeSuccessJSON(map[string]interface{}{
  6839. "msg": "上传成功",
  6840. })
  6841. return
  6842. }
  6843. }
  6844. func (c *HisApiController) Get3269() {
  6845. admin_user_id, _ := c.GetInt64("admin_user_id")
  6846. startTime := c.GetString("start_time")
  6847. //endTime, _ := c.GetString("end_time")
  6848. times := strings.Split(startTime, "-")
  6849. setl_mon := times[0] + times[1]
  6850. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6851. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6852. var result3263 models.JSResult3263
  6853. data := make(map[string]interface{})
  6854. data["org_name"] = miConfig.OrgName
  6855. data["doctor"] = curRoles.UserName
  6856. data["doctor_name"] = curRoles.UserName
  6857. data["fixmedins_code"] = miConfig.Code
  6858. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6859. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6860. data["secret_key"] = miConfig.SecretKey
  6861. data["url"] = miConfig.Url
  6862. data["ak"] = miConfig.AccessKey
  6863. data["cainfo"] = miConfig.Cainfo
  6864. data["setl_mon"] = setl_mon
  6865. data["stmt_loc"] = "2"
  6866. client := &http.Client{}
  6867. bytesData, _ := json.Marshal(data)
  6868. var req *http.Request
  6869. if miConfig.MdtrtareaAdmvs == "320921" {
  6870. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6871. } else {
  6872. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6873. }
  6874. resp, _ := client.Do(req)
  6875. defer resp.Body.Close()
  6876. body, ioErr := ioutil.ReadAll(resp.Body)
  6877. if ioErr != nil {
  6878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6880. }
  6881. var respJSON map[string]interface{}
  6882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6885. }
  6886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6887. fmt.Println(respJSON)
  6888. result, _ := json.Marshal(respJSON)
  6889. fmt.Println(result)
  6890. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6891. utils.ErrorLog("解析失败:%v", err)
  6892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6893. }
  6894. if result3263.Infcode != "0" {
  6895. c.ServeSuccessJSON(map[string]interface{}{
  6896. "failed_code": -10,
  6897. "msg": result3263.ErrMsg,
  6898. })
  6899. return
  6900. } else {
  6901. c.ServeSuccessJSON(map[string]interface{}{
  6902. "msg": "上传成功",
  6903. })
  6904. return
  6905. }
  6906. }
  6907. func (c *HisApiController) Get3270() {
  6908. admin_user_id, _ := c.GetInt64("admin_user_id")
  6909. startTime := c.GetString("start_time")
  6910. //endTime, _ := c.GetString("end_time")
  6911. times := strings.Split(startTime, "-")
  6912. setl_mon := times[0] + times[1]
  6913. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6914. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6915. var result3263 models.JSResult3263
  6916. data2 := make(map[string]interface{})
  6917. data2["org_name"] = miConfig.OrgName
  6918. data2["doctor"] = curRoles.UserName
  6919. data2["doctor_name"] = curRoles.UserName
  6920. data2["fixmedins_code"] = miConfig.Code
  6921. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6922. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6923. data2["secret_key"] = miConfig.SecretKey
  6924. data2["url"] = miConfig.Url
  6925. data2["ak"] = miConfig.AccessKey
  6926. data2["cainfo"] = miConfig.Cainfo
  6927. data2["setl_mon"] = setl_mon
  6928. data2["stmt_loc"] = "2"
  6929. client2 := &http.Client{}
  6930. bytesData2, _ := json.Marshal(data2)
  6931. var req3263 *http.Request
  6932. if miConfig.MdtrtareaAdmvs == "320921" {
  6933. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6934. } else {
  6935. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6936. }
  6937. resp2, _ := client2.Do(req3263)
  6938. defer resp2.Body.Close()
  6939. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6940. if ioErr2 != nil {
  6941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6943. }
  6944. var respJSON3263 map[string]interface{}
  6945. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6948. }
  6949. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6950. fmt.Println(respJSON3263)
  6951. result2, _ := json.Marshal(respJSON3263)
  6952. fmt.Println(result2)
  6953. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6954. utils.ErrorLog("解析失败:%v", err)
  6955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6956. }
  6957. var ids []string
  6958. for _, item := range result3263.Output {
  6959. ids = append(ids, item.SolidifyID)
  6960. }
  6961. var result3264 models.JSResult3264
  6962. data := make(map[string]interface{})
  6963. data["org_name"] = miConfig.OrgName
  6964. data["doctor"] = curRoles.UserName
  6965. data["doctor_name"] = curRoles.UserName
  6966. data["fixmedins_code"] = miConfig.Code
  6967. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6968. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6969. data["secret_key"] = miConfig.SecretKey
  6970. data["url"] = miConfig.Url
  6971. data["ak"] = miConfig.AccessKey
  6972. data["cainfo"] = miConfig.Cainfo
  6973. data["setl_mon"] = setl_mon
  6974. data["stmt_loc"] = "2"
  6975. data["solidify_id"] = ids
  6976. client := &http.Client{}
  6977. bytesData, _ := json.Marshal(data)
  6978. var req *http.Request
  6979. if miConfig.MdtrtareaAdmvs == "320921" {
  6980. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6981. } else {
  6982. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6983. }
  6984. resp, _ := client.Do(req)
  6985. defer resp.Body.Close()
  6986. body, ioErr := ioutil.ReadAll(resp.Body)
  6987. if ioErr != nil {
  6988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6990. }
  6991. var respJSON map[string]interface{}
  6992. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6995. }
  6996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6997. fmt.Println(respJSON)
  6998. result, _ := json.Marshal(respJSON)
  6999. fmt.Println(result)
  7000. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7001. utils.ErrorLog("解析失败:%v", err)
  7002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7003. }
  7004. if result3264.Infcode != "0" {
  7005. c.ServeSuccessJSON(map[string]interface{}{
  7006. "failed_code": -10,
  7007. "msg": result3264.ErrMsg,
  7008. })
  7009. return
  7010. } else {
  7011. c.ServeSuccessJSON(map[string]interface{}{
  7012. "info": result3264.Output,
  7013. })
  7014. return
  7015. }
  7016. }
  7017. func (c *HisApiController) Get3271() {
  7018. admin_user_id, _ := c.GetInt64("admin_user_id")
  7019. startTime := c.GetString("start_time")
  7020. //endTime, _ := c.GetString("end_time")
  7021. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7022. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7023. times := strings.Split(startTime, "-")
  7024. setl_mon := times[0] + times[1]
  7025. //var empty models.JSResultEmpty
  7026. var result3265 models.JSResult3264
  7027. var result3263 models.JSResult3263
  7028. data2 := make(map[string]interface{})
  7029. data2["org_name"] = miConfig.OrgName
  7030. data2["doctor"] = curRoles.UserName
  7031. data2["doctor_name"] = curRoles.UserName
  7032. data2["fixmedins_code"] = miConfig.Code
  7033. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7034. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7035. data2["secret_key"] = miConfig.SecretKey
  7036. data2["url"] = miConfig.Url
  7037. data2["ak"] = miConfig.AccessKey
  7038. data2["cainfo"] = miConfig.Cainfo
  7039. data2["setl_mon"] = setl_mon
  7040. data2["stmt_loc"] = "2"
  7041. client2 := &http.Client{}
  7042. bytesData2, _ := json.Marshal(data2)
  7043. var req3263 *http.Request
  7044. if miConfig.MdtrtareaAdmvs == "320921" {
  7045. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7046. } else {
  7047. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7048. }
  7049. resp2, _ := client2.Do(req3263)
  7050. defer resp2.Body.Close()
  7051. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7052. if ioErr2 != nil {
  7053. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. }
  7056. var respJSON3263 map[string]interface{}
  7057. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7060. }
  7061. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7062. fmt.Println(respJSON3263)
  7063. result2, _ := json.Marshal(respJSON3263)
  7064. fmt.Println(result2)
  7065. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7066. utils.ErrorLog("解析失败:%v", err)
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. }
  7069. var ids []string
  7070. for _, item := range result3263.Output {
  7071. ids = append(ids, item.SolidifyID)
  7072. }
  7073. data := make(map[string]interface{})
  7074. data["org_name"] = miConfig.OrgName
  7075. data["doctor"] = curRoles.UserName
  7076. data["doctor_name"] = curRoles.UserName
  7077. data["fixmedins_code"] = miConfig.Code
  7078. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7079. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7080. data["secret_key"] = miConfig.SecretKey
  7081. data["url"] = miConfig.Url
  7082. data["ak"] = miConfig.AccessKey
  7083. data["cainfo"] = miConfig.Cainfo
  7084. data["setl_mon"] = setl_mon
  7085. data["solidify_id"] = ids
  7086. month := time.Unix(1557042972, 0).Format("1")
  7087. year := time.Now().Format("2006")
  7088. month = time.Now().Format("01")
  7089. day := time.Now().Format("02")
  7090. hour := time.Now().Format("15")
  7091. min := time.Now().Format("04")
  7092. sec := time.Now().Format("05")
  7093. fix_fill_date := year + month + day + hour + min + sec
  7094. data["fix_fill_dept"] = miConfig.OrgName
  7095. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7096. data["fix_fill_psn"] = curRoles.UserName
  7097. data["fix_fill_date"] = fix_fill_date
  7098. data["stmt_loc"] = "2"
  7099. client := &http.Client{}
  7100. bytesData, _ := json.Marshal(data)
  7101. var req *http.Request
  7102. if miConfig.MdtrtareaAdmvs == "320921" {
  7103. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7104. } else {
  7105. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7106. }
  7107. resp, _ := client.Do(req)
  7108. defer resp.Body.Close()
  7109. body, ioErr := ioutil.ReadAll(resp.Body)
  7110. if ioErr != nil {
  7111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7113. }
  7114. var respJSON map[string]interface{}
  7115. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7118. }
  7119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7120. fmt.Println(respJSON)
  7121. result, _ := json.Marshal(respJSON)
  7122. fmt.Println(result)
  7123. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7124. utils.ErrorLog("解析失败:%v", err)
  7125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7126. }
  7127. if result3265.Infcode != "0" {
  7128. c.ServeSuccessJSON(map[string]interface{}{
  7129. "failed_code": -10,
  7130. "msg": result3265.ErrMsg,
  7131. })
  7132. return
  7133. } else {
  7134. c.ServeSuccessJSON(map[string]interface{}{
  7135. "info": result3265.Output.Data,
  7136. })
  7137. return
  7138. }
  7139. }
  7140. func (c *HisApiController) Get3272() {
  7141. admin_user_id, _ := c.GetInt64("admin_user_id")
  7142. startTime := c.GetString("start_time")
  7143. //endTime, _ := c.GetString("end_time")
  7144. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7145. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7146. times := strings.Split(startTime, "-")
  7147. setl_mon := times[0] + times[1]
  7148. var upld_btch string
  7149. //var empty models.JSResultEmpty
  7150. var result3265 models.JSResult3264
  7151. data := make(map[string]interface{})
  7152. data["org_name"] = miConfig.OrgName
  7153. data["doctor"] = curRoles.UserName
  7154. data["doctor_name"] = curRoles.UserName
  7155. data["fixmedins_code"] = miConfig.Code
  7156. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7157. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7158. data["secret_key"] = miConfig.SecretKey
  7159. data["url"] = miConfig.Url
  7160. data["ak"] = miConfig.AccessKey
  7161. data["cainfo"] = miConfig.Cainfo
  7162. data["setl_mon"] = setl_mon
  7163. month := time.Unix(1557042972, 0).Format("1")
  7164. year := time.Now().Format("2006")
  7165. month = time.Now().Format("01")
  7166. day := time.Now().Format("02")
  7167. hour := time.Now().Format("15")
  7168. min := time.Now().Format("04")
  7169. sec := time.Now().Format("05")
  7170. fix_fill_date := year + month + day + hour + min + sec
  7171. data["fix_fill_dept"] = miConfig.OrgName
  7172. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7173. data["fix_fill_psn"] = curRoles.UserName
  7174. data["fix_fill_date"] = fix_fill_date
  7175. data["stmt_loc"] = "2"
  7176. data["upld_btch"] = upld_btch
  7177. client := &http.Client{}
  7178. bytesData, _ := json.Marshal(data)
  7179. var req *http.Request
  7180. if miConfig.MdtrtareaAdmvs == "320921" {
  7181. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7182. } else {
  7183. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7184. }
  7185. resp, _ := client.Do(req)
  7186. defer resp.Body.Close()
  7187. body, ioErr := ioutil.ReadAll(resp.Body)
  7188. if ioErr != nil {
  7189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7191. }
  7192. var respJSON map[string]interface{}
  7193. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7196. }
  7197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7198. fmt.Println(respJSON)
  7199. result, _ := json.Marshal(respJSON)
  7200. fmt.Println(result)
  7201. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7202. utils.ErrorLog("解析失败:%v", err)
  7203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7204. }
  7205. if result3265.Infcode != "0" {
  7206. c.ServeSuccessJSON(map[string]interface{}{
  7207. "failed_code": -10,
  7208. "msg": result3265.ErrMsg,
  7209. })
  7210. return
  7211. } else {
  7212. c.ServeSuccessJSON(map[string]interface{}{
  7213. "info": result3265.Output,
  7214. })
  7215. return
  7216. }
  7217. }
  7218. func (c *HisApiController) Get3273() {
  7219. admin_user_id, _ := c.GetInt64("admin_user_id")
  7220. startTime := c.GetString("start_time")
  7221. //endTime, _ := c.GetString("end_time")
  7222. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7223. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7224. times := strings.Split(startTime, "-")
  7225. setl_mon := times[0] + times[1]
  7226. var result3265 models.JSResult3264
  7227. data := make(map[string]interface{})
  7228. data["org_name"] = miConfig.OrgName
  7229. data["doctor"] = curRoles.UserName
  7230. data["doctor_name"] = curRoles.UserName
  7231. data["fixmedins_code"] = miConfig.Code
  7232. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7233. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7234. data["secret_key"] = miConfig.SecretKey
  7235. data["url"] = miConfig.Url
  7236. data["ak"] = miConfig.AccessKey
  7237. data["cainfo"] = miConfig.Cainfo
  7238. data["setl_mon"] = setl_mon
  7239. data["stmt_loc"] = "2"
  7240. client := &http.Client{}
  7241. bytesData, _ := json.Marshal(data)
  7242. var req *http.Request
  7243. if miConfig.MdtrtareaAdmvs == "320921" {
  7244. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7245. } else {
  7246. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7247. }
  7248. resp, _ := client.Do(req)
  7249. defer resp.Body.Close()
  7250. body, ioErr := ioutil.ReadAll(resp.Body)
  7251. if ioErr != nil {
  7252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7254. }
  7255. var respJSON map[string]interface{}
  7256. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7259. }
  7260. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7261. fmt.Println(respJSON)
  7262. result, _ := json.Marshal(respJSON)
  7263. fmt.Println(result)
  7264. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7265. utils.ErrorLog("解析失败:%v", err)
  7266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7267. }
  7268. if result3265.Infcode != "0" {
  7269. c.ServeSuccessJSON(map[string]interface{}{
  7270. "failed_code": -10,
  7271. "msg": result3265.ErrMsg,
  7272. })
  7273. return
  7274. } else {
  7275. c.ServeSuccessJSON(map[string]interface{}{
  7276. "info": result3265.Output.Data,
  7277. })
  7278. return
  7279. }
  7280. }
  7281. func (c *HisApiController) Get3274() {
  7282. //if miConfig.MdtrtareaAdmvs == "320921" {
  7283. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7284. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7285. // "&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
  7286. //
  7287. //} else {
  7288. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7289. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7290. // "&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
  7291. //
  7292. //}
  7293. }
  7294. func (c *HisApiController) Get3275() {
  7295. //if miConfig.MdtrtareaAdmvs == "320921" {
  7296. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7297. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7298. // "&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
  7299. //
  7300. //} else {
  7301. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7302. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7303. // "&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
  7304. //
  7305. //}
  7306. }
  7307. func (c *HisApiController) Get3276() {
  7308. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7309. //month := c.GetString("month")
  7310. //
  7311. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7312. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7313. //var api string
  7314. //var res Result5301
  7315. //
  7316. //if miConfig.MdtrtareaAdmvs == "320921" {
  7317. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7318. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7319. //} else {
  7320. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7321. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7322. //}
  7323. //
  7324. //resp, requestErr := http.Get(api)
  7325. //if requestErr != nil {
  7326. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7327. // return
  7328. //}
  7329. //
  7330. //body, ioErr := ioutil.ReadAll(resp.Body)
  7331. //if ioErr != nil {
  7332. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7334. // return
  7335. //}
  7336. //var respJSON map[string]interface{}
  7337. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7338. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7339. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7340. // return
  7341. //}
  7342. //
  7343. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7344. //result, _ := json.Marshal(respJSON)
  7345. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7346. // utils.ErrorLog("解析失败:%v", err)
  7347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7348. // return
  7349. //}
  7350. }
  7351. func (c *HisApiController) Get3277() {
  7352. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7353. //month := c.GetString("month")
  7354. //
  7355. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7356. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7357. //var api string
  7358. //var res Result5301
  7359. //
  7360. //if miConfig.MdtrtareaAdmvs == "320921" {
  7361. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7362. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7363. //} else {
  7364. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7365. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7366. //}
  7367. //
  7368. //resp, requestErr := http.Get(api)
  7369. //if requestErr != nil {
  7370. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7371. // return
  7372. //}
  7373. //
  7374. //body, ioErr := ioutil.ReadAll(resp.Body)
  7375. //if ioErr != nil {
  7376. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7378. // return
  7379. //}
  7380. //var respJSON map[string]interface{}
  7381. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7382. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7384. // return
  7385. //}
  7386. //
  7387. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7388. //result, _ := json.Marshal(respJSON)
  7389. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7390. // utils.ErrorLog("解析失败:%v", err)
  7391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7392. // return
  7393. //}
  7394. }
  7395. func (c *HisApiController) GetCFYLJG001() {
  7396. admin_user_id, _ := c.GetInt64("admin_user_id")
  7397. patient_id, _ := c.GetInt64("patient_id")
  7398. his_patient_id, _ := c.GetInt64("his_patient_id")
  7399. record_time := c.GetString("record_time")
  7400. admin_user_id = 3626
  7401. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7402. psn, _ := service.GetPsnByPatientId(patient_id)
  7403. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7404. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7405. var cFYLJG001 models.CFYLJG001
  7406. timeLayout := "2006-01-02"
  7407. loc, _ := time.LoadLocation("Local")
  7408. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7409. if err != nil {
  7410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7411. return
  7412. }
  7413. recordDateTime := theTime.Unix()
  7414. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7415. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7416. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7417. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7418. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7419. for _, item := range prescriptions {
  7420. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7421. if his.IdCardType == 1 {
  7422. bas := strings.Split(psn.CardInfo, "|")
  7423. basNumber := bas[1]
  7424. fmt.Println(basNumber)
  7425. card_sn := bas[3]
  7426. card_no := bas[2]
  7427. cFYLJG001.MdtrtCertType = "03"
  7428. cFYLJG001.CardSn = card_sn
  7429. cFYLJG001.MdtrtCertNo = card_no
  7430. cFYLJG001.EcToken = ""
  7431. cFYLJG001.AuthNo = ""
  7432. } else if his.IdCardType == 2 {
  7433. cFYLJG001.MdtrtCertType = "02"
  7434. cFYLJG001.CardSn = ""
  7435. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7436. cFYLJG001.EcToken = ""
  7437. cFYLJG001.AuthNo = ""
  7438. } else if his.IdCardType == 4 {
  7439. cFYLJG001.MdtrtCertType = "01"
  7440. cFYLJG001.CardSn = ""
  7441. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7442. cFYLJG001.EcToken = psn.VerifyNumber
  7443. cFYLJG001.AuthNo = ""
  7444. }
  7445. cFYLJG001.BizTypeCode = "01"
  7446. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7447. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7448. cFYLJG001.RxTypeCode = "1"
  7449. tempTime := time.Unix(item.PreTime, 0)
  7450. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7451. cFYLJG001.PrscTime = timeFormatOne
  7452. var count float64
  7453. if item.Type == 1 {
  7454. for _, sumItem := range item.HisDoctorAdviceInfo {
  7455. count = count + sumItem.PrescribingNumber
  7456. }
  7457. }
  7458. cFYLJG001.RxDrugCnt = count
  7459. cFYLJG001.ValiDays = "5"
  7460. ts := time.Unix(item.PreTime, 0)
  7461. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7462. tempTime3 := time.Unix(record_time2, 0)
  7463. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7464. cFYLJG001.ValiEndTime = timeFormat3
  7465. cFYLJG001.RxCotnFlag = "0"
  7466. for _, subItem := range item.HisDoctorAdviceInfo {
  7467. var drug models.RxDrug
  7468. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7469. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7470. drug.RxItemTypeCode = "11"
  7471. drug.DrugDosform = "乳膏剂" //TODO
  7472. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7473. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7474. }
  7475. drug.MedcWayDscr = subItem.DeliveryWay
  7476. tempTime2 := time.Unix(subItem.StartTime, 0)
  7477. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7478. drug.MedcBegntime = timeFormatTwo
  7479. if subItem.Day > 0 {
  7480. ts := time.Unix(subItem.StartTime, 0)
  7481. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7482. tempTime4 := time.Unix(record_time, 0)
  7483. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7484. drug.MedcEndtime = timeFormat5
  7485. } else {
  7486. tempTime2 := time.Unix(subItem.StartTime, 0)
  7487. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7488. drug.MedcEndtime = timeFormatTwo
  7489. }
  7490. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7491. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7492. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7493. drug.DrugCnt = subItem.PrescribingNumber
  7494. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7495. drug.DrugGenname = subItem.AdviceName
  7496. drug.MedcWayCodg = subItem.DeliveryWay
  7497. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7498. drug.SinDoscnt = subItem.SingleDose
  7499. drug.SinDosunt = subItem.SingleDoseUnit
  7500. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7501. drug.UsedFrquName = subItem.ExecutionFrequency
  7502. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7503. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7504. drug.HospApprFlag = "1"
  7505. cFYLJG001.List = append(cFYLJG001.List, drug)
  7506. }
  7507. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7508. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7509. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7510. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7511. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7512. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7513. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7514. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7515. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7516. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7517. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7518. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7519. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7520. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7521. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7522. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7523. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7524. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7525. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7526. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7527. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7528. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7529. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7530. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7531. tempTime2 := time.Now().Unix()
  7532. tempTime6 := time.Unix(tempTime2, 0)
  7533. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7534. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7535. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7536. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7537. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7538. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7539. //memo := make(map[string]interface{})
  7540. //inputData := make(map[string]interface{}, 0)
  7541. //type MyData struct {
  7542. // Insutype string `json:"insutype"`
  7543. //}
  7544. //
  7545. // data := MyData{
  7546. // Insutype: his.Insutype,
  7547. //}
  7548. //
  7549. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7550. var config []*models.HisXtDiagnoseConfig
  7551. for _, item := range diagnosis_ids {
  7552. id, _ := strconv.ParseInt(item, 10, 64)
  7553. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7554. config = append(config, &diagnosisConfig)
  7555. }
  7556. for index, subitem := range config {
  7557. if index == 0 {
  7558. var dia models.DiseInfo
  7559. dia.DiagType = "1"
  7560. dia.MaindiagFlag = "1"
  7561. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7562. dia.DiagCode = subitem.CountryCode
  7563. dia.DiagName = subitem.ClassName
  7564. dia.DiagDept = "肾内科"
  7565. dia.DiagDrNo = doctor.DoctorNumber
  7566. dia.DiagDrName = doctor.UserName
  7567. tempTime3 := time.Unix(item.PreTime, 0)
  7568. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7569. dia.DiagTime = timeFormatTwo
  7570. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7571. } else {
  7572. var dia models.DiseInfo
  7573. dia.DiagType = "1"
  7574. dia.MaindiagFlag = "0"
  7575. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7576. dia.DiagCode = subitem.CountryCode
  7577. dia.DiagName = subitem.ClassName
  7578. dia.DiagDept = "肾内科"
  7579. dia.DiagDrNo = doctor.DoctorNumber
  7580. dia.DiagDrName = doctor.UserName
  7581. tempTime3 := time.Unix(item.PreTime, 0)
  7582. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7583. dia.DiagTime = timeFormatTwo
  7584. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7585. }
  7586. }
  7587. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7588. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7589. var res ResultCFYLJG001
  7590. var respJSON2 map[string]interface{}
  7591. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7594. return
  7595. }
  7596. userJSONBytes2, _ := json.Marshal(respJSON2)
  7597. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7598. utils.ErrorLog("解析失败:%v", err)
  7599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7600. return
  7601. }
  7602. if res.Infcode == -1 {
  7603. c.ServeSuccessJSON(map[string]interface{}{
  7604. "failed_code": -10,
  7605. "msg": res.ErrMsg,
  7606. })
  7607. return
  7608. } else {
  7609. var flow models.HisPrescriptionFlow
  7610. flow.Ctime = time.Now().Unix()
  7611. flow.SignDigest = ""
  7612. flow.RxTraceCode = res.Output.RxTraceCode
  7613. flow.HiRxno = res.Output.HiRxno
  7614. flow.MID = his.Number
  7615. flow.Status = 1
  7616. flow.DCode = doctor_info.DoctorNumber
  7617. flow.OriginalRxFile = ""
  7618. flow.OriginalValue = ""
  7619. flow.SignCertDn = ""
  7620. flow.UserOrgId = 10454
  7621. flow.SignCertSn = ""
  7622. flow.Mtime = time.Now().Unix()
  7623. service.Createflow(&flow)
  7624. c.ServeSuccessJSON(map[string]interface{}{
  7625. "msg": "上传成功",
  7626. })
  7627. }
  7628. }
  7629. }
  7630. func (c *HisApiController) GetCFYLJG002() {
  7631. admin_user_id, _ := c.GetInt64("admin_user_id")
  7632. his_patient_id, _ := c.GetInt64("his_patient_id")
  7633. record_time := c.GetString("record_time")
  7634. admin_user_id = 3626
  7635. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7636. //id, _ := c.GetInt64("id")
  7637. admin_user_id = 3626
  7638. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7639. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7640. flow, _ := service.Getflowtwo(his.Number)
  7641. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7642. //record_time := c.GetString("record_time")
  7643. patient_id, _ := c.GetInt64("patient_id")
  7644. //patient_id = 23834
  7645. //record_time = "2023-09-18"
  7646. timeLayout := "2006-01-02"
  7647. loc, _ := time.LoadLocation("Local")
  7648. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7649. if err != nil {
  7650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7651. return
  7652. }
  7653. recordDateTime := theTime.Unix()
  7654. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7655. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7656. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7657. dept, _ := service.GetDepartMentDetail(info.Departments)
  7658. inputData := make(map[string]interface{})
  7659. inputData["rxTraceCode"] = flow.RxTraceCode
  7660. inputData["hiRxno"] = flow.HiRxno
  7661. inputData["mdtrtId"] = flow.MID
  7662. inputData["patnName"] = his.PsnName
  7663. inputData["psnCertType"] = his.PsnCertType
  7664. inputData["certno"] = his.Certno
  7665. inputData["fixmedinsName"] = miConfig.OrgName
  7666. inputData["fixmedinsCode"] = miConfig.Code
  7667. inputData["drCode"] = doctor_info.DoctorNumber
  7668. inputData["prscDrName"] = doctor_info.UserName
  7669. inputData["pharDeptName"] = dept.Name
  7670. inputData["pharDeptCode"] = dept.Number
  7671. inputData["pharProfttlCodg"] = dept.Name
  7672. inputData["pharProfttlName"] = ""
  7673. inputData["pharCode"] = "HY440309002107"
  7674. inputData["pharCertType"] = "01"
  7675. inputData["pharCertno"] = "430482199408260023"
  7676. inputData["pharName"] = "彭斯遥"
  7677. inputData["pharPracCertNo"] = ""
  7678. tempTime2 := time.Unix(info.Ctime, 0)
  7679. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7680. inputData["pharChkTime"] = timeFormatTwo
  7681. bytesData, _ := json.Marshal(inputData)
  7682. fmt.Println(string(bytesData))
  7683. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7684. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7685. if err != nil {
  7686. fmt.Println("Error reading PDF file:", err)
  7687. return
  7688. }
  7689. // 将 PDF 文件内容进行 Base64 编码
  7690. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7691. fmt.Println(err)
  7692. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7693. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7694. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7695. var res2 Result002
  7696. var respJSON2 map[string]interface{}
  7697. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7700. return
  7701. }
  7702. userJSONBytes2, _ := json.Marshal(respJSON2)
  7703. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7704. utils.ErrorLog("解析失败:%v", err)
  7705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7706. return
  7707. }
  7708. if res2.Infcode == 0 {
  7709. flow.Ctime = time.Now().Unix()
  7710. flow.SignDigest = res2.Output.SignDigest
  7711. flow.RxFile = res2.Output.RxFile
  7712. flow.MID = his.Number
  7713. flow.Status = 1
  7714. flow.DCode = doctor_info.DoctorNumber
  7715. flow.OriginalRxFile = rx_encoded
  7716. flow.OriginalValue = encoded
  7717. flow.SignCertDn = res2.Output.SignCertDn
  7718. flow.SignCertSn = res2.Output.SignCertSn
  7719. flow.Mtime = time.Now().Unix()
  7720. service.Saveflow(flow)
  7721. c.ServeSuccessJSON(map[string]interface{}{
  7722. "msg": "预签名成功",
  7723. })
  7724. } else {
  7725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7726. return
  7727. }
  7728. }
  7729. func (c *HisApiController) GetCFYLJG003() {
  7730. admin_user_id, _ := c.GetInt64("admin_user_id")
  7731. his_patient_id, _ := c.GetInt64("his_patient_id")
  7732. record_time := c.GetString("record_time")
  7733. admin_user_id = 3626
  7734. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7735. //id, _ := c.GetInt64("id")
  7736. admin_user_id = 3626
  7737. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7738. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7739. flow, _ := service.Getflowtwo(his.Number)
  7740. //id = 3
  7741. patient_id, _ := c.GetInt64("patient_id")
  7742. //patient_id = 23834
  7743. //record_time = "2023-09-18"
  7744. timeLayout := "2006-01-02"
  7745. loc, _ := time.LoadLocation("Local")
  7746. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7747. if err != nil {
  7748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7749. return
  7750. }
  7751. recordDateTime := theTime.Unix()
  7752. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7753. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7754. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7755. dept, _ := service.GetDepartMentDetail(info.Departments)
  7756. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7757. var cFYLJG003 models.CFYLJG003
  7758. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7759. cFYLJG003.HiRxno = flow.HiRxno
  7760. cFYLJG003.MdtrtID = flow.MID
  7761. cFYLJG003.PatnName = his.Name
  7762. cFYLJG003.Certno = his.Certno
  7763. cFYLJG003.FixmedinsName = miConfig.OrgName
  7764. cFYLJG003.FixmedinsCode = miConfig.Code
  7765. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7766. cFYLJG003.PrscDrName = doctor_info.UserName
  7767. cFYLJG003.PharDeptName = dept.Name
  7768. cFYLJG003.PharDeptCode = dept.Number
  7769. cFYLJG003.PharCode = "HY440309002107"
  7770. cFYLJG003.PharCertType = "01"
  7771. cFYLJG003.PharCertno = "430482199408260023"
  7772. cFYLJG003.PharName = "彭斯遥"
  7773. cFYLJG003.PsnCertType = "01"
  7774. cFYLJG003.RxFile = flow.RxFile
  7775. cFYLJG003.SignDigest = flow.SignDigest
  7776. cFYLJG003.FixmedinsCode = miConfig.Code
  7777. cFYLJG003.PsnCertType = "01"
  7778. cFYLJG003.PharProfttlCodg = dept.Name
  7779. //inputData["pharProfttlCodg"] =dept.Name
  7780. tempTime2 := time.Unix(info.Ctime, 0)
  7781. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7782. cFYLJG003.PharChkTime = timeFormatTwo
  7783. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7784. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7785. var res ResultCFYLJG003
  7786. var respJSON2 map[string]interface{}
  7787. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7790. return
  7791. }
  7792. userJSONBytes2, _ := json.Marshal(respJSON2)
  7793. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7794. utils.ErrorLog("解析失败:%v", err)
  7795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7796. return
  7797. }
  7798. if res.Infcode == -1 {
  7799. c.ServeSuccessJSON(map[string]interface{}{
  7800. "failed_code": -10,
  7801. "msg": res.ErrMsg,
  7802. })
  7803. return
  7804. } else {
  7805. c.ServeSuccessJSON(map[string]interface{}{
  7806. "info": res.Output,
  7807. })
  7808. }
  7809. }
  7810. func (c *HisApiController) GetCFYLJG004() {
  7811. admin_user_id, _ := c.GetInt64("admin_user_id")
  7812. his_patient_id, _ := c.GetInt64("his_patient_id")
  7813. record_time := c.GetString("record_time")
  7814. admin_user_id = 3626
  7815. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7816. //id, _ := c.GetInt64("id")
  7817. admin_user_id = 3626
  7818. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7819. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7820. flow, _ := service.Getflowtwo(his.Number)
  7821. //id = 3
  7822. patient_id, _ := c.GetInt64("patient_id")
  7823. //patient_id = 23834
  7824. //record_time = "2023-09-18"
  7825. timeLayout := "2006-01-02"
  7826. loc, _ := time.LoadLocation("Local")
  7827. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7828. if err != nil {
  7829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7830. return
  7831. }
  7832. recordDateTime := theTime.Unix()
  7833. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7834. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7835. var cFYLJG004 models.CFYLJG004
  7836. cFYLJG004.HiRxno = flow.HiRxno
  7837. cFYLJG004.FixmedinsCode = miConfig.Code
  7838. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7839. cFYLJG004.UndoDrCertType = "01"
  7840. cFYLJG004.UndoRea = "撤销处方"
  7841. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7842. cFYLJG004.UndoDrName = doctor_info.UserName
  7843. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7844. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7845. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7846. var res ResultCFYLJG004
  7847. var respJSON2 map[string]interface{}
  7848. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7851. return
  7852. }
  7853. userJSONBytes2, _ := json.Marshal(respJSON2)
  7854. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7855. utils.ErrorLog("解析失败:%v", err)
  7856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7857. return
  7858. }
  7859. if res.Infcode == -1 {
  7860. c.ServeSuccessJSON(map[string]interface{}{
  7861. "failed_code": -10,
  7862. "msg": res.ErrMsg,
  7863. })
  7864. return
  7865. } else {
  7866. flow.Status = 0
  7867. service.Saveflow(flow)
  7868. c.ServeSuccessJSON(map[string]interface{}{
  7869. "msg": "撤销成功",
  7870. })
  7871. return
  7872. }
  7873. }
  7874. func (c *HisApiController) GetCFYLJG005() {
  7875. admin_user_id, _ := c.GetInt64("admin_user_id")
  7876. his_patient_id, _ := c.GetInt64("his_patient_id")
  7877. //record_time := c.GetString("record_time")
  7878. admin_user_id = 3626
  7879. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7880. //id, _ := c.GetInt64("id")
  7881. admin_user_id = 3626
  7882. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7883. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7884. flow, _ := service.Getflowtwo(his.Number)
  7885. //id = 3
  7886. var cFYLJG005 models.CFYLJG005
  7887. //patient_id, _ := c.GetInt64("patient_id")
  7888. cFYLJG005.HiRxno = flow.HiRxno
  7889. cFYLJG005.MdtrtID = flow.MID
  7890. cFYLJG005.EcToken = ""
  7891. cFYLJG005.PsnName = his.Name
  7892. cFYLJG005.PsnCertType = "01"
  7893. cFYLJG005.Certno = his.IdCardNo
  7894. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7895. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7896. var res ResultCFYLJG005
  7897. var respJSON2 map[string]interface{}
  7898. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7901. return
  7902. }
  7903. userJSONBytes2, _ := json.Marshal(respJSON2)
  7904. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7905. utils.ErrorLog("解析失败:%v", err)
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7907. return
  7908. }
  7909. if res.Infcode == -1 {
  7910. c.ServeSuccessJSON(map[string]interface{}{
  7911. "failed_code": -10,
  7912. "msg": res.ErrMsg,
  7913. })
  7914. return
  7915. } else {
  7916. c.ServeSuccessJSON(map[string]interface{}{
  7917. "info": res.Output,
  7918. })
  7919. return
  7920. }
  7921. }
  7922. func (c *HisApiController) GetCFYLJG006() {
  7923. admin_user_id, _ := c.GetInt64("admin_user_id")
  7924. his_patient_id, _ := c.GetInt64("his_patient_id")
  7925. admin_user_id = 3626
  7926. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7927. //id, _ := c.GetInt64("id")
  7928. admin_user_id = 3626
  7929. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7930. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7931. flow, _ := service.Getflowtwo(his.Number)
  7932. //id = 3
  7933. patient_id, _ := c.GetInt64("patient_id")
  7934. var cFYLJG006 models.CFYLJG006
  7935. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7936. cFYLJG006.HiRxno = flow.HiRxno
  7937. cFYLJG006.MdtrtID = flow.MID
  7938. cFYLJG006.PsnName = patient.Name
  7939. cFYLJG006.PsnCertType = "01"
  7940. cFYLJG006.Certno = patient.IdCardNo
  7941. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7942. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7943. var res ResultCFYLJG006
  7944. var respJSON2 map[string]interface{}
  7945. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7948. return
  7949. }
  7950. userJSONBytes2, _ := json.Marshal(respJSON2)
  7951. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7952. utils.ErrorLog("解析失败:%v", err)
  7953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7954. return
  7955. }
  7956. if res.Infcode == -1 {
  7957. c.ServeSuccessJSON(map[string]interface{}{
  7958. "failed_code": -10,
  7959. "msg": res.ErrMsg,
  7960. })
  7961. return
  7962. } else {
  7963. c.ServeSuccessJSON(map[string]interface{}{
  7964. "info": res.Output,
  7965. })
  7966. return
  7967. }
  7968. }
  7969. func (c *HisApiController) GetCFYLJG007() {
  7970. admin_user_id, _ := c.GetInt64("admin_user_id")
  7971. his_patient_id, _ := c.GetInt64("his_patient_id")
  7972. admin_user_id = 3626
  7973. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7974. //id, _ := c.GetInt64("id")
  7975. admin_user_id = 3626
  7976. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7977. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7978. flow, _ := service.Getflowtwo(his.Number)
  7979. //id = 3
  7980. patient_id, _ := c.GetInt64("patient_id")
  7981. var cFYLJG007 models.CFYLJG007
  7982. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7983. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7984. cFYLJG007.HiRxno = flow.HiRxno
  7985. cFYLJG007.MdtrtID = flow.MID
  7986. cFYLJG007.PsnNo = his.PsnNo
  7987. cFYLJG007.PsnCertType = "01"
  7988. cFYLJG007.Certno = patient.IdCardNo
  7989. cFYLJG007.PsnName = patient.Name
  7990. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7991. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7992. var res ResultCFYLJG007
  7993. var respJSON2 map[string]interface{}
  7994. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7997. return
  7998. }
  7999. userJSONBytes2, _ := json.Marshal(respJSON2)
  8000. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8001. utils.ErrorLog("解析失败:%v", err)
  8002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8003. return
  8004. }
  8005. if res.Infcode == -1 {
  8006. c.ServeSuccessJSON(map[string]interface{}{
  8007. "failed_code": -10,
  8008. "msg": res.ErrMsg,
  8009. })
  8010. return
  8011. } else {
  8012. c.ServeSuccessJSON(map[string]interface{}{
  8013. "info": res,
  8014. })
  8015. return
  8016. }
  8017. }
  8018. func (c *HisApiController) GetCFYLJG008() {
  8019. admin_user_id, _ := c.GetInt64("admin_user_id")
  8020. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8021. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8022. var cFYLJG008 models.CFYLJG008
  8023. //id, _ := c.GetInt64("id")
  8024. patient_id, _ := c.GetInt64("patient_id")
  8025. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8026. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8027. //id = 3
  8028. //flow, _ := service.Getflow(id)
  8029. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8030. //
  8031. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8032. //patient_id, _ := c.GetInt64("patient_id")
  8033. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8034. record_time := c.GetString("record_time")
  8035. admin_user_id = 3626
  8036. patient_id = 19424
  8037. //his_patient_id = 263947
  8038. record_time = "2023-08-29"
  8039. timeLayout := "2006-01-02"
  8040. loc, _ := time.LoadLocation("Local")
  8041. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8042. if err != nil {
  8043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8044. return
  8045. }
  8046. recordDateTime := theTime.Unix()
  8047. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8048. cFYLJG008.FixmedinsName = ""
  8049. cFYLJG008.Lat = ""
  8050. cFYLJG008.Lng = ""
  8051. cFYLJG008.OrderType = "1"
  8052. cFYLJG008.PoolareaNo = ""
  8053. cFYLJG008.Lng = ""
  8054. cFYLJG008.PageNum = 1
  8055. cFYLJG008.PageSize = 10
  8056. var MPI models.MedinsProdInvChgDDTO
  8057. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8058. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8059. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8060. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8061. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8062. var res ResultCFYLJG008
  8063. var respJSON2 map[string]interface{}
  8064. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8067. return
  8068. }
  8069. userJSONBytes2, _ := json.Marshal(respJSON2)
  8070. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8071. utils.ErrorLog("解析失败:%v", err)
  8072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8073. return
  8074. }
  8075. if res.Infcode == -1 {
  8076. c.ServeSuccessJSON(map[string]interface{}{
  8077. "failed_code": -10,
  8078. "msg": res.ErrMsg,
  8079. })
  8080. return
  8081. } else {
  8082. c.ServeSuccessJSON(map[string]interface{}{
  8083. "info": res.Output,
  8084. })
  8085. return
  8086. }
  8087. }
  8088. func (c *HisApiController) GetBL4201A() {
  8089. order_id, _ := c.GetInt64("order_id")
  8090. admin_user_id, _ := c.GetInt64("admin_user_id")
  8091. order, _ := service.GetHisOrderByIDTwo(order_id)
  8092. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8093. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8094. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8095. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8096. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8097. department, _ := service.GetDepartMentDetail(his.Departments)
  8098. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8099. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8100. if order.ID == 0 {
  8101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8102. return
  8103. }
  8104. var struct4201A models.Struct4201A
  8105. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8106. for _, items := range order_info {
  8107. memo := make(map[string]interface{})
  8108. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8109. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8110. fsiOPFLD.MedType = "14"
  8111. fsiOPFLD.BkkpSn = items.FeedetlSn
  8112. fsiOPFLD.FixmedinsCode = miConfig.Code
  8113. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8114. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8115. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8116. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8117. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8118. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8119. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8120. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8121. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8122. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8123. fsiOPFLD.BilgDeptName = department.Name
  8124. fsiOPFLD.BilgDeptCodg = department.Number
  8125. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8126. fsiOPFLD.BilgDrName = doctor.UserName
  8127. fsiOPFLD.MedChrgitmType = "09"
  8128. memo["hosp_appr_flag"] = "1"
  8129. memo["invoice_no"] = order.MdtrtId
  8130. memo["memo"] = "自费"
  8131. bytesData, _ := json.Marshal(memo)
  8132. fsiOPFLD.Memo = string(bytesData)
  8133. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8134. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8135. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8136. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8137. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8138. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8139. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8140. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8141. fsiOPFLD.BilgDeptName = department.Name
  8142. fsiOPFLD.BilgDeptCodg = department.Number
  8143. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8144. fsiOPFLD.BilgDrName = doctor.UserName
  8145. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8146. case 0:
  8147. break
  8148. case 1:
  8149. fsiOPFLD.MedChrgitmType = "14"
  8150. break
  8151. case 2:
  8152. fsiOPFLD.MedChrgitmType = "05"
  8153. break
  8154. case 3:
  8155. fsiOPFLD.MedChrgitmType = "03"
  8156. break
  8157. case 4:
  8158. fsiOPFLD.MedChrgitmType = "03"
  8159. break
  8160. case 5:
  8161. fsiOPFLD.MedChrgitmType = "08"
  8162. break
  8163. case 6:
  8164. fsiOPFLD.MedChrgitmType = "14"
  8165. break
  8166. case 7:
  8167. fsiOPFLD.MedChrgitmType = "14"
  8168. break
  8169. case 8:
  8170. fsiOPFLD.MedChrgitmType = "03"
  8171. break
  8172. case 9:
  8173. fsiOPFLD.MedChrgitmType = "14"
  8174. break
  8175. case 10:
  8176. fsiOPFLD.MedChrgitmType = "14"
  8177. break
  8178. case 11:
  8179. fsiOPFLD.MedChrgitmType = "06"
  8180. break
  8181. case 12:
  8182. fsiOPFLD.MedChrgitmType = "12"
  8183. break
  8184. case 13:
  8185. fsiOPFLD.MedChrgitmType = "01"
  8186. break
  8187. case 14:
  8188. fsiOPFLD.MedChrgitmType = "04"
  8189. break
  8190. case 15:
  8191. fsiOPFLD.MedChrgitmType = "14"
  8192. break
  8193. }
  8194. memo["hosp_appr_flag"] = "1"
  8195. memo["invoice_no"] = order.MdtrtId
  8196. memo["memo"] = "自费"
  8197. bytesData, _ := json.Marshal(memo)
  8198. fsiOPFLD.Memo = string(bytesData)
  8199. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8200. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8201. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8202. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8203. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8204. fsiOPFLD.BilgDeptName = department.Name
  8205. fsiOPFLD.BilgDeptCodg = department.Number
  8206. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8207. fsiOPFLD.BilgDrName = doctor.UserName
  8208. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8209. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8210. fsiOPFLD.MedChrgitmType = "08"
  8211. memo["hosp_appr_flag"] = "1"
  8212. memo["invoice_no"] = order.MdtrtId
  8213. memo["memo"] = "自费"
  8214. bytesData, _ := json.Marshal(memo)
  8215. fsiOPFLD.Memo = string(bytesData)
  8216. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8217. }
  8218. }
  8219. }
  8220. for _, items := range order_info_two {
  8221. memo := make(map[string]interface{})
  8222. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8223. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8224. fsiOPFLD.MedType = "14"
  8225. fsiOPFLD.BkkpSn = items.FeedetlSn
  8226. fsiOPFLD.FixmedinsCode = miConfig.Code
  8227. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8228. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8229. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8230. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8231. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8232. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8233. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8234. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8235. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8236. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8237. fsiOPFLD.BilgDeptName = department.Name
  8238. fsiOPFLD.BilgDeptCodg = department.Number
  8239. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8240. fsiOPFLD.BilgDrName = doctor.UserName
  8241. fsiOPFLD.MedChrgitmType = "09"
  8242. memo["hosp_appr_flag"] = "1"
  8243. memo["invoice_no"] = order.MdtrtId
  8244. memo["memo"] = "自费"
  8245. bytesData, _ := json.Marshal(memo)
  8246. fsiOPFLD.Memo = string(bytesData)
  8247. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8248. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8249. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8250. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8251. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8252. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8253. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8254. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8255. fsiOPFLD.BilgDeptName = department.Name
  8256. fsiOPFLD.BilgDeptCodg = department.Number
  8257. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8258. fsiOPFLD.BilgDrName = doctor.UserName
  8259. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8260. case 0:
  8261. break
  8262. case 1:
  8263. fsiOPFLD.MedChrgitmType = "14"
  8264. break
  8265. case 2:
  8266. fsiOPFLD.MedChrgitmType = "05"
  8267. break
  8268. case 3:
  8269. fsiOPFLD.MedChrgitmType = "03"
  8270. break
  8271. case 4:
  8272. fsiOPFLD.MedChrgitmType = "03"
  8273. break
  8274. case 5:
  8275. fsiOPFLD.MedChrgitmType = "08"
  8276. break
  8277. case 6:
  8278. fsiOPFLD.MedChrgitmType = "14"
  8279. break
  8280. case 7:
  8281. fsiOPFLD.MedChrgitmType = "14"
  8282. break
  8283. case 8:
  8284. fsiOPFLD.MedChrgitmType = "03"
  8285. break
  8286. case 9:
  8287. fsiOPFLD.MedChrgitmType = "14"
  8288. break
  8289. case 10:
  8290. fsiOPFLD.MedChrgitmType = "14"
  8291. break
  8292. case 11:
  8293. fsiOPFLD.MedChrgitmType = "06"
  8294. break
  8295. case 12:
  8296. fsiOPFLD.MedChrgitmType = "12"
  8297. break
  8298. case 13:
  8299. fsiOPFLD.MedChrgitmType = "01"
  8300. break
  8301. case 14:
  8302. fsiOPFLD.MedChrgitmType = "04"
  8303. break
  8304. case 15:
  8305. fsiOPFLD.MedChrgitmType = "14"
  8306. break
  8307. }
  8308. memo["hosp_appr_flag"] = "1"
  8309. memo["invoice_no"] = order.MdtrtId
  8310. memo["memo"] = "自费"
  8311. bytesData, _ := json.Marshal(memo)
  8312. fsiOPFLD.Memo = string(bytesData)
  8313. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8314. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8315. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8316. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8317. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8318. fsiOPFLD.BilgDeptName = department.Name
  8319. fsiOPFLD.BilgDeptCodg = department.Number
  8320. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8321. fsiOPFLD.BilgDrName = doctor.UserName
  8322. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8323. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8324. fsiOPFLD.MedChrgitmType = "08"
  8325. memo["hosp_appr_flag"] = "1"
  8326. memo["invoice_no"] = order.MdtrtId
  8327. memo["memo"] = "自费"
  8328. bytesData, _ := json.Marshal(memo)
  8329. fsiOPFLD.Memo = string(bytesData)
  8330. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8331. }
  8332. }
  8333. }
  8334. fmt.Println(fsiOPFLDs)
  8335. struct4201A.Fopfd = fsiOPFLDs
  8336. fmt.Println(struct4201A.Fopfd)
  8337. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8338. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8339. var res2 ResultSix
  8340. var respJSON2 map[string]interface{}
  8341. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8344. return
  8345. }
  8346. userJSONBytes2, _ := json.Marshal(respJSON2)
  8347. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8348. utils.ErrorLog("解析失败:%v", err)
  8349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8350. return
  8351. }
  8352. if res2.Infcode != 0 {
  8353. c.ServeSuccessJSON(map[string]interface{}{
  8354. "failed_code": -10,
  8355. "msg": res2.ErrMsg,
  8356. })
  8357. return
  8358. } else {
  8359. order.IsUploadOrderInfo = 1
  8360. service.UpdateOrder(order)
  8361. c.ServeSuccessJSON(map[string]interface{}{
  8362. "msg": "上传成功",
  8363. })
  8364. }
  8365. }
  8366. func (c *HisApiController) Get2505() {
  8367. admin_user_id, _ := c.GetInt64("admin_user_id")
  8368. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8369. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8370. service.Gdyb2505("45000000000008100145868008", curRoles.UserName, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2024-01-12 09:00:00", "2026-12-31 23:00:00", admin_user_id)
  8371. }
  8372. func (c *HisApiController) Get4201A() {
  8373. order_id, _ := c.GetInt64("order_id")
  8374. admin_user_id, _ := c.GetInt64("admin_user_id")
  8375. order, _ := service.GetHisOrderByIDTwo(order_id)
  8376. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8377. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8378. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8379. //order_info = append(order_info, order_info_two...)
  8380. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8381. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8382. department, _ := service.GetDepartMentDetail(his.Departments)
  8383. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8384. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8385. if order.ID == 0 {
  8386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8387. return
  8388. }
  8389. var struct4201A models.Struct4201A
  8390. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8391. for _, items := range order_info {
  8392. memo := make(map[string]interface{})
  8393. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8394. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8395. fsiOPFLD.MedType = "14"
  8396. fsiOPFLD.BkkpSn = items.FeedetlSn
  8397. fsiOPFLD.FixmedinsCode = miConfig.Code
  8398. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8399. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8400. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8401. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8402. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8403. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8404. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8405. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8406. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8407. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8408. fsiOPFLD.BilgDeptName = department.Name
  8409. fsiOPFLD.BilgDeptCodg = department.Number
  8410. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8411. fsiOPFLD.BilgDrName = doctor.UserName
  8412. fsiOPFLD.MedChrgitmType = "09"
  8413. memo["hosp_appr_flag"] = "1"
  8414. memo["invoice_no"] = order.MdtrtId
  8415. memo["memo"] = "自费"
  8416. bytesData, _ := json.Marshal(memo)
  8417. fsiOPFLD.Memo = string(bytesData)
  8418. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8419. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8420. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8421. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8422. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8423. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8424. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8425. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8426. fsiOPFLD.BilgDeptName = department.Name
  8427. fsiOPFLD.BilgDeptCodg = department.Number
  8428. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8429. fsiOPFLD.BilgDrName = doctor.UserName
  8430. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8431. case 0:
  8432. break
  8433. case 1:
  8434. fsiOPFLD.MedChrgitmType = "14"
  8435. break
  8436. case 2:
  8437. fsiOPFLD.MedChrgitmType = "05"
  8438. break
  8439. case 3:
  8440. fsiOPFLD.MedChrgitmType = "03"
  8441. break
  8442. case 4:
  8443. fsiOPFLD.MedChrgitmType = "03"
  8444. break
  8445. case 5:
  8446. fsiOPFLD.MedChrgitmType = "08"
  8447. break
  8448. case 6:
  8449. fsiOPFLD.MedChrgitmType = "14"
  8450. break
  8451. case 7:
  8452. fsiOPFLD.MedChrgitmType = "14"
  8453. break
  8454. case 8:
  8455. fsiOPFLD.MedChrgitmType = "03"
  8456. break
  8457. case 9:
  8458. fsiOPFLD.MedChrgitmType = "14"
  8459. break
  8460. case 10:
  8461. fsiOPFLD.MedChrgitmType = "14"
  8462. break
  8463. case 11:
  8464. fsiOPFLD.MedChrgitmType = "06"
  8465. break
  8466. case 12:
  8467. fsiOPFLD.MedChrgitmType = "12"
  8468. break
  8469. case 13:
  8470. fsiOPFLD.MedChrgitmType = "01"
  8471. break
  8472. case 14:
  8473. fsiOPFLD.MedChrgitmType = "04"
  8474. break
  8475. case 15:
  8476. fsiOPFLD.MedChrgitmType = "14"
  8477. break
  8478. }
  8479. memo["hosp_appr_flag"] = "1"
  8480. memo["invoice_no"] = order.MdtrtId
  8481. memo["memo"] = "自费"
  8482. bytesData, _ := json.Marshal(memo)
  8483. fsiOPFLD.Memo = string(bytesData)
  8484. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8485. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8486. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8487. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8488. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8489. fsiOPFLD.BilgDeptName = department.Name
  8490. fsiOPFLD.BilgDeptCodg = department.Number
  8491. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8492. fsiOPFLD.BilgDrName = doctor.UserName
  8493. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8494. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8495. fsiOPFLD.MedChrgitmType = "08"
  8496. memo["hosp_appr_flag"] = "1"
  8497. memo["invoice_no"] = order.MdtrtId
  8498. memo["memo"] = "自费"
  8499. bytesData, _ := json.Marshal(memo)
  8500. fsiOPFLD.Memo = string(bytesData)
  8501. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8502. }
  8503. }
  8504. }
  8505. for _, items := range order_info_two {
  8506. memo := make(map[string]interface{})
  8507. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8508. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8509. fsiOPFLD.MedType = "14"
  8510. fsiOPFLD.BkkpSn = items.FeedetlSn
  8511. fsiOPFLD.FixmedinsCode = miConfig.Code
  8512. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8513. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8514. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8515. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8516. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8517. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8518. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8519. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8520. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8521. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8522. fsiOPFLD.BilgDeptName = department.Name
  8523. fsiOPFLD.BilgDeptCodg = department.Number
  8524. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8525. fsiOPFLD.BilgDrName = doctor.UserName
  8526. fsiOPFLD.MedChrgitmType = "09"
  8527. memo["hosp_appr_flag"] = "1"
  8528. memo["invoice_no"] = order.MdtrtId
  8529. memo["memo"] = "自费"
  8530. bytesData, _ := json.Marshal(memo)
  8531. fsiOPFLD.Memo = string(bytesData)
  8532. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8533. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8534. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8535. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8536. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8537. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8538. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8539. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8540. fsiOPFLD.BilgDeptName = department.Name
  8541. fsiOPFLD.BilgDeptCodg = department.Number
  8542. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8543. fsiOPFLD.BilgDrName = doctor.UserName
  8544. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8545. case 0:
  8546. break
  8547. case 1:
  8548. fsiOPFLD.MedChrgitmType = "14"
  8549. break
  8550. case 2:
  8551. fsiOPFLD.MedChrgitmType = "05"
  8552. break
  8553. case 3:
  8554. fsiOPFLD.MedChrgitmType = "03"
  8555. break
  8556. case 4:
  8557. fsiOPFLD.MedChrgitmType = "03"
  8558. break
  8559. case 5:
  8560. fsiOPFLD.MedChrgitmType = "08"
  8561. break
  8562. case 6:
  8563. fsiOPFLD.MedChrgitmType = "14"
  8564. break
  8565. case 7:
  8566. fsiOPFLD.MedChrgitmType = "14"
  8567. break
  8568. case 8:
  8569. fsiOPFLD.MedChrgitmType = "03"
  8570. break
  8571. case 9:
  8572. fsiOPFLD.MedChrgitmType = "14"
  8573. break
  8574. case 10:
  8575. fsiOPFLD.MedChrgitmType = "14"
  8576. break
  8577. case 11:
  8578. fsiOPFLD.MedChrgitmType = "06"
  8579. break
  8580. case 12:
  8581. fsiOPFLD.MedChrgitmType = "12"
  8582. break
  8583. case 13:
  8584. fsiOPFLD.MedChrgitmType = "01"
  8585. break
  8586. case 14:
  8587. fsiOPFLD.MedChrgitmType = "04"
  8588. break
  8589. case 15:
  8590. fsiOPFLD.MedChrgitmType = "14"
  8591. break
  8592. }
  8593. memo["hosp_appr_flag"] = "1"
  8594. memo["invoice_no"] = order.MdtrtId
  8595. memo["memo"] = "自费"
  8596. bytesData, _ := json.Marshal(memo)
  8597. fsiOPFLD.Memo = string(bytesData)
  8598. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8599. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8600. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8601. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8602. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8603. fsiOPFLD.BilgDeptName = department.Name
  8604. fsiOPFLD.BilgDeptCodg = department.Number
  8605. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8606. fsiOPFLD.BilgDrName = doctor.UserName
  8607. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8608. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8609. fsiOPFLD.MedChrgitmType = "08"
  8610. memo["hosp_appr_flag"] = "1"
  8611. memo["invoice_no"] = order.MdtrtId
  8612. memo["memo"] = "自费"
  8613. bytesData, _ := json.Marshal(memo)
  8614. fsiOPFLD.Memo = string(bytesData)
  8615. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8616. }
  8617. }
  8618. }
  8619. fmt.Println(fsiOPFLDs)
  8620. struct4201A.Fopfd = fsiOPFLDs
  8621. fmt.Println(struct4201A.Fopfd)
  8622. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8623. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8624. var res2 ResultSix
  8625. var respJSON2 map[string]interface{}
  8626. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8629. return
  8630. }
  8631. userJSONBytes2, _ := json.Marshal(respJSON2)
  8632. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8633. utils.ErrorLog("解析失败:%v", err)
  8634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8635. return
  8636. }
  8637. if res2.Infcode != 0 {
  8638. c.ServeSuccessJSON(map[string]interface{}{
  8639. "failed_code": -10,
  8640. "msg": res2.ErrMsg,
  8641. })
  8642. return
  8643. } else {
  8644. order.IsUploadOrderInfo = 1
  8645. service.UpdateOrder(order)
  8646. c.ServeSuccessJSON(map[string]interface{}{
  8647. "msg": "上传成功",
  8648. })
  8649. }
  8650. }
  8651. func (c *HisApiController) Get4202() {
  8652. order_id, _ := c.GetInt64("order_id")
  8653. admin_user_id, _ := c.GetInt64("admin_user_id")
  8654. order, _ := service.GetHisOrderByIDTwo(order_id)
  8655. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8656. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8657. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8658. if order.ID == 0 {
  8659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8660. return
  8661. }
  8662. var struct4202 models.Struct4202
  8663. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8664. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8665. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8666. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8667. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8668. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8669. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8670. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8671. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8672. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8673. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8674. var config []*models.HisXtDiagnoseConfig
  8675. for _, item := range diagnosis_ids {
  8676. id, _ := strconv.ParseInt(item, 10, 64)
  8677. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8678. config = append(config, &diagnosisConfig)
  8679. }
  8680. var tempDiaginfos []models.OwnPayPatnDiagListD
  8681. for index, item := range config {
  8682. if index == 0 {
  8683. var tempDiaginfo models.OwnPayPatnDiagListD
  8684. tempDiaginfo.InoutDiagType = "1"
  8685. tempDiaginfo.DiagCode = item.CountryCode
  8686. tempDiaginfo.DiagName = item.CountryContentName
  8687. tempDiaginfo.DiagType = "1"
  8688. tempDiaginfo.DiagSrtNo = "1"
  8689. tempDiaginfo.MaindiagFlag = "1"
  8690. tempDiaginfo.ValiFlag = "1"
  8691. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8692. } else {
  8693. var tempDiaginfo models.OwnPayPatnDiagListD
  8694. tempDiaginfo.DiagCode = item.CountryCode
  8695. tempDiaginfo.DiagName = item.CountryContentName
  8696. tempDiaginfo.DiagType = "2"
  8697. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8698. tempDiaginfo.MaindiagFlag = "0"
  8699. tempDiaginfo.ValiFlag = "1"
  8700. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8701. }
  8702. }
  8703. struct4202.ODiagListD = tempDiaginfos
  8704. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8705. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8706. var res2 ResultSix
  8707. var respJSON2 map[string]interface{}
  8708. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8711. return
  8712. }
  8713. userJSONBytes2, _ := json.Marshal(respJSON2)
  8714. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8715. utils.ErrorLog("解析失败:%v", err)
  8716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8717. return
  8718. }
  8719. if res2.Infcode != 0 {
  8720. c.ServeSuccessJSON(map[string]interface{}{
  8721. "failed_code": -10,
  8722. "msg": res2.ErrMsg,
  8723. })
  8724. return
  8725. } else {
  8726. order.IsUploadDiagnose = 1
  8727. service.UpdateOrder(order)
  8728. c.ServeSuccessJSON(map[string]interface{}{
  8729. "msg": "上传成功",
  8730. })
  8731. }
  8732. }
  8733. func (c *HisApiController) Get4203() {
  8734. admin_user_id, _ := c.GetInt64("admin_user_id")
  8735. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8736. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8737. order_id, _ := c.GetInt64("order_id")
  8738. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8739. number := ""
  8740. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8741. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8742. if his.ID == 0 {
  8743. number = hospital.Number
  8744. } else {
  8745. number = his.Number
  8746. }
  8747. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8748. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8749. var res2 ResultSix
  8750. var respJSON2 map[string]interface{}
  8751. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8754. return
  8755. }
  8756. userJSONBytes2, _ := json.Marshal(respJSON2)
  8757. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8758. utils.ErrorLog("解析失败:%v", err)
  8759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8760. return
  8761. }
  8762. if res2.Infcode != 0 {
  8763. c.ServeSuccessJSON(map[string]interface{}{
  8764. "failed_code": -10,
  8765. "msg": res2.ErrMsg,
  8766. })
  8767. return
  8768. } else {
  8769. order.IsUploadSuccess = 1
  8770. service.UpdateOrderTwo(order)
  8771. c.ServeSuccessJSON(map[string]interface{}{
  8772. "msg": "上传成功",
  8773. })
  8774. }
  8775. }
  8776. func (c *HisApiController) Get4205() {
  8777. order_id, _ := c.GetInt64("order_id")
  8778. admin_user_id, _ := c.GetInt64("admin_user_id")
  8779. fapiao_code := c.GetString("fapiao_code")
  8780. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8781. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8782. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8783. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8784. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8785. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8786. //order_info = append(order_info, order_info_two...)
  8787. department, _ := service.GetDepartMentDetail(his.Departments)
  8788. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8789. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8790. if order.ID == 0 {
  8791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8792. return
  8793. }
  8794. var struct4201A models.Struct4201A
  8795. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8796. for _, items := range order_info {
  8797. memo := make(map[string]interface{})
  8798. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8799. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8800. fsiOPFLD.MedType = pre.MedType
  8801. fsiOPFLD.FixmedinsCode = miConfig.Code
  8802. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8803. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8804. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8805. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8806. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8807. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8808. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8809. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8810. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8811. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8812. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8813. fsiOPFLD.BilgDeptName = department.Name
  8814. fsiOPFLD.BilgDeptCodg = department.Number
  8815. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8816. fsiOPFLD.BilgDrName = doctor.UserName
  8817. fsiOPFLD.MedChrgitmType = "09"
  8818. memo["hosp_appr_flag"] = "1"
  8819. memo["invoice_no"] = fapiao_code
  8820. memo["memo"] = "自费"
  8821. bytesData, _ := json.Marshal(memo)
  8822. fsiOPFLD.Memo = string(bytesData)
  8823. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8824. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8825. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8826. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8827. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8828. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8829. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8830. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8831. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8832. fsiOPFLD.BilgDeptName = department.Name
  8833. fsiOPFLD.BilgDeptCodg = department.Number
  8834. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8835. fsiOPFLD.BilgDrName = doctor.UserName
  8836. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8837. case 0:
  8838. break
  8839. case 1:
  8840. fsiOPFLD.MedChrgitmType = "14"
  8841. break
  8842. case 2:
  8843. fsiOPFLD.MedChrgitmType = "05"
  8844. break
  8845. case 3:
  8846. fsiOPFLD.MedChrgitmType = "03"
  8847. break
  8848. case 4:
  8849. fsiOPFLD.MedChrgitmType = "03"
  8850. break
  8851. case 5:
  8852. fsiOPFLD.MedChrgitmType = "08"
  8853. break
  8854. case 6:
  8855. fsiOPFLD.MedChrgitmType = "14"
  8856. break
  8857. case 7:
  8858. fsiOPFLD.MedChrgitmType = "14"
  8859. break
  8860. case 8:
  8861. fsiOPFLD.MedChrgitmType = "03"
  8862. break
  8863. case 9:
  8864. fsiOPFLD.MedChrgitmType = "14"
  8865. break
  8866. case 10:
  8867. fsiOPFLD.MedChrgitmType = "14"
  8868. break
  8869. case 11:
  8870. fsiOPFLD.MedChrgitmType = "06"
  8871. break
  8872. case 12:
  8873. fsiOPFLD.MedChrgitmType = "12"
  8874. break
  8875. case 13:
  8876. fsiOPFLD.MedChrgitmType = "01"
  8877. break
  8878. case 14:
  8879. fsiOPFLD.MedChrgitmType = "04"
  8880. break
  8881. case 15:
  8882. fsiOPFLD.MedChrgitmType = "14"
  8883. break
  8884. }
  8885. memo["hosp_appr_flag"] = "1"
  8886. memo["invoice_no"] = fapiao_code
  8887. memo["memo"] = "自费"
  8888. bytesData, _ := json.Marshal(memo)
  8889. fsiOPFLD.Memo = string(bytesData)
  8890. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8891. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8892. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8893. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8894. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8895. fsiOPFLD.BilgDeptName = department.Name
  8896. fsiOPFLD.BilgDeptCodg = department.Number
  8897. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8898. fsiOPFLD.BilgDrName = doctor.UserName
  8899. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8900. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8901. fsiOPFLD.MedChrgitmType = "08"
  8902. memo["hosp_appr_flag"] = "1"
  8903. memo["invoice_no"] = fapiao_code
  8904. memo["memo"] = "自费"
  8905. bytesData, _ := json.Marshal(memo)
  8906. fsiOPFLD.Memo = string(bytesData)
  8907. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8908. }
  8909. }
  8910. }
  8911. for _, items := range order_info_two {
  8912. memo := make(map[string]interface{})
  8913. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8914. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8915. fsiOPFLD.MedType = pre.MedType
  8916. fsiOPFLD.BkkpSn = items.FeedetlSn
  8917. fsiOPFLD.FixmedinsCode = miConfig.Code
  8918. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8919. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8920. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8921. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8922. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8923. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8924. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8925. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8926. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8927. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8928. fsiOPFLD.BilgDeptName = department.Name
  8929. fsiOPFLD.BilgDeptCodg = department.Number
  8930. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8931. fsiOPFLD.BilgDrName = doctor.UserName
  8932. fsiOPFLD.MedChrgitmType = "09"
  8933. memo["hosp_appr_flag"] = "1"
  8934. memo["invoice_no"] = fapiao_code
  8935. memo["memo"] = "自费"
  8936. bytesData, _ := json.Marshal(memo)
  8937. fsiOPFLD.Memo = string(bytesData)
  8938. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8939. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8940. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8941. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8942. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8943. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8944. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8945. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8946. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8947. fsiOPFLD.BilgDeptName = department.Name
  8948. fsiOPFLD.BilgDeptCodg = department.Number
  8949. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8950. fsiOPFLD.BilgDrName = doctor.UserName
  8951. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8952. case 0:
  8953. break
  8954. case 1:
  8955. fsiOPFLD.MedChrgitmType = "14"
  8956. break
  8957. case 2:
  8958. fsiOPFLD.MedChrgitmType = "05"
  8959. break
  8960. case 3:
  8961. fsiOPFLD.MedChrgitmType = "03"
  8962. break
  8963. case 4:
  8964. fsiOPFLD.MedChrgitmType = "03"
  8965. break
  8966. case 5:
  8967. fsiOPFLD.MedChrgitmType = "08"
  8968. break
  8969. case 6:
  8970. fsiOPFLD.MedChrgitmType = "14"
  8971. break
  8972. case 7:
  8973. fsiOPFLD.MedChrgitmType = "14"
  8974. break
  8975. case 8:
  8976. fsiOPFLD.MedChrgitmType = "03"
  8977. break
  8978. case 9:
  8979. fsiOPFLD.MedChrgitmType = "14"
  8980. break
  8981. case 10:
  8982. fsiOPFLD.MedChrgitmType = "14"
  8983. break
  8984. case 11:
  8985. fsiOPFLD.MedChrgitmType = "06"
  8986. break
  8987. case 12:
  8988. fsiOPFLD.MedChrgitmType = "12"
  8989. break
  8990. case 13:
  8991. fsiOPFLD.MedChrgitmType = "01"
  8992. break
  8993. case 14:
  8994. fsiOPFLD.MedChrgitmType = "04"
  8995. break
  8996. case 15:
  8997. fsiOPFLD.MedChrgitmType = "14"
  8998. break
  8999. }
  9000. memo["hosp_appr_flag"] = "1"
  9001. memo["invoice_no"] = fapiao_code
  9002. memo["memo"] = "自费"
  9003. bytesData, _ := json.Marshal(memo)
  9004. fsiOPFLD.Memo = string(bytesData)
  9005. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9006. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9007. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9008. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9009. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9010. fsiOPFLD.BilgDeptName = department.Name
  9011. fsiOPFLD.BilgDeptCodg = department.Number
  9012. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9013. fsiOPFLD.BilgDrName = doctor.UserName
  9014. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9015. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9016. fsiOPFLD.MedChrgitmType = "08"
  9017. memo["hosp_appr_flag"] = "1"
  9018. memo["invoice_no"] = fapiao_code
  9019. memo["memo"] = "自费"
  9020. bytesData, _ := json.Marshal(memo)
  9021. fsiOPFLD.Memo = string(bytesData)
  9022. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9023. }
  9024. }
  9025. }
  9026. fmt.Println(fsiOPFLDs)
  9027. struct4201A.Fopfd = fsiOPFLDs
  9028. fmt.Println(struct4201A.Fopfd)
  9029. var struct4202 models.Struct4202
  9030. timeLayout := "2006-01-02 15:04:05"
  9031. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9032. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9033. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9034. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9035. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9036. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9037. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9038. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9039. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9040. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9041. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9042. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9043. var config []*models.HisXtDiagnoseConfig
  9044. for _, item := range diagnosis_ids {
  9045. id, _ := strconv.ParseInt(item, 10, 64)
  9046. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9047. config = append(config, &diagnosisConfig)
  9048. }
  9049. var tempDiaginfos []models.OwnPayPatnDiagListD
  9050. for index, item := range config {
  9051. if index == 0 {
  9052. var tempDiaginfo models.OwnPayPatnDiagListD
  9053. tempDiaginfo.InoutDiagType = "1"
  9054. tempDiaginfo.DiagCode = item.CountryCode
  9055. tempDiaginfo.DiagName = item.CountryContentName
  9056. tempDiaginfo.DiagType = "1"
  9057. tempDiaginfo.DiagSrtNo = "1"
  9058. tempDiaginfo.MaindiagFlag = "1"
  9059. tempDiaginfo.ValiFlag = "1"
  9060. tempDiaginfo.DiagDrName = doctor.UserName
  9061. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9062. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9063. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9064. } else {
  9065. var tempDiaginfo models.OwnPayPatnDiagListD
  9066. tempDiaginfo.DiagCode = item.CountryCode
  9067. tempDiaginfo.DiagName = item.CountryContentName
  9068. tempDiaginfo.DiagType = "2"
  9069. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9070. tempDiaginfo.MaindiagFlag = "0"
  9071. tempDiaginfo.ValiFlag = "1"
  9072. tempDiaginfo.DiagDrName = doctor.UserName
  9073. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9074. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9075. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9076. }
  9077. }
  9078. struct4202.ODiagListD = tempDiaginfos
  9079. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9080. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9081. var res2 ResultSix
  9082. var respJSON2 map[string]interface{}
  9083. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9086. return
  9087. }
  9088. userJSONBytes2, _ := json.Marshal(respJSON2)
  9089. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9090. utils.ErrorLog("解析失败:%v", err)
  9091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9092. return
  9093. }
  9094. if res2.Infcode != 0 {
  9095. c.ServeSuccessJSON(map[string]interface{}{
  9096. "failed_code": -10,
  9097. "msg": res2.ErrMsg,
  9098. })
  9099. return
  9100. } else {
  9101. order.IsUploadDiagnose = 1
  9102. order.IsUploadOrderInfo = 1
  9103. service.UpdateOrderTwo(order)
  9104. c.ServeSuccessJSON(map[string]interface{}{
  9105. "msg": "上传成功",
  9106. })
  9107. }
  9108. }
  9109. func (c *HisApiController) Get4207() {
  9110. admin_user_id, _ := c.GetInt64("admin_user_id")
  9111. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9112. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9113. order_id, _ := c.GetInt64("order_id")
  9114. order, _ := service.GetHisOrderByIDTwo(order_id)
  9115. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9116. var struct4207 models.Struct4207
  9117. struct4207.PageNum = "1"
  9118. struct4207.PageSize = "1000"
  9119. struct4207.FixmedinsCode = miConfig.Code
  9120. struct4207.FixmedinsMdtrtID = order.Number
  9121. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9122. saveLog(result, requestLog, "4207", "查询")
  9123. var res2 ResultSix
  9124. var respJSON2 map[string]interface{}
  9125. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9128. return
  9129. }
  9130. userJSONBytes2, _ := json.Marshal(respJSON2)
  9131. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9132. utils.ErrorLog("解析失败:%v", err)
  9133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9134. return
  9135. }
  9136. if res2.Infcode != 0 {
  9137. c.ServeSuccessJSON(map[string]interface{}{
  9138. "failed_code": -10,
  9139. "msg": res2.ErrMsg,
  9140. })
  9141. return
  9142. } else {
  9143. c.ServeSuccessJSON(map[string]interface{}{
  9144. "msg": "查询成功",
  9145. })
  9146. }
  9147. }
  9148. func (c *HisApiController) Get4208() {
  9149. admin_user_id, _ := c.GetInt64("admin_user_id")
  9150. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9151. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9152. order_id, _ := c.GetInt64("order_id")
  9153. order, _ := service.GetHisOrderByIDTwo(order_id)
  9154. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9155. var struct4208 models.Struct4208
  9156. struct4208.PageNum = "1"
  9157. struct4208.PageSize = "1000"
  9158. struct4208.PsnCertType = "01"
  9159. struct4208.Certno = his.Certno
  9160. struct4208.MedType = order.MedType
  9161. struct4208.PsnName = his.Name
  9162. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9163. saveLog(result, requestLog, "4208", "查询")
  9164. var res2 ResultSix
  9165. var respJSON2 map[string]interface{}
  9166. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9169. return
  9170. }
  9171. userJSONBytes2, _ := json.Marshal(respJSON2)
  9172. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9173. utils.ErrorLog("解析失败:%v", err)
  9174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9175. return
  9176. }
  9177. if res2.Infcode != 0 {
  9178. c.ServeSuccessJSON(map[string]interface{}{
  9179. "failed_code": -10,
  9180. "msg": res2.ErrMsg,
  9181. })
  9182. return
  9183. } else {
  9184. c.ServeSuccessJSON(map[string]interface{}{
  9185. "msg": "查询成功",
  9186. })
  9187. }
  9188. }
  9189. func (c *HisApiController) Get4209() {
  9190. admin_user_id, _ := c.GetInt64("admin_user_id")
  9191. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9192. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9193. order_id, _ := c.GetInt64("order_id")
  9194. order, _ := service.GetHisOrderByIDTwo(order_id)
  9195. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9196. var struct4209 models.Struct4209
  9197. struct4209.FixmedinsMdtrtID = order.Number
  9198. struct4209.FixmedinsCode = miConfig.Code
  9199. struct4209.PageSize = "1000"
  9200. struct4209.PageNum = "1"
  9201. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9202. saveLog(result, requestLog, "4209", "查询")
  9203. var res2 ResultSix
  9204. var respJSON2 map[string]interface{}
  9205. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9208. return
  9209. }
  9210. userJSONBytes2, _ := json.Marshal(respJSON2)
  9211. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9212. utils.ErrorLog("解析失败:%v", err)
  9213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9214. return
  9215. }
  9216. if res2.Infcode != 0 {
  9217. c.ServeSuccessJSON(map[string]interface{}{
  9218. "failed_code": -10,
  9219. "msg": res2.ErrMsg,
  9220. })
  9221. return
  9222. } else {
  9223. c.ServeSuccessJSON(map[string]interface{}{
  9224. "msg": "查询成功",
  9225. })
  9226. }
  9227. }
  9228. type Result3101 struct {
  9229. Infcode string `json:"infcode"`
  9230. InfRefmsgid string `json:"inf_refmsgid"`
  9231. RefmsgTime string `json:"refmsg_time"`
  9232. RespondTime string `json:"respond_time"`
  9233. Enctype string `json:"enctype"`
  9234. Signtype string `json:"signtype"`
  9235. ErrMsg string `json:"err_msg"`
  9236. Output struct {
  9237. Result []struct {
  9238. JudgeResultDetailDtos []struct {
  9239. VolaItemType string `json:"vola_item_type"`
  9240. MdtrtID string `json:"mdtrt_id"`
  9241. JrdID string `json:"jrd_id"`
  9242. PatnID string `json:"patn_id"`
  9243. RxID string `json:"rx_id"`
  9244. VolaAmt interface{} `json:"vola_amt"`
  9245. } `json:"judge_result_detail_dtos"`
  9246. RuleID string `json:"rule_id"`
  9247. VolaEvid string `json:"vola_evid"`
  9248. MdtrtID string `json:"mdtrt_id"`
  9249. RuleName string `json:"rule_name"`
  9250. VolaAmtStas string `json:"vola_amt_stas"`
  9251. JrID string `json:"jr_id"`
  9252. PatnID string `json:"patn_id"`
  9253. SevDeg string `json:"sev_deg"`
  9254. VolaAmt float64 `json:"vola_amt"`
  9255. VolaBhvrType string `json:"vola_bhvr_type"`
  9256. VolaCont string `json:"vola_cont"`
  9257. } `json:"result"`
  9258. } `json:"output"`
  9259. }
  9260. type Resultgd3101 struct {
  9261. Infcode int64 `json:"infcode"`
  9262. InfRefmsgid string `json:"inf_refmsgid"`
  9263. RefmsgTime string `json:"refmsg_time"`
  9264. RespondTime string `json:"respond_time"`
  9265. Enctype string `json:"enctype"`
  9266. Signtype string `json:"signtype"`
  9267. ErrMsg string `json:"err_msg"`
  9268. Output struct {
  9269. Result []struct {
  9270. JudgeResultDetailDtos []struct {
  9271. VolaItemType string `json:"vola_item_type"`
  9272. MdtrtID string `json:"mdtrt_id"`
  9273. JrdID string `json:"jrd_id"`
  9274. PatnID string `json:"patn_id"`
  9275. RxID string `json:"rx_id"`
  9276. VolaAmt interface{} `json:"vola_amt"`
  9277. } `json:"judge_result_detail_dtos"`
  9278. RuleID string `json:"rule_id"`
  9279. VolaEvid string `json:"vola_evid"`
  9280. MdtrtID string `json:"mdtrt_id"`
  9281. RuleName string `json:"rule_name"`
  9282. VolaAmtStas string `json:"vola_amt_stas"`
  9283. JrID string `json:"jr_id"`
  9284. PatnID string `json:"patn_id"`
  9285. SevDeg string `json:"sev_deg"`
  9286. VolaAmt float64 `json:"vola_amt"`
  9287. VolaBhvrType string `json:"vola_bhvr_type"`
  9288. VolaCont string `json:"vola_cont"`
  9289. } `json:"result"`
  9290. } `json:"output"`
  9291. }
  9292. func (c *HisApiController) ReadEleToken() {
  9293. admin_user_id, _ := c.GetInt64("admin_user_id")
  9294. his_patient_id, _ := c.GetInt64("his_patient_id")
  9295. adminUser := c.GetAdminUserInfo()
  9296. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9297. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9298. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9299. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9300. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9301. if len(tokens) > 0 {
  9302. c.ServeSuccessJSON(map[string]interface{}{
  9303. "msg": "读取成功",
  9304. })
  9305. } else {
  9306. c.ServeSuccessJSON(map[string]interface{}{
  9307. "failed_code": -10,
  9308. "msg": "读取失败",
  9309. })
  9310. }
  9311. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9312. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9313. if len(tokens) > 0 {
  9314. c.ServeSuccessJSON(map[string]interface{}{
  9315. "msg": "读取成功",
  9316. })
  9317. } else {
  9318. c.ServeSuccessJSON(map[string]interface{}{
  9319. "failed_code": -10,
  9320. "msg": "读取失败",
  9321. })
  9322. }
  9323. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9324. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9325. if len(tokens) > 0 {
  9326. c.ServeSuccessJSON(map[string]interface{}{
  9327. "msg": "读取成功",
  9328. })
  9329. } else {
  9330. c.ServeSuccessJSON(map[string]interface{}{
  9331. "failed_code": -10,
  9332. "msg": "读取失败",
  9333. })
  9334. }
  9335. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9336. var api string
  9337. 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 +
  9338. "&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"
  9339. resp, requestErr := http.Get(api)
  9340. if requestErr != nil {
  9341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9342. }
  9343. body, ioErr := ioutil.ReadAll(resp.Body)
  9344. if ioErr != nil {
  9345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9347. }
  9348. var respJSON map[string]interface{}
  9349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9352. return
  9353. }
  9354. var status string
  9355. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9356. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9357. var token string
  9358. var res ResultTwo //1101结果
  9359. var res10265 ResultTwo10265 //1101结果
  9360. if status == "0" { //读卡成功
  9361. var card_info string //卡信息
  9362. var busi_card_info string
  9363. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9364. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9365. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9366. fmt.Println(card_info)
  9367. fmt.Println(busi_card_info)
  9368. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9369. result, _ := json.Marshal(respJSON)
  9370. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9371. utils.ErrorLog("解析失败:%v", err)
  9372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9373. return
  9374. }
  9375. res.ErrMsg = res10265.ErrMsg
  9376. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9377. res.Infcode = infocode
  9378. res.Output = res10265.Output
  9379. res.InfRefmsgid = res10265.InfRefmsgid
  9380. if res.Infcode == 0 {
  9381. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9382. if err == gorm.ErrRecordNotFound {
  9383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9384. return
  9385. } else if err != nil {
  9386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9387. return
  9388. } else {
  9389. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9390. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9391. infoStr := string(Iinfos)
  9392. idetinfoStr := string(Idetinfos)
  9393. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9394. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9395. psn := &models.HisPsn{
  9396. PsnNo: res.Output.Baseinfo.PsnNo,
  9397. PatientId: patient.ID,
  9398. Certno: res.Output.Baseinfo.Certno,
  9399. Gend: res.Output.Baseinfo.Gend,
  9400. Naty: res.Output.Baseinfo.Naty,
  9401. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9402. PsnName: res.Output.Baseinfo.PsnName,
  9403. Age: float64(age),
  9404. Brdy: b,
  9405. Idetinfo: idetinfoStr,
  9406. Insuinfo: infoStr,
  9407. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9408. CardInfo: card_info,
  9409. VerifyNumber: token,
  9410. IdCardType: 4,
  9411. }
  9412. var rf []*ResultFive
  9413. json.Unmarshal([]byte(infoStr), &rf)
  9414. var insutypes []*ResultFive
  9415. var insutype string
  9416. var is390 int = 0
  9417. var is310 int = 0
  9418. for _, item := range rf {
  9419. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9420. insutypes = append(insutypes, item)
  9421. }
  9422. }
  9423. if len(insutypes) == 1 {
  9424. insutype = insutypes[0].Insutype
  9425. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9426. } else {
  9427. for _, i := range insutypes {
  9428. if i.Insutype == "390" {
  9429. is390 = 1
  9430. }
  9431. if i.Insutype == "310" {
  9432. is310 = 1
  9433. }
  9434. }
  9435. }
  9436. if is390 == 1 {
  9437. insutype = "390"
  9438. }
  9439. if is310 == 1 {
  9440. insutype = "310"
  9441. }
  9442. if len(insutypes) == 0 {
  9443. insutype = "310"
  9444. }
  9445. service.CreateHisPsn(psn)
  9446. c.ServeSuccessJSON(map[string]interface{}{
  9447. "patient": patient,
  9448. "number": token,
  9449. "insutype": insutype,
  9450. })
  9451. }
  9452. } else {
  9453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9454. return
  9455. }
  9456. } else { //读卡失败
  9457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9458. return
  9459. }
  9460. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9461. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9462. if len(errMsg) == 0 {
  9463. type ELeData struct {
  9464. Data struct {
  9465. IdNo string `json:"idNo"`
  9466. IdType string `json:"idType"`
  9467. UserName string `json:"userName"`
  9468. EcToken string `json:"ecToken"`
  9469. InsuOrg string `json:"insuOrg"`
  9470. Gender string `json:"gender"`
  9471. Birthday string `json:"birthday"`
  9472. Nationality string `json:"nationality"`
  9473. Email string `json:"email"`
  9474. Extra string `json:"extra"`
  9475. } `json:"data"`
  9476. Code int `json:"code"`
  9477. Message string `json:"message"`
  9478. }
  9479. var ele ELeData
  9480. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9481. if err != nil {
  9482. utils.ErrorLog("解析失败:%v", err)
  9483. }
  9484. token := ele.Data.EcToken
  9485. if len(token) > 0 {
  9486. psn := &models.HisPsn{
  9487. PsnNo: his.PsnNo,
  9488. Age: 0,
  9489. PatientId: his.PatientId,
  9490. Certno: his.Certno,
  9491. Brdy: his.Brdy,
  9492. Gend: his.Gend,
  9493. Naty: his.Naty,
  9494. PsnCertType: his.PsnCertType,
  9495. PsnName: his.PsnName,
  9496. Idetinfo: his.Idetinfo,
  9497. Insuinfo: his.Iinfo,
  9498. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9499. CardInfo: outPutInfo,
  9500. VerifyNumber: token,
  9501. }
  9502. service.CreateHisPsn(psn)
  9503. }
  9504. if len(token) > 0 {
  9505. c.ServeSuccessJSON(map[string]interface{}{
  9506. "msg": "读取成功",
  9507. })
  9508. } else {
  9509. c.ServeSuccessJSON(map[string]interface{}{
  9510. "failed_code": -10,
  9511. "msg": "读取失败",
  9512. })
  9513. }
  9514. }
  9515. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9516. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9517. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9518. type ELeData struct {
  9519. Data struct {
  9520. IdNo string `json:"idNo"`
  9521. IdType string `json:"idType"`
  9522. UserName string `json:"userName"`
  9523. EcToken string `json:"ecToken"`
  9524. InsuOrg string `json:"insuOrg"`
  9525. Gender string `json:"gender"`
  9526. Birthday string `json:"birthday"`
  9527. Nationality string `json:"nationality"`
  9528. Email string `json:"email"`
  9529. Extra string `json:"extra"`
  9530. } `json:"data"`
  9531. Code int `json:"code"`
  9532. Message string `json:"message"`
  9533. }
  9534. var ele ELeData
  9535. err := json.Unmarshal([]byte(result), &ele)
  9536. if err != nil {
  9537. utils.ErrorLog("解析失败:%v", err)
  9538. }
  9539. token := ele.Data.EcToken
  9540. token = Remove0000(token)
  9541. fmt.Println(ele.Data.UserName)
  9542. 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)
  9543. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9544. var res ResultTwo
  9545. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9546. utils.ErrorLog("解析失败:%v", err)
  9547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9548. return
  9549. }
  9550. if res.Infcode == 0 {
  9551. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9552. if err == gorm.ErrRecordNotFound {
  9553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9554. return
  9555. } else if err != nil {
  9556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9557. return
  9558. } else {
  9559. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9560. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9561. infoStr := string(Iinfos)
  9562. idetinfoStr := string(Idetinfos)
  9563. psn := &models.HisPsn{
  9564. PsnNo: res.Output.Baseinfo.PsnNo,
  9565. PatientId: patient.ID,
  9566. Certno: res.Output.Baseinfo.Certno,
  9567. Gend: res.Output.Baseinfo.Gend,
  9568. Naty: res.Output.Baseinfo.Naty,
  9569. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9570. PsnName: res.Output.Baseinfo.PsnName,
  9571. Idetinfo: idetinfoStr,
  9572. Insuinfo: infoStr,
  9573. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9574. CardInfo: "",
  9575. VerifyNumber: token,
  9576. }
  9577. service.CreateHisPsn(psn)
  9578. c.ServeSuccessJSON(map[string]interface{}{
  9579. "patient": patient,
  9580. "number": token,
  9581. })
  9582. }
  9583. } else {
  9584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9585. return
  9586. }
  9587. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9588. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9589. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9590. type ELeData struct {
  9591. Data struct {
  9592. IdNo string `json:"idNo"`
  9593. IdType string `json:"idType"`
  9594. UserName string `json:"userName"`
  9595. EcToken string `json:"ecToken"`
  9596. InsuOrg string `json:"insuOrg"`
  9597. Gender string `json:"gender"`
  9598. Birthday string `json:"birthday"`
  9599. Nationality string `json:"nationality"`
  9600. Email string `json:"email"`
  9601. Extra string `json:"extra"`
  9602. } `json:"data"`
  9603. Code int `json:"code"`
  9604. Message string `json:"message"`
  9605. }
  9606. var ele ELeData
  9607. err := json.Unmarshal([]byte(result), &ele)
  9608. if err != nil {
  9609. utils.ErrorLog("解析失败:%v", err)
  9610. }
  9611. token := ele.Data.EcToken
  9612. token = Remove0000(token)
  9613. fmt.Println(ele.Data.UserName)
  9614. 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)
  9615. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9616. var res ResultTwo
  9617. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9618. utils.ErrorLog("解析失败:%v", err)
  9619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9620. return
  9621. }
  9622. if res.Infcode == 0 {
  9623. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9624. if err == gorm.ErrRecordNotFound {
  9625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9626. return
  9627. } else if err != nil {
  9628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9629. return
  9630. } else {
  9631. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9632. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9633. infoStr := string(Iinfos)
  9634. idetinfoStr := string(Idetinfos)
  9635. psn := &models.HisPsn{
  9636. PsnNo: res.Output.Baseinfo.PsnNo,
  9637. PatientId: patient.ID,
  9638. Certno: res.Output.Baseinfo.Certno,
  9639. Gend: res.Output.Baseinfo.Gend,
  9640. Naty: res.Output.Baseinfo.Naty,
  9641. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9642. PsnName: res.Output.Baseinfo.PsnName,
  9643. Idetinfo: idetinfoStr,
  9644. Insuinfo: infoStr,
  9645. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9646. CardInfo: "",
  9647. VerifyNumber: token,
  9648. }
  9649. service.CreateHisPsn(psn)
  9650. c.ServeSuccessJSON(map[string]interface{}{
  9651. "patient": patient,
  9652. "number": token,
  9653. })
  9654. }
  9655. } else {
  9656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9657. return
  9658. }
  9659. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9660. //if initFlag == 0 {
  9661. //c.TestGetJiangXiBasBaseInit()
  9662. //}
  9663. //if initEleFlag == 0 {
  9664. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9665. //}
  9666. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9667. utils.ErrorLog("解析失败:%v", json_result)
  9668. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9669. type ELeData struct {
  9670. Data struct {
  9671. IdNo string `json:"idNo"`
  9672. IdType string `json:"idType"`
  9673. UserName string `json:"userName"`
  9674. EcToken string `json:"ecToken"`
  9675. InsuOrg string `json:"insuOrg"`
  9676. Gender string `json:"gender"`
  9677. Birthday string `json:"birthday"`
  9678. Nationality string `json:"nationality"`
  9679. Email string `json:"email"`
  9680. Extra string `json:"extra"`
  9681. } `json:"data"`
  9682. Code int `json:"code"`
  9683. Message string `json:"message"`
  9684. }
  9685. var ele ELeData
  9686. err := json.Unmarshal([]byte(json_result), &ele)
  9687. if err != nil {
  9688. utils.ErrorLog("解析失败:%v", err)
  9689. }
  9690. token := ele.Data.EcToken
  9691. token = Remove0000(token)
  9692. //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)
  9693. 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)
  9694. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9695. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9696. var res ResultTwo
  9697. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9698. utils.ErrorLog("解析失败:%v", err)
  9699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9700. return
  9701. }
  9702. if res.Infcode == 0 {
  9703. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9704. if err == gorm.ErrRecordNotFound {
  9705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9706. return
  9707. } else if err != nil {
  9708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9709. return
  9710. } else {
  9711. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9712. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9713. infoStr := string(Iinfos)
  9714. idetinfoStr := string(Idetinfos)
  9715. psn := &models.HisPsn{
  9716. PsnNo: res.Output.Baseinfo.PsnNo,
  9717. PatientId: patient.ID,
  9718. Certno: res.Output.Baseinfo.Certno,
  9719. Gend: res.Output.Baseinfo.Gend,
  9720. Naty: res.Output.Baseinfo.Naty,
  9721. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9722. PsnName: res.Output.Baseinfo.PsnName,
  9723. Idetinfo: idetinfoStr,
  9724. Insuinfo: infoStr,
  9725. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9726. CardInfo: "",
  9727. VerifyNumber: token,
  9728. InsuplcAdmdvs: ele.Data.InsuOrg,
  9729. }
  9730. service.CreateHisPsn(psn)
  9731. c.ServeSuccessJSON(map[string]interface{}{
  9732. "patient": patient,
  9733. "number": token,
  9734. })
  9735. }
  9736. } else {
  9737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9738. return
  9739. }
  9740. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9741. res := c.GetoleInfo()
  9742. if res.Infcode == 0 {
  9743. var result string
  9744. if res.Output.MdtrtCertType == "01" {
  9745. 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)
  9746. } else if res.Output.MdtrtCertType == "02" {
  9747. 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)
  9748. } else if res.Output.MdtrtCertType == "03" {
  9749. 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)
  9750. }
  9751. var dat map[string]interface{}
  9752. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9753. fmt.Println(dat)
  9754. } else {
  9755. fmt.Println(err)
  9756. }
  9757. userJSONBytes, _ := json.Marshal(dat)
  9758. var res2 ResultTwo
  9759. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9760. utils.ErrorLog("解析失败:%v", err)
  9761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9762. return
  9763. }
  9764. if res2.Infcode == 0 {
  9765. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9766. if err == gorm.ErrRecordNotFound {
  9767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9768. return
  9769. } else if err != nil {
  9770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9771. return
  9772. } else {
  9773. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9774. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9775. infoStr := string(Iinfos)
  9776. idetinfoStr := string(Idetinfos)
  9777. var rf []*ResultFive
  9778. json.Unmarshal([]byte(infoStr), &rf)
  9779. var insutypes []*ResultFive
  9780. var insutype string
  9781. var is390 int = 0
  9782. var is310 int = 0
  9783. //var insuplc_admdvs string
  9784. for _, item := range rf {
  9785. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9786. insutypes = append(insutypes, item)
  9787. }
  9788. }
  9789. if len(insutypes) == 1 {
  9790. insutype = insutypes[0].Insutype
  9791. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9792. } else {
  9793. for _, i := range insutypes {
  9794. if i.Insutype == "390" {
  9795. is390 = 1
  9796. }
  9797. if i.Insutype == "310" {
  9798. is310 = 1
  9799. }
  9800. }
  9801. }
  9802. if is390 == 1 {
  9803. insutype = "390"
  9804. }
  9805. if is310 == 1 {
  9806. insutype = "310"
  9807. }
  9808. if len(insutypes) == 0 {
  9809. insutype = "310"
  9810. }
  9811. psn := &models.HisPsn{
  9812. PsnNo: res2.Output.Baseinfo.PsnNo,
  9813. PatientId: patient.ID,
  9814. Certno: res2.Output.Baseinfo.Certno,
  9815. Gend: res2.Output.Baseinfo.Gend,
  9816. Naty: res2.Output.Baseinfo.Naty,
  9817. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9818. PsnName: res2.Output.Baseinfo.PsnName,
  9819. Idetinfo: idetinfoStr,
  9820. Insuinfo: infoStr,
  9821. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9822. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9823. VerifyNumber: res.Output.EcToken,
  9824. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9825. }
  9826. service.CreateHisPsn(psn)
  9827. c.ServeSuccessJSON(map[string]interface{}{
  9828. "patient": patient,
  9829. "number": res.Output.CardNo,
  9830. "insutype": insutype,
  9831. })
  9832. }
  9833. } else {
  9834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9835. return
  9836. }
  9837. } else {
  9838. c.ServeSuccessJSON(map[string]interface{}{
  9839. "failed_code": -10,
  9840. "msg": res.ErrMsg,
  9841. })
  9842. }
  9843. } else {
  9844. //if initFlag == 0 {
  9845. // c.TestGetBasBaseInit()
  9846. //}
  9847. //token := c.GetEleBaseInfo()
  9848. //token = Remove0000(token)
  9849. type ELeData struct {
  9850. Code string `json:"code"`
  9851. Data struct {
  9852. Aac002 string `json:"aac002"`
  9853. Aaz500 string `json:"aaz500"`
  9854. ActCardNo string `json:"actCardNo"`
  9855. Bab520 string `json:"bab520"`
  9856. Bkz543 string `json:"bkz543"`
  9857. BusinessType string `json:"businessType"`
  9858. CertfCodg string `json:"certfCodg"`
  9859. EcIndexNo string `json:"ecIndexNo"`
  9860. EcToken string `json:"ecToken"`
  9861. ID0000 string `json:"id0000"`
  9862. IDNo string `json:"idNo"`
  9863. IDType string `json:"idType"`
  9864. Idcode string `json:"idcode"`
  9865. IdentityToken string `json:"identity_token"`
  9866. InsuOrg string `json:"insuOrg"`
  9867. OfficeID string `json:"officeId"`
  9868. OfficeName string `json:"officeName"`
  9869. OperatorID string `json:"operatorId"`
  9870. OperatorName string `json:"operatorName"`
  9871. OrgID string `json:"orgId"`
  9872. UserName string `json:"userName"`
  9873. } `json:"data"`
  9874. Infno interface{} `json:"infno"`
  9875. Message string `json:"message"`
  9876. OrgID string `json:"orgId"`
  9877. TransType string `json:"transType"`
  9878. }
  9879. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9880. fmt.Println(result)
  9881. outPutInfo := Remove0000(result)
  9882. fmt.Println(outPutInfo)
  9883. var ele ELeData
  9884. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9885. if err != nil {
  9886. utils.ErrorLog("解析失败:%v", err)
  9887. }
  9888. token := ele.Data.EcToken
  9889. var result2 string
  9890. var requestLog2 string
  9891. if len(token) > 0 {
  9892. if strings.Contains(ele.Data.IDNo, "HKG") {
  9893. 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)
  9894. } else {
  9895. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9896. }
  9897. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9898. var res ResultTwo
  9899. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9900. utils.ErrorLog("解析失败:%v", err)
  9901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9902. return
  9903. }
  9904. if res.Infcode == 0 {
  9905. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9906. if err == gorm.ErrRecordNotFound {
  9907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9908. return
  9909. } else if err != nil {
  9910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9911. return
  9912. } else {
  9913. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9914. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9915. infoStr := string(Iinfos)
  9916. idetinfoStr := string(Idetinfos)
  9917. psn := &models.HisPsn{
  9918. PsnNo: res.Output.Baseinfo.PsnNo,
  9919. PatientId: patient.ID,
  9920. Certno: res.Output.Baseinfo.Certno,
  9921. Gend: res.Output.Baseinfo.Gend,
  9922. Naty: res.Output.Baseinfo.Naty,
  9923. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9924. PsnName: res.Output.Baseinfo.PsnName,
  9925. Idetinfo: idetinfoStr,
  9926. Insuinfo: infoStr,
  9927. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9928. CardInfo: "",
  9929. VerifyNumber: token,
  9930. }
  9931. service.CreateHisPsn(psn)
  9932. c.ServeSuccessJSON(map[string]interface{}{
  9933. "msg": "读取成功",
  9934. })
  9935. }
  9936. } else {
  9937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9938. return
  9939. }
  9940. } else {
  9941. c.ServeSuccessJSON(map[string]interface{}{
  9942. "failed_code": -10,
  9943. "msg": "读取失败",
  9944. })
  9945. }
  9946. }
  9947. }
  9948. func (c *HisApiController) ReadEleFace() {
  9949. admin_user_id, _ := c.GetInt64("admin_user_id")
  9950. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9951. adminUser := c.GetAdminUserInfo()
  9952. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9953. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9954. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9955. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9956. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9957. if len(tokens) > 0 {
  9958. c.ServeSuccessJSON(map[string]interface{}{
  9959. "msg": "读取成功",
  9960. })
  9961. } else {
  9962. c.ServeSuccessJSON(map[string]interface{}{
  9963. "failed_code": -10,
  9964. "msg": "读取失败",
  9965. })
  9966. }
  9967. }
  9968. }
  9969. func (c *HisApiController) Get9001() {
  9970. adminUser := c.GetAdminUserInfo()
  9971. admin_user_id, _ := c.GetInt64("admin_user_id")
  9972. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9973. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9974. if miConfig.MdtrtareaAdmvs == "350500" {
  9975. service.GetFjAuthorizationInfo(miConfig.Code)
  9976. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9977. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9978. var dat map[string]interface{}
  9979. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9980. fmt.Println(dat)
  9981. } else {
  9982. fmt.Println(err)
  9983. }
  9984. userJSONBytes, _ := json.Marshal(dat)
  9985. var res models.Result9001
  9986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9987. utils.ErrorLog("解析失败:%v", err)
  9988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9989. return
  9990. }
  9991. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9992. fmt.Println(miConfig.SecretKey)
  9993. var res models.Result9001Two
  9994. 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 +
  9995. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9996. resp, requestErr := http.Get(api)
  9997. if requestErr != nil {
  9998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9999. return
  10000. }
  10001. body, ioErr := ioutil.ReadAll(resp.Body)
  10002. if ioErr != nil {
  10003. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10005. return
  10006. }
  10007. var respJSON map[string]interface{}
  10008. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10011. return
  10012. }
  10013. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10014. if status == "0" {
  10015. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10016. c.ServeSuccessJSON(map[string]interface{}{
  10017. "failed_code": -10,
  10018. "msg": err_msg,
  10019. })
  10020. return
  10021. }
  10022. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10023. result, _ := json.Marshal(respJSON)
  10024. fmt.Println("log")
  10025. fmt.Println(string(result))
  10026. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10027. utils.ErrorLog("解析失败:%v", err)
  10028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10029. return
  10030. }
  10031. if res.Infcode == 0 {
  10032. sign := models.HisSignIn{
  10033. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10034. SignNo: res.Output.Signinoutb.SignNo,
  10035. SignTime: "",
  10036. Ctime: time.Now().Unix(),
  10037. Mtime: time.Now().Unix(),
  10038. Status: 1,
  10039. InputLog: "",
  10040. OutputLog: "",
  10041. FixmedinsCode: miConfig.Code,
  10042. }
  10043. err := service.CreateSignIn(&sign)
  10044. if err == nil {
  10045. c.ServeSuccessJSON(map[string]interface{}{
  10046. "msg": "签到成功",
  10047. })
  10048. }
  10049. } else {
  10050. c.ServeSuccessJSON(map[string]interface{}{
  10051. "failed_code": -10,
  10052. "msg": res.ErrMsg,
  10053. })
  10054. return
  10055. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10056. //return
  10057. }
  10058. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10059. fmt.Println(miConfig.SecretKey)
  10060. var res models.Result9001Two
  10061. 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 +
  10062. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10063. resp, requestErr := http.Get(api)
  10064. if requestErr != nil {
  10065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10066. return
  10067. }
  10068. body, ioErr := ioutil.ReadAll(resp.Body)
  10069. if ioErr != nil {
  10070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10072. return
  10073. }
  10074. var respJSON map[string]interface{}
  10075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10078. return
  10079. }
  10080. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10081. if status == "0" {
  10082. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10083. c.ServeSuccessJSON(map[string]interface{}{
  10084. "failed_code": -10,
  10085. "msg": err_msg,
  10086. })
  10087. return
  10088. }
  10089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10090. result, _ := json.Marshal(respJSON)
  10091. fmt.Println("log")
  10092. fmt.Println(string(result))
  10093. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10094. utils.ErrorLog("解析失败:%v", err)
  10095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10096. return
  10097. }
  10098. if res.Infcode == 0 {
  10099. sign := models.HisSignIn{
  10100. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10101. SignNo: res.Output.Signinoutb.SignNo,
  10102. SignTime: "",
  10103. Ctime: time.Now().Unix(),
  10104. Mtime: time.Now().Unix(),
  10105. Status: 1,
  10106. InputLog: "",
  10107. OutputLog: "",
  10108. FixmedinsCode: miConfig.Code,
  10109. }
  10110. err := service.CreateSignIn(&sign)
  10111. if err == nil {
  10112. c.ServeSuccessJSON(map[string]interface{}{
  10113. "msg": "签到成功",
  10114. })
  10115. }
  10116. } else {
  10117. c.ServeSuccessJSON(map[string]interface{}{
  10118. "failed_code": -10,
  10119. "msg": res.ErrMsg,
  10120. })
  10121. return
  10122. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10123. //return
  10124. }
  10125. } else {
  10126. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10127. var dat map[string]interface{}
  10128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10129. fmt.Println(dat)
  10130. } else {
  10131. fmt.Println(err)
  10132. }
  10133. userJSONBytes, _ := json.Marshal(dat)
  10134. var res models.Result9001
  10135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10136. utils.ErrorLog("解析失败:%v", err)
  10137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10138. return
  10139. }
  10140. if res.Infcode == 0 {
  10141. sign := models.HisSignIn{
  10142. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10143. SignNo: res.Output.Signinoutb.SignNo,
  10144. SignTime: res.Output.Signinoutb.SignTime,
  10145. Ctime: time.Now().Unix(),
  10146. Mtime: time.Now().Unix(),
  10147. Status: 1,
  10148. InputLog: "",
  10149. OutputLog: "",
  10150. FixmedinsCode: miConfig.Code,
  10151. }
  10152. err := service.CreateSignIn(&sign)
  10153. if err == nil {
  10154. c.ServeSuccessJSON(map[string]interface{}{
  10155. "msg": "签到成功",
  10156. })
  10157. }
  10158. }
  10159. }
  10160. }
  10161. 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) {
  10162. var res Result3101
  10163. adminUser := c.GetAdminUserInfo()
  10164. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10165. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10166. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10167. //record_time := c.GetString("record_time")
  10168. //trig_scen := c.GetString("trig_scen")
  10169. timeLayout := "2006-01-02"
  10170. loc, _ := time.LoadLocation("Local")
  10171. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10172. if err != nil {
  10173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10174. return res
  10175. }
  10176. recordDateTime := theTime.Unix()
  10177. var patientPrescription models.HisPrescriptionInfo
  10178. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10179. //if patientPrescription.ID == 0 {
  10180. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10181. //}
  10182. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10183. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10184. //
  10185. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10186. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10187. var pp models.PublicParams
  10188. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10189. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10190. pp.FixmedinsName = miConfig.OrgName
  10191. pp.FixmedinsCode = miConfig.Code
  10192. pp.RequestUrl = miConfig.Url
  10193. pp.Cainfo = miConfig.Cainfo
  10194. pp.SecretKey = miConfig.SecretKey
  10195. pp.AccessKey = miConfig.AccessKey
  10196. pp.OpterName = roles.UserName
  10197. var config []*models.HisXtDiagnoseConfig
  10198. for _, item := range diagnosis_ids {
  10199. id, _ := strconv.ParseInt(item, 10, 64)
  10200. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10201. config = append(config, &diagnosisConfig)
  10202. }
  10203. var pd models.PatientDtos
  10204. pd.PatnID = his.PsnNo
  10205. pd.PatnName = his.Name
  10206. pd.Gend = his.Gend
  10207. pd.Brdy = his.Brdy
  10208. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10209. pd.CurrMdtrtID = his.Number
  10210. var fed models.FsiEncounterDtos
  10211. fed.MdtrtID = his.Number
  10212. fed.MedinsID = miConfig.Code
  10213. fed.MedinsName = miConfig.OrgName
  10214. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10215. fed.MedMdtrtType = "1"
  10216. fed.MedinsType = "1"
  10217. fed.MedinsLv = "11"
  10218. tm := time.Unix(his.RecordDate, 0)
  10219. s_tm := tm.Format("2006-01-02 15:04:05")
  10220. fed.AdmDate = s_tm
  10221. fed.DscgDate = s_tm
  10222. fed.DscgMainDiseCodg = config[0].CountryCode
  10223. fed.DscgMainDiseName = config[0].CountryContentName
  10224. //诊断信息
  10225. var fdds []*models.FsiDiagnoseDtos
  10226. for index, item := range config {
  10227. if index == 0 {
  10228. var fdd models.FsiDiagnoseDtos
  10229. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10230. fdd.InoutDiseType = "1"
  10231. fdd.MaindiseFlag = "1"
  10232. fdd.DiseDate = s_tm
  10233. fdd.DiasSrtNo = "1"
  10234. fdd.DiseName = item.CountryContentName
  10235. fdd.DiseCodg = item.CountryCode
  10236. fdds = append(fdds, &fdd)
  10237. } else {
  10238. var fdd models.FsiDiagnoseDtos
  10239. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10240. fdd.InoutDiseType = "1"
  10241. fdd.MaindiseFlag = "1"
  10242. fdd.DiseDate = s_tm
  10243. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10244. fdd.DiseName = item.CountryContentName
  10245. fdd.DiseCodg = item.CountryCode
  10246. fdds = append(fdds, &fdd)
  10247. }
  10248. }
  10249. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10250. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10251. fed.AdmDeptName = de.Name
  10252. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10253. fed.DscgDeptName = de.Name
  10254. fed.MedMdtrtType = "1"
  10255. fed.MedType = "11"
  10256. //if his.Insutype == "390" {
  10257. // fed.MedType = "1402"
  10258. //} else {
  10259. // fed.MedType = "9933"
  10260. //}
  10261. var orders []*models.FsiOrderDtos
  10262. if trig_scen == "2" {
  10263. //处方医嘱信息
  10264. for _, item := range prescriptions {
  10265. for _, subItem := range item.HisDoctorAdviceInfo {
  10266. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10267. var order models.FsiOrderDtos
  10268. order.RxID = strconv.FormatInt(item.ID, 10)
  10269. order.Rxno = strconv.FormatInt(item.ID, 10)
  10270. order.LongDrordFlag = "0"
  10271. order.HilistType = "1"
  10272. order.ChrgType = "1"
  10273. order.DrordBhvr = "-"
  10274. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10275. order.HosplistName = subItem.BaseDrugLib.DrugName
  10276. order.HilistLv = "1"
  10277. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10278. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10279. order.HosplistName = subItem.BaseDrugLib.DrugName
  10280. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10281. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10282. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10283. order.OwnpayAmt = ""
  10284. order.SelfpayAmt = ""
  10285. order.Spec = ""
  10286. order.SpecUnt = ""
  10287. order.DrordBegnDate = s_tm
  10288. order.DrordStopDate = ""
  10289. order.DrordDrCodg = doctor_info.DoctorNumber
  10290. order.DrordDeptName = department.Name
  10291. order.DrordDeptCodg = department.Number
  10292. order.DrordDrName = doctor_info.UserName
  10293. order.DrordDrProfttl = "234"
  10294. order.CurrDrordFlag = "1"
  10295. orders = append(orders, &order)
  10296. }
  10297. }
  10298. for _, subItem := range item.HisPrescriptionProject {
  10299. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10300. var order models.FsiOrderDtos
  10301. order.RxID = strconv.FormatInt(item.ID, 10)
  10302. order.Rxno = strconv.FormatInt(item.ID, 10)
  10303. order.LongDrordFlag = "0"
  10304. order.HilistType = "1"
  10305. order.ChrgType = "1"
  10306. order.DrordBhvr = "-"
  10307. order.HilistCode = subItem.HisProject.MedicalCode
  10308. order.HosplistName = subItem.HisProject.ProjectName
  10309. order.HilistLv = "1"
  10310. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10311. order.HosplistCode = subItem.HisProject.MedicalCode
  10312. order.HosplistName = subItem.HisProject.ProjectName
  10313. order.Cnt = subItem.Count
  10314. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10315. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10316. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10317. order.OwnpayAmt = ""
  10318. order.SelfpayAmt = ""
  10319. order.Spec = ""
  10320. order.SpecUnt = ""
  10321. order.DrordBegnDate = s_tm
  10322. order.DrordStopDate = ""
  10323. order.DrordDrCodg = doctor_info.DoctorNumber
  10324. order.DrordDeptName = department.Name
  10325. order.DrordDeptCodg = department.Number
  10326. order.DrordDrName = doctor_info.UserName
  10327. order.DrordDrProfttl = "234"
  10328. order.CurrDrordFlag = "1"
  10329. orders = append(orders, &order)
  10330. }
  10331. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10332. var order models.FsiOrderDtos
  10333. order.RxID = strconv.FormatInt(item.ID, 10)
  10334. order.Rxno = strconv.FormatInt(item.ID, 10)
  10335. order.LongDrordFlag = "0"
  10336. order.HilistType = "1"
  10337. order.ChrgType = "1"
  10338. order.DrordBhvr = "-"
  10339. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10340. order.HosplistName = subItem.GoodInfo.GoodName
  10341. order.HilistLv = "1"
  10342. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10343. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10344. order.HosplistName = subItem.GoodInfo.GoodName
  10345. order.Cnt = subItem.Count
  10346. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10347. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10348. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10349. order.OwnpayAmt = ""
  10350. order.SelfpayAmt = ""
  10351. order.Spec = ""
  10352. order.SpecUnt = ""
  10353. order.DrordBegnDate = s_tm
  10354. order.DrordStopDate = ""
  10355. order.DrordDrCodg = doctor_info.DoctorNumber
  10356. order.DrordDeptName = department.Name
  10357. order.DrordDeptCodg = department.Number
  10358. order.DrordDrName = doctor_info.UserName
  10359. order.DrordDrProfttl = "234"
  10360. order.CurrDrordFlag = "1"
  10361. orders = append(orders, &order)
  10362. }
  10363. }
  10364. }
  10365. //处方医嘱信息
  10366. }
  10367. fed.MatnStas = "0"
  10368. fed.MedfeeSumamt = "0"
  10369. fed.OwnpayAmt = "0"
  10370. fed.SelfpayAmt = "0"
  10371. fed.AcctPayamt = "0"
  10372. fed.MaAmt = "0"
  10373. fed.HifpPayamt = "0"
  10374. fed.SetlTotlnum = "1"
  10375. fed.Insutype = his.Insutype
  10376. fed.ReimFlag = "0"
  10377. fed.OutSetlFlag = "0"
  10378. var fopd []*models.FsiOperationDtosData
  10379. data := make(map[string]interface{})
  10380. data["fed"] = fed
  10381. data["fdd"] = fdds
  10382. data["fod"] = orders
  10383. data["pd"] = pd
  10384. data["pp"] = pp
  10385. data["fopd"] = fopd
  10386. data["trig_scen"] = trig_scen
  10387. fmt.Println(data)
  10388. fmt.Println(fed)
  10389. fmt.Println(fdds)
  10390. fmt.Println(orders)
  10391. fmt.Println(pd)
  10392. fmt.Println(pp)
  10393. fmt.Println(fopd)
  10394. client := &http.Client{}
  10395. bytesData, _ := json.Marshal(data)
  10396. var req *http.Request
  10397. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10398. if miConfig.MdtrtareaAdmvs == "320921" {
  10399. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10400. } else {
  10401. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10402. }
  10403. resp, _ := client.Do(req)
  10404. defer resp.Body.Close()
  10405. body, ioErr := ioutil.ReadAll(resp.Body)
  10406. if ioErr != nil {
  10407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10409. return res
  10410. }
  10411. var respJSON map[string]interface{}
  10412. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10415. return res
  10416. }
  10417. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10418. fmt.Println(respJSON)
  10419. result, _ := json.Marshal(respJSON)
  10420. fmt.Println(result)
  10421. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10422. utils.ErrorLog("解析失败:%v", err)
  10423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10424. return res
  10425. }
  10426. return res
  10427. } else {
  10428. //if miConfig.MdtrtareaAdmvs == "441202" {
  10429. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10430. saveLog(output, input, "3101", "事前")
  10431. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10432. utils.ErrorLog("解析失败:%v", err)
  10433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10434. return
  10435. }
  10436. return res
  10437. //}
  10438. }
  10439. }
  10440. 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) {
  10441. adminUser := c.GetAdminUserInfo()
  10442. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10443. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10445. //record_time := c.GetString("record_time")
  10446. //trig_scen := c.GetString("trig_scen")
  10447. timeLayout := "2006-01-02"
  10448. loc, _ := time.LoadLocation("Local")
  10449. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10450. if err != nil {
  10451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10452. return res
  10453. }
  10454. recordDateTime := theTime.Unix()
  10455. var patientPrescription models.HisPrescriptionInfo
  10456. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10457. if patientPrescription.ID == 0 {
  10458. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10459. }
  10460. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10461. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10462. //
  10463. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10464. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10465. var pp models.PublicParams
  10466. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10467. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10468. pp.FixmedinsName = miConfig.OrgName
  10469. pp.FixmedinsCode = miConfig.Code
  10470. pp.RequestUrl = miConfig.Url
  10471. pp.Cainfo = miConfig.Cainfo
  10472. pp.SecretKey = miConfig.SecretKey
  10473. pp.AccessKey = miConfig.AccessKey
  10474. pp.OpterName = roles.UserName
  10475. var config []*models.HisXtDiagnoseConfig
  10476. for _, item := range diagnosis_ids {
  10477. id, _ := strconv.ParseInt(item, 10, 64)
  10478. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10479. config = append(config, &diagnosisConfig)
  10480. }
  10481. var pd models.PatientDtos
  10482. pd.PatnID = his.PsnNo
  10483. pd.PatnName = his.Name
  10484. pd.Gend = his.Gend
  10485. pd.Brdy = his.Brdy
  10486. pd.Poolarea = his.InsuplcAdmdvs
  10487. pd.CurrMdtrtID = his.Number
  10488. var fed models.FsiEncounterDtos
  10489. fed.MdtrtID = his.Number
  10490. fed.MedinsID = miConfig.Code
  10491. fed.MedinsName = miConfig.OrgName
  10492. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10493. fed.MedMdtrtType = "1"
  10494. fed.MedinsType = "1"
  10495. fed.MedinsLv = "11"
  10496. tm := time.Unix(his.RecordDate, 0)
  10497. s_tm := tm.Format("2006-01-02 15:04:05")
  10498. fed.AdmDate = s_tm
  10499. fed.DscgDate = s_tm
  10500. fed.DscgMainDiseCodg = config[0].CountryCode
  10501. fed.DscgMainDiseName = config[0].CountryContentName
  10502. //诊断信息
  10503. var fdds []*models.FsiDiagnoseDtos
  10504. for index, item := range config {
  10505. if index == 0 {
  10506. var fdd models.FsiDiagnoseDtos
  10507. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10508. fdd.InoutDiseType = "1"
  10509. fdd.MaindiseFlag = "1"
  10510. fdd.DiseDate = s_tm
  10511. fdd.DiasSrtNo = "1"
  10512. fdd.DiseName = item.CountryContentName
  10513. fdd.DiseCodg = item.CountryCode
  10514. fdds = append(fdds, &fdd)
  10515. } else {
  10516. var fdd models.FsiDiagnoseDtos
  10517. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10518. fdd.InoutDiseType = "1"
  10519. fdd.MaindiseFlag = "1"
  10520. fdd.DiseDate = s_tm
  10521. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10522. fdd.DiseName = item.CountryContentName
  10523. fdd.DiseCodg = item.CountryCode
  10524. fdds = append(fdds, &fdd)
  10525. }
  10526. }
  10527. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10528. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10529. fed.AdmDeptName = department.Name
  10530. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10531. fed.DscgDeptName = department.Name
  10532. fed.MedMdtrtType = "1"
  10533. fed.MedType = "11"
  10534. //if his.Insutype == "390" {
  10535. // fed.MedType = "1402"
  10536. //} else {
  10537. // fed.MedType = "9933"
  10538. //}
  10539. var orders []*models.FsiOrderDtos
  10540. if trig_scen == "2" {
  10541. //处方医嘱信息
  10542. for _, item := range prescriptions {
  10543. for _, subItem := range item.HisDoctorAdviceInfo {
  10544. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10545. var order models.FsiOrderDtos
  10546. order.RxID = strconv.FormatInt(item.ID, 10)
  10547. order.Rxno = strconv.FormatInt(item.ID, 10)
  10548. order.LongDrordFlag = "0"
  10549. order.HilistType = "1"
  10550. order.ChrgType = "1"
  10551. order.DrordBhvr = "-"
  10552. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10553. order.HosplistName = subItem.BaseDrugLib.DrugName
  10554. order.HilistLv = "1"
  10555. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10556. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10557. order.HosplistName = subItem.BaseDrugLib.DrugName
  10558. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10559. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10560. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10561. order.OwnpayAmt = ""
  10562. order.SelfpayAmt = ""
  10563. order.Spec = ""
  10564. order.SpecUnt = ""
  10565. order.DrordBegnDate = s_tm
  10566. order.DrordStopDate = ""
  10567. order.DrordDrCodg = doctor_info.DoctorNumber
  10568. order.DrordDeptName = department.Name
  10569. order.DrordDeptCodg = department.Number
  10570. order.DrordDrName = doctor_info.UserName
  10571. order.DrordDrProfttl = "234"
  10572. order.CurrDrordFlag = "1"
  10573. orders = append(orders, &order)
  10574. }
  10575. }
  10576. for _, subItem := range item.HisPrescriptionProject {
  10577. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10578. var order models.FsiOrderDtos
  10579. order.RxID = strconv.FormatInt(item.ID, 10)
  10580. order.Rxno = strconv.FormatInt(item.ID, 10)
  10581. order.LongDrordFlag = "0"
  10582. order.HilistType = "1"
  10583. order.ChrgType = "1"
  10584. order.DrordBhvr = "-"
  10585. order.HilistCode = subItem.HisProject.MedicalCode
  10586. order.HosplistName = subItem.HisProject.ProjectName
  10587. order.HilistLv = "1"
  10588. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10589. order.HosplistCode = subItem.HisProject.MedicalCode
  10590. order.HosplistName = subItem.HisProject.ProjectName
  10591. order.Cnt = subItem.Count
  10592. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10593. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10594. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10595. order.OwnpayAmt = ""
  10596. order.SelfpayAmt = ""
  10597. order.Spec = ""
  10598. order.SpecUnt = ""
  10599. order.DrordBegnDate = s_tm
  10600. order.DrordStopDate = ""
  10601. order.DrordDrCodg = doctor_info.DoctorNumber
  10602. order.DrordDeptName = department.Name
  10603. order.DrordDeptCodg = department.Number
  10604. order.DrordDrName = doctor_info.UserName
  10605. order.DrordDrProfttl = "234"
  10606. order.CurrDrordFlag = "1"
  10607. orders = append(orders, &order)
  10608. }
  10609. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10610. var order models.FsiOrderDtos
  10611. order.RxID = strconv.FormatInt(item.ID, 10)
  10612. order.Rxno = strconv.FormatInt(item.ID, 10)
  10613. order.LongDrordFlag = "0"
  10614. order.HilistType = "1"
  10615. order.ChrgType = "1"
  10616. order.DrordBhvr = "-"
  10617. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10618. order.HosplistName = subItem.GoodInfo.GoodName
  10619. order.HilistLv = "1"
  10620. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10621. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10622. order.HosplistName = subItem.GoodInfo.GoodName
  10623. order.Cnt = subItem.Count
  10624. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10625. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10626. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10627. order.OwnpayAmt = ""
  10628. order.SelfpayAmt = ""
  10629. order.Spec = ""
  10630. order.SpecUnt = ""
  10631. order.DrordBegnDate = s_tm
  10632. order.DrordStopDate = ""
  10633. order.DrordDrCodg = doctor_info.DoctorNumber
  10634. order.DrordDeptName = department.Name
  10635. order.DrordDeptCodg = department.Number
  10636. order.DrordDrName = doctor_info.UserName
  10637. order.DrordDrProfttl = "234"
  10638. order.CurrDrordFlag = "1"
  10639. orders = append(orders, &order)
  10640. }
  10641. }
  10642. }
  10643. //处方医嘱信息
  10644. }
  10645. fed.MatnStas = "0"
  10646. fed.MedfeeSumamt = "0"
  10647. fed.OwnpayAmt = "0"
  10648. fed.SelfpayAmt = "0"
  10649. fed.AcctPayamt = "0"
  10650. fed.MaAmt = "0"
  10651. fed.HifpPayamt = "0"
  10652. fed.SetlTotlnum = "1"
  10653. fed.Insutype = his.Insutype
  10654. fed.ReimFlag = "0"
  10655. fed.OutSetlFlag = "0"
  10656. var fopd []*models.FsiOperationDtosData
  10657. data := make(map[string]interface{})
  10658. data["fed"] = fed
  10659. data["fdd"] = fdds
  10660. data["fod"] = orders
  10661. data["pd"] = pd
  10662. data["pp"] = pp
  10663. data["fopd"] = fopd
  10664. data["trig_scen"] = trig_scen
  10665. fmt.Println(data)
  10666. fmt.Println(fed)
  10667. fmt.Println(fdds)
  10668. fmt.Println(orders)
  10669. fmt.Println(pd)
  10670. fmt.Println(pp)
  10671. fmt.Println(fopd)
  10672. client := &http.Client{}
  10673. bytesData, _ := json.Marshal(data)
  10674. var req *http.Request
  10675. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10676. if miConfig.MdtrtareaAdmvs == "320921" {
  10677. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10678. } else {
  10679. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10680. }
  10681. resp, _ := client.Do(req)
  10682. defer resp.Body.Close()
  10683. body, ioErr := ioutil.ReadAll(resp.Body)
  10684. if ioErr != nil {
  10685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10687. return res
  10688. }
  10689. var respJSON map[string]interface{}
  10690. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10693. return res
  10694. }
  10695. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10696. fmt.Println(respJSON)
  10697. result, _ := json.Marshal(respJSON)
  10698. fmt.Println(result)
  10699. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10700. utils.ErrorLog("解析失败:%v", err)
  10701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10702. return res
  10703. }
  10704. return res
  10705. } else {
  10706. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10707. saveLog(output, input, "3101", "事前")
  10708. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10709. utils.ErrorLog("解析失败:%v", err)
  10710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10711. return
  10712. }
  10713. return res
  10714. }
  10715. return res
  10716. }
  10717. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10718. ////patient_id, _ := c.GetInt64("patient_id")
  10719. //order_id, _ := c.GetInt64("order_id")
  10720. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10721. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10722. //trig_scen := c.GetString("trig_scen")
  10723. adminUser := c.GetAdminUserInfo()
  10724. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10725. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10726. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10727. record_time := c.GetString("record_time")
  10728. order, _ := service.GetHisOrderByID(order_id)
  10729. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10730. timeLayout := "2006-01-02"
  10731. loc, _ := time.LoadLocation("Local")
  10732. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10733. if err != nil {
  10734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10735. return
  10736. }
  10737. recordDateTime := theTime.Unix()
  10738. var patientPrescription models.HisPrescriptionInfo
  10739. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10740. if patientPrescription.ID == 0 {
  10741. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10742. }
  10743. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10744. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10745. //
  10746. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10747. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10748. var pp models.PublicParams
  10749. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10750. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10751. pp.FixmedinsName = miConfig.OrgName
  10752. pp.FixmedinsCode = miConfig.Code
  10753. pp.RequestUrl = miConfig.Url
  10754. pp.Cainfo = miConfig.Cainfo
  10755. pp.SecretKey = miConfig.SecretKey
  10756. pp.AccessKey = miConfig.AccessKey
  10757. pp.OpterName = roles.UserName
  10758. var config []*models.HisXtDiagnoseConfig
  10759. for _, item := range diagnosis_ids {
  10760. id, _ := strconv.ParseInt(item, 10, 64)
  10761. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10762. config = append(config, &diagnosisConfig)
  10763. }
  10764. var pd models.PatientDtos
  10765. pd.PatnID = his.PsnNo
  10766. pd.PatnName = his.Name
  10767. pd.Gend = his.Gend
  10768. pd.Brdy = psn_info.Brdy
  10769. pd.Poolarea = his.InsuplcAdmdvs
  10770. pd.CurrMdtrtID = his.Number
  10771. var fed models.FsiEncounterDtos
  10772. fed.MdtrtID = his.Number
  10773. fed.MedinsID = miConfig.Code
  10774. fed.MedinsName = miConfig.OrgName
  10775. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10776. fed.MedMdtrtType = "1"
  10777. fed.MedinsType = "1"
  10778. fed.MedinsLv = "11"
  10779. tm := time.Unix(his.RecordDate, 0)
  10780. s_tm := tm.Format("2006-01-02 15:04:05")
  10781. fed.AdmDate = s_tm
  10782. fed.DscgDate = s_tm
  10783. fed.DscgMainDiseCodg = config[0].CountryCode
  10784. fed.DscgMainDiseName = config[0].CountryContentName
  10785. //诊断信息
  10786. var fdds []*models.FsiDiagnoseDtos
  10787. for index, item := range config {
  10788. if index == 0 {
  10789. var fdd models.FsiDiagnoseDtos
  10790. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10791. fdd.InoutDiseType = "1"
  10792. fdd.MaindiseFlag = "1"
  10793. fdd.DiseDate = s_tm
  10794. fdd.DiasSrtNo = "1"
  10795. fdd.DiseName = item.CountryContentName
  10796. fdd.DiseCodg = item.CountryCode
  10797. fdds = append(fdds, &fdd)
  10798. } else {
  10799. var fdd models.FsiDiagnoseDtos
  10800. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10801. fdd.InoutDiseType = "1"
  10802. fdd.MaindiseFlag = "1"
  10803. fdd.DiseDate = s_tm
  10804. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10805. fdd.DiseName = item.CountryContentName
  10806. fdd.DiseCodg = item.CountryCode
  10807. fdds = append(fdds, &fdd)
  10808. }
  10809. }
  10810. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10811. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10812. fed.AdmDeptName = department.Name
  10813. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10814. fed.DscgDeptName = department.Name
  10815. fed.MedType = order.MedType
  10816. //处方医嘱信息
  10817. var orders []*models.FsiOrderDtos
  10818. //for _, item := range prescriptions {
  10819. // for _, subItem := range item.HisDoctorAdviceInfo {
  10820. // var order models.FsiOrderDtos
  10821. // order.RxID = strconv.FormatInt(item.ID, 10)
  10822. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10823. // order.LongDrordFlag = "0"
  10824. // order.HilistType = "1"
  10825. // order.ChrgType = "1"
  10826. // order.DrordBhvr = "-"
  10827. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10828. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10829. // order.HilistLv = "1"
  10830. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10831. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10832. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10833. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10834. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10835. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10836. // order.OwnpayAmt = ""
  10837. // order.SelfpayAmt = ""
  10838. // order.Spec = ""
  10839. // order.SpecUnt = ""
  10840. // order.DrordBegnDate = s_tm
  10841. // order.DrordStopDate = ""
  10842. // order.DrordDrCodg = "1"
  10843. // order.DrordDeptName = department.Name
  10844. // order.DrordDrCodg = "1"
  10845. // order.DrordDrName = doctor_info.UserName
  10846. // order.DrordDrProfttl = ""
  10847. // order.CurrDrordFlag = "1"
  10848. // orders = append(orders, &order)
  10849. // }
  10850. // for _, subItem := range item.HisPrescriptionProject {
  10851. // if subItem.Type == 2 {
  10852. // var order models.FsiOrderDtos
  10853. // order.RxID = strconv.FormatInt(item.ID, 10)
  10854. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10855. // order.LongDrordFlag = "0"
  10856. // order.HilistType = "1"
  10857. // order.ChrgType = "1"
  10858. // order.DrordBhvr = "-"
  10859. // order.HilistCode = subItem.HisProject.MedicalCode
  10860. // order.HosplistName = subItem.HisProject.ProjectName
  10861. // order.HilistLv = "1"
  10862. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10863. // order.HosplistCode = subItem.HisProject.MedicalCode
  10864. // order.HosplistName = subItem.HisProject.ProjectName
  10865. // order.Cnt = subItem.Count
  10866. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10867. //
  10868. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10869. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10870. // order.OwnpayAmt = ""
  10871. // order.SelfpayAmt = ""
  10872. // order.Spec = ""
  10873. // order.SpecUnt = ""
  10874. // order.DrordBegnDate = s_tm
  10875. // order.DrordStopDate = ""
  10876. // order.DrordDrCodg = "1"
  10877. // order.DrordDeptName = department.Name
  10878. // order.DrordDrCodg = "1"
  10879. // order.DrordDrName = doctor_info.UserName
  10880. // order.DrordDrProfttl = ""
  10881. // order.CurrDrordFlag = "1"
  10882. // orders = append(orders, &order)
  10883. //
  10884. // }
  10885. // if subItem.Type == 3 {
  10886. //
  10887. // var order models.FsiOrderDtos
  10888. // order.RxID = strconv.FormatInt(item.ID, 10)
  10889. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10890. // order.LongDrordFlag = "0"
  10891. // order.HilistType = "1"
  10892. // order.ChrgType = "1"
  10893. // order.DrordBhvr = "-"
  10894. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10895. // order.HosplistName = subItem.GoodInfo.GoodName
  10896. // order.HilistLv = "1"
  10897. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10898. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10899. // order.HosplistName = subItem.GoodInfo.GoodName
  10900. // order.Cnt = subItem.Count
  10901. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10902. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10903. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10904. // order.OwnpayAmt = ""
  10905. // order.SelfpayAmt = ""
  10906. // order.Spec = ""
  10907. // order.SpecUnt = ""
  10908. // order.DrordBegnDate = s_tm
  10909. // order.DrordStopDate = ""
  10910. // order.DrordDrCodg = "1"
  10911. // order.DrordDeptName = department.Name
  10912. // order.DrordDrCodg = "1"
  10913. // order.DrordDrName = doctor_info.UserName
  10914. // order.DrordDrProfttl = ""
  10915. // order.CurrDrordFlag = "1"
  10916. // orders = append(orders, &order)
  10917. //
  10918. // }
  10919. // }
  10920. //}
  10921. for _, item := range prescriptions {
  10922. for _, subItem := range item.HisDoctorAdviceInfo {
  10923. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10924. var order models.FsiOrderDtos
  10925. order.RxID = strconv.FormatInt(item.ID, 10)
  10926. order.Rxno = strconv.FormatInt(item.ID, 10)
  10927. order.LongDrordFlag = "0"
  10928. order.HilistType = "1"
  10929. order.ChrgType = "1"
  10930. order.DrordBhvr = "-"
  10931. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10932. order.HosplistName = subItem.BaseDrugLib.DrugName
  10933. order.HilistLv = "1"
  10934. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10935. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10936. order.HosplistName = subItem.BaseDrugLib.DrugName
  10937. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10938. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10939. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10940. order.OwnpayAmt = ""
  10941. order.SelfpayAmt = ""
  10942. order.Spec = ""
  10943. order.SpecUnt = ""
  10944. order.DrordBegnDate = s_tm
  10945. order.DrordStopDate = ""
  10946. order.DrordDrCodg = doctor_info.DoctorNumber
  10947. order.DrordDeptName = department.Name
  10948. order.DrordDeptCodg = department.Number
  10949. order.DrordDrName = doctor_info.UserName
  10950. order.DrordDrProfttl = "234"
  10951. order.CurrDrordFlag = "1"
  10952. orders = append(orders, &order)
  10953. }
  10954. }
  10955. for _, subItem := range item.HisPrescriptionProject {
  10956. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10957. var order models.FsiOrderDtos
  10958. order.RxID = strconv.FormatInt(item.ID, 10)
  10959. order.Rxno = strconv.FormatInt(item.ID, 10)
  10960. order.LongDrordFlag = "0"
  10961. order.HilistType = "1"
  10962. order.ChrgType = "1"
  10963. order.DrordBhvr = "-"
  10964. order.HilistCode = subItem.HisProject.MedicalCode
  10965. order.HosplistName = subItem.HisProject.ProjectName
  10966. order.HilistLv = "1"
  10967. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10968. order.HosplistCode = subItem.HisProject.MedicalCode
  10969. order.HosplistName = subItem.HisProject.ProjectName
  10970. order.Cnt = subItem.Count
  10971. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10972. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10973. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10974. order.OwnpayAmt = ""
  10975. order.SelfpayAmt = ""
  10976. order.Spec = ""
  10977. order.SpecUnt = ""
  10978. order.DrordBegnDate = s_tm
  10979. order.DrordStopDate = ""
  10980. order.DrordDrCodg = doctor_info.DoctorNumber
  10981. order.DrordDeptName = department.Name
  10982. order.DrordDeptCodg = department.Number
  10983. order.DrordDrName = doctor_info.UserName
  10984. order.DrordDrProfttl = "234"
  10985. order.CurrDrordFlag = "1"
  10986. orders = append(orders, &order)
  10987. }
  10988. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10989. var order models.FsiOrderDtos
  10990. order.RxID = strconv.FormatInt(item.ID, 10)
  10991. order.Rxno = strconv.FormatInt(item.ID, 10)
  10992. order.LongDrordFlag = "0"
  10993. order.HilistType = "1"
  10994. order.ChrgType = "1"
  10995. order.DrordBhvr = "0"
  10996. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10997. order.HosplistName = subItem.GoodInfo.GoodName
  10998. order.HilistLv = "1"
  10999. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11000. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11001. order.HosplistName = subItem.GoodInfo.GoodName
  11002. order.Cnt = subItem.Count
  11003. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11004. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11005. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11006. order.OwnpayAmt = ""
  11007. order.SelfpayAmt = ""
  11008. order.Spec = ""
  11009. order.SpecUnt = ""
  11010. order.DrordBegnDate = s_tm
  11011. order.DrordStopDate = ""
  11012. order.DrordDrCodg = doctor_info.DoctorNumber
  11013. order.DrordDeptName = department.Name
  11014. order.DrordDeptCodg = department.Number
  11015. order.DrordDrName = doctor_info.UserName
  11016. order.DrordDrProfttl = "234"
  11017. order.CurrDrordFlag = "1"
  11018. orders = append(orders, &order)
  11019. }
  11020. }
  11021. }
  11022. //处方医嘱信息
  11023. fed.MatnStas = "0"
  11024. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11025. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11026. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11027. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11028. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11029. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11030. fed.SetlTotlnum = "1"
  11031. fed.Insutype = his.Insutype
  11032. fed.ReimFlag = "0"
  11033. fed.OutSetlFlag = "0"
  11034. var fopd []*models.FsiOperationDtosData
  11035. data := make(map[string]interface{})
  11036. data["fed"] = fed
  11037. data["fdd"] = fdds
  11038. data["fod"] = orders
  11039. data["pd"] = pd
  11040. data["pp"] = pp
  11041. data["fopd"] = fopd
  11042. data["trig_scen"] = trig_scen
  11043. client := &http.Client{}
  11044. bytesData, _ := json.Marshal(data)
  11045. var req *http.Request
  11046. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11047. if miConfig.MdtrtareaAdmvs == "320921" {
  11048. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11049. } else {
  11050. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11051. }
  11052. resp, _ := client.Do(req)
  11053. defer resp.Body.Close()
  11054. body, ioErr := ioutil.ReadAll(resp.Body)
  11055. if ioErr != nil {
  11056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11058. return res
  11059. }
  11060. var respJSON map[string]interface{}
  11061. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11064. return res
  11065. }
  11066. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11067. result, _ := json.Marshal(respJSON)
  11068. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11069. utils.ErrorLog("解析失败:%v", err)
  11070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11071. return res
  11072. }
  11073. return res
  11074. } else {
  11075. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11076. saveLog(output, input, "3102", "事中")
  11077. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11078. utils.ErrorLog("解析失败:%v", err)
  11079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11080. return
  11081. }
  11082. return res
  11083. }
  11084. return res
  11085. }
  11086. 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) {
  11087. var res Resultgd3101
  11088. adminUser := c.GetAdminUserInfo()
  11089. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11090. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11091. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11092. //record_time := c.GetString("record_time")
  11093. //trig_scen := c.GetString("trig_scen")
  11094. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11095. //psn_info, _ := service.GetPatientId(patient_id)
  11096. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11097. timeLayout := "2006-01-02"
  11098. loc, _ := time.LoadLocation("Local")
  11099. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11100. if err != nil {
  11101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11102. return res
  11103. }
  11104. recordDateTime := theTime.Unix()
  11105. var patientPrescription models.HisPrescriptionInfo
  11106. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11107. //if patientPrescription.ID == 0 {
  11108. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11109. //}
  11110. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11111. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11112. //
  11113. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11114. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11115. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11116. var pp models.PublicParams
  11117. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11118. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11119. pp.FixmedinsName = miConfig.OrgName
  11120. pp.FixmedinsCode = miConfig.Code
  11121. pp.RequestUrl = miConfig.Url
  11122. pp.Cainfo = miConfig.Cainfo
  11123. pp.SecretKey = miConfig.SecretKey
  11124. pp.AccessKey = miConfig.AccessKey
  11125. pp.OpterName = roles.UserName
  11126. var config []*models.HisXtDiagnoseConfig
  11127. for _, item := range diagnosis_ids {
  11128. id, _ := strconv.ParseInt(item, 10, 64)
  11129. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11130. config = append(config, &diagnosisConfig)
  11131. }
  11132. var pd models.PatientDtos
  11133. pd.PatnID = his.PsnNo
  11134. pd.PatnName = his.Name
  11135. pd.Gend = his.Gend
  11136. pd.Brdy = str
  11137. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11138. pd.CurrMdtrtID = his.Number
  11139. var fed models.FsiEncounterDtos
  11140. fed.MdtrtID = his.Number
  11141. fed.MedinsID = miConfig.Code
  11142. fed.MedinsName = miConfig.OrgName
  11143. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11144. fed.MedMdtrtType = "1"
  11145. fed.MedinsType = "1"
  11146. fed.MedinsLv = "11"
  11147. tm := time.Unix(his.RecordDate, 0)
  11148. s_tm := tm.Format("2006-01-02 15:04:05")
  11149. fed.AdmDate = s_tm
  11150. fed.DscgDate = s_tm
  11151. fed.DscgMainDiseCodg = config[0].CountryCode
  11152. fed.DscgMainDiseName = config[0].CountryContentName
  11153. //诊断信息
  11154. var fdds []*models.FsiDiagnoseDtos
  11155. for index, item := range config {
  11156. if index == 0 {
  11157. var fdd models.FsiDiagnoseDtos
  11158. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11159. fdd.InoutDiseType = "1"
  11160. fdd.MaindiseFlag = "1"
  11161. fdd.DiseDate = s_tm
  11162. fdd.DiasSrtNo = "1"
  11163. fdd.DiseName = item.CountryContentName
  11164. fdd.DiseCodg = item.CountryCode
  11165. fdds = append(fdds, &fdd)
  11166. } else {
  11167. var fdd models.FsiDiagnoseDtos
  11168. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11169. fdd.InoutDiseType = "1"
  11170. fdd.MaindiseFlag = "1"
  11171. fdd.DiseDate = s_tm
  11172. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11173. fdd.DiseName = item.CountryContentName
  11174. fdd.DiseCodg = item.CountryCode
  11175. fdds = append(fdds, &fdd)
  11176. }
  11177. }
  11178. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11179. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11180. fed.AdmDeptName = de.Name
  11181. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11182. fed.DscgDeptName = de.Name
  11183. fed.MedMdtrtType = "1"
  11184. fed.MedType = "11"
  11185. //if his.Insutype == "390" {
  11186. // fed.MedType = "1402"
  11187. //} else {
  11188. // fed.MedType = "9933"
  11189. //}
  11190. var orders []*models.FsiOrderDtos
  11191. if trig_scen == "2" {
  11192. //处方医嘱信息
  11193. for _, item := range prescriptions {
  11194. for _, subItem := range item.HisDoctorAdviceInfo {
  11195. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11196. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11197. var order models.FsiOrderDtos
  11198. order.RxID = strconv.FormatInt(item.ID, 10)
  11199. order.Rxno = strconv.FormatInt(item.ID, 10)
  11200. order.LongDrordFlag = "0"
  11201. order.HilistType = "1"
  11202. order.ChrgType = "1"
  11203. order.DrordBhvr = "0"
  11204. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11205. order.HosplistName = subItem.BaseDrugLib.DrugName
  11206. order.HilistLv = "1"
  11207. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11208. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11209. order.HosplistName = subItem.BaseDrugLib.DrugName
  11210. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11211. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11212. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11213. order.OwnpayAmt = ""
  11214. order.SelfpayAmt = ""
  11215. order.Spec = spec
  11216. order.SpecUnt = subItem.PrescribingNumberUnit
  11217. order.DrordBegnDate = s_tm
  11218. order.DrordStopDate = ""
  11219. order.DrordDrCodg = doctor_info.DoctorNumber
  11220. order.DrordDeptName = department.Name
  11221. order.DrordDeptCodg = department.Number
  11222. order.DrordDrName = doctor_info.UserName
  11223. order.DrordDrProfttl = "234"
  11224. order.CurrDrordFlag = "1"
  11225. orders = append(orders, &order)
  11226. }
  11227. }
  11228. for _, subItem := range item.HisPrescriptionProject {
  11229. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11230. var order models.FsiOrderDtos
  11231. order.RxID = strconv.FormatInt(item.ID, 10)
  11232. order.Rxno = strconv.FormatInt(item.ID, 10)
  11233. order.LongDrordFlag = "0"
  11234. order.HilistType = "1"
  11235. order.ChrgType = "1"
  11236. order.DrordBhvr = "0"
  11237. order.HilistCode = subItem.HisProject.MedicalCode
  11238. order.HosplistName = subItem.HisProject.ProjectName
  11239. order.HilistLv = "1"
  11240. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11241. order.HosplistCode = subItem.HisProject.MedicalCode
  11242. order.HosplistName = subItem.HisProject.ProjectName
  11243. order.Cnt = subItem.Count
  11244. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11245. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11246. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11247. order.OwnpayAmt = ""
  11248. order.SelfpayAmt = ""
  11249. order.Spec = subItem.Unit
  11250. order.SpecUnt = subItem.Unit
  11251. order.DrordBegnDate = s_tm
  11252. order.DrordStopDate = ""
  11253. order.DrordDrCodg = doctor_info.DoctorNumber
  11254. order.DrordDeptName = department.Name
  11255. order.DrordDeptCodg = department.Number
  11256. order.DrordDrName = doctor_info.UserName
  11257. order.DrordDrProfttl = "234"
  11258. order.CurrDrordFlag = "1"
  11259. orders = append(orders, &order)
  11260. }
  11261. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11262. var order models.FsiOrderDtos
  11263. order.RxID = strconv.FormatInt(item.ID, 10)
  11264. order.Rxno = strconv.FormatInt(item.ID, 10)
  11265. order.LongDrordFlag = "0"
  11266. order.HilistType = "1"
  11267. order.ChrgType = "1"
  11268. order.DrordBhvr = "0"
  11269. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11270. order.HosplistName = subItem.GoodInfo.GoodName
  11271. order.HilistLv = "1"
  11272. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11273. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11274. order.HosplistName = subItem.GoodInfo.GoodName
  11275. order.Cnt = subItem.Count
  11276. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11277. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11278. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11279. order.OwnpayAmt = ""
  11280. order.SelfpayAmt = ""
  11281. order.Spec = subItem.GoodInfo.SpecificationName
  11282. order.SpecUnt = subItem.Unit
  11283. order.DrordBegnDate = s_tm
  11284. order.DrordStopDate = ""
  11285. order.DrordDrCodg = doctor_info.DoctorNumber
  11286. order.DrordDeptName = department.Name
  11287. order.DrordDeptCodg = department.Number
  11288. order.DrordDrName = doctor_info.UserName
  11289. order.DrordDrProfttl = "234"
  11290. order.CurrDrordFlag = "1"
  11291. orders = append(orders, &order)
  11292. }
  11293. }
  11294. }
  11295. //处方医嘱信息
  11296. }
  11297. fed.MatnStas = "0"
  11298. fed.MedfeeSumamt = "0"
  11299. fed.OwnpayAmt = "0"
  11300. fed.SelfpayAmt = "0"
  11301. fed.AcctPayamt = "0"
  11302. fed.MaAmt = "0"
  11303. fed.HifpPayamt = "0"
  11304. fed.SetlTotlnum = "1"
  11305. fed.Insutype = his.Insutype
  11306. fed.ReimFlag = "0"
  11307. fed.OutSetlFlag = "0"
  11308. var fopd []*models.FsiOperationDtosData
  11309. data := make(map[string]interface{})
  11310. data["fed"] = fed
  11311. data["fdd"] = fdds
  11312. data["fod"] = orders
  11313. data["pd"] = pd
  11314. data["pp"] = pp
  11315. data["fopd"] = fopd
  11316. data["trig_scen"] = trig_scen
  11317. fmt.Println(data)
  11318. fmt.Println(fed)
  11319. fmt.Println(fdds)
  11320. fmt.Println(orders)
  11321. fmt.Println(pd)
  11322. fmt.Println(pp)
  11323. fmt.Println(fopd)
  11324. client := &http.Client{}
  11325. bytesData, _ := json.Marshal(data)
  11326. var req *http.Request
  11327. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11328. if miConfig.MdtrtareaAdmvs == "320921" {
  11329. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11330. } else {
  11331. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11332. }
  11333. resp, _ := client.Do(req)
  11334. defer resp.Body.Close()
  11335. body, ioErr := ioutil.ReadAll(resp.Body)
  11336. if ioErr != nil {
  11337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11339. return res
  11340. }
  11341. var respJSON map[string]interface{}
  11342. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11345. return res
  11346. }
  11347. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11348. fmt.Println(respJSON)
  11349. result, _ := json.Marshal(respJSON)
  11350. fmt.Println(result)
  11351. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11352. utils.ErrorLog("解析失败:%v", err)
  11353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11354. return res
  11355. }
  11356. return res
  11357. } else {
  11358. //if miConfig.MdtrtareaAdmvs == "441202" {
  11359. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11360. saveLog(output, input, "3101", "事前")
  11361. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11362. utils.ErrorLog("解析失败:%v", err)
  11363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11364. return
  11365. }
  11366. return res
  11367. //}
  11368. }
  11369. }
  11370. 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) {
  11371. adminUser := c.GetAdminUserInfo()
  11372. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11373. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11374. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11375. //record_time := c.GetString("record_time")
  11376. //trig_scen := c.GetString("trig_scen")
  11377. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11378. timeLayout := "2006-01-02"
  11379. loc, _ := time.LoadLocation("Local")
  11380. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11381. if err != nil {
  11382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11383. return res
  11384. }
  11385. recordDateTime := theTime.Unix()
  11386. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11387. var patientPrescription models.HisPrescriptionInfo
  11388. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11389. if patientPrescription.ID == 0 {
  11390. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11391. }
  11392. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11393. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11394. //
  11395. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11396. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11397. var pp models.PublicParams
  11398. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11399. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11400. pp.FixmedinsName = miConfig.OrgName
  11401. pp.FixmedinsCode = miConfig.Code
  11402. pp.RequestUrl = miConfig.Url
  11403. pp.Cainfo = miConfig.Cainfo
  11404. pp.SecretKey = miConfig.SecretKey
  11405. pp.AccessKey = miConfig.AccessKey
  11406. pp.OpterName = roles.UserName
  11407. var config []*models.HisXtDiagnoseConfig
  11408. for _, item := range diagnosis_ids {
  11409. id, _ := strconv.ParseInt(item, 10, 64)
  11410. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11411. config = append(config, &diagnosisConfig)
  11412. }
  11413. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11414. var pd models.PatientDtos
  11415. pd.PatnID = his.PsnNo
  11416. pd.PatnName = his.Name
  11417. pd.Gend = his.Gend
  11418. pd.Brdy = str
  11419. pd.Poolarea = his.InsuplcAdmdvs
  11420. pd.CurrMdtrtID = his.Number
  11421. var fed models.FsiEncounterDtos
  11422. fed.MdtrtID = his.Number
  11423. fed.MedinsID = miConfig.Code
  11424. fed.MedinsName = miConfig.OrgName
  11425. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11426. fed.MedMdtrtType = "1"
  11427. fed.MedinsType = "1"
  11428. fed.MedinsLv = "11"
  11429. tm := time.Unix(his.RecordDate, 0)
  11430. s_tm := tm.Format("2006-01-02 15:04:05")
  11431. fed.AdmDate = s_tm
  11432. fed.DscgDate = s_tm
  11433. fed.DscgMainDiseCodg = config[0].CountryCode
  11434. fed.DscgMainDiseName = config[0].CountryContentName
  11435. //诊断信息
  11436. var fdds []*models.FsiDiagnoseDtos
  11437. for index, item := range config {
  11438. if index == 0 {
  11439. var fdd models.FsiDiagnoseDtos
  11440. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11441. fdd.InoutDiseType = "1"
  11442. fdd.MaindiseFlag = "1"
  11443. fdd.DiseDate = s_tm
  11444. fdd.DiasSrtNo = "1"
  11445. fdd.DiseName = item.CountryContentName
  11446. fdd.DiseCodg = item.CountryCode
  11447. fdds = append(fdds, &fdd)
  11448. } else {
  11449. var fdd models.FsiDiagnoseDtos
  11450. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11451. fdd.InoutDiseType = "1"
  11452. fdd.MaindiseFlag = "1"
  11453. fdd.DiseDate = s_tm
  11454. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11455. fdd.DiseName = item.CountryContentName
  11456. fdd.DiseCodg = item.CountryCode
  11457. fdds = append(fdds, &fdd)
  11458. }
  11459. }
  11460. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11461. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11462. fed.AdmDeptName = department.Name
  11463. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11464. fed.DscgDeptName = department.Name
  11465. fed.MedMdtrtType = "1"
  11466. fed.MedType = "11"
  11467. //if his.Insutype == "390" {
  11468. // fed.MedType = "1402"
  11469. //} else {
  11470. // fed.MedType = "9933"
  11471. //}
  11472. var orders []*models.FsiOrderDtos
  11473. if trig_scen == "2" {
  11474. //处方医嘱信息
  11475. for _, item := range prescriptions {
  11476. for _, subItem := range item.HisDoctorAdviceInfo {
  11477. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11478. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11479. var order models.FsiOrderDtos
  11480. order.RxID = strconv.FormatInt(item.ID, 10)
  11481. order.Rxno = strconv.FormatInt(item.ID, 10)
  11482. order.LongDrordFlag = "0"
  11483. order.HilistType = "1"
  11484. order.ChrgType = "1"
  11485. order.DrordBhvr = "0"
  11486. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11487. order.HosplistName = subItem.BaseDrugLib.DrugName
  11488. order.HilistLv = "1"
  11489. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11490. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11491. order.HosplistName = subItem.BaseDrugLib.DrugName
  11492. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11493. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11494. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11495. order.OwnpayAmt = ""
  11496. order.SelfpayAmt = ""
  11497. order.Spec = spec
  11498. order.SpecUnt = subItem.PrescribingNumberUnit
  11499. order.DrordBegnDate = s_tm
  11500. order.DrordStopDate = ""
  11501. order.DrordDrCodg = doctor_info.DoctorNumber
  11502. order.DrordDeptName = department.Name
  11503. order.DrordDeptCodg = department.Number
  11504. order.DrordDrName = doctor_info.UserName
  11505. order.DrordDrProfttl = "234"
  11506. order.CurrDrordFlag = "1"
  11507. orders = append(orders, &order)
  11508. }
  11509. }
  11510. for _, subItem := range item.HisPrescriptionProject {
  11511. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11512. var order models.FsiOrderDtos
  11513. order.RxID = strconv.FormatInt(item.ID, 10)
  11514. order.Rxno = strconv.FormatInt(item.ID, 10)
  11515. order.LongDrordFlag = "0"
  11516. order.HilistType = "1"
  11517. order.ChrgType = "1"
  11518. order.DrordBhvr = "0"
  11519. order.HilistCode = subItem.HisProject.MedicalCode
  11520. order.HosplistName = subItem.HisProject.ProjectName
  11521. order.HilistLv = "1"
  11522. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11523. order.HosplistCode = subItem.HisProject.MedicalCode
  11524. order.HosplistName = subItem.HisProject.ProjectName
  11525. order.Cnt = subItem.Count
  11526. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11527. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11528. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11529. order.OwnpayAmt = ""
  11530. order.SelfpayAmt = ""
  11531. order.Spec = subItem.Unit
  11532. order.SpecUnt = subItem.Unit
  11533. order.DrordBegnDate = s_tm
  11534. order.DrordStopDate = ""
  11535. order.DrordDrCodg = doctor_info.DoctorNumber
  11536. order.DrordDeptName = department.Name
  11537. order.DrordDeptCodg = department.Number
  11538. order.DrordDrName = doctor_info.UserName
  11539. order.DrordDrProfttl = "234"
  11540. order.CurrDrordFlag = "1"
  11541. orders = append(orders, &order)
  11542. }
  11543. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11544. var order models.FsiOrderDtos
  11545. order.RxID = strconv.FormatInt(item.ID, 10)
  11546. order.Rxno = strconv.FormatInt(item.ID, 10)
  11547. order.LongDrordFlag = "0"
  11548. order.HilistType = "1"
  11549. order.ChrgType = "1"
  11550. order.DrordBhvr = "0"
  11551. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11552. order.HosplistName = subItem.GoodInfo.GoodName
  11553. order.HilistLv = "1"
  11554. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11555. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11556. order.HosplistName = subItem.GoodInfo.GoodName
  11557. order.Cnt = subItem.Count
  11558. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11559. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11560. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11561. order.OwnpayAmt = ""
  11562. order.SelfpayAmt = ""
  11563. order.Spec = subItem.GoodInfo.SpecificationName
  11564. order.SpecUnt = subItem.Unit
  11565. order.DrordBegnDate = s_tm
  11566. order.DrordStopDate = ""
  11567. order.DrordDrCodg = doctor_info.DoctorNumber
  11568. order.DrordDeptName = department.Name
  11569. order.DrordDeptCodg = department.Number
  11570. order.DrordDrName = doctor_info.UserName
  11571. order.DrordDrProfttl = "234"
  11572. order.CurrDrordFlag = "1"
  11573. orders = append(orders, &order)
  11574. }
  11575. }
  11576. }
  11577. //处方医嘱信息
  11578. }
  11579. fed.MatnStas = "0"
  11580. fed.MedfeeSumamt = "0"
  11581. fed.OwnpayAmt = "0"
  11582. fed.SelfpayAmt = "0"
  11583. fed.AcctPayamt = "0"
  11584. fed.MaAmt = "0"
  11585. fed.HifpPayamt = "0"
  11586. fed.SetlTotlnum = "1"
  11587. fed.Insutype = his.Insutype
  11588. fed.ReimFlag = "0"
  11589. fed.OutSetlFlag = "0"
  11590. var fopd []*models.FsiOperationDtosData
  11591. data := make(map[string]interface{})
  11592. data["fed"] = fed
  11593. data["fdd"] = fdds
  11594. data["fod"] = orders
  11595. data["pd"] = pd
  11596. data["pp"] = pp
  11597. data["fopd"] = fopd
  11598. data["trig_scen"] = trig_scen
  11599. fmt.Println(data)
  11600. fmt.Println(fed)
  11601. fmt.Println(fdds)
  11602. fmt.Println(orders)
  11603. fmt.Println(pd)
  11604. fmt.Println(pp)
  11605. fmt.Println(fopd)
  11606. client := &http.Client{}
  11607. bytesData, _ := json.Marshal(data)
  11608. var req *http.Request
  11609. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11610. if miConfig.MdtrtareaAdmvs == "320921" {
  11611. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11612. } else {
  11613. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11614. }
  11615. resp, _ := client.Do(req)
  11616. defer resp.Body.Close()
  11617. body, ioErr := ioutil.ReadAll(resp.Body)
  11618. if ioErr != nil {
  11619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11621. return res
  11622. }
  11623. var respJSON map[string]interface{}
  11624. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11627. return res
  11628. }
  11629. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11630. fmt.Println(respJSON)
  11631. result, _ := json.Marshal(respJSON)
  11632. fmt.Println(result)
  11633. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11634. utils.ErrorLog("解析失败:%v", err)
  11635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11636. return res
  11637. }
  11638. return res
  11639. } else {
  11640. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11641. saveLog(output, input, "3101", "事前")
  11642. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11643. utils.ErrorLog("解析失败:%v", err)
  11644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11645. return
  11646. }
  11647. return res
  11648. }
  11649. return res
  11650. }
  11651. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11652. ////patient_id, _ := c.GetInt64("patient_id")
  11653. //order_id, _ := c.GetInt64("order_id")
  11654. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11655. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11656. //trig_scen := c.GetString("trig_scen")
  11657. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11658. //utils.ErrorLog("解析失败:%v", psn_info)
  11659. adminUser := c.GetAdminUserInfo()
  11660. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11661. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11662. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11663. record_time := c.GetString("record_time")
  11664. order, _ := service.GetHisOrderByID(order_id)
  11665. timeLayout := "2006-01-02"
  11666. loc, _ := time.LoadLocation("Local")
  11667. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11668. if err != nil {
  11669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11670. return
  11671. }
  11672. recordDateTime := theTime.Unix()
  11673. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11674. var patientPrescription models.HisPrescriptionInfo
  11675. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11676. if patientPrescription.ID == 0 {
  11677. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11678. }
  11679. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11680. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11681. //
  11682. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11683. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11684. var pp models.PublicParams
  11685. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11686. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11687. pp.FixmedinsName = miConfig.OrgName
  11688. pp.FixmedinsCode = miConfig.Code
  11689. pp.RequestUrl = miConfig.Url
  11690. pp.Cainfo = miConfig.Cainfo
  11691. pp.SecretKey = miConfig.SecretKey
  11692. pp.AccessKey = miConfig.AccessKey
  11693. pp.OpterName = roles.UserName
  11694. var config []*models.HisXtDiagnoseConfig
  11695. for _, item := range diagnosis_ids {
  11696. id, _ := strconv.ParseInt(item, 10, 64)
  11697. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11698. config = append(config, &diagnosisConfig)
  11699. }
  11700. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11701. var pd models.PatientDtos
  11702. pd.PatnID = his.PsnNo
  11703. pd.PatnName = his.Name
  11704. pd.Gend = his.Gend
  11705. pd.Brdy = str
  11706. pd.Poolarea = his.InsuplcAdmdvs
  11707. pd.CurrMdtrtID = his.Number
  11708. var fed models.FsiEncounterDtos
  11709. fed.MdtrtID = his.Number
  11710. fed.MedinsID = miConfig.Code
  11711. fed.MedinsName = miConfig.OrgName
  11712. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11713. fed.MedMdtrtType = "1"
  11714. fed.MedinsType = "1"
  11715. fed.MedinsLv = "11"
  11716. tm := time.Unix(his.RecordDate, 0)
  11717. s_tm := tm.Format("2006-01-02 15:04:05")
  11718. fed.AdmDate = s_tm
  11719. fed.DscgDate = s_tm
  11720. fed.DscgMainDiseCodg = config[0].CountryCode
  11721. fed.DscgMainDiseName = config[0].CountryContentName
  11722. //诊断信息
  11723. var fdds []*models.FsiDiagnoseDtos
  11724. for index, item := range config {
  11725. if index == 0 {
  11726. var fdd models.FsiDiagnoseDtos
  11727. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11728. fdd.InoutDiseType = "1"
  11729. fdd.MaindiseFlag = "1"
  11730. fdd.DiseDate = s_tm
  11731. fdd.DiasSrtNo = "1"
  11732. fdd.DiseName = item.CountryContentName
  11733. fdd.DiseCodg = item.CountryCode
  11734. fdds = append(fdds, &fdd)
  11735. } else {
  11736. var fdd models.FsiDiagnoseDtos
  11737. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11738. fdd.InoutDiseType = "1"
  11739. fdd.MaindiseFlag = "1"
  11740. fdd.DiseDate = s_tm
  11741. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11742. fdd.DiseName = item.CountryContentName
  11743. fdd.DiseCodg = item.CountryCode
  11744. fdds = append(fdds, &fdd)
  11745. }
  11746. }
  11747. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11748. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11749. fed.AdmDeptName = department.Name
  11750. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11751. fed.DscgDeptName = department.Name
  11752. fed.MedType = order.MedType
  11753. //处方医嘱信息
  11754. var orders []*models.FsiOrderDtos
  11755. //for _, item := range prescriptions {
  11756. // for _, subItem := range item.HisDoctorAdviceInfo {
  11757. // var order models.FsiOrderDtos
  11758. // order.RxID = strconv.FormatInt(item.ID, 10)
  11759. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11760. // order.LongDrordFlag = "0"
  11761. // order.HilistType = "1"
  11762. // order.ChrgType = "1"
  11763. // order.DrordBhvr = "-"
  11764. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11765. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11766. // order.HilistLv = "1"
  11767. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11768. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11769. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11770. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11771. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11772. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11773. // order.OwnpayAmt = ""
  11774. // order.SelfpayAmt = ""
  11775. // order.Spec = ""
  11776. // order.SpecUnt = ""
  11777. // order.DrordBegnDate = s_tm
  11778. // order.DrordStopDate = ""
  11779. // order.DrordDrCodg = "1"
  11780. // order.DrordDeptName = department.Name
  11781. // order.DrordDrCodg = "1"
  11782. // order.DrordDrName = doctor_info.UserName
  11783. // order.DrordDrProfttl = ""
  11784. // order.CurrDrordFlag = "1"
  11785. // orders = append(orders, &order)
  11786. // }
  11787. // for _, subItem := range item.HisPrescriptionProject {
  11788. // if subItem.Type == 2 {
  11789. // var order models.FsiOrderDtos
  11790. // order.RxID = strconv.FormatInt(item.ID, 10)
  11791. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11792. // order.LongDrordFlag = "0"
  11793. // order.HilistType = "1"
  11794. // order.ChrgType = "1"
  11795. // order.DrordBhvr = "-"
  11796. // order.HilistCode = subItem.HisProject.MedicalCode
  11797. // order.HosplistName = subItem.HisProject.ProjectName
  11798. // order.HilistLv = "1"
  11799. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11800. // order.HosplistCode = subItem.HisProject.MedicalCode
  11801. // order.HosplistName = subItem.HisProject.ProjectName
  11802. // order.Cnt = subItem.Count
  11803. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11804. //
  11805. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11806. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11807. // order.OwnpayAmt = ""
  11808. // order.SelfpayAmt = ""
  11809. // order.Spec = ""
  11810. // order.SpecUnt = ""
  11811. // order.DrordBegnDate = s_tm
  11812. // order.DrordStopDate = ""
  11813. // order.DrordDrCodg = "1"
  11814. // order.DrordDeptName = department.Name
  11815. // order.DrordDrCodg = "1"
  11816. // order.DrordDrName = doctor_info.UserName
  11817. // order.DrordDrProfttl = ""
  11818. // order.CurrDrordFlag = "1"
  11819. // orders = append(orders, &order)
  11820. //
  11821. // }
  11822. // if subItem.Type == 3 {
  11823. //
  11824. // var order models.FsiOrderDtos
  11825. // order.RxID = strconv.FormatInt(item.ID, 10)
  11826. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11827. // order.LongDrordFlag = "0"
  11828. // order.HilistType = "1"
  11829. // order.ChrgType = "1"
  11830. // order.DrordBhvr = "-"
  11831. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11832. // order.HosplistName = subItem.GoodInfo.GoodName
  11833. // order.HilistLv = "1"
  11834. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11835. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11836. // order.HosplistName = subItem.GoodInfo.GoodName
  11837. // order.Cnt = subItem.Count
  11838. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11839. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11840. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11841. // order.OwnpayAmt = ""
  11842. // order.SelfpayAmt = ""
  11843. // order.Spec = ""
  11844. // order.SpecUnt = ""
  11845. // order.DrordBegnDate = s_tm
  11846. // order.DrordStopDate = ""
  11847. // order.DrordDrCodg = "1"
  11848. // order.DrordDeptName = department.Name
  11849. // order.DrordDrCodg = "1"
  11850. // order.DrordDrName = doctor_info.UserName
  11851. // order.DrordDrProfttl = ""
  11852. // order.CurrDrordFlag = "1"
  11853. // orders = append(orders, &order)
  11854. //
  11855. // }
  11856. // }
  11857. //}
  11858. for _, item := range prescriptions {
  11859. for _, subItem := range item.HisDoctorAdviceInfo {
  11860. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11861. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11862. var order models.FsiOrderDtos
  11863. order.RxID = strconv.FormatInt(item.ID, 10)
  11864. order.Rxno = strconv.FormatInt(item.ID, 10)
  11865. order.LongDrordFlag = "0"
  11866. order.HilistType = "1"
  11867. order.ChrgType = "1"
  11868. order.DrordBhvr = "0"
  11869. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11870. order.HosplistName = subItem.BaseDrugLib.DrugName
  11871. order.HilistLv = "1"
  11872. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11873. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11874. order.HosplistName = subItem.BaseDrugLib.DrugName
  11875. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11876. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11877. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11878. order.OwnpayAmt = ""
  11879. order.SelfpayAmt = ""
  11880. order.Spec = spec
  11881. order.SpecUnt = subItem.PrescribingNumberUnit
  11882. order.DrordBegnDate = s_tm
  11883. order.DrordStopDate = ""
  11884. order.DrordDrCodg = doctor_info.DoctorNumber
  11885. order.DrordDeptName = department.Name
  11886. order.DrordDeptCodg = department.Number
  11887. order.DrordDrName = doctor_info.UserName
  11888. order.DrordDrProfttl = "234"
  11889. order.CurrDrordFlag = "1"
  11890. orders = append(orders, &order)
  11891. }
  11892. }
  11893. for _, subItem := range item.HisPrescriptionProject {
  11894. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11895. var order models.FsiOrderDtos
  11896. order.RxID = strconv.FormatInt(item.ID, 10)
  11897. order.Rxno = strconv.FormatInt(item.ID, 10)
  11898. order.LongDrordFlag = "0"
  11899. order.HilistType = "1"
  11900. order.ChrgType = "1"
  11901. order.DrordBhvr = "0"
  11902. order.HilistCode = subItem.HisProject.MedicalCode
  11903. order.HosplistName = subItem.HisProject.ProjectName
  11904. order.HilistLv = "1"
  11905. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11906. order.HosplistCode = subItem.HisProject.MedicalCode
  11907. order.HosplistName = subItem.HisProject.ProjectName
  11908. order.Cnt = subItem.Count
  11909. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11910. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11911. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11912. order.OwnpayAmt = ""
  11913. order.SelfpayAmt = ""
  11914. order.Spec = subItem.Unit
  11915. order.SpecUnt = subItem.Unit
  11916. order.DrordBegnDate = s_tm
  11917. order.DrordStopDate = ""
  11918. order.DrordDrCodg = doctor_info.DoctorNumber
  11919. order.DrordDeptName = department.Name
  11920. order.DrordDeptCodg = department.Number
  11921. order.DrordDrName = doctor_info.UserName
  11922. order.DrordDrProfttl = "234"
  11923. order.CurrDrordFlag = "1"
  11924. orders = append(orders, &order)
  11925. }
  11926. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11927. var order models.FsiOrderDtos
  11928. order.RxID = strconv.FormatInt(item.ID, 10)
  11929. order.Rxno = strconv.FormatInt(item.ID, 10)
  11930. order.LongDrordFlag = "0"
  11931. order.HilistType = "1"
  11932. order.ChrgType = "1"
  11933. order.DrordBhvr = "0"
  11934. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11935. order.HosplistName = subItem.GoodInfo.GoodName
  11936. order.HilistLv = "1"
  11937. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11938. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11939. order.HosplistName = subItem.GoodInfo.GoodName
  11940. order.Cnt = subItem.Count
  11941. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11942. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11943. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11944. order.OwnpayAmt = ""
  11945. order.SelfpayAmt = ""
  11946. order.Spec = subItem.GoodInfo.SpecificationName
  11947. order.SpecUnt = subItem.Unit
  11948. order.DrordBegnDate = s_tm
  11949. order.DrordStopDate = ""
  11950. order.DrordDrCodg = doctor_info.DoctorNumber
  11951. order.DrordDeptName = department.Name
  11952. order.DrordDeptCodg = department.Number
  11953. order.DrordDrName = doctor_info.UserName
  11954. order.DrordDrProfttl = "234"
  11955. order.CurrDrordFlag = "1"
  11956. orders = append(orders, &order)
  11957. }
  11958. }
  11959. }
  11960. //处方医嘱信息
  11961. fed.MatnStas = "0"
  11962. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11963. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11964. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11965. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11966. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11967. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11968. fed.SetlTotlnum = "1"
  11969. fed.Insutype = his.Insutype
  11970. fed.ReimFlag = "0"
  11971. fed.OutSetlFlag = "0"
  11972. var fopd []*models.FsiOperationDtosData
  11973. data := make(map[string]interface{})
  11974. data["fed"] = fed
  11975. data["fdd"] = fdds
  11976. data["fod"] = orders
  11977. data["pd"] = pd
  11978. data["pp"] = pp
  11979. data["fopd"] = fopd
  11980. data["trig_scen"] = trig_scen
  11981. client := &http.Client{}
  11982. bytesData, _ := json.Marshal(data)
  11983. var req *http.Request
  11984. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11985. if miConfig.MdtrtareaAdmvs == "320921" {
  11986. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11987. } else {
  11988. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11989. }
  11990. resp, _ := client.Do(req)
  11991. defer resp.Body.Close()
  11992. body, ioErr := ioutil.ReadAll(resp.Body)
  11993. if ioErr != nil {
  11994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11996. return res
  11997. }
  11998. var respJSON map[string]interface{}
  11999. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12002. return res
  12003. }
  12004. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12005. result, _ := json.Marshal(respJSON)
  12006. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12007. utils.ErrorLog("解析失败:%v", err)
  12008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12009. return res
  12010. }
  12011. return res
  12012. } else {
  12013. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12014. saveLog(output, input, "3102", "事中")
  12015. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12016. utils.ErrorLog("解析失败:%v", err)
  12017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12018. return
  12019. }
  12020. return res
  12021. }
  12022. return res
  12023. }
  12024. func (c *HisApiController) Check() {
  12025. psn_no := c.GetString("psn_no")
  12026. in := c.GetString("in")
  12027. mt := c.GetString("mt")
  12028. baseParams := models.BaseParams{
  12029. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12030. FixmedinsCode: "H15049901371",
  12031. InsuplcAdmdvs: "150499",
  12032. MdtrtareaAdmvs: "150499",
  12033. OrgName: "赤峰费森血液透析中心",
  12034. Doctor: "1111",
  12035. }
  12036. service.Gdyb2001(baseParams, psn_no, in, mt)
  12037. }
  12038. func (c *HisApiController) GetPsnNcdsInfo() {
  12039. admin_user_id, _ := c.GetInt64("admin_user_id")
  12040. patient_id, _ := c.GetInt64("patient_id")
  12041. //id, _ := c.GetInt64("id")
  12042. adminUser := c.GetAdminUserInfo()
  12043. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12044. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12045. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12046. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12047. //psn_record, _ := service.GetP(id)
  12048. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12049. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12050. //
  12051. //if psn_record.ID == 0 {
  12052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12053. // return
  12054. //}
  12055. var res Result5301
  12056. var res10265 Result5301For10265
  12057. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12058. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12059. var api string
  12060. if miConfig.MdtrtareaAdmvs == "320921" {
  12061. 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 +
  12062. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12063. } else {
  12064. 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 +
  12065. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12066. }
  12067. resp, requestErr := http.Get(api)
  12068. if requestErr != nil {
  12069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12070. return
  12071. }
  12072. body, ioErr := ioutil.ReadAll(resp.Body)
  12073. if ioErr != nil {
  12074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12076. return
  12077. }
  12078. var respJSON map[string]interface{}
  12079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12082. return
  12083. }
  12084. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12085. result, _ := json.Marshal(respJSON)
  12086. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12087. utils.ErrorLog("解析失败:%v", err)
  12088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12089. return
  12090. }
  12091. res.ErrMsg = res10265.ErrMsg
  12092. res.Output = res10265.Output
  12093. res.InfRefmsgid = res10265.InfRefmsgid
  12094. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12095. res.Infcode = infocode
  12096. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12097. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12098. var api string
  12099. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12100. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12101. resp, requestErr := http.Get(api)
  12102. if requestErr != nil {
  12103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12104. return
  12105. }
  12106. body, ioErr := ioutil.ReadAll(resp.Body)
  12107. if ioErr != nil {
  12108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12110. return
  12111. }
  12112. var respJSON map[string]interface{}
  12113. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12116. return
  12117. }
  12118. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12119. if status == "0" {
  12120. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12121. c.ServeSuccessJSON(map[string]interface{}{
  12122. "failed_code": -10,
  12123. "msg": err_msg,
  12124. })
  12125. return
  12126. }
  12127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12128. result, _ := json.Marshal(respJSON)
  12129. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12130. utils.ErrorLog("解析失败:%v", err)
  12131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12132. return
  12133. }
  12134. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12135. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12136. var api string
  12137. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12138. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12139. resp, requestErr := http.Get(api)
  12140. if requestErr != nil {
  12141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12142. return
  12143. }
  12144. body, ioErr := ioutil.ReadAll(resp.Body)
  12145. if ioErr != nil {
  12146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12148. return
  12149. }
  12150. var respJSON map[string]interface{}
  12151. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12154. return
  12155. }
  12156. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12157. if status == "0" {
  12158. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12159. c.ServeSuccessJSON(map[string]interface{}{
  12160. "failed_code": -10,
  12161. "msg": err_msg,
  12162. })
  12163. return
  12164. }
  12165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12166. result, _ := json.Marshal(respJSON)
  12167. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12168. utils.ErrorLog("解析失败:%v", err)
  12169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12170. return
  12171. }
  12172. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12173. p, _ := service.GetHisPatientById(patient_id)
  12174. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12175. var dat map[string]interface{}
  12176. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12177. fmt.Println(dat)
  12178. } else {
  12179. fmt.Println(err)
  12180. }
  12181. userJSONBytes, _ := json.Marshal(dat)
  12182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12183. utils.ErrorLog("解析失败:%v", err)
  12184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12185. return
  12186. }
  12187. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12188. p, _ := service.GetHisPatientById(patient_id)
  12189. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12190. var dat map[string]interface{}
  12191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12192. fmt.Println(dat)
  12193. } else {
  12194. fmt.Println(err)
  12195. }
  12196. userJSONBytes, _ := json.Marshal(dat)
  12197. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12198. utils.ErrorLog("解析失败:%v", err)
  12199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12200. return
  12201. }
  12202. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12203. p, _ := service.GetHisPatientById(patient_id)
  12204. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12205. var dat map[string]interface{}
  12206. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12207. fmt.Println(dat)
  12208. } else {
  12209. fmt.Println(err)
  12210. }
  12211. userJSONBytes, _ := json.Marshal(dat)
  12212. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12213. utils.ErrorLog("解析失败:%v", err)
  12214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12215. return
  12216. }
  12217. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12218. p, _ := service.GetHisPatientById(patient_id)
  12219. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12220. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12221. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12222. resp, requestErr := http.Get(api)
  12223. if requestErr != nil {
  12224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12225. return
  12226. }
  12227. body, ioErr := ioutil.ReadAll(resp.Body)
  12228. if ioErr != nil {
  12229. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12231. return
  12232. }
  12233. var respJSON map[string]interface{}
  12234. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12237. return
  12238. }
  12239. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12240. result, _ := json.Marshal(respJSON)
  12241. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12242. utils.ErrorLog("解析失败:%v", err)
  12243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12244. return
  12245. }
  12246. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12247. p, _ := service.GetHisPatientById(patient_id)
  12248. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12249. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12250. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12251. resp, requestErr := http.Get(api)
  12252. if requestErr != nil {
  12253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12254. return
  12255. }
  12256. body, ioErr := ioutil.ReadAll(resp.Body)
  12257. if ioErr != nil {
  12258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12260. return
  12261. }
  12262. var respJSON map[string]interface{}
  12263. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12266. return
  12267. }
  12268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12269. result, _ := json.Marshal(respJSON)
  12270. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12271. utils.ErrorLog("解析失败:%v", err)
  12272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12273. return
  12274. }
  12275. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12276. p, _ := service.GetHisPatientById(patient_id)
  12277. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12278. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12279. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12280. resp, requestErr := http.Get(api)
  12281. if requestErr != nil {
  12282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12283. return
  12284. }
  12285. body, ioErr := ioutil.ReadAll(resp.Body)
  12286. if ioErr != nil {
  12287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12289. return
  12290. }
  12291. var respJSON map[string]interface{}
  12292. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12295. return
  12296. }
  12297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12298. result, _ := json.Marshal(respJSON)
  12299. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12300. utils.ErrorLog("解析失败:%v", err)
  12301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12302. return
  12303. }
  12304. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12305. p, _ := service.GetHisPatientById(patient_id)
  12306. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12307. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12308. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12309. resp, requestErr := http.Get(api)
  12310. if requestErr != nil {
  12311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12312. return
  12313. }
  12314. body, ioErr := ioutil.ReadAll(resp.Body)
  12315. if ioErr != nil {
  12316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12318. return
  12319. }
  12320. var respJSON map[string]interface{}
  12321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12324. return
  12325. }
  12326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12327. result, _ := json.Marshal(respJSON)
  12328. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12329. utils.ErrorLog("解析失败:%v", err)
  12330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12331. return
  12332. }
  12333. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12334. p, _ := service.GetHisPatientById(patient_id)
  12335. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12336. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12337. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12338. resp, requestErr := http.Get(api)
  12339. if requestErr != nil {
  12340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12341. return
  12342. }
  12343. body, ioErr := ioutil.ReadAll(resp.Body)
  12344. if ioErr != nil {
  12345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12347. return
  12348. }
  12349. var respJSON map[string]interface{}
  12350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12353. return
  12354. }
  12355. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12356. result, _ := json.Marshal(respJSON)
  12357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12358. utils.ErrorLog("解析失败:%v", err)
  12359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12360. return
  12361. }
  12362. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12363. p, _ := service.GetHisPatientById(patient_id)
  12364. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12365. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12366. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12367. resp, requestErr := http.Get(api)
  12368. if requestErr != nil {
  12369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12370. return
  12371. }
  12372. body, ioErr := ioutil.ReadAll(resp.Body)
  12373. if ioErr != nil {
  12374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. return
  12377. }
  12378. var respJSON map[string]interface{}
  12379. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12382. return
  12383. }
  12384. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12385. result, _ := json.Marshal(respJSON)
  12386. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12387. utils.ErrorLog("解析失败:%v", err)
  12388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12389. return
  12390. }
  12391. } else {
  12392. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12393. var dat map[string]interface{}
  12394. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12395. fmt.Println(dat)
  12396. } else {
  12397. fmt.Println(err)
  12398. }
  12399. userJSONBytes, _ := json.Marshal(dat)
  12400. if miConfig.Code == "H15049901371" {
  12401. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12402. utils.ErrorLog("解析失败:%v", err)
  12403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12404. return
  12405. }
  12406. res.InfRefmsgid = res10265.InfRefmsgid
  12407. res.Output = res10265.Output
  12408. res.ErrMsg = res10265.ErrMsg
  12409. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12410. res.Infcode = infocode
  12411. } else {
  12412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12413. utils.ErrorLog("解析失败:%v", err)
  12414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12415. return
  12416. }
  12417. }
  12418. }
  12419. if res.Infcode == 0 {
  12420. c.ServeSuccessJSON(map[string]interface{}{
  12421. "result": res.Output.Result,
  12422. })
  12423. }
  12424. }
  12425. func (c *HisApiController) CheckInsutype() {
  12426. his_patient_id, _ := c.GetInt64("his_patient_id")
  12427. admin_user_id, _ := c.GetInt64("admin_user_id")
  12428. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12429. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12430. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12431. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12432. var dat map[string]interface{}
  12433. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12434. fmt.Println(dat)
  12435. } else {
  12436. fmt.Println(err)
  12437. }
  12438. userJSONBytes, _ := json.Marshal(dat)
  12439. var res Result90100
  12440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12441. utils.ErrorLog("解析失败:%v", err)
  12442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12443. return
  12444. }
  12445. if res.Infcode != 0 {
  12446. c.ServeSuccessJSON(map[string]interface{}{
  12447. "failed_code": -10,
  12448. "msg": res.ErrMsg,
  12449. })
  12450. return
  12451. } else {
  12452. fmt.Println(res)
  12453. }
  12454. }
  12455. func (c *HisApiController) CheckCardPWD() {
  12456. card_pwd := c.GetString("card_pwd")
  12457. his_patient_id, _ := c.GetInt64("his_patient_id")
  12458. admin_user_id, _ := c.GetInt64("admin_user_id")
  12459. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12460. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12461. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12462. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12463. bas := strings.Split(psn.CardInfo, "|")
  12464. basNumber := bas[2]
  12465. if psn.InsuplcAdmdvs[:4] == "4403" {
  12466. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12467. var dat map[string]interface{}
  12468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12469. fmt.Println(dat)
  12470. } else {
  12471. fmt.Println(err)
  12472. }
  12473. userJSONBytes, _ := json.Marshal(dat)
  12474. var res Result90991
  12475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12476. utils.ErrorLog("解析失败:%v", err)
  12477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12478. return
  12479. }
  12480. if res.Infcode != 0 {
  12481. c.ServeSuccessJSON(map[string]interface{}{
  12482. "failed_code": -10,
  12483. "msg": res.ErrMsg,
  12484. })
  12485. return
  12486. } else {
  12487. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12488. var msg string
  12489. switch res.Output.Result.CardStat {
  12490. case "00":
  12491. msg = "未激活"
  12492. break
  12493. case "10":
  12494. msg = "激活"
  12495. break
  12496. case "20":
  12497. msg = "窗口挂失"
  12498. break
  12499. case "21":
  12500. msg = "电话挂失"
  12501. break
  12502. case "22":
  12503. msg = "单位网上申报挂失"
  12504. break
  12505. case "23":
  12506. msg = "保健办挂失"
  12507. break
  12508. case "24":
  12509. msg = "个人网上挂失"
  12510. break
  12511. case "25":
  12512. msg = "网上服务大厅挂失"
  12513. break
  12514. case "30":
  12515. msg = "注销"
  12516. break
  12517. case "40":
  12518. msg = "回收"
  12519. break
  12520. case "99":
  12521. msg = "制卡中(无效卡)"
  12522. break
  12523. }
  12524. c.ServeSuccessJSON(map[string]interface{}{
  12525. "failed_code": -10,
  12526. "msg": msg,
  12527. })
  12528. return
  12529. } else {
  12530. c.ServeSuccessJSON(map[string]interface{}{
  12531. "msg": "校验成功",
  12532. })
  12533. return
  12534. }
  12535. }
  12536. } else {
  12537. c.ServeSuccessJSON(map[string]interface{}{
  12538. "msg": "校验成功",
  12539. })
  12540. return
  12541. }
  12542. }
  12543. func (c *HisApiController) CheckCardPWDTwo() {
  12544. //card_pwd := c.GetString("card_pwd")
  12545. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12546. admin_user_id, _ := c.GetInt64("admin_user_id")
  12547. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12548. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12549. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12550. var dat map[string]interface{}
  12551. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12552. fmt.Println(dat)
  12553. } else {
  12554. fmt.Println(err)
  12555. }
  12556. userJSONBytes, _ := json.Marshal(dat)
  12557. var res Result90991
  12558. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12559. utils.ErrorLog("解析失败:%v", err)
  12560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12561. return
  12562. }
  12563. if res.Infcode != 0 {
  12564. c.ServeSuccessJSON(map[string]interface{}{
  12565. "failed_code": -10,
  12566. "msg": res.ErrMsg,
  12567. })
  12568. return
  12569. } else {
  12570. if res.Output.Result.SscnoCheckStat == "0" {
  12571. var msg string
  12572. switch res.Output.Result.CardStat {
  12573. case "00":
  12574. msg = "未激活"
  12575. break
  12576. case "10":
  12577. msg = "激活"
  12578. break
  12579. case "20":
  12580. msg = "窗口挂失"
  12581. break
  12582. case "21":
  12583. msg = "电话挂失"
  12584. break
  12585. case "22":
  12586. msg = "单位网上申报挂失"
  12587. break
  12588. case "23":
  12589. msg = "保健办挂失"
  12590. break
  12591. case "24":
  12592. msg = "个人网上挂失"
  12593. break
  12594. case "25":
  12595. msg = "网上服务大厅挂失"
  12596. break
  12597. case "30":
  12598. msg = "注销"
  12599. break
  12600. case "40":
  12601. msg = "回收"
  12602. break
  12603. case "99":
  12604. msg = "制卡中(无效卡)"
  12605. break
  12606. }
  12607. c.ServeSuccessJSON(map[string]interface{}{
  12608. "failed_code": -10,
  12609. "msg": msg,
  12610. })
  12611. return
  12612. } else {
  12613. c.ServeSuccessJSON(map[string]interface{}{
  12614. "msg": "校验成功",
  12615. })
  12616. return
  12617. }
  12618. }
  12619. }
  12620. type ELeCertData struct {
  12621. Data struct {
  12622. Extra string `json:"extra"`
  12623. IDNo string `json:"idNo"`
  12624. IDType string `json:"idType"`
  12625. EcToken string `json:"ecToken"`
  12626. InsuOrg string `json:"insuOrg"`
  12627. UserName string `json:"userName"`
  12628. EcIndexNo string `json:"ecIndexNo"`
  12629. Gender string `json:"gender"`
  12630. Birthday string `json:"birthday"`
  12631. Nationality string `json:"nationality"`
  12632. Email string `json:"email"`
  12633. } `json:"OutData"`
  12634. }
  12635. func (c *HisApiController) ReadCard() {
  12636. id_card_type, _ := c.GetInt64("id_card_type")
  12637. admin_user_id, _ := c.GetInt64("admin_user_id")
  12638. certificates, _ := c.GetInt64("certificates")
  12639. //
  12640. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12641. id_card_no := c.GetString("id_card_no")
  12642. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12643. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12644. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12645. switch id_card_type {
  12646. case 1:
  12647. if miConfig.MdtrtareaAdmvs == "421300" {
  12648. var res ResultTwo
  12649. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12650. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12651. "&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)
  12652. resp, requestErr := http.Get(api)
  12653. if requestErr != nil {
  12654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12655. return
  12656. }
  12657. body, ioErr := ioutil.ReadAll(resp.Body)
  12658. if ioErr != nil {
  12659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12661. return
  12662. }
  12663. var respJSON map[string]interface{}
  12664. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12667. return
  12668. }
  12669. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12670. result, _ := json.Marshal(respJSON)
  12671. fmt.Println("log")
  12672. fmt.Println(string(result))
  12673. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12674. utils.ErrorLog("解析失败:%v", err)
  12675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12676. return
  12677. }
  12678. if res.Infcode == 0 {
  12679. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12680. if err == gorm.ErrRecordNotFound {
  12681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12682. return
  12683. } else if err != nil {
  12684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12685. return
  12686. } else {
  12687. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12688. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12689. infoStr := string(Iinfos)
  12690. idetinfoStr := string(Idetinfos)
  12691. var rf []*ResultFive
  12692. json.Unmarshal([]byte(infoStr), &rf)
  12693. var insutypes []*ResultFive
  12694. var insutype string
  12695. var is390 int = 0
  12696. var is310 int = 0
  12697. for _, item := range rf {
  12698. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12699. insutypes = append(insutypes, item)
  12700. }
  12701. }
  12702. if len(insutypes) == 1 {
  12703. insutype = insutypes[0].Insutype
  12704. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12705. } else {
  12706. for _, i := range insutypes {
  12707. if i.Insutype == "390" {
  12708. is390 = 1
  12709. }
  12710. if i.Insutype == "310" {
  12711. is310 = 1
  12712. }
  12713. }
  12714. }
  12715. if is390 == 1 {
  12716. insutype = "390"
  12717. }
  12718. if is310 == 1 {
  12719. insutype = "310"
  12720. }
  12721. if len(insutypes) == 0 {
  12722. insutype = "390"
  12723. }
  12724. var insuplc_admdvs string
  12725. for _, item := range rf {
  12726. if item.Insutype == insutype {
  12727. insuplc_admdvs = item.InsuplcAdmdvs
  12728. }
  12729. }
  12730. if strings.Contains(insuplc_admdvs, "4213") {
  12731. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12732. }
  12733. psn := &models.HisPsn{
  12734. PsnNo: res.Output.Baseinfo.PsnNo,
  12735. PatientId: patient.ID,
  12736. Certno: res.Output.Baseinfo.Certno,
  12737. Gend: res.Output.Baseinfo.Gend,
  12738. Naty: res.Output.Baseinfo.Naty,
  12739. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12740. PsnName: res.Output.Baseinfo.PsnName,
  12741. Idetinfo: idetinfoStr,
  12742. Insuinfo: infoStr,
  12743. InsuplcAdmdvs: insuplc_admdvs,
  12744. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12745. }
  12746. service.CreateHisPsn(psn)
  12747. c.ServeSuccessJSON(map[string]interface{}{
  12748. "patient": patient,
  12749. "number": res.Output.Baseinfo.Certno,
  12750. })
  12751. }
  12752. } else {
  12753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12754. return
  12755. }
  12756. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12757. var res ResultTwo
  12758. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12759. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12760. "&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)
  12761. resp, requestErr := http.Get(api)
  12762. if requestErr != nil {
  12763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12764. return
  12765. }
  12766. body, ioErr := ioutil.ReadAll(resp.Body)
  12767. if ioErr != nil {
  12768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12770. return
  12771. }
  12772. var respJSON map[string]interface{}
  12773. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12776. return
  12777. }
  12778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12779. result, _ := json.Marshal(respJSON)
  12780. fmt.Println("log")
  12781. fmt.Println(string(result))
  12782. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12783. utils.ErrorLog("解析失败:%v", err)
  12784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12785. return
  12786. }
  12787. if res.Infcode == 0 {
  12788. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12789. if err == gorm.ErrRecordNotFound {
  12790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12791. return
  12792. } else if err != nil {
  12793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12794. return
  12795. } else {
  12796. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12797. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12798. infoStr := string(Iinfos)
  12799. idetinfoStr := string(Idetinfos)
  12800. psn := &models.HisPsn{
  12801. PsnNo: res.Output.Baseinfo.PsnNo,
  12802. PatientId: patient.ID,
  12803. Certno: res.Output.Baseinfo.Certno,
  12804. Gend: res.Output.Baseinfo.Gend,
  12805. Naty: res.Output.Baseinfo.Naty,
  12806. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12807. PsnName: res.Output.Baseinfo.PsnName,
  12808. Idetinfo: idetinfoStr,
  12809. Insuinfo: infoStr,
  12810. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12811. }
  12812. service.CreateHisPsn(psn)
  12813. var rf []*ResultFive
  12814. json.Unmarshal([]byte(infoStr), &rf)
  12815. var insutypes []*ResultFive
  12816. var insutype string
  12817. var is390 int = 0
  12818. var is310 int = 0
  12819. for _, item := range rf {
  12820. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12821. insutypes = append(insutypes, item)
  12822. }
  12823. }
  12824. if len(insutypes) == 1 {
  12825. insutype = insutypes[0].Insutype
  12826. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12827. } else {
  12828. for _, i := range insutypes {
  12829. if i.Insutype == "390" {
  12830. is390 = 1
  12831. }
  12832. if i.Insutype == "310" {
  12833. is310 = 1
  12834. }
  12835. }
  12836. }
  12837. if is390 == 1 {
  12838. insutype = "390"
  12839. }
  12840. if is310 == 1 {
  12841. insutype = "310"
  12842. }
  12843. if len(insutypes) == 0 {
  12844. insutype = "310"
  12845. }
  12846. c.ServeSuccessJSON(map[string]interface{}{
  12847. "patient": patient,
  12848. "number": res.Output.Baseinfo.Certno,
  12849. "insutype": insutype,
  12850. })
  12851. }
  12852. } else {
  12853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12854. return
  12855. }
  12856. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12857. var res ResultTwo
  12858. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12859. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12860. "&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)
  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. fmt.Println("log")
  12881. fmt.Println(string(result))
  12882. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12883. utils.ErrorLog("解析失败:%v", err)
  12884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12885. return
  12886. }
  12887. if res.Infcode == 0 {
  12888. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12889. if err == gorm.ErrRecordNotFound {
  12890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12891. return
  12892. } else if err != nil {
  12893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12894. return
  12895. } else {
  12896. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12897. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12898. infoStr := string(Iinfos)
  12899. idetinfoStr := string(Idetinfos)
  12900. var rf []*ResultFive
  12901. json.Unmarshal([]byte(infoStr), &rf)
  12902. var insutypes []*ResultFive
  12903. var insutype string
  12904. var is390 int = 0
  12905. var is310 int = 0
  12906. for _, item := range rf {
  12907. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12908. insutypes = append(insutypes, item)
  12909. }
  12910. }
  12911. if len(insutypes) == 1 {
  12912. insutype = insutypes[0].Insutype
  12913. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12914. } else {
  12915. for _, i := range insutypes {
  12916. if i.Insutype == "390" {
  12917. is390 = 1
  12918. }
  12919. if i.Insutype == "310" {
  12920. is310 = 1
  12921. }
  12922. }
  12923. }
  12924. if is390 == 1 {
  12925. insutype = "390"
  12926. }
  12927. if is310 == 1 {
  12928. insutype = "310"
  12929. }
  12930. if len(insutypes) == 0 {
  12931. insutype = "390"
  12932. }
  12933. var insuplc_admdvs string
  12934. for _, item := range rf {
  12935. if item.Insutype == insutype {
  12936. insuplc_admdvs = item.InsuplcAdmdvs
  12937. }
  12938. }
  12939. psn := &models.HisPsn{
  12940. PsnNo: res.Output.Baseinfo.PsnNo,
  12941. PatientId: patient.ID,
  12942. Certno: res.Output.Baseinfo.Certno,
  12943. Gend: res.Output.Baseinfo.Gend,
  12944. Naty: res.Output.Baseinfo.Naty,
  12945. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12946. PsnName: res.Output.Baseinfo.PsnName,
  12947. Idetinfo: idetinfoStr,
  12948. Insuinfo: infoStr,
  12949. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12950. InsuplcAdmdvs: insuplc_admdvs,
  12951. }
  12952. service.CreateHisPsn(psn)
  12953. for _, item := range rf {
  12954. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12955. insutypes = append(insutypes, item)
  12956. }
  12957. }
  12958. if len(insutypes) == 1 {
  12959. insutype = insutypes[0].Insutype
  12960. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12961. } else {
  12962. for _, i := range insutypes {
  12963. if i.Insutype == "390" {
  12964. is390 = 1
  12965. }
  12966. if i.Insutype == "310" {
  12967. is310 = 1
  12968. }
  12969. }
  12970. }
  12971. if is390 == 1 {
  12972. insutype = "390"
  12973. }
  12974. if is310 == 1 {
  12975. insutype = "310"
  12976. }
  12977. if len(insutypes) == 0 {
  12978. insutype = "310"
  12979. }
  12980. c.ServeSuccessJSON(map[string]interface{}{
  12981. "patient": patient,
  12982. "number": res.Output.Baseinfo.Certno,
  12983. "insutype": insutype,
  12984. })
  12985. }
  12986. } else {
  12987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12988. return
  12989. }
  12990. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12991. var res ResultTwo
  12992. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12993. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12994. "&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)
  12995. resp, requestErr := http.Get(api)
  12996. if requestErr != nil {
  12997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12998. return
  12999. }
  13000. body, ioErr := ioutil.ReadAll(resp.Body)
  13001. if ioErr != nil {
  13002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13004. return
  13005. }
  13006. var respJSON map[string]interface{}
  13007. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13010. return
  13011. }
  13012. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13013. result, _ := json.Marshal(respJSON)
  13014. fmt.Println("log")
  13015. fmt.Println(string(result))
  13016. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13017. utils.ErrorLog("解析失败:%v", err)
  13018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13019. return
  13020. }
  13021. if res.Infcode == 0 {
  13022. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13023. if err == gorm.ErrRecordNotFound {
  13024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13025. return
  13026. } else if err != nil {
  13027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13028. return
  13029. } else {
  13030. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13031. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13032. infoStr := string(Iinfos)
  13033. idetinfoStr := string(Idetinfos)
  13034. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13035. psn := &models.HisPsn{
  13036. PsnNo: res.Output.Baseinfo.PsnNo,
  13037. PatientId: patient.ID,
  13038. Certno: res.Output.Baseinfo.Certno,
  13039. Brdy: b,
  13040. Age: float64(age),
  13041. Gend: res.Output.Baseinfo.Gend,
  13042. Naty: res.Output.Baseinfo.Naty,
  13043. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13044. PsnName: res.Output.Baseinfo.PsnName,
  13045. Idetinfo: idetinfoStr,
  13046. Insuinfo: infoStr,
  13047. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13048. }
  13049. service.CreateHisPsn(psn)
  13050. var rf []*ResultFive
  13051. json.Unmarshal([]byte(infoStr), &rf)
  13052. var insutypes []*ResultFive
  13053. var insutype string
  13054. var is390 int = 0
  13055. var is310 int = 0
  13056. for _, item := range rf {
  13057. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13058. insutypes = append(insutypes, item)
  13059. }
  13060. }
  13061. if len(insutypes) == 1 {
  13062. insutype = insutypes[0].Insutype
  13063. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13064. } else {
  13065. for _, i := range insutypes {
  13066. if i.Insutype == "390" {
  13067. is390 = 1
  13068. }
  13069. if i.Insutype == "310" {
  13070. is310 = 1
  13071. }
  13072. }
  13073. }
  13074. if is390 == 1 {
  13075. insutype = "390"
  13076. }
  13077. if is310 == 1 {
  13078. insutype = "310"
  13079. }
  13080. if len(insutypes) == 0 {
  13081. insutype = "310"
  13082. }
  13083. c.ServeSuccessJSON(map[string]interface{}{
  13084. "patient": patient,
  13085. "number": res.Output.Baseinfo.Certno,
  13086. "insutype": insutype,
  13087. })
  13088. }
  13089. } else {
  13090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13091. return
  13092. }
  13093. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13094. var api string
  13095. if miConfig.MdtrtareaAdmvs == "320921" {
  13096. 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 +
  13097. "&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
  13098. fmt.Println(api)
  13099. } else {
  13100. 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 +
  13101. "&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)
  13102. }
  13103. resp, requestErr := http.Get(api)
  13104. if requestErr != nil {
  13105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13106. return
  13107. }
  13108. body, ioErr := ioutil.ReadAll(resp.Body)
  13109. if ioErr != nil {
  13110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13112. return
  13113. }
  13114. var respJSON map[string]interface{}
  13115. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13118. return
  13119. }
  13120. var status string
  13121. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13122. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13123. //console.log()
  13124. fmt.Println("type===")
  13125. fmt.Println(card_type)
  13126. var token string
  13127. var res ResultTwo //1101结果
  13128. var res10265 ResultTwo10265 //1101结果
  13129. var card_info string //卡信息
  13130. var busi_card_info string
  13131. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13132. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13133. if status == "0" { //读卡成功
  13134. if card_type == "1" {
  13135. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13136. result, _ := json.Marshal(respJSON)
  13137. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13138. utils.ErrorLog("解析失败:%v", err)
  13139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13140. return
  13141. }
  13142. res.ErrMsg = res10265.ErrMsg
  13143. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13144. res.Infcode = infocode
  13145. res.Output = res10265.Output
  13146. res.InfRefmsgid = res10265.InfRefmsgid
  13147. } else {
  13148. //var card_info string //卡信息
  13149. //var busi_card_info string
  13150. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13151. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13152. //fmt.Println(card_info)
  13153. //fmt.Println(busi_card_info)
  13154. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13155. result, _ := json.Marshal(respJSON)
  13156. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13157. utils.ErrorLog("解析失败:%v", err)
  13158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13159. return
  13160. }
  13161. res.ErrMsg = res10265.ErrMsg
  13162. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13163. res.Infcode = infocode
  13164. res.Output = res10265.Output
  13165. res.InfRefmsgid = res10265.InfRefmsgid
  13166. }
  13167. if res.Infcode == 0 {
  13168. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13169. if err == gorm.ErrRecordNotFound {
  13170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13171. return
  13172. } else if err != nil {
  13173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13174. return
  13175. } else {
  13176. if card_type == "1" {
  13177. bas := strings.Split(card_info, "|")
  13178. basNumber := bas[2]
  13179. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13180. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13181. infoStr := string(Iinfos)
  13182. idetinfoStr := string(Idetinfos)
  13183. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13184. psn := &models.HisPsn{
  13185. PsnNo: res.Output.Baseinfo.PsnNo,
  13186. PatientId: patient.ID,
  13187. Certno: res.Output.Baseinfo.Certno,
  13188. Brdy: b,
  13189. Age: float64(age),
  13190. Gend: res.Output.Baseinfo.Gend,
  13191. Naty: res.Output.Baseinfo.Naty,
  13192. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13193. PsnName: res.Output.Baseinfo.PsnName,
  13194. Idetinfo: idetinfoStr,
  13195. Insuinfo: infoStr,
  13196. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13197. CardInfo: card_info,
  13198. VerifyNumber: busi_card_info,
  13199. }
  13200. service.CreateHisPsn(psn)
  13201. var rf []*ResultFive
  13202. json.Unmarshal([]byte(infoStr), &rf)
  13203. var insutypes []*ResultFive
  13204. var insutype string
  13205. var is390 int = 0
  13206. var is310 int = 0
  13207. for _, item := range rf {
  13208. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13209. insutypes = append(insutypes, item)
  13210. }
  13211. }
  13212. if len(insutypes) == 1 {
  13213. insutype = insutypes[0].Insutype
  13214. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13215. } else {
  13216. for _, i := range insutypes {
  13217. if i.Insutype == "390" {
  13218. is390 = 1
  13219. }
  13220. if i.Insutype == "310" {
  13221. is310 = 1
  13222. }
  13223. }
  13224. }
  13225. if is390 == 1 {
  13226. insutype = "390"
  13227. }
  13228. if is310 == 1 {
  13229. insutype = "310"
  13230. }
  13231. if len(insutypes) == 0 {
  13232. insutype = "310"
  13233. }
  13234. c.ServeSuccessJSON(map[string]interface{}{
  13235. "patient": patient,
  13236. "number": basNumber,
  13237. "insutype": insutype,
  13238. })
  13239. } else {
  13240. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13241. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13242. infoStr := string(Iinfos)
  13243. idetinfoStr := string(Idetinfos)
  13244. psn := &models.HisPsn{
  13245. PsnNo: res.Output.Baseinfo.PsnNo,
  13246. PatientId: patient.ID,
  13247. Certno: res.Output.Baseinfo.Certno,
  13248. Gend: res.Output.Baseinfo.Gend,
  13249. Naty: res.Output.Baseinfo.Naty,
  13250. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13251. PsnName: res.Output.Baseinfo.PsnName,
  13252. Idetinfo: idetinfoStr,
  13253. Insuinfo: infoStr,
  13254. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13255. CardInfo: card_info,
  13256. VerifyNumber: token,
  13257. }
  13258. service.CreateHisPsn(psn)
  13259. c.ServeSuccessJSON(map[string]interface{}{
  13260. "patient": patient,
  13261. "number": token,
  13262. })
  13263. }
  13264. }
  13265. } else {
  13266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13267. return
  13268. }
  13269. } else { //读卡失败
  13270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13271. return
  13272. }
  13273. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13274. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13275. cardnum = DeleteExtraSpaceTwo(cardnum)
  13276. cardCode = DeleteExtraSpaceTwo(cardCode)
  13277. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13278. name = DeleteExtraSpaceTwo(name)
  13279. errmsg = DeleteExtraSpaceTwo(errmsg)
  13280. cardnum = Remove0000(cardnum)
  13281. cardCode = Remove0000(cardCode)
  13282. id_card_no = Remove0000(id_card_no)
  13283. name = Remove0000(name)
  13284. errmsg = Remove0000(errmsg)
  13285. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13286. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13287. //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)
  13288. //fmt.Println(result2)
  13289. //fmt.Println(requestLog2)
  13290. //fmt.Println(errMsgLog2)
  13291. 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)
  13292. saveLog(result, requestLog, "1101", "获取人员信息")
  13293. fmt.Println(errMsgLog)
  13294. if len(errMsgLog) > 0 {
  13295. } else {
  13296. var dat map[string]interface{}
  13297. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13298. fmt.Println(dat)
  13299. } else {
  13300. fmt.Println(err)
  13301. }
  13302. userJSONBytes, _ := json.Marshal(dat)
  13303. var res ResultTwo
  13304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13305. utils.ErrorLog("解析失败:%v", err)
  13306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13307. return
  13308. }
  13309. res.ErrMsg = errMsgLog
  13310. if res.Infcode == 0 {
  13311. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13312. if err == gorm.ErrRecordNotFound {
  13313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13314. return
  13315. } else if err != nil {
  13316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13317. return
  13318. } else {
  13319. fmt.Println(res)
  13320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13322. infoStr := string(Iinfos)
  13323. idetinfoStr := string(Idetinfos)
  13324. var rf []*ResultFive
  13325. json.Unmarshal([]byte(infoStr), &rf)
  13326. var insutypes []*ResultFive
  13327. var insutype string
  13328. var is390 int = 0
  13329. var is310 int = 0
  13330. for _, item := range rf {
  13331. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13332. insutypes = append(insutypes, item)
  13333. }
  13334. }
  13335. if len(insutypes) == 1 {
  13336. insutype = insutypes[0].Insutype
  13337. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13338. } else {
  13339. for _, i := range insutypes {
  13340. if i.Insutype == "390" {
  13341. is390 = 1
  13342. }
  13343. if i.Insutype == "310" {
  13344. is310 = 1
  13345. }
  13346. }
  13347. }
  13348. if is390 == 1 {
  13349. insutype = "390"
  13350. }
  13351. if is310 == 1 {
  13352. insutype = "310"
  13353. }
  13354. if len(insutypes) == 0 {
  13355. insutype = "390"
  13356. }
  13357. var insuplc_admdvs string
  13358. for _, item := range rf {
  13359. if item.Insutype == insutype {
  13360. insuplc_admdvs = item.InsuplcAdmdvs
  13361. }
  13362. }
  13363. psn := &models.HisPsn{
  13364. PsnNo: res.Output.Baseinfo.PsnNo,
  13365. PatientId: patient.ID,
  13366. Certno: res.Output.Baseinfo.Certno,
  13367. Gend: res.Output.Baseinfo.Gend,
  13368. Naty: res.Output.Baseinfo.Naty,
  13369. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13370. PsnName: res.Output.Baseinfo.PsnName,
  13371. Idetinfo: idetinfoStr,
  13372. Insuinfo: infoStr,
  13373. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13374. CardInfo: basStr,
  13375. VerifyNumber: "",
  13376. InsuplcAdmdvs: insuplc_admdvs,
  13377. }
  13378. service.CreateHisPsn(psn)
  13379. c.ServeSuccessJSON(map[string]interface{}{
  13380. "patient": patient,
  13381. "number": cardnum,
  13382. "insutype": insutype,
  13383. })
  13384. }
  13385. } else {
  13386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13387. return
  13388. }
  13389. }
  13390. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13391. fmt.Println(initFlag)
  13392. fmt.Println("initFlag")
  13393. if initFlag == 0 {
  13394. c.TestGetJiangXiBasBaseInit()
  13395. }
  13396. basStr := c.GetBasBaseInfo()
  13397. if len(basStr) == 0 {
  13398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13399. return
  13400. }
  13401. fmt.Println(basStr)
  13402. bas := strings.Split(basStr, "|")
  13403. basNumber := bas[1]
  13404. fmt.Println(basNumber)
  13405. card_sn := bas[3]
  13406. fmt.Println(card_sn)
  13407. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13408. 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)
  13409. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13410. var dat map[string]interface{}
  13411. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13412. fmt.Println(dat)
  13413. } else {
  13414. fmt.Println(err)
  13415. }
  13416. userJSONBytes, _ := json.Marshal(dat)
  13417. var res ResultTwo
  13418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13419. utils.ErrorLog("解析失败:%v", err)
  13420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13421. return
  13422. }
  13423. if res.Infcode == 0 {
  13424. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13425. if err == gorm.ErrRecordNotFound {
  13426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13427. return
  13428. } else if err != nil {
  13429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13430. return
  13431. } else {
  13432. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13433. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13434. infoStr := string(Iinfos)
  13435. idetinfoStr := string(Idetinfos)
  13436. var rf []*ResultFive
  13437. json.Unmarshal([]byte(infoStr), &rf)
  13438. var insutypes []*ResultFive
  13439. var insutype string
  13440. var is390 int = 0
  13441. var is310 int = 0
  13442. var insuplc_admdvs string
  13443. for _, item := range rf {
  13444. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13445. insutypes = append(insutypes, item)
  13446. }
  13447. }
  13448. if len(insutypes) == 1 {
  13449. insutype = insutypes[0].Insutype
  13450. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13451. } else {
  13452. for _, i := range insutypes {
  13453. if i.Insutype == "390" {
  13454. is390 = 1
  13455. }
  13456. if i.Insutype == "310" {
  13457. is310 = 1
  13458. }
  13459. }
  13460. }
  13461. if is390 == 1 {
  13462. insutype = "390"
  13463. }
  13464. if is310 == 1 {
  13465. insutype = "310"
  13466. }
  13467. if len(insutypes) == 0 {
  13468. insutype = "310"
  13469. }
  13470. for _, item := range rf {
  13471. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13472. insuplc_admdvs = item.InsuplcAdmdvs
  13473. }
  13474. }
  13475. psn := &models.HisPsn{
  13476. PsnNo: res.Output.Baseinfo.PsnNo,
  13477. PatientId: patient.ID,
  13478. Certno: res.Output.Baseinfo.Certno,
  13479. Gend: res.Output.Baseinfo.Gend,
  13480. Naty: res.Output.Baseinfo.Naty,
  13481. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13482. PsnName: res.Output.Baseinfo.PsnName,
  13483. Idetinfo: idetinfoStr,
  13484. Insuinfo: infoStr,
  13485. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13486. CardInfo: basStr,
  13487. InsuplcAdmdvs: insuplc_admdvs,
  13488. VerifyNumber: "",
  13489. }
  13490. service.CreateHisPsn(psn)
  13491. c.ServeSuccessJSON(map[string]interface{}{
  13492. "patient": patient,
  13493. "number": basNumber,
  13494. "insutype": insutype,
  13495. })
  13496. }
  13497. } else {
  13498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13499. return
  13500. }
  13501. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13502. basStr := c.GetBasBaseInfo22222()
  13503. fmt.Println(basStr)
  13504. if len(basStr) == 0 {
  13505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13506. return
  13507. }
  13508. fmt.Println(basStr)
  13509. bas := strings.Split(basStr, "|")
  13510. basNumber := bas[2] //卡号
  13511. card_sn := bas[3] //
  13512. id_card_No := bas[1] //卡号
  13513. fmt.Println(basNumber)
  13514. fmt.Println(card_sn)
  13515. fmt.Println(id_card_No)
  13516. var patient service.Patients
  13517. if len(id_card_No) == 0 {
  13518. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13519. } else {
  13520. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13521. }
  13522. 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)
  13523. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13524. var dat map[string]interface{}
  13525. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13526. fmt.Println(dat)
  13527. } else {
  13528. fmt.Println(err)
  13529. }
  13530. userJSONBytes, _ := json.Marshal(dat)
  13531. var res ResultTwo
  13532. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13533. utils.ErrorLog("解析失败:%v", err)
  13534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13535. return
  13536. }
  13537. if res.Infcode == 0 {
  13538. var pateint2 service.Patients
  13539. var err error
  13540. if len(id_card_No) == 0 {
  13541. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13542. } else {
  13543. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13544. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13545. }
  13546. if err == gorm.ErrRecordNotFound {
  13547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13548. return
  13549. } else if err != nil {
  13550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13551. return
  13552. } else {
  13553. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13554. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13555. infoStr := string(Iinfos)
  13556. idetinfoStr := string(Idetinfos)
  13557. var rf []*ResultFive
  13558. json.Unmarshal([]byte(infoStr), &rf)
  13559. var insutypes []*ResultFive
  13560. var insutype string
  13561. var is390 int = 0
  13562. var is310 int = 0
  13563. var insuplc_admdvs string
  13564. for _, item := range rf {
  13565. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13566. insutypes = append(insutypes, item)
  13567. }
  13568. }
  13569. if len(insutypes) == 1 {
  13570. insutype = insutypes[0].Insutype
  13571. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13572. } else {
  13573. for _, i := range insutypes {
  13574. if i.Insutype == "390" {
  13575. is390 = 1
  13576. }
  13577. if i.Insutype == "310" {
  13578. is310 = 1
  13579. }
  13580. }
  13581. }
  13582. if is390 == 1 {
  13583. insutype = "390"
  13584. }
  13585. if is310 == 1 {
  13586. insutype = "310"
  13587. }
  13588. if len(insutypes) == 0 {
  13589. insutype = "310"
  13590. }
  13591. for _, item := range rf {
  13592. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13593. insuplc_admdvs = item.InsuplcAdmdvs
  13594. }
  13595. }
  13596. psn := &models.HisPsn{
  13597. PsnNo: res.Output.Baseinfo.PsnNo,
  13598. PatientId: pateint2.ID,
  13599. Certno: res.Output.Baseinfo.Certno,
  13600. Gend: res.Output.Baseinfo.Gend,
  13601. Naty: res.Output.Baseinfo.Naty,
  13602. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13603. PsnName: res.Output.Baseinfo.PsnName,
  13604. Idetinfo: idetinfoStr,
  13605. Insuinfo: infoStr,
  13606. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13607. CardInfo: basStr,
  13608. InsuplcAdmdvs: insuplc_admdvs,
  13609. VerifyNumber: "",
  13610. }
  13611. service.CreateHisPsn(psn)
  13612. c.ServeSuccessJSON(map[string]interface{}{
  13613. "patient": patient,
  13614. "number": basNumber,
  13615. "insutype": insutype,
  13616. })
  13617. }
  13618. } else {
  13619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13620. return
  13621. }
  13622. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13623. fmt.Println(initFlag)
  13624. fmt.Println("initFlag")
  13625. if initFlag == 0 {
  13626. c.TestGetHnBasBaseInit()
  13627. }
  13628. basStr := c.GetBasBaseInfo()
  13629. if len(basStr) == 0 {
  13630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13631. return
  13632. }
  13633. fmt.Println(basStr)
  13634. bas := strings.Split(basStr, "|")
  13635. basNumber := bas[1]
  13636. fmt.Println(basNumber)
  13637. card_sn := bas[3]
  13638. card_no := bas[2]
  13639. fmt.Println(card_sn)
  13640. name := bas[4]
  13641. name = ConvertToString(name, "gbk", "utf-8")
  13642. 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)
  13643. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13644. var dat map[string]interface{}
  13645. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13646. fmt.Println(dat)
  13647. } else {
  13648. fmt.Println(err)
  13649. }
  13650. userJSONBytes, _ := json.Marshal(dat)
  13651. var res ResultTwo
  13652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13653. utils.ErrorLog("解析失败:%v", err)
  13654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13655. return
  13656. }
  13657. if res.Infcode == 0 {
  13658. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13659. if err == gorm.ErrRecordNotFound {
  13660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13661. return
  13662. } else if err != nil {
  13663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13664. return
  13665. } else {
  13666. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13667. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13668. infoStr := string(Iinfos)
  13669. idetinfoStr := string(Idetinfos)
  13670. psn := &models.HisPsn{
  13671. PsnNo: res.Output.Baseinfo.PsnNo,
  13672. PatientId: patient.ID,
  13673. Certno: res.Output.Baseinfo.Certno,
  13674. Gend: res.Output.Baseinfo.Gend,
  13675. Naty: res.Output.Baseinfo.Naty,
  13676. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13677. PsnName: res.Output.Baseinfo.PsnName,
  13678. Idetinfo: idetinfoStr,
  13679. Insuinfo: infoStr,
  13680. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13681. CardInfo: basStr,
  13682. VerifyNumber: "",
  13683. }
  13684. service.CreateHisPsn(psn)
  13685. var rf []*ResultFive
  13686. json.Unmarshal([]byte(infoStr), &rf)
  13687. var insutypes []*ResultFive
  13688. var insutype string
  13689. var is390 int = 0
  13690. var is310 int = 0
  13691. for _, item := range rf {
  13692. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13693. insutypes = append(insutypes, item)
  13694. }
  13695. }
  13696. if len(insutypes) == 1 {
  13697. insutype = insutypes[0].Insutype
  13698. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13699. } else {
  13700. for _, i := range insutypes {
  13701. if i.Insutype == "390" {
  13702. is390 = 1
  13703. }
  13704. if i.Insutype == "310" {
  13705. is310 = 1
  13706. }
  13707. }
  13708. }
  13709. if is390 == 1 {
  13710. insutype = "390"
  13711. }
  13712. if is310 == 1 {
  13713. insutype = "310"
  13714. }
  13715. if len(insutypes) == 0 {
  13716. insutype = "310"
  13717. }
  13718. c.ServeSuccessJSON(map[string]interface{}{
  13719. "patient": patient,
  13720. "number": basNumber,
  13721. "insutype": insutype,
  13722. })
  13723. }
  13724. } else {
  13725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13726. return
  13727. }
  13728. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13729. var api string
  13730. 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 +
  13731. "&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
  13732. fmt.Println(api)
  13733. resp, requestErr := http.Get(api)
  13734. if requestErr != nil {
  13735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13736. return
  13737. }
  13738. body, ioErr := ioutil.ReadAll(resp.Body)
  13739. if ioErr != nil {
  13740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13742. return
  13743. }
  13744. var respJSON map[string]interface{}
  13745. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13748. return
  13749. }
  13750. var res ResultTwo //1101结果
  13751. var res10265 ResultTwo10265 //1101结果
  13752. var card_info string //卡信息
  13753. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13754. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13755. result, _ := json.Marshal(respJSON)
  13756. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13757. utils.ErrorLog("解析失败:%v", err)
  13758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13759. return
  13760. }
  13761. res.ErrMsg = res10265.ErrMsg
  13762. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13763. res.Infcode = infocode
  13764. res.Output = res10265.Output
  13765. res.InfRefmsgid = res10265.InfRefmsgid
  13766. if res.Infcode == 0 {
  13767. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13768. if err == gorm.ErrRecordNotFound {
  13769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13770. return
  13771. } else if err != nil {
  13772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13773. return
  13774. } else {
  13775. bas := strings.Split(card_info, "|")
  13776. basNumber := bas[2]
  13777. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13778. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13779. infoStr := string(Iinfos)
  13780. idetinfoStr := string(Idetinfos)
  13781. psn := &models.HisPsn{
  13782. PsnNo: res.Output.Baseinfo.PsnNo,
  13783. PatientId: patient.ID,
  13784. Certno: res.Output.Baseinfo.Certno,
  13785. Gend: res.Output.Baseinfo.Gend,
  13786. Naty: res.Output.Baseinfo.Naty,
  13787. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13788. PsnName: res.Output.Baseinfo.PsnName,
  13789. Idetinfo: idetinfoStr,
  13790. Insuinfo: infoStr,
  13791. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13792. CardInfo: card_info,
  13793. VerifyNumber: token,
  13794. }
  13795. service.CreateHisPsn(psn)
  13796. var rf []*ResultFive
  13797. json.Unmarshal([]byte(infoStr), &rf)
  13798. var insutypes []*ResultFive
  13799. var insutype string
  13800. var is390 int = 0
  13801. var is310 int = 0
  13802. for _, item := range rf {
  13803. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13804. insutypes = append(insutypes, item)
  13805. }
  13806. }
  13807. if len(insutypes) == 1 {
  13808. insutype = insutypes[0].Insutype
  13809. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13810. } else {
  13811. for _, i := range insutypes {
  13812. if i.Insutype == "390" {
  13813. is390 = 1
  13814. }
  13815. if i.Insutype == "310" {
  13816. is310 = 1
  13817. }
  13818. }
  13819. }
  13820. if is390 == 1 {
  13821. insutype = "390"
  13822. }
  13823. if is310 == 1 {
  13824. insutype = "310"
  13825. }
  13826. if len(insutypes) == 0 {
  13827. insutype = "310"
  13828. }
  13829. c.ServeSuccessJSON(map[string]interface{}{
  13830. "patient": patient,
  13831. "number": basNumber,
  13832. "insutype": insutype,
  13833. })
  13834. }
  13835. } else {
  13836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13837. return
  13838. }
  13839. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13840. res := c.GetoleInfo()
  13841. if res.Infcode == 0 {
  13842. var result string
  13843. if res.Output.MdtrtCertType == "01" {
  13844. 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)
  13845. } else if res.Output.MdtrtCertType == "02" {
  13846. 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)
  13847. } else if res.Output.MdtrtCertType == "03" {
  13848. 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)
  13849. }
  13850. var dat map[string]interface{}
  13851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13852. fmt.Println(dat)
  13853. } else {
  13854. fmt.Println(err)
  13855. }
  13856. userJSONBytes, _ := json.Marshal(dat)
  13857. var res2 ResultTwo
  13858. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13859. utils.ErrorLog("解析失败:%v", err)
  13860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13861. return
  13862. }
  13863. if res2.Infcode == 0 {
  13864. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13865. if err == gorm.ErrRecordNotFound {
  13866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13867. return
  13868. } else if err != nil {
  13869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13870. return
  13871. } else {
  13872. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13873. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13874. infoStr := string(Iinfos)
  13875. idetinfoStr := string(Idetinfos)
  13876. var rf []*ResultFive
  13877. json.Unmarshal([]byte(infoStr), &rf)
  13878. var insutypes []*ResultFive
  13879. var insutype string
  13880. var is390 int = 0
  13881. var is310 int = 0
  13882. //var insuplc_admdvs string
  13883. for _, item := range rf {
  13884. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13885. insutypes = append(insutypes, item)
  13886. }
  13887. }
  13888. if len(insutypes) == 1 {
  13889. insutype = insutypes[0].Insutype
  13890. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13891. } else {
  13892. for _, i := range insutypes {
  13893. if i.Insutype == "390" {
  13894. is390 = 1
  13895. }
  13896. if i.Insutype == "310" {
  13897. is310 = 1
  13898. }
  13899. }
  13900. }
  13901. if is390 == 1 {
  13902. insutype = "390"
  13903. }
  13904. if is310 == 1 {
  13905. insutype = "310"
  13906. }
  13907. if len(insutypes) == 0 {
  13908. insutype = "310"
  13909. }
  13910. psn := &models.HisPsn{
  13911. PsnNo: res2.Output.Baseinfo.PsnNo,
  13912. PatientId: patient.ID,
  13913. Certno: res2.Output.Baseinfo.Certno,
  13914. Gend: res2.Output.Baseinfo.Gend,
  13915. Naty: res2.Output.Baseinfo.Naty,
  13916. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13917. PsnName: res2.Output.Baseinfo.PsnName,
  13918. Idetinfo: idetinfoStr,
  13919. Insuinfo: infoStr,
  13920. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13921. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13922. VerifyNumber: res.Output.EcToken,
  13923. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13924. }
  13925. if res.Output.MdtrtCertType == "01" {
  13926. psn.VerifyNumber = res.Output.EcToken
  13927. //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)
  13928. } else if res.Output.MdtrtCertType == "02" {
  13929. psn.VerifyNumber = res.Output.MdtrtCertNo
  13930. //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)
  13931. } else if res.Output.MdtrtCertType == "03" {
  13932. psn.VerifyNumber = res.Output.MdtrtCertNo
  13933. //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)
  13934. }
  13935. var balc float64
  13936. for _, item := range rf {
  13937. if item.Insutype == insutype {
  13938. balc = item.Balc
  13939. }
  13940. }
  13941. service.CreateHisPsn(psn)
  13942. c.ServeSuccessJSON(map[string]interface{}{
  13943. "patient": patient,
  13944. "number": res.Output.CardNo,
  13945. "insutype": insutype,
  13946. "blac": balc,
  13947. "desc": idetinfoStr,
  13948. })
  13949. }
  13950. } else {
  13951. c.ServeSuccessJSON(map[string]interface{}{
  13952. "failed_code": -10,
  13953. "msg": res2.ErrMsg,
  13954. })
  13955. }
  13956. } else {
  13957. c.ServeSuccessJSON(map[string]interface{}{
  13958. "failed_code": -10,
  13959. "msg": res.ErrMsg,
  13960. })
  13961. }
  13962. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13963. var api string
  13964. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13965. "&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
  13966. fmt.Println(api)
  13967. resp, requestErr := http.Get(api)
  13968. if requestErr != nil {
  13969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13970. return
  13971. }
  13972. body, ioErr := ioutil.ReadAll(resp.Body)
  13973. if ioErr != nil {
  13974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13976. return
  13977. }
  13978. var respJSON map[string]interface{}
  13979. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13982. return
  13983. }
  13984. var status string
  13985. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13986. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13987. //console.log()
  13988. fmt.Println("type===")
  13989. fmt.Println(card_type)
  13990. var token string
  13991. var res ResultTwo //1101结果
  13992. //var res10265 ResultTwoesultTwo10265 //1101结果
  13993. var card_info string //卡信息
  13994. var busi_card_info string
  13995. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13996. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13997. if status == "0" { //读卡成功
  13998. if card_type == "1" {
  13999. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14000. result, _ := json.Marshal(respJSON)
  14001. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14002. utils.ErrorLog("解析失败:%v", err)
  14003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14004. return
  14005. }
  14006. } else {
  14007. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14008. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14009. result, _ := json.Marshal(respJSON)
  14010. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14011. utils.ErrorLog("解析失败:%v", err)
  14012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14013. return
  14014. }
  14015. }
  14016. if res.Infcode == 0 {
  14017. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14018. if err == gorm.ErrRecordNotFound {
  14019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14020. return
  14021. } else if err != nil {
  14022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14023. return
  14024. } else {
  14025. if card_type == "1" {
  14026. bas := strings.Split(card_info, "|")
  14027. basNumber := bas[2]
  14028. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14029. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14030. infoStr := string(Iinfos)
  14031. idetinfoStr := string(Idetinfos)
  14032. psn := &models.HisPsn{
  14033. PsnNo: res.Output.Baseinfo.PsnNo,
  14034. PatientId: patient.ID,
  14035. Certno: res.Output.Baseinfo.Certno,
  14036. Gend: res.Output.Baseinfo.Gend,
  14037. Naty: res.Output.Baseinfo.Naty,
  14038. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14039. PsnName: res.Output.Baseinfo.PsnName,
  14040. Idetinfo: idetinfoStr,
  14041. Insuinfo: infoStr,
  14042. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14043. CardInfo: card_info,
  14044. VerifyNumber: busi_card_info,
  14045. }
  14046. service.CreateHisPsn(psn)
  14047. var rf []*ResultFive
  14048. json.Unmarshal([]byte(infoStr), &rf)
  14049. var insutypes []*ResultFive
  14050. var insutype string
  14051. var is390 int = 0
  14052. var is310 int = 0
  14053. for _, item := range rf {
  14054. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14055. insutypes = append(insutypes, item)
  14056. }
  14057. }
  14058. if len(insutypes) == 1 {
  14059. insutype = insutypes[0].Insutype
  14060. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14061. } else {
  14062. for _, i := range insutypes {
  14063. if i.Insutype == "390" {
  14064. is390 = 1
  14065. }
  14066. if i.Insutype == "310" {
  14067. is310 = 1
  14068. }
  14069. }
  14070. }
  14071. if is390 == 1 {
  14072. insutype = "390"
  14073. }
  14074. if is310 == 1 {
  14075. insutype = "310"
  14076. }
  14077. if len(insutypes) == 0 {
  14078. insutype = "310"
  14079. }
  14080. c.ServeSuccessJSON(map[string]interface{}{
  14081. "patient": patient,
  14082. "number": basNumber,
  14083. "insutype": insutype,
  14084. })
  14085. } else {
  14086. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14087. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14088. infoStr := string(Iinfos)
  14089. idetinfoStr := string(Idetinfos)
  14090. psn := &models.HisPsn{
  14091. PsnNo: res.Output.Baseinfo.PsnNo,
  14092. PatientId: patient.ID,
  14093. Certno: res.Output.Baseinfo.Certno,
  14094. Gend: res.Output.Baseinfo.Gend,
  14095. Naty: res.Output.Baseinfo.Naty,
  14096. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14097. PsnName: res.Output.Baseinfo.PsnName,
  14098. Idetinfo: idetinfoStr,
  14099. Insuinfo: infoStr,
  14100. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14101. CardInfo: card_info,
  14102. VerifyNumber: token,
  14103. }
  14104. service.CreateHisPsn(psn)
  14105. c.ServeSuccessJSON(map[string]interface{}{
  14106. "patient": patient,
  14107. "number": token,
  14108. })
  14109. }
  14110. }
  14111. } else {
  14112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14113. return
  14114. }
  14115. } else { //读卡失败
  14116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14117. return
  14118. }
  14119. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14120. var api string
  14121. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14122. "&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
  14123. fmt.Println(api)
  14124. resp, requestErr := http.Get(api)
  14125. if requestErr != nil {
  14126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14127. return
  14128. }
  14129. body, ioErr := ioutil.ReadAll(resp.Body)
  14130. if ioErr != nil {
  14131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14133. return
  14134. }
  14135. var respJSON map[string]interface{}
  14136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14139. return
  14140. }
  14141. var status string
  14142. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14143. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14144. //console.log()
  14145. fmt.Println("type===")
  14146. fmt.Println(card_type)
  14147. var token string
  14148. var res ResultTwo //1101结果
  14149. //var res10265 ResultTwoesultTwo10265 //1101结果
  14150. var card_info string //卡信息
  14151. //var busi_card_info string
  14152. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14153. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14154. if status == "0" { //读卡成功
  14155. if card_type == "1" {
  14156. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14157. result, _ := json.Marshal(respJSON)
  14158. fmt.Println(result)
  14159. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14160. utils.ErrorLog("解析失败:%v", err)
  14161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14162. return
  14163. }
  14164. fmt.Println(res)
  14165. } else {
  14166. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14167. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14168. result, _ := json.Marshal(respJSON)
  14169. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14170. utils.ErrorLog("解析失败:%v", err)
  14171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14172. return
  14173. }
  14174. }
  14175. if res.Infcode == 0 {
  14176. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14177. if err == gorm.ErrRecordNotFound {
  14178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14179. return
  14180. } else if err != nil {
  14181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14182. return
  14183. } else {
  14184. if card_type == "1" {
  14185. bas := strings.Split(card_info, "|")
  14186. basNumber := bas[2]
  14187. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14188. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14189. infoStr := string(Iinfos)
  14190. idetinfoStr := string(Idetinfos)
  14191. psn := &models.HisPsn{
  14192. PsnNo: res.Output.Baseinfo.PsnNo,
  14193. PatientId: patient.ID,
  14194. Certno: res.Output.Baseinfo.Certno,
  14195. Gend: res.Output.Baseinfo.Gend,
  14196. Naty: res.Output.Baseinfo.Naty,
  14197. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14198. PsnName: res.Output.Baseinfo.PsnName,
  14199. Idetinfo: idetinfoStr,
  14200. Insuinfo: infoStr,
  14201. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14202. CardInfo: card_info,
  14203. //VerifyNumber: busi_card_info,
  14204. }
  14205. service.CreateHisPsn(psn)
  14206. var rf []*ResultFive
  14207. json.Unmarshal([]byte(infoStr), &rf)
  14208. var insutypes []*ResultFive
  14209. var insutype string
  14210. var is390 int = 0
  14211. var is310 int = 0
  14212. for _, item := range rf {
  14213. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14214. insutypes = append(insutypes, item)
  14215. }
  14216. }
  14217. if len(insutypes) == 1 {
  14218. insutype = insutypes[0].Insutype
  14219. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14220. } else {
  14221. for _, i := range insutypes {
  14222. if i.Insutype == "390" {
  14223. is390 = 1
  14224. }
  14225. if i.Insutype == "310" {
  14226. is310 = 1
  14227. }
  14228. }
  14229. }
  14230. if is390 == 1 {
  14231. insutype = "390"
  14232. }
  14233. if is310 == 1 {
  14234. insutype = "310"
  14235. }
  14236. if len(insutypes) == 0 {
  14237. insutype = "310"
  14238. }
  14239. c.ServeSuccessJSON(map[string]interface{}{
  14240. "patient": patient,
  14241. "number": basNumber,
  14242. "insutype": insutype,
  14243. })
  14244. } else {
  14245. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14246. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14247. infoStr := string(Iinfos)
  14248. idetinfoStr := string(Idetinfos)
  14249. psn := &models.HisPsn{
  14250. PsnNo: res.Output.Baseinfo.PsnNo,
  14251. PatientId: patient.ID,
  14252. Certno: res.Output.Baseinfo.Certno,
  14253. Gend: res.Output.Baseinfo.Gend,
  14254. Naty: res.Output.Baseinfo.Naty,
  14255. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14256. PsnName: res.Output.Baseinfo.PsnName,
  14257. Idetinfo: idetinfoStr,
  14258. Insuinfo: infoStr,
  14259. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14260. CardInfo: card_info,
  14261. VerifyNumber: token,
  14262. }
  14263. service.CreateHisPsn(psn)
  14264. c.ServeSuccessJSON(map[string]interface{}{
  14265. "patient": patient,
  14266. "number": token,
  14267. })
  14268. }
  14269. }
  14270. } else {
  14271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14272. return
  14273. }
  14274. } else { //读卡失败
  14275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14276. return
  14277. }
  14278. } else {
  14279. if initFlag == 0 {
  14280. c.TestGetBasBaseInit()
  14281. }
  14282. basStr := c.GetBasBaseInfo()
  14283. if len(basStr) == 0 {
  14284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14285. return
  14286. }
  14287. fmt.Println(basStr)
  14288. bas := strings.Split(basStr, "|")
  14289. basNumber := bas[1]
  14290. fmt.Println(basNumber)
  14291. card_sn := bas[3]
  14292. fmt.Println(card_sn)
  14293. cardNumber := bas[2]
  14294. fmt.Println(cardNumber)
  14295. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14296. var result string
  14297. if bas[0][:2] == "44" {
  14298. 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)
  14299. } else {
  14300. 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)
  14301. }
  14302. var dat map[string]interface{}
  14303. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14304. fmt.Println(dat)
  14305. } else {
  14306. fmt.Println(err)
  14307. }
  14308. userJSONBytes, _ := json.Marshal(dat)
  14309. var res ResultTwo
  14310. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14311. utils.ErrorLog("解析失败:%v", err)
  14312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14313. return
  14314. }
  14315. if res.Infcode == 0 {
  14316. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14317. if err == gorm.ErrRecordNotFound {
  14318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14319. return
  14320. } else if err != nil {
  14321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14322. return
  14323. } else {
  14324. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14325. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14326. infoStr := string(Iinfos)
  14327. idetinfoStr := string(Idetinfos)
  14328. var rf []*ResultFive
  14329. json.Unmarshal([]byte(infoStr), &rf)
  14330. var insutypes []*ResultFive
  14331. var insutype string
  14332. var is390 int = 0
  14333. var is310 int = 0
  14334. var insuplc_admdvs string
  14335. for _, item := range rf {
  14336. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14337. insutypes = append(insutypes, item)
  14338. }
  14339. }
  14340. if len(insutypes) == 1 {
  14341. insutype = insutypes[0].Insutype
  14342. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14343. } else {
  14344. for _, i := range insutypes {
  14345. if i.Insutype == "390" {
  14346. is390 = 1
  14347. }
  14348. if i.Insutype == "310" {
  14349. is310 = 1
  14350. }
  14351. }
  14352. }
  14353. if is390 == 1 {
  14354. insutype = "390"
  14355. }
  14356. if is310 == 1 {
  14357. insutype = "310"
  14358. }
  14359. if len(insutypes) == 0 {
  14360. insutype = "310"
  14361. }
  14362. for _, item := range rf {
  14363. if item.Insutype == insutype {
  14364. insuplc_admdvs = item.InsuplcAdmdvs
  14365. }
  14366. }
  14367. psn := &models.HisPsn{
  14368. PsnNo: res.Output.Baseinfo.PsnNo,
  14369. PatientId: patient.ID,
  14370. Certno: res.Output.Baseinfo.Certno,
  14371. Gend: res.Output.Baseinfo.Gend,
  14372. Naty: res.Output.Baseinfo.Naty,
  14373. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14374. PsnName: res.Output.Baseinfo.PsnName,
  14375. Idetinfo: idetinfoStr,
  14376. Insuinfo: infoStr,
  14377. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14378. CardInfo: basStr,
  14379. VerifyNumber: "",
  14380. InsuplcAdmdvs: insuplc_admdvs,
  14381. }
  14382. service.CreateHisPsn(psn)
  14383. c.ServeSuccessJSON(map[string]interface{}{
  14384. "patient": patient,
  14385. "number": basNumber,
  14386. })
  14387. }
  14388. } else {
  14389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14390. return
  14391. }
  14392. break
  14393. }
  14394. case 2:
  14395. if miConfig.MdtrtareaAdmvs == "430800" {
  14396. if initFlag == 0 {
  14397. c.TestGetHnBasBaseInit()
  14398. }
  14399. SFZStr := c.GetSFZBaseInfo()
  14400. if len(SFZStr) == 0 {
  14401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14402. return
  14403. }
  14404. fmt.Println(SFZStr)
  14405. id_card_str := strings.Split(SFZStr, "^")
  14406. card_no := id_card_str[0]
  14407. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14408. //name := id_card_str[1]
  14409. //name = ConvertToString(name, "gbk", "utf-8")
  14410. 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)
  14411. var dat map[string]interface{}
  14412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14413. fmt.Println(dat)
  14414. } else {
  14415. fmt.Println(err)
  14416. }
  14417. userJSONBytes, _ := json.Marshal(dat)
  14418. var res ResultTwo
  14419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14420. utils.ErrorLog("解析失败:%v", err)
  14421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14422. return
  14423. }
  14424. if res.Infcode == 0 {
  14425. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14426. if err == gorm.ErrRecordNotFound {
  14427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14428. return
  14429. } else if err != nil {
  14430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14431. return
  14432. } else {
  14433. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14434. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14435. infoStr := string(Iinfos)
  14436. idetinfoStr := string(Idetinfos)
  14437. var rf []*ResultFive
  14438. json.Unmarshal([]byte(infoStr), &rf)
  14439. var insutypes []*ResultFive
  14440. var insutype string
  14441. var is390 int = 0
  14442. var is310 int = 0
  14443. for _, item := range rf {
  14444. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14445. insutypes = append(insutypes, item)
  14446. }
  14447. }
  14448. if len(insutypes) == 1 {
  14449. insutype = insutypes[0].Insutype
  14450. } else {
  14451. for _, i := range insutypes {
  14452. if i.Insutype == "390" {
  14453. is390 = 1
  14454. }
  14455. if i.Insutype == "310" {
  14456. is310 = 1
  14457. }
  14458. }
  14459. }
  14460. if is390 == 1 {
  14461. insutype = "390"
  14462. }
  14463. if is310 == 1 {
  14464. insutype = "310"
  14465. }
  14466. if len(insutypes) == 0 {
  14467. insutype = "310"
  14468. }
  14469. var InsuplcAdmdvs string
  14470. for _, item := range rf {
  14471. if item.Insutype == insutype {
  14472. InsuplcAdmdvs = item.InsuplcAdmdvs
  14473. }
  14474. }
  14475. psn := &models.HisPsn{
  14476. PsnNo: res.Output.Baseinfo.PsnNo,
  14477. PatientId: patient.ID,
  14478. Certno: res.Output.Baseinfo.Certno,
  14479. Gend: res.Output.Baseinfo.Gend,
  14480. Naty: res.Output.Baseinfo.Naty,
  14481. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14482. PsnName: res.Output.Baseinfo.PsnName,
  14483. Idetinfo: idetinfoStr,
  14484. Insuinfo: infoStr,
  14485. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14486. CardInfo: SFZStr,
  14487. VerifyNumber: "",
  14488. InsuplcAdmdvs: InsuplcAdmdvs,
  14489. }
  14490. service.CreateHisPsn(psn)
  14491. c.ServeSuccessJSON(map[string]interface{}{
  14492. "patient": patient,
  14493. "number": card_no,
  14494. "insutype": insutype,
  14495. })
  14496. }
  14497. } else {
  14498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14499. return
  14500. }
  14501. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14502. var res ResultTwo
  14503. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14504. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14505. "&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)
  14506. resp, requestErr := http.Get(api)
  14507. if requestErr != nil {
  14508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14509. return
  14510. }
  14511. body, ioErr := ioutil.ReadAll(resp.Body)
  14512. if ioErr != nil {
  14513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14515. return
  14516. }
  14517. var respJSON map[string]interface{}
  14518. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14521. return
  14522. }
  14523. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14524. result, _ := json.Marshal(respJSON)
  14525. fmt.Println("log")
  14526. fmt.Println(string(result))
  14527. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14528. utils.ErrorLog("解析失败:%v", err)
  14529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14530. return
  14531. }
  14532. if res.Infcode == 0 {
  14533. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14534. if err == gorm.ErrRecordNotFound {
  14535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14536. return
  14537. } else if err != nil {
  14538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14539. return
  14540. } else {
  14541. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14542. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14543. infoStr := string(Iinfos)
  14544. idetinfoStr := string(Idetinfos)
  14545. psn := &models.HisPsn{
  14546. PsnNo: res.Output.Baseinfo.PsnNo,
  14547. PatientId: patient.ID,
  14548. Certno: res.Output.Baseinfo.Certno,
  14549. Gend: res.Output.Baseinfo.Gend,
  14550. Naty: res.Output.Baseinfo.Naty,
  14551. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14552. PsnName: res.Output.Baseinfo.PsnName,
  14553. Idetinfo: idetinfoStr,
  14554. Insuinfo: infoStr,
  14555. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14556. }
  14557. service.CreateHisPsn(psn)
  14558. c.ServeSuccessJSON(map[string]interface{}{
  14559. "patient": patient,
  14560. "number": res.Output.Baseinfo.Certno,
  14561. })
  14562. }
  14563. } else {
  14564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14565. return
  14566. }
  14567. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14568. var res ResultTwo
  14569. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14570. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14571. "&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)
  14572. resp, requestErr := http.Get(api)
  14573. if requestErr != nil {
  14574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14575. return
  14576. }
  14577. body, ioErr := ioutil.ReadAll(resp.Body)
  14578. if ioErr != nil {
  14579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14581. return
  14582. }
  14583. var respJSON map[string]interface{}
  14584. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14587. return
  14588. }
  14589. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14590. result, _ := json.Marshal(respJSON)
  14591. fmt.Println("log")
  14592. fmt.Println(string(result))
  14593. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14594. utils.ErrorLog("解析失败:%v", err)
  14595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14596. return
  14597. }
  14598. if res.Infcode == 0 {
  14599. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14600. if err == gorm.ErrRecordNotFound {
  14601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14602. return
  14603. } else if err != nil {
  14604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14605. return
  14606. } else {
  14607. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14608. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14609. infoStr := string(Iinfos)
  14610. idetinfoStr := string(Idetinfos)
  14611. psn := &models.HisPsn{
  14612. PsnNo: res.Output.Baseinfo.PsnNo,
  14613. PatientId: patient.ID,
  14614. Certno: res.Output.Baseinfo.Certno,
  14615. Gend: res.Output.Baseinfo.Gend,
  14616. Naty: res.Output.Baseinfo.Naty,
  14617. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14618. PsnName: res.Output.Baseinfo.PsnName,
  14619. Idetinfo: idetinfoStr,
  14620. Insuinfo: infoStr,
  14621. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14622. }
  14623. service.CreateHisPsn(psn)
  14624. c.ServeSuccessJSON(map[string]interface{}{
  14625. "patient": patient,
  14626. "number": res.Output.Baseinfo.Certno,
  14627. })
  14628. }
  14629. } else {
  14630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14631. return
  14632. }
  14633. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14634. var res ResultTwo
  14635. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14636. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14637. "&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)
  14638. resp, requestErr := http.Get(api)
  14639. if requestErr != nil {
  14640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14641. return
  14642. }
  14643. body, ioErr := ioutil.ReadAll(resp.Body)
  14644. if ioErr != nil {
  14645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14647. return
  14648. }
  14649. var respJSON map[string]interface{}
  14650. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14653. return
  14654. }
  14655. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14656. result, _ := json.Marshal(respJSON)
  14657. fmt.Println("log")
  14658. fmt.Println(string(result))
  14659. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14660. utils.ErrorLog("解析失败:%v", err)
  14661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14662. return
  14663. }
  14664. if res.Infcode == 0 {
  14665. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14666. if err == gorm.ErrRecordNotFound {
  14667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14668. return
  14669. } else if err != nil {
  14670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14671. return
  14672. } else {
  14673. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14674. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14675. infoStr := string(Iinfos)
  14676. idetinfoStr := string(Idetinfos)
  14677. var rf []*ResultFive
  14678. json.Unmarshal([]byte(infoStr), &rf)
  14679. var insutypes []*ResultFive
  14680. var insutype string
  14681. var is390 int = 0
  14682. var is310 int = 0
  14683. for _, item := range rf {
  14684. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14685. insutypes = append(insutypes, item)
  14686. }
  14687. }
  14688. if len(insutypes) == 1 {
  14689. insutype = insutypes[0].Insutype
  14690. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14691. } else {
  14692. for _, i := range insutypes {
  14693. if i.Insutype == "390" {
  14694. is390 = 1
  14695. }
  14696. if i.Insutype == "310" {
  14697. is310 = 1
  14698. }
  14699. }
  14700. }
  14701. if is390 == 1 {
  14702. insutype = "390"
  14703. }
  14704. if is310 == 1 {
  14705. insutype = "310"
  14706. }
  14707. if len(insutypes) == 0 {
  14708. insutype = "390"
  14709. }
  14710. var insuplc_admdvs string
  14711. for _, item := range rf {
  14712. if item.Insutype == insutype {
  14713. insuplc_admdvs = item.InsuplcAdmdvs
  14714. }
  14715. }
  14716. psn := &models.HisPsn{
  14717. PsnNo: res.Output.Baseinfo.PsnNo,
  14718. PatientId: patient.ID,
  14719. Certno: res.Output.Baseinfo.Certno,
  14720. Gend: res.Output.Baseinfo.Gend,
  14721. Naty: res.Output.Baseinfo.Naty,
  14722. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14723. PsnName: res.Output.Baseinfo.PsnName,
  14724. Idetinfo: idetinfoStr,
  14725. Insuinfo: infoStr,
  14726. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14727. InsuplcAdmdvs: insuplc_admdvs,
  14728. }
  14729. service.CreateHisPsn(psn)
  14730. c.ServeSuccessJSON(map[string]interface{}{
  14731. "patient": patient,
  14732. "number": res.Output.Baseinfo.Certno,
  14733. })
  14734. }
  14735. } else {
  14736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14737. return
  14738. }
  14739. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14740. res := c.GetoleInfo()
  14741. if res.Infcode == 0 {
  14742. var result string
  14743. if res.Output.MdtrtCertType == "01" {
  14744. 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)
  14745. } else if res.Output.MdtrtCertType == "02" {
  14746. 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)
  14747. } else if res.Output.MdtrtCertType == "03" {
  14748. 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)
  14749. }
  14750. var dat map[string]interface{}
  14751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14752. fmt.Println(dat)
  14753. } else {
  14754. fmt.Println(err)
  14755. }
  14756. userJSONBytes, _ := json.Marshal(dat)
  14757. var res2 ResultTwo
  14758. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14759. utils.ErrorLog("解析失败:%v", err)
  14760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14761. return
  14762. }
  14763. if res2.Infcode == 0 {
  14764. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14765. if err == gorm.ErrRecordNotFound {
  14766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14767. return
  14768. } else if err != nil {
  14769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14770. return
  14771. } else {
  14772. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14773. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14774. infoStr := string(Iinfos)
  14775. idetinfoStr := string(Idetinfos)
  14776. var rf []*ResultFive
  14777. json.Unmarshal([]byte(infoStr), &rf)
  14778. var insutypes []*ResultFive
  14779. var insutype string
  14780. var is390 int = 0
  14781. var is310 int = 0
  14782. //var insuplc_admdvs string
  14783. for _, item := range rf {
  14784. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14785. insutypes = append(insutypes, item)
  14786. }
  14787. }
  14788. if len(insutypes) == 1 {
  14789. insutype = insutypes[0].Insutype
  14790. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14791. } else {
  14792. for _, i := range insutypes {
  14793. if i.Insutype == "390" {
  14794. is390 = 1
  14795. }
  14796. if i.Insutype == "310" {
  14797. is310 = 1
  14798. }
  14799. }
  14800. }
  14801. if is390 == 1 {
  14802. insutype = "390"
  14803. }
  14804. if is310 == 1 {
  14805. insutype = "310"
  14806. }
  14807. if len(insutypes) == 0 {
  14808. insutype = "310"
  14809. }
  14810. psn := &models.HisPsn{
  14811. PsnNo: res2.Output.Baseinfo.PsnNo,
  14812. PatientId: patient.ID,
  14813. //Brdy: res2.Output.Baseinfo.Brdy,
  14814. Certno: res2.Output.Baseinfo.Certno,
  14815. Gend: res2.Output.Baseinfo.Gend,
  14816. Naty: res2.Output.Baseinfo.Naty,
  14817. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14818. PsnName: res2.Output.Baseinfo.PsnName,
  14819. Idetinfo: idetinfoStr,
  14820. Insuinfo: infoStr,
  14821. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14822. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14823. VerifyNumber: res.Output.EcToken,
  14824. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14825. }
  14826. service.CreateHisPsn(psn)
  14827. var balc float64
  14828. for _, item := range rf {
  14829. if item.Insutype == insutype {
  14830. balc = item.Balc
  14831. }
  14832. }
  14833. c.ServeSuccessJSON(map[string]interface{}{
  14834. "patient": patient,
  14835. "number": res.Output.CardNo,
  14836. "insutype": insutype,
  14837. "blac": balc,
  14838. "desc": idetinfoStr,
  14839. })
  14840. }
  14841. } else {
  14842. c.ServeSuccessJSON(map[string]interface{}{
  14843. "failed_code": -10,
  14844. "msg": res2.ErrMsg,
  14845. })
  14846. }
  14847. } else {
  14848. c.ServeSuccessJSON(map[string]interface{}{
  14849. "failed_code": -10,
  14850. "msg": res.ErrMsg,
  14851. })
  14852. }
  14853. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14854. var insuplc_admdvs string
  14855. if len(patient.InsuplcAdmdvs) > 0 {
  14856. insuplc_admdvs = patient.InsuplcAdmdvs
  14857. } else {
  14858. if len(insuplc_admdvs_str) > 0 {
  14859. insuplc_admdvs = insuplc_admdvs_str
  14860. } else {
  14861. insuplc_admdvs = miConfig.InsuplcAdmdvs
  14862. }
  14863. }
  14864. //请求内网数据
  14865. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  14866. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14867. "&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=" + ""
  14868. resp, requestErr := http.Get(api)
  14869. if requestErr != nil {
  14870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14871. return
  14872. }
  14873. body, ioErr := ioutil.ReadAll(resp.Body)
  14874. if ioErr != nil {
  14875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14877. return
  14878. }
  14879. var respJSON map[string]interface{}
  14880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14883. return
  14884. }
  14885. status := respJSON["data"].(map[string]interface{})["status"].(string)
  14886. if status == "0" {
  14887. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  14888. c.ServeSuccessJSON(map[string]interface{}{
  14889. "failed_code": -10,
  14890. "msg": err_msg,
  14891. })
  14892. return
  14893. }
  14894. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14895. var res ResultTwo
  14896. result, _ := json.Marshal(respJSON)
  14897. fmt.Println("log")
  14898. fmt.Println(string(result))
  14899. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14900. utils.ErrorLog("解析失败:%v", err)
  14901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14902. return
  14903. }
  14904. if res.Infcode == 0 {
  14905. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14906. if err == gorm.ErrRecordNotFound {
  14907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14908. return
  14909. } else if err != nil {
  14910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14911. return
  14912. } else {
  14913. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14914. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14915. infoStr := string(Iinfos)
  14916. idetinfoStr := string(Idetinfos)
  14917. psn := &models.HisPsn{
  14918. PsnNo: res.Output.Baseinfo.PsnNo,
  14919. PatientId: patient.ID,
  14920. Certno: res.Output.Baseinfo.Certno,
  14921. Gend: res.Output.Baseinfo.Gend,
  14922. Naty: res.Output.Baseinfo.Naty,
  14923. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14924. PsnName: res.Output.Baseinfo.PsnName,
  14925. Idetinfo: idetinfoStr,
  14926. Insuinfo: infoStr,
  14927. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14928. }
  14929. service.CreateHisPsn(psn)
  14930. var rf []*ResultFive
  14931. json.Unmarshal([]byte(infoStr), &rf)
  14932. var insutypes []*ResultFive
  14933. var is390 int = 0
  14934. var is310 int = 0
  14935. var insutype string
  14936. for _, item := range rf {
  14937. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14938. insutypes = append(insutypes, item)
  14939. }
  14940. }
  14941. if len(insutypes) == 1 {
  14942. insutype = insutypes[0].Insutype
  14943. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14944. } else {
  14945. for _, i := range insutypes {
  14946. if i.Insutype == "390" {
  14947. is390 = 1
  14948. }
  14949. if i.Insutype == "310" {
  14950. is310 = 1
  14951. }
  14952. }
  14953. }
  14954. if is390 == 1 {
  14955. insutype = "390"
  14956. }
  14957. if is310 == 1 {
  14958. insutype = "310"
  14959. }
  14960. if len(insutypes) == 0 {
  14961. insutype = "390"
  14962. }
  14963. c.ServeSuccessJSON(map[string]interface{}{
  14964. "patient": patient,
  14965. "insutype": insutype,
  14966. "number": res.Output.Baseinfo.Certno,
  14967. "info": res,
  14968. })
  14969. }
  14970. } else {
  14971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14972. return
  14973. }
  14974. } else {
  14975. SFZStr := c.GetSFZBaseInfo()
  14976. id_card_str := strings.Split(SFZStr, "^")
  14977. id_card_number := id_card_str[0]
  14978. card_sn := ""
  14979. 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)
  14980. var dat map[string]interface{}
  14981. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14982. fmt.Println(dat)
  14983. } else {
  14984. fmt.Println(err)
  14985. }
  14986. userJSONBytes, _ := json.Marshal(dat)
  14987. var res ResultTwo
  14988. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14989. utils.ErrorLog("解析失败:%v", err)
  14990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14991. return
  14992. }
  14993. if res.Infcode == 0 {
  14994. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  14995. if err == gorm.ErrRecordNotFound {
  14996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14997. return
  14998. } else if err != nil {
  14999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15000. return
  15001. } else {
  15002. c.ServeSuccessJSON(map[string]interface{}{
  15003. "patient": patient,
  15004. "number": id_card_number,
  15005. })
  15006. }
  15007. } else {
  15008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15009. return
  15010. }
  15011. }
  15012. break
  15013. case 3:
  15014. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15015. var api string
  15016. if miConfig.MdtrtareaAdmvs == "320921" {
  15017. 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 +
  15018. "&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
  15019. fmt.Println(api)
  15020. } else {
  15021. 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 +
  15022. "&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)
  15023. }
  15024. resp, requestErr := http.Get(api)
  15025. if requestErr != nil {
  15026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15027. return
  15028. }
  15029. body, ioErr := ioutil.ReadAll(resp.Body)
  15030. if ioErr != nil {
  15031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15033. return
  15034. }
  15035. var respJSON map[string]interface{}
  15036. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15039. return
  15040. }
  15041. var status string
  15042. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15043. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15044. var token string
  15045. var res ResultTwo //1101结果
  15046. var res10265 ResultTwo10265 //1101结果
  15047. var card_info string //卡信息
  15048. var busi_card_info string
  15049. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15050. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15051. if status == "0" { //读卡成功
  15052. if card_type == "1" {
  15053. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15054. result, _ := json.Marshal(respJSON)
  15055. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15056. utils.ErrorLog("解析失败:%v", err)
  15057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15058. return
  15059. }
  15060. res.ErrMsg = res10265.ErrMsg
  15061. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15062. res.Infcode = infocode
  15063. res.Output = res10265.Output
  15064. res.InfRefmsgid = res10265.InfRefmsgid
  15065. } else {
  15066. //var card_info string //卡信息
  15067. //var busi_card_info string
  15068. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15069. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15070. //fmt.Println(card_info)
  15071. //fmt.Println(busi_card_info)
  15072. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15073. result, _ := json.Marshal(respJSON)
  15074. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15075. utils.ErrorLog("解析失败:%v", err)
  15076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15077. return
  15078. }
  15079. res.ErrMsg = res10265.ErrMsg
  15080. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15081. res.Infcode = infocode
  15082. res.Output = res10265.Output
  15083. res.InfRefmsgid = res10265.InfRefmsgid
  15084. }
  15085. if res.Infcode == 0 {
  15086. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15087. if err == gorm.ErrRecordNotFound {
  15088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15089. return
  15090. } else if err != nil {
  15091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15092. return
  15093. } else {
  15094. if card_type == "1" {
  15095. bas := strings.Split(card_info, "|")
  15096. basNumber := bas[2]
  15097. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15098. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15099. infoStr := string(Iinfos)
  15100. idetinfoStr := string(Idetinfos)
  15101. psn := &models.HisPsn{
  15102. PsnNo: res.Output.Baseinfo.PsnNo,
  15103. PatientId: patient.ID,
  15104. Certno: res.Output.Baseinfo.Certno,
  15105. //Brdy: res.Output.Baseinfo.Brdy,
  15106. Gend: res.Output.Baseinfo.Gend,
  15107. Naty: res.Output.Baseinfo.Naty,
  15108. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15109. PsnName: res.Output.Baseinfo.PsnName,
  15110. Idetinfo: idetinfoStr,
  15111. Insuinfo: infoStr,
  15112. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15113. CardInfo: card_info,
  15114. VerifyNumber: busi_card_info,
  15115. }
  15116. service.CreateHisPsn(psn)
  15117. c.ServeSuccessJSON(map[string]interface{}{
  15118. "patient": patient,
  15119. "number": basNumber,
  15120. })
  15121. } else {
  15122. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15123. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15124. infoStr := string(Iinfos)
  15125. idetinfoStr := string(Idetinfos)
  15126. psn := &models.HisPsn{
  15127. PsnNo: res.Output.Baseinfo.PsnNo,
  15128. PatientId: patient.ID,
  15129. Certno: res.Output.Baseinfo.Certno,
  15130. Gend: res.Output.Baseinfo.Gend,
  15131. Naty: res.Output.Baseinfo.Naty,
  15132. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15133. PsnName: res.Output.Baseinfo.PsnName,
  15134. Idetinfo: idetinfoStr,
  15135. Insuinfo: infoStr,
  15136. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15137. CardInfo: card_info,
  15138. VerifyNumber: token,
  15139. }
  15140. service.CreateHisPsn(psn)
  15141. var rf []*ResultFive
  15142. json.Unmarshal([]byte(infoStr), &rf)
  15143. var insutypes []*ResultFive
  15144. var insutype string
  15145. var is390 int = 0
  15146. var is310 int = 0
  15147. for _, item := range rf {
  15148. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15149. insutypes = append(insutypes, item)
  15150. }
  15151. }
  15152. if len(insutypes) == 1 {
  15153. insutype = insutypes[0].Insutype
  15154. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15155. } else {
  15156. for _, i := range insutypes {
  15157. if i.Insutype == "390" {
  15158. is390 = 1
  15159. }
  15160. if i.Insutype == "310" {
  15161. is310 = 1
  15162. }
  15163. }
  15164. }
  15165. if is390 == 1 {
  15166. insutype = "390"
  15167. }
  15168. if is310 == 1 {
  15169. insutype = "310"
  15170. }
  15171. if len(insutypes) == 0 {
  15172. insutype = "310"
  15173. }
  15174. c.ServeSuccessJSON(map[string]interface{}{
  15175. "patient": patient,
  15176. "number": token,
  15177. "insutype": insutype,
  15178. })
  15179. }
  15180. }
  15181. } else {
  15182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15183. return
  15184. }
  15185. } else { //读卡失败
  15186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15187. return
  15188. }
  15189. }
  15190. break
  15191. case 4:
  15192. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15193. var api string
  15194. if miConfig.MdtrtareaAdmvs == "320921" {
  15195. 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 +
  15196. "&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
  15197. fmt.Println(api)
  15198. } else {
  15199. 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 +
  15200. "&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)
  15201. }
  15202. resp, requestErr := http.Get(api)
  15203. if requestErr != nil {
  15204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15205. return
  15206. }
  15207. body, ioErr := ioutil.ReadAll(resp.Body)
  15208. if ioErr != nil {
  15209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15211. return
  15212. }
  15213. var respJSON map[string]interface{}
  15214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15217. return
  15218. }
  15219. var status string
  15220. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15221. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15222. var token string
  15223. var res ResultTwo //1101结果
  15224. var res10265 ResultTwo10265 //1101结果
  15225. if status == "0" { //读卡成功
  15226. var card_info string //卡信息
  15227. var busi_card_info string
  15228. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15229. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15230. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15231. fmt.Println(card_info)
  15232. fmt.Println(busi_card_info)
  15233. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15234. result, _ := json.Marshal(respJSON)
  15235. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15236. utils.ErrorLog("解析失败:%v", err)
  15237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15238. return
  15239. }
  15240. res.ErrMsg = res10265.ErrMsg
  15241. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15242. res.Infcode = infocode
  15243. res.Output = res10265.Output
  15244. res.InfRefmsgid = res10265.InfRefmsgid
  15245. if res.Infcode == 0 {
  15246. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15247. if err == gorm.ErrRecordNotFound {
  15248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15249. return
  15250. } else if err != nil {
  15251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15252. return
  15253. } else {
  15254. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15255. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15256. infoStr := string(Iinfos)
  15257. idetinfoStr := string(Idetinfos)
  15258. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15259. psn := &models.HisPsn{
  15260. PsnNo: res.Output.Baseinfo.PsnNo,
  15261. PatientId: patient.ID,
  15262. Certno: res.Output.Baseinfo.Certno,
  15263. Brdy: b,
  15264. Age: float64(age),
  15265. //Brdy: res.Output.Baseinfo.Brdy,
  15266. Gend: res.Output.Baseinfo.Gend,
  15267. Naty: res.Output.Baseinfo.Naty,
  15268. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15269. PsnName: res.Output.Baseinfo.PsnName,
  15270. Idetinfo: idetinfoStr,
  15271. Insuinfo: infoStr,
  15272. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15273. CardInfo: card_info,
  15274. VerifyNumber: token,
  15275. }
  15276. var rf []*ResultFive
  15277. json.Unmarshal([]byte(infoStr), &rf)
  15278. var insutypes []*ResultFive
  15279. var insutype string
  15280. var is390 int = 0
  15281. var is310 int = 0
  15282. for _, item := range rf {
  15283. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15284. insutypes = append(insutypes, item)
  15285. }
  15286. }
  15287. if len(insutypes) == 1 {
  15288. insutype = insutypes[0].Insutype
  15289. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15290. } else {
  15291. for _, i := range insutypes {
  15292. if i.Insutype == "390" {
  15293. is390 = 1
  15294. }
  15295. if i.Insutype == "310" {
  15296. is310 = 1
  15297. }
  15298. }
  15299. }
  15300. if is390 == 1 {
  15301. insutype = "390"
  15302. }
  15303. if is310 == 1 {
  15304. insutype = "310"
  15305. }
  15306. if len(insutypes) == 0 {
  15307. insutype = "310"
  15308. }
  15309. service.CreateHisPsn(psn)
  15310. c.ServeSuccessJSON(map[string]interface{}{
  15311. "patient": patient,
  15312. "number": token,
  15313. "insutype": insutype,
  15314. })
  15315. }
  15316. } else {
  15317. c.ServeSuccessJSON(map[string]interface{}{
  15318. "failed_code": -10,
  15319. "msg": res.ErrMsg,
  15320. })
  15321. }
  15322. } else { //读卡失败
  15323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15324. return
  15325. }
  15326. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15327. var api string
  15328. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15329. "&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
  15330. resp, requestErr := http.Get(api)
  15331. if requestErr != nil {
  15332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15333. return
  15334. }
  15335. body, ioErr := ioutil.ReadAll(resp.Body)
  15336. if ioErr != nil {
  15337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15339. return
  15340. }
  15341. var respJSON map[string]interface{}
  15342. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15345. return
  15346. }
  15347. var status string
  15348. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15349. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15350. var token string
  15351. var res ResultTwo //1101结果
  15352. if status == "1" { //读卡成功
  15353. var card_info string //卡信息
  15354. var busi_card_info string
  15355. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15356. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15357. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15358. fmt.Println(card_info)
  15359. fmt.Println(busi_card_info)
  15360. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15361. result, _ := json.Marshal(respJSON)
  15362. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15363. utils.ErrorLog("解析失败:%v", err)
  15364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15365. return
  15366. }
  15367. if res.Infcode == 0 {
  15368. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15369. if err == gorm.ErrRecordNotFound {
  15370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15371. return
  15372. } else if err != nil {
  15373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15374. return
  15375. } else {
  15376. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15377. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15378. infoStr := string(Iinfos)
  15379. idetinfoStr := string(Idetinfos)
  15380. psn := &models.HisPsn{
  15381. PsnNo: res.Output.Baseinfo.PsnNo,
  15382. PatientId: patient.ID,
  15383. Certno: res.Output.Baseinfo.Certno,
  15384. Gend: res.Output.Baseinfo.Gend,
  15385. Naty: res.Output.Baseinfo.Naty,
  15386. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15387. PsnName: res.Output.Baseinfo.PsnName,
  15388. Idetinfo: idetinfoStr,
  15389. Insuinfo: infoStr,
  15390. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15391. CardInfo: card_info,
  15392. VerifyNumber: token,
  15393. }
  15394. var rf []*ResultFive
  15395. json.Unmarshal([]byte(infoStr), &rf)
  15396. var insutypes []*ResultFive
  15397. var insutype string
  15398. var is390 int = 0
  15399. var is310 int = 0
  15400. for _, item := range rf {
  15401. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15402. insutypes = append(insutypes, item)
  15403. }
  15404. }
  15405. if len(insutypes) == 1 {
  15406. insutype = insutypes[0].Insutype
  15407. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15408. } else {
  15409. for _, i := range insutypes {
  15410. if i.Insutype == "390" {
  15411. is390 = 1
  15412. }
  15413. if i.Insutype == "310" {
  15414. is310 = 1
  15415. }
  15416. }
  15417. }
  15418. if is390 == 1 {
  15419. insutype = "390"
  15420. }
  15421. if is310 == 1 {
  15422. insutype = "310"
  15423. }
  15424. if len(insutypes) == 0 {
  15425. insutype = "310"
  15426. }
  15427. service.CreateHisPsn(psn)
  15428. c.ServeSuccessJSON(map[string]interface{}{
  15429. "patient": patient,
  15430. "number": token,
  15431. "insutype": insutype,
  15432. })
  15433. }
  15434. } else {
  15435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15436. return
  15437. }
  15438. } else { //读卡失败
  15439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15440. return
  15441. }
  15442. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15443. var api string
  15444. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15445. "&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
  15446. resp, requestErr := http.Get(api)
  15447. if requestErr != nil {
  15448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15449. return
  15450. }
  15451. body, ioErr := ioutil.ReadAll(resp.Body)
  15452. if ioErr != nil {
  15453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15455. return
  15456. }
  15457. var respJSON map[string]interface{}
  15458. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15461. return
  15462. }
  15463. var status string
  15464. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15465. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15466. var token string
  15467. var res ResultTwo //1101结果
  15468. if status == "1" { //读卡成功
  15469. var card_info string //卡信息
  15470. var busi_card_info string
  15471. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15472. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15473. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15474. fmt.Println(card_info)
  15475. fmt.Println(busi_card_info)
  15476. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15477. result, _ := json.Marshal(respJSON)
  15478. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15479. utils.ErrorLog("解析失败:%v", err)
  15480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15481. return
  15482. }
  15483. if res.Infcode == 0 {
  15484. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15485. if err == gorm.ErrRecordNotFound {
  15486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15487. return
  15488. } else if err != nil {
  15489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15490. return
  15491. } else {
  15492. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15493. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15494. infoStr := string(Iinfos)
  15495. idetinfoStr := string(Idetinfos)
  15496. psn := &models.HisPsn{
  15497. PsnNo: res.Output.Baseinfo.PsnNo,
  15498. PatientId: patient.ID,
  15499. Certno: res.Output.Baseinfo.Certno,
  15500. Gend: res.Output.Baseinfo.Gend,
  15501. Naty: res.Output.Baseinfo.Naty,
  15502. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15503. PsnName: res.Output.Baseinfo.PsnName,
  15504. Idetinfo: idetinfoStr,
  15505. Insuinfo: infoStr,
  15506. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15507. CardInfo: card_info,
  15508. VerifyNumber: token,
  15509. }
  15510. var rf []*ResultFive
  15511. json.Unmarshal([]byte(infoStr), &rf)
  15512. var insutypes []*ResultFive
  15513. var insutype string
  15514. var is390 int = 0
  15515. var is310 int = 0
  15516. for _, item := range rf {
  15517. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15518. insutypes = append(insutypes, item)
  15519. }
  15520. }
  15521. if len(insutypes) == 1 {
  15522. insutype = insutypes[0].Insutype
  15523. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15524. } else {
  15525. for _, i := range insutypes {
  15526. if i.Insutype == "390" {
  15527. is390 = 1
  15528. }
  15529. if i.Insutype == "310" {
  15530. is310 = 1
  15531. }
  15532. }
  15533. }
  15534. if is390 == 1 {
  15535. insutype = "390"
  15536. }
  15537. if is310 == 1 {
  15538. insutype = "310"
  15539. }
  15540. if len(insutypes) == 0 {
  15541. insutype = "310"
  15542. }
  15543. service.CreateHisPsn(psn)
  15544. c.ServeSuccessJSON(map[string]interface{}{
  15545. "patient": patient,
  15546. "number": token,
  15547. "insutype": insutype,
  15548. })
  15549. }
  15550. } else {
  15551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15552. return
  15553. }
  15554. } else { //读卡失败
  15555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15556. return
  15557. }
  15558. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15559. //idNo := c.GetString("idNo")
  15560. //userName := c.GetString("userName")
  15561. //ecToken := c.GetString("ecToken")
  15562. //insuOrg := c.GetString("insuOrg")
  15563. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15564. utils.ErrorLog("解析失败:%v", json_result)
  15565. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15566. type ELeData struct {
  15567. Data struct {
  15568. IdNo string `json:"idNo"`
  15569. IdType string `json:"idType"`
  15570. UserName string `json:"userName"`
  15571. EcToken string `json:"ecToken"`
  15572. InsuOrg string `json:"insuOrg"`
  15573. Gender string `json:"gender"`
  15574. Birthday string `json:"birthday"`
  15575. Nationality string `json:"nationality"`
  15576. Email string `json:"email"`
  15577. Extra string `json:"extra"`
  15578. } `json:"data"`
  15579. Code int `json:"code"`
  15580. Message string `json:"message"`
  15581. }
  15582. var ele ELeData
  15583. err := json.Unmarshal([]byte(json_result), &ele)
  15584. if err != nil {
  15585. utils.ErrorLog("解析失败:%v", err)
  15586. }
  15587. token := ele.Data.EcToken
  15588. token = Remove0000(token)
  15589. 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)
  15590. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15591. var res ResultTwo
  15592. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15593. utils.ErrorLog("解析失败:%v", err)
  15594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15595. return
  15596. }
  15597. if res.Infcode == 0 {
  15598. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15599. if err == gorm.ErrRecordNotFound {
  15600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15601. return
  15602. } else if err != nil {
  15603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15604. return
  15605. } else {
  15606. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15607. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15608. infoStr := string(Iinfos)
  15609. idetinfoStr := string(Idetinfos)
  15610. psn := &models.HisPsn{
  15611. PsnNo: res.Output.Baseinfo.PsnNo,
  15612. PatientId: patient.ID,
  15613. Certno: res.Output.Baseinfo.Certno,
  15614. Gend: res.Output.Baseinfo.Gend,
  15615. Naty: res.Output.Baseinfo.Naty,
  15616. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15617. PsnName: res.Output.Baseinfo.PsnName,
  15618. Idetinfo: idetinfoStr,
  15619. Insuinfo: infoStr,
  15620. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15621. CardInfo: "",
  15622. Stage: "1",
  15623. VerifyNumber: token,
  15624. InsuplcAdmdvs: ele.Data.InsuOrg,
  15625. }
  15626. service.CreateHisPsn(psn)
  15627. var rf []*ResultFive
  15628. json.Unmarshal([]byte(infoStr), &rf)
  15629. var insutypes []*ResultFive
  15630. var insutype string
  15631. var is390 int = 0
  15632. var is310 int = 0
  15633. for _, item := range rf {
  15634. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15635. insutypes = append(insutypes, item)
  15636. }
  15637. }
  15638. if len(insutypes) == 1 {
  15639. insutype = insutypes[0].Insutype
  15640. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15641. } else {
  15642. for _, i := range insutypes {
  15643. if i.Insutype == "390" {
  15644. is390 = 1
  15645. }
  15646. if i.Insutype == "310" {
  15647. is310 = 1
  15648. }
  15649. }
  15650. }
  15651. if is390 == 1 {
  15652. insutype = "390"
  15653. }
  15654. if is310 == 1 {
  15655. insutype = "310"
  15656. }
  15657. if len(insutypes) == 0 {
  15658. insutype = "310"
  15659. }
  15660. c.ServeSuccessJSON(map[string]interface{}{
  15661. "patient": patient,
  15662. "number": token,
  15663. "insutype": insutype,
  15664. })
  15665. }
  15666. } else {
  15667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15668. return
  15669. }
  15670. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15671. //if initFlag == 0 {
  15672. //c.TestGetJiangXiBasBaseInit()
  15673. //}
  15674. //if initEleFlag == 0 {
  15675. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15676. //}
  15677. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15678. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15679. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15680. type ELeData struct {
  15681. Data struct {
  15682. IdNo string `json:"idNo"`
  15683. IdType string `json:"idType"`
  15684. UserName string `json:"userName"`
  15685. EcToken string `json:"ecToken"`
  15686. InsuOrg string `json:"insuOrg"`
  15687. Gender string `json:"gender"`
  15688. Birthday string `json:"birthday"`
  15689. Nationality string `json:"nationality"`
  15690. Email string `json:"email"`
  15691. Extra string `json:"extra"`
  15692. } `json:"data"`
  15693. Code int `json:"code"`
  15694. Message string `json:"message"`
  15695. }
  15696. var ele ELeData
  15697. err := json.Unmarshal([]byte(result), &ele)
  15698. if err != nil {
  15699. utils.ErrorLog("解析失败:%v", err)
  15700. }
  15701. token := ele.Data.EcToken
  15702. token = Remove0000(token)
  15703. 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)
  15704. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15705. var res ResultTwo
  15706. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15707. utils.ErrorLog("解析失败:%v", err)
  15708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15709. return
  15710. }
  15711. if res.Infcode == 0 {
  15712. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15713. if err == gorm.ErrRecordNotFound {
  15714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15715. return
  15716. } else if err != nil {
  15717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15718. return
  15719. } else {
  15720. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15721. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15722. infoStr := string(Iinfos)
  15723. idetinfoStr := string(Idetinfos)
  15724. psn := &models.HisPsn{
  15725. PsnNo: res.Output.Baseinfo.PsnNo,
  15726. PatientId: patient.ID,
  15727. Certno: res.Output.Baseinfo.Certno,
  15728. Gend: res.Output.Baseinfo.Gend,
  15729. Naty: res.Output.Baseinfo.Naty,
  15730. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15731. PsnName: res.Output.Baseinfo.PsnName,
  15732. Idetinfo: idetinfoStr,
  15733. Insuinfo: infoStr,
  15734. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15735. CardInfo: "",
  15736. VerifyNumber: token,
  15737. InsuplcAdmdvs: ele.Data.InsuOrg,
  15738. }
  15739. service.CreateHisPsn(psn)
  15740. var rf []*ResultFive
  15741. json.Unmarshal([]byte(infoStr), &rf)
  15742. var insutypes []*ResultFive
  15743. var insutype string
  15744. var is390 int = 0
  15745. var is310 int = 0
  15746. for _, item := range rf {
  15747. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15748. insutypes = append(insutypes, item)
  15749. }
  15750. }
  15751. if len(insutypes) == 1 {
  15752. insutype = insutypes[0].Insutype
  15753. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15754. } else {
  15755. for _, i := range insutypes {
  15756. if i.Insutype == "390" {
  15757. is390 = 1
  15758. }
  15759. if i.Insutype == "310" {
  15760. is310 = 1
  15761. }
  15762. }
  15763. }
  15764. if is390 == 1 {
  15765. insutype = "390"
  15766. }
  15767. if is310 == 1 {
  15768. insutype = "310"
  15769. }
  15770. if len(insutypes) == 0 {
  15771. insutype = "310"
  15772. }
  15773. c.ServeSuccessJSON(map[string]interface{}{
  15774. "patient": patient,
  15775. "number": token,
  15776. "insutype": insutype,
  15777. })
  15778. }
  15779. } else {
  15780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15781. return
  15782. }
  15783. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15784. //if initFlag == 0 {
  15785. //c.TestGetJiangXiBasBaseInit()
  15786. //}
  15787. //if initEleFlag == 0 {
  15788. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15789. //}
  15790. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15791. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15792. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15793. type ELeData struct {
  15794. Data struct {
  15795. IdNo string `json:"idNo"`
  15796. IdType string `json:"idType"`
  15797. UserName string `json:"userName"`
  15798. EcToken string `json:"ecToken"`
  15799. InsuOrg string `json:"insuOrg"`
  15800. Gender string `json:"gender"`
  15801. Birthday string `json:"birthday"`
  15802. Nationality string `json:"nationality"`
  15803. Email string `json:"email"`
  15804. Extra string `json:"extra"`
  15805. } `json:"data"`
  15806. Code int `json:"code"`
  15807. Message string `json:"message"`
  15808. }
  15809. var ele ELeData
  15810. err := json.Unmarshal([]byte(result), &ele)
  15811. if err != nil {
  15812. utils.ErrorLog("解析失败:%v", err)
  15813. }
  15814. token := ele.Data.EcToken
  15815. token = Remove0000(token)
  15816. 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)
  15817. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15818. var res ResultTwo
  15819. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15820. utils.ErrorLog("解析失败:%v", err)
  15821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15822. return
  15823. }
  15824. if res.Infcode == 0 {
  15825. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15826. if err == gorm.ErrRecordNotFound {
  15827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15828. return
  15829. } else if err != nil {
  15830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15831. return
  15832. } else {
  15833. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15834. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15835. infoStr := string(Iinfos)
  15836. idetinfoStr := string(Idetinfos)
  15837. psn := &models.HisPsn{
  15838. PsnNo: res.Output.Baseinfo.PsnNo,
  15839. PatientId: patient.ID,
  15840. Certno: res.Output.Baseinfo.Certno,
  15841. Gend: res.Output.Baseinfo.Gend,
  15842. Naty: res.Output.Baseinfo.Naty,
  15843. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15844. PsnName: res.Output.Baseinfo.PsnName,
  15845. Idetinfo: idetinfoStr,
  15846. Insuinfo: infoStr,
  15847. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15848. CardInfo: "",
  15849. VerifyNumber: token,
  15850. InsuplcAdmdvs: ele.Data.InsuOrg,
  15851. }
  15852. service.CreateHisPsn(psn)
  15853. var rf []*ResultFive
  15854. json.Unmarshal([]byte(infoStr), &rf)
  15855. var insutypes []*ResultFive
  15856. var insutype string
  15857. var is390 int = 0
  15858. var is310 int = 0
  15859. for _, item := range rf {
  15860. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15861. insutypes = append(insutypes, item)
  15862. }
  15863. }
  15864. if len(insutypes) == 1 {
  15865. insutype = insutypes[0].Insutype
  15866. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15867. } else {
  15868. for _, i := range insutypes {
  15869. if i.Insutype == "390" {
  15870. is390 = 1
  15871. }
  15872. if i.Insutype == "310" {
  15873. is310 = 1
  15874. }
  15875. }
  15876. }
  15877. if is390 == 1 {
  15878. insutype = "390"
  15879. }
  15880. if is310 == 1 {
  15881. insutype = "310"
  15882. }
  15883. if len(insutypes) == 0 {
  15884. insutype = "310"
  15885. }
  15886. c.ServeSuccessJSON(map[string]interface{}{
  15887. "patient": patient,
  15888. "number": token,
  15889. "insutype": insutype,
  15890. })
  15891. }
  15892. } else {
  15893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15894. return
  15895. }
  15896. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15897. //if initFlag == 0 {
  15898. c.TestGetJiangXiBasBaseInit()
  15899. //}
  15900. //if initEleFlag == 0 {
  15901. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15902. //}
  15903. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15904. type ELeData struct {
  15905. Data struct {
  15906. IdNo string `json:"idNo"`
  15907. IdType string `json:"idType"`
  15908. UserName string `json:"userName"`
  15909. EcToken string `json:"ecToken"`
  15910. InsuOrg string `json:"insuOrg"`
  15911. Gender string `json:"gender"`
  15912. Birthday string `json:"birthday"`
  15913. Nationality string `json:"nationality"`
  15914. Email string `json:"email"`
  15915. Extra string `json:"extra"`
  15916. } `json:"data"`
  15917. Code int `json:"code"`
  15918. Message string `json:"message"`
  15919. }
  15920. var ele ELeData
  15921. err := json.Unmarshal([]byte(json_result), &ele)
  15922. if err != nil {
  15923. utils.ErrorLog("解析失败:%v", err)
  15924. }
  15925. token := ele.Data.EcToken
  15926. token = Remove0000(token)
  15927. 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)
  15928. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15929. var res ResultTwo
  15930. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15931. utils.ErrorLog("解析失败:%v", err)
  15932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15933. return
  15934. }
  15935. if res.Infcode == 0 {
  15936. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15937. if err == gorm.ErrRecordNotFound {
  15938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15939. return
  15940. } else if err != nil {
  15941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15942. return
  15943. } else {
  15944. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15945. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15946. infoStr := string(Iinfos)
  15947. idetinfoStr := string(Idetinfos)
  15948. psn := &models.HisPsn{
  15949. PsnNo: res.Output.Baseinfo.PsnNo,
  15950. PatientId: patient.ID,
  15951. Certno: res.Output.Baseinfo.Certno,
  15952. Gend: res.Output.Baseinfo.Gend,
  15953. Naty: res.Output.Baseinfo.Naty,
  15954. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15955. PsnName: res.Output.Baseinfo.PsnName,
  15956. Idetinfo: idetinfoStr,
  15957. Insuinfo: infoStr,
  15958. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15959. CardInfo: "",
  15960. VerifyNumber: token,
  15961. }
  15962. service.CreateHisPsn(psn)
  15963. var rf []*ResultFive
  15964. json.Unmarshal([]byte(infoStr), &rf)
  15965. var insutypes []*ResultFive
  15966. var insutype string
  15967. var is390 int = 0
  15968. var is310 int = 0
  15969. for _, item := range rf {
  15970. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15971. insutypes = append(insutypes, item)
  15972. }
  15973. }
  15974. if len(insutypes) == 1 {
  15975. insutype = insutypes[0].Insutype
  15976. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15977. } else {
  15978. for _, i := range insutypes {
  15979. if i.Insutype == "390" {
  15980. is390 = 1
  15981. }
  15982. if i.Insutype == "310" {
  15983. is310 = 1
  15984. }
  15985. }
  15986. }
  15987. if is390 == 1 {
  15988. insutype = "390"
  15989. }
  15990. if is310 == 1 {
  15991. insutype = "310"
  15992. }
  15993. if len(insutypes) == 0 {
  15994. insutype = "310"
  15995. }
  15996. c.ServeSuccessJSON(map[string]interface{}{
  15997. "patient": patient,
  15998. "number": token,
  15999. "insutype": insutype,
  16000. })
  16001. }
  16002. } else {
  16003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16004. return
  16005. }
  16006. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16007. type ELeData struct {
  16008. Code string `json:"code"`
  16009. Data struct {
  16010. Aac002 string `json:"aac002"`
  16011. Aaz500 string `json:"aaz500"`
  16012. ActCardNo string `json:"actCardNo"`
  16013. Bab520 string `json:"bab520"`
  16014. Bkz543 string `json:"bkz543"`
  16015. BusinessType string `json:"businessType"`
  16016. CertfCodg string `json:"certfCodg"`
  16017. EcIndexNo string `json:"ecIndexNo"`
  16018. EcToken string `json:"ecToken"`
  16019. ID0000 string `json:"id0000"`
  16020. IDNo string `json:"idNo"`
  16021. IDType string `json:"idType"`
  16022. Idcode string `json:"idcode"`
  16023. IdentityToken string `json:"identity_token"`
  16024. InsuOrg string `json:"insuOrg"`
  16025. OfficeID string `json:"officeId"`
  16026. OfficeName string `json:"officeName"`
  16027. OperatorID string `json:"operatorId"`
  16028. OperatorName string `json:"operatorName"`
  16029. OrgID string `json:"orgId"`
  16030. UserName string `json:"userName"`
  16031. } `json:"data"`
  16032. Infno interface{} `json:"infno"`
  16033. Message string `json:"message"`
  16034. OrgID string `json:"orgId"`
  16035. TransType string `json:"transType"`
  16036. }
  16037. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16038. outPutInfo = Remove0000(outPutInfo)
  16039. if len(outPutInfo) > 0 {
  16040. var ele ELeData
  16041. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16042. if err != nil {
  16043. utils.ErrorLog("解析失败:%v", err)
  16044. }
  16045. token := ele.Data.EcToken
  16046. fmt.Println(inputInfo)
  16047. fmt.Println(outPutInfo)
  16048. 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)
  16049. saveLog(result, requestLog, "1101", "获取人员信息")
  16050. var dat map[string]interface{}
  16051. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16052. fmt.Println(dat)
  16053. } else {
  16054. fmt.Println(err)
  16055. }
  16056. userJSONBytes, _ := json.Marshal(dat)
  16057. var res ResultTwo
  16058. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16059. utils.ErrorLog("解析失败:%v", err)
  16060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16061. return
  16062. }
  16063. res.ErrMsg = errMsgLog
  16064. if res.Infcode == 0 {
  16065. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16066. if err == gorm.ErrRecordNotFound {
  16067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16068. return
  16069. } else if err != nil {
  16070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16071. return
  16072. } else {
  16073. fmt.Println(res)
  16074. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16075. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16076. infoStr := string(Iinfos)
  16077. idetinfoStr := string(Idetinfos)
  16078. psn := &models.HisPsn{
  16079. PsnNo: res.Output.Baseinfo.PsnNo,
  16080. PatientId: patient.ID,
  16081. Certno: res.Output.Baseinfo.Certno,
  16082. Gend: res.Output.Baseinfo.Gend,
  16083. Naty: res.Output.Baseinfo.Naty,
  16084. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16085. PsnName: res.Output.Baseinfo.PsnName,
  16086. Idetinfo: idetinfoStr,
  16087. Insuinfo: infoStr,
  16088. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16089. CardInfo: outPutInfo,
  16090. VerifyNumber: token,
  16091. InsuplcAdmdvs: ele.Data.InsuOrg,
  16092. }
  16093. service.CreateHisPsn(psn)
  16094. var rf []*ResultFive
  16095. json.Unmarshal([]byte(infoStr), &rf)
  16096. var insutypes []*ResultFive
  16097. var insutype string
  16098. var is390 int = 0
  16099. var is310 int = 0
  16100. for _, item := range rf {
  16101. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16102. insutypes = append(insutypes, item)
  16103. }
  16104. }
  16105. if len(insutypes) == 1 {
  16106. insutype = insutypes[0].Insutype
  16107. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16108. } else {
  16109. for _, i := range insutypes {
  16110. if i.Insutype == "390" {
  16111. is390 = 1
  16112. }
  16113. if i.Insutype == "310" {
  16114. is310 = 1
  16115. }
  16116. }
  16117. }
  16118. if is390 == 1 {
  16119. insutype = "390"
  16120. }
  16121. if is310 == 1 {
  16122. insutype = "310"
  16123. }
  16124. if len(insutypes) == 0 {
  16125. insutype = "310"
  16126. }
  16127. c.ServeSuccessJSON(map[string]interface{}{
  16128. "patient": patient,
  16129. "number": token,
  16130. "insutype": insutype,
  16131. })
  16132. }
  16133. } else {
  16134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16135. return
  16136. }
  16137. }
  16138. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16139. var api string
  16140. 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 +
  16141. "&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
  16142. resp, requestErr := http.Get(api)
  16143. if requestErr != nil {
  16144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16145. return
  16146. }
  16147. body, ioErr := ioutil.ReadAll(resp.Body)
  16148. if ioErr != nil {
  16149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16151. return
  16152. }
  16153. var respJSON map[string]interface{}
  16154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16157. return
  16158. }
  16159. var status string
  16160. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16161. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16162. var token string
  16163. var res ResultTwo //1101结果
  16164. var res10265 ResultTwo10265 //1101结果
  16165. if status == "0" { //读卡成功
  16166. var card_info string //卡信息
  16167. var busi_card_info string
  16168. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16169. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16170. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16171. fmt.Println(card_info)
  16172. fmt.Println(busi_card_info)
  16173. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16174. result, _ := json.Marshal(respJSON)
  16175. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16176. utils.ErrorLog("解析失败:%v", err)
  16177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16178. return
  16179. }
  16180. res.ErrMsg = res10265.ErrMsg
  16181. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16182. res.Infcode = infocode
  16183. res.Output = res10265.Output
  16184. res.InfRefmsgid = res10265.InfRefmsgid
  16185. if res.Infcode == 0 {
  16186. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16187. if err == gorm.ErrRecordNotFound {
  16188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16189. return
  16190. } else if err != nil {
  16191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16192. return
  16193. } else {
  16194. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16195. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16196. infoStr := string(Iinfos)
  16197. idetinfoStr := string(Idetinfos)
  16198. psn := &models.HisPsn{
  16199. PsnNo: res.Output.Baseinfo.PsnNo,
  16200. PatientId: patient.ID,
  16201. Certno: res.Output.Baseinfo.Certno,
  16202. Gend: res.Output.Baseinfo.Gend,
  16203. Naty: res.Output.Baseinfo.Naty,
  16204. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16205. PsnName: res.Output.Baseinfo.PsnName,
  16206. Idetinfo: idetinfoStr,
  16207. Insuinfo: infoStr,
  16208. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16209. CardInfo: card_info,
  16210. VerifyNumber: token,
  16211. }
  16212. var rf []*ResultFive
  16213. json.Unmarshal([]byte(infoStr), &rf)
  16214. var insutypes []*ResultFive
  16215. var insutype string
  16216. var is390 int = 0
  16217. var is310 int = 0
  16218. for _, item := range rf {
  16219. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16220. insutypes = append(insutypes, item)
  16221. }
  16222. }
  16223. if len(insutypes) == 1 {
  16224. insutype = insutypes[0].Insutype
  16225. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16226. } else {
  16227. for _, i := range insutypes {
  16228. if i.Insutype == "390" {
  16229. is390 = 1
  16230. }
  16231. if i.Insutype == "310" {
  16232. is310 = 1
  16233. }
  16234. }
  16235. }
  16236. if is390 == 1 {
  16237. insutype = "390"
  16238. }
  16239. if is310 == 1 {
  16240. insutype = "310"
  16241. }
  16242. if len(insutypes) == 0 {
  16243. insutype = "310"
  16244. }
  16245. service.CreateHisPsn(psn)
  16246. c.ServeSuccessJSON(map[string]interface{}{
  16247. "patient": patient,
  16248. "number": token,
  16249. "insutype": insutype,
  16250. })
  16251. }
  16252. } else {
  16253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16254. return
  16255. }
  16256. } else { //读卡失败
  16257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16258. return
  16259. }
  16260. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16261. res := c.GetoleInfo()
  16262. if res.Infcode == 0 {
  16263. var result string
  16264. if res.Output.MdtrtCertType == "01" {
  16265. 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)
  16266. } else if res.Output.MdtrtCertType == "02" {
  16267. 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)
  16268. } else if res.Output.MdtrtCertType == "03" {
  16269. 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)
  16270. }
  16271. var dat map[string]interface{}
  16272. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16273. fmt.Println(dat)
  16274. } else {
  16275. fmt.Println(err)
  16276. }
  16277. userJSONBytes, _ := json.Marshal(dat)
  16278. var res2 ResultTwo
  16279. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16280. utils.ErrorLog("解析失败:%v", err)
  16281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16282. return
  16283. }
  16284. if res2.Infcode == 0 {
  16285. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16286. if err == gorm.ErrRecordNotFound {
  16287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16288. return
  16289. } else if err != nil {
  16290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16291. return
  16292. } else {
  16293. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16294. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16295. infoStr := string(Iinfos)
  16296. idetinfoStr := string(Idetinfos)
  16297. var rf []*ResultFive
  16298. json.Unmarshal([]byte(infoStr), &rf)
  16299. var insutypes []*ResultFive
  16300. var insutype string
  16301. var is390 int = 0
  16302. var is310 int = 0
  16303. //var insuplc_admdvs string
  16304. for _, item := range rf {
  16305. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16306. insutypes = append(insutypes, item)
  16307. }
  16308. }
  16309. if len(insutypes) == 1 {
  16310. insutype = insutypes[0].Insutype
  16311. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16312. } else {
  16313. for _, i := range insutypes {
  16314. if i.Insutype == "390" {
  16315. is390 = 1
  16316. }
  16317. if i.Insutype == "310" {
  16318. is310 = 1
  16319. }
  16320. }
  16321. }
  16322. if is390 == 1 {
  16323. insutype = "390"
  16324. }
  16325. if is310 == 1 {
  16326. insutype = "310"
  16327. }
  16328. if len(insutypes) == 0 {
  16329. insutype = "310"
  16330. }
  16331. psn := &models.HisPsn{
  16332. PsnNo: res2.Output.Baseinfo.PsnNo,
  16333. PatientId: patient.ID,
  16334. Certno: res2.Output.Baseinfo.Certno,
  16335. Gend: res2.Output.Baseinfo.Gend,
  16336. Naty: res2.Output.Baseinfo.Naty,
  16337. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16338. PsnName: res2.Output.Baseinfo.PsnName,
  16339. Idetinfo: idetinfoStr,
  16340. Insuinfo: infoStr,
  16341. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16342. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16343. VerifyNumber: res.Output.EcToken,
  16344. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16345. }
  16346. if res.Output.MdtrtCertType == "01" {
  16347. psn.VerifyNumber = res.Output.EcToken
  16348. //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)
  16349. } else if res.Output.MdtrtCertType == "02" {
  16350. psn.VerifyNumber = res.Output.CardNo
  16351. //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)
  16352. } else if res.Output.MdtrtCertType == "03" {
  16353. psn.VerifyNumber = res.Output.MdtrtCertNo
  16354. //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)
  16355. }
  16356. service.CreateHisPsn(psn)
  16357. var balc float64
  16358. for _, item := range rf {
  16359. if item.Insutype == insutype {
  16360. balc = item.Balc
  16361. }
  16362. }
  16363. c.ServeSuccessJSON(map[string]interface{}{
  16364. "patient": patient,
  16365. "number": res.Output.CardNo,
  16366. "insutype": insutype,
  16367. "blac": balc,
  16368. "desc": idetinfoStr,
  16369. })
  16370. }
  16371. } else {
  16372. c.ServeSuccessJSON(map[string]interface{}{
  16373. "failed_code": -10,
  16374. "msg": res2.ErrMsg,
  16375. })
  16376. }
  16377. } else {
  16378. c.ServeSuccessJSON(map[string]interface{}{
  16379. "failed_code": -10,
  16380. "msg": res.ErrMsg,
  16381. })
  16382. }
  16383. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16384. var res ResultTwo
  16385. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16386. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16387. "&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)
  16388. resp, requestErr := http.Get(api)
  16389. if requestErr != nil {
  16390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16391. return
  16392. }
  16393. body, ioErr := ioutil.ReadAll(resp.Body)
  16394. if ioErr != nil {
  16395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16397. return
  16398. }
  16399. var respJSON map[string]interface{}
  16400. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16403. return
  16404. }
  16405. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16406. result, _ := json.Marshal(respJSON)
  16407. fmt.Println("log")
  16408. fmt.Println(string(result))
  16409. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16410. utils.ErrorLog("解析失败:%v", err)
  16411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16412. return
  16413. }
  16414. if res.Infcode == 0 {
  16415. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16416. if err == gorm.ErrRecordNotFound {
  16417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16418. return
  16419. } else if err != nil {
  16420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16421. return
  16422. } else {
  16423. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16424. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16425. infoStr := string(Iinfos)
  16426. idetinfoStr := string(Idetinfos)
  16427. var rf []*ResultFive
  16428. json.Unmarshal([]byte(infoStr), &rf)
  16429. var insutypes []*ResultFive
  16430. var insutype string
  16431. var is390 int = 0
  16432. var is310 int = 0
  16433. for _, item := range rf {
  16434. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16435. insutypes = append(insutypes, item)
  16436. }
  16437. }
  16438. if len(insutypes) == 1 {
  16439. insutype = insutypes[0].Insutype
  16440. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16441. } else {
  16442. for _, i := range insutypes {
  16443. if i.Insutype == "390" {
  16444. is390 = 1
  16445. }
  16446. if i.Insutype == "310" {
  16447. is310 = 1
  16448. }
  16449. }
  16450. }
  16451. if is390 == 1 {
  16452. insutype = "390"
  16453. }
  16454. if is310 == 1 {
  16455. insutype = "310"
  16456. }
  16457. if len(insutypes) == 0 {
  16458. insutype = "390"
  16459. }
  16460. var insuplc_admdvs string
  16461. for _, item := range rf {
  16462. if item.Insutype == insutype {
  16463. insuplc_admdvs = item.InsuplcAdmdvs
  16464. }
  16465. }
  16466. psn := &models.HisPsn{
  16467. PsnNo: res.Output.Baseinfo.PsnNo,
  16468. PatientId: patient.ID,
  16469. Certno: res.Output.Baseinfo.Certno,
  16470. Gend: res.Output.Baseinfo.Gend,
  16471. Naty: res.Output.Baseinfo.Naty,
  16472. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16473. PsnName: res.Output.Baseinfo.PsnName,
  16474. Idetinfo: idetinfoStr,
  16475. Insuinfo: infoStr,
  16476. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16477. InsuplcAdmdvs: insuplc_admdvs,
  16478. }
  16479. service.CreateHisPsn(psn)
  16480. c.ServeSuccessJSON(map[string]interface{}{
  16481. "patient": patient,
  16482. "number": res.Output.Baseinfo.Certno,
  16483. })
  16484. }
  16485. } else {
  16486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16487. return
  16488. }
  16489. } else {
  16490. type ELeData struct {
  16491. Code string `json:"code"`
  16492. Data struct {
  16493. Aac002 string `json:"aac002"`
  16494. Aaz500 string `json:"aaz500"`
  16495. ActCardNo string `json:"actCardNo"`
  16496. Bab520 string `json:"bab520"`
  16497. Bkz543 string `json:"bkz543"`
  16498. BusinessType string `json:"businessType"`
  16499. CertfCodg string `json:"certfCodg"`
  16500. EcIndexNo string `json:"ecIndexNo"`
  16501. EcToken string `json:"ecToken"`
  16502. ID0000 string `json:"id0000"`
  16503. IDNo string `json:"idNo"`
  16504. IDType string `json:"idType"`
  16505. Idcode string `json:"idcode"`
  16506. IdentityToken string `json:"identity_token"`
  16507. InsuOrg string `json:"insuOrg"`
  16508. OfficeID string `json:"officeId"`
  16509. OfficeName string `json:"officeName"`
  16510. OperatorID string `json:"operatorId"`
  16511. OperatorName string `json:"operatorName"`
  16512. OrgID string `json:"orgId"`
  16513. UserName string `json:"userName"`
  16514. } `json:"data"`
  16515. Infno interface{} `json:"infno"`
  16516. Message string `json:"message"`
  16517. OrgID string `json:"orgId"`
  16518. TransType string `json:"transType"`
  16519. }
  16520. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16521. fmt.Println(result)
  16522. outPutInfo := Remove0000(result)
  16523. fmt.Println(outPutInfo)
  16524. if len(outPutInfo) > 0 {
  16525. var ele ELeData
  16526. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16527. if err != nil {
  16528. utils.ErrorLog("解析失败:%v", err)
  16529. }
  16530. token := ele.Data.EcToken
  16531. fmt.Println(outPutInfo)
  16532. 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)
  16533. saveLog(result, requestLog, "1101", "获取人员信息")
  16534. var dat map[string]interface{}
  16535. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16536. fmt.Println(dat)
  16537. } else {
  16538. fmt.Println(err)
  16539. }
  16540. userJSONBytes, _ := json.Marshal(dat)
  16541. var res ResultTwo
  16542. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16543. utils.ErrorLog("解析失败:%v", err)
  16544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16545. return
  16546. }
  16547. if res.Infcode == 0 {
  16548. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16549. if err == gorm.ErrRecordNotFound {
  16550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16551. return
  16552. } else if err != nil {
  16553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16554. return
  16555. } else {
  16556. fmt.Println(res)
  16557. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16558. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16559. infoStr := string(Iinfos)
  16560. idetinfoStr := string(Idetinfos)
  16561. psn := &models.HisPsn{
  16562. PsnNo: res.Output.Baseinfo.PsnNo,
  16563. PatientId: patient.ID,
  16564. Certno: res.Output.Baseinfo.Certno,
  16565. Gend: res.Output.Baseinfo.Gend,
  16566. Naty: res.Output.Baseinfo.Naty,
  16567. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16568. PsnName: res.Output.Baseinfo.PsnName,
  16569. Idetinfo: idetinfoStr,
  16570. Insuinfo: infoStr,
  16571. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16572. CardInfo: outPutInfo,
  16573. VerifyNumber: token,
  16574. InsuplcAdmdvs: ele.Data.InsuOrg,
  16575. }
  16576. service.CreateHisPsn(psn)
  16577. var rf []*ResultFive
  16578. json.Unmarshal([]byte(infoStr), &rf)
  16579. var insutypes []*ResultFive
  16580. var insutype string
  16581. var is390 int = 0
  16582. var is310 int = 0
  16583. for _, item := range rf {
  16584. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16585. insutypes = append(insutypes, item)
  16586. }
  16587. }
  16588. if len(insutypes) == 1 {
  16589. insutype = insutypes[0].Insutype
  16590. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16591. } else {
  16592. for _, i := range insutypes {
  16593. if i.Insutype == "390" {
  16594. is390 = 1
  16595. }
  16596. if i.Insutype == "310" {
  16597. is310 = 1
  16598. }
  16599. }
  16600. }
  16601. if is390 == 1 {
  16602. insutype = "390"
  16603. }
  16604. if is310 == 1 {
  16605. insutype = "310"
  16606. }
  16607. if len(insutypes) == 0 {
  16608. insutype = "310"
  16609. }
  16610. c.ServeSuccessJSON(map[string]interface{}{
  16611. "patient": patient,
  16612. "number": token,
  16613. "insutype": insutype,
  16614. })
  16615. }
  16616. } else {
  16617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16618. return
  16619. }
  16620. }
  16621. //fmt.Println(result)
  16622. //
  16623. //if initFlag == 0 {
  16624. // c.TestGetBasBaseInit()
  16625. //}
  16626. //token := c.GetEleBaseInfo()
  16627. //
  16628. //token = Remove0000(token)
  16629. //
  16630. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16631. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16632. ////
  16633. //var res ResultTwo
  16634. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16635. // utils.ErrorLog("解析失败:%v", err)
  16636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16637. // return
  16638. //}
  16639. //
  16640. //if res.Infcode == 0 {
  16641. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16642. // if err == gorm.ErrRecordNotFound {
  16643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16644. // return
  16645. // } else if err != nil {
  16646. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16647. // return
  16648. //
  16649. // } else {
  16650. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16651. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16652. // infoStr := string(Iinfos)
  16653. // idetinfoStr := string(Idetinfos)
  16654. //
  16655. //
  16656. //
  16657. //
  16658. // var rf []*ResultFive
  16659. // json.Unmarshal([]byte(infoStr), &rf)
  16660. //
  16661. // var insutypes []*ResultFive
  16662. // var insutype string
  16663. // var is390 int = 0
  16664. // var is310 int = 0
  16665. // var insuplc_admdvs string
  16666. //
  16667. // for _, item := range rf {
  16668. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16669. // insutypes = append(insutypes, item)
  16670. // }
  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. //
  16682. // if i.Insutype == "310" {
  16683. // is310 = 1
  16684. // }
  16685. // }
  16686. // }
  16687. // if is390 == 1 {
  16688. // insutype = "390"
  16689. // }
  16690. //
  16691. // if is310 == 1 {
  16692. // insutype = "310"
  16693. // }
  16694. // if len(insutypes) == 0 {
  16695. // insutype = "310"
  16696. // }
  16697. // for _, item := range rf {
  16698. // if item.Insutype == insutype {
  16699. // insuplc_admdvs = item.InsuplcAdmdvs
  16700. // }
  16701. // }
  16702. // psn := &models.HisPsn{
  16703. // PsnNo: res.Output.Baseinfo.PsnNo,
  16704. // Age: res.Output.Baseinfo.Age,
  16705. // PatientId: patient.ID,
  16706. // Certno: res.Output.Baseinfo.Certno,
  16707. // Brdy: res.Output.Baseinfo.Brdy,
  16708. // Gend: res.Output.Baseinfo.Gend,
  16709. // Naty: res.Output.Baseinfo.Naty,
  16710. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16711. // PsnName: res.Output.Baseinfo.PsnName,
  16712. // Idetinfo: idetinfoStr,
  16713. // Insuinfo: infoStr,
  16714. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16715. // CardInfo: "",
  16716. // VerifyNumber: token,
  16717. // InsuplcAdmdvs: insuplc_admdvs,
  16718. // }
  16719. // service.CreateHisPsn(psn)
  16720. //
  16721. // c.ServeSuccessJSON(map[string]interface{}{
  16722. // "patient": patient,
  16723. // "number": token,
  16724. // })
  16725. // }
  16726. //} else {
  16727. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16728. // return
  16729. //}
  16730. }
  16731. break
  16732. case 5:
  16733. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16734. var api string
  16735. if miConfig.MdtrtareaAdmvs == "320921" {
  16736. 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 +
  16737. "&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
  16738. fmt.Println(api)
  16739. } else {
  16740. 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 +
  16741. "&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)
  16742. }
  16743. resp, requestErr := http.Get(api)
  16744. if requestErr != nil {
  16745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16746. return
  16747. }
  16748. body, ioErr := ioutil.ReadAll(resp.Body)
  16749. if ioErr != nil {
  16750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16752. return
  16753. }
  16754. var respJSON map[string]interface{}
  16755. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16758. return
  16759. }
  16760. var status string
  16761. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16762. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16763. var token string
  16764. var res ResultTwo //1101结果
  16765. var res10265 ResultTwo10265 //1101结果
  16766. if status == "0" { //读卡成功
  16767. var card_info string //卡信息
  16768. //var busi_card_info string
  16769. var auth_info string
  16770. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16771. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16772. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16773. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16774. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16775. result, _ := json.Marshal(respJSON)
  16776. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16777. utils.ErrorLog("解析失败:%v", err)
  16778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16779. return
  16780. }
  16781. res.ErrMsg = res10265.ErrMsg
  16782. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16783. res.Infcode = infocode
  16784. res.Output = res10265.Output
  16785. res.InfRefmsgid = res10265.InfRefmsgid
  16786. if res.Infcode == 0 {
  16787. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16788. if err == gorm.ErrRecordNotFound {
  16789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16790. return
  16791. } else if err != nil {
  16792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16793. return
  16794. } else {
  16795. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16796. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16797. infoStr := string(Iinfos)
  16798. idetinfoStr := string(Idetinfos)
  16799. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16800. psn := &models.HisPsn{
  16801. PsnNo: res.Output.Baseinfo.PsnNo,
  16802. PatientId: patient.ID,
  16803. Certno: res.Output.Baseinfo.Certno,
  16804. Gend: res.Output.Baseinfo.Gend,
  16805. Brdy: b,
  16806. Age: float64(age),
  16807. Naty: res.Output.Baseinfo.Naty,
  16808. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16809. PsnName: res.Output.Baseinfo.PsnName,
  16810. Idetinfo: idetinfoStr,
  16811. Insuinfo: infoStr,
  16812. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16813. CardInfo: card_info,
  16814. VerifyNumber: token,
  16815. AuthInfo: auth_info,
  16816. }
  16817. var rf []*ResultFive
  16818. json.Unmarshal([]byte(infoStr), &rf)
  16819. var insutypes []*ResultFive
  16820. var insutype string
  16821. var is390 int = 0
  16822. var is310 int = 0
  16823. for _, item := range rf {
  16824. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16825. insutypes = append(insutypes, item)
  16826. }
  16827. }
  16828. if len(insutypes) == 1 {
  16829. insutype = insutypes[0].Insutype
  16830. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16831. } else {
  16832. for _, i := range insutypes {
  16833. if i.Insutype == "390" {
  16834. is390 = 1
  16835. }
  16836. if i.Insutype == "310" {
  16837. is310 = 1
  16838. }
  16839. }
  16840. }
  16841. if is390 == 1 {
  16842. insutype = "390"
  16843. }
  16844. if is310 == 1 {
  16845. insutype = "310"
  16846. }
  16847. if len(insutypes) == 0 {
  16848. insutype = "310"
  16849. }
  16850. service.CreateHisPsn(psn)
  16851. c.ServeSuccessJSON(map[string]interface{}{
  16852. "patient": patient,
  16853. "number": token,
  16854. "insutype": insutype,
  16855. })
  16856. }
  16857. } else {
  16858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16859. return
  16860. }
  16861. } else { //读卡失败
  16862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16863. return
  16864. }
  16865. }
  16866. break
  16867. }
  16868. }
  16869. var initFlag int64 = 0
  16870. var initEleFlag int64 = 0
  16871. func (c *HisApiController) TestGetBasBaseInit() {
  16872. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16873. Iinit := DllDef.MustFindProc("Init")
  16874. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16875. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  16876. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  16877. if ret != 0 {
  16878. fmt.Println("SSCard的报错原因:", err)
  16879. fmt.Println("SSCard的运算结果为:", ret)
  16880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16881. return
  16882. }
  16883. result := int(ret)
  16884. fmt.Println("SSCard的运算结果为1:", result)
  16885. initFlag = 1
  16886. return
  16887. }
  16888. func (c *HisApiController) HandleJiangXiReadCard() {
  16889. fmt.Println("~~~~~~")
  16890. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16891. admin_user_id, _ := c.GetInt64("admin_user_id")
  16892. id_card_type, _ := c.GetInt64("id_card_type")
  16893. //certificates, _ := c.GetInt64("certificates")
  16894. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16895. if initFlag == 0 {
  16896. c.TestGetJiangXiBasBaseInit()
  16897. }
  16898. basStr := c.GetBasBaseInfo()
  16899. if len(basStr) == 0 {
  16900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16901. return
  16902. }
  16903. fmt.Println(basStr)
  16904. bas := strings.Split(basStr, "|")
  16905. basNumber := bas[1]
  16906. fmt.Println(basNumber)
  16907. card_sn := bas[3]
  16908. fmt.Println(card_sn)
  16909. 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, "")
  16910. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  16911. var dat map[string]interface{}
  16912. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16913. fmt.Println(dat)
  16914. } else {
  16915. fmt.Println(err)
  16916. }
  16917. userJSONBytes, _ := json.Marshal(dat)
  16918. var res ResultTwo
  16919. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16920. utils.ErrorLog("解析失败:%v", err)
  16921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16922. return
  16923. }
  16924. if res.Infcode == 0 {
  16925. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  16926. if err == gorm.ErrRecordNotFound {
  16927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16928. return
  16929. } else if err != nil {
  16930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16931. return
  16932. } else {
  16933. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16934. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16935. infoStr := string(Iinfos)
  16936. idetinfoStr := string(Idetinfos)
  16937. psn := &models.HisPsn{
  16938. PsnNo: res.Output.Baseinfo.PsnNo,
  16939. PatientId: patient.ID,
  16940. Certno: res.Output.Baseinfo.Certno,
  16941. Gend: res.Output.Baseinfo.Gend,
  16942. Naty: res.Output.Baseinfo.Naty,
  16943. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16944. PsnName: res.Output.Baseinfo.PsnName,
  16945. Idetinfo: idetinfoStr,
  16946. Insuinfo: infoStr,
  16947. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16948. CardInfo: basStr,
  16949. VerifyNumber: "",
  16950. }
  16951. service.CreateHisPsn(psn)
  16952. c.ServeSuccessJSON(map[string]interface{}{
  16953. "patient": patient,
  16954. "number": basNumber,
  16955. })
  16956. }
  16957. } else {
  16958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16959. return
  16960. }
  16961. }
  16962. func (c *HisApiController) TestGetHnBasBaseInit() {
  16963. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16964. Iinit := DllDef.MustFindProc("Init")
  16965. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16966. //http://10.77.211.236/CSB/hsa-fsi-1303
  16967. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  16968. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  16969. // 调用 Init 函数
  16970. 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"))))
  16971. //if ret != 0 {
  16972. fmt.Println("SSCard的报错原因:", err)
  16973. fmt.Println("SSCard的运算结果为:", ret)
  16974. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16975. // return
  16976. //}
  16977. result := int(ret)
  16978. fmt.Println("SSCard的运算结果为1:", result)
  16979. initFlag = 1
  16980. return
  16981. }
  16982. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  16983. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16984. Iinit := DllDef.MustFindProc("Init")
  16985. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16986. //http://10.77.211.236/CSB/hsa-fsi-1303
  16987. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  16988. if ret != 0 {
  16989. fmt.Println("SSCard的报错原因:", err)
  16990. fmt.Println("SSCard的运算结果为:", ret)
  16991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16992. return
  16993. }
  16994. result := int(ret)
  16995. fmt.Println("SSCard的运算结果为1:", result)
  16996. initFlag = 1
  16997. return
  16998. }
  16999. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17000. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17001. Iinit := DllDef.MustFindProc("Init")
  17002. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17003. //http://10.77.211.236/CSB/hsa-fsi-1303
  17004. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17005. if ret != 0 {
  17006. fmt.Println("SSCard的报错原因:", err)
  17007. fmt.Println("SSCard的运算结果为:", ret)
  17008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17009. return
  17010. }
  17011. result := int(ret)
  17012. fmt.Println("SSCard的运算结果为1:", result)
  17013. initFlag = 1
  17014. return
  17015. }
  17016. func (c *HisApiController) GetSFZBaseInfo() string {
  17017. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17018. readCard := DllDef.MustFindProc("ReadSFZ")
  17019. if readCard == nil {
  17020. fmt.Println("readcard is nil")
  17021. readCard = DllDef.MustFindProc("ReadSFZ")
  17022. }
  17023. str := make([]byte, 8096)
  17024. str1 := make([]byte, 8096)
  17025. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17026. fmt.Println(r)
  17027. return Remove0000(string(str))
  17028. }
  17029. func (c *HisApiController) GetEleBaseInfo() string {
  17030. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17031. readCard := DllDef.MustFindProc("GetQRBase")
  17032. fmt.Println(readCard)
  17033. if readCard == nil {
  17034. fmt.Println("readcard is nil")
  17035. readCard = DllDef.MustFindProc("GetQRBase")
  17036. }
  17037. str := make([]byte, 1024)
  17038. str1 := make([]byte, 1024)
  17039. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17040. fmt.Println(ret2)
  17041. fmt.Println(string(str1))
  17042. fmt.Println(string(str))
  17043. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17044. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17045. if ret2 != 0 {
  17046. return ""
  17047. }
  17048. return string(str)
  17049. }
  17050. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17051. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17052. readCard := DllDef.MustFindProc("NationEcTrans")
  17053. fmt.Println(readCard)
  17054. fmt.Println("!!!!!")
  17055. pBusiCardInfo := make([]byte, 2048)
  17056. input := make(map[string]interface{})
  17057. inputData := make(map[string]interface{})
  17058. inputData["orgId"] = code
  17059. inputData["businessType"] = "01101"
  17060. inputData["operatorId"] = "1"
  17061. inputData["operatorName"] = "admin"
  17062. inputData["officeId"] = "001"
  17063. inputData["officeName"] = "血透室"
  17064. inputData["deviceType"] = ""
  17065. input["data"] = inputData
  17066. input["orgId"] = code
  17067. input["transType"] = "ec.query"
  17068. bytesData, _ := json.Marshal(input)
  17069. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17070. fmt.Println(ret2)
  17071. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17072. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17073. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17074. }
  17075. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17076. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17077. readCard := DllDef.MustFindProc("NationEcTrans")
  17078. fmt.Println(readCard)
  17079. fmt.Println("!!!!!")
  17080. pBusiCardInfo := make([]byte, 2048)
  17081. input := make(map[string]interface{})
  17082. inputData := make(map[string]interface{})
  17083. inputData["orgId"] = code
  17084. inputData["businessType"] = "01101"
  17085. inputData["operatorId"] = "9"
  17086. inputData["operatorName"] = "admin"
  17087. inputData["officeId"] = "001"
  17088. inputData["officeName"] = "血透室"
  17089. inputData["deviceType"] = ""
  17090. input["data"] = inputData
  17091. input["orgId"] = code
  17092. input["transType"] = "ec.query"
  17093. bytesData, _ := json.Marshal(input)
  17094. 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])))
  17095. fmt.Println(ret2)
  17096. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17097. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17098. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17099. }
  17100. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17101. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17102. readCard := DllDef.MustFindProc("NationEcTrans")
  17103. fmt.Println(readCard)
  17104. fmt.Println("!!!!!")
  17105. pBusiCardInfo := make([]byte, 2048)
  17106. input := make(map[string]interface{})
  17107. inputData := make(map[string]interface{})
  17108. inputData["orgId"] = code
  17109. inputData["businessType"] = "01301"
  17110. inputData["operatorId"] = "9"
  17111. inputData["operatorName"] = "admin"
  17112. inputData["officeId"] = "001"
  17113. inputData["officeName"] = "血透室"
  17114. inputData["deviceType"] = ""
  17115. input["data"] = inputData
  17116. input["orgId"] = code
  17117. input["transType"] = "ec.query"
  17118. bytesData, _ := json.Marshal(input)
  17119. 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])))
  17120. fmt.Println(ret2)
  17121. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17122. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17123. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17124. }
  17125. func GetJxEleBaseInfo(org_id int64) string {
  17126. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17127. readCard := DllDef.MustFindProc("NationEcTrans")
  17128. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17129. if readCard == nil {
  17130. fmt.Println("readcard is nil")
  17131. readCard = DllDef.MustFindProc("NationEcTrans")
  17132. }
  17133. str1 := make([]byte, 1024)
  17134. data := make(map[string]interface{})
  17135. inputData := make(map[string]interface{})
  17136. inputData["orgId"] = miConfig.Code
  17137. inputData["businessType"] = "01101"
  17138. inputData["operatorId"] = "test001"
  17139. inputData["operatorName"] = "cn"
  17140. inputData["officeId"] = "32760"
  17141. inputData["officeName"] = "waike"
  17142. inputData["deviceType"] = ""
  17143. data["data"] = inputData
  17144. data["transType"] = "ec.query"
  17145. data["extra "] = ""
  17146. data["orgId"] = miConfig.Code
  17147. bytesData, _ := json.Marshal(data)
  17148. //bytesData, _ := json.Marshal(data)
  17149. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17150. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17151. fmt.Println(ret2)
  17152. fmt.Println(string(str1))
  17153. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17154. if ret2 != 0 {
  17155. return ""
  17156. }
  17157. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17158. }
  17159. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17160. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17161. // readCard := DllDef.MustFindProc("NationEcTrans")
  17162. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17163. //
  17164. // if readCard == nil {
  17165. // fmt.Println("readcard is nil")
  17166. // readCard = DllDef.MustFindProc("NationEcTrans")
  17167. // }
  17168. // str1 := make([]byte, 1024)
  17169. //
  17170. // data := make(map[string]interface{})
  17171. //
  17172. // inputData := make(map[string]interface{})
  17173. // inputData["orgId"] = miConfig.Code
  17174. // inputData["businessType"] = "01101"
  17175. // inputData["operatorId"] = "test001"
  17176. // inputData["operatorName"] = "cn"
  17177. // inputData["officeId"] = "32760"
  17178. // inputData["officeName"] = "waike"
  17179. // inputData["deviceType"] = ""
  17180. //
  17181. // data["data"] = inputData
  17182. // data["transType"] = "ec.query"
  17183. // data["extra "] = ""
  17184. // data["orgId"] = miConfig.Code
  17185. // bytesData, _ := json.Marshal(data)
  17186. // //bytesData, _ := json.Marshal(data)
  17187. //
  17188. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17189. //
  17190. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17191. // fmt.Println(ret2)
  17192. // fmt.Println(string(str1))
  17193. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17194. //
  17195. // if ret2 != 0 {
  17196. // return ""
  17197. // }
  17198. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17199. //}
  17200. func GetJxEleBaseInitInfo(org_id int64) string {
  17201. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17202. readCard := DllDef.MustFindProc("NationEcTrans")
  17203. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17204. if readCard == nil {
  17205. fmt.Println("readcard is nil")
  17206. readCard = DllDef.MustFindProc("NationEcTrans")
  17207. }
  17208. str1 := make([]byte, 2048)
  17209. data := make(map[string]interface{})
  17210. inputData := make(map[string]interface{})
  17211. inputData["orgId"] = miConfig.Code
  17212. inputData["businessType"] = "01101"
  17213. inputData["operatorId"] = "1"
  17214. inputData["operatorName"] = "huangchuang"
  17215. inputData["officeId"] = "101"
  17216. inputData["officeName"] = "xuetou"
  17217. inputData["deviceType"] = ""
  17218. data["data"] = inputData
  17219. data["transType"] = "ec.query"
  17220. data["orgId"] = miConfig.Code
  17221. bytesData, _ := json.Marshal(data)
  17222. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17223. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17224. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17225. fmt.Println(ret2)
  17226. fmt.Println(string(str1))
  17227. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17228. if ret2 != 0 {
  17229. return ""
  17230. }
  17231. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17232. initEleFlag = 1
  17233. }
  17234. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17235. }
  17236. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17237. // // 构建命令
  17238. // cmd := exec.Command("python", "b.py")
  17239. //
  17240. // // 执行命令并等待完成
  17241. // output, err := cmd.CombinedOutput()
  17242. // if err != nil {
  17243. // fmt.Println("Error executing Python script:", err)
  17244. // return
  17245. // }
  17246. //
  17247. // // 打印Python脚本的输出
  17248. // fmt.Println(string(output))
  17249. //}
  17250. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17251. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17252. readCard := DllDef.MustFindProc("gxyb_call")
  17253. if readCard == nil {
  17254. fmt.Println("readcard is nil")
  17255. readCard = DllDef.MustFindProc("gxyb_call")
  17256. }
  17257. str := make([]byte, 1024)
  17258. str1 := make([]byte, 1024)
  17259. //data := make(map[string]interface{})
  17260. currentTime := time.Now()
  17261. // 格式化时间为 "YYYYMMDDHH24MISS"
  17262. formattedTime := currentTime.Format("20060102150405")
  17263. inputData := make(map[string]interface{})
  17264. inputData2 := make(map[string]interface{})
  17265. inputData["transNo"] = "1401"
  17266. inputData["transType"] = "passwordCheck"
  17267. inputData["timestamp"] = formattedTime
  17268. inputData2["fixmedinsCode"] = code
  17269. inputData2["psnNo"] = ""
  17270. inputData["data"] = inputData2
  17271. jsonBytes, err := json.Marshal(inputData)
  17272. if err != nil {
  17273. fmt.Println("Error encoding map to JSON:", err)
  17274. }
  17275. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17276. fmt.Println(string(str1))
  17277. fmt.Println(string(str))
  17278. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17279. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17280. if ret2 != 0 {
  17281. return ""
  17282. }
  17283. return string(str)
  17284. }
  17285. func (c *HisApiController) GetoleInfo() Response {
  17286. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17287. defer ole.CoUninitialize()
  17288. // Replace with the ProgID or CLSID of your COM object
  17289. progID := "YinHai.XJ.Actual.Interface.New"
  17290. // Create COM object
  17291. unknown, err := oleutil.CreateObject(progID)
  17292. if err != nil {
  17293. fmt.Println("Unable to create COM object:", err)
  17294. }
  17295. defer unknown.Release()
  17296. // Query for the IDispatch interface
  17297. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17298. if err != nil {
  17299. fmt.Println("Unable to get IDispatch interface:", err)
  17300. }
  17301. defer dispatch.Release()
  17302. // Prepare parameters
  17303. transNo := "1401"
  17304. transType := "passwordCheck"
  17305. timestamp := time.Now().Unix()
  17306. fixmedinsCode := "H45072101171"
  17307. psnNo := ""
  17308. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17309. result2 := ""
  17310. // Call COM object's method using the IDispatch interface
  17311. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17312. fmt.Println(resulr)
  17313. fmt.Println(result2)
  17314. if err != nil {
  17315. fmt.Println("调用COM对象方法失败:", err)
  17316. }
  17317. var response Response
  17318. err2 := json.Unmarshal([]byte(result2), &response)
  17319. if err2 != nil {
  17320. fmt.Println("解析JSON失败:", err)
  17321. }
  17322. return response
  17323. }
  17324. func (c *HisApiController) GetBasBaseInfo() string {
  17325. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17326. readCard := DllDef.MustFindProc("ReadCardBas")
  17327. if readCard == nil {
  17328. fmt.Println("readcard is nil")
  17329. readCard = DllDef.MustFindProc("ReadCardBas")
  17330. }
  17331. str := make([]byte, 1024)
  17332. str1 := make([]byte, 1024)
  17333. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17334. fmt.Println(string(str1))
  17335. fmt.Println(string(str))
  17336. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17337. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17338. if ret2 != 0 {
  17339. return ""
  17340. }
  17341. return string(str)
  17342. }
  17343. type Program struct {
  17344. FunctionID string `xml:"function_id"`
  17345. CardInfo string `xml:"cardinfo"`
  17346. User string `xml:"user"`
  17347. }
  17348. func (c *HisApiController) GetBasBaseInfo1111() string {
  17349. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17350. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17351. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17352. if readCard == nil {
  17353. fmt.Println("readcard is nil")
  17354. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17355. }
  17356. if readCard2 == nil {
  17357. fmt.Println("readcard is nil")
  17358. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17359. }
  17360. str := make([]byte, 1024)
  17361. str1 := make([]byte, 1024)
  17362. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17363. str3 := make([]byte, 1024)
  17364. str4 := make([]byte, 1024)
  17365. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17366. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17367. //if err != nil {
  17368. // fmt.Println("Error opening file:", err)
  17369. //}
  17370. //defer file.Close()
  17371. //
  17372. //var lastProgram Program
  17373. //scanner := bufio.NewScanner(file)
  17374. //inProgram := false
  17375. //
  17376. //for scanner.Scan() {
  17377. // line := scanner.Text()
  17378. // if strings.Contains(line, "<program>") {
  17379. // inProgram = true
  17380. // programXML := "<program>"
  17381. // for scanner.Scan() {
  17382. // line = scanner.Text()
  17383. // programXML += line
  17384. // if strings.Contains(line, "</program>") {
  17385. // programXML += "</program>"
  17386. // break
  17387. // }
  17388. // }
  17389. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17390. // // 解析成功,更新最后的 Program
  17391. // }
  17392. // inProgram = false
  17393. // }
  17394. //}
  17395. //
  17396. // fmt.Println("Error reading file:", inProgram)
  17397. //
  17398. //if err := scanner.Err(); err != nil {
  17399. // fmt.Println("Error reading file:", err)
  17400. //}
  17401. // 输出最后一次的 Program
  17402. //fmt.Printf("最后一次的 <program>:\n")
  17403. //fmt.Printf("<program>\n")
  17404. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17405. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17406. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17407. //fmt.Printf("</program>\n")
  17408. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17409. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17410. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17411. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17412. return ConvertToString(string(str), "gbk", "utf-8")
  17413. }
  17414. func (c *HisApiController) GetBasBaseInfo22222() string {
  17415. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17416. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17417. if readCard == nil {
  17418. fmt.Println("readcard is nil")
  17419. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17420. }
  17421. str := make([]byte, 1024)
  17422. str1 := make([]byte, 1024)
  17423. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17424. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17425. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17426. //if err != nil {
  17427. // fmt.Println("Error opening file:", err)
  17428. //}
  17429. //defer file.Close()
  17430. //
  17431. //var lastProgram Program
  17432. //scanner := bufio.NewScanner(file)
  17433. //inProgram := false
  17434. //
  17435. //for scanner.Scan() {
  17436. // line := scanner.Text()
  17437. // if strings.Contains(line, "<program>") {
  17438. // inProgram = true
  17439. // programXML := "<program>"
  17440. // for scanner.Scan() {
  17441. // line = scanner.Text()
  17442. // programXML += line
  17443. // if strings.Contains(line, "</program>") {
  17444. // programXML += "</program>"
  17445. // break
  17446. // }
  17447. // }
  17448. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17449. // // 解析成功,更新最后的 Program
  17450. // }
  17451. // inProgram = false
  17452. // }
  17453. //}
  17454. //
  17455. // fmt.Println("Error reading file:", inProgram)
  17456. //
  17457. //if err := scanner.Err(); err != nil {
  17458. // fmt.Println("Error reading file:", err)
  17459. //}
  17460. // 输出最后一次的 Program
  17461. //fmt.Printf("最后一次的 <program>:\n")
  17462. //fmt.Printf("<program>\n")
  17463. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17464. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17465. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17466. //fmt.Printf("</program>\n")
  17467. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17468. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17469. return ConvertToString(string(str1), "gbk", "utf-8")
  17470. }
  17471. func (c *HisApiController) GetahBasBaseInfo() string {
  17472. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17473. readCard := DllDef.MustFindProc("iReadCardBas")
  17474. if readCard == nil {
  17475. fmt.Println("readcard is nil")
  17476. readCard = DllDef.MustFindProc("iReadCardBas")
  17477. }
  17478. //str := make([]byte, 1024)
  17479. str1 := make([]byte, 1024)
  17480. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17481. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17482. //if err != nil {
  17483. // fmt.Println("Error opening file:", err)
  17484. //}
  17485. //defer file.Close()
  17486. //
  17487. //var lastProgram Program
  17488. //scanner := bufio.NewScanner(file)
  17489. //inProgram := false
  17490. //
  17491. //for scanner.Scan() {
  17492. // line := scanner.Text()
  17493. // if strings.Contains(line, "<program>") {
  17494. // inProgram = true
  17495. // programXML := "<program>"
  17496. // for scanner.Scan() {
  17497. // line = scanner.Text()
  17498. // programXML += line
  17499. // if strings.Contains(line, "</program>") {
  17500. // programXML += "</program>"
  17501. // break
  17502. // }
  17503. // }
  17504. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17505. // // 解析成功,更新最后的 Program
  17506. // }
  17507. // inProgram = false
  17508. // }
  17509. //}
  17510. //
  17511. // fmt.Println("Error reading file:", inProgram)
  17512. //
  17513. //if err := scanner.Err(); err != nil {
  17514. // fmt.Println("Error reading file:", err)
  17515. //}
  17516. // 输出最后一次的 Program
  17517. //fmt.Printf("最后一次的 <program>:\n")
  17518. //fmt.Printf("<program>\n")
  17519. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17520. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17521. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17522. //fmt.Printf("</program>\n")
  17523. fmt.Println(string(str1))
  17524. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17525. if ret2 != 0 {
  17526. return ""
  17527. }
  17528. return string(str1)
  17529. }
  17530. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17531. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17532. readCard := DllDef.MustFindProc("read_cardinfo")
  17533. if readCard == nil {
  17534. fmt.Println("readcard is nil")
  17535. readCard = DllDef.MustFindProc("read_cardinfo")
  17536. }
  17537. str := make([]byte, 1024) //卡号
  17538. str1 := make([]byte, 1024) //卡识别码
  17539. str2 := make([]byte, 1024) //身份证号
  17540. str3 := make([]byte, 1024) //姓名
  17541. str4 := make([]byte, 1024) //错误信息
  17542. 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])))
  17543. fmt.Println(string(str1))
  17544. fmt.Println(string(str))
  17545. fmt.Println(string(str2))
  17546. fmt.Println(string(str3))
  17547. fmt.Println(string(str4))
  17548. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17549. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17550. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17551. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17552. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17553. if ret2 != 0 {
  17554. return "", "", "", "", ""
  17555. }
  17556. return string(str), string(str1), string(str2), string(str3), string(str4)
  17557. }
  17558. type CustomFundPay struct {
  17559. FundPayType string `json:"fund_pay_type"`
  17560. FundPayamt float64 `json:"fund_payamt"`
  17561. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17562. }
  17563. //func (c *HisApiController) GetBatchSettleList() {
  17564. // start_time_str := c.GetString("start_time")
  17565. // //end_time_str := c.GetString("end_time")
  17566. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17567. //
  17568. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17569. //
  17570. // for _, item := range orders {
  17571. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17572. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17573. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17574. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17575. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17576. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17577. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17578. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17579. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17580. //
  17581. // if order.ID == 0 {
  17582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17583. // return
  17584. // }
  17585. //
  17586. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17587. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17588. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17589. // //fmt.Println(count)
  17590. // //var zero string
  17591. // //number := count + 1
  17592. // //if number >= 1000 {
  17593. // // zero = "0000" + strconv.FormatInt(number, 10)
  17594. // //} else if number >= 10000 {
  17595. // // zero = "000" + strconv.FormatInt(number, 10)
  17596. // //} else if number >= 100000 {
  17597. // // zero = "00" + strconv.FormatInt(number, 10)
  17598. // //} else if number >= 1000000 {
  17599. // // zero = "0" + strconv.FormatInt(number, 10)
  17600. // //} else {
  17601. // // zero = strconv.FormatInt(number, 10)
  17602. // //}
  17603. // //fmt.Println(zero)
  17604. //
  17605. // struct4101 := service.Struct4101{
  17606. // PsnNo: order.PsnNo,
  17607. // MdtrtId: order.MdtrtId,
  17608. // SetlId: order.SetlId,
  17609. // PsnName: order.PsnName,
  17610. // Gend: order.Gend,
  17611. // Brdy: his.Brdy,
  17612. // Age: his.Age,
  17613. // Naty: order.Naty,
  17614. // PatnCertType: "01",
  17615. // Certno: order.Certno,
  17616. // Prfs: "90",
  17617. // ConerName: roles[0].UserName,
  17618. // PatnRlts: "99",
  17619. // ConerAddr: miConfig.OrgName,
  17620. // ConerTel: admin.Mobile,
  17621. // HiType: order.Insutype,
  17622. // Insuplc: miConfig.InsuplcAdmdvs,
  17623. // MaindiagFlag: "1",
  17624. // BillCode: order.SetlId,
  17625. // BillNo: order.SetlId,
  17626. // BizSn: order.Number,
  17627. // PsnSelfPay: order.PsnPartAmt,
  17628. // PsnOwnPay: order.PsnPartAmt,
  17629. // AcctPay: order.AcctPay,
  17630. // PsnCashpay: order.PsnCashPay,
  17631. // HiPaymtd: "1",
  17632. // Hsorg: miConfig.InsuplcAdmdvs,
  17633. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17634. // MedinsFillPsn: curRoles.UserName,
  17635. // MedinsFillDept: miConfig.OrgName,
  17636. // IptMedType: "2",
  17637. // }
  17638. // struct4101.SetlBegnDate = order.SetlTime
  17639. // struct4101.SetlEndDate = order.SetlTime
  17640. // time_arr := strings.Split(order.SetlTime, " ")
  17641. // struct4101.AdmTime = time_arr[0]
  17642. // struct4101.AdmEndTime = time_arr[0]
  17643. //
  17644. // var rf []CustomFundPay
  17645. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17646. //
  17647. // var tempFunPays []service.CustomStruct
  17648. // for _, item := range rf {
  17649. // var tempFunPay service.CustomStruct
  17650. // tempFunPay.FundPayamt = item.FundPayamt
  17651. // tempFunPay.FundPayType = item.FundPayType
  17652. // tempFunPays = append(tempFunPays, tempFunPay)
  17653. // }
  17654. // struct4101.CustomStruct = tempFunPays
  17655. //
  17656. // var tempDiaginfos []service.DiaginfoStructTwo
  17657. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17658. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17659. //
  17660. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17661. // var config []*models.HisXtDiagnoseConfig
  17662. // for _, item := range diagnosis_ids {
  17663. // id, _ := strconv.ParseInt(item, 10, 64)
  17664. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17665. // config = append(config, &diagnosisConfig)
  17666. // }
  17667. //
  17668. // for index, item := range config {
  17669. // if index == 0 {
  17670. // var tempDiaginfo service.DiaginfoStructTwo
  17671. // tempDiaginfo.DiagCode = item.CountryCode
  17672. // tempDiaginfo.DiagName = item.CountryContentName
  17673. // tempDiaginfo.DiagType = "1"
  17674. // tempDiaginfo.MaindiagFlag = "1"
  17675. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17676. // } else {
  17677. // var tempDiaginfo service.DiaginfoStructTwo
  17678. // tempDiaginfo.DiagCode = item.CountryCode
  17679. // tempDiaginfo.DiagName = item.CountryContentName
  17680. // tempDiaginfo.DiagType = "1"
  17681. // tempDiaginfo.MaindiagFlag = "0"
  17682. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17683. // }
  17684. // }
  17685. // struct4101.Diseinfo = tempDiaginfos
  17686. //
  17687. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17688. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17689. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17690. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17691. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17692. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17693. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17694. //
  17695. // var iteminfo service.IteminfoStruct
  17696. //
  17697. // var bedCostTotal float64 = 0 //床位总费
  17698. // var bedCostSelfTotal float64 = 0 //床位自费
  17699. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17700. //
  17701. // var operationCostTotal float64 = 0 //手术费
  17702. // var operationCostSelfTotal float64 = 0 //手术费
  17703. // var operationCostPartSelfTotal float64 = 0 //手术费
  17704. //
  17705. // var otherCostTotal float64 = 0 //其他费用
  17706. // var otherCostSelfTotal float64 = 0 //其他费用
  17707. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17708. //
  17709. // var materialCostTotal float64 = 0 //材料费
  17710. // var materialCostSelfTotal float64 = 0 //材料费
  17711. // var materialCostPartSelfTotal float64 = 0 //材料费
  17712. //
  17713. // var westernMedicineCostTotal float64 = 0 //西药费
  17714. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17715. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17716. //
  17717. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17718. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17719. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17720. //
  17721. // var checkCostTotal float64 = 0 //检查费
  17722. // var checkCostSelfTotal float64 = 0 //检查费
  17723. // var checkCostPartSelfTotal float64 = 0 //检查费
  17724. //
  17725. // var laboratoryCostTotal float64 = 0 //化验费
  17726. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17727. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17728. //
  17729. // var treatCostTotal float64 = 0 //治疗费用
  17730. // var treatCostSelfTotal float64 = 0 //治疗费用
  17731. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17732. //
  17733. // decimal.DivisionPrecision = 2
  17734. //
  17735. // var bed_fulamt_ownpay_amt float64 = 0
  17736. // var operation_fulamt_ownpay_amt float64 = 0
  17737. // var other_fulamt_ownpay_amt float64 = 0
  17738. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17739. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17740. // var check_fulamt_ownpay_amt float64 = 0
  17741. // var material_fulamt_ownpay_amt float64 = 0
  17742. // var laboratory_fulamt_ownpay_amt float64 = 0
  17743. // var treat_fulamt_ownpay_amt float64 = 0
  17744. //
  17745. // var bed_claa_sunmfee float64 = 0
  17746. // var bed_clab_amt float64 = 0
  17747. // var bed_other_amt float64 = 0
  17748. //
  17749. // var operation_claa_sunmfee float64 = 0
  17750. // var operation_clab_amt float64 = 0
  17751. // var operation_other_amt float64 = 0
  17752. //
  17753. // var other_claa_sunmfee float64 = 0
  17754. // var other_clab_amt float64 = 0
  17755. // var other_other_amt float64 = 0
  17756. //
  17757. // var westernMedicine_claa_sunmfee float64 = 0
  17758. // var westernMedicine_clab_amt float64 = 0
  17759. // var westernMedicine_other_amt float64 = 0
  17760. //
  17761. // var chineseTraditional_claa_sunmfee float64 = 0
  17762. // var chineseTraditional_clab_amt float64 = 0
  17763. // var chineseTraditional_other_amt float64 = 0
  17764. //
  17765. // var check_claa_sunmfee float64 = 0
  17766. // var check_clab_amt float64 = 0
  17767. // var check_other_amt float64 = 0
  17768. //
  17769. // var material_claa_sunmfee float64 = 0
  17770. // var material_clab_amt float64 = 0
  17771. // var material_other_amt float64 = 0
  17772. //
  17773. // var laboratory_claa_sunmfee float64 = 0
  17774. // var laboratory_clab_amt float64 = 0
  17775. // var laboratory_other_amt float64 = 0
  17776. //
  17777. // var treat_claa_sunmfee float64 = 0
  17778. // var treat_clab_amt float64 = 0
  17779. // var treat_other_amt float64 = 0
  17780. //
  17781. // for _, item := range order.HisOrderInfo {
  17782. // if item.MedChrgitmType == "01" { //床位费
  17783. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17784. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17785. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17786. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17787. // if item.ChrgitmLv == "1" {
  17788. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17789. // }
  17790. // if item.ChrgitmLv == "2" {
  17791. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17792. //
  17793. // }
  17794. // if item.ChrgitmLv == "3" {
  17795. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17796. // }
  17797. //
  17798. // }
  17799. //
  17800. // if item.MedChrgitmType == "03" { //检查费
  17801. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17802. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17803. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17804. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17805. // if item.ChrgitmLv == "1" {
  17806. //
  17807. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17808. //
  17809. // }
  17810. // if item.ChrgitmLv == "2" {
  17811. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17812. //
  17813. // }
  17814. // if item.ChrgitmLv == "3" {
  17815. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17816. // }
  17817. // }
  17818. //
  17819. // if item.MedChrgitmType == "04" { //化验费
  17820. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17821. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17822. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17823. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17824. // if item.ChrgitmLv == "1" {
  17825. //
  17826. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17827. //
  17828. // }
  17829. // if item.ChrgitmLv == "2" {
  17830. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17831. //
  17832. // }
  17833. // if item.ChrgitmLv == "3" {
  17834. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17835. // }
  17836. // }
  17837. //
  17838. // if item.MedChrgitmType == "05" { //治疗费
  17839. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17840. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17841. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17842. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17843. // if item.ChrgitmLv == "1" {
  17844. //
  17845. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17846. //
  17847. // }
  17848. // if item.ChrgitmLv == "2" {
  17849. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17850. //
  17851. // }
  17852. // if item.ChrgitmLv == "3" {
  17853. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17854. // }
  17855. // }
  17856. //
  17857. // if item.MedChrgitmType == "06" { //手术费
  17858. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17859. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17860. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17861. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17862. //
  17863. // if item.ChrgitmLv == "1" {
  17864. //
  17865. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17866. //
  17867. // }
  17868. // if item.ChrgitmLv == "2" {
  17869. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17870. //
  17871. // }
  17872. // if item.ChrgitmLv == "3" {
  17873. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17874. // }
  17875. // }
  17876. //
  17877. // if item.MedChrgitmType == "08" { //材料费
  17878. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17879. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17880. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17881. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17882. // if item.ChrgitmLv == "1" {
  17883. //
  17884. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17885. //
  17886. // }
  17887. // if item.ChrgitmLv == "2" {
  17888. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17889. //
  17890. // }
  17891. // if item.ChrgitmLv == "3" {
  17892. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17893. // }
  17894. // }
  17895. //
  17896. // if item.MedChrgitmType == "09" { //西药费
  17897. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17898. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17899. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17900. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17901. // if item.ChrgitmLv == "1" {
  17902. //
  17903. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17904. //
  17905. // }
  17906. // if item.ChrgitmLv == "2" {
  17907. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17908. //
  17909. // }
  17910. // if item.ChrgitmLv == "3" {
  17911. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17912. // }
  17913. // }
  17914. //
  17915. // if item.MedChrgitmType == "11" { //中成费
  17916. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17917. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17918. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17919. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17920. // if item.ChrgitmLv == "1" {
  17921. //
  17922. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17923. //
  17924. // }
  17925. // if item.ChrgitmLv == "2" {
  17926. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17927. //
  17928. // }
  17929. // if item.ChrgitmLv == "3" {
  17930. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17931. // }
  17932. // }
  17933. //
  17934. // if item.MedChrgitmType == "14" { //其他费
  17935. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17936. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17937. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17938. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17939. // if item.ChrgitmLv == "1" {
  17940. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17941. //
  17942. // }
  17943. // if item.ChrgitmLv == "2" {
  17944. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17945. //
  17946. // }
  17947. // if item.ChrgitmLv == "3" {
  17948. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17949. // }
  17950. // }
  17951. //
  17952. // }
  17953. //
  17954. // var iteminfoStructs []service.IteminfoStruct
  17955. //
  17956. // if bedCostTotal != 0 {
  17957. // iteminfo.MedChrgitm = "01"
  17958. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17959. // iteminfo.Amt = bedCostTotal
  17960. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  17961. // iteminfo.ClabAmt = bed_clab_amt
  17962. // iteminfo.OthAmt = bed_other_amt
  17963. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17964. // }
  17965. //
  17966. // if checkCostTotal != 0 {
  17967. // iteminfo.MedChrgitm = "03"
  17968. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17969. // iteminfo.Amt = checkCostTotal
  17970. // iteminfo.ClaaSumfee = check_claa_sunmfee
  17971. // iteminfo.ClabAmt = check_clab_amt
  17972. // iteminfo.OthAmt = check_other_amt
  17973. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17974. //
  17975. // }
  17976. //
  17977. // if laboratoryCostTotal != 0 {
  17978. // iteminfo.MedChrgitm = "04"
  17979. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17980. // iteminfo.Amt = laboratoryCostTotal
  17981. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17982. // iteminfo.ClabAmt = laboratory_clab_amt
  17983. // iteminfo.OthAmt = laboratory_other_amt
  17984. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17985. //
  17986. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17987. //
  17988. // }
  17989. //
  17990. // if treatCostTotal != 0 {
  17991. // iteminfo.MedChrgitm = "05"
  17992. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17993. // iteminfo.Amt = treatCostTotal
  17994. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  17995. // iteminfo.ClabAmt = treat_clab_amt
  17996. // iteminfo.OthAmt = treat_other_amt
  17997. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17998. // //(struct4101.IteminfoStruct, iteminfo)
  17999. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18000. // }
  18001. //
  18002. // if operationCostTotal != 0 {
  18003. // iteminfo.MedChrgitm = "06"
  18004. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18005. // iteminfo.Amt = operationCostTotal
  18006. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18007. // iteminfo.ClabAmt = operation_clab_amt
  18008. // iteminfo.OthAmt = operation_other_amt
  18009. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18010. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18011. // }
  18012. //
  18013. // if materialCostTotal != 0 {
  18014. // iteminfo.MedChrgitm = "08"
  18015. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18016. // iteminfo.Amt = materialCostTotal
  18017. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18018. // iteminfo.ClabAmt = material_clab_amt
  18019. // iteminfo.OthAmt = material_other_amt
  18020. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18021. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18022. // }
  18023. //
  18024. // if westernMedicineCostTotal != 0 {
  18025. // iteminfo.MedChrgitm = "09"
  18026. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18027. // iteminfo.Amt = westernMedicineCostTotal
  18028. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18029. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18030. // iteminfo.OthAmt = westernMedicine_other_amt
  18031. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18032. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18033. //
  18034. // }
  18035. // if chineseTraditionalMedicineCostTotal != 0 {
  18036. // iteminfo.MedChrgitm = "11"
  18037. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18038. // iteminfo.Amt = westernMedicineCostTotal
  18039. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18040. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18041. // iteminfo.OthAmt = westernMedicine_other_amt
  18042. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18043. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18044. //
  18045. // }
  18046. // if otherCostTotal != 0 {
  18047. // iteminfo.MedChrgitm = "14"
  18048. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18049. // iteminfo.Amt = otherCostTotal
  18050. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18051. // iteminfo.ClabAmt = other_clab_amt
  18052. // iteminfo.OthAmt = other_other_amt
  18053. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18054. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18055. //
  18056. // }
  18057. // struct4101.IteminfoStruct = iteminfoStructs
  18058. // struct4101.Ntly = "中国"
  18059. // struct4101.AdmCaty = "A03.06"
  18060. //
  18061. // struct4101.DoctorName = doctor.UserName
  18062. // struct4101.DoctorCode = doctor.DoctorNumber
  18063. //
  18064. // var res ResultSeventeen
  18065. //
  18066. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18067. // struct4101.BillCode = order.Number
  18068. // struct4101.BillNo = order.SetlId
  18069. // var resOther ResultSeventeenOther
  18070. // var pp models.PublicParams
  18071. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18072. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18073. // pp.FixmedinsName = miConfig.OrgName
  18074. // pp.FixmedinsCode = miConfig.Code
  18075. // pp.RequestUrl = miConfig.Url
  18076. // pp.Cainfo = miConfig.Cainfo
  18077. // pp.SecretKey = miConfig.SecretKey
  18078. // pp.AccessKey = miConfig.AccessKey
  18079. // pp.OpterName = curRoles.UserName
  18080. //
  18081. // client := &http.Client{}
  18082. // var req *http.Request
  18083. // data := make(map[string]interface{})
  18084. // data["struct4101"] = struct4101
  18085. // data["pp"] = pp
  18086. // bytesData, _ := json.Marshal(data)
  18087. // if miConfig.MdtrtareaAdmvs == "320921" {
  18088. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18089. // } else {
  18090. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18091. // }
  18092. // resp, _ := client.Do(req)
  18093. // defer resp.Body.Close()
  18094. // body, ioErr := ioutil.ReadAll(resp.Body)
  18095. // if ioErr != nil {
  18096. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18098. // return
  18099. // }
  18100. // var respJSON map[string]interface{}
  18101. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18102. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18103. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18104. // return
  18105. // }
  18106. //
  18107. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18108. // userJSONBytes, _ := json.Marshal(respJSON)
  18109. // fmt.Println("log")
  18110. // fmt.Println(string(userJSONBytes))
  18111. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18112. // utils.ErrorLog("解析失败:%v", err)
  18113. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18114. // return
  18115. // }
  18116. // res.InfRefmsgid = resOther.InfRefmsgid
  18117. // res.Output = resOther.Output
  18118. // res.ErrMsg = resOther.ErrMsg
  18119. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18120. // res.Infcode = infocode
  18121. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18122. //
  18123. // var pp models.PublicParams
  18124. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18125. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18126. // pp.FixmedinsName = miConfig.OrgName
  18127. // pp.FixmedinsCode = miConfig.Code
  18128. // pp.RequestUrl = miConfig.Url
  18129. // pp.Cainfo = miConfig.Cainfo
  18130. // pp.SecretKey = miConfig.SecretKey
  18131. // pp.AccessKey = miConfig.AccessKey
  18132. // pp.OpterName = curRoles.UserName
  18133. // result, _ := service.Jxyb4101(struct4101, pp)
  18134. // var dat map[string]interface{}
  18135. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18136. // fmt.Println(dat)
  18137. // } else {
  18138. // fmt.Println(err)
  18139. // }
  18140. // userJSONBytes, _ := json.Marshal(dat)
  18141. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18142. // utils.ErrorLog("解析失败:%v", err)
  18143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18144. // return
  18145. // }
  18146. //
  18147. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18148. // var pp models.PublicParams
  18149. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18150. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18151. // pp.FixmedinsName = miConfig.OrgName
  18152. // pp.FixmedinsCode = miConfig.Code
  18153. // pp.RequestUrl = miConfig.Url
  18154. // pp.Cainfo = miConfig.Cainfo
  18155. // pp.SecretKey = miConfig.SecretKey
  18156. // pp.AccessKey = miConfig.AccessKey
  18157. // pp.OpterName = curRoles.UserName
  18158. // result, _ := service.Hnyb4101(struct4101, pp)
  18159. // var dat map[string]interface{}
  18160. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18161. // fmt.Println(dat)
  18162. // } else {
  18163. // fmt.Println(err)
  18164. // }
  18165. // userJSONBytes, _ := json.Marshal(dat)
  18166. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18167. // utils.ErrorLog("解析失败:%v", err)
  18168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18169. // return
  18170. // }
  18171. //
  18172. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18173. // var resOther ResultSeventeenOther
  18174. //
  18175. // var pp models.PublicParams
  18176. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18177. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18178. // pp.FixmedinsName = miConfig.OrgName
  18179. // pp.FixmedinsCode = miConfig.Code
  18180. // pp.RequestUrl = miConfig.Url
  18181. // pp.Cainfo = miConfig.Cainfo
  18182. // pp.SecretKey = miConfig.SecretKey
  18183. // pp.AccessKey = miConfig.AccessKey
  18184. // pp.OpterName = curRoles.UserName
  18185. // client := &http.Client{}
  18186. // var req *http.Request
  18187. // data := make(map[string]interface{})
  18188. // data["struct4101"] = struct4101
  18189. // data["pp"] = pp
  18190. // bytesData, _ := json.Marshal(data)
  18191. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18192. // resp, _ := client.Do(req)
  18193. // defer resp.Body.Close()
  18194. // body, ioErr := ioutil.ReadAll(resp.Body)
  18195. // if ioErr != nil {
  18196. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18198. // return
  18199. // }
  18200. // var respJSON map[string]interface{}
  18201. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18202. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18204. // return
  18205. // }
  18206. //
  18207. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18208. // userJSONBytes, _ := json.Marshal(respJSON)
  18209. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18210. // utils.ErrorLog("解析失败:%v", err)
  18211. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18212. // return
  18213. // }
  18214. // res.InfRefmsgid = resOther.InfRefmsgid
  18215. // res.Output = resOther.Output
  18216. // res.ErrMsg = resOther.ErrMsg
  18217. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18218. // res.Infcode = infocode
  18219. //
  18220. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18221. // var pp models.PublicParams
  18222. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18223. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18224. // pp.FixmedinsName = miConfig.OrgName
  18225. // pp.FixmedinsCode = miConfig.Code
  18226. // pp.RequestUrl = miConfig.Url
  18227. // pp.Cainfo = miConfig.Cainfo
  18228. // pp.SecretKey = miConfig.SecretKey
  18229. // pp.AccessKey = miConfig.AccessKey
  18230. // pp.OpterName = curRoles.UserName
  18231. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18232. // fmt.Println(requestLog)
  18233. // fmt.Println(errMsgLog)
  18234. //
  18235. // saveLog(result, requestLog, "4101a", "上传清单")
  18236. //
  18237. // var dat map[string]interface{}
  18238. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18239. // fmt.Println(dat)
  18240. // } else {
  18241. // fmt.Println(err)
  18242. // }
  18243. // userJSONBytes, _ := json.Marshal(dat)
  18244. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18245. // utils.ErrorLog("解析失败:%v", err)
  18246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18247. // return
  18248. // }
  18249. //
  18250. // } else {
  18251. //
  18252. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18253. // var dat map[string]interface{}
  18254. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18255. // fmt.Println(dat)
  18256. // } else {
  18257. // fmt.Println(err)
  18258. // }
  18259. // userJSONBytes, _ := json.Marshal(dat)
  18260. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18261. // utils.ErrorLog("解析失败:%v", err)
  18262. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18263. // return
  18264. // }
  18265. // }
  18266. //
  18267. // if res.Infcode != 0 {
  18268. // adminUser := c.GetAdminUserInfo()
  18269. // errlog := &models.HisOrderError{
  18270. // UserOrgId: adminUser.CurrentOrgId,
  18271. // Ctime: time.Now().Unix(),
  18272. // Mtime: time.Now().Unix(),
  18273. // ErrMsg: res.ErrMsg,
  18274. // Status: 1,
  18275. // PatientId: order.ID,
  18276. // Stage: 10265,
  18277. // }
  18278. // service.CreateErrMsgLog(errlog)
  18279. // continue
  18280. // } else {
  18281. // //order.FaPiaoNumber = zero
  18282. // //order.FaPiaoCode = last_order.FaPiaoCode
  18283. // //service.UpdateOrder(order)
  18284. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18285. // Number: res.Output.SetlListId,
  18286. // Status: 1,
  18287. // Ctime: time.Now().Unix(),
  18288. // Mtime: time.Now().Unix(),
  18289. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18290. // IsUpload: 1,
  18291. // OrderId: order.ID,
  18292. // }
  18293. // service.CreateUploadRecord(hisFundSettleListResult)
  18294. // c.ServeSuccessJSON(map[string]interface{}{
  18295. // "msg": "上传成功",
  18296. // "result": hisFundSettleListResult,
  18297. // })
  18298. // continue
  18299. // }
  18300. // }
  18301. //}
  18302. func (c *HisApiController) GetbatchSettleList() {
  18303. //order_id, _ := c.GetInt64("order_id")
  18304. admin_user_id, _ := c.GetInt64("admin_user_id")
  18305. orders, _ := service.GetAllHisOrderTwo10485()
  18306. for _, item := range orders {
  18307. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18308. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18309. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18310. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18311. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18312. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18313. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18314. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18315. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18316. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18317. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18318. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18319. //fmt.Println(count)
  18320. //var zero string
  18321. //number := count + 1
  18322. //if number >= 1000 {
  18323. // zero = "0000" + strconv.FormatInt(number, 10)
  18324. //} else if number >= 10000 {
  18325. // zero = "000" + strconv.FormatInt(number, 10)
  18326. //} else if number >= 100000 {
  18327. // zero = "00" + strconv.FormatInt(number, 10)
  18328. //} else if number >= 1000000 {
  18329. // zero = "0" + strconv.FormatInt(number, 10)
  18330. //} else {
  18331. // zero = strconv.FormatInt(number, 10)
  18332. //}
  18333. //fmt.Println(zero)
  18334. struct4101 := service.Struct4101{
  18335. PsnNo: order.PsnNo,
  18336. MdtrtId: order.MdtrtId,
  18337. SetlId: order.SetlId,
  18338. PsnName: order.PsnName,
  18339. Gend: order.Gend,
  18340. Brdy: his.Brdy,
  18341. Age: his.Age,
  18342. Naty: order.Naty,
  18343. PatnCertType: "01",
  18344. Certno: order.Certno,
  18345. Prfs: "90",
  18346. ConerName: roles[0].UserName,
  18347. PatnRlts: "99",
  18348. ConerAddr: miConfig.OrgName,
  18349. ConerTel: admin.Mobile,
  18350. HiType: order.Insutype,
  18351. Insuplc: miConfig.InsuplcAdmdvs,
  18352. MaindiagFlag: "1",
  18353. BillCode: order.SetlId,
  18354. BillNo: order.SetlId,
  18355. BizSn: order.Number,
  18356. PsnSelfPay: order.PsnPartAmt,
  18357. PsnOwnPay: order.PsnPartAmt,
  18358. AcctPay: order.AcctPay,
  18359. PsnCashpay: order.PsnCashPay,
  18360. HiPaymtd: "1",
  18361. Hsorg: miConfig.InsuplcAdmdvs,
  18362. HsorgOpter: miConfig.InsuplcAdmdvs,
  18363. MedinsFillPsn: curRoles.UserName,
  18364. MedinsFillDept: miConfig.OrgName,
  18365. IptMedType: "2",
  18366. }
  18367. struct4101.SetlBegnDate = order.SetlTime
  18368. struct4101.SetlEndDate = order.SetlTime
  18369. time_arr := strings.Split(order.SetlTime, " ")
  18370. struct4101.AdmTime = time_arr[0]
  18371. struct4101.AdmEndTime = time_arr[0]
  18372. //var rf []CustomFundPay
  18373. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18374. //
  18375. //var tempFunPays []service.CustomStruct
  18376. //for _, item := range rf {
  18377. // var tempFunPay service.CustomStruct
  18378. // tempFunPay.FundPayamt = item.FundPayamt
  18379. // tempFunPay.FundPayType = item.FundPayType
  18380. // tempFunPays = append(tempFunPays, tempFunPay)
  18381. //}
  18382. //struct4101.CustomStruct = tempFunPays
  18383. var tempDiaginfos []service.DiaginfoStructTwo
  18384. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18385. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18386. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18387. var config []*models.HisXtDiagnoseConfig
  18388. for _, item := range diagnosis_ids {
  18389. id, _ := strconv.ParseInt(item, 10, 64)
  18390. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18391. config = append(config, &diagnosisConfig)
  18392. }
  18393. for index, item := range config {
  18394. if index == 0 {
  18395. var tempDiaginfo service.DiaginfoStructTwo
  18396. tempDiaginfo.DiagCode = item.CountryCode
  18397. tempDiaginfo.DiagName = item.CountryContentName
  18398. tempDiaginfo.DiagType = "1"
  18399. tempDiaginfo.MaindiagFlag = "1"
  18400. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18401. } else {
  18402. var tempDiaginfo service.DiaginfoStructTwo
  18403. tempDiaginfo.DiagCode = item.CountryCode
  18404. tempDiaginfo.DiagName = item.CountryContentName
  18405. tempDiaginfo.DiagType = "1"
  18406. tempDiaginfo.MaindiagFlag = "0"
  18407. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18408. }
  18409. }
  18410. struct4101.Diseinfo = tempDiaginfos
  18411. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18412. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18413. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18414. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18415. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18416. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18417. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18418. var iteminfo service.IteminfoStruct
  18419. var bedCostTotal float64 = 0 //床位总费
  18420. var bedCostSelfTotal float64 = 0 //床位自费
  18421. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18422. var operationCostTotal float64 = 0 //手术费
  18423. var operationCostSelfTotal float64 = 0 //手术费
  18424. var operationCostPartSelfTotal float64 = 0 //手术费
  18425. var otherCostTotal float64 = 0 //其他费用
  18426. var otherCostSelfTotal float64 = 0 //其他费用
  18427. var otherCostPartSelfTotal float64 = 0 //其他费用
  18428. var materialCostTotal float64 = 0 //材料费
  18429. var materialCostSelfTotal float64 = 0 //材料费
  18430. var materialCostPartSelfTotal float64 = 0 //材料费
  18431. var westernMedicineCostTotal float64 = 0 //西药费
  18432. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18433. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18434. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18435. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18436. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18437. var checkCostTotal float64 = 0 //检查费
  18438. var checkCostSelfTotal float64 = 0 //检查费
  18439. var checkCostPartSelfTotal float64 = 0 //检查费
  18440. var laboratoryCostTotal float64 = 0 //化验费
  18441. var laboratoryCostSelfTotal float64 = 0 //化验费
  18442. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18443. var treatCostTotal float64 = 0 //治疗费用
  18444. var treatCostSelfTotal float64 = 0 //治疗费用
  18445. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18446. decimal.DivisionPrecision = 2
  18447. var bed_fulamt_ownpay_amt float64 = 0
  18448. var operation_fulamt_ownpay_amt float64 = 0
  18449. var other_fulamt_ownpay_amt float64 = 0
  18450. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18451. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18452. var check_fulamt_ownpay_amt float64 = 0
  18453. var material_fulamt_ownpay_amt float64 = 0
  18454. var laboratory_fulamt_ownpay_amt float64 = 0
  18455. var treat_fulamt_ownpay_amt float64 = 0
  18456. var bed_claa_sunmfee float64 = 0
  18457. var bed_clab_amt float64 = 0
  18458. var bed_other_amt float64 = 0
  18459. var operation_claa_sunmfee float64 = 0
  18460. var operation_clab_amt float64 = 0
  18461. var operation_other_amt float64 = 0
  18462. var other_claa_sunmfee float64 = 0
  18463. var other_clab_amt float64 = 0
  18464. var other_other_amt float64 = 0
  18465. var westernMedicine_claa_sunmfee float64 = 0
  18466. var westernMedicine_clab_amt float64 = 0
  18467. var westernMedicine_other_amt float64 = 0
  18468. var chineseTraditional_claa_sunmfee float64 = 0
  18469. var chineseTraditional_clab_amt float64 = 0
  18470. var chineseTraditional_other_amt float64 = 0
  18471. var check_claa_sunmfee float64 = 0
  18472. var check_clab_amt float64 = 0
  18473. var check_other_amt float64 = 0
  18474. var material_claa_sunmfee float64 = 0
  18475. var material_clab_amt float64 = 0
  18476. var material_other_amt float64 = 0
  18477. var laboratory_claa_sunmfee float64 = 0
  18478. var laboratory_clab_amt float64 = 0
  18479. var laboratory_other_amt float64 = 0
  18480. var treat_claa_sunmfee float64 = 0
  18481. var treat_clab_amt float64 = 0
  18482. var treat_other_amt float64 = 0
  18483. for _, item := range order.HisOrderInfo {
  18484. if item.MedChrgitmType == "01" { //床位费
  18485. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18486. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18487. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18488. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18489. if item.ChrgitmLv == "1" {
  18490. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18491. }
  18492. if item.ChrgitmLv == "2" {
  18493. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18494. }
  18495. if item.ChrgitmLv == "3" {
  18496. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18497. }
  18498. }
  18499. if item.MedChrgitmType == "03" { //检查费
  18500. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18501. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18502. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18503. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18504. if item.ChrgitmLv == "1" {
  18505. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18506. }
  18507. if item.ChrgitmLv == "2" {
  18508. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18509. }
  18510. if item.ChrgitmLv == "3" {
  18511. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18512. }
  18513. }
  18514. if item.MedChrgitmType == "04" { //化验费
  18515. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18516. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18517. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18518. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18519. if item.ChrgitmLv == "1" {
  18520. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18521. }
  18522. if item.ChrgitmLv == "2" {
  18523. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18524. }
  18525. if item.ChrgitmLv == "3" {
  18526. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18527. }
  18528. }
  18529. if item.MedChrgitmType == "05" { //治疗费
  18530. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18531. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18532. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18533. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18534. if item.ChrgitmLv == "1" {
  18535. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18536. }
  18537. if item.ChrgitmLv == "2" {
  18538. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18539. }
  18540. if item.ChrgitmLv == "3" {
  18541. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18542. }
  18543. }
  18544. if item.MedChrgitmType == "06" { //手术费
  18545. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18546. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18547. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18548. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18549. if item.ChrgitmLv == "1" {
  18550. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18551. }
  18552. if item.ChrgitmLv == "2" {
  18553. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18554. }
  18555. if item.ChrgitmLv == "3" {
  18556. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18557. }
  18558. }
  18559. if item.MedChrgitmType == "08" { //材料费
  18560. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18561. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18562. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18563. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18564. if item.ChrgitmLv == "1" {
  18565. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18566. }
  18567. if item.ChrgitmLv == "2" {
  18568. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18569. }
  18570. if item.ChrgitmLv == "3" {
  18571. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18572. }
  18573. }
  18574. if item.MedChrgitmType == "09" { //西药费
  18575. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18576. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18577. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18578. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18579. if item.ChrgitmLv == "1" {
  18580. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18581. }
  18582. if item.ChrgitmLv == "2" {
  18583. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18584. }
  18585. if item.ChrgitmLv == "3" {
  18586. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18587. }
  18588. }
  18589. if item.MedChrgitmType == "11" { //中成费
  18590. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18591. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18592. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18593. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18594. if item.ChrgitmLv == "1" {
  18595. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18596. }
  18597. if item.ChrgitmLv == "2" {
  18598. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18599. }
  18600. if item.ChrgitmLv == "3" {
  18601. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18602. }
  18603. }
  18604. if item.MedChrgitmType == "14" { //其他费
  18605. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18606. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18607. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18608. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18609. if item.ChrgitmLv == "1" {
  18610. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18611. }
  18612. if item.ChrgitmLv == "2" {
  18613. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18614. }
  18615. if item.ChrgitmLv == "3" {
  18616. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18617. }
  18618. }
  18619. }
  18620. var iteminfoStructs []service.IteminfoStruct
  18621. if bedCostTotal != 0 {
  18622. iteminfo.MedChrgitm = "01"
  18623. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18624. iteminfo.Amt = bedCostTotal
  18625. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18626. iteminfo.ClabAmt = bed_clab_amt
  18627. iteminfo.OthAmt = bed_other_amt
  18628. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18629. }
  18630. if checkCostTotal != 0 {
  18631. iteminfo.MedChrgitm = "03"
  18632. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18633. iteminfo.Amt = checkCostTotal
  18634. iteminfo.ClaaSumfee = check_claa_sunmfee
  18635. iteminfo.ClabAmt = check_clab_amt
  18636. iteminfo.OthAmt = check_other_amt
  18637. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18638. }
  18639. if laboratoryCostTotal != 0 {
  18640. iteminfo.MedChrgitm = "04"
  18641. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18642. iteminfo.Amt = laboratoryCostTotal
  18643. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18644. iteminfo.ClabAmt = laboratory_clab_amt
  18645. iteminfo.OthAmt = laboratory_other_amt
  18646. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18647. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18648. }
  18649. if treatCostTotal != 0 {
  18650. iteminfo.MedChrgitm = "05"
  18651. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18652. iteminfo.Amt = treatCostTotal
  18653. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18654. iteminfo.ClabAmt = treat_clab_amt
  18655. iteminfo.OthAmt = treat_other_amt
  18656. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18657. //(struct4101.IteminfoStruct, iteminfo)
  18658. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18659. }
  18660. if operationCostTotal != 0 {
  18661. iteminfo.MedChrgitm = "06"
  18662. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18663. iteminfo.Amt = operationCostTotal
  18664. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18665. iteminfo.ClabAmt = operation_clab_amt
  18666. iteminfo.OthAmt = operation_other_amt
  18667. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18668. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18669. }
  18670. if materialCostTotal != 0 {
  18671. iteminfo.MedChrgitm = "08"
  18672. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18673. iteminfo.Amt = materialCostTotal
  18674. iteminfo.ClaaSumfee = material_claa_sunmfee
  18675. iteminfo.ClabAmt = material_clab_amt
  18676. iteminfo.OthAmt = material_other_amt
  18677. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18678. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18679. }
  18680. if westernMedicineCostTotal != 0 {
  18681. iteminfo.MedChrgitm = "09"
  18682. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18683. iteminfo.Amt = westernMedicineCostTotal
  18684. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18685. iteminfo.ClabAmt = westernMedicine_clab_amt
  18686. iteminfo.OthAmt = westernMedicine_other_amt
  18687. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18688. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18689. }
  18690. if chineseTraditionalMedicineCostTotal != 0 {
  18691. iteminfo.MedChrgitm = "11"
  18692. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18693. iteminfo.Amt = westernMedicineCostTotal
  18694. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18695. iteminfo.ClabAmt = westernMedicine_clab_amt
  18696. iteminfo.OthAmt = westernMedicine_other_amt
  18697. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18698. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18699. }
  18700. if otherCostTotal != 0 {
  18701. iteminfo.MedChrgitm = "14"
  18702. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18703. iteminfo.Amt = otherCostTotal
  18704. iteminfo.ClaaSumfee = other_claa_sunmfee
  18705. iteminfo.ClabAmt = other_clab_amt
  18706. iteminfo.OthAmt = other_other_amt
  18707. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18708. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18709. }
  18710. struct4101.IteminfoStruct = iteminfoStructs
  18711. struct4101.Ntly = "中国"
  18712. struct4101.AdmCaty = "A03.06"
  18713. struct4101.DoctorName = doctor.UserName
  18714. struct4101.DoctorCode = doctor.DoctorNumber
  18715. var res ResultSeventeen
  18716. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18717. struct4101.BillCode = order.Number
  18718. struct4101.BillNo = order.SetlId
  18719. var resOther ResultSeventeenOther
  18720. var pp models.PublicParams
  18721. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18722. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18723. pp.FixmedinsName = miConfig.OrgName
  18724. pp.FixmedinsCode = miConfig.Code
  18725. pp.RequestUrl = miConfig.Url
  18726. pp.Cainfo = miConfig.Cainfo
  18727. pp.SecretKey = miConfig.SecretKey
  18728. pp.AccessKey = miConfig.AccessKey
  18729. pp.OpterName = curRoles.UserName
  18730. client := &http.Client{}
  18731. var req *http.Request
  18732. data := make(map[string]interface{})
  18733. data["struct4101"] = struct4101
  18734. data["pp"] = pp
  18735. bytesData, _ := json.Marshal(data)
  18736. if miConfig.MdtrtareaAdmvs == "320921" {
  18737. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18738. } else {
  18739. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18740. }
  18741. resp, _ := client.Do(req)
  18742. defer resp.Body.Close()
  18743. body, ioErr := ioutil.ReadAll(resp.Body)
  18744. if ioErr != nil {
  18745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18747. return
  18748. }
  18749. var respJSON map[string]interface{}
  18750. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18753. return
  18754. }
  18755. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18756. userJSONBytes, _ := json.Marshal(respJSON)
  18757. fmt.Println("log")
  18758. fmt.Println(string(userJSONBytes))
  18759. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18760. utils.ErrorLog("解析失败:%v", err)
  18761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18762. return
  18763. }
  18764. res.InfRefmsgid = resOther.InfRefmsgid
  18765. res.Output = resOther.Output
  18766. res.ErrMsg = resOther.ErrMsg
  18767. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18768. res.Infcode = infocode
  18769. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18770. var pp models.PublicParams
  18771. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18772. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18773. pp.FixmedinsName = miConfig.OrgName
  18774. pp.FixmedinsCode = miConfig.Code
  18775. pp.RequestUrl = miConfig.Url
  18776. pp.Cainfo = miConfig.Cainfo
  18777. pp.SecretKey = miConfig.SecretKey
  18778. pp.AccessKey = miConfig.AccessKey
  18779. pp.OpterName = curRoles.UserName
  18780. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18781. result, _ := service.Jxyb4101(struct4101, pp)
  18782. var dat map[string]interface{}
  18783. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18784. fmt.Println(dat)
  18785. } else {
  18786. fmt.Println(err)
  18787. }
  18788. userJSONBytes, _ := json.Marshal(dat)
  18789. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18790. utils.ErrorLog("解析失败:%v", err)
  18791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18792. return
  18793. }
  18794. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18795. var pp models.PublicParams
  18796. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18797. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18798. pp.FixmedinsName = miConfig.OrgName
  18799. pp.FixmedinsCode = miConfig.Code
  18800. pp.RequestUrl = miConfig.Url
  18801. pp.Cainfo = miConfig.Cainfo
  18802. pp.SecretKey = miConfig.SecretKey
  18803. pp.AccessKey = miConfig.AccessKey
  18804. pp.OpterName = curRoles.UserName
  18805. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18806. result, _ := service.Jxyb4101(struct4101, pp)
  18807. var dat map[string]interface{}
  18808. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18809. fmt.Println(dat)
  18810. } else {
  18811. fmt.Println(err)
  18812. }
  18813. userJSONBytes, _ := json.Marshal(dat)
  18814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18815. utils.ErrorLog("解析失败:%v", err)
  18816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18817. return
  18818. }
  18819. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18820. var pp models.PublicParams
  18821. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18822. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18823. pp.FixmedinsName = miConfig.OrgName
  18824. pp.FixmedinsCode = miConfig.Code
  18825. pp.RequestUrl = miConfig.Url
  18826. pp.Cainfo = miConfig.Cainfo
  18827. pp.SecretKey = miConfig.SecretKey
  18828. pp.AccessKey = miConfig.AccessKey
  18829. pp.OpterName = curRoles.UserName
  18830. result, _ := service.Hnyb4101(struct4101, pp)
  18831. var dat map[string]interface{}
  18832. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18833. fmt.Println(dat)
  18834. } else {
  18835. fmt.Println(err)
  18836. }
  18837. userJSONBytes, _ := json.Marshal(dat)
  18838. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18839. utils.ErrorLog("解析失败:%v", err)
  18840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18841. return
  18842. }
  18843. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18844. var resOther ResultSeventeenOther
  18845. var pp models.PublicParams
  18846. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18847. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18848. pp.FixmedinsName = miConfig.OrgName
  18849. pp.FixmedinsCode = miConfig.Code
  18850. pp.RequestUrl = miConfig.Url
  18851. pp.Cainfo = miConfig.Cainfo
  18852. pp.SecretKey = miConfig.SecretKey
  18853. pp.AccessKey = miConfig.AccessKey
  18854. pp.OpterName = curRoles.UserName
  18855. client := &http.Client{}
  18856. var req *http.Request
  18857. data := make(map[string]interface{})
  18858. data["struct4101"] = struct4101
  18859. data["pp"] = pp
  18860. bytesData, _ := json.Marshal(data)
  18861. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18862. resp, _ := client.Do(req)
  18863. defer resp.Body.Close()
  18864. body, ioErr := ioutil.ReadAll(resp.Body)
  18865. if ioErr != nil {
  18866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18868. return
  18869. }
  18870. var respJSON map[string]interface{}
  18871. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18874. return
  18875. }
  18876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18877. userJSONBytes, _ := json.Marshal(respJSON)
  18878. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18879. utils.ErrorLog("解析失败:%v", err)
  18880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18881. return
  18882. }
  18883. res.InfRefmsgid = resOther.InfRefmsgid
  18884. res.Output = resOther.Output
  18885. res.ErrMsg = resOther.ErrMsg
  18886. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18887. res.Infcode = infocode
  18888. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18889. var pp models.PublicParams
  18890. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18891. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18892. pp.FixmedinsName = miConfig.OrgName
  18893. pp.FixmedinsCode = miConfig.Code
  18894. pp.RequestUrl = miConfig.Url
  18895. pp.Cainfo = miConfig.Cainfo
  18896. pp.SecretKey = miConfig.SecretKey
  18897. pp.AccessKey = miConfig.AccessKey
  18898. pp.OpterName = curRoles.UserName
  18899. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18900. fmt.Println(requestLog)
  18901. fmt.Println(errMsgLog)
  18902. saveLog(result, requestLog, "4101a", "上传清单")
  18903. var dat map[string]interface{}
  18904. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18905. fmt.Println(dat)
  18906. } else {
  18907. fmt.Println(err)
  18908. }
  18909. userJSONBytes, _ := json.Marshal(dat)
  18910. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18911. utils.ErrorLog("解析失败:%v", err)
  18912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18913. return
  18914. }
  18915. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18916. var pp models.PublicParams
  18917. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18918. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18919. pp.FixmedinsName = miConfig.OrgName
  18920. pp.FixmedinsCode = miConfig.Code
  18921. pp.RequestUrl = miConfig.Url
  18922. pp.Cainfo = miConfig.Cainfo
  18923. pp.SecretKey = miConfig.SecretKey
  18924. pp.AccessKey = miConfig.AccessKey
  18925. pp.OpterName = curRoles.UserName
  18926. client := &http.Client{}
  18927. var req *http.Request
  18928. data := make(map[string]interface{})
  18929. data["struct4101"] = struct4101
  18930. data["pp"] = pp
  18931. bytesData, _ := json.Marshal(data)
  18932. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18933. resp, _ := client.Do(req)
  18934. defer resp.Body.Close()
  18935. body, ioErr := ioutil.ReadAll(resp.Body)
  18936. if ioErr != nil {
  18937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18939. return
  18940. }
  18941. var respJSON map[string]interface{}
  18942. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18945. return
  18946. }
  18947. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18948. userJSONBytes, _ := json.Marshal(respJSON)
  18949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18950. utils.ErrorLog("解析失败:%v", err)
  18951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18952. return
  18953. }
  18954. } else {
  18955. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18956. var dat map[string]interface{}
  18957. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18958. fmt.Println(dat)
  18959. } else {
  18960. fmt.Println(err)
  18961. }
  18962. userJSONBytes, _ := json.Marshal(dat)
  18963. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18964. utils.ErrorLog("解析失败:%v", err)
  18965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18966. return
  18967. }
  18968. }
  18969. if res.Infcode != 0 {
  18970. errlog := &models.HisOrderError{
  18971. UserOrgId: order.UserOrgId,
  18972. Ctime: time.Now().Unix(),
  18973. Mtime: time.Now().Unix(),
  18974. ErrMsg: res.ErrMsg + "解析失败",
  18975. Status: 1,
  18976. PatientId: order.ID,
  18977. Stage: 10485,
  18978. }
  18979. service.CreateErrMsgLog(errlog)
  18980. continue
  18981. //c.ServeSuccessJSON(map[string]interface{}{
  18982. // "failed_code": -10,
  18983. // "msg": res.ErrMsg,
  18984. //})
  18985. } else {
  18986. //order.FaPiaoNumber = zero
  18987. //order.FaPiaoCode = last_order.FaPiaoCode
  18988. //service.UpdateOrder(order)
  18989. hisFundSettleListResult := &models.HisFundSettleListResult{
  18990. Number: res.Output.SetlListId,
  18991. Status: 1,
  18992. Ctime: time.Now().Unix(),
  18993. Mtime: time.Now().Unix(),
  18994. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18995. IsUpload: 1,
  18996. OrderId: order.ID,
  18997. }
  18998. service.CreateUploadRecord(hisFundSettleListResult)
  18999. continue
  19000. }
  19001. }
  19002. }
  19003. func (c *HisApiController) GetSettleList() {
  19004. order_id, _ := c.GetInt64("order_id")
  19005. admin_user_id, _ := c.GetInt64("admin_user_id")
  19006. order, _ := service.GetHisOrderByIDTwo(order_id)
  19007. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19008. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19009. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19010. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19011. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19012. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19013. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19014. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19015. if order.ID == 0 {
  19016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19017. return
  19018. }
  19019. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19020. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19021. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19022. //fmt.Println(count)
  19023. //var zero string
  19024. //number := count + 1
  19025. //if number >= 1000 {
  19026. // zero = "0000" + strconv.FormatInt(number, 10)
  19027. //} else if number >= 10000 {
  19028. // zero = "000" + strconv.FormatInt(number, 10)
  19029. //} else if number >= 100000 {
  19030. // zero = "00" + strconv.FormatInt(number, 10)
  19031. //} else if number >= 1000000 {
  19032. // zero = "0" + strconv.FormatInt(number, 10)
  19033. //} else {
  19034. // zero = strconv.FormatInt(number, 10)
  19035. //}
  19036. //fmt.Println(zero)
  19037. struct4101 := service.Struct4101{
  19038. PsnNo: order.PsnNo,
  19039. MdtrtId: order.MdtrtId,
  19040. SetlId: order.SetlId,
  19041. PsnName: order.PsnName,
  19042. Gend: order.Gend,
  19043. Brdy: his.Brdy,
  19044. Age: his.Age,
  19045. Naty: order.Naty,
  19046. PatnCertType: "01",
  19047. Certno: order.Certno,
  19048. Prfs: "90",
  19049. ConerName: roles[0].UserName,
  19050. PatnRlts: "99",
  19051. ConerAddr: miConfig.OrgName,
  19052. ConerTel: admin.Mobile,
  19053. HiType: order.Insutype,
  19054. Insuplc: miConfig.InsuplcAdmdvs,
  19055. MaindiagFlag: "1",
  19056. BillCode: order.SetlId,
  19057. BillNo: order.SetlId,
  19058. BizSn: order.Number,
  19059. PsnSelfPay: order.PsnPartAmt,
  19060. PsnOwnPay: order.PsnPartAmt,
  19061. AcctPay: order.AcctPay,
  19062. PsnCashpay: order.PsnCashPay,
  19063. HiPaymtd: "1",
  19064. Hsorg: miConfig.InsuplcAdmdvs,
  19065. HsorgOpter: miConfig.InsuplcAdmdvs,
  19066. MedinsFillPsn: curRoles.UserName,
  19067. MedinsFillDept: miConfig.OrgName,
  19068. IptMedType: "2",
  19069. }
  19070. struct4101.SetlBegnDate = order.SetlTime
  19071. struct4101.SetlEndDate = order.SetlTime
  19072. time_arr := strings.Split(order.SetlTime, " ")
  19073. struct4101.AdmTime = time_arr[0]
  19074. struct4101.AdmEndTime = time_arr[0]
  19075. //
  19076. //var rf []CustomFundPay
  19077. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19078. //
  19079. //var tempFunPays []service.CustomStruct
  19080. //for _, item := range rf {
  19081. // var tempFunPay service.CustomStruct
  19082. // tempFunPay.FundPayamt = item.FundPayamt
  19083. // tempFunPay.FundPayType = item.FundPayType
  19084. // tempFunPays = append(tempFunPays, tempFunPay)
  19085. //}
  19086. //struct4101.CustomStruct = tempFunPays
  19087. var tempDiaginfos []service.DiaginfoStructTwo
  19088. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19089. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19090. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19091. var config []*models.HisXtDiagnoseConfig
  19092. for _, item := range diagnosis_ids {
  19093. id, _ := strconv.ParseInt(item, 10, 64)
  19094. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19095. config = append(config, &diagnosisConfig)
  19096. }
  19097. if miConfig.Code == "H15049901371" {
  19098. //for _, item := range config {
  19099. // if item.ID == 138 {
  19100. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19101. var tempDiaginfo service.DiaginfoStructTwo
  19102. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19103. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19104. tempDiaginfo.DiagType = "1"
  19105. tempDiaginfo.MaindiagFlag = "1"
  19106. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19107. //}
  19108. //}
  19109. for _, item := range config {
  19110. if item.ID != 138 {
  19111. var tempDiaginfo service.DiaginfoStructTwo
  19112. tempDiaginfo.DiagCode = item.CountryCode
  19113. tempDiaginfo.DiagName = item.CountryContentName
  19114. tempDiaginfo.DiagType = "1"
  19115. tempDiaginfo.MaindiagFlag = "0"
  19116. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19117. }
  19118. }
  19119. } else {
  19120. for index, item := range config {
  19121. if index == 0 {
  19122. var tempDiaginfo service.DiaginfoStructTwo
  19123. tempDiaginfo.DiagCode = item.CountryCode
  19124. tempDiaginfo.DiagName = item.CountryContentName
  19125. tempDiaginfo.DiagType = "1"
  19126. tempDiaginfo.MaindiagFlag = "1"
  19127. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19128. } else {
  19129. var tempDiaginfo service.DiaginfoStructTwo
  19130. tempDiaginfo.DiagCode = item.CountryCode
  19131. tempDiaginfo.DiagName = item.CountryContentName
  19132. tempDiaginfo.DiagType = "1"
  19133. tempDiaginfo.MaindiagFlag = "0"
  19134. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19135. }
  19136. }
  19137. }
  19138. struct4101.Diseinfo = tempDiaginfos
  19139. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19140. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19141. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19142. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19143. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19144. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19145. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19146. var iteminfo service.IteminfoStruct
  19147. var bedCostTotal float64 = 0 //床位总费
  19148. var bedCostSelfTotal float64 = 0 //床位自费
  19149. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19150. var operationCostTotal float64 = 0 //手术费
  19151. var operationCostSelfTotal float64 = 0 //手术费
  19152. var operationCostPartSelfTotal float64 = 0 //手术费
  19153. var otherCostTotal float64 = 0 //其他费用
  19154. var otherCostSelfTotal float64 = 0 //其他费用
  19155. var otherCostPartSelfTotal float64 = 0 //其他费用
  19156. var materialCostTotal float64 = 0 //材料费
  19157. var materialCostSelfTotal float64 = 0 //材料费
  19158. var materialCostPartSelfTotal float64 = 0 //材料费
  19159. var westernMedicineCostTotal float64 = 0 //西药费
  19160. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19161. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19162. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19163. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19164. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19165. var checkCostTotal float64 = 0 //检查费
  19166. var checkCostSelfTotal float64 = 0 //检查费
  19167. var checkCostPartSelfTotal float64 = 0 //检查费
  19168. var laboratoryCostTotal float64 = 0 //化验费
  19169. var laboratoryCostSelfTotal float64 = 0 //化验费
  19170. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19171. var treatCostTotal float64 = 0 //治疗费用
  19172. var treatCostSelfTotal float64 = 0 //治疗费用
  19173. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19174. decimal.DivisionPrecision = 2
  19175. var bed_fulamt_ownpay_amt float64 = 0
  19176. var operation_fulamt_ownpay_amt float64 = 0
  19177. var other_fulamt_ownpay_amt float64 = 0
  19178. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19179. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19180. var check_fulamt_ownpay_amt float64 = 0
  19181. var material_fulamt_ownpay_amt float64 = 0
  19182. var laboratory_fulamt_ownpay_amt float64 = 0
  19183. var treat_fulamt_ownpay_amt float64 = 0
  19184. var bed_claa_sunmfee float64 = 0
  19185. var bed_clab_amt float64 = 0
  19186. var bed_other_amt float64 = 0
  19187. var operation_claa_sunmfee float64 = 0
  19188. var operation_clab_amt float64 = 0
  19189. var operation_other_amt float64 = 0
  19190. var other_claa_sunmfee float64 = 0
  19191. var other_clab_amt float64 = 0
  19192. var other_other_amt float64 = 0
  19193. var westernMedicine_claa_sunmfee float64 = 0
  19194. var westernMedicine_clab_amt float64 = 0
  19195. var westernMedicine_other_amt float64 = 0
  19196. var chineseTraditional_claa_sunmfee float64 = 0
  19197. var chineseTraditional_clab_amt float64 = 0
  19198. var chineseTraditional_other_amt float64 = 0
  19199. var check_claa_sunmfee float64 = 0
  19200. var check_clab_amt float64 = 0
  19201. var check_other_amt float64 = 0
  19202. var material_claa_sunmfee float64 = 0
  19203. var material_clab_amt float64 = 0
  19204. var material_other_amt float64 = 0
  19205. var laboratory_claa_sunmfee float64 = 0
  19206. var laboratory_clab_amt float64 = 0
  19207. var laboratory_other_amt float64 = 0
  19208. var treat_claa_sunmfee float64 = 0
  19209. var treat_clab_amt float64 = 0
  19210. var treat_other_amt float64 = 0
  19211. for _, item := range order.HisOrderInfo {
  19212. if item.MedChrgitmType == "01" { //床位费
  19213. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19214. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19215. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19216. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19217. if item.ChrgitmLv == "1" {
  19218. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19219. }
  19220. if item.ChrgitmLv == "2" {
  19221. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19222. }
  19223. if item.ChrgitmLv == "3" {
  19224. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19225. }
  19226. }
  19227. if item.MedChrgitmType == "03" { //检查费
  19228. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19229. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19230. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19231. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19232. if item.ChrgitmLv == "1" {
  19233. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19234. }
  19235. if item.ChrgitmLv == "2" {
  19236. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19237. }
  19238. if item.ChrgitmLv == "3" {
  19239. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19240. }
  19241. }
  19242. if item.MedChrgitmType == "04" { //化验费
  19243. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19244. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19245. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19246. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19247. if item.ChrgitmLv == "1" {
  19248. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19249. }
  19250. if item.ChrgitmLv == "2" {
  19251. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19252. }
  19253. if item.ChrgitmLv == "3" {
  19254. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19255. }
  19256. }
  19257. if item.MedChrgitmType == "05" { //治疗费
  19258. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19259. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19260. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19261. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19262. if item.ChrgitmLv == "1" {
  19263. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19264. }
  19265. if item.ChrgitmLv == "2" {
  19266. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19267. }
  19268. if item.ChrgitmLv == "3" {
  19269. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19270. }
  19271. }
  19272. if item.MedChrgitmType == "06" { //手术费
  19273. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19274. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19275. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19276. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19277. if item.ChrgitmLv == "1" {
  19278. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19279. }
  19280. if item.ChrgitmLv == "2" {
  19281. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19282. }
  19283. if item.ChrgitmLv == "3" {
  19284. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19285. }
  19286. }
  19287. if item.MedChrgitmType == "08" { //材料费
  19288. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19289. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19290. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19291. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19292. if item.ChrgitmLv == "1" {
  19293. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19294. }
  19295. if item.ChrgitmLv == "2" {
  19296. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19297. }
  19298. if item.ChrgitmLv == "3" {
  19299. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19300. }
  19301. }
  19302. if item.MedChrgitmType == "09" { //西药费
  19303. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19304. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19305. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19306. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19307. if item.ChrgitmLv == "1" {
  19308. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19309. }
  19310. if item.ChrgitmLv == "2" {
  19311. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19312. }
  19313. if item.ChrgitmLv == "3" {
  19314. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19315. }
  19316. }
  19317. if item.MedChrgitmType == "11" { //中成费
  19318. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19319. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19320. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19321. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19322. if item.ChrgitmLv == "1" {
  19323. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19324. }
  19325. if item.ChrgitmLv == "2" {
  19326. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19327. }
  19328. if item.ChrgitmLv == "3" {
  19329. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19330. }
  19331. }
  19332. if item.MedChrgitmType == "14" { //其他费
  19333. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19334. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19335. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19336. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19337. if item.ChrgitmLv == "1" {
  19338. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19339. }
  19340. if item.ChrgitmLv == "2" {
  19341. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19342. }
  19343. if item.ChrgitmLv == "3" {
  19344. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19345. }
  19346. }
  19347. }
  19348. var iteminfoStructs []service.IteminfoStruct
  19349. if bedCostTotal != 0 {
  19350. iteminfo.MedChrgitm = "01"
  19351. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19352. iteminfo.Amt = bedCostTotal
  19353. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19354. iteminfo.ClabAmt = bed_clab_amt
  19355. iteminfo.OthAmt = bed_other_amt
  19356. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19357. }
  19358. if checkCostTotal != 0 {
  19359. iteminfo.MedChrgitm = "03"
  19360. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19361. iteminfo.Amt = checkCostTotal
  19362. iteminfo.ClaaSumfee = check_claa_sunmfee
  19363. iteminfo.ClabAmt = check_clab_amt
  19364. iteminfo.OthAmt = check_other_amt
  19365. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19366. }
  19367. if laboratoryCostTotal != 0 {
  19368. iteminfo.MedChrgitm = "04"
  19369. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19370. iteminfo.Amt = laboratoryCostTotal
  19371. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19372. iteminfo.ClabAmt = laboratory_clab_amt
  19373. iteminfo.OthAmt = laboratory_other_amt
  19374. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19375. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19376. }
  19377. if treatCostTotal != 0 {
  19378. iteminfo.MedChrgitm = "05"
  19379. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19380. iteminfo.Amt = treatCostTotal
  19381. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19382. iteminfo.ClabAmt = treat_clab_amt
  19383. iteminfo.OthAmt = treat_other_amt
  19384. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19385. //(struct4101.IteminfoStruct, iteminfo)
  19386. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19387. }
  19388. if operationCostTotal != 0 {
  19389. iteminfo.MedChrgitm = "06"
  19390. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19391. iteminfo.Amt = operationCostTotal
  19392. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19393. iteminfo.ClabAmt = operation_clab_amt
  19394. iteminfo.OthAmt = operation_other_amt
  19395. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19396. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19397. }
  19398. if materialCostTotal != 0 {
  19399. iteminfo.MedChrgitm = "08"
  19400. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19401. iteminfo.Amt = materialCostTotal
  19402. iteminfo.ClaaSumfee = material_claa_sunmfee
  19403. iteminfo.ClabAmt = material_clab_amt
  19404. iteminfo.OthAmt = material_other_amt
  19405. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19406. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19407. }
  19408. if westernMedicineCostTotal != 0 {
  19409. iteminfo.MedChrgitm = "09"
  19410. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19411. iteminfo.Amt = westernMedicineCostTotal
  19412. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19413. iteminfo.ClabAmt = westernMedicine_clab_amt
  19414. iteminfo.OthAmt = westernMedicine_other_amt
  19415. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19416. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19417. }
  19418. if chineseTraditionalMedicineCostTotal != 0 {
  19419. iteminfo.MedChrgitm = "11"
  19420. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19421. iteminfo.Amt = westernMedicineCostTotal
  19422. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19423. iteminfo.ClabAmt = westernMedicine_clab_amt
  19424. iteminfo.OthAmt = westernMedicine_other_amt
  19425. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19426. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19427. }
  19428. if otherCostTotal != 0 {
  19429. iteminfo.MedChrgitm = "14"
  19430. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19431. iteminfo.Amt = otherCostTotal
  19432. iteminfo.ClaaSumfee = other_claa_sunmfee
  19433. iteminfo.ClabAmt = other_clab_amt
  19434. iteminfo.OthAmt = other_other_amt
  19435. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19436. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19437. }
  19438. struct4101.IteminfoStruct = iteminfoStructs
  19439. struct4101.Ntly = "中国"
  19440. struct4101.AdmCaty = "A03.06"
  19441. struct4101.DoctorName = doctor.UserName
  19442. struct4101.DoctorCode = doctor.DoctorNumber
  19443. var res ResultSeventeen
  19444. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19445. struct4101.BillCode = order.Number
  19446. struct4101.BillNo = order.SetlId
  19447. var resOther ResultSeventeenOther
  19448. var pp models.PublicParams
  19449. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19450. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19451. pp.FixmedinsName = miConfig.OrgName
  19452. pp.FixmedinsCode = miConfig.Code
  19453. pp.RequestUrl = miConfig.Url
  19454. pp.Cainfo = miConfig.Cainfo
  19455. pp.SecretKey = miConfig.SecretKey
  19456. pp.AccessKey = miConfig.AccessKey
  19457. pp.OpterName = curRoles.UserName
  19458. client := &http.Client{}
  19459. var req *http.Request
  19460. data := make(map[string]interface{})
  19461. data["struct4101"] = struct4101
  19462. data["pp"] = pp
  19463. bytesData, _ := json.Marshal(data)
  19464. if miConfig.MdtrtareaAdmvs == "320921" {
  19465. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19466. } else {
  19467. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19468. }
  19469. resp, _ := client.Do(req)
  19470. defer resp.Body.Close()
  19471. body, ioErr := ioutil.ReadAll(resp.Body)
  19472. if ioErr != nil {
  19473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19475. return
  19476. }
  19477. var respJSON map[string]interface{}
  19478. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19481. return
  19482. }
  19483. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19484. userJSONBytes, _ := json.Marshal(respJSON)
  19485. fmt.Println("log")
  19486. fmt.Println(string(userJSONBytes))
  19487. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19488. utils.ErrorLog("解析失败:%v", err)
  19489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19490. return
  19491. }
  19492. res.InfRefmsgid = resOther.InfRefmsgid
  19493. res.Output = resOther.Output
  19494. res.ErrMsg = resOther.ErrMsg
  19495. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19496. res.Infcode = infocode
  19497. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19498. var pp models.PublicParams
  19499. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19500. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19501. pp.FixmedinsName = miConfig.OrgName
  19502. pp.FixmedinsCode = miConfig.Code
  19503. pp.RequestUrl = miConfig.Url
  19504. pp.Cainfo = miConfig.Cainfo
  19505. pp.SecretKey = miConfig.SecretKey
  19506. pp.AccessKey = miConfig.AccessKey
  19507. pp.OpterName = curRoles.UserName
  19508. result, _ := service.Jxyb4101(struct4101, pp)
  19509. var dat map[string]interface{}
  19510. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19511. fmt.Println(dat)
  19512. } else {
  19513. fmt.Println(err)
  19514. }
  19515. userJSONBytes, _ := json.Marshal(dat)
  19516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19517. utils.ErrorLog("解析失败:%v", err)
  19518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19519. return
  19520. }
  19521. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19522. var pp models.PublicParams
  19523. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19524. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19525. pp.FixmedinsName = miConfig.OrgName
  19526. pp.FixmedinsCode = miConfig.Code
  19527. pp.RequestUrl = miConfig.Url
  19528. pp.Cainfo = miConfig.Cainfo
  19529. pp.SecretKey = miConfig.SecretKey
  19530. pp.AccessKey = miConfig.AccessKey
  19531. pp.OpterName = curRoles.UserName
  19532. result, _ := service.Jxyb4101(struct4101, pp)
  19533. var dat map[string]interface{}
  19534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19535. fmt.Println(dat)
  19536. } else {
  19537. fmt.Println(err)
  19538. }
  19539. userJSONBytes, _ := json.Marshal(dat)
  19540. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19541. utils.ErrorLog("解析失败:%v", err)
  19542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19543. return
  19544. }
  19545. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19546. var pp models.PublicParams
  19547. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19548. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19549. pp.FixmedinsName = miConfig.OrgName
  19550. pp.FixmedinsCode = miConfig.Code
  19551. pp.RequestUrl = miConfig.Url
  19552. pp.Cainfo = miConfig.Cainfo
  19553. pp.SecretKey = miConfig.SecretKey
  19554. pp.AccessKey = miConfig.AccessKey
  19555. pp.OpterName = curRoles.UserName
  19556. result, _ := service.Hnyb4101(struct4101, pp)
  19557. var dat map[string]interface{}
  19558. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19559. fmt.Println(dat)
  19560. } else {
  19561. fmt.Println(err)
  19562. }
  19563. userJSONBytes, _ := json.Marshal(dat)
  19564. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19565. utils.ErrorLog("解析失败:%v", err)
  19566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19567. return
  19568. }
  19569. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19570. var resOther ResultSeventeenOther
  19571. var pp models.PublicParams
  19572. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19573. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19574. pp.FixmedinsName = miConfig.OrgName
  19575. pp.FixmedinsCode = miConfig.Code
  19576. pp.RequestUrl = miConfig.Url
  19577. pp.Cainfo = miConfig.Cainfo
  19578. pp.SecretKey = miConfig.SecretKey
  19579. pp.AccessKey = miConfig.AccessKey
  19580. pp.OpterName = curRoles.UserName
  19581. client := &http.Client{}
  19582. var req *http.Request
  19583. data := make(map[string]interface{})
  19584. data["struct4101"] = struct4101
  19585. data["pp"] = pp
  19586. bytesData, _ := json.Marshal(data)
  19587. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19588. resp, _ := client.Do(req)
  19589. defer resp.Body.Close()
  19590. body, ioErr := ioutil.ReadAll(resp.Body)
  19591. if ioErr != nil {
  19592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19594. return
  19595. }
  19596. var respJSON map[string]interface{}
  19597. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19600. return
  19601. }
  19602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19603. userJSONBytes, _ := json.Marshal(respJSON)
  19604. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19605. utils.ErrorLog("解析失败:%v", err)
  19606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19607. return
  19608. }
  19609. res.InfRefmsgid = resOther.InfRefmsgid
  19610. res.Output = resOther.Output
  19611. res.ErrMsg = resOther.ErrMsg
  19612. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19613. res.Infcode = infocode
  19614. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19615. var pp models.PublicParams
  19616. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19617. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19618. pp.FixmedinsName = miConfig.OrgName
  19619. pp.FixmedinsCode = miConfig.Code
  19620. pp.RequestUrl = miConfig.Url
  19621. pp.Cainfo = miConfig.Cainfo
  19622. pp.SecretKey = miConfig.SecretKey
  19623. pp.AccessKey = miConfig.AccessKey
  19624. pp.OpterName = curRoles.UserName
  19625. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19626. fmt.Println(requestLog)
  19627. fmt.Println(errMsgLog)
  19628. saveLog(result, requestLog, "4101a", "上传清单")
  19629. var dat map[string]interface{}
  19630. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19631. fmt.Println(dat)
  19632. } else {
  19633. fmt.Println(err)
  19634. }
  19635. userJSONBytes, _ := json.Marshal(dat)
  19636. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19637. utils.ErrorLog("解析失败:%v", err)
  19638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19639. return
  19640. }
  19641. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19642. var pp models.PublicParams
  19643. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19644. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19645. pp.FixmedinsName = miConfig.OrgName
  19646. pp.FixmedinsCode = miConfig.Code
  19647. pp.RequestUrl = miConfig.Url
  19648. pp.Cainfo = miConfig.Cainfo
  19649. pp.SecretKey = miConfig.SecretKey
  19650. pp.AccessKey = miConfig.AccessKey
  19651. pp.OpterName = curRoles.UserName
  19652. client := &http.Client{}
  19653. var req *http.Request
  19654. data := make(map[string]interface{})
  19655. data["struct4101"] = struct4101
  19656. data["pp"] = pp
  19657. bytesData, _ := json.Marshal(data)
  19658. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19659. resp, _ := client.Do(req)
  19660. defer resp.Body.Close()
  19661. body, ioErr := ioutil.ReadAll(resp.Body)
  19662. if ioErr != nil {
  19663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19665. return
  19666. }
  19667. var respJSON map[string]interface{}
  19668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19671. return
  19672. }
  19673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19674. userJSONBytes, _ := json.Marshal(respJSON)
  19675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19676. utils.ErrorLog("解析失败:%v", err)
  19677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19678. return
  19679. }
  19680. } else {
  19681. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19682. var dat map[string]interface{}
  19683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19684. fmt.Println(dat)
  19685. } else {
  19686. fmt.Println(err)
  19687. }
  19688. userJSONBytes, _ := json.Marshal(dat)
  19689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19690. utils.ErrorLog("解析失败:%v", err)
  19691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19692. return
  19693. }
  19694. }
  19695. if res.Infcode != 0 {
  19696. c.ServeSuccessJSON(map[string]interface{}{
  19697. "failed_code": -10,
  19698. "msg": res.ErrMsg,
  19699. })
  19700. return
  19701. } else {
  19702. //order.FaPiaoNumber = zero
  19703. //order.FaPiaoCode = last_order.FaPiaoCode
  19704. //service.UpdateOrder(order)
  19705. hisFundSettleListResult := &models.HisFundSettleListResult{
  19706. Number: res.Output.SetlListId,
  19707. Status: 1,
  19708. Ctime: time.Now().Unix(),
  19709. Mtime: time.Now().Unix(),
  19710. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19711. IsUpload: 1,
  19712. OrderId: order_id,
  19713. }
  19714. service.CreateUploadRecord(hisFundSettleListResult)
  19715. c.ServeSuccessJSON(map[string]interface{}{
  19716. "msg": "上传成功",
  19717. "result": hisFundSettleListResult,
  19718. })
  19719. return
  19720. }
  19721. }
  19722. func (c *HisApiController) GetSettleListHospital() {
  19723. order_id, _ := c.GetInt64("order_id")
  19724. admin_user_id, _ := c.GetInt64("admin_user_id")
  19725. order, _ := service.GetHisOrderByIDTwo(order_id)
  19726. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19727. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19728. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19729. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19730. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19731. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19732. if order.ID == 0 {
  19733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19734. return
  19735. }
  19736. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19737. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19738. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19739. fmt.Println(count)
  19740. var zero string
  19741. number := count + 1
  19742. if number >= 1000 {
  19743. zero = "0000" + strconv.FormatInt(number, 10)
  19744. } else if number >= 10000 {
  19745. zero = "000" + strconv.FormatInt(number, 10)
  19746. } else if number >= 100000 {
  19747. zero = "00" + strconv.FormatInt(number, 10)
  19748. } else if number >= 1000000 {
  19749. zero = "0" + strconv.FormatInt(number, 10)
  19750. } else {
  19751. zero = strconv.FormatInt(number, 10)
  19752. }
  19753. fmt.Println(zero)
  19754. struct4101 := service.Struct4101{
  19755. PsnNo: order.PsnNo,
  19756. MdtrtId: order.MdtrtId,
  19757. SetlId: order.SetlId,
  19758. PsnName: order.PsnName,
  19759. Gend: order.Gend,
  19760. Brdy: his.Brdy,
  19761. Age: int64(order.Age),
  19762. Naty: order.Naty,
  19763. PatnCertType: "01",
  19764. Certno: order.Certno,
  19765. Prfs: "90",
  19766. ConerName: roles[0].UserName,
  19767. PatnRlts: "99",
  19768. ConerAddr: miConfig.OrgName,
  19769. ConerTel: admin.Mobile,
  19770. HiType: order.Insutype,
  19771. Insuplc: miConfig.InsuplcAdmdvs,
  19772. MaindiagFlag: "1",
  19773. BillCode: order.SetlId,
  19774. BillNo: order.SetlId,
  19775. BizSn: order.Number,
  19776. PsnSelfPay: order.PsnPartAmt,
  19777. PsnOwnPay: order.PsnPartAmt,
  19778. AcctPay: order.AcctPay,
  19779. PsnCashpay: order.PsnCashPay,
  19780. HiPaymtd: "1",
  19781. Hsorg: miConfig.InsuplcAdmdvs,
  19782. HsorgOpter: miConfig.InsuplcAdmdvs,
  19783. MedinsFillPsn: curRoles.UserName,
  19784. MedinsFillDept: depart.Name,
  19785. IptMedType: "2",
  19786. AdmTime: his.InHosptialTime,
  19787. AdmEndTime: his.OutHosptialTime,
  19788. }
  19789. struct4101.SetlBegnDate = order.SetlTime
  19790. struct4101.SetlEndDate = order.SetlTime
  19791. //var rf []CustomFundPay
  19792. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19793. //
  19794. //var tempFunPays []service.CustomStruct
  19795. //for _, item := range rf {
  19796. // var tempFunPay service.CustomStruct
  19797. // tempFunPay.FundPayamt = item.FundPayamt
  19798. // tempFunPay.FundPayType = item.FundPayType
  19799. // tempFunPays = append(tempFunPays, tempFunPay)
  19800. //}
  19801. //struct4101.CustomStruct = tempFunPays
  19802. var tempDiaginfos []service.DiaginfoStructTwo
  19803. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19804. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19805. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19806. //for _, item := range infos {
  19807. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19808. //}
  19809. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19810. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19811. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19812. fmt.Println(diagnosis_ids_arr)
  19813. if order.UserOrgId == 10210 {
  19814. var diagnosis_ids_arr_two []int64
  19815. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19816. var config []*models.HisXtDiagnoseConfig
  19817. for _, id := range diagnosis_ids_arr_two {
  19818. //id, _ := strconv.ParseInt(item, 10, 64)
  19819. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19820. if diagnosisConfig.ID > 0 {
  19821. config = append(config, &diagnosisConfig)
  19822. }
  19823. }
  19824. for index, item := range config {
  19825. if item.ID > 0 {
  19826. if index == 0 {
  19827. var tempDiaginfo service.DiaginfoStructTwo
  19828. tempDiaginfo.DiagCode = item.CountryCode
  19829. tempDiaginfo.DiagName = item.CountryContentName
  19830. tempDiaginfo.DiagType = "1"
  19831. tempDiaginfo.MaindiagFlag = "1"
  19832. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19833. } else {
  19834. var tempDiaginfo service.DiaginfoStructTwo
  19835. tempDiaginfo.DiagCode = item.CountryCode
  19836. tempDiaginfo.DiagName = item.CountryContentName
  19837. tempDiaginfo.DiagType = "1"
  19838. tempDiaginfo.MaindiagFlag = "0"
  19839. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19840. }
  19841. }
  19842. }
  19843. struct4101.Diseinfo = tempDiaginfos
  19844. } else {
  19845. var config []*models.HisXtDiagnoseConfig
  19846. for _, item := range diagnosis_ids_arr {
  19847. id, _ := strconv.ParseInt(item, 10, 64)
  19848. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19849. if diagnosisConfig.ID > 0 {
  19850. config = append(config, &diagnosisConfig)
  19851. }
  19852. }
  19853. for index, item := range config {
  19854. if item.ID > 0 {
  19855. if index == 0 {
  19856. var tempDiaginfo service.DiaginfoStructTwo
  19857. tempDiaginfo.DiagCode = item.CountryCode
  19858. tempDiaginfo.DiagName = item.CountryContentName
  19859. tempDiaginfo.DiagType = "1"
  19860. tempDiaginfo.MaindiagFlag = "1"
  19861. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19862. } else {
  19863. var tempDiaginfo service.DiaginfoStructTwo
  19864. tempDiaginfo.DiagCode = item.CountryCode
  19865. tempDiaginfo.DiagName = item.CountryContentName
  19866. tempDiaginfo.DiagType = "1"
  19867. tempDiaginfo.MaindiagFlag = "0"
  19868. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19869. }
  19870. }
  19871. }
  19872. struct4101.Diseinfo = tempDiaginfos
  19873. }
  19874. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19875. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19876. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19877. tempOpspdiseinfo2.OprnOprtCode = ""
  19878. tempOpspdiseinfo2.OprnOprtName = ""
  19879. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19880. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19881. var iteminfo service.IteminfoStruct
  19882. var bedCostTotal float64 = 0 //床位总费
  19883. var bedCostSelfTotal float64 = 0 //床位自费
  19884. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19885. var operationCostTotal float64 = 0 //手术费
  19886. var operationCostSelfTotal float64 = 0 //手术费
  19887. var operationCostPartSelfTotal float64 = 0 //手术费
  19888. var otherCostTotal float64 = 0 //其他费用
  19889. var otherCostSelfTotal float64 = 0 //其他费用
  19890. var otherCostPartSelfTotal float64 = 0 //其他费用
  19891. var materialCostTotal float64 = 0 //材料费
  19892. var materialCostSelfTotal float64 = 0 //材料费
  19893. var materialCostPartSelfTotal float64 = 0 //材料费
  19894. var westernMedicineCostTotal float64 = 0 //西药费
  19895. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19896. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19897. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19898. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19899. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19900. var checkCostTotal float64 = 0 //检查费
  19901. var checkCostSelfTotal float64 = 0 //检查费
  19902. var checkCostPartSelfTotal float64 = 0 //检查费
  19903. var laboratoryCostTotal float64 = 0 //化验费
  19904. var laboratoryCostSelfTotal float64 = 0 //化验费
  19905. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19906. var treatCostTotal float64 = 0 //治疗费用
  19907. var treatCostSelfTotal float64 = 0 //治疗费用
  19908. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19909. decimal.DivisionPrecision = 2
  19910. var bed_fulamt_ownpay_amt float64 = 0
  19911. var operation_fulamt_ownpay_amt float64 = 0
  19912. var other_fulamt_ownpay_amt float64 = 0
  19913. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19914. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19915. var check_fulamt_ownpay_amt float64 = 0
  19916. var material_fulamt_ownpay_amt float64 = 0
  19917. var laboratory_fulamt_ownpay_amt float64 = 0
  19918. var treat_fulamt_ownpay_amt float64 = 0
  19919. var bed_claa_sunmfee float64 = 0
  19920. var bed_clab_amt float64 = 0
  19921. var bed_other_amt float64 = 0
  19922. var operation_claa_sunmfee float64 = 0
  19923. var operation_clab_amt float64 = 0
  19924. var operation_other_amt float64 = 0
  19925. var other_claa_sunmfee float64 = 0
  19926. var other_clab_amt float64 = 0
  19927. var other_other_amt float64 = 0
  19928. var westernMedicine_claa_sunmfee float64 = 0
  19929. var westernMedicine_clab_amt float64 = 0
  19930. var westernMedicine_other_amt float64 = 0
  19931. var chineseTraditional_claa_sunmfee float64 = 0
  19932. var chineseTraditional_clab_amt float64 = 0
  19933. var chineseTraditional_other_amt float64 = 0
  19934. var check_claa_sunmfee float64 = 0
  19935. var check_clab_amt float64 = 0
  19936. var check_other_amt float64 = 0
  19937. var material_claa_sunmfee float64 = 0
  19938. var material_clab_amt float64 = 0
  19939. var material_other_amt float64 = 0
  19940. var laboratory_claa_sunmfee float64 = 0
  19941. var laboratory_clab_amt float64 = 0
  19942. var laboratory_other_amt float64 = 0
  19943. var treat_claa_sunmfee float64 = 0
  19944. var treat_clab_amt float64 = 0
  19945. var treat_other_amt float64 = 0
  19946. for _, item := range order.HisOrderInfo {
  19947. if item.MedChrgitmType == "01" { //床位费
  19948. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19949. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19950. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19951. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19952. if item.ChrgitmLv == "1" {
  19953. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19954. }
  19955. if item.ChrgitmLv == "2" {
  19956. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19957. }
  19958. if item.ChrgitmLv == "3" {
  19959. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19960. }
  19961. }
  19962. if item.MedChrgitmType == "03" { //检查费
  19963. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19964. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19965. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19966. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19967. if item.ChrgitmLv == "1" {
  19968. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19969. }
  19970. if item.ChrgitmLv == "2" {
  19971. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19972. }
  19973. if item.ChrgitmLv == "3" {
  19974. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19975. }
  19976. }
  19977. if item.MedChrgitmType == "04" { //化验费
  19978. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19979. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19980. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19981. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19982. if item.ChrgitmLv == "1" {
  19983. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19984. }
  19985. if item.ChrgitmLv == "2" {
  19986. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19987. }
  19988. if item.ChrgitmLv == "3" {
  19989. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19990. }
  19991. }
  19992. if item.MedChrgitmType == "05" { //治疗费
  19993. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19994. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19995. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19996. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19997. if item.ChrgitmLv == "1" {
  19998. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19999. }
  20000. if item.ChrgitmLv == "2" {
  20001. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20002. }
  20003. if item.ChrgitmLv == "3" {
  20004. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20005. }
  20006. }
  20007. if item.MedChrgitmType == "06" { //手术费
  20008. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20009. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20010. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20011. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20012. if item.ChrgitmLv == "1" {
  20013. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20014. }
  20015. if item.ChrgitmLv == "2" {
  20016. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20017. }
  20018. if item.ChrgitmLv == "3" {
  20019. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20020. }
  20021. }
  20022. if item.MedChrgitmType == "08" { //材料费
  20023. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20024. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20025. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20026. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20027. if item.ChrgitmLv == "1" {
  20028. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20029. }
  20030. if item.ChrgitmLv == "2" {
  20031. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20032. }
  20033. if item.ChrgitmLv == "3" {
  20034. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20035. }
  20036. }
  20037. if item.MedChrgitmType == "09" { //西药费
  20038. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20039. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20040. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20041. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20042. if item.ChrgitmLv == "1" {
  20043. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20044. }
  20045. if item.ChrgitmLv == "2" {
  20046. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20047. }
  20048. if item.ChrgitmLv == "3" {
  20049. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20050. }
  20051. }
  20052. if item.MedChrgitmType == "11" { //中成费
  20053. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20054. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20055. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20056. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20057. if item.ChrgitmLv == "1" {
  20058. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20059. }
  20060. if item.ChrgitmLv == "2" {
  20061. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20062. }
  20063. if item.ChrgitmLv == "3" {
  20064. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20065. }
  20066. }
  20067. if item.MedChrgitmType == "14" { //其他费
  20068. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20069. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20070. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20071. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20072. if item.ChrgitmLv == "1" {
  20073. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20074. }
  20075. if item.ChrgitmLv == "2" {
  20076. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20077. }
  20078. if item.ChrgitmLv == "3" {
  20079. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20080. }
  20081. }
  20082. }
  20083. var iteminfoStructs []service.IteminfoStruct
  20084. if bedCostTotal != 0 {
  20085. iteminfo.MedChrgitm = "01"
  20086. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20087. iteminfo.Amt = bedCostTotal
  20088. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20089. iteminfo.ClabAmt = bed_clab_amt
  20090. iteminfo.OthAmt = bed_other_amt
  20091. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20092. }
  20093. if checkCostTotal != 0 {
  20094. iteminfo.MedChrgitm = "03"
  20095. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20096. iteminfo.Amt = checkCostTotal
  20097. iteminfo.ClaaSumfee = check_claa_sunmfee
  20098. iteminfo.ClabAmt = check_clab_amt
  20099. iteminfo.OthAmt = check_other_amt
  20100. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20101. }
  20102. if laboratoryCostTotal != 0 {
  20103. iteminfo.MedChrgitm = "04"
  20104. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20105. iteminfo.Amt = laboratoryCostTotal
  20106. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20107. iteminfo.ClabAmt = laboratory_clab_amt
  20108. iteminfo.OthAmt = laboratory_other_amt
  20109. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20110. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20111. }
  20112. if treatCostTotal != 0 {
  20113. iteminfo.MedChrgitm = "05"
  20114. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20115. iteminfo.Amt = treatCostTotal
  20116. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20117. iteminfo.ClabAmt = treat_clab_amt
  20118. iteminfo.OthAmt = treat_other_amt
  20119. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20120. //(struct4101.IteminfoStruct, iteminfo)
  20121. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20122. }
  20123. if operationCostTotal != 0 {
  20124. iteminfo.MedChrgitm = "06"
  20125. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20126. iteminfo.Amt = operationCostTotal
  20127. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20128. iteminfo.ClabAmt = operation_clab_amt
  20129. iteminfo.OthAmt = operation_other_amt
  20130. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20131. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20132. }
  20133. if materialCostTotal != 0 {
  20134. iteminfo.MedChrgitm = "08"
  20135. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20136. iteminfo.Amt = materialCostTotal
  20137. iteminfo.ClaaSumfee = material_claa_sunmfee
  20138. iteminfo.ClabAmt = material_clab_amt
  20139. iteminfo.OthAmt = material_other_amt
  20140. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20141. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20142. }
  20143. if westernMedicineCostTotal != 0 {
  20144. iteminfo.MedChrgitm = "09"
  20145. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20146. iteminfo.Amt = westernMedicineCostTotal
  20147. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20148. iteminfo.ClabAmt = westernMedicine_clab_amt
  20149. iteminfo.OthAmt = westernMedicine_other_amt
  20150. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20151. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20152. }
  20153. if chineseTraditionalMedicineCostTotal != 0 {
  20154. iteminfo.MedChrgitm = "11"
  20155. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20156. iteminfo.Amt = westernMedicineCostTotal
  20157. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20158. iteminfo.ClabAmt = westernMedicine_clab_amt
  20159. iteminfo.OthAmt = westernMedicine_other_amt
  20160. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20161. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20162. }
  20163. if otherCostTotal != 0 {
  20164. iteminfo.MedChrgitm = "14"
  20165. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20166. iteminfo.Amt = otherCostTotal
  20167. iteminfo.ClaaSumfee = other_claa_sunmfee
  20168. iteminfo.ClabAmt = other_clab_amt
  20169. iteminfo.OthAmt = other_other_amt
  20170. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20171. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20172. }
  20173. struct4101.IteminfoStruct = iteminfoStructs
  20174. struct4101.Ntly = "中国"
  20175. struct4101.AdmCaty = "A03.06"
  20176. var resOther ResultSeventeenOther
  20177. var res ResultSeventeen
  20178. if miConfig.MdtrtareaAdmvs == "150499" {
  20179. var pp models.PublicParams
  20180. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20181. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20182. pp.FixmedinsName = miConfig.OrgName
  20183. pp.FixmedinsCode = miConfig.Code
  20184. pp.RequestUrl = miConfig.Url
  20185. pp.Cainfo = miConfig.Cainfo
  20186. pp.SecretKey = miConfig.SecretKey
  20187. pp.AccessKey = miConfig.AccessKey
  20188. pp.OpterName = curRoles.UserName
  20189. client := &http.Client{}
  20190. var req *http.Request
  20191. data := make(map[string]interface{})
  20192. data["struct4101"] = struct4101
  20193. data["pp"] = pp
  20194. bytesData, _ := json.Marshal(data)
  20195. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20196. resp, _ := client.Do(req)
  20197. defer resp.Body.Close()
  20198. body, ioErr := ioutil.ReadAll(resp.Body)
  20199. if ioErr != nil {
  20200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20202. return
  20203. }
  20204. var respJSON map[string]interface{}
  20205. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20208. return
  20209. }
  20210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20211. userJSONBytes, _ := json.Marshal(respJSON)
  20212. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20213. utils.ErrorLog("解析失败:%v", err)
  20214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20215. return
  20216. }
  20217. res.InfRefmsgid = resOther.InfRefmsgid
  20218. res.Output = resOther.Output
  20219. res.ErrMsg = resOther.ErrMsg
  20220. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20221. res.Infcode = infocode
  20222. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20223. var pp models.PublicParams
  20224. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20225. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20226. pp.FixmedinsName = miConfig.OrgName
  20227. pp.FixmedinsCode = miConfig.Code
  20228. pp.RequestUrl = miConfig.Url
  20229. pp.Cainfo = miConfig.Cainfo
  20230. pp.SecretKey = miConfig.SecretKey
  20231. pp.AccessKey = miConfig.AccessKey
  20232. pp.OpterName = curRoles.UserName
  20233. result, _ := service.Jxyb4101(struct4101, pp)
  20234. var dat map[string]interface{}
  20235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20236. fmt.Println(dat)
  20237. } else {
  20238. fmt.Println(err)
  20239. }
  20240. userJSONBytes, _ := json.Marshal(dat)
  20241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20242. utils.ErrorLog("解析失败:%v", err)
  20243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20244. return
  20245. }
  20246. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20247. var pp models.PublicParams
  20248. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20249. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20250. pp.FixmedinsName = miConfig.OrgName
  20251. pp.FixmedinsCode = miConfig.Code
  20252. pp.RequestUrl = miConfig.Url
  20253. pp.Cainfo = miConfig.Cainfo
  20254. pp.SecretKey = miConfig.SecretKey
  20255. pp.AccessKey = miConfig.AccessKey
  20256. pp.OpterName = curRoles.UserName
  20257. result, _ := service.Jxyb4101(struct4101, pp)
  20258. var dat map[string]interface{}
  20259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20260. fmt.Println(dat)
  20261. } else {
  20262. fmt.Println(err)
  20263. }
  20264. userJSONBytes, _ := json.Marshal(dat)
  20265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20266. utils.ErrorLog("解析失败:%v", err)
  20267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20268. return
  20269. }
  20270. } else {
  20271. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20272. var dat map[string]interface{}
  20273. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20274. fmt.Println(dat)
  20275. } else {
  20276. fmt.Println(err)
  20277. }
  20278. userJSONBytes, _ := json.Marshal(dat)
  20279. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20280. utils.ErrorLog("解析失败:%v", err)
  20281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20282. return
  20283. }
  20284. }
  20285. if res.Infcode != 0 {
  20286. c.ServeSuccessJSON(map[string]interface{}{
  20287. "failed_code": -10,
  20288. "msg": res.ErrMsg,
  20289. })
  20290. return
  20291. } else {
  20292. if miConfig.MdtrtareaAdmvs != "150499" {
  20293. order.FaPiaoNumber = zero
  20294. order.FaPiaoCode = last_order.FaPiaoCode
  20295. service.UpdateOrder(order)
  20296. }
  20297. hisFundSettleListResult := &models.HisFundSettleListResult{
  20298. Number: res.Output.SetlListId,
  20299. Status: 1,
  20300. Ctime: time.Now().Unix(),
  20301. Mtime: time.Now().Unix(),
  20302. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20303. IsUpload: 1,
  20304. OrderId: order_id,
  20305. }
  20306. service.CreateUploadRecord(hisFundSettleListResult)
  20307. c.ServeSuccessJSON(map[string]interface{}{
  20308. "msg": "上传成功",
  20309. "result": hisFundSettleListResult,
  20310. })
  20311. return
  20312. }
  20313. }
  20314. //func (c *HisApiController) GetBatchSettleList() {
  20315. // orders, _ := service.GetAllHisOrder(10106)
  20316. // for _, item := range orders {
  20317. // order_id := item.ID
  20318. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20319. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20320. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20321. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20322. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20323. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20324. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20325. //
  20326. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20327. //
  20328. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20329. //
  20330. // if order.ID == 0 {
  20331. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20332. // return
  20333. // }
  20334. // if his.BalanceAccountsType == 2 {
  20335. // continue
  20336. // }
  20337. // struct4101 := service.Struct4101{
  20338. // PsnNo: order.PsnNo,
  20339. // MdtrtId: order.MdtrtId,
  20340. // SetlId: order.SetlId,
  20341. // PsnName: order.PsnName,
  20342. // Gend: order.Gend,
  20343. // Brdy: his.Brdy,
  20344. // Age: his.Age,
  20345. // Naty: order.Naty,
  20346. // PatnCertType: "01",
  20347. // Certno: order.Certno,
  20348. // Prfs: "90",
  20349. // ConerName: roles[0].UserName,
  20350. // PatnRlts: "99",
  20351. // ConerAddr: miConfig.OrgName,
  20352. // ConerTel: admin.Mobile,
  20353. // HiType: order.Insutype,
  20354. // Insuplc: his.InsuplcAdmdvs,
  20355. // MaindiagFlag: "1",
  20356. // BillCode: order.SetlId,
  20357. // BillNo: order.SetlId,
  20358. // BizSn: order.Number,
  20359. // PsnSelfPay: order.PsnPartAmt,
  20360. // PsnOwnPay: order.PsnPartAmt,
  20361. // AcctPay: order.AcctPay,
  20362. // PsnCashpay: order.PsnCashPay,
  20363. // HiPaymtd: "1",
  20364. // Hsorg: his.InsuplcAdmdvs,
  20365. // HsorgOpter: his.InsuplcAdmdvs,
  20366. // MedinsFillPsn: curRoles.UserName,
  20367. // MedinsFillDept: depart.Name,
  20368. // IptMedType: "2",
  20369. // }
  20370. // struct4101.SetlBegnDate = order.SetlTime
  20371. // struct4101.SetlEndDate = order.SetlTime
  20372. // //if order.SettleType == 1 {
  20373. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20374. // // dateStr := t.Format("2006-01-02")
  20375. // // struct4101.SetlBegnDate = dateStr
  20376. // // struct4101.SetlEndDate = dateStr
  20377. // //} else {
  20378. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20379. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20380. // // dateStartStr := t.Format("2006-01-02")
  20381. // // dateEndStr := t2.Format("2006-01-02")
  20382. // // struct4101.SetlBegnDate = dateStartStr
  20383. // // struct4101.SetlEndDate = dateEndStr
  20384. // //}
  20385. //
  20386. // var rf []CustomFundPay
  20387. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20388. //
  20389. // var tempFunPays []service.CustomStruct
  20390. // var tempFunPay610100 service.CustomStruct
  20391. //
  20392. // for _, item := range rf {
  20393. // if item.FundPayType == "610100" {
  20394. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20395. // tempFunPay610100.FundPayType = item.FundPayType
  20396. // } else {
  20397. // var tempFunPay service.CustomStruct
  20398. // tempFunPay.FundPayamt = item.FundPayamt
  20399. // tempFunPay.FundPayType = item.FundPayType
  20400. // tempFunPays = append(tempFunPays, tempFunPay)
  20401. // }
  20402. // }
  20403. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20404. // struct4101.CustomStruct = tempFunPays
  20405. //
  20406. // var tempDiaginfos []service.DiaginfoStructTwo
  20407. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20408. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20409. //
  20410. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20411. // var config []*models.HisXtDiagnoseConfig
  20412. // for _, item := range diagnosis_ids {
  20413. // id, _ := strconv.ParseInt(item, 10, 64)
  20414. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20415. // config = append(config, &diagnosisConfig)
  20416. // }
  20417. //
  20418. // for index, item := range config {
  20419. // if index == 0 {
  20420. // var tempDiaginfo service.DiaginfoStructTwo
  20421. // tempDiaginfo.DiagCode = item.CountryCode
  20422. // tempDiaginfo.DiagName = item.CountryContentName
  20423. // tempDiaginfo.DiagType = "1"
  20424. // tempDiaginfo.MaindiagFlag = "1"
  20425. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20426. // } else {
  20427. //
  20428. // var tempDiaginfo service.DiaginfoStructTwo
  20429. // tempDiaginfo.DiagCode = item.CountryCode
  20430. // tempDiaginfo.DiagName = item.CountryContentName
  20431. // tempDiaginfo.DiagType = "2"
  20432. // tempDiaginfo.MaindiagFlag = "0"
  20433. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20434. // }
  20435. // }
  20436. // struct4101.Diseinfo = tempDiaginfos
  20437. //
  20438. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20439. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20440. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20441. // tempOpspdiseinfo2.OprnOprtCode = ""
  20442. // tempOpspdiseinfo2.OprnOprtName = ""
  20443. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20444. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20445. //
  20446. // var iteminfo service.IteminfoStruct
  20447. //
  20448. // var bedCostTotal float64 = 0 //床位总费
  20449. // var bedCostSelfTotal float64 = 0 //床位自费
  20450. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20451. //
  20452. // var examineCostTotal float64 = 0 //诊查总费
  20453. // var examineCostSelfTotal float64 = 0 //诊查自费
  20454. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20455. //
  20456. // var nursingCostTotal float64 = 0 //护理总费
  20457. // var nursingCostSelfTotal float64 = 0 //护理自费
  20458. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20459. //
  20460. // var chineseMedicineCostTotal float64 = 0 //中成药
  20461. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20462. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20463. //
  20464. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20465. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20466. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20467. //
  20468. // var registerCostTotal float64 = 0 //一般诊疗费
  20469. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20470. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20471. //
  20472. // var operationCostTotal float64 = 0 //手术费
  20473. // var operationCostSelfTotal float64 = 0 //手术费
  20474. // var operationCostPartSelfTotal float64 = 0 //手术费
  20475. //
  20476. // var otherCostTotal float64 = 0 //其他费用
  20477. // var otherCostSelfTotal float64 = 0 //其他费用
  20478. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20479. //
  20480. // var materialCostTotal float64 = 0 //材料费
  20481. // var materialCostSelfTotal float64 = 0 //材料费
  20482. // var materialCostPartSelfTotal float64 = 0 //材料费
  20483. //
  20484. // var westernMedicineCostTotal float64 = 0 //西药费
  20485. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20486. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20487. //
  20488. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20489. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20490. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20491. //
  20492. // var checkCostTotal float64 = 0 //检查费
  20493. // var checkCostSelfTotal float64 = 0 //检查费
  20494. // var checkCostPartSelfTotal float64 = 0 //检查费
  20495. //
  20496. // var laboratoryCostTotal float64 = 0 //化验费
  20497. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20498. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20499. //
  20500. // var treatCostTotal float64 = 0 //治疗费用
  20501. // var treatCostSelfTotal float64 = 0 //治疗费用
  20502. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20503. //
  20504. // decimal.DivisionPrecision = 2
  20505. //
  20506. // var bed_fulamt_ownpay_amt float64 = 0
  20507. //
  20508. // var examine_fulamt_ownpay_amt float64 = 0
  20509. //
  20510. // var nursing_fulamt_ownpay_amt float64 = 0
  20511. //
  20512. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20513. //
  20514. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20515. //
  20516. // var register_fulamt_ownpay_amt float64 = 0
  20517. //
  20518. // var operation_fulamt_ownpay_amt float64 = 0
  20519. // var other_fulamt_ownpay_amt float64 = 0
  20520. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20521. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20522. // var check_fulamt_ownpay_amt float64 = 0
  20523. // var material_fulamt_ownpay_amt float64 = 0
  20524. // var laboratory_fulamt_ownpay_amt float64 = 0
  20525. // var treat_fulamt_ownpay_amt float64 = 0
  20526. //
  20527. // var bed_claa_sunmfee float64 = 0
  20528. // var bed_clab_amt float64 = 0
  20529. // var bed_other_amt float64 = 0
  20530. //
  20531. // var examine_claa_sunmfee float64 = 0
  20532. // var examine_clab_amt float64 = 0
  20533. // var examine_other_amt float64 = 0
  20534. //
  20535. // var nursing_claa_sunmfee float64 = 0
  20536. // var nursing_clab_amt float64 = 0
  20537. // var nursing_other_amt float64 = 0
  20538. //
  20539. // var chinese_medicine_claa_sunmfee float64 = 0
  20540. // var chinese_medicine_clab_amt float64 = 0
  20541. // var chinese_medicine_other_amt float64 = 0
  20542. //
  20543. // var commonly_treatment_claa_sunmfee float64 = 0
  20544. // var commonly_treatment_clab_amt float64 = 0
  20545. // var commonly_treatment_other_amt float64 = 0
  20546. //
  20547. // var operation_claa_sunmfee float64 = 0
  20548. // var operation_clab_amt float64 = 0
  20549. // var operation_other_amt float64 = 0
  20550. //
  20551. // var other_claa_sunmfee float64 = 0
  20552. // var other_clab_amt float64 = 0
  20553. // var other_other_amt float64 = 0
  20554. //
  20555. // var westernMedicine_claa_sunmfee float64 = 0
  20556. // var westernMedicine_clab_amt float64 = 0
  20557. // var westernMedicine_other_amt float64 = 0
  20558. //
  20559. // var chineseTraditional_claa_sunmfee float64 = 0
  20560. // var chineseTraditional_clab_amt float64 = 0
  20561. // var chineseTraditional_other_amt float64 = 0
  20562. //
  20563. // var check_claa_sunmfee float64 = 0
  20564. // var check_clab_amt float64 = 0
  20565. // var check_other_amt float64 = 0
  20566. //
  20567. // var material_claa_sunmfee float64 = 0
  20568. // var material_clab_amt float64 = 0
  20569. // var material_other_amt float64 = 0
  20570. //
  20571. // var laboratory_claa_sunmfee float64 = 0
  20572. // var laboratory_clab_amt float64 = 0
  20573. // var laboratory_other_amt float64 = 0
  20574. //
  20575. // var treat_claa_sunmfee float64 = 0
  20576. // var treat_clab_amt float64 = 0
  20577. // var treat_other_amt float64 = 0
  20578. //
  20579. // var register_claa_sunmfee float64 = 0
  20580. // var register_clab_amt float64 = 0
  20581. // var register_other_amt float64 = 0
  20582. //
  20583. // for _, item := range order.HisOrderInfo {
  20584. // if item.MedChrgitmType == "01" { //床位费
  20585. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20586. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20587. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20588. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20589. // if item.ChrgitmLv == "1" {
  20590. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20591. // }
  20592. // if item.ChrgitmLv == "2" {
  20593. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20594. //
  20595. // }
  20596. // if item.ChrgitmLv == "3" {
  20597. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20598. // }
  20599. //
  20600. // }
  20601. //
  20602. // if item.MedChrgitmType == "02" { //诊查
  20603. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20604. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20605. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20606. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20607. // if item.ChrgitmLv == "1" {
  20608. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20609. // }
  20610. // if item.ChrgitmLv == "2" {
  20611. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20612. //
  20613. // }
  20614. // if item.ChrgitmLv == "3" {
  20615. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20616. // }
  20617. //
  20618. // }
  20619. //
  20620. // if item.MedChrgitmType == "03" { //检查费
  20621. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20622. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20623. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20624. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20625. // if item.ChrgitmLv == "1" {
  20626. //
  20627. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20628. //
  20629. // }
  20630. // if item.ChrgitmLv == "2" {
  20631. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20632. //
  20633. // }
  20634. // if item.ChrgitmLv == "3" {
  20635. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20636. // }
  20637. // }
  20638. //
  20639. // if item.MedChrgitmType == "04" { //化验费
  20640. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20641. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20642. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20643. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20644. // if item.ChrgitmLv == "1" {
  20645. //
  20646. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20647. //
  20648. // }
  20649. // if item.ChrgitmLv == "2" {
  20650. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20651. //
  20652. // }
  20653. // if item.ChrgitmLv == "3" {
  20654. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20655. // }
  20656. // }
  20657. //
  20658. // if item.MedChrgitmType == "05" { //治疗费
  20659. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20660. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20661. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20662. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20663. // if item.ChrgitmLv == "1" {
  20664. //
  20665. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20666. //
  20667. // }
  20668. // if item.ChrgitmLv == "2" {
  20669. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20670. //
  20671. // }
  20672. // if item.ChrgitmLv == "3" {
  20673. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20674. // }
  20675. // }
  20676. //
  20677. // if item.MedChrgitmType == "06" { //手术费
  20678. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20679. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20680. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20681. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20682. //
  20683. // if item.ChrgitmLv == "1" {
  20684. //
  20685. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20686. //
  20687. // }
  20688. // if item.ChrgitmLv == "2" {
  20689. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20690. //
  20691. // }
  20692. // if item.ChrgitmLv == "3" {
  20693. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20694. // }
  20695. // }
  20696. //
  20697. // if item.MedChrgitmType == "07" { //手术费
  20698. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20699. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20700. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20701. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20702. //
  20703. // if item.ChrgitmLv == "1" {
  20704. //
  20705. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20706. //
  20707. // }
  20708. // if item.ChrgitmLv == "2" {
  20709. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20710. //
  20711. // }
  20712. // if item.ChrgitmLv == "3" {
  20713. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20714. // }
  20715. // }
  20716. //
  20717. // if item.MedChrgitmType == "08" { //材料费
  20718. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20719. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20720. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20721. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20722. // if item.ChrgitmLv == "1" {
  20723. //
  20724. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20725. //
  20726. // }
  20727. // if item.ChrgitmLv == "2" {
  20728. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20729. //
  20730. // }
  20731. // if item.ChrgitmLv == "3" {
  20732. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20733. // }
  20734. // }
  20735. // if item.MedChrgitmType == "09" { //西药费
  20736. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20737. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20738. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20739. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20740. // if item.ChrgitmLv == "1" {
  20741. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20742. // }
  20743. // if item.ChrgitmLv == "2" {
  20744. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20745. // }
  20746. // if item.ChrgitmLv == "3" {
  20747. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20748. // }
  20749. // }
  20750. // if item.MedChrgitmType == "10" { //中药饮片
  20751. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20752. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20753. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20754. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20755. // if item.ChrgitmLv == "1" {
  20756. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20757. // }
  20758. // if item.ChrgitmLv == "2" {
  20759. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20760. // }
  20761. // if item.ChrgitmLv == "3" {
  20762. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20763. // }
  20764. // }
  20765. //
  20766. // if item.MedChrgitmType == "11" { //中成费
  20767. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20768. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20769. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20770. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20771. // if item.ChrgitmLv == "1" {
  20772. //
  20773. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20774. //
  20775. // }
  20776. // if item.ChrgitmLv == "2" {
  20777. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20778. //
  20779. // }
  20780. // if item.ChrgitmLv == "3" {
  20781. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20782. // }
  20783. // }
  20784. //
  20785. // if item.MedChrgitmType == "12" { //中成费
  20786. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20787. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20788. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20789. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20790. // if item.ChrgitmLv == "1" {
  20791. //
  20792. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20793. //
  20794. // }
  20795. // if item.ChrgitmLv == "2" {
  20796. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20797. //
  20798. // }
  20799. // if item.ChrgitmLv == "3" {
  20800. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20801. // }
  20802. // }
  20803. //
  20804. // if item.MedChrgitmType == "13" { //中成费
  20805. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20806. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20807. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20808. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20809. // if item.ChrgitmLv == "1" {
  20810. //
  20811. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20812. //
  20813. // }
  20814. // if item.ChrgitmLv == "2" {
  20815. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20816. //
  20817. // }
  20818. // if item.ChrgitmLv == "3" {
  20819. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20820. // }
  20821. // }
  20822. //
  20823. // if item.MedChrgitmType == "14" { //其他费
  20824. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20825. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20826. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20827. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20828. // if item.ChrgitmLv == "1" {
  20829. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20830. //
  20831. // }
  20832. // if item.ChrgitmLv == "2" {
  20833. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20834. //
  20835. // }
  20836. // if item.ChrgitmLv == "3" {
  20837. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20838. // }
  20839. // }
  20840. //
  20841. // }
  20842. //
  20843. // var iteminfoStructs []service.IteminfoStruct
  20844. //
  20845. // if bedCostTotal != 0 {
  20846. // iteminfo.MedChrgitm = "01"
  20847. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20848. // iteminfo.Amt = bedCostTotal
  20849. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20850. // iteminfo.ClabAmt = bed_clab_amt
  20851. // iteminfo.OthAmt = bed_other_amt
  20852. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20853. // }
  20854. //
  20855. // if examineCostTotal != 0 {
  20856. // iteminfo.MedChrgitm = "02"
  20857. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20858. // iteminfo.Amt = examineCostTotal
  20859. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20860. // iteminfo.ClabAmt = examine_clab_amt
  20861. // iteminfo.OthAmt = examine_other_amt
  20862. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20863. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20864. // }
  20865. //
  20866. // if checkCostTotal != 0 {
  20867. // iteminfo.MedChrgitm = "03"
  20868. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20869. // iteminfo.Amt = checkCostTotal
  20870. // iteminfo.ClaaSumfee = check_claa_sunmfee
  20871. // iteminfo.ClabAmt = check_clab_amt
  20872. // iteminfo.OthAmt = check_other_amt
  20873. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20874. //
  20875. // }
  20876. //
  20877. // if laboratoryCostTotal != 0 {
  20878. // iteminfo.MedChrgitm = "04"
  20879. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20880. // iteminfo.Amt = laboratoryCostTotal
  20881. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20882. // iteminfo.ClabAmt = laboratory_clab_amt
  20883. // iteminfo.OthAmt = laboratory_other_amt
  20884. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20885. //
  20886. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20887. //
  20888. // }
  20889. //
  20890. // if treatCostTotal != 0 {
  20891. // iteminfo.MedChrgitm = "05"
  20892. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20893. // iteminfo.Amt = treatCostTotal
  20894. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  20895. // iteminfo.ClabAmt = treat_clab_amt
  20896. // iteminfo.OthAmt = treat_other_amt
  20897. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20898. // //(struct4101.IteminfoStruct, iteminfo)
  20899. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20900. // }
  20901. //
  20902. // if operationCostTotal != 0 {
  20903. // iteminfo.MedChrgitm = "06"
  20904. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20905. // iteminfo.Amt = operationCostTotal
  20906. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  20907. // iteminfo.ClabAmt = operation_clab_amt
  20908. // iteminfo.OthAmt = operation_other_amt
  20909. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20910. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20911. // }
  20912. //
  20913. // if nursingCostTotal != 0 {
  20914. // iteminfo.MedChrgitm = "07"
  20915. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  20916. // iteminfo.Amt = nursingCostTotal
  20917. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  20918. // iteminfo.ClabAmt = nursing_clab_amt
  20919. // iteminfo.OthAmt = nursing_other_amt
  20920. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20921. // }
  20922. //
  20923. // if materialCostTotal != 0 {
  20924. // iteminfo.MedChrgitm = "08"
  20925. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20926. // iteminfo.Amt = materialCostTotal
  20927. // iteminfo.ClaaSumfee = material_claa_sunmfee
  20928. // iteminfo.ClabAmt = material_clab_amt
  20929. // iteminfo.OthAmt = material_other_amt
  20930. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20931. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20932. // }
  20933. //
  20934. // if westernMedicineCostTotal != 0 {
  20935. // iteminfo.MedChrgitm = "09"
  20936. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20937. // iteminfo.Amt = westernMedicineCostTotal
  20938. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20939. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20940. // iteminfo.OthAmt = westernMedicine_other_amt
  20941. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20942. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20943. //
  20944. // }
  20945. //
  20946. // if chineseMedicineCostTotal != 0 {
  20947. // iteminfo.MedChrgitm = "10"
  20948. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  20949. // iteminfo.Amt = chineseMedicineCostTotal
  20950. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  20951. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  20952. // iteminfo.OthAmt = chinese_medicine_other_amt
  20953. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20954. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20955. //
  20956. // }
  20957. //
  20958. // if chineseTraditionalMedicineCostTotal != 0 {
  20959. // iteminfo.MedChrgitm = "11"
  20960. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20961. // iteminfo.Amt = westernMedicineCostTotal
  20962. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20963. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20964. // iteminfo.OthAmt = westernMedicine_other_amt
  20965. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20966. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20967. //
  20968. // }
  20969. //
  20970. // if commonlyTreatmentCostTotal != 0 {
  20971. // iteminfo.MedChrgitm = "12"
  20972. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  20973. // iteminfo.Amt = commonlyTreatmentCostTotal
  20974. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  20975. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  20976. // iteminfo.OthAmt = commonly_treatment_other_amt
  20977. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20978. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20979. //
  20980. // }
  20981. //
  20982. // if registerCostTotal != 0 {
  20983. // iteminfo.MedChrgitm = "13"
  20984. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  20985. // iteminfo.Amt = registerCostTotal
  20986. // iteminfo.ClaaSumfee = register_claa_sunmfee
  20987. // iteminfo.ClabAmt = register_clab_amt
  20988. // iteminfo.OthAmt = register_other_amt
  20989. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20990. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20991. //
  20992. // }
  20993. //
  20994. // if otherCostTotal != 0 {
  20995. // iteminfo.MedChrgitm = "14"
  20996. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20997. // iteminfo.Amt = otherCostTotal
  20998. // iteminfo.ClaaSumfee = other_claa_sunmfee
  20999. // iteminfo.ClabAmt = other_clab_amt
  21000. // iteminfo.OthAmt = other_other_amt
  21001. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21002. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21003. //
  21004. // }
  21005. // struct4101.IteminfoStruct = iteminfoStructs
  21006. // time_arr := strings.Split(order.SetlTime, " ")
  21007. // struct4101.AdmTime = time_arr[0]
  21008. // struct4101.AdmEndTime = time_arr[0]
  21009. //
  21010. // struct4101.DoctorName = doctor.UserName
  21011. // struct4101.DoctorCode = doctor.DoctorNumber
  21012. //
  21013. // struct4101.Ntly = "中国"
  21014. // struct4101.AdmCaty = "A03.06"
  21015. // var res ResultSeventeen
  21016. // if miConfig.MdtrtareaAdmvs == "421300" {
  21017. // data := make(map[string]interface{})
  21018. // data["struct4101"] = struct4101
  21019. // data["secret_key"] = miConfig.SecretKey
  21020. // data["org_name"] = miConfig.OrgName
  21021. // data["opera"] = curRoles.UserName
  21022. // data["code"] = miConfig.Code
  21023. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21024. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21025. //
  21026. // client := &http.Client{}
  21027. // bytesData, _ := json.Marshal(data)
  21028. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21029. // resp, _ := client.Do(req)
  21030. // defer resp.Body.Close()
  21031. // body, ioErr := ioutil.ReadAll(resp.Body)
  21032. // if ioErr != nil {
  21033. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21035. // return
  21036. // }
  21037. // var respJSON map[string]interface{}
  21038. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21039. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21041. // return
  21042. // }
  21043. //
  21044. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21045. // userJSONBytes, _ := json.Marshal(respJSON)
  21046. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21047. // utils.ErrorLog("解析失败:%v", err)
  21048. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21049. // adminUser := c.GetAdminUserInfo()
  21050. // errlog := &models.HisOrderError{
  21051. // UserOrgId: adminUser.CurrentOrgId,
  21052. // Ctime: time.Now().Unix(),
  21053. // Mtime: time.Now().Unix(),
  21054. // ErrMsg: res.ErrMsg + "解析失败",
  21055. // Status: 1,
  21056. // PatientId: order_id,
  21057. // Stage: 10088,
  21058. // }
  21059. // service.CreateErrMsgLog(errlog)
  21060. // continue
  21061. // }
  21062. //
  21063. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21064. // data := make(map[string]interface{})
  21065. // data["struct4101"] = struct4101
  21066. // data["secret_key"] = miConfig.SecretKey
  21067. // data["org_name"] = miConfig.OrgName
  21068. // data["opera"] = curRoles.UserName
  21069. // data["code"] = miConfig.Code
  21070. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21071. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21072. //
  21073. // client := &http.Client{}
  21074. // bytesData, _ := json.Marshal(data)
  21075. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21076. // resp, _ := client.Do(req)
  21077. // defer resp.Body.Close()
  21078. // body, ioErr := ioutil.ReadAll(resp.Body)
  21079. // if ioErr != nil {
  21080. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21081. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21082. // return
  21083. // }
  21084. // var respJSON map[string]interface{}
  21085. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21086. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21087. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21088. // return
  21089. // }
  21090. //
  21091. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21092. // userJSONBytes, _ := json.Marshal(respJSON)
  21093. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21094. // utils.ErrorLog("解析失败:%v", err)
  21095. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21096. // adminUser := c.GetAdminUserInfo()
  21097. // errlog := &models.HisOrderError{
  21098. // UserOrgId: adminUser.CurrentOrgId,
  21099. // Ctime: time.Now().Unix(),
  21100. // Mtime: time.Now().Unix(),
  21101. // ErrMsg: res.ErrMsg + "解析失败",
  21102. // Status: 1,
  21103. // PatientId: order_id,
  21104. // Stage: 10088,
  21105. // }
  21106. // service.CreateErrMsgLog(errlog)
  21107. // continue
  21108. // }
  21109. //
  21110. // } else {
  21111. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21112. // fmt.Println(result)
  21113. //
  21114. // var dat map[string]interface{}
  21115. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21116. // fmt.Println(dat)
  21117. // } else {
  21118. // fmt.Println(err)
  21119. // }
  21120. // userJSONBytes, _ := json.Marshal(dat)
  21121. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21122. // utils.ErrorLog("解析失败:%v", err)
  21123. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21124. // adminUser := c.GetAdminUserInfo()
  21125. // errlog := &models.HisOrderError{
  21126. // UserOrgId: adminUser.CurrentOrgId,
  21127. // Ctime: time.Now().Unix(),
  21128. // Mtime: time.Now().Unix(),
  21129. // ErrMsg: res.ErrMsg + "解析失败",
  21130. // Status: 1,
  21131. // PatientId: order_id,
  21132. // Stage: 10106,
  21133. // }
  21134. // service.CreateErrMsgLog(errlog)
  21135. // continue
  21136. // }
  21137. // }
  21138. //
  21139. // if res.Infcode != 0 {
  21140. // adminUser := c.GetAdminUserInfo()
  21141. // errlog := &models.HisOrderError{
  21142. // UserOrgId: adminUser.CurrentOrgId,
  21143. // Ctime: time.Now().Unix(),
  21144. // Mtime: time.Now().Unix(),
  21145. // ErrMsg: res.ErrMsg,
  21146. // Status: 1,
  21147. // PatientId: order_id,
  21148. // Stage: 10106,
  21149. // }
  21150. // service.CreateErrMsgLog(errlog)
  21151. // continue
  21152. // } else {
  21153. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21154. // Number: res.Output.SetlListId,
  21155. // Status: 1,
  21156. // Ctime: time.Now().Unix(),
  21157. // Mtime: time.Now().Unix(),
  21158. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21159. // IsUpload: 1,
  21160. // OrderId: order_id,
  21161. // }
  21162. // service.CreateUploadRecord(hisFundSettleListResult)
  21163. // continue
  21164. // }
  21165. // }
  21166. //}
  21167. func (c *HisApiController) GetOrgInfo() {
  21168. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21169. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21170. }
  21171. func (c *HisApiController) GetHisPatientInfo() {
  21172. medical_insurance_card := c.GetString("medical_insurance_card")
  21173. id_card_type, _ := c.GetInt64("id_card_type")
  21174. id_card := c.GetString("id_card")
  21175. adminInfo := c.GetAdminUserInfo()
  21176. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21177. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21178. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21179. IdCardNo := ""
  21180. if id_card_type == 1 {
  21181. IdCardNo = medical_insurance_card
  21182. } else if id_card_type == 2 {
  21183. IdCardNo = id_card
  21184. }
  21185. if config.IsOpen == 1 {
  21186. 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
  21187. resp, requestErr := http.Get(api)
  21188. if requestErr != nil {
  21189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21190. return
  21191. }
  21192. defer resp.Body.Close()
  21193. body, ioErr := ioutil.ReadAll(resp.Body)
  21194. if ioErr != nil {
  21195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21197. return
  21198. }
  21199. var respJSON map[string]interface{}
  21200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21203. return
  21204. }
  21205. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21206. userJSONBytes, _ := json.Marshal(userJSON)
  21207. var res ResultTwo
  21208. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21209. utils.ErrorLog("解析失败:%v", err)
  21210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21211. return
  21212. }
  21213. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21214. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21215. infoStr := string(Iinfos)
  21216. idetinfoStr := string(Idetinfos)
  21217. if res.Infcode == 0 {
  21218. his := models.VMHisPatient{
  21219. Status: 1,
  21220. Ctime: time.Now().Unix(),
  21221. Mtime: time.Now().Unix(),
  21222. PsnNo: res.Output.Baseinfo.PsnNo,
  21223. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21224. Certno: res.Output.Baseinfo.Certno,
  21225. PsnName: res.Output.Baseinfo.PsnName,
  21226. Gend: res.Output.Baseinfo.Gend,
  21227. Naty: res.Output.Baseinfo.Naty,
  21228. Iinfo: infoStr,
  21229. Idetinfo: idetinfoStr,
  21230. UserOrgId: adminInfo.CurrentOrgId,
  21231. IsReturn: 1,
  21232. IdCardType: id_card_type,
  21233. }
  21234. c.ServeSuccessJSON(map[string]interface{}{
  21235. "info": his,
  21236. })
  21237. } else {
  21238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21239. return
  21240. }
  21241. }
  21242. }
  21243. //func GetBasBaseInfo() (jsonStr string, err error) {
  21244. //
  21245. // handle := syscall.NewLazyDLL("SSCard.dll")
  21246. // add := handle.NewProc("ReadCardBas")
  21247. // str := make([]byte, 1024)
  21248. // str1 := make([]byte, 1024)
  21249. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21250. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21251. //
  21252. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21253. //
  21254. // fmt.Println("> Add(4,5)的结果为:", ret)
  21255. // handle.Release()
  21256. //
  21257. // return "", nil
  21258. //
  21259. //}
  21260. //func GetQRBaseInfo() (jsonStr string, err error) {
  21261. // handle := syscall.LoadDLL("SSCard.dll")
  21262. // ReadCardBas := handle.FindProc("GetQRBase")
  21263. //
  21264. // str := make([]byte, 256)
  21265. // str1 := make([]byte, 256)
  21266. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21267. //
  21268. // fmt.Println(string(str))
  21269. // fmt.Println(r)
  21270. // return string(str), nil
  21271. //}
  21272. //func CardInit() int {
  21273. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21274. // add := DllTestDef.MustFindProc("Init")
  21275. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21276. // if err != nil {
  21277. // fmt.Println("SSCard的运算结果为:", ret)
  21278. // }
  21279. // result := int(ret)
  21280. // return result
  21281. //}
  21282. //func CardInit() int {
  21283. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21284. // if err != nil {
  21285. // fmt.Println("SSCard的运算结果为:", ret)
  21286. // }
  21287. // fmt.Println(err)
  21288. // result := int(ret)
  21289. // return result
  21290. //}
  21291. func IntPtr(n int) uintptr {
  21292. return uintptr(n)
  21293. }
  21294. func StrPtr(s string) uintptr {
  21295. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21296. }
  21297. type Result2001 struct {
  21298. Cainfo interface{} `json:"cainfo"`
  21299. ErrMsg string `json:"err_msg"`
  21300. InfRefmsgid string `json:"inf_refmsgid"`
  21301. Infcode int64 `json:"infcode"`
  21302. Output struct {
  21303. Trtinfo struct {
  21304. PsnNo string `json:"psn_no"`
  21305. TrtChkType string `json:"trt_chk_type"`
  21306. FundPayType string `json:"fund_pay_type"`
  21307. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21308. Begndate string `json:"begndate"`
  21309. Enddate string `json:"enddate"`
  21310. TrtChkRslt string `json:"trt_chk_rslt"`
  21311. } `json:"trtinfo"`
  21312. } `json:"output"`
  21313. RefmsgTime string `json:"refmsg_time"`
  21314. RespondTime string `json:"respond_time"`
  21315. Signtype interface{} `json:"signtype"`
  21316. WarnMsg interface{} `json:"warn_msg"`
  21317. }
  21318. type Result2001Org10265 struct {
  21319. Cainfo interface{} `json:"cainfo"`
  21320. ErrMsg string `json:"err_msg"`
  21321. InfRefmsgid string `json:"inf_refmsgid"`
  21322. Infcode string `json:"infcode"`
  21323. Output struct {
  21324. Trtinfo struct {
  21325. PsnNo string `json:"psn_no"`
  21326. TrtChkType string `json:"trt_chk_type"`
  21327. FundPayType string `json:"fund_pay_type"`
  21328. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21329. Begndate string `json:"begndate"`
  21330. Enddate string `json:"enddate"`
  21331. TrtChkRslt string `json:"trt_chk_rslt"`
  21332. } `json:"trtinfo"`
  21333. } `json:"output"`
  21334. RefmsgTime string `json:"refmsg_time"`
  21335. RespondTime string `json:"respond_time"`
  21336. Signtype interface{} `json:"signtype"`
  21337. WarnMsg interface{} `json:"warn_msg"`
  21338. }
  21339. type ResultTwo struct {
  21340. ErrMsg string `json:"err_msg"`
  21341. InfRefmsgid string `json:"inf_refmsgid"`
  21342. Infcode int64 `json:"infcode"`
  21343. Output struct {
  21344. Baseinfo struct {
  21345. //Brdy string `json:"brdy"`
  21346. Certno string `json:"certno"`
  21347. Gend string `json:"gend"`
  21348. Naty string `json:"naty"`
  21349. PsnCertType string `json:"psn_cert_type"`
  21350. PsnName string `json:"psn_name"`
  21351. PsnNo string `json:"psn_no"`
  21352. } `json:"baseinfo"`
  21353. Idetinfo []interface{} `json:"idetinfo"`
  21354. Iinfo []struct {
  21355. Balc float64 `json:"balc"`
  21356. CvlservFlag string `json:"cvlserv_flag"`
  21357. EmpName string `json:"emp_name"`
  21358. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21359. Insutype string `json:"insutype"`
  21360. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21361. //PausInsuDate string `json:"paus_insu_date"`
  21362. //PsnInsuDate string `json:"psn_insu_date"`
  21363. PsnInsuStas string `json:"psn_insu_stas"`
  21364. PsnType string `json:"psn_type"`
  21365. } `json:"insuinfo"`
  21366. } `json:"output"`
  21367. RefmsgTime string `json:"refmsg_time"`
  21368. RespondTime string `json:"respond_time"`
  21369. Signtype interface{} `json:"signtype"`
  21370. WarnInfo interface{} `json:"warn_info"`
  21371. }
  21372. type ResultTwo10265 struct {
  21373. ErrMsg string `json:"err_msg"`
  21374. InfRefmsgid string `json:"inf_refmsgid"`
  21375. Infcode string `json:"infcode"`
  21376. Output struct {
  21377. Baseinfo struct {
  21378. //Brdy string `json:"brdy"`
  21379. Certno string `json:"certno"`
  21380. Gend string `json:"gend"`
  21381. Naty string `json:"naty"`
  21382. PsnCertType string `json:"psn_cert_type"`
  21383. PsnName string `json:"psn_name"`
  21384. PsnNo string `json:"psn_no"`
  21385. } `json:"baseinfo"`
  21386. Idetinfo []interface{} `json:"idetinfo"`
  21387. Iinfo []struct {
  21388. Balc float64 `json:"balc"`
  21389. CvlservFlag string `json:"cvlserv_flag"`
  21390. EmpName string `json:"emp_name"`
  21391. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21392. Insutype string `json:"insutype"`
  21393. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21394. PsnInsuStas string `json:"psn_insu_stas"`
  21395. PsnType string `json:"psn_type"`
  21396. } `json:"insuinfo"`
  21397. } `json:"output"`
  21398. RefmsgTime string `json:"refmsg_time"`
  21399. RespondTime string `json:"respond_time"`
  21400. Signtype interface{} `json:"signtype"`
  21401. WarnInfo interface{} `json:"warn_info"`
  21402. }
  21403. type ResultThree struct {
  21404. Cainfo interface{} `json:"cainfo"`
  21405. ErrMsg string `json:"err_msg"`
  21406. InfRefmsgid string `json:"inf_refmsgid"`
  21407. Infcode int64 `json:"infcode"`
  21408. Output struct {
  21409. Data struct {
  21410. IptOtpNo string `json:"ipt_otp_no"`
  21411. MdtrtID string `json:"mdtrt_id"`
  21412. PsnNo string `json:"psn_no"`
  21413. } `json:"data"`
  21414. } `json:"output"`
  21415. RefmsgTime string `json:"refmsg_time"`
  21416. RespondTime string `json:"respond_time"`
  21417. Signtype interface{} `json:"signtype"`
  21418. WarnMsg interface{} `json:"warn_msg"`
  21419. }
  21420. type ResultThree10265 struct {
  21421. Cainfo interface{} `json:"cainfo"`
  21422. ErrMsg string `json:"err_msg"`
  21423. InfRefmsgid string `json:"inf_refmsgid"`
  21424. Infcode string `json:"infcode"`
  21425. Output struct {
  21426. Data struct {
  21427. IptOtpNo string `json:"ipt_otp_no"`
  21428. MdtrtID string `json:"mdtrt_id"`
  21429. PsnNo string `json:"psn_no"`
  21430. } `json:"data"`
  21431. } `json:"output"`
  21432. RefmsgTime string `json:"refmsg_time"`
  21433. RespondTime string `json:"respond_time"`
  21434. Signtype interface{} `json:"signtype"`
  21435. WarnMsg interface{} `json:"warn_msg"`
  21436. }
  21437. type ResultFour struct {
  21438. Cainfo string `json:"cainfo"`
  21439. ErrMsg string `json:"err_msg"`
  21440. InfRefmsgid string `json:"inf_refmsgid"`
  21441. Infcode int64 `json:"infcode"`
  21442. Output struct {
  21443. Result []struct {
  21444. BasMednFlag string `json:"bas_medn_flag"`
  21445. ChldMedcFlag string `json:"chld_medc_flag"`
  21446. ChrgitmLv string `json:"chrgitm_lv"`
  21447. Cnt float64 `json:"cnt"`
  21448. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21449. DrtReimFlag string `json:"drt_reim_flag"`
  21450. FeedetlSn string `json:"feedetl_sn"`
  21451. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21452. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21453. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21454. ListSpItemFlag string `json:"list_sp_item_flag"`
  21455. LmtUsedFlag string `json:"lmt_used_flag"`
  21456. MedChrgitmType string `json:"med_chrgitm_type"`
  21457. Memo string `json:"memo"`
  21458. OverlmtAmt float64 `json:"overlmt_amt"`
  21459. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21460. Pric float64 `json:"pric"`
  21461. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21462. SelfpayProp float64 `json:"selfpay_prop"`
  21463. } `json:"result"`
  21464. } `json:"output"`
  21465. RefmsgTime string `json:"refmsg_time"`
  21466. RespondTime string `json:"respond_time"`
  21467. Signtype string `json:"signtype"`
  21468. WarnMsg string `json:"warn_msg"`
  21469. }
  21470. type ResultFour10265 struct {
  21471. Cainfo string `json:"cainfo"`
  21472. ErrMsg string `json:"err_msg"`
  21473. InfRefmsgid string `json:"inf_refmsgid"`
  21474. Infcode string `json:"infcode"`
  21475. Output struct {
  21476. Result []struct {
  21477. BasMednFlag string `json:"bas_medn_flag"`
  21478. ChldMedcFlag string `json:"chld_medc_flag"`
  21479. ChrgitmLv string `json:"chrgitm_lv"`
  21480. Cnt float64 `json:"cnt"`
  21481. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21482. DrtReimFlag string `json:"drt_reim_flag"`
  21483. FeedetlSn string `json:"feedetl_sn"`
  21484. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21485. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21486. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21487. ListSpItemFlag string `json:"list_sp_item_flag"`
  21488. LmtUsedFlag string `json:"lmt_used_flag"`
  21489. MedChrgitmType string `json:"med_chrgitm_type"`
  21490. Memo string `json:"memo"`
  21491. OverlmtAmt float64 `json:"overlmt_amt"`
  21492. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21493. Pric float64 `json:"pric"`
  21494. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21495. SelfpayProp float64 `json:"selfpay_prop"`
  21496. } `json:"result"`
  21497. } `json:"output"`
  21498. RefmsgTime string `json:"refmsg_time"`
  21499. RespondTime string `json:"respond_time"`
  21500. Signtype string `json:"signtype"`
  21501. WarnMsg string `json:"warn_msg"`
  21502. }
  21503. type ResultMemo struct {
  21504. InsuAdmdvs string `json:"insuAdmdvs"`
  21505. }
  21506. // [{"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}]
  21507. type ResultIDInfo struct {
  21508. Begntime string `json:"begntime"`
  21509. Endtime string `json:"endtime"`
  21510. Memo string `json:"memo"`
  21511. }
  21512. type ResultFive struct {
  21513. Balc float64 `json:"balc"`
  21514. CvlservFlag string `json:"cvlserv_flag"`
  21515. EmpName string `json:"emp_name"`
  21516. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21517. Insutype string `json:"insutype"`
  21518. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21519. PausInsuDate string `json:"paus_insu_date"`
  21520. PsnInsuDate string `json:"psn_insu_date"`
  21521. PsnInsuStas string `json:"psn_insu_stas"`
  21522. PsnType string `json:"psn_type"`
  21523. }
  21524. type ResultSix struct {
  21525. Cainfo interface{} `json:"cainfo"`
  21526. ErrMsg string `json:"err_msg"`
  21527. InfRefmsgid string `json:"inf_refmsgid"`
  21528. Infcode int64 `json:"infcode"`
  21529. Output struct {
  21530. } `json:"output"`
  21531. RefmsgTime string `json:"refmsg_time"`
  21532. RespondTime string `json:"respond_time"`
  21533. Signtype interface{} `json:"signtype"`
  21534. WarnMsg interface{} `json:"warn_msg"`
  21535. }
  21536. type FJ3507Result struct {
  21537. Cainfo interface{} `json:"cainfo"`
  21538. ErrMsg string `json:"err_msg"`
  21539. InfRefmsgid string `json:"inf_refmsgid"`
  21540. Infcode int64 `json:"infcode"`
  21541. Output struct {
  21542. retRslt string `json:"retRslt"`
  21543. msgRslt string `json:"msgRslt"`
  21544. } `json:"output"`
  21545. RefmsgTime string `json:"refmsg_time"`
  21546. RespondTime string `json:"respond_time"`
  21547. Signtype interface{} `json:"signtype"`
  21548. WarnMsg interface{} `json:"warn_msg"`
  21549. }
  21550. type FJ3507ResultFor10188 struct {
  21551. Cainfo interface{} `json:"cainfo"`
  21552. ErrMsg string `json:"err_msg"`
  21553. InfRefmsgid string `json:"inf_refmsgid"`
  21554. Infcode string `json:"infcode"`
  21555. RefmsgTime string `json:"refmsg_time"`
  21556. RespondTime string `json:"respond_time"`
  21557. Signtype interface{} `json:"signtype"`
  21558. WarnMsg interface{} `json:"warn_msg"`
  21559. }
  21560. type Result2406 struct {
  21561. Cainfo interface{} `json:"cainfo"`
  21562. ErrMsg string `json:"err_msg"`
  21563. InfRefmsgid string `json:"inf_refmsgid"`
  21564. Infcode int64 `json:"infcode"`
  21565. Output struct {
  21566. Result struct {
  21567. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21568. } `json:"result"`
  21569. } `json:"output"`
  21570. RefmsgTime string `json:"refmsg_time"`
  21571. RespondTime string `json:"respond_time"`
  21572. Signtype interface{} `json:"signtype"`
  21573. WarnMsg interface{} `json:"warn_msg"`
  21574. }
  21575. type GZResultSix struct {
  21576. Cainfo interface{} `json:"cainfo"`
  21577. ErrMsg string `json:"err_msg"`
  21578. InfRefmsgid string `json:"inf_refmsgid"`
  21579. Infcode int64 `json:"infcode"`
  21580. Output string `json:"output"`
  21581. RefmsgTime string `json:"refmsg_time"`
  21582. RespondTime string `json:"respond_time"`
  21583. Signtype interface{} `json:"signtype"`
  21584. WarnMsg interface{} `json:"warn_msg"`
  21585. }
  21586. type ResultSix10265 struct {
  21587. Cainfo interface{} `json:"cainfo"`
  21588. ErrMsg string `json:"err_msg"`
  21589. InfRefmsgid string `json:"inf_refmsgid"`
  21590. Infcode string `json:"infcode"`
  21591. Output struct {
  21592. } `json:"output"`
  21593. RefmsgTime string `json:"refmsg_time"`
  21594. RespondTime string `json:"respond_time"`
  21595. Signtype interface{} `json:"signtype"`
  21596. WarnMsg interface{} `json:"warn_msg"`
  21597. }
  21598. type ResultSeven struct {
  21599. Cainfo string `json:"cainfo"`
  21600. ErrMsg string `json:"err_msg"`
  21601. InfRefmsgid string `json:"inf_refmsgid"`
  21602. Infcode int64 `json:"infcode"`
  21603. Output struct {
  21604. Setlinfo struct {
  21605. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21606. AcctPay float64 `json:"acct_pay"`
  21607. ActPayDedc float64 `json:"act_pay_dedc"`
  21608. Age float64 `json:"age"`
  21609. Balc float64 `json:"balc"`
  21610. Certno string `json:"certno"`
  21611. ClrOptins string `json:"clr_optins"`
  21612. ClrType string `json:"clr_type"`
  21613. ClrWay string `json:"clr_way"`
  21614. CvlservFlag string `json:"cvlserv_flag"`
  21615. CvlservPay float64 `json:"cvlserv_pay"`
  21616. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21617. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21618. Gend string `json:"gend"`
  21619. HifesPay float64 `json:"hifes_pay"`
  21620. HifmiPay float64 `json:"hifmi_pay"`
  21621. HifpPay float64 `json:"hifp_pay"`
  21622. HospPartAmt float64 `json:"hosp_part_amt"`
  21623. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21624. Insutype string `json:"insutype"`
  21625. MafPay float64 `json:"maf_pay"`
  21626. MdtrtCertType string `json:"mdtrt_cert_type"`
  21627. HifobPay float64 `json:"hifob_pay"`
  21628. MdtrtID string `json:"mdtrt_id"`
  21629. MedType string `json:"med_type"`
  21630. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21631. MedinsSetlID string `json:"medins_setl_id"`
  21632. Naty string `json:"naty"`
  21633. OthPay float64 `json:"oth_pay"`
  21634. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21635. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21636. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21637. PsnCashPay float64 `json:"psn_cash_pay"`
  21638. PsnCertType string `json:"psn_cert_type"`
  21639. PsnName string `json:"psn_name"`
  21640. PsnNo string `json:"psn_no"`
  21641. PsnPartAmt float64 `json:"psn_part_amt"`
  21642. PsnType string `json:"psn_type"`
  21643. SetlID string `json:"setl_id"`
  21644. SetlTime string `json:"setl_time"`
  21645. } `json:"setlinfo"`
  21646. Setldetail interface{} `json:"setldetail"`
  21647. } `json:"output"`
  21648. RefmsgTime string `json:"refmsg_time"`
  21649. RespondTime string `json:"respond_time"`
  21650. Signtype interface{} `json:"signtype"`
  21651. WarnMsg interface{} `json:"warn_msg"`
  21652. }
  21653. type ResultSevenAH struct {
  21654. Cainfo string `json:"cainfo"`
  21655. ErrMsg string `json:"err_msg"`
  21656. InfRefmsgid string `json:"inf_refmsgid"`
  21657. Infcode int64 `json:"infcode"`
  21658. Output struct {
  21659. Setlinfo struct {
  21660. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21661. AcctPay float64 `json:"acct_pay"`
  21662. ActPayDedc float64 `json:"act_pay_dedc"`
  21663. Age float64 `json:"age"`
  21664. Balc float64 `json:"balc"`
  21665. Certno string `json:"certno"`
  21666. ClrOptins string `json:"clr_optins"`
  21667. ClrType string `json:"clr_type"`
  21668. ClrWay string `json:"clr_way"`
  21669. CvlservFlag string `json:"cvlserv_flag"`
  21670. CvlservPay float64 `json:"cvlserv_pay"`
  21671. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21672. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21673. Gend string `json:"gend"`
  21674. HifesPay float64 `json:"hifes_pay"`
  21675. HifmiPay float64 `json:"hifmi_pay"`
  21676. HifpPay float64 `json:"hifp_pay"`
  21677. HospPartAmt float64 `json:"hosp_part_amt"`
  21678. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21679. Insutype string `json:"insutype"`
  21680. MafPay float64 `json:"maf_pay"`
  21681. MdtrtCertType string `json:"mdtrt_cert_type"`
  21682. HifobPay float64 `json:"hifob_pay"`
  21683. MdtrtID string `json:"mdtrt_id"`
  21684. MedType string `json:"med_type"`
  21685. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21686. MedinsSetlID string `json:"medins_setl_id"`
  21687. Naty string `json:"naty"`
  21688. OthPay float64 `json:"oth_pay"`
  21689. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21690. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21691. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21692. PsnCashPay float64 `json:"psn_cash_pay"`
  21693. PsnCertType string `json:"psn_cert_type"`
  21694. PsnName string `json:"psn_name"`
  21695. PsnNo string `json:"psn_no"`
  21696. PsnPartAmt float64 `json:"psn_part_amt"`
  21697. PsnType string `json:"psn_type"`
  21698. SetlID string `json:"setl_id"`
  21699. SetlTime int64 `json:"setl_time"`
  21700. } `json:"setlinfo"`
  21701. Setldetail interface{} `json:"setldetail"`
  21702. } `json:"output"`
  21703. RefmsgTime string `json:"refmsg_time"`
  21704. RespondTime string `json:"respond_time"`
  21705. Signtype interface{} `json:"signtype"`
  21706. WarnMsg interface{} `json:"warn_msg"`
  21707. }
  21708. type ResultSeven10265 struct {
  21709. Cainfo string `json:"cainfo"`
  21710. ErrMsg string `json:"err_msg"`
  21711. InfRefmsgid string `json:"inf_refmsgid"`
  21712. Infcode string `json:"infcode"`
  21713. Output struct {
  21714. Setlinfo struct {
  21715. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21716. AcctPay float64 `json:"acct_pay"`
  21717. ActPayDedc float64 `json:"act_pay_dedc"`
  21718. Age float64 `json:"age"`
  21719. Balc float64 `json:"balc"`
  21720. Certno string `json:"certno"`
  21721. ClrOptins string `json:"clr_optins"`
  21722. ClrType string `json:"clr_type"`
  21723. ClrWay string `json:"clr_way"`
  21724. CvlservFlag string `json:"cvlserv_flag"`
  21725. CvlservPay float64 `json:"cvlserv_pay"`
  21726. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21727. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21728. Gend string `json:"gend"`
  21729. HifesPay float64 `json:"hifes_pay"`
  21730. HifmiPay float64 `json:"hifmi_pay"`
  21731. HifpPay float64 `json:"hifp_pay"`
  21732. HospPartAmt float64 `json:"hosp_part_amt"`
  21733. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21734. Insutype string `json:"insutype"`
  21735. MafPay float64 `json:"maf_pay"`
  21736. MdtrtCertType string `json:"mdtrt_cert_type"`
  21737. HifobPay float64 `json:"hifob_pay"`
  21738. MdtrtID string `json:"mdtrt_id"`
  21739. MedType string `json:"med_type"`
  21740. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21741. MedinsSetlID string `json:"medins_setl_id"`
  21742. Naty string `json:"naty"`
  21743. OthPay float64 `json:"oth_pay"`
  21744. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21745. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21746. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21747. PsnCashPay float64 `json:"psn_cash_pay"`
  21748. PsnCertType string `json:"psn_cert_type"`
  21749. PsnName string `json:"psn_name"`
  21750. PsnNo string `json:"psn_no"`
  21751. PsnPartAmt float64 `json:"psn_part_amt"`
  21752. PsnType string `json:"psn_type"`
  21753. SetlID string `json:"setl_id"`
  21754. SetlTime string `json:"setl_time"`
  21755. } `json:"setlinfo"`
  21756. Setldetail interface{} `json:"setldetail"`
  21757. } `json:"output"`
  21758. RefmsgTime string `json:"refmsg_time"`
  21759. RespondTime string `json:"respond_time"`
  21760. Signtype interface{} `json:"signtype"`
  21761. WarnMsg interface{} `json:"warn_msg"`
  21762. }
  21763. type ResultSeven10265Two struct {
  21764. Cainfo string `json:"cainfo"`
  21765. ErrMsg string `json:"err_msg"`
  21766. InfRefmsgid string `json:"inf_refmsgid"`
  21767. Infcode string `json:"infcode"`
  21768. Output struct {
  21769. Setlinfo struct {
  21770. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21771. AcctPay float64 `json:"acct_pay"`
  21772. ActPayDedc float64 `json:"act_pay_dedc"`
  21773. Age float64 `json:"age"`
  21774. Balc float64 `json:"balc"`
  21775. Certno string `json:"certno"`
  21776. ClrOptins string `json:"clr_optins"`
  21777. ClrType string `json:"clr_type"`
  21778. ClrWay string `json:"clr_way"`
  21779. CvlservFlag string `json:"cvlserv_flag"`
  21780. CvlservPay float64 `json:"cvlserv_pay"`
  21781. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21782. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21783. Gend string `json:"gend"`
  21784. HifesPay float64 `json:"hifes_pay"`
  21785. HifmiPay float64 `json:"hifmi_pay"`
  21786. HifpPay float64 `json:"hifp_pay"`
  21787. HospPartAmt string `json:"hosp_part_amt"`
  21788. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21789. Insutype string `json:"insutype"`
  21790. MafPay float64 `json:"maf_pay"`
  21791. MdtrtCertType string `json:"mdtrt_cert_type"`
  21792. HifobPay float64 `json:"hifob_pay"`
  21793. MdtrtID string `json:"mdtrt_id"`
  21794. MedType string `json:"med_type"`
  21795. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21796. MedinsSetlID string `json:"medins_setl_id"`
  21797. Naty string `json:"naty"`
  21798. OthPay float64 `json:"oth_pay"`
  21799. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21800. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21801. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21802. PsnCashPay float64 `json:"psn_cash_pay"`
  21803. PsnCertType string `json:"psn_cert_type"`
  21804. PsnName string `json:"psn_name"`
  21805. PsnNo string `json:"psn_no"`
  21806. PsnPartAmt float64 `json:"psn_part_amt"`
  21807. PsnType string `json:"psn_type"`
  21808. SetlID string `json:"setl_id"`
  21809. SetlTime string `json:"setl_time"`
  21810. } `json:"setlinfo"`
  21811. Setldetail interface{} `json:"setldetail"`
  21812. } `json:"output"`
  21813. RefmsgTime string `json:"refmsg_time"`
  21814. RespondTime string `json:"respond_time"`
  21815. Signtype interface{} `json:"signtype"`
  21816. WarnMsg interface{} `json:"warn_msg"`
  21817. }
  21818. type GZResultSeven10265Two struct {
  21819. Cainfo string `json:"cainfo"`
  21820. ErrMsg string `json:"err_msg"`
  21821. InfRefmsgid string `json:"inf_refmsgid"`
  21822. Infcode int64 `json:"infcode"`
  21823. Output struct {
  21824. Setlinfo struct {
  21825. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21826. AcctPay float64 `json:"acct_pay"`
  21827. ActPayDedc float64 `json:"act_pay_dedc"`
  21828. Age float64 `json:"age"`
  21829. Balc float64 `json:"balc"`
  21830. Certno string `json:"certno"`
  21831. ClrOptins string `json:"clr_optins"`
  21832. ClrType string `json:"clr_type"`
  21833. ClrWay string `json:"clr_way"`
  21834. CvlservFlag string `json:"cvlserv_flag"`
  21835. CvlservPay float64 `json:"cvlserv_pay"`
  21836. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21837. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21838. Gend string `json:"gend"`
  21839. HifesPay float64 `json:"hifes_pay"`
  21840. HifmiPay float64 `json:"hifmi_pay"`
  21841. HifpPay float64 `json:"hifp_pay"`
  21842. HospPartAmt float64 `json:"hosp_part_amt"`
  21843. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21844. Insutype string `json:"insutype"`
  21845. MafPay float64 `json:"maf_pay"`
  21846. MdtrtCertType string `json:"mdtrt_cert_type"`
  21847. HifobPay float64 `json:"hifob_pay"`
  21848. MdtrtID string `json:"mdtrt_id"`
  21849. MedType string `json:"med_type"`
  21850. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21851. MedinsSetlID string `json:"medins_setl_id"`
  21852. Naty string `json:"naty"`
  21853. OthPay float64 `json:"oth_pay"`
  21854. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21855. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21856. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21857. PsnCashPay float64 `json:"psn_cash_pay"`
  21858. PsnCertType string `json:"psn_cert_type"`
  21859. PsnName string `json:"psn_name"`
  21860. PsnNo string `json:"psn_no"`
  21861. PsnPartAmt float64 `json:"psn_part_amt"`
  21862. PsnType string `json:"psn_type"`
  21863. SetlID string `json:"setl_id"`
  21864. SetlTime string `json:"setl_time"`
  21865. } `json:"setlinfo"`
  21866. Setldetail interface{} `json:"setldetail"`
  21867. } `json:"output"`
  21868. RefmsgTime string `json:"refmsg_time"`
  21869. RespondTime string `json:"respond_time"`
  21870. Signtype interface{} `json:"signtype"`
  21871. WarnMsg interface{} `json:"warn_msg"`
  21872. }
  21873. type ResultEight struct {
  21874. Cainfo string `json:"cainfo"`
  21875. ErrMsg string `json:"err_msg"`
  21876. InfRefmsgid string `json:"inf_refmsgid"`
  21877. Infcode int64 `json:"infcode"`
  21878. Output struct {
  21879. Stmtinfo struct {
  21880. SetlOptins string `json:"setl_optins"`
  21881. StmtRslt string `json:"stmt_rslt"`
  21882. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21883. } `json:"stmtinfo"`
  21884. } `json:"output"`
  21885. RefmsgTime string `json:"refmsg_time"`
  21886. RespondTime string `json:"respond_time"`
  21887. Signtype interface{} `json:"signtype"`
  21888. WarnMsg interface{} `json:"warn_msg"`
  21889. }
  21890. type ResultEightFor10188 struct {
  21891. Cainfo string `json:"cainfo"`
  21892. ErrMsg string `json:"err_msg"`
  21893. InfRefmsgid string `json:"inf_refmsgid"`
  21894. Infcode string `json:"infcode"`
  21895. Output struct {
  21896. Stmtinfo struct {
  21897. SetlOptins string `json:"setl_optins"`
  21898. StmtRslt string `json:"stmt_rslt"`
  21899. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21900. } `json:"stmtinfo"`
  21901. } `json:"output"`
  21902. RefmsgTime string `json:"refmsg_time"`
  21903. RespondTime string `json:"respond_time"`
  21904. Signtype interface{} `json:"signtype"`
  21905. WarnMsg interface{} `json:"warn_msg"`
  21906. }
  21907. type ResultNine struct {
  21908. Cainfo string `json:"cainfo"`
  21909. ErrMsg string `json:"err_msg"`
  21910. InfRefmsgid string `json:"inf_refmsgid"`
  21911. Infcode int64 `json:"infcode"`
  21912. Output struct {
  21913. FileQuryNo string `json:"file_qury_no"`
  21914. } `json:"output"`
  21915. RefmsgTime string `json:"refmsg_time"`
  21916. RespondTime string `json:"respond_time"`
  21917. Signtype interface{} `json:"signtype"`
  21918. WarnMsg interface{} `json:"warn_msg"`
  21919. }
  21920. type ResultTen struct {
  21921. Cainfo string `json:"cainfo"`
  21922. ErrMsg string `json:"err_msg"`
  21923. InfRefmsgid string `json:"inf_refmsgid"`
  21924. Infcode int64 `json:"infcode"`
  21925. Output struct {
  21926. Fileinfo struct {
  21927. DldEndtime string `json:"dld_endtime"`
  21928. FileQuryNo string `json:"file_qury_no"`
  21929. Filename string `json:"filename"`
  21930. } `json:"fileinfo"`
  21931. } `json:"output"`
  21932. RefmsgTime string `json:"refmsg_time"`
  21933. RespondTime string `json:"respond_time"`
  21934. Signtype interface{} `json:"signtype"`
  21935. WarnMsg interface{} `json:"warn_msg"`
  21936. }
  21937. type Result5262 struct {
  21938. ErrMsg string `json:"err_msg"`
  21939. InfRefmsgid string `json:"inf_refmsgid"`
  21940. Infcode int64 `json:"infcode"`
  21941. Output struct {
  21942. PageInfo struct {
  21943. Size int `json:"size"`
  21944. RecordCounts int `json:"record_counts"`
  21945. } `json:"page_info"`
  21946. Idetinfo []interface{} `json:"idetinfo"`
  21947. Result []struct {
  21948. SetlID string `json:"setl_id"`
  21949. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21950. MdtrtID string `json:"mdtrt_id"`
  21951. InitSetlID string `json:"init_setl_id,omitempty"`
  21952. PsnNo string `json:"psn_no"`
  21953. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21954. PsnName string `json:"psn_name"`
  21955. PsnCertType string `json:"psn_cert_type"`
  21956. Certno string `json:"certno"`
  21957. Gend string `json:"gend,omitempty"`
  21958. Naty string `json:"naty,omitempty"`
  21959. Brdy string `json:"brdy,omitempty"`
  21960. Age float64 `json:"age,omitempty"`
  21961. Insutype string `json:"insutype,omitempty"`
  21962. PsnType string `json:"psn_type"`
  21963. CvlservFlag string `json:"cvlserv_flag"`
  21964. CvlservLv string `json:"cvlserv_lv,omitempty"`
  21965. SpPsnType string `json:"sp_psn_type,omitempty"`
  21966. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  21967. ClctGrde string `json:"clct_grde,omitempty"`
  21968. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  21969. NwbFlag string `json:"nwb_flag,omitempty"`
  21970. InsuAdmdvs string `json:"insu_admdvs"`
  21971. EmpNo string `json:"emp_no,omitempty"`
  21972. EmpName string `json:"emp_name,omitempty"`
  21973. EmpType string `json:"emp_type,omitempty"`
  21974. EconType string `json:"econ_type,omitempty"`
  21975. AfilIndu string `json:"afil_indu,omitempty"`
  21976. AfilRlts string `json:"afil_rlts,omitempty"`
  21977. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  21978. PayLoc string `json:"pay_loc,omitempty"`
  21979. FixmedinsCode string `json:"fixmedins_code"`
  21980. FixmedinsName string `json:"fixmedins_name"`
  21981. HospLv string `json:"hosp_lv,omitempty"`
  21982. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  21983. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  21984. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  21985. Begndate string `json:"begndate"`
  21986. Enddate string `json:"enddate"`
  21987. SetlTime string `json:"setl_time"`
  21988. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  21989. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  21990. MedType string `json:"med_type"`
  21991. SetlType string `json:"setl_type,omitempty"`
  21992. ClrType string `json:"clr_type,omitempty"`
  21993. ClrWay string `json:"clr_way,omitempty"`
  21994. PsnSetlway string `json:"psn_setlway,omitempty"`
  21995. ClrOptins string `json:"clr_optins,omitempty"`
  21996. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  21997. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  21998. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  21999. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22000. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22001. DedcStd float64 `json:"dedc_std,omitempty"`
  22002. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22003. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22004. HifpPay float64 `json:"hifp_pay,omitempty"`
  22005. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22006. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22007. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22008. HifesPay float64 `json:"hifes_pay,omitempty"`
  22009. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22010. HifobPay float64 `json:"hifob_pay,omitempty"`
  22011. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22012. MafPay float64 `json:"maf_pay,omitempty"`
  22013. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22014. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22015. PsnPay float64 `json:"psn_pay,omitempty"`
  22016. AcctPay float64 `json:"acct_pay,omitempty"`
  22017. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22018. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22019. Balc float64 `json:"balc,omitempty"`
  22020. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22021. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22022. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22023. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22024. Year string `json:"year,omitempty"`
  22025. DiseNo string `json:"dise_no,omitempty"`
  22026. DiseName string `json:"dise_name,omitempty"`
  22027. Invono string `json:"invono,omitempty"`
  22028. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22029. ValiFlag string `json:"vali_flag,omitempty"`
  22030. Memo string `json:"memo,omitempty"`
  22031. Rid string `json:"rid"`
  22032. UpdtTime string `json:"updt_time,omitempty"`
  22033. CrterID string `json:"crter_id,omitempty"`
  22034. CrterName string `json:"crter_name,omitempty"`
  22035. CrteTime string `json:"crte_time,omitempty"`
  22036. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22037. OpterID string `json:"opter_id,omitempty"`
  22038. OpterName string `json:"opter_name,omitempty"`
  22039. OptTime string `json:"opt_time,omitempty"`
  22040. OptinsNo string `json:"optins_no,omitempty"`
  22041. PoolareaNo string `json:"poolarea_no,omitempty"`
  22042. } `json:"result"`
  22043. } `json:"output"`
  22044. RefmsgTime string `json:"refmsg_time"`
  22045. RespondTime string `json:"respond_time"`
  22046. Signtype interface{} `json:"signtype"`
  22047. WarnInfo interface{} `json:"warn_info"`
  22048. }
  22049. type Result5267 struct {
  22050. ErrMsg string `json:"err_msg"`
  22051. InfRefmsgid string `json:"inf_refmsgid"`
  22052. Infcode int64 `json:"infcode"`
  22053. Output struct {
  22054. PageInfo struct {
  22055. Size int `json:"size"`
  22056. RecordCounts int `json:"record_counts"`
  22057. } `json:"pageinfo"`
  22058. Result []struct {
  22059. SetlID string `json:"setl_id"`
  22060. ClrOptins string `json:"clr_optins"`
  22061. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22062. MdtrtID string `json:"mdtrt_id"`
  22063. InitSetlID string `json:"init_setl_id,omitempty"`
  22064. PsnNo string `json:"psn_no"`
  22065. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22066. PsnName string `json:"psn_name"`
  22067. PsnCertType string `json:"psn_cert_type"`
  22068. Certno string `json:"certno"`
  22069. Gend string `json:"gend,omitempty"`
  22070. Naty string `json:"naty,omitempty"`
  22071. Brdy string `json:"brdy,omitempty"`
  22072. Age float64 `json:"age,omitempty"`
  22073. Insutype string `json:"insutype,omitempty"`
  22074. PsnType string `json:"psn_type"`
  22075. CvlservFlag string `json:"cvlserv_flag"`
  22076. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22077. SpPsnType string `json:"sp_psn_type,omitempty"`
  22078. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22079. ClctGrde string `json:"clct_grde,omitempty"`
  22080. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22081. NwbFlag string `json:"nwb_flag,omitempty"`
  22082. InsuAdmdvs string `json:"insu_admdvs"`
  22083. EmpNo string `json:"emp_no,omitempty"`
  22084. EmpName string `json:"emp_name,omitempty"`
  22085. EmpType string `json:"emp_type,omitempty"`
  22086. EconType string `json:"econ_type,omitempty"`
  22087. AfilIndu string `json:"afil_indu,omitempty"`
  22088. AfilRlts string `json:"afil_rlts,omitempty"`
  22089. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22090. PayLoc string `json:"pay_loc,omitempty"`
  22091. FixmedinsCode string `json:"fixmedins_code"`
  22092. FixmedinsName string `json:"fixmedins_name"`
  22093. HospLv string `json:"hosp_lv,omitempty"`
  22094. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22095. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22096. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22097. Begndate string `json:"begndate,omitempty"`
  22098. Enddate string `json:"enddate,omitempty"`
  22099. SetlTime string `json:"setl_time,omitempty"`
  22100. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22101. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22102. MedType string `json:"med_type"`
  22103. SetlType string `json:"setl_type,omitempty"`
  22104. ClrType string `json:"clr_type,omitempty"`
  22105. ClrWay string `json:"clr_way,omitempty"`
  22106. PsnSetlway string `json:"psn_setlway,omitempty"`
  22107. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22108. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22109. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22110. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22111. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22112. DedcStd float64 `json:"dedc_std,omitempty"`
  22113. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22114. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22115. HifpPay float64 `json:"hifp_pay,omitempty"`
  22116. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22117. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22118. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22119. HifesPay float64 `json:"hifes_pay,omitempty"`
  22120. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22121. HifobPay float64 `json:"hifob_pay,omitempty"`
  22122. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22123. MafPay float64 `json:"maf_pay,omitempty"`
  22124. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22125. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22126. PsnPay float64 `json:"psn_pay,omitempty"`
  22127. AcctPay float64 `json:"acct_pay,omitempty"`
  22128. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22129. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22130. Balc float64 `json:"balc,omitempty"`
  22131. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22132. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22133. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22134. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22135. Year string `json:"year,omitempty"`
  22136. DiseNo string `json:"dise_no,omitempty"`
  22137. DiseName string `json:"dise_name,omitempty"`
  22138. Invono string `json:"invono,omitempty"`
  22139. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22140. Memo string `json:"memo,omitempty"`
  22141. UpdtTime string `json:"updt_time,omitempty"`
  22142. OpterID string `json:"opter_id,omitempty"`
  22143. OpterName string `json:"opter_name,omitempty"`
  22144. OptTime string `json:"opt_time,omitempty"`
  22145. OptinsNo string `json:"optins_no,omitempty"`
  22146. PoolareaNo string `json:"poolarea_no,omitempty"`
  22147. } `json:"result"`
  22148. } `json:"output"`
  22149. RefmsgTime string `json:"refmsg_time"`
  22150. RespondTime string `json:"respond_time"`
  22151. Signtype interface{} `json:"signtype"`
  22152. WarnInfo interface{} `json:"warn_info"`
  22153. }
  22154. // type Autogenerated struct {
  22155. // Output struct {
  22156. // Setlinfo struct {
  22157. // SetlTime string `json:"setl_time"`
  22158. // CvlservPay float64 `json:"cvlserv_pay"`
  22159. // Year string `json:"year"`
  22160. // MedType string `json:"med_type"`
  22161. // PsnPay float64 `json:"psn_pay"`
  22162. // OpterID string `json:"opter_id"`
  22163. // Begndate string `json:"begndate"`
  22164. // FlxempeFlag string `json:"flxempe_flag"`
  22165. // HifmiPay float64 `json:"hifmi_pay"`
  22166. // PsnNo string `json:"psn_no"`
  22167. // ActPayDedc float64 `json:"act_pay_dedc"`
  22168. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22169. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22170. // ClrWay string `json:"clr_way"`
  22171. // OthPay float64 `json:"oth_pay"`
  22172. // Gend string `json:"gend"`
  22173. // MdtrtID string `json:"mdtrt_id"`
  22174. // AcctPay float64 `json:"acct_pay"`
  22175. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22176. // Insutype string `json:"insutype"`
  22177. // Invono interface{} `json:"invono"`
  22178. // Enddate string `json:"enddate"`
  22179. // CashPayamt float64 `json:"cash_payamt"`
  22180. // PsnType string `json:"psn_type"`
  22181. // FixmedinsName string `json:"fixmedins_name"`
  22182. // HifpPay float64 `json:"hifp_pay"`
  22183. // NewFlag interface{} `json:"new_flag"`
  22184. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22185. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22186. // PayLoc string `json:"pay_loc"`
  22187. // ClrType string `json:"clr_type"`
  22188. // RefdSetlFlag string `json:"refd_setl_flag"`
  22189. // CvlservFlag string `json:"cvlserv_flag"`
  22190. // EmpName string `json:"emp_name"`
  22191. // Brdy string `json:"brdy"`
  22192. // Naty string `json:"naty"`
  22193. // Certno string `json:"certno"`
  22194. // DiseCode string `json:"dise_code"`
  22195. // FixmedinsCode string `json:"fixmedins_code"`
  22196. // DedcHospLv string `json:"dedc_hosp_lv"`
  22197. // OpterName string `json:"opter_name"`
  22198. // Balc float64 `json:"balc"`
  22199. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22200. // PsnCertType string `json:"psn_cert_type"`
  22201. // HifobPay float64 `json:"hifob_pay"`
  22202. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22203. // HifesPay float64 `json:"hifes_pay"`
  22204. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22205. // OptTime string `json:"opt_time"`
  22206. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22207. // SetlID string `json:"setl_id"`
  22208. // MafPay float64 `json:"maf_pay"`
  22209. // PsnName string `json:"psn_name"`
  22210. // InsuOptins interface{} `json:"insu_optins"`
  22211. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22212. // ClrOptins string `json:"clr_optins"`
  22213. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22214. // DiseName string `json:"dise_name"`
  22215. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22216. // Age float64 `json:"age"`
  22217. // DtrtCertType string `json:"dtrt_cert_type"`
  22218. // HospLv string `json:"hosp_lv"`
  22219. // } `json:"setlinfo"`
  22220. // Setldetail []struct {
  22221. // FundPayType string `json:"fund_pay_type"`
  22222. // FundPayamt float64 `json:"fund_payamt"`
  22223. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22224. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22225. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22226. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22227. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22228. // } `json:"setldetail"`
  22229. // } `json:"output"`
  22230. // Infcode int `json:"infcode"`
  22231. // WarnMsg interface{} `json:"warn_msg"`
  22232. // Cainfo interface{} `json:"cainfo"`
  22233. // ErrMsg interface{} `json:"err_msg"`
  22234. // RefmsgTime string `json:"refmsg_time"`
  22235. // Signtype interface{} `json:"signtype"`
  22236. // RespondTime string `json:"respond_time"`
  22237. // InfRefmsgid string `json:"inf_refmsgid"`
  22238. // }
  22239. type Result002 struct {
  22240. Cainfo interface{} `json:"cainfo"`
  22241. ErrMsg string `json:"err_msg"`
  22242. InfRefmsgid string `json:"inf_refmsgid"`
  22243. Infcode int64 `json:"infcode"`
  22244. Output struct {
  22245. RxFile string `json:"rx_file"`
  22246. SignDigest string `json:"sign_digest"`
  22247. SignCertSn string `json:"sign_cert_sn"`
  22248. SignCertDn string `json:"sign_cert_dn"`
  22249. } `json:"output"`
  22250. RefmsgTime string `json:"refmsg_time"`
  22251. RespondTime string `json:"respond_time"`
  22252. Signtype interface{} `json:"signtype"`
  22253. WarnMsg interface{} `json:"warn_msg"`
  22254. }
  22255. type Result003 struct {
  22256. Cainfo interface{} `json:"cainfo"`
  22257. ErrMsg string `json:"err_msg"`
  22258. InfRefmsgid string `json:"inf_refmsgid"`
  22259. Infcode int64 `json:"infcode"`
  22260. Output struct {
  22261. HiRxno string `json:"hi_rxno"`
  22262. RxStasCodg string `json:"rx_stas_codg"`
  22263. RxStasName string `json:"rx_stas_name"`
  22264. } `json:"output"`
  22265. RefmsgTime string `json:"refmsg_time"`
  22266. RespondTime string `json:"respond_time"`
  22267. Signtype interface{} `json:"signtype"`
  22268. WarnMsg interface{} `json:"warn_msg"`
  22269. }
  22270. type ResultEleven struct {
  22271. Cainfo string `json:"cainfo"`
  22272. ErrMsg string `json:"err_msg"`
  22273. InfRefmsgid string `json:"inf_refmsgid"`
  22274. Infcode int64 `json:"infcode"`
  22275. Output struct {
  22276. Setlinfo struct {
  22277. SetlTime string `json:"setl_time"`
  22278. CvlservPay float64 `json:"cvlserv_pay"`
  22279. Year string `json:"year"`
  22280. MedType string `json:"med_type"`
  22281. PsnPay float64 `json:"psn_pay"`
  22282. OpterID string `json:"opter_id"`
  22283. Begndate string `json:"begndate"`
  22284. FlxempeFlag string `json:"flxempe_flag"`
  22285. HifmiPay float64 `json:"hifmi_pay"`
  22286. PsnNo string `json:"psn_no"`
  22287. ActPayDedc float64 `json:"act_pay_dedc"`
  22288. MedinsSetlID interface{} `json:"medins_setl_id"`
  22289. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22290. ClrWay string `json:"clr_way"`
  22291. OthPay float64 `json:"oth_pay"`
  22292. Gend string `json:"gend"`
  22293. MdtrtID string `json:"mdtrt_id"`
  22294. AcctPay float64 `json:"acct_pay"`
  22295. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22296. Insutype string `json:"insutype"`
  22297. Invono interface{} `json:"invono"`
  22298. Enddate string `json:"enddate"`
  22299. CashPayamt float64 `json:"cash_payamt"`
  22300. PsnType string `json:"psn_type"`
  22301. FixmedinsName string `json:"fixmedins_name"`
  22302. HifpPay float64 `json:"hifp_pay"`
  22303. NewFlag interface{} `json:"new_flag"`
  22304. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22305. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22306. PayLoc string `json:"pay_loc"`
  22307. ClrType string `json:"clr_type"`
  22308. RefdSetlFlag string `json:"refd_setl_flag"`
  22309. CvlservFlag string `json:"cvlserv_flag"`
  22310. EmpName string `json:"emp_name"`
  22311. Brdy string `json:"brdy"`
  22312. Naty string `json:"naty"`
  22313. Certno string `json:"certno"`
  22314. DiseCode string `json:"dise_code"`
  22315. FixmedinsCode string `json:"fixmedins_code"`
  22316. DedcHospLv string `json:"dedc_hosp_lv"`
  22317. OpterName string `json:"opter_name"`
  22318. Balc float64 `json:"balc"`
  22319. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22320. PsnCertType string `json:"psn_cert_type"`
  22321. HifobPay float64 `json:"hifob_pay"`
  22322. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22323. HifesPay float64 `json:"hifes_pay"`
  22324. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22325. OptTime string `json:"opt_time"`
  22326. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22327. SetlID string `json:"setl_id"`
  22328. MafPay float64 `json:"maf_pay"`
  22329. PsnName string `json:"psn_name"`
  22330. InsuOptins interface{} `json:"insu_optins"`
  22331. PrefFundPay interface{} `json:"pref_fund_pay"`
  22332. ClrOptins string `json:"clr_optins"`
  22333. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22334. DiseName string `json:"dise_name"`
  22335. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22336. Age float64 `json:"age"`
  22337. DtrtCertType string `json:"dtrt_cert_type"`
  22338. HospLv string `json:"hosp_lv"`
  22339. PsnCashPay float64 `json:"psn_cash_pay"`
  22340. } `json:"setlinfo"`
  22341. } `json:"output"`
  22342. RefmsgTime string `json:"refmsg_time"`
  22343. RespondTime string `json:"respond_time"`
  22344. Signtype interface{} `json:"signtype"`
  22345. WarnMsg interface{} `json:"warn_msg"`
  22346. }
  22347. type ResultElevenah struct {
  22348. Cainfo string `json:"cainfo"`
  22349. ErrMsg string `json:"err_msg"`
  22350. InfRefmsgid string `json:"inf_refmsgid"`
  22351. Infcode int64 `json:"infcode"`
  22352. Output struct {
  22353. Setlinfo struct {
  22354. SetlTime int64 `json:"setl_time"`
  22355. CvlservPay float64 `json:"cvlserv_pay"`
  22356. Year string `json:"year"`
  22357. MedType string `json:"med_type"`
  22358. PsnPay float64 `json:"psn_pay"`
  22359. OpterID string `json:"opter_id"`
  22360. Begndate int64 `json:"begndate"`
  22361. FlxempeFlag string `json:"flxempe_flag"`
  22362. HifmiPay float64 `json:"hifmi_pay"`
  22363. PsnNo string `json:"psn_no"`
  22364. ActPayDedc float64 `json:"act_pay_dedc"`
  22365. MedinsSetlID interface{} `json:"medins_setl_id"`
  22366. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22367. ClrWay string `json:"clr_way"`
  22368. OthPay float64 `json:"oth_pay"`
  22369. Gend string `json:"gend"`
  22370. MdtrtID string `json:"mdtrt_id"`
  22371. AcctPay float64 `json:"acct_pay"`
  22372. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22373. Insutype string `json:"insutype"`
  22374. Invono interface{} `json:"invono"`
  22375. Enddate int64 `json:"enddate"`
  22376. CashPayamt float64 `json:"cash_payamt"`
  22377. PsnType string `json:"psn_type"`
  22378. FixmedinsName string `json:"fixmedins_name"`
  22379. HifpPay float64 `json:"hifp_pay"`
  22380. NewFlag interface{} `json:"new_flag"`
  22381. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22382. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22383. PayLoc string `json:"pay_loc"`
  22384. ClrType string `json:"clr_type"`
  22385. RefdSetlFlag string `json:"refd_setl_flag"`
  22386. CvlservFlag string `json:"cvlserv_flag"`
  22387. EmpName string `json:"emp_name"`
  22388. Brdy int64 `json:"brdy"`
  22389. Naty string `json:"naty"`
  22390. Certno string `json:"certno"`
  22391. DiseCode string `json:"dise_code"`
  22392. FixmedinsCode string `json:"fixmedins_code"`
  22393. DedcHospLv string `json:"dedc_hosp_lv"`
  22394. OpterName string `json:"opter_name"`
  22395. Balc float64 `json:"balc"`
  22396. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22397. PsnCertType string `json:"psn_cert_type"`
  22398. HifobPay float64 `json:"hifob_pay"`
  22399. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22400. HifesPay float64 `json:"hifes_pay"`
  22401. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22402. OptTime int64 `json:"opt_time"`
  22403. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22404. SetlID string `json:"setl_id"`
  22405. MafPay float64 `json:"maf_pay"`
  22406. PsnName string `json:"psn_name"`
  22407. InsuOptins interface{} `json:"insu_optins"`
  22408. PrefFundPay interface{} `json:"pref_fund_pay"`
  22409. ClrOptins string `json:"clr_optins"`
  22410. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22411. DiseName string `json:"dise_name"`
  22412. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22413. Age float64 `json:"age"`
  22414. DtrtCertType string `json:"dtrt_cert_type"`
  22415. HospLv string `json:"hosp_lv"`
  22416. PsnCashPay float64 `json:"psn_cash_pay"`
  22417. } `json:"setlinfo"`
  22418. } `json:"output"`
  22419. RefmsgTime string `json:"refmsg_time"`
  22420. RespondTime string `json:"respond_time"`
  22421. Signtype interface{} `json:"signtype"`
  22422. WarnMsg interface{} `json:"warn_msg"`
  22423. }
  22424. type ResultEleven10265 struct {
  22425. Cainfo string `json:"cainfo"`
  22426. ErrMsg string `json:"err_msg"`
  22427. InfRefmsgid string `json:"inf_refmsgid"`
  22428. Infcode string `json:"infcode"`
  22429. Output struct {
  22430. Setlinfo struct {
  22431. SetlTime string `json:"setl_time"`
  22432. CvlservPay float64 `json:"cvlserv_pay"`
  22433. Year string `json:"year"`
  22434. MedType string `json:"med_type"`
  22435. PsnPay float64 `json:"psn_pay"`
  22436. OpterID string `json:"opter_id"`
  22437. Begndate string `json:"begndate"`
  22438. FlxempeFlag string `json:"flxempe_flag"`
  22439. HifmiPay float64 `json:"hifmi_pay"`
  22440. PsnNo string `json:"psn_no"`
  22441. ActPayDedc float64 `json:"act_pay_dedc"`
  22442. MedinsSetlID interface{} `json:"medins_setl_id"`
  22443. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22444. ClrWay string `json:"clr_way"`
  22445. OthPay float64 `json:"oth_pay"`
  22446. Gend string `json:"gend"`
  22447. MdtrtID string `json:"mdtrt_id"`
  22448. AcctPay float64 `json:"acct_pay"`
  22449. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22450. Insutype string `json:"insutype"`
  22451. Invono interface{} `json:"invono"`
  22452. Enddate string `json:"enddate"`
  22453. CashPayamt float64 `json:"cash_payamt"`
  22454. PsnType string `json:"psn_type"`
  22455. FixmedinsName string `json:"fixmedins_name"`
  22456. HifpPay float64 `json:"hifp_pay"`
  22457. NewFlag interface{} `json:"new_flag"`
  22458. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22459. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22460. PayLoc string `json:"pay_loc"`
  22461. ClrType string `json:"clr_type"`
  22462. RefdSetlFlag string `json:"refd_setl_flag"`
  22463. CvlservFlag string `json:"cvlserv_flag"`
  22464. EmpName string `json:"emp_name"`
  22465. Brdy string `json:"brdy"`
  22466. Naty string `json:"naty"`
  22467. Certno string `json:"certno"`
  22468. DiseCode string `json:"dise_code"`
  22469. FixmedinsCode string `json:"fixmedins_code"`
  22470. DedcHospLv string `json:"dedc_hosp_lv"`
  22471. OpterName string `json:"opter_name"`
  22472. Balc float64 `json:"balc"`
  22473. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22474. PsnCertType string `json:"psn_cert_type"`
  22475. HifobPay float64 `json:"hifob_pay"`
  22476. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22477. HifesPay float64 `json:"hifes_pay"`
  22478. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22479. OptTime string `json:"opt_time"`
  22480. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22481. SetlID string `json:"setl_id"`
  22482. MafPay float64 `json:"maf_pay"`
  22483. PsnName string `json:"psn_name"`
  22484. InsuOptins interface{} `json:"insu_optins"`
  22485. PrefFundPay interface{} `json:"pref_fund_pay"`
  22486. ClrOptins string `json:"clr_optins"`
  22487. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22488. DiseName string `json:"dise_name"`
  22489. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22490. Age float64 `json:"age"`
  22491. DtrtCertType string `json:"dtrt_cert_type"`
  22492. HospLv string `json:"hosp_lv"`
  22493. PsnCashPay float64 `json:"psn_cash_pay"`
  22494. } `json:"setlinfo"`
  22495. } `json:"output"`
  22496. RefmsgTime string `json:"refmsg_time"`
  22497. RespondTime string `json:"respond_time"`
  22498. Signtype interface{} `json:"signtype"`
  22499. WarnMsg interface{} `json:"warn_msg"`
  22500. }
  22501. type ResultTwelve struct {
  22502. Cainfo string `json:"cainfo"`
  22503. ErrMsg string `json:"err_msg"`
  22504. InfRefmsgid string `json:"inf_refmsgid"`
  22505. Infcode int64 `json:"infcode"`
  22506. Output struct {
  22507. MdtrtId string `json:"mdtrt_id"`
  22508. ChrgBchno string `json:"chrg_bchno"`
  22509. PsnNo string `json:"psn_no"`
  22510. } `json:"output"`
  22511. RefmsgTime string `json:"refmsg_time"`
  22512. RespondTime string `json:"respond_time"`
  22513. Signtype interface{} `json:"signtype"`
  22514. WarnMsg interface{} `json:"warn_msg"`
  22515. }
  22516. type ResultThirteen struct {
  22517. ErrMsg string `json:"err_msg"`
  22518. InfRefmsgid string `json:"inf_refmsgid"`
  22519. Infcode int64 `json:"infcode"`
  22520. Output struct {
  22521. Result struct {
  22522. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22523. } `json:"result"`
  22524. } `json:"output"`
  22525. RefmsgTime string `json:"refmsg_time"`
  22526. RespondTime string `json:"respond_time"`
  22527. Signtype interface{} `json:"signtype"`
  22528. WarnInfo interface{} `json:"warn_info"`
  22529. }
  22530. type ResultThirteen10265 struct {
  22531. ErrMsg string `json:"err_msg"`
  22532. InfRefmsgid string `json:"inf_refmsgid"`
  22533. Infcode string `json:"infcode"`
  22534. Output struct {
  22535. Result struct {
  22536. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22537. } `json:"result"`
  22538. } `json:"output"`
  22539. RefmsgTime string `json:"refmsg_time"`
  22540. RespondTime string `json:"respond_time"`
  22541. Signtype interface{} `json:"signtype"`
  22542. WarnInfo interface{} `json:"warn_info"`
  22543. }
  22544. type ResultFourteen struct {
  22545. ErrMsg string `json:"err_msg"`
  22546. InfRefmsgid string `json:"inf_refmsgid"`
  22547. Infcode int64 `json:"infcode"`
  22548. Output struct {
  22549. } `json:"output"`
  22550. RefmsgTime string `json:"refmsg_time"`
  22551. RespondTime string `json:"respond_time"`
  22552. Signtype interface{} `json:"signtype"`
  22553. WarnInfo interface{} `json:"warn_info"`
  22554. }
  22555. type ResultCFYLJG001 struct {
  22556. ErrMsg string `json:"err_msg"`
  22557. InfRefmsgid string `json:"inf_refmsgid"`
  22558. Infcode int64 `json:"infcode"`
  22559. Output struct {
  22560. RxTraceCode string `json:"rx_trace_code"`
  22561. HiRxno string `json:"hi_rxno"`
  22562. } `json:"output"`
  22563. RefmsgTime string `json:"refmsg_time"`
  22564. RespondTime string `json:"respond_time"`
  22565. Signtype interface{} `json:"signtype"`
  22566. WarnInfo interface{} `json:"warn_info"`
  22567. }
  22568. type ResultCFYLJG007 struct {
  22569. ErrMsg string `json:"err_msg"`
  22570. InfRefmsgid string `json:"inf_refmsgid"`
  22571. Infcode int64 `json:"infcode"`
  22572. Output struct {
  22573. HiRxno string `json:"hi_rxno"`
  22574. RxStasName string `json:"rx_stas_name"`
  22575. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22576. Seltdelts []interface{} `json:"seltdelts"`
  22577. RxUsedStasName string `json:"rx_used_stas_name"`
  22578. RxStasCodg string `json:"rx_stas_codg"`
  22579. } `json:"output"`
  22580. RefmsgTime string `json:"refmsg_time"`
  22581. RespondTime string `json:"respond_time"`
  22582. Signtype interface{} `json:"signtype"`
  22583. WarnInfo interface{} `json:"warn_info"`
  22584. }
  22585. type ResultCFYLJG002 struct {
  22586. ErrMsg string `json:"err_msg"`
  22587. InfRefmsgid string `json:"inf_refmsgid"`
  22588. Infcode int64 `json:"infcode"`
  22589. Output struct {
  22590. RxFile string `json:"rx_file"`
  22591. SignDigest string `json:"sign_digest"`
  22592. SignCertSn string `json:"sign_cert_sn"`
  22593. SignCertDn string `json:"sign_cert_dn"`
  22594. } `json:"output"`
  22595. RefmsgTime string `json:"refmsg_time"`
  22596. RespondTime string `json:"respond_time"`
  22597. Signtype interface{} `json:"signtype"`
  22598. WarnInfo interface{} `json:"warn_info"`
  22599. }
  22600. type ResultCFYLJG003 struct {
  22601. ErrMsg string `json:"err_msg"`
  22602. InfRefmsgid string `json:"inf_refmsgid"`
  22603. Infcode int64 `json:"infcode"`
  22604. Output struct {
  22605. HiRxno string `json:"hi_rxno"`
  22606. RxStasCodg string `json:"rx_stas_codg"`
  22607. RxStasName string `json:"rx_stas_name"`
  22608. } `json:"output"`
  22609. RefmsgTime string `json:"refmsg_time"`
  22610. RespondTime string `json:"respond_time"`
  22611. Signtype interface{} `json:"signtype"`
  22612. WarnInfo interface{} `json:"warn_info"`
  22613. }
  22614. type ResultCFYLJG004 struct {
  22615. ErrMsg string `json:"err_msg"`
  22616. InfRefmsgid string `json:"inf_refmsgid"`
  22617. Infcode int64 `json:"infcode"`
  22618. Output struct {
  22619. HiRxno string `json:"hi_rxno"`
  22620. RxStasCodg string `json:"rx_stas_codg"`
  22621. RxStasName string `json:"rx_stas_name"`
  22622. } `json:"output"`
  22623. RefmsgTime string `json:"refmsg_time"`
  22624. RespondTime string `json:"respond_time"`
  22625. Signtype interface{} `json:"signtype"`
  22626. WarnInfo interface{} `json:"warn_info"`
  22627. }
  22628. type ResultCFYLJG008 struct {
  22629. ErrMsg string `json:"err_msg"`
  22630. InfRefmsgid string `json:"inf_refmsgid"`
  22631. Infcode int64 `json:"infcode"`
  22632. Output struct {
  22633. PoolareaNo string `json:"poolareaNo"`
  22634. AdmdvsName string `json:"admdvsName"`
  22635. Count string `json:"count"`
  22636. } `json:"output"`
  22637. RefmsgTime string `json:"refmsg_time"`
  22638. RespondTime string `json:"respond_time"`
  22639. Signtype interface{} `json:"signtype"`
  22640. WarnInfo interface{} `json:"warn_info"`
  22641. }
  22642. type ResultCFYLJG005 struct {
  22643. ErrMsg string `json:"err_msg"`
  22644. InfRefmsgid string `json:"inf_refmsgid"`
  22645. Infcode int64 `json:"infcode"`
  22646. Output struct {
  22647. HiRxNo string `json:"hi_rxno"`
  22648. FixMedinsCode string `json:"fixmedins_code"`
  22649. FixMedinsName string `json:"fixmedins_name"`
  22650. RxStasCodg string `json:"rx_stas_codg"`
  22651. RxStasName string `json:"rx_stas_name"`
  22652. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22653. RxUserdStasName string `json:"rx_userd_stas_name"`
  22654. PrscTime string `json:"prsc_time"`
  22655. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22656. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22657. RxUsedWayName string `json:"rx_used_way_name"`
  22658. RxFrquCodg string `json:"rx_frqu_codg"`
  22659. RxFrquName string `json:"rx_frqu_name"`
  22660. RxDosunt string `json:"rx_dosunt"`
  22661. RxDoscnt float64 `json:"rx_doscnt"`
  22662. RxDrordDscr string `json:"rx_drord_dscr"`
  22663. ValiDays int64 `json:"vali_days"`
  22664. ValiEndTime string `json:"vali_end_time"`
  22665. ReptFlag string `json:"rept_flag"`
  22666. MaxReptCnt int64 `json:"max_rept_cnt"`
  22667. ReptdCnt int64 `json:"reptd_cnt"`
  22668. MinInrvDays int64 `json:"min_inrv_days"`
  22669. RxTypeCode string `json:"rx_type_code"`
  22670. RxTypeName string `json:"rx_type_name"`
  22671. LongRxFlag string `json:"long_rx_flag"`
  22672. RxDetlList []struct {
  22673. MedListCodg string `json:"med_list_codg"`
  22674. MedinsListCodg string `json:"medins_list_codg"`
  22675. HospPrepFlag string `json:"hosp_prep_flag"`
  22676. RxItemTypeCode string `json:"rx_item_type_code"`
  22677. RxItemTypeName string `json:"rx_item_type_name"`
  22678. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22679. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22680. TcmHerbFoote string `json:"tcmherb_foote"`
  22681. MednTypeCode string `json:"medn_type_code"`
  22682. MednTypeName string `json:"medn_type_name"`
  22683. MainMedcFlag string `json:"main_medc_flag"`
  22684. UrgtFlag string `json:"urgt_flag"`
  22685. BasMednFlag string `json:"bas_medn_flag"`
  22686. ImpDrugFlag string `json:"imp_drug_flag"`
  22687. ProdBarc string `json:"prod_barc"`
  22688. DrugProdname string `json:"drug_prodname"`
  22689. GennameCodg string `json:"genname_codg"`
  22690. DrugGenname string `json:"drug_genname"`
  22691. DrugDosform string `json:"drug_dosform"`
  22692. DrugSpec string `json:"drug_spec"`
  22693. PrdrName string `json:"prdr_name"`
  22694. MedcWayCodg string `json:"medc_way_codg"`
  22695. MedcWayDscr string `json:"medc_way_dscr"`
  22696. MedcBegntime string `json:"medc_begntime"`
  22697. MedcEndtime string `json:"medc_endtime"`
  22698. MedcDays float64 `json:"medc_days"`
  22699. DrugPric float64 `json:"drug_pric"`
  22700. DrugSumamt float64 `json:"drug_sumamt"`
  22701. DrugCnt float64 `json:"drug_cnt"`
  22702. DrugDosunt string `json:"drug_dosunt"`
  22703. SinDoscnt float64 `json:"sin_doscnt"`
  22704. SinDosunt string `json:"sin_dosunt"`
  22705. UsedFrquCodg string `json:"used_frqu_codg"`
  22706. UsedFrquName string `json:"used_frqu_name"`
  22707. DrugTotlcnt string `json:"drug_totlcnt"`
  22708. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22709. DiseCodg string `json:"dise_codg"`
  22710. HospApprFlag string `json:"hosp_appr_flag"`
  22711. } `json:"rx_detl_list"`
  22712. RxOtpinfo struct {
  22713. MedType string `json:"med_type"`
  22714. IptOtpNo string `json:"ipt_otp_no"`
  22715. OtpIptFlag string `json:"otp_ipt_flag"`
  22716. PatnName string `json:"patn_name"`
  22717. PatnAge float64 `json:"patn_age"`
  22718. PatnHgt float64 `json:"patn_hgt"`
  22719. PatnWt float64 `json:"patn_wt"`
  22720. Gend string `json:"gend"`
  22721. GesoVal float64 `json:"geso_val"`
  22722. NwbFlag string `json:"nwb_flag"`
  22723. NwbAge string `json:"nwb_age"`
  22724. SuckPrdFlag string `json:"suck_prd_flag"`
  22725. AlgsHis string `json:"algs_his"`
  22726. Insutype string `json:"insutype"`
  22727. PrscDeptName string `json:"prsc_dept_name"`
  22728. PrscDrName string `json:"prsc_dr_name"`
  22729. PharName string `json:"phar_name"`
  22730. PharChkTime string `json:"phar_chk_time"`
  22731. MdtrtTime string `json:"mdtrt_time"`
  22732. DiseCodg string `json:"dise_codg"`
  22733. DiseName string `json:"dise_name"`
  22734. SpDiseFlag string `json:"sp_dise_flag"`
  22735. MaindiagCode string `json:"maindiag_code"`
  22736. MaindiagName string `json:"maindiag_name"`
  22737. DiseCondDscr string `json:"dise_cond_dscr"`
  22738. FstdiagFlag string `json:"fstdiag_flag"`
  22739. } `json:"rx_otpinfo"`
  22740. RxDiseList []struct {
  22741. DiagType string `json:"diag_type"`
  22742. MaindiagFlag string `json:"maindiag_flag"`
  22743. DiagSrtNo string `json:"diag_srt_no"`
  22744. DiagCode string `json:"diag_code"`
  22745. DiagName string `json:"diag_name"`
  22746. DiagDept string `json:"diag_dept"`
  22747. DiagDrNo string `json:"diag_dr_no"`
  22748. DiagDrName string `json:"diag_dr_name"`
  22749. DiagTime string `json:"diag_time"`
  22750. TcmDiseCode string `json:"tcm_dise_code"`
  22751. TcmDiseName string `json:"tcm_dise_name"`
  22752. TcmSympCode string `json:"tcmsymp_code"`
  22753. TcmSymp string `json:"tcmsymp"`
  22754. } `json:"rx_dise_list"`
  22755. } `json:"output"`
  22756. RefmsgTime string `json:"refmsg_time"`
  22757. RespondTime string `json:"respond_time"`
  22758. Signtype interface{} `json:"signtype"`
  22759. WarnInfo interface{} `json:"warn_info"`
  22760. }
  22761. type ResultCFYLJG006 struct {
  22762. ErrMsg string `json:"err_msg"`
  22763. InfRefmsgid string `json:"inf_refmsgid"`
  22764. Infcode int64 `json:"infcode"`
  22765. Output struct {
  22766. HiRxNo string `json:"hi_rxno"`
  22767. PharCode string `json:"phar_code"`
  22768. PharName string `json:"phar_name"`
  22769. RxChkOpnn string `json:"rx_chk_opnn"`
  22770. RxChkTime string `json:"rx_chk_time"`
  22771. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22772. RxChkStasName string `json:"rx_chk_stas_name"`
  22773. RxStasCodg string `json:"rx_stas_codg"`
  22774. RxStasName string `json:"rx_stas_name"`
  22775. } `json:"output"`
  22776. RefmsgTime string `json:"refmsg_time"`
  22777. RespondTime string `json:"respond_time"`
  22778. Signtype interface{} `json:"signtype"`
  22779. WarnInfo interface{} `json:"warn_info"`
  22780. }
  22781. type ResultFourteen10265 struct {
  22782. ErrMsg string `json:"err_msg"`
  22783. InfRefmsgid string `json:"inf_refmsgid"`
  22784. Infcode string `json:"infcode"`
  22785. Output struct {
  22786. } `json:"output"`
  22787. RefmsgTime string `json:"refmsg_time"`
  22788. RespondTime string `json:"respond_time"`
  22789. Signtype interface{} `json:"signtype"`
  22790. WarnInfo interface{} `json:"warn_info"`
  22791. }
  22792. type ResultSixteen struct {
  22793. Cainfo string `json:"cainfo"`
  22794. ErrMsg string `json:"err_msg"`
  22795. InfRefmsgid string `json:"inf_refmsgid"`
  22796. Infcode int64 `json:"infcode"`
  22797. Output struct {
  22798. Setlinfo struct {
  22799. MdtrtID string `json:"mdtrt_id"`
  22800. SetlID string `json:"setl_id"`
  22801. ClrOptins string `json:"clr_optins"`
  22802. SetlTime string `json:"setl_time"`
  22803. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22804. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22805. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22806. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22807. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22808. ActPayDedc float64 `json:"act_pay_dedc"`
  22809. HifpPay float64 `json:"hifp_pay"`
  22810. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22811. Lfpay float64 `json:"selfpay"`
  22812. CvlservPay float64 `json:"cvlserv_pay"`
  22813. HifesPay float64 `json:"hifes_pay"`
  22814. HifmiPay float64 `json:"hifmi_pay"`
  22815. HifobPay float64 `json:"hifob_pay"`
  22816. MafPay float64 `json:"maf_pay"`
  22817. OthPay float64 `json:"oth_pay"`
  22818. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22819. PsnPartAmt float64 `json:"psn_part_amt"`
  22820. AcctPay float64 `json:"acct_pay"`
  22821. Balc float64 `json:"balc"`
  22822. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22823. HospPartAmt float64 `json:"hosp_part_amt"`
  22824. MedinsSetlID string `json:"medins_setl_id"`
  22825. PdnCashPay string `json:"pdn_cash_pay"`
  22826. } `json:"setlinfo"`
  22827. } `json:"output"`
  22828. RefmsgTime string `json:"refmsg_time"`
  22829. RespondTime string `json:"respond_time"`
  22830. Signtype interface{} `json:"signtype"`
  22831. WarnMsg interface{} `json:"warn_msg"`
  22832. }
  22833. type ResultSixteen10265 struct {
  22834. Cainfo string `json:"cainfo"`
  22835. ErrMsg string `json:"err_msg"`
  22836. InfRefmsgid string `json:"inf_refmsgid"`
  22837. Infcode string `json:"infcode"`
  22838. Output struct {
  22839. Setlinfo struct {
  22840. MdtrtID string `json:"mdtrt_id"`
  22841. SetlID string `json:"setl_id"`
  22842. ClrOptins string `json:"clr_optins"`
  22843. SetlTime string `json:"setl_time"`
  22844. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22845. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22846. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22847. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22848. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22849. ActPayDedc float64 `json:"act_pay_dedc"`
  22850. HifpPay float64 `json:"hifp_pay"`
  22851. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22852. Lfpay float64 `json:"selfpay"`
  22853. CvlservPay float64 `json:"cvlserv_pay"`
  22854. HifesPay float64 `json:"hifes_pay"`
  22855. HifmiPay float64 `json:"hifmi_pay"`
  22856. HifobPay float64 `json:"hifob_pay"`
  22857. MafPay float64 `json:"maf_pay"`
  22858. OthPay float64 `json:"oth_pay"`
  22859. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22860. PsnPartAmt float64 `json:"psn_part_amt"`
  22861. AcctPay float64 `json:"acct_pay"`
  22862. Balc float64 `json:"balc"`
  22863. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22864. HospPartAmt float64 `json:"hosp_part_amt"`
  22865. MedinsSetlID string `json:"medins_setl_id"`
  22866. PdnCashPay string `json:"pdn_cash_pay"`
  22867. } `json:"setlinfo"`
  22868. } `json:"output"`
  22869. RefmsgTime string `json:"refmsg_time"`
  22870. RespondTime string `json:"respond_time"`
  22871. Signtype interface{} `json:"signtype"`
  22872. WarnMsg interface{} `json:"warn_msg"`
  22873. }
  22874. type ResultSixteen10265Two struct {
  22875. Cainfo string `json:"cainfo"`
  22876. ErrMsg string `json:"err_msg"`
  22877. InfRefmsgid string `json:"inf_refmsgid"`
  22878. Infcode string `json:"infcode"`
  22879. Output struct {
  22880. Setlinfo interface{} `json:"setlinfo"`
  22881. } `json:"output"`
  22882. RefmsgTime string `json:"refmsg_time"`
  22883. RespondTime string `json:"respond_time"`
  22884. Signtype interface{} `json:"signtype"`
  22885. WarnMsg interface{} `json:"warn_msg"`
  22886. }
  22887. type ResultgzSixteen10265Two struct {
  22888. Cainfo string `json:"cainfo"`
  22889. ErrMsg string `json:"err_msg"`
  22890. InfRefmsgid string `json:"inf_refmsgid"`
  22891. Infcode int64 `json:"infcode"`
  22892. Output struct {
  22893. Setlinfo interface{} `json:"setlinfo"`
  22894. } `json:"output"`
  22895. RefmsgTime string `json:"refmsg_time"`
  22896. RespondTime string `json:"respond_time"`
  22897. Signtype interface{} `json:"signtype"`
  22898. WarnMsg interface{} `json:"warn_msg"`
  22899. }
  22900. type ResultSeventeen struct {
  22901. ErrMsg string `json:"err_msg"`
  22902. InfRefmsgid string `json:"inf_refmsgid"`
  22903. Infcode int64 `json:"infcode"`
  22904. Output struct {
  22905. SetlListId string `json:"setl_list_id"`
  22906. } `json:"output"`
  22907. RefmsgTime string `json:"refmsg_time"`
  22908. RespondTime string `json:"respond_time"`
  22909. Signtype string `json:"signtype"`
  22910. WarnInfo string `json:"warn_info"`
  22911. }
  22912. type ResultSeventeenOther struct {
  22913. ErrMsg string `json:"err_msg"`
  22914. InfRefmsgid string `json:"inf_refmsgid"`
  22915. Infcode string `json:"infcode"`
  22916. Output struct {
  22917. SetlListId string `json:"setl_list_id"`
  22918. } `json:"output"`
  22919. RefmsgTime string `json:"refmsg_time"`
  22920. RespondTime string `json:"respond_time"`
  22921. Signtype string `json:"signtype"`
  22922. WarnInfo string `json:"warn_info"`
  22923. }
  22924. type Result90991 struct {
  22925. ErrMsg string `json:"err_msg"`
  22926. InfRefmsgid string `json:"inf_refmsgid"`
  22927. Infcode int64 `json:"infcode"`
  22928. Output struct {
  22929. Result struct {
  22930. PsnNo string `json:"psn_no"`
  22931. CardStat string `json:"card_stat"`
  22932. Certno string `json:"certno"`
  22933. PsnName string `json:"psn_name"`
  22934. CheckStat string `json:"check_stat"`
  22935. SscnoCheckStat string `json:"sscno_check_stat"`
  22936. } `json:"result"`
  22937. } `json:"output"`
  22938. RefmsgTime string `json:"refmsg_time"`
  22939. RespondTime string `json:"respond_time"`
  22940. Signtype interface{} `json:"signtype"`
  22941. WarnInfo interface{} `json:"warn_info"`
  22942. }
  22943. type Result90100 struct {
  22944. ErrMsg string `json:"err_msg"`
  22945. InfRefmsgid string `json:"inf_refmsgid"`
  22946. Infcode int64 `json:"infcode"`
  22947. Output struct {
  22948. PoolareaNo string `json:"poolarea_no"`
  22949. PoolareaNoName string `json:"poolarea_no_name"`
  22950. Insutype string `json:"insutype"`
  22951. InsutypeName string `json:"insutype_name"`
  22952. ClctType string `json:"clct_type"`
  22953. ClctTypeName string `json:"clct_type_name"`
  22954. ClctFlag string `json:"clct_flag"`
  22955. ClctFlagName string `json:"clct_flag_name"`
  22956. AccrymBegn string `json:"accrym_begn"`
  22957. AccrymEnd string `json:"accrym_end"`
  22958. ClctTime string `json:"clct_time"`
  22959. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  22960. } `json:"output"`
  22961. RefmsgTime string `json:"refmsg_time"`
  22962. RespondTime string `json:"respond_time"`
  22963. Signtype interface{} `json:"signtype"`
  22964. WarnInfo interface{} `json:"warn_info"`
  22965. }
  22966. type Custom struct {
  22967. DetItemFeeSumamt string
  22968. Cut string
  22969. FeedetlSn string
  22970. Price string
  22971. MedListCodg string
  22972. Type int64
  22973. AdviceId int64
  22974. ProjectId int64
  22975. ItemId int64
  22976. }
  22977. type Result5301 struct {
  22978. ErrMsg string `json:"err_msg"`
  22979. InfRefmsgid string `json:"inf_refmsgid"`
  22980. Infcode int64 `json:"infcode"`
  22981. Output struct {
  22982. Result []struct {
  22983. OpspDiseCode string `json:"opsp_dise_code"`
  22984. OpspDiseName string `json:"opsp_dise_name"`
  22985. Begndate string `json:"begndate"`
  22986. Enddate string `json:"enddate"`
  22987. } `json:"feedetail"`
  22988. } `json:"output"`
  22989. RefmsgTime string `json:"refmsg_time"`
  22990. RespondTime string `json:"respond_time"`
  22991. Signtype interface{} `json:"signtype"`
  22992. WarnInfo interface{} `json:"warn_info"`
  22993. }
  22994. type Result5301For10265 struct {
  22995. ErrMsg string `json:"err_msg"`
  22996. InfRefmsgid string `json:"inf_refmsgid"`
  22997. Infcode string `json:"infcode"`
  22998. Output struct {
  22999. Result []struct {
  23000. OpspDiseCode string `json:"opsp_dise_code"`
  23001. OpspDiseName string `json:"opsp_dise_name"`
  23002. Begndate string `json:"begndate"`
  23003. Enddate string `json:"enddate"`
  23004. } `json:"feedetail"`
  23005. } `json:"output"`
  23006. RefmsgTime string `json:"refmsg_time"`
  23007. RespondTime string `json:"respond_time"`
  23008. Signtype interface{} `json:"signtype"`
  23009. WarnInfo interface{} `json:"warn_info"`
  23010. }
  23011. //获取个人信息----挂号-----上传就诊信息
  23012. func (c *HisApiController) GetRegisterInfo() {
  23013. id, _ := c.GetInt64("id")
  23014. record_time := c.GetString("record_time")
  23015. settlementValue, _ := c.GetInt64("settlement_value")
  23016. medical_insurance_card := c.GetString("medical_insurance_card")
  23017. name := c.GetString("name")
  23018. id_card_type, _ := c.GetInt64("id_card_type")
  23019. certificates, _ := c.GetInt64("certificates")
  23020. medical_care, _ := c.GetInt64("medical_care")
  23021. birthday := c.GetString("birthday")
  23022. id_card := c.GetString("id_card")
  23023. register_type, _ := c.GetInt64("register")
  23024. doctor, _ := c.GetInt64("doctor")
  23025. department, _ := c.GetInt64("department")
  23026. gender, _ := c.GetInt64("sex")
  23027. registration_fee, _ := c.GetFloat("registration_fee")
  23028. medical_expenses, _ := c.GetFloat("medical_expenses")
  23029. social_type, _ := c.GetInt64("social_type")
  23030. admin_user_id, _ := c.GetInt64("admin_user_id")
  23031. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23032. mdtrt_type := c.GetString("mdtrt_type")
  23033. if id_card_type == 5 {
  23034. id_card_type = 4
  23035. }
  23036. timeLayout := "2006-01-02"
  23037. loc, _ := time.LoadLocation("Local")
  23038. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23039. birthUnix := birthdays.Unix()
  23040. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23041. if err != nil {
  23042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23043. return
  23044. }
  23045. recordDateTime := theTime.Unix()
  23046. adminInfo := c.GetAdminUserInfo()
  23047. var patient service.Patients
  23048. if id == 0 {
  23049. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23050. } else {
  23051. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23052. }
  23053. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23054. if patientPrescription.ID == 0 {
  23055. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23056. }
  23057. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23058. if patient.ID == 0 {
  23059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23060. return
  23061. }
  23062. if len(patient.IdCardNo) == 0 {
  23063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23064. return
  23065. }
  23066. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23067. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23068. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23069. //就诊结算未完成,不能进行二次挂号
  23070. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23071. if len(his) >= 1 {
  23072. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23073. if len(his) >= 1 && order.ID == 0 {
  23074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23075. return
  23076. }
  23077. }
  23078. //var register_log string
  23079. if config.IsOpen == 1 {
  23080. var res ResultTwo
  23081. var res10265 ResultTwo10265
  23082. var PsnNo string
  23083. var PsnCertType string
  23084. var Certno string
  23085. var PsnName string
  23086. var Gend string
  23087. var Naty string
  23088. var Brdy string
  23089. var Age float64
  23090. var infoStr string
  23091. var idetinfoStr string
  23092. var infocode int64
  23093. var verify_number string
  23094. fmt.Println(verify_number)
  23095. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23096. psn_info, _ := service.GetPsnByPatientId(id)
  23097. PsnNo = psn_info.PsnNo
  23098. PsnCertType = psn_info.PsnCertType
  23099. Certno = psn_info.Certno
  23100. PsnName = psn_info.PsnName
  23101. Gend = psn_info.Gend
  23102. Naty = psn_info.Naty
  23103. Brdy = psn_info.Brdy
  23104. Age = psn_info.Age
  23105. infoStr = psn_info.Insuinfo
  23106. idetinfoStr = psn_info.Idetinfo
  23107. infocode = 0
  23108. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23109. psn_info, _ := service.GetPsnByPatientId(id)
  23110. PsnNo = psn_info.PsnNo
  23111. PsnCertType = psn_info.PsnCertType
  23112. Certno = psn_info.Certno
  23113. PsnName = psn_info.PsnName
  23114. Gend = psn_info.Gend
  23115. Naty = psn_info.Naty
  23116. Brdy = psn_info.Brdy
  23117. Age = psn_info.Age
  23118. infoStr = psn_info.Insuinfo
  23119. idetinfoStr = psn_info.Idetinfo
  23120. infocode = 0
  23121. verify_number = psn_info.VerifyNumber
  23122. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23123. if id_card_type == 2 {
  23124. //请求内网数据
  23125. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23126. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23127. "&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
  23128. resp, requestErr := http.Get(api)
  23129. if requestErr != nil {
  23130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23131. return
  23132. }
  23133. body, ioErr := ioutil.ReadAll(resp.Body)
  23134. if ioErr != nil {
  23135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23137. return
  23138. }
  23139. var respJSON map[string]interface{}
  23140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23143. return
  23144. }
  23145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23146. result_byte, _ := json.Marshal(respJSON)
  23147. result := string(result_byte)
  23148. var dat map[string]interface{}
  23149. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23150. fmt.Println(dat)
  23151. } else {
  23152. fmt.Println(err)
  23153. }
  23154. userJSONBytes, _ := json.Marshal(dat)
  23155. var res ResultTwo
  23156. var resTwo10265 ResultTwo10265
  23157. if miConfig.Code == "H15049901371" {
  23158. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23159. utils.ErrorLog("解析失败:%v", err)
  23160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23161. return
  23162. }
  23163. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23164. res.Infcode = Infcode
  23165. res.ErrMsg = resTwo10265.ErrMsg
  23166. res.Output = resTwo10265.Output
  23167. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23168. res.RespondTime = resTwo10265.RespondTime
  23169. res.WarnInfo = resTwo10265.WarnInfo
  23170. } else {
  23171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23172. utils.ErrorLog("解析失败:%v", err)
  23173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23174. return
  23175. }
  23176. }
  23177. //var insutypes []string
  23178. //var insutype string
  23179. //var is390 int = 0
  23180. //var is310 int = 0
  23181. //for _, item := range res.Output.Iinfo {
  23182. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23183. // insutypes = append(insutypes, item.Insutype)
  23184. // }
  23185. //}
  23186. //if len(insutypes) == 1 {
  23187. // insutype = insutypes[0]
  23188. //} else {
  23189. // for _, i := range insutypes {
  23190. // if i == "390" {
  23191. // is390 = 1
  23192. // }
  23193. //
  23194. // if i == "310" {
  23195. // is310 = 1
  23196. // }
  23197. // }
  23198. //}
  23199. //if is390 == 1 {
  23200. // insutype = "390"
  23201. //}
  23202. //if is310 == 1 {
  23203. // insutype = "310"
  23204. //}
  23205. //if len(insutypes) == 0 {
  23206. // insutype = "310"
  23207. //}
  23208. PsnNo = res.Output.Baseinfo.PsnNo
  23209. PsnCertType = res.Output.Baseinfo.PsnCertType
  23210. Certno = res.Output.Baseinfo.Certno
  23211. PsnName = res.Output.Baseinfo.PsnName
  23212. Gend = res.Output.Baseinfo.Gend
  23213. Naty = res.Output.Baseinfo.Naty
  23214. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23215. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23216. infoStr = string(Iinfos)
  23217. idetinfoStr = string(Idetinfos)
  23218. infocode = res.Infcode
  23219. //infocode = 0
  23220. //verify_number = psn_info.VerifyNumber
  23221. } else {
  23222. psn_info, _ := service.GetPsnByPatientId(id)
  23223. PsnNo = psn_info.PsnNo
  23224. PsnCertType = psn_info.PsnCertType
  23225. Certno = psn_info.Certno
  23226. PsnName = psn_info.PsnName
  23227. Gend = psn_info.Gend
  23228. Naty = psn_info.Naty
  23229. Brdy = psn_info.Brdy
  23230. Age = psn_info.Age
  23231. infoStr = psn_info.Insuinfo
  23232. idetinfoStr = psn_info.Idetinfo
  23233. infocode = 0
  23234. verify_number = psn_info.VerifyNumber
  23235. }
  23236. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23237. if id_card_type == 1 {
  23238. psn_info, _ := service.GetPsnByPatientId(id)
  23239. PsnNo = psn_info.PsnNo
  23240. PsnCertType = psn_info.PsnCertType
  23241. Certno = psn_info.Certno
  23242. PsnName = psn_info.PsnName
  23243. Gend = psn_info.Gend
  23244. Naty = psn_info.Naty
  23245. Brdy = psn_info.Brdy
  23246. Age = psn_info.Age
  23247. infoStr = psn_info.Insuinfo
  23248. idetinfoStr = psn_info.Idetinfo
  23249. infocode = 0
  23250. verify_number = psn_info.VerifyNumber
  23251. } else if id_card_type == 2 {
  23252. 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)
  23253. fmt.Println(errMsgLog)
  23254. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23255. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23256. utils.ErrorLog("解析失败:%v", err)
  23257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23258. return
  23259. }
  23260. PsnNo = res.Output.Baseinfo.PsnNo
  23261. PsnCertType = res.Output.Baseinfo.PsnCertType
  23262. Certno = res.Output.Baseinfo.Certno
  23263. PsnName = res.Output.Baseinfo.PsnName
  23264. Gend = res.Output.Baseinfo.Gend
  23265. Naty = res.Output.Baseinfo.Naty
  23266. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23267. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23268. infoStr = string(Iinfos)
  23269. idetinfoStr = string(Idetinfos)
  23270. infocode = res.Infcode
  23271. }
  23272. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23273. if id_card_type == 1 {
  23274. psn_info, _ := service.GetPsnByPatientId(id)
  23275. PsnNo = psn_info.PsnNo
  23276. PsnCertType = psn_info.PsnCertType
  23277. Certno = psn_info.Certno
  23278. PsnName = psn_info.PsnName
  23279. Gend = psn_info.Gend
  23280. Naty = psn_info.Naty
  23281. Brdy = psn_info.Brdy
  23282. Age = psn_info.Age
  23283. infoStr = psn_info.Insuinfo
  23284. idetinfoStr = psn_info.Idetinfo
  23285. infocode = 0
  23286. verify_number = psn_info.VerifyNumber
  23287. } else if id_card_type == 2 {
  23288. 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, "")
  23289. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23290. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23291. utils.ErrorLog("解析失败:%v", err)
  23292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23293. return
  23294. }
  23295. PsnNo = res.Output.Baseinfo.PsnNo
  23296. PsnCertType = res.Output.Baseinfo.PsnCertType
  23297. Certno = res.Output.Baseinfo.Certno
  23298. PsnName = res.Output.Baseinfo.PsnName
  23299. Gend = res.Output.Baseinfo.Gend
  23300. Naty = res.Output.Baseinfo.Naty
  23301. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23302. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23303. infoStr = string(Iinfos)
  23304. idetinfoStr = string(Idetinfos)
  23305. infocode = res.Infcode
  23306. } else {
  23307. psn_info, _ := service.GetPsnByPatientId(id)
  23308. PsnNo = psn_info.PsnNo
  23309. PsnCertType = psn_info.PsnCertType
  23310. Certno = psn_info.Certno
  23311. PsnName = psn_info.PsnName
  23312. Gend = psn_info.Gend
  23313. Naty = psn_info.Naty
  23314. Brdy = psn_info.Brdy
  23315. Age = psn_info.Age
  23316. infoStr = psn_info.Insuinfo
  23317. idetinfoStr = psn_info.Idetinfo
  23318. infocode = 0
  23319. verify_number = psn_info.VerifyNumber
  23320. }
  23321. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23322. if id_card_type == 1 {
  23323. psn_info, _ := service.GetPsnByPatientId(id)
  23324. PsnNo = psn_info.PsnNo
  23325. PsnCertType = psn_info.PsnCertType
  23326. Certno = psn_info.Certno
  23327. PsnName = psn_info.PsnName
  23328. Gend = psn_info.Gend
  23329. Naty = psn_info.Naty
  23330. Brdy = psn_info.Brdy
  23331. Age = psn_info.Age
  23332. infoStr = psn_info.Insuinfo
  23333. idetinfoStr = psn_info.Idetinfo
  23334. infocode = 0
  23335. verify_number = psn_info.VerifyNumber
  23336. } else if id_card_type == 2 {
  23337. psn_info, _ := service.GetPsnByPatientId(id)
  23338. PsnNo = psn_info.PsnNo
  23339. PsnCertType = psn_info.PsnCertType
  23340. Certno = psn_info.Certno
  23341. PsnName = psn_info.PsnName
  23342. Gend = psn_info.Gend
  23343. Naty = psn_info.Naty
  23344. Brdy = psn_info.Brdy
  23345. Age = psn_info.Age
  23346. infoStr = psn_info.Insuinfo
  23347. idetinfoStr = psn_info.Idetinfo
  23348. infocode = 0
  23349. verify_number = psn_info.VerifyNumber
  23350. } else {
  23351. psn_info, _ := service.GetPsnByPatientId(id)
  23352. PsnNo = psn_info.PsnNo
  23353. PsnCertType = psn_info.PsnCertType
  23354. Certno = psn_info.Certno
  23355. PsnName = psn_info.PsnName
  23356. Gend = psn_info.Gend
  23357. Naty = psn_info.Naty
  23358. Brdy = psn_info.Brdy
  23359. Age = psn_info.Age
  23360. infoStr = psn_info.Insuinfo
  23361. idetinfoStr = psn_info.Idetinfo
  23362. infocode = 0
  23363. verify_number = psn_info.VerifyNumber
  23364. }
  23365. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23366. psn_info, _ := service.GetPsnByPatientId(id)
  23367. PsnNo = psn_info.PsnNo
  23368. PsnCertType = psn_info.PsnCertType
  23369. Certno = psn_info.Certno
  23370. PsnName = psn_info.PsnName
  23371. Gend = psn_info.Gend
  23372. Naty = psn_info.Naty
  23373. Brdy = psn_info.Brdy
  23374. Age = psn_info.Age
  23375. infoStr = psn_info.Insuinfo
  23376. idetinfoStr = psn_info.Idetinfo
  23377. infocode = 0
  23378. verify_number = psn_info.VerifyNumber
  23379. idetinfoStr = psn_info.Idetinfo
  23380. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23381. if id_card_type == 1 {
  23382. psn_info, _ := service.GetPsnByPatientId(id)
  23383. PsnNo = psn_info.PsnNo
  23384. PsnCertType = psn_info.PsnCertType
  23385. Certno = psn_info.Certno
  23386. PsnName = psn_info.PsnName
  23387. Gend = psn_info.Gend
  23388. Naty = psn_info.Naty
  23389. Brdy = psn_info.Brdy
  23390. Age = psn_info.Age
  23391. infoStr = psn_info.Insuinfo
  23392. idetinfoStr = psn_info.Idetinfo
  23393. infocode = 0
  23394. verify_number = psn_info.VerifyNumber
  23395. } else if id_card_type == 2 {
  23396. 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)
  23397. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23398. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23399. utils.ErrorLog("解析失败:%v", err)
  23400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23401. return
  23402. }
  23403. PsnNo = res.Output.Baseinfo.PsnNo
  23404. PsnCertType = res.Output.Baseinfo.PsnCertType
  23405. Certno = res.Output.Baseinfo.Certno
  23406. PsnName = res.Output.Baseinfo.PsnName
  23407. Gend = res.Output.Baseinfo.Gend
  23408. Naty = res.Output.Baseinfo.Naty
  23409. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23410. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23411. infoStr = string(Iinfos)
  23412. idetinfoStr = string(Idetinfos)
  23413. infocode = res.Infcode
  23414. } else if id_card_type == 4 {
  23415. psn_info, _ := service.GetPsnByPatientId(id)
  23416. PsnNo = psn_info.PsnNo
  23417. PsnCertType = psn_info.PsnCertType
  23418. Certno = psn_info.Certno
  23419. PsnName = psn_info.PsnName
  23420. Gend = psn_info.Gend
  23421. Naty = psn_info.Naty
  23422. Brdy = psn_info.Brdy
  23423. Age = psn_info.Age
  23424. infoStr = psn_info.Insuinfo
  23425. idetinfoStr = psn_info.Idetinfo
  23426. infocode = 0
  23427. verify_number = psn_info.VerifyNumber
  23428. }
  23429. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23430. var result string
  23431. var requestLog string
  23432. 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), "")
  23433. if id_card_type == 4 {
  23434. psn_info, _ := service.GetPsnByPatientId(id)
  23435. PsnNo = psn_info.PsnNo
  23436. PsnCertType = psn_info.PsnCertType
  23437. Certno = psn_info.Certno
  23438. PsnName = psn_info.PsnName
  23439. Gend = psn_info.Gend
  23440. Naty = psn_info.Naty
  23441. Brdy = psn_info.Brdy
  23442. Age = psn_info.Age
  23443. infoStr = psn_info.Insuinfo
  23444. idetinfoStr = psn_info.Idetinfo
  23445. infocode = 0
  23446. verify_number = psn_info.VerifyNumber
  23447. } else {
  23448. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23449. if miConfig.Code == "H15049901371" {
  23450. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23451. utils.ErrorLog("解析失败:%v", err)
  23452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23453. return
  23454. }
  23455. res.ErrMsg = res10265.ErrMsg
  23456. res.Output = res10265.Output
  23457. res.InfRefmsgid = res10265.InfRefmsgid
  23458. } else {
  23459. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23460. utils.ErrorLog("解析失败:%v", err)
  23461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23462. return
  23463. }
  23464. }
  23465. PsnNo = res.Output.Baseinfo.PsnNo
  23466. PsnCertType = res.Output.Baseinfo.PsnCertType
  23467. Certno = res.Output.Baseinfo.Certno
  23468. PsnName = res.Output.Baseinfo.PsnName
  23469. Gend = res.Output.Baseinfo.Gend
  23470. Naty = res.Output.Baseinfo.Naty
  23471. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23472. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23473. infoStr = string(Iinfos)
  23474. idetinfoStr = string(Idetinfos)
  23475. if miConfig.Code == "H15049901371" {
  23476. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23477. } else {
  23478. infocode = res.Infcode
  23479. }
  23480. }
  23481. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23482. psn_info, _ := service.GetPsnByPatientId(id)
  23483. PsnNo = psn_info.PsnNo
  23484. PsnCertType = psn_info.PsnCertType
  23485. Certno = psn_info.Certno
  23486. PsnName = psn_info.PsnName
  23487. Gend = psn_info.Gend
  23488. Naty = psn_info.Naty
  23489. Brdy = psn_info.Brdy
  23490. Age = psn_info.Age
  23491. infoStr = psn_info.Insuinfo
  23492. idetinfoStr = psn_info.Idetinfo
  23493. infocode = 0
  23494. verify_number = psn_info.VerifyNumber
  23495. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23496. psn_info, _ := service.GetPsnByPatientId(id)
  23497. PsnNo = psn_info.PsnNo
  23498. PsnCertType = psn_info.PsnCertType
  23499. Certno = psn_info.Certno
  23500. PsnName = psn_info.PsnName
  23501. Gend = psn_info.Gend
  23502. Naty = psn_info.Naty
  23503. Brdy = psn_info.Brdy
  23504. Age = psn_info.Age
  23505. infoStr = psn_info.Insuinfo
  23506. idetinfoStr = psn_info.Idetinfo
  23507. infocode = 0
  23508. verify_number = psn_info.VerifyNumber
  23509. } else {
  23510. var result string
  23511. var requestLog string
  23512. //if miConfig.UserOrgId == 10138 {
  23513. if id_card_type != 4 || id_card_type != 1 {
  23514. var insa string
  23515. if len(patient.InsuplcAdmdvs) > 0 {
  23516. insa = patient.InsuplcAdmdvs
  23517. } else {
  23518. insa = miConfig.InsuplcAdmdvs
  23519. }
  23520. //psn_info, _ := service.GetPsnByPatientId(id)
  23521. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23522. 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)
  23523. }
  23524. //}
  23525. //else {
  23526. // var insa string
  23527. // if len(patient.InsuplcAdmdvs) > 0 {
  23528. // insa = patient.InsuplcAdmdvs
  23529. // } else {
  23530. // insa = miConfig.InsuplcAdmdvs
  23531. // }
  23532. // 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)
  23533. //}
  23534. if id_card_type == 4 || id_card_type == 1 {
  23535. psn_info, _ := service.GetPsnByPatientId(id)
  23536. PsnNo = psn_info.PsnNo
  23537. PsnCertType = psn_info.PsnCertType
  23538. Certno = psn_info.Certno
  23539. PsnName = psn_info.PsnName
  23540. Gend = psn_info.Gend
  23541. Naty = psn_info.Naty
  23542. Brdy = psn_info.Brdy
  23543. Age = psn_info.Age
  23544. infoStr = psn_info.Insuinfo
  23545. idetinfoStr = psn_info.Idetinfo
  23546. infocode = 0
  23547. verify_number = psn_info.VerifyNumber
  23548. } else {
  23549. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23550. if miConfig.Code == "H15049901371" {
  23551. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23552. utils.ErrorLog("解析失败:%v", err)
  23553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23554. return
  23555. }
  23556. res.ErrMsg = res10265.ErrMsg
  23557. res.Output = res10265.Output
  23558. res.InfRefmsgid = res10265.InfRefmsgid
  23559. } else {
  23560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23561. utils.ErrorLog("解析失败:%v", err)
  23562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23563. return
  23564. }
  23565. }
  23566. PsnNo = res.Output.Baseinfo.PsnNo
  23567. PsnCertType = res.Output.Baseinfo.PsnCertType
  23568. Certno = res.Output.Baseinfo.Certno
  23569. PsnName = res.Output.Baseinfo.PsnName
  23570. Gend = res.Output.Baseinfo.Gend
  23571. Naty = res.Output.Baseinfo.Naty
  23572. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23573. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23574. infoStr = string(Iinfos)
  23575. idetinfoStr = string(Idetinfos)
  23576. if miConfig.Code == "H15049901371" {
  23577. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23578. } else {
  23579. infocode = res.Infcode
  23580. }
  23581. }
  23582. }
  23583. if infocode == 0 {
  23584. his := models.VMHisPatient{
  23585. Name: name,
  23586. Gender: gender,
  23587. Birthday: birthUnix,
  23588. MedicalTreatmentType: medical_care,
  23589. IdType: certificates,
  23590. IdCardNo: id_card,
  23591. BalanceAccountsType: settlementValue,
  23592. SocialType: social_type,
  23593. MedicalInsuranceNumber: medical_insurance_card,
  23594. RegisterType: register_type,
  23595. RegisterCost: registration_fee,
  23596. TreatmentCost: medical_expenses,
  23597. Status: 1,
  23598. Ctime: time.Now().Unix(),
  23599. Mtime: time.Now().Unix(),
  23600. PsnNo: PsnNo,
  23601. PsnCertType: PsnCertType,
  23602. Certno: Certno,
  23603. PsnName: PsnName,
  23604. Gend: Gend,
  23605. Naty: Naty,
  23606. Brdy: Brdy,
  23607. Age: Age,
  23608. Iinfo: infoStr,
  23609. Idetinfo: idetinfoStr,
  23610. PatientId: patient.ID,
  23611. RecordDate: theTime.Unix(),
  23612. UserOrgId: adminInfo.CurrentOrgId,
  23613. AdminUserId: admin_user_id,
  23614. IsReturn: 1,
  23615. IdCardType: id_card_type,
  23616. Doctor: doctor,
  23617. Departments: department,
  23618. MdtrtGrpType: mdtrt_type,
  23619. }
  23620. timestamp := time.Now().Unix()
  23621. tempTime := time.Unix(timestamp, 0)
  23622. timeFormat := tempTime.Format("20060102150405")
  23623. chrgBchno := rand.Intn(100000) + 10000
  23624. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23625. his.Number = ipt_otp_no
  23626. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23627. department, _ := service.GetDepartMentDetail(department)
  23628. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23629. IdCardNo := ""
  23630. if id_card_type == 1 {
  23631. // IdCardNo = medical_insurance_card
  23632. IdCardNo = patient.IdCardNo
  23633. } else {
  23634. IdCardNo = patient.IdCardNo
  23635. }
  23636. var rf []*ResultFive
  23637. json.Unmarshal([]byte(his.Iinfo), &rf)
  23638. var insutypes []*ResultFive
  23639. var insutype string
  23640. var insuplc_admdvs_temp string
  23641. var is390 int = 0
  23642. var is310 int = 0
  23643. for _, item := range rf {
  23644. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23645. insutypes = append(insutypes, item)
  23646. }
  23647. }
  23648. if len(insutypes) == 1 {
  23649. insutype = insutypes[0].Insutype
  23650. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23651. if insutype == "390" {
  23652. is390 = 1
  23653. }
  23654. if insutype == "310" {
  23655. is310 = 1
  23656. }
  23657. } else {
  23658. for _, i := range insutypes {
  23659. if i.Insutype == "390" {
  23660. is390 = 1
  23661. }
  23662. if i.Insutype == "310" {
  23663. is310 = 1
  23664. }
  23665. }
  23666. }
  23667. if is390 == 1 {
  23668. insutype = "390"
  23669. }
  23670. if is310 == 1 {
  23671. insutype = "310"
  23672. }
  23673. fmt.Println(social_type)
  23674. if social_type > 0 {
  23675. insutype = strconv.FormatInt(social_type, 10)
  23676. }
  23677. var infocode int64
  23678. var resThree ResultThree
  23679. var resThree10265 ResultThree10265
  23680. if len(insuplc_admdvs) == 0 {
  23681. psn_info, _ := service.GetPsnByPatientId(id)
  23682. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23683. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23684. //}
  23685. } else {
  23686. insuplc_admdvs_temp = insuplc_admdvs
  23687. }
  23688. if miConfig.MdtrtareaAdmvs == "421300" {
  23689. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23690. psn_info, _ := service.GetPsnByPatientId(id)
  23691. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23692. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23693. "&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
  23694. resp, requestErr := http.Get(api)
  23695. if requestErr != nil {
  23696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23697. return
  23698. }
  23699. body, ioErr := ioutil.ReadAll(resp.Body)
  23700. if ioErr != nil {
  23701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23703. return
  23704. }
  23705. var respJSON map[string]interface{}
  23706. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23709. return
  23710. }
  23711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23712. result, _ := json.Marshal(respJSON)
  23713. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23714. utils.ErrorLog("解析失败:%v", err)
  23715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23716. return
  23717. }
  23718. infocode = resThree.Infcode
  23719. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23720. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23721. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23722. // insuplc_admdvs_temp =
  23723. //}
  23724. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23725. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23726. //}
  23727. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23728. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23729. "&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
  23730. resp, requestErr := http.Get(api)
  23731. if requestErr != nil {
  23732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23733. return
  23734. }
  23735. body, ioErr := ioutil.ReadAll(resp.Body)
  23736. if ioErr != nil {
  23737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23739. return
  23740. }
  23741. var respJSON map[string]interface{}
  23742. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23745. return
  23746. }
  23747. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23748. result, _ := json.Marshal(respJSON)
  23749. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23750. utils.ErrorLog("解析失败:%v", err)
  23751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23752. return
  23753. }
  23754. infocode = resThree.Infcode
  23755. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23756. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23757. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23758. // insuplc_admdvs_temp =
  23759. //}
  23760. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23761. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23762. //}
  23763. utils.ErrorLog("解析失败:%v", insutype)
  23764. utils.ErrorLog("解析失败:%v", PsnNo)
  23765. utils.ErrorLog("解析失败:%v", Certno)
  23766. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23767. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23768. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23769. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23770. utils.ErrorLog("解析失败:%v", PsnNo)
  23771. utils.ErrorLog("解析失败:%v", department.Number)
  23772. utils.ErrorLog("解析失败:%v", department.Name)
  23773. utils.ErrorLog("解析失败:%v", roles.UserName)
  23774. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23775. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23776. "&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
  23777. resp, requestErr := http.Get(api)
  23778. if requestErr != nil {
  23779. utils.ErrorLog("解析失败:%v", requestErr)
  23780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23781. return
  23782. }
  23783. body, ioErr := ioutil.ReadAll(resp.Body)
  23784. if ioErr != nil {
  23785. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23787. return
  23788. }
  23789. var respJSON map[string]interface{}
  23790. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23793. return
  23794. }
  23795. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23796. result, _ := json.Marshal(respJSON)
  23797. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23798. utils.ErrorLog("解析失败:%v", err)
  23799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23800. return
  23801. }
  23802. infocode = resThree.Infcode
  23803. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23804. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23805. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23806. // insuplc_admdvs_temp =
  23807. //}
  23808. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23809. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23810. //}
  23811. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23812. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23813. "&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
  23814. resp, requestErr := http.Get(api)
  23815. if requestErr != nil {
  23816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23817. return
  23818. }
  23819. body, ioErr := ioutil.ReadAll(resp.Body)
  23820. if ioErr != nil {
  23821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23823. return
  23824. }
  23825. var respJSON map[string]interface{}
  23826. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23829. return
  23830. }
  23831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23832. result, _ := json.Marshal(respJSON)
  23833. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23834. utils.ErrorLog("解析失败:%v", err)
  23835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23836. return
  23837. }
  23838. infocode = resThree.Infcode
  23839. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23840. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23841. psn_info, _ := service.GetPsnByPatientId(id)
  23842. var verify_number string
  23843. if id_card_type == 4 {
  23844. verify_number = psn_info.VerifyNumber
  23845. } else if id_card_type == 1 {
  23846. bas := strings.Split(psn_info.CardInfo, "|")
  23847. cardNumber := bas[2]
  23848. verify_number = cardNumber
  23849. }
  23850. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23851. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23852. "&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
  23853. resp, requestErr := http.Get(api)
  23854. if requestErr != nil {
  23855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23856. return
  23857. }
  23858. body, ioErr := ioutil.ReadAll(resp.Body)
  23859. if ioErr != nil {
  23860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23862. return
  23863. }
  23864. var respJSON map[string]interface{}
  23865. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23868. return
  23869. }
  23870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23871. result, _ := json.Marshal(respJSON)
  23872. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23873. // utils.ErrorLog("解析失败:%v", err)
  23874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23875. // return
  23876. //}
  23877. //infocode = resThree.Infcode
  23878. //result, _ := json.Marshal(respJSON)
  23879. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23880. utils.ErrorLog("解析失败:%v", err)
  23881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23882. return
  23883. }
  23884. resThree.ErrMsg = resThree10265.ErrMsg
  23885. resThree.Output = resThree10265.Output
  23886. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23887. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23888. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23889. psn_info, _ := service.GetPsnByPatientId(id)
  23890. his.PsnNo = psn_info.PsnNo
  23891. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23892. var cert_no string
  23893. if id_card_type == 3 {
  23894. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  23895. cert_no = IdCardNo
  23896. } else if id_card_type == 4 {
  23897. cert_no = IdCardNo
  23898. psn_info.VerifyNumber = psn_info.VerifyNumber
  23899. } else {
  23900. bas := strings.Split(psn_info.CardInfo, "|")
  23901. cert_no = bas[2]
  23902. }
  23903. var hisPrescription []*models.HisPrescription
  23904. for _, item := range rf {
  23905. if item.Insutype == insutype {
  23906. //insuplc_admdvs = item.InsuplcAdmdvs
  23907. his.InsuplcAdmdvs = insuplc_admdvs
  23908. }
  23909. }
  23910. his.Insutype = insutype
  23911. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23912. fmt.Println(res3101)
  23913. fmt.Println(res3101.Infcode)
  23914. if res3101.Infcode == "0" {
  23915. fmt.Println("33333333")
  23916. if len(res3101.Output.Result) > 0 {
  23917. fmt.Println("222222")
  23918. for _, item := range res3101.Output.Result {
  23919. if len(res3101.ErrMsg) == 0 {
  23920. res3101.ErrMsg = item.VolaCont
  23921. } else {
  23922. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23923. }
  23924. }
  23925. c.ServeSuccessJSON(map[string]interface{}{
  23926. "failed_code": -10,
  23927. "msg": res3101.ErrMsg,
  23928. })
  23929. return
  23930. } else {
  23931. fmt.Println("11111")
  23932. var api string
  23933. if miConfig.MdtrtareaAdmvs == "320921" {
  23934. ipt_otp_no = timeFormat
  23935. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23936. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23937. "&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
  23938. } else {
  23939. ipt_otp_no = timeFormat
  23940. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23941. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23942. "&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
  23943. }
  23944. resp, requestErr := http.Get(api)
  23945. if requestErr != nil {
  23946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23947. return
  23948. }
  23949. body, ioErr := ioutil.ReadAll(resp.Body)
  23950. if ioErr != nil {
  23951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23953. return
  23954. }
  23955. var respJSON map[string]interface{}
  23956. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23959. return
  23960. }
  23961. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23962. result, _ := json.Marshal(respJSON)
  23963. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23964. utils.ErrorLog("解析失败:%v", err)
  23965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23966. return
  23967. }
  23968. resThree.ErrMsg = resThree10265.ErrMsg
  23969. resThree.Output = resThree10265.Output
  23970. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23971. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23972. }
  23973. } else if res3101.Infcode != "0" {
  23974. c.ServeSuccessJSON(map[string]interface{}{
  23975. "failed_code": -10,
  23976. "msg": res3101.ErrMsg,
  23977. })
  23978. return
  23979. }
  23980. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23981. psn_info, _ := service.GetPsnByPatientId(id)
  23982. var cert_no string
  23983. if id_card_type == 1 {
  23984. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  23985. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23986. } else if id_card_type == 4 {
  23987. cert_no = psn_info.VerifyNumber
  23988. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23989. } else {
  23990. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23991. cert_no = psn_info.VerifyNumber
  23992. }
  23993. 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)
  23994. saveLog(result, requestLog, "2201", "挂号")
  23995. if miConfig.Code == "H15049901371" {
  23996. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23997. utils.ErrorLog("解析失败:%v", err)
  23998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23999. return
  24000. }
  24001. resThree.ErrMsg = resThree10265.ErrMsg
  24002. resThree.Output = resThree10265.Output
  24003. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24004. } else {
  24005. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24006. utils.ErrorLog("解析失败:%v", err)
  24007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24008. return
  24009. }
  24010. }
  24011. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24012. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24013. psn_info, _ := service.GetPsnByPatientId(id)
  24014. var result string
  24015. var requestLog string
  24016. if id_card_type == 1 {
  24017. bas := strings.Split(psn_info.CardInfo, "|")
  24018. basNumber := bas[2]
  24019. card_sn := bas[3]
  24020. 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)
  24021. saveLog(result, requestLog, "2201A", "挂号")
  24022. } else if id_card_type == 2 {
  24023. 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, "", "", "", "", "", "")
  24024. saveLog(result, requestLog, "2201A", "挂号")
  24025. } else {
  24026. 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)
  24027. saveLog(result, requestLog, "2201A", "挂号")
  24028. }
  24029. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24030. utils.ErrorLog("解析失败:%v", err)
  24031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24032. return
  24033. }
  24034. infocode = resThree.Infcode
  24035. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24036. psn_info, _ := service.GetPsnByPatientId(id)
  24037. var result string
  24038. var requestLog string
  24039. if id_card_type == 1 {
  24040. bas := strings.Split(psn_info.CardInfo, "|")
  24041. basNumber := bas[2]
  24042. card_sn := ""
  24043. 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)
  24044. saveLog(result, requestLog, "2201A", "挂号")
  24045. } else if id_card_type == 2 {
  24046. 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, "", "", "", "", "", "")
  24047. saveLog(result, requestLog, "2201A", "挂号")
  24048. } else {
  24049. 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)
  24050. saveLog(result, requestLog, "2201A", "挂号")
  24051. }
  24052. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24053. utils.ErrorLog("解析失败:%v", err)
  24054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24055. return
  24056. }
  24057. infocode = resThree.Infcode
  24058. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24059. psn_info, _ := service.GetPsnByPatientId(id)
  24060. his.PsnNo = psn_info.PsnNo
  24061. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24062. var cert_no string
  24063. if id_card_type == 1 {
  24064. bas := strings.Split(psn_info.CardInfo, "|")
  24065. cert_no = bas[2]
  24066. } else if id_card_type == 4 {
  24067. cert_no = psn_info.VerifyNumber
  24068. psn_info.VerifyNumber = psn_info.VerifyNumber
  24069. IdCardNo = psn_info.VerifyNumber
  24070. } else {
  24071. cert_no = IdCardNo
  24072. psn_info.VerifyNumber = cert_no
  24073. }
  24074. for _, item := range rf {
  24075. if item.Insutype == insutype {
  24076. his.InsuplcAdmdvs = insuplc_admdvs
  24077. }
  24078. }
  24079. his.Insutype = insutype
  24080. var api string
  24081. ipt_otp_no = timeFormat
  24082. 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 +
  24083. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24084. "&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
  24085. resp, requestErr := http.Get(api)
  24086. if requestErr != nil {
  24087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24088. return
  24089. }
  24090. body, ioErr := ioutil.ReadAll(resp.Body)
  24091. if ioErr != nil {
  24092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24094. return
  24095. }
  24096. var respJSON map[string]interface{}
  24097. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24100. return
  24101. }
  24102. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24103. if status == "0" {
  24104. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24105. c.ServeSuccessJSON(map[string]interface{}{
  24106. "failed_code": -10,
  24107. "msg": err_msg,
  24108. })
  24109. return
  24110. }
  24111. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24112. result, _ := json.Marshal(respJSON)
  24113. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24114. utils.ErrorLog("解析失败:%v", err)
  24115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24116. return
  24117. }
  24118. infocode = resThree.Infcode
  24119. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24120. psn_info, _ := service.GetPsnByPatientId(id)
  24121. his.PsnNo = psn_info.PsnNo
  24122. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24123. var cert_no string
  24124. if id_card_type == 1 {
  24125. bas := strings.Split(psn_info.CardInfo, "|")
  24126. cert_no = bas[2]
  24127. } else if id_card_type == 4 {
  24128. cert_no = psn_info.VerifyNumber
  24129. psn_info.VerifyNumber = psn_info.VerifyNumber
  24130. IdCardNo = psn_info.VerifyNumber
  24131. } else {
  24132. cert_no = IdCardNo
  24133. psn_info.VerifyNumber = cert_no
  24134. }
  24135. for _, item := range rf {
  24136. if item.Insutype == insutype {
  24137. his.InsuplcAdmdvs = insuplc_admdvs
  24138. patient.InsuplcAdmdvs = insuplc_admdvs
  24139. }
  24140. }
  24141. his.Insutype = insutype
  24142. var api string
  24143. ipt_otp_no = timeFormat
  24144. 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 +
  24145. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24146. "&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
  24147. resp, requestErr := http.Get(api)
  24148. if requestErr != nil {
  24149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24150. return
  24151. }
  24152. body, ioErr := ioutil.ReadAll(resp.Body)
  24153. if ioErr != nil {
  24154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24156. return
  24157. }
  24158. var respJSON map[string]interface{}
  24159. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24162. return
  24163. }
  24164. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24165. if status == "0" {
  24166. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24167. c.ServeSuccessJSON(map[string]interface{}{
  24168. "failed_code": -10,
  24169. "msg": err_msg,
  24170. })
  24171. return
  24172. }
  24173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24174. result, _ := json.Marshal(respJSON)
  24175. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24176. utils.ErrorLog("解析失败:%v", err)
  24177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24178. return
  24179. }
  24180. infocode = resThree.Infcode
  24181. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24182. psn_info, _ := service.GetPsnByPatientId(id)
  24183. var result string
  24184. var requestLog string
  24185. if id_card_type == 1 {
  24186. bas := strings.Split(psn_info.CardInfo, "|")
  24187. basNumber := bas[2]
  24188. card_sn := bas[3]
  24189. 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)
  24190. saveLog(result, requestLog, "2201A", "挂号")
  24191. } else if id_card_type == 2 {
  24192. 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, "", "")
  24193. saveLog(result, requestLog, "2201A", "挂号")
  24194. } else {
  24195. 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, "", "")
  24196. saveLog(result, requestLog, "2201A", "挂号")
  24197. }
  24198. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24199. utils.ErrorLog("解析失败:%v", err)
  24200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24201. return
  24202. }
  24203. infocode = resThree.Infcode
  24204. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24205. psn_info, _ := service.GetPsnByPatientId(id)
  24206. 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)
  24207. saveLog(result, requestLog, "2201A", "挂号")
  24208. if miConfig.Code == "H15049901371" {
  24209. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24210. utils.ErrorLog("解析失败:%v", err)
  24211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24212. return
  24213. }
  24214. resThree.ErrMsg = resThree10265.ErrMsg
  24215. resThree.Output = resThree10265.Output
  24216. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24217. } else {
  24218. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24219. utils.ErrorLog("解析失败:%v", err)
  24220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24221. return
  24222. }
  24223. }
  24224. if miConfig.Code == "H15049901371" {
  24225. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24226. } else {
  24227. infocode = resThree.Infcode
  24228. }
  24229. } else {
  24230. psn_info, _ := service.GetPsnByPatientId(id)
  24231. if id_card_type == 4 || id_card_type == 1 {
  24232. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24233. }
  24234. var rf []*ResultFive
  24235. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24236. var insutypes []*ResultFive
  24237. var insutype string
  24238. var is390 int = 0
  24239. var is310 int = 0
  24240. for _, item := range rf {
  24241. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24242. insutypes = append(insutypes, item)
  24243. }
  24244. }
  24245. if len(insutypes) == 1 {
  24246. insutype = insutypes[0].Insutype
  24247. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24248. } else {
  24249. for _, i := range insutypes {
  24250. if i.Insutype == "390" {
  24251. is390 = 1
  24252. }
  24253. if i.Insutype == "310" {
  24254. is310 = 1
  24255. }
  24256. }
  24257. }
  24258. if is390 == 1 {
  24259. insutype = "390"
  24260. }
  24261. if is310 == 1 {
  24262. insutype = "310"
  24263. }
  24264. fmt.Println(len(insutypes))
  24265. if len(insutypes) == 0 {
  24266. for index, item := range rf {
  24267. if index == 0 {
  24268. insutype = item.Insutype
  24269. insuplc_admdvs = item.InsuplcAdmdvs
  24270. }
  24271. }
  24272. fmt.Println(insutype)
  24273. fmt.Println(insuplc_admdvs)
  24274. }
  24275. if social_type > 0 {
  24276. insutype = strconv.FormatInt(social_type, 10)
  24277. }
  24278. fmt.Println("--------")
  24279. fmt.Println(psn_info)
  24280. fmt.Println(psn_info.PsnNo)
  24281. if miConfig.MdtrtareaAdmvs == "441202" {
  24282. var hisPrescription []*models.HisPrescription
  24283. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24284. if res3101.Infcode == 0 {
  24285. fmt.Println("33333333")
  24286. if len(res3101.Output.Result) > 0 {
  24287. fmt.Println("222222")
  24288. for _, item := range res3101.Output.Result {
  24289. if len(res3101.ErrMsg) == 0 {
  24290. res3101.ErrMsg = item.VolaCont
  24291. } else {
  24292. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24293. }
  24294. }
  24295. c.ServeSuccessJSON(map[string]interface{}{
  24296. "failed_code": -10,
  24297. "msg": res3101.ErrMsg,
  24298. })
  24299. return
  24300. } else {
  24301. hour := time.Now().Format("15")
  24302. min := time.Now().Format("04")
  24303. sec := time.Now().Format("05")
  24304. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24305. fmt.Println(record_time_two)
  24306. 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)
  24307. saveLog(result, requestLog, "2201A", "挂号")
  24308. if miConfig.Code == "H15049901371" {
  24309. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24310. utils.ErrorLog("解析失败:%v", err)
  24311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24312. return
  24313. }
  24314. resThree.ErrMsg = resThree10265.ErrMsg
  24315. resThree.Output = resThree10265.Output
  24316. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24317. } else {
  24318. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24319. utils.ErrorLog("解析失败:%v", err)
  24320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24321. return
  24322. }
  24323. }
  24324. if miConfig.Code == "H15049901371" {
  24325. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24326. } else {
  24327. infocode = resThree.Infcode
  24328. }
  24329. }
  24330. } else if res3101.Infcode != 0 {
  24331. c.ServeSuccessJSON(map[string]interface{}{
  24332. "failed_code": -10,
  24333. "msg": res3101.ErrMsg,
  24334. })
  24335. return
  24336. }
  24337. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24338. var hisPrescription []*models.HisPrescription
  24339. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24340. if res3101.Infcode == 0 {
  24341. fmt.Println("33333333")
  24342. if len(res3101.Output.Result) > 0 {
  24343. fmt.Println("222222")
  24344. for _, item := range res3101.Output.Result {
  24345. if len(res3101.ErrMsg) == 0 {
  24346. res3101.ErrMsg = item.VolaCont
  24347. } else {
  24348. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24349. }
  24350. }
  24351. c.ServeSuccessJSON(map[string]interface{}{
  24352. "failed_code": -10,
  24353. "msg": res3101.ErrMsg,
  24354. })
  24355. return
  24356. } else {
  24357. hour := time.Now().Format("15")
  24358. min := time.Now().Format("04")
  24359. sec := time.Now().Format("05")
  24360. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24361. fmt.Println(record_time_two)
  24362. 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)
  24363. saveLog(result, requestLog, "2201A", "挂号")
  24364. if miConfig.Code == "H15049901371" {
  24365. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24366. utils.ErrorLog("解析失败:%v", err)
  24367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24368. return
  24369. }
  24370. resThree.ErrMsg = resThree10265.ErrMsg
  24371. resThree.Output = resThree10265.Output
  24372. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24373. } else {
  24374. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24375. utils.ErrorLog("解析失败:%v", err)
  24376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24377. return
  24378. }
  24379. }
  24380. if miConfig.Code == "H15049901371" {
  24381. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24382. } else {
  24383. infocode = resThree.Infcode
  24384. }
  24385. }
  24386. } else if res3101.Infcode != 0 {
  24387. c.ServeSuccessJSON(map[string]interface{}{
  24388. "failed_code": -10,
  24389. "msg": res3101.ErrMsg,
  24390. })
  24391. return
  24392. }
  24393. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24394. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24395. psn_info, _ := service.GetPsnByPatientId(id)
  24396. var verify_number string
  24397. if id_card_type == 4 {
  24398. verify_number = psn_info.VerifyNumber
  24399. } else if id_card_type == 1 {
  24400. bas := strings.Split(psn_info.CardInfo, "|")
  24401. cardNumber := bas[2]
  24402. verify_number = cardNumber
  24403. } else {
  24404. verify_number = psn_info.Certno
  24405. }
  24406. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24407. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24408. "&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
  24409. resp, requestErr := http.Get(api)
  24410. if requestErr != nil {
  24411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24412. return
  24413. }
  24414. body, ioErr := ioutil.ReadAll(resp.Body)
  24415. if ioErr != nil {
  24416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24418. return
  24419. }
  24420. var respJSON map[string]interface{}
  24421. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24424. return
  24425. }
  24426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24427. result, _ := json.Marshal(respJSON)
  24428. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24429. utils.ErrorLog("解析失败:%v", err)
  24430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24431. return
  24432. }
  24433. infocode = resThree.Infcode
  24434. } else {
  24435. hour := time.Now().Format("15")
  24436. min := time.Now().Format("04")
  24437. sec := time.Now().Format("05")
  24438. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24439. if id_card_type == 1 {
  24440. for _, item := range rf {
  24441. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24442. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24443. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24444. } else if strconv.FormatInt(social_type, 10) == "390" {
  24445. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24446. } else {
  24447. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24448. }
  24449. }
  24450. }
  24451. }
  24452. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24453. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24454. }
  24455. if id_card_type == 1 {
  24456. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24457. bas := strings.Split(psn_info.CardInfo, "|")
  24458. basNumber := bas[1]
  24459. IdCardNo = basNumber
  24460. }
  24461. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24462. IdCardNo = psn_info.VerifyNumber
  24463. }
  24464. if len(insuplc_admdvs_temp) == 0 {
  24465. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24466. }
  24467. var result string
  24468. var requestLog string
  24469. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  24470. var hisPrescription []*models.HisPrescription
  24471. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24472. if res3101.Infcode == 0 {
  24473. if len(res3101.Output.Result) > 0 {
  24474. for _, item := range res3101.Output.Result {
  24475. if len(res3101.ErrMsg) == 0 {
  24476. res3101.ErrMsg = item.VolaCont
  24477. } else {
  24478. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24479. }
  24480. }
  24481. c.ServeSuccessJSON(map[string]interface{}{
  24482. "failed_code": -10,
  24483. "msg": res3101.ErrMsg,
  24484. })
  24485. return
  24486. } else {
  24487. hour := time.Now().Format("15")
  24488. min := time.Now().Format("04")
  24489. sec := time.Now().Format("05")
  24490. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24491. fmt.Println(record_time_two)
  24492. if his.IdCardType == 2 {
  24493. IdCardNo = psn_info.Certno
  24494. psn_info.VerifyNumber = psn_info.Certno
  24495. } else if his.IdCardType == 4 {
  24496. IdCardNo = psn_info.Certno
  24497. }else{
  24498. bas := strings.Split(psn_info.CardInfo, "|")
  24499. IdCardNo = bas[2]
  24500. }
  24501. 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)
  24502. saveLog(result, requestLog, "2201A", "挂号")
  24503. if miConfig.Code == "H15049901371" {
  24504. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24505. utils.ErrorLog("解析失败:%v", err)
  24506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24507. return
  24508. }
  24509. resThree.ErrMsg = resThree10265.ErrMsg
  24510. resThree.Output = resThree10265.Output
  24511. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24512. } else {
  24513. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24514. utils.ErrorLog("解析失败:%v", err)
  24515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24516. return
  24517. }
  24518. }
  24519. if miConfig.Code == "H15049901371" {
  24520. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24521. } else {
  24522. infocode = resThree.Infcode
  24523. }
  24524. }
  24525. } else if res3101.Infcode != 0 {
  24526. c.ServeSuccessJSON(map[string]interface{}{
  24527. "failed_code": -10,
  24528. "msg": res3101.ErrMsg,
  24529. })
  24530. return
  24531. }
  24532. } else {
  24533. psn_info, _ := service.GetPsnByPatientId(id)
  24534. var rf []*ResultFive
  24535. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24536. //var insutypes []*ResultFive
  24537. var insutype string
  24538. var insutypes []*ResultFive
  24539. var is390 int = 0
  24540. var is310 int = 0
  24541. for _, item := range rf {
  24542. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24543. insutypes = append(insutypes, item)
  24544. }
  24545. }
  24546. if len(insutypes) == 1 {
  24547. insutype = insutypes[0].Insutype
  24548. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24549. } else {
  24550. for _, i := range insutypes {
  24551. if i.Insutype == "390" {
  24552. is390 = 1
  24553. }
  24554. if i.Insutype == "310" {
  24555. is310 = 1
  24556. }
  24557. }
  24558. }
  24559. if is390 == 1 {
  24560. insutype = "390"
  24561. }
  24562. if is310 == 1 {
  24563. insutype = "310"
  24564. }
  24565. if len(insutypes) == 0 {
  24566. insutype = "310"
  24567. }
  24568. if social_type > 0 {
  24569. insutype = strconv.FormatInt(social_type, 10)
  24570. }
  24571. for _, item := range rf {
  24572. if item.Insutype == insutype {
  24573. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24574. }
  24575. }
  24576. 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)
  24577. saveLog(result, requestLog, "2201A", "挂号")
  24578. }
  24579. if miConfig.Code == "H15049901371" {
  24580. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24581. utils.ErrorLog("解析失败:%v", err)
  24582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24583. return
  24584. }
  24585. resThree.ErrMsg = resThree10265.ErrMsg
  24586. resThree.Output = resThree10265.Output
  24587. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24588. } else {
  24589. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24590. utils.ErrorLog("解析失败:%v", err)
  24591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24592. return
  24593. }
  24594. }
  24595. if miConfig.Code == "H15049901371" {
  24596. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24597. } else {
  24598. infocode = resThree.Infcode
  24599. }
  24600. }
  24601. }
  24602. if infocode == -1 {
  24603. adminUser := c.GetAdminUserInfo()
  24604. errlog := &models.HisOrderError{
  24605. UserOrgId: adminUser.CurrentOrgId,
  24606. Ctime: time.Now().Unix(),
  24607. Mtime: time.Now().Unix(),
  24608. ErrMsg: resThree.ErrMsg,
  24609. Status: 1,
  24610. PatientId: id,
  24611. RecordTime: recordDateTime,
  24612. Stage: 2,
  24613. }
  24614. service.CreateErrMsgLog(errlog)
  24615. c.ServeSuccessJSON(map[string]interface{}{
  24616. "failed_code": -10,
  24617. "msg": resThree.ErrMsg,
  24618. })
  24619. return
  24620. }
  24621. his.Number = resThree.Output.Data.MdtrtID
  24622. his.PsnNo = resThree.Output.Data.PsnNo
  24623. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24624. his.IdCardNo = patient.IdCardNo
  24625. his.PhoneNumber = patient.Phone
  24626. his.UserOrgId = adminInfo.CurrentOrgId
  24627. his.Insutype = insutype
  24628. his.Ctime = time.Now().Unix()
  24629. his.Mtime = time.Now().Unix()
  24630. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24631. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24632. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24633. }
  24634. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24635. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24636. }
  24637. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24638. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24639. }
  24640. his.Status = 1
  24641. his.MdtrtGrpType = mdtrt_type
  24642. service.UpdateHisPatientStatus(&his)
  24643. service.UpdateHisPatient123(&patient)
  24644. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24645. c.ServeSuccessJSON(map[string]interface{}{
  24646. "his_info": his,
  24647. })
  24648. } else {
  24649. adminUser := c.GetAdminUserInfo()
  24650. errlog := &models.HisOrderError{
  24651. UserOrgId: adminUser.CurrentOrgId,
  24652. Ctime: time.Now().Unix(),
  24653. Mtime: time.Now().Unix(),
  24654. ErrMsg: res.ErrMsg,
  24655. Status: 1,
  24656. PatientId: id,
  24657. RecordTime: recordDateTime,
  24658. Stage: 1,
  24659. }
  24660. service.CreateErrMsgLog(errlog)
  24661. c.ServeSuccessJSON(map[string]interface{}{
  24662. "failed_code": -10,
  24663. "msg": res.ErrMsg,
  24664. })
  24665. return
  24666. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24667. }
  24668. }
  24669. }
  24670. func (c *HisApiController) GetUploadInfo() {
  24671. id, _ := c.GetInt64("id")
  24672. record_time := c.GetString("record_time")
  24673. his_patient_id, _ := c.GetInt64("his_patient_id")
  24674. order_id, _ := c.GetInt64("order_id")
  24675. pay_way, _ := c.GetInt64("pay_way")
  24676. pay_ways := c.GetString("pay_ways")
  24677. oth_desc := c.GetString("oth_desc")
  24678. pay_price, _ := c.GetFloat("pay_price")
  24679. pay_card_no := c.GetString("pay_card_no")
  24680. discount_price, _ := c.GetFloat("discount_price")
  24681. preferential_price, _ := c.GetFloat("preferential_price")
  24682. reality_price, _ := c.GetFloat("reality_price")
  24683. found_price, _ := c.GetFloat("found_price")
  24684. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24685. private_price, _ := c.GetFloat("private_price")
  24686. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24687. admin_user_id, _ := c.GetInt64("admin_user_id")
  24688. fapiao_code := c.GetString("fapiao_code")
  24689. fapiao_number := c.GetString("fapiao_number")
  24690. diagnosis_id := c.GetString("diagnosis")
  24691. sick_type, _ := c.GetInt64("sick_type")
  24692. reg_type, _ := c.GetInt64("p_type")
  24693. begin_time := c.GetString("begin_time")
  24694. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24695. cash_pay := c.GetString("cash_pay")
  24696. band_card_pay := c.GetString("band_card_pay")
  24697. wechat_pay := c.GetString("wechat_pay")
  24698. ali_pay := c.GetString("ali_pay")
  24699. jifen_pay := c.GetString("jifen_pay")
  24700. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24701. fmt.Println(acct_used_flag)
  24702. id_str := c.GetString("ids")
  24703. ids_arr := strings.Split(id_str, ",")
  24704. timeLayout := "2006-01-02"
  24705. loc, _ := time.LoadLocation("Local")
  24706. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24707. if err != nil {
  24708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24709. return
  24710. }
  24711. recordDateTime := theTime.Unix()
  24712. adminUser := c.GetAdminUserInfo()
  24713. var tempOrder models.HisOrder
  24714. tempOrder, _ = service.GetHisOrderByID(order_id)
  24715. var prescriptions []*models.HisPrescription
  24716. var start_time int64
  24717. var end_time int64
  24718. //押金模块
  24719. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24720. tmp_decimal := c.GetString("tmp_decimal")
  24721. var decimal float64 //本次使用的押金
  24722. var errmsg error
  24723. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24724. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24725. return
  24726. }
  24727. if len(tmp_decimal) > 0 {
  24728. if tmp_decimal[0] == 45 {
  24729. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24730. return
  24731. }
  24732. }
  24733. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24734. fmt.Println(errs)
  24735. decimal = tt
  24736. //if adminUser.CurrentOrgId == 10106{
  24737. // if len(fapiao_code) == 0{
  24738. // fapiao_code = "144072080589"
  24739. // }
  24740. // if len(fapiao_number) == 0{
  24741. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24742. // if order.ID == 0{
  24743. // fapiao_number = "00001520"
  24744. // }else{
  24745. // //fapiao_code = "00001520"
  24746. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24747. // var zero string
  24748. // if fpNumber >= 1000{
  24749. // zero = "0000" + strconv.Itoa(fpNumber)
  24750. // }else if fpNumber >= 10000{
  24751. // zero = "000" + strconv.Itoa(fpNumber)
  24752. // } else if fpNumber >= 100000{
  24753. // zero = "00" + strconv.Itoa(fpNumber)
  24754. // } else if fpNumber >= 1000000{
  24755. // zero = "0" + strconv.Itoa(fpNumber)
  24756. // }else {
  24757. // zero = strconv.Itoa(fpNumber)
  24758. // }
  24759. // fapiao_number = zero
  24760. // }
  24761. // }
  24762. //}
  24763. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24764. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24765. var patientPrescription models.HisPrescriptionInfo
  24766. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24767. if patientPrescription.ID == 0 {
  24768. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24769. }
  24770. //if patientPrescription.Do
  24771. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24772. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24773. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24774. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24775. var config []*models.HisXtDiagnoseConfig
  24776. for _, item := range diagnosis_ids {
  24777. id, _ := strconv.ParseInt(item, 10, 64)
  24778. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24779. config = append(config, &diagnosisConfig)
  24780. }
  24781. sickConfig, _ := service.FindSickById(sick_type)
  24782. //if tempOrder.ID == 0 {
  24783. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24784. //}
  24785. if tempOrder.ID == 0 {
  24786. var result string
  24787. var requestLog string
  24788. var res2 ResultSix
  24789. var res3 GZResultSix
  24790. var ressix10265 ResultSix10265
  24791. if miConfig.MdtrtareaAdmvs == "421300" {
  24792. data := make(map[string]interface{})
  24793. client := &http.Client{}
  24794. data["psn_no"] = his.PsnNo
  24795. data["mdtrt_id"] = his.Number
  24796. data["opter"] = roles.UserName
  24797. data["org_name"] = miConfig.OrgName
  24798. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24799. data["doctor_id"] = doctor_info.DoctorNumber
  24800. data["doctor_name"] = doctor_info.UserName
  24801. data["department"] = department.Name
  24802. data["fixmedins_code"] = miConfig.Code
  24803. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24804. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24805. data["secret_key"] = miConfig.SecretKey
  24806. data["sick_code"] = sickConfig.CountryCode
  24807. data["sick_name"] = sickConfig.ClassName
  24808. data["dept"] = strconv.FormatInt(department.ID, 10)
  24809. data["config"] = config
  24810. data["begin_time"] = begin_time
  24811. bytesData, _ := json.Marshal(data)
  24812. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24813. resp, _ := client.Do(req)
  24814. defer resp.Body.Close()
  24815. body, ioErr := ioutil.ReadAll(resp.Body)
  24816. if ioErr != nil {
  24817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24819. return
  24820. }
  24821. var respJSON map[string]interface{}
  24822. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24825. return
  24826. }
  24827. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24828. userJSONBytes, _ := json.Marshal(respJSON)
  24829. fmt.Println("log")
  24830. fmt.Println(string(userJSONBytes))
  24831. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24832. utils.ErrorLog("解析失败:%v", err)
  24833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24834. return
  24835. }
  24836. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24837. data := make(map[string]interface{})
  24838. client := &http.Client{}
  24839. data["psn_no"] = his.PsnNo
  24840. data["mdtrt_id"] = his.Number
  24841. data["opter"] = roles.UserName
  24842. data["org_name"] = miConfig.OrgName
  24843. if reg_type == 11 && his.Insutype == "390" {
  24844. data["med_type"] = "110104"
  24845. } else {
  24846. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24847. }
  24848. data["doctor_id"] = doctor_info.DoctorNumber
  24849. data["doctor_name"] = doctor_info.UserName
  24850. data["department"] = department.Name
  24851. data["fixmedins_code"] = miConfig.Code
  24852. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24853. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24854. data["secret_key"] = miConfig.SecretKey
  24855. data["sick_code"] = sickConfig.CountryCode
  24856. data["sick_name"] = sickConfig.ClassName
  24857. data["dept"] = strconv.FormatInt(department.ID, 10)
  24858. data["config"] = config
  24859. data["begin_time"] = begin_time
  24860. bytesData, _ := json.Marshal(data)
  24861. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24862. resp, _ := client.Do(req)
  24863. defer resp.Body.Close()
  24864. body, ioErr := ioutil.ReadAll(resp.Body)
  24865. if ioErr != nil {
  24866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24868. return
  24869. }
  24870. var respJSON map[string]interface{}
  24871. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24874. return
  24875. }
  24876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24877. userJSONBytes, _ := json.Marshal(respJSON)
  24878. fmt.Println("log")
  24879. fmt.Println(string(userJSONBytes))
  24880. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24881. utils.ErrorLog("解析失败:%v", err)
  24882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24883. return
  24884. }
  24885. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24886. data := make(map[string]interface{})
  24887. client := &http.Client{}
  24888. data["psn_no"] = his.PsnNo
  24889. data["mdtrt_id"] = his.Number
  24890. data["opter"] = roles.UserName
  24891. data["org_name"] = miConfig.OrgName
  24892. if reg_type == 11 && his.Insutype == "390" {
  24893. data["med_type"] = "110104"
  24894. } else {
  24895. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24896. }
  24897. data["doctor_id"] = doctor_info.DoctorNumber
  24898. data["doctor_name"] = doctor_info.UserName
  24899. data["department"] = department.Name
  24900. data["fixmedins_code"] = miConfig.Code
  24901. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24902. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24903. data["secret_key"] = miConfig.SecretKey
  24904. data["sick_code"] = sickConfig.CountryCode
  24905. data["sick_name"] = sickConfig.ClassName
  24906. data["dept"] = strconv.FormatInt(department.ID, 10)
  24907. data["config"] = config
  24908. data["begin_time"] = begin_time
  24909. bytesData, _ := json.Marshal(data)
  24910. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24911. resp, _ := client.Do(req)
  24912. defer resp.Body.Close()
  24913. body, ioErr := ioutil.ReadAll(resp.Body)
  24914. if ioErr != nil {
  24915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24917. return
  24918. }
  24919. var respJSON map[string]interface{}
  24920. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24923. return
  24924. }
  24925. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24926. userJSONBytes, _ := json.Marshal(respJSON)
  24927. fmt.Println("log")
  24928. fmt.Println(string(userJSONBytes))
  24929. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24930. utils.ErrorLog("解析失败:%v", err)
  24931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24932. return
  24933. }
  24934. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24935. data := make(map[string]interface{})
  24936. client := &http.Client{}
  24937. data["psn_no"] = his.PsnNo
  24938. data["mdtrt_id"] = his.Number
  24939. data["opter"] = roles.UserName
  24940. data["org_name"] = miConfig.OrgName
  24941. if reg_type == 11 && his.Insutype == "390" {
  24942. data["med_type"] = "110104"
  24943. } else {
  24944. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24945. }
  24946. data["doctor_id"] = doctor_info.DoctorNumber
  24947. data["doctor_name"] = doctor_info.UserName
  24948. data["department"] = department.Name
  24949. data["fixmedins_code"] = miConfig.Code
  24950. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24951. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24952. data["secret_key"] = miConfig.SecretKey
  24953. data["sick_code"] = sickConfig.CountryCode
  24954. data["sick_name"] = sickConfig.ClassName
  24955. data["dept"] = strconv.FormatInt(department.ID, 10)
  24956. data["config"] = config
  24957. data["begin_time"] = begin_time
  24958. bytesData, _ := json.Marshal(data)
  24959. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24960. resp, _ := client.Do(req)
  24961. defer resp.Body.Close()
  24962. body, ioErr := ioutil.ReadAll(resp.Body)
  24963. if ioErr != nil {
  24964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24966. return
  24967. }
  24968. var respJSON map[string]interface{}
  24969. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24972. return
  24973. }
  24974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24975. userJSONBytes, _ := json.Marshal(respJSON)
  24976. fmt.Println("log")
  24977. fmt.Println(string(userJSONBytes))
  24978. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24979. utils.ErrorLog("解析失败:%v", err)
  24980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24981. return
  24982. }
  24983. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24984. data := make(map[string]interface{})
  24985. client := &http.Client{}
  24986. data["psn_no"] = his.PsnNo
  24987. data["mdtrt_id"] = his.Number
  24988. data["doctor"] = roles.UserName
  24989. data["department"] = department.Name
  24990. data["org_name"] = miConfig.OrgName
  24991. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24992. data["doctor_id"] = doctor_info.DoctorNumber
  24993. data["new_doctor_name"] = doctor_info.UserName
  24994. data["fixmedins_code"] = miConfig.Code
  24995. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24996. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24997. data["secret_key"] = miConfig.SecretKey
  24998. data["sick_code"] = sickConfig.CountryCode
  24999. data["sick_name"] = sickConfig.ClassName
  25000. data["url"] = miConfig.Url
  25001. data["ak"] = miConfig.AccessKey
  25002. data["begin_time"] = begin_time
  25003. data["cainfo"] = miConfig.Cainfo
  25004. data["dept"] = strconv.FormatInt(department.ID, 10)
  25005. data["config"] = config
  25006. bytesData, _ := json.Marshal(data)
  25007. var req *http.Request
  25008. if miConfig.MdtrtareaAdmvs == "320921" {
  25009. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25010. //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 +
  25011. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25012. } else {
  25013. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25014. }
  25015. resp, _ := client.Do(req)
  25016. defer resp.Body.Close()
  25017. body, ioErr := ioutil.ReadAll(resp.Body)
  25018. if ioErr != nil {
  25019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25021. return
  25022. }
  25023. var respJSON map[string]interface{}
  25024. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25027. return
  25028. }
  25029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25030. userJSONBytes, _ := json.Marshal(respJSON)
  25031. fmt.Println("log")
  25032. fmt.Println(string(userJSONBytes))
  25033. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25034. utils.ErrorLog("解析失败:%v", err)
  25035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25036. return
  25037. }
  25038. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25039. res2.Output = ressix10265.Output
  25040. res2.ErrMsg = ressix10265.ErrMsg
  25041. res2.Cainfo = ressix10265.Cainfo
  25042. res2.WarnMsg = ressix10265.WarnMsg
  25043. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25044. res2.Infcode = infocode
  25045. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25046. data := make(map[string]interface{})
  25047. client := &http.Client{}
  25048. data["psn_no"] = his.PsnNo
  25049. data["mdtrt_id"] = his.Number
  25050. data["doctor"] = roles.UserName
  25051. data["department"] = department.Name
  25052. data["org_name"] = miConfig.OrgName
  25053. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25054. data["doctor_id"] = doctor_info.DoctorNumber
  25055. data["new_doctor_name"] = doctor_info.UserName
  25056. data["fixmedins_code"] = miConfig.Code
  25057. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25058. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25059. data["secret_key"] = miConfig.SecretKey
  25060. data["sick_code"] = sickConfig.CountryCode
  25061. data["sick_name"] = sickConfig.ClassName
  25062. data["url"] = miConfig.Url
  25063. data["ak"] = miConfig.AccessKey
  25064. data["begin_time"] = begin_time
  25065. data["cainfo"] = miConfig.Cainfo
  25066. data["dept"] = strconv.FormatInt(department.ID, 10)
  25067. data["config"] = config
  25068. bytesData, _ := json.Marshal(data)
  25069. var req *http.Request
  25070. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25071. resp, _ := client.Do(req)
  25072. defer resp.Body.Close()
  25073. body, ioErr := ioutil.ReadAll(resp.Body)
  25074. if ioErr != nil {
  25075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25077. return
  25078. }
  25079. var respJSON map[string]interface{}
  25080. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25083. return
  25084. }
  25085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25086. userJSONBytes, _ := json.Marshal(respJSON)
  25087. fmt.Println("log")
  25088. fmt.Println(string(userJSONBytes))
  25089. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25090. utils.ErrorLog("解析失败:%v", err)
  25091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25092. return
  25093. }
  25094. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25095. res2.Output = ressix10265.Output
  25096. res2.ErrMsg = ressix10265.ErrMsg
  25097. res2.Cainfo = ressix10265.Cainfo
  25098. res2.WarnMsg = ressix10265.WarnMsg
  25099. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25100. res2.Infcode = infocode
  25101. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25102. 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)
  25103. saveLog(result, requestLog, "2203", "上传就诊信息")
  25104. var respJSON2 map[string]interface{}
  25105. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25108. return
  25109. }
  25110. userJSONBytes2, _ := json.Marshal(respJSON2)
  25111. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25112. utils.ErrorLog("解析失败:%v", err)
  25113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25114. return
  25115. }
  25116. 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)
  25117. fmt.Println(result2)
  25118. fmt.Println(src_request)
  25119. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25120. data := make(map[string]interface{})
  25121. client := &http.Client{}
  25122. data["psn_no"] = his.PsnNo
  25123. data["mdtrt_id"] = his.Number
  25124. data["doctor"] = roles.UserName
  25125. data["department"] = department.Name
  25126. data["org_name"] = miConfig.OrgName
  25127. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25128. data["doctor_id"] = doctor_info.DoctorNumber
  25129. data["new_doctor_name"] = doctor_info.UserName
  25130. data["fixmedins_code"] = miConfig.Code
  25131. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25132. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25133. data["secret_key"] = miConfig.SecretKey
  25134. data["sick_code"] = sickConfig.CountryCode
  25135. data["sick_name"] = sickConfig.ClassName
  25136. data["url"] = miConfig.Url
  25137. data["ak"] = miConfig.AccessKey
  25138. data["begin_time"] = begin_time
  25139. data["cainfo"] = miConfig.Cainfo
  25140. data["dept"] = strconv.FormatInt(department.ID, 10)
  25141. data["config"] = config
  25142. bytesData, _ := json.Marshal(data)
  25143. var req *http.Request
  25144. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25145. resp, _ := client.Do(req)
  25146. defer resp.Body.Close()
  25147. body, ioErr := ioutil.ReadAll(resp.Body)
  25148. if ioErr != nil {
  25149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25151. return
  25152. }
  25153. var respJSON map[string]interface{}
  25154. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25157. return
  25158. }
  25159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25160. userJSONBytes, _ := json.Marshal(respJSON)
  25161. fmt.Println("log")
  25162. fmt.Println(string(userJSONBytes))
  25163. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25164. utils.ErrorLog("解析失败:%v", err)
  25165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25166. return
  25167. }
  25168. } else {
  25169. if miConfig.MdtrtareaAdmvs == "440781" { //
  25170. 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)
  25171. } else {
  25172. if miConfig.Code == "H15049901371" {
  25173. //赤峰地区国家医保医疗类别
  25174. //职工透析:医疗类别选特殊情况门诊990502
  25175. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25176. var med_type string
  25177. if his.Insutype == "390" {
  25178. if reg_type == 14 {
  25179. med_type = "9933"
  25180. } else if reg_type == 11 {
  25181. med_type = "11"
  25182. }
  25183. } else if his.Insutype == "310" {
  25184. if reg_type == 14 {
  25185. med_type = "990502"
  25186. } else if reg_type == 11 {
  25187. med_type = "11"
  25188. }
  25189. }
  25190. 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)
  25191. } else {
  25192. 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)
  25193. }
  25194. }
  25195. saveLog(result, requestLog, "2203", "上传就诊信息")
  25196. var respJSON2 map[string]interface{}
  25197. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25200. return
  25201. }
  25202. userJSONBytes2, _ := json.Marshal(respJSON2)
  25203. if miConfig.Code == "H15049901371" {
  25204. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25205. utils.ErrorLog("解析失败:%v", err)
  25206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25207. return
  25208. }
  25209. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25210. res2.Output = ressix10265.Output
  25211. res2.ErrMsg = ressix10265.ErrMsg
  25212. res2.Cainfo = ressix10265.Cainfo
  25213. res2.WarnMsg = ressix10265.WarnMsg
  25214. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25215. res2.Infcode = infocode
  25216. } else {
  25217. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25218. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25219. utils.ErrorLog("解析失败:%v", err)
  25220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25221. return
  25222. }
  25223. res2.Infcode = res3.Infcode
  25224. } else {
  25225. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25226. utils.ErrorLog("解析失败:%v", err)
  25227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25228. return
  25229. }
  25230. }
  25231. }
  25232. }
  25233. if res2.Infcode == -1 {
  25234. adminUser := c.GetAdminUserInfo()
  25235. errlog := &models.HisOrderError{
  25236. UserOrgId: adminUser.CurrentOrgId,
  25237. Ctime: time.Now().Unix(),
  25238. Mtime: time.Now().Unix(),
  25239. ErrMsg: res2.ErrMsg,
  25240. Status: 1,
  25241. PatientId: id,
  25242. RecordTime: recordDateTime,
  25243. Stage: 3,
  25244. }
  25245. service.CreateErrMsgLog(errlog)
  25246. c.ServeSuccessJSON(map[string]interface{}{
  25247. "failed_code": -10,
  25248. "msg": res2.ErrMsg,
  25249. })
  25250. return
  25251. } else {
  25252. his.Diagnosis = diagnosis_id
  25253. his.SickType = sickConfig.ID
  25254. //var p_type int64
  25255. //if reg_type == 1111 || reg_type == 1112 {
  25256. // p_type = 11
  25257. //
  25258. //}
  25259. his.PType = fmt.Sprintf("%d", reg_type)
  25260. service.UpdateHisPatientThree(&his)
  25261. data := make(map[string]interface{})
  25262. if settle_accounts_type == 1 { //日结
  25263. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25264. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25265. } else {
  25266. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25267. }
  25268. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25269. data["pre"] = prescriptions
  25270. } else { //月结
  25271. start_time_str := c.GetString("start_time")
  25272. end_time_str := c.GetString("end_time")
  25273. timeLayout := "2006-01-02"
  25274. loc, _ := time.LoadLocation("Local")
  25275. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25276. if err != nil {
  25277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25278. return
  25279. }
  25280. recordStartTime := theStartTime.Unix()
  25281. start_time = recordStartTime
  25282. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25283. if err != nil {
  25284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25285. return
  25286. }
  25287. recordEndTime := theEndTime.Unix()
  25288. end_time = recordEndTime
  25289. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25290. data["pre"] = prescriptions
  25291. }
  25292. timestamp := time.Now().Unix()
  25293. tempTime := time.Unix(timestamp, 0)
  25294. timeFormat := tempTime.Format("20060102150405")
  25295. chrgBchno := rand.Intn(100000) + 10000
  25296. new_chrg_bchno := ""
  25297. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25298. new_chrg_bchno = chrg_bchno
  25299. strconv.FormatInt(his.PatientId, 10)
  25300. client := &http.Client{}
  25301. if adminUser.CurrentOrgId == 10265 {
  25302. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25303. new_chrg_bchno = "0000"
  25304. }
  25305. }
  25306. data["psn_no"] = his.PsnNo
  25307. data["mdtrt_id"] = his.Number
  25308. data["chrg_bchno"] = new_chrg_bchno
  25309. data["org_name"] = miConfig.OrgName
  25310. data["doctor"] = doctor_info.UserName
  25311. data["doctor_id"] = doctor_info.DoctorNumber
  25312. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25313. data["fixmedins_code"] = miConfig.Code
  25314. data["dept_code"] = department.Number
  25315. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25316. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25317. data["secret_key"] = miConfig.SecretKey
  25318. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25319. data["url"] = miConfig.Url
  25320. data["ak"] = miConfig.AccessKey
  25321. data["new_doctor_name"] = patientPrescription.Doctor
  25322. data["diag_code"] = sickConfig.CountryCode
  25323. data["cainfo"] = miConfig.Cainfo
  25324. data["opter"] = roles.UserName
  25325. var ids []int64
  25326. for _, item := range prescriptions {
  25327. ids = append(ids, item.ID)
  25328. }
  25329. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25330. if config.IsOpen == 1 { //对接了医保,走医保流程
  25331. var res ResultFour
  25332. var resFour10265 ResultFour10265
  25333. if miConfig.MdtrtareaAdmvs == "421300" {
  25334. bytesData, _ := json.Marshal(data)
  25335. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25336. resp, _ := client.Do(req)
  25337. defer resp.Body.Close()
  25338. body, ioErr := ioutil.ReadAll(resp.Body)
  25339. if ioErr != nil {
  25340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25342. return
  25343. }
  25344. var respJSON map[string]interface{}
  25345. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25348. return
  25349. }
  25350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25351. userJSONBytes, _ := json.Marshal(respJSON)
  25352. fmt.Println("log")
  25353. fmt.Println(string(userJSONBytes))
  25354. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25355. utils.ErrorLog("解析失败:%v", err)
  25356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25357. return
  25358. }
  25359. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25360. bytesData, _ := json.Marshal(data)
  25361. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25362. resp, _ := client.Do(req)
  25363. defer resp.Body.Close()
  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(body), &respJSON); err != nil {
  25372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25374. return
  25375. }
  25376. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25377. userJSONBytes, _ := json.Marshal(respJSON)
  25378. fmt.Println("log")
  25379. fmt.Println(string(userJSONBytes))
  25380. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25381. utils.ErrorLog("解析失败:%v", err)
  25382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25383. return
  25384. }
  25385. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25386. bytesData, _ := json.Marshal(data)
  25387. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25388. resp, _ := client.Do(req)
  25389. defer resp.Body.Close()
  25390. body, ioErr := ioutil.ReadAll(resp.Body)
  25391. if ioErr != nil {
  25392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25394. return
  25395. }
  25396. var respJSON map[string]interface{}
  25397. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25400. return
  25401. }
  25402. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25403. userJSONBytes, _ := json.Marshal(respJSON)
  25404. fmt.Println("log")
  25405. fmt.Println(string(userJSONBytes))
  25406. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25407. utils.ErrorLog("解析失败:%v", err)
  25408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25409. return
  25410. }
  25411. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25412. bytesData, _ := json.Marshal(data)
  25413. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25414. resp, _ := client.Do(req)
  25415. defer resp.Body.Close()
  25416. body, ioErr := ioutil.ReadAll(resp.Body)
  25417. if ioErr != nil {
  25418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25420. return
  25421. }
  25422. var respJSON map[string]interface{}
  25423. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25426. return
  25427. }
  25428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25429. userJSONBytes, _ := json.Marshal(respJSON)
  25430. fmt.Println("log")
  25431. fmt.Println(string(userJSONBytes))
  25432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25433. utils.ErrorLog("解析失败:%v", err)
  25434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25435. return
  25436. }
  25437. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25438. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25439. if result3101.Infcode == "0" {
  25440. if len(result3101.Output.Result) > 0 {
  25441. var errMsgs []string
  25442. for _, item := range result3101.Output.Result {
  25443. errMsgs = append(errMsgs, item.VolaCont)
  25444. }
  25445. c.ServeSuccessJSON(map[string]interface{}{
  25446. "failed_code": -10,
  25447. "msg": errMsgs,
  25448. })
  25449. return
  25450. }
  25451. }
  25452. bytesData, _ := json.Marshal(data)
  25453. var req *http.Request
  25454. if miConfig.MdtrtareaAdmvs == "320921" {
  25455. data["diag_code"] = sickConfig.CountryCode
  25456. fmt.Println(data)
  25457. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25458. } else {
  25459. data["diag_code"] = sickConfig.CountryCode
  25460. fmt.Println(data)
  25461. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25462. }
  25463. resp, _ := client.Do(req)
  25464. defer resp.Body.Close()
  25465. body, ioErr := ioutil.ReadAll(resp.Body)
  25466. if ioErr != nil {
  25467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25469. return
  25470. }
  25471. var respJSON map[string]interface{}
  25472. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25475. return
  25476. }
  25477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25478. userJSONBytes, _ := json.Marshal(respJSON)
  25479. fmt.Println("log")
  25480. fmt.Println(string(userJSONBytes))
  25481. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25482. utils.ErrorLog("解析失败:%v", err)
  25483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25484. return
  25485. }
  25486. res.InfRefmsgid = resFour10265.InfRefmsgid
  25487. res.Output = resFour10265.Output
  25488. res.ErrMsg = resFour10265.ErrMsg
  25489. res.Cainfo = resFour10265.Cainfo
  25490. res.WarnMsg = resFour10265.WarnMsg
  25491. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25492. res.Infcode = infocode
  25493. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25494. var pagesize int = 2
  25495. var start int = 1
  25496. var stop int
  25497. var pagecount int
  25498. var curpage int
  25499. var isSuccess bool = true
  25500. data["doctor_id"] = doctor_info.DoctorNumber
  25501. //总页数,向上取整,注意除之前要先转换类型为float64
  25502. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25503. for curpage = 1; curpage <= pagecount; curpage++ {
  25504. if curpage == 1 {
  25505. start = 1
  25506. } else {
  25507. start = (curpage-1)*pagesize + 1
  25508. }
  25509. stop = curpage * pagesize
  25510. if stop > len(prescriptions) {
  25511. stop = len(prescriptions)
  25512. }
  25513. //var requestLog string
  25514. data["pre"] = prescriptions[start-1 : stop]
  25515. fmt.Println(data["pre"])
  25516. bytesData, _ := json.Marshal(data)
  25517. var req *http.Request
  25518. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25519. resp, _ := client.Do(req)
  25520. defer resp.Body.Close()
  25521. body, ioErr := ioutil.ReadAll(resp.Body)
  25522. if ioErr != nil {
  25523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25525. return
  25526. }
  25527. var respJSON map[string]interface{}
  25528. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25531. return
  25532. }
  25533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25534. userJSONBytes, _ := json.Marshal(respJSON)
  25535. fmt.Println("log")
  25536. fmt.Println(string(userJSONBytes))
  25537. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25538. utils.ErrorLog("解析失败:%v", err)
  25539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25540. return
  25541. }
  25542. res.InfRefmsgid = resFour10265.InfRefmsgid
  25543. res.Output = resFour10265.Output
  25544. res.ErrMsg = resFour10265.ErrMsg
  25545. res.Cainfo = resFour10265.Cainfo
  25546. res.WarnMsg = resFour10265.WarnMsg
  25547. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25548. res.Infcode = infocode
  25549. if infocode == 0 {
  25550. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25551. } else {
  25552. isSuccess = false
  25553. errlog := &models.HisOrderError{
  25554. UserOrgId: adminUser.CurrentOrgId,
  25555. Ctime: time.Now().Unix(),
  25556. Mtime: time.Now().Unix(),
  25557. Number: chrg_bchno,
  25558. ErrMsg: "",
  25559. Status: 1,
  25560. PatientId: id,
  25561. RecordTime: recordDateTime,
  25562. Stage: 4,
  25563. }
  25564. service.CreateErrMsgLog(errlog)
  25565. c.ServeSuccessJSON(map[string]interface{}{
  25566. "failed_code": -10,
  25567. "msg": res.ErrMsg,
  25568. })
  25569. return
  25570. }
  25571. }
  25572. if isSuccess {
  25573. res.Infcode = 0
  25574. }
  25575. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25576. 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)
  25577. var dat map[string]interface{}
  25578. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25579. fmt.Println(dat)
  25580. } else {
  25581. fmt.Println(err)
  25582. }
  25583. saveLog(result, request_log, "2204", "上传费用明细")
  25584. userJSONBytes, _ := json.Marshal(dat)
  25585. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25586. utils.ErrorLog("解析失败:%v", err)
  25587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25588. return
  25589. }
  25590. res.InfRefmsgid = resFour10265.InfRefmsgid
  25591. res.Output = resFour10265.Output
  25592. res.ErrMsg = resFour10265.ErrMsg
  25593. res.Cainfo = resFour10265.Cainfo
  25594. res.WarnMsg = resFour10265.WarnMsg
  25595. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25596. res.Infcode = infocode
  25597. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25598. bytesData, _ := json.Marshal(data)
  25599. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25600. resp, _ := client.Do(req)
  25601. defer resp.Body.Close()
  25602. body, ioErr := ioutil.ReadAll(resp.Body)
  25603. if ioErr != nil {
  25604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25606. return
  25607. }
  25608. var respJSON map[string]interface{}
  25609. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25612. return
  25613. }
  25614. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25615. userJSONBytes, _ := json.Marshal(respJSON)
  25616. fmt.Println("log")
  25617. fmt.Println(string(userJSONBytes))
  25618. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25619. utils.ErrorLog("解析失败:%v", err)
  25620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25621. return
  25622. }
  25623. } else {
  25624. if miConfig.Code == "H15049901371" {
  25625. 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)
  25626. var dat map[string]interface{}
  25627. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25628. fmt.Println(dat)
  25629. } else {
  25630. fmt.Println(err)
  25631. }
  25632. saveLog(result, request_log, "2204", "上传费用明细")
  25633. userJSONBytes, _ := json.Marshal(dat)
  25634. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25635. utils.ErrorLog("解析失败:%v", err)
  25636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25637. return
  25638. }
  25639. res.InfRefmsgid = resFour10265.InfRefmsgid
  25640. res.Output = resFour10265.Output
  25641. res.ErrMsg = resFour10265.ErrMsg
  25642. res.Cainfo = resFour10265.Cainfo
  25643. res.WarnMsg = resFour10265.WarnMsg
  25644. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25645. res.Infcode = infocode
  25646. } else {
  25647. 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)
  25648. var dat map[string]interface{}
  25649. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25650. fmt.Println(dat)
  25651. } else {
  25652. fmt.Println(err)
  25653. }
  25654. saveLog(result, request_log, "2204", "上传费用明细")
  25655. userJSONBytes, _ := json.Marshal(dat)
  25656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25657. utils.ErrorLog("解析失败:%v", err)
  25658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25659. return
  25660. }
  25661. }
  25662. }
  25663. if res.Infcode == 0 {
  25664. order := &models.HisOrder{
  25665. UserOrgId: adminUser.CurrentOrgId,
  25666. HisPatientId: his.ID,
  25667. PatientId: his.PatientId,
  25668. SettleAccountsDate: recordDateTime,
  25669. MdtrtId: his.Number,
  25670. PsnNo: his.PsnNo,
  25671. MedType: strconv.FormatInt(reg_type, 10),
  25672. Ctime: time.Now().Unix(),
  25673. Mtime: time.Now().Unix(),
  25674. Status: 1,
  25675. Number: chrg_bchno,
  25676. Infcode: res.Infcode,
  25677. WarnMsg: res.WarnMsg,
  25678. Cainfo: res.Cainfo,
  25679. ErrMsg: res.ErrMsg,
  25680. RespondTime: res.RefmsgTime,
  25681. InfRefmsgid: res.InfRefmsgid,
  25682. OrderStatus: 1,
  25683. PayWay: pay_way,
  25684. PayWays: pay_ways,
  25685. OthDesc: oth_desc,
  25686. PayPrice: pay_price,
  25687. PayCardNo: pay_card_no,
  25688. DiscountPrice: discount_price,
  25689. PreferentialPrice: preferential_price,
  25690. RealityPrice: reality_price,
  25691. FoundPrice: found_price,
  25692. MedicalInsurancePrice: medical_insurance_price,
  25693. PrivatePrice: private_price,
  25694. IsMedicineInsurance: 1,
  25695. SettleType: settle_accounts_type,
  25696. SettleStartTime: start_time,
  25697. SettleEndTime: end_time,
  25698. Creator: roles.AdminUserId,
  25699. Modify: roles.AdminUserId,
  25700. FaPiaoNumber: fapiao_number,
  25701. FaPiaoCode: fapiao_code,
  25702. PType: 2,
  25703. Diagnosis: diagnosis_id,
  25704. CashPay: cash_pay,
  25705. WechatPay: wechat_pay,
  25706. AliPay: ali_pay,
  25707. JifenPay: jifen_pay,
  25708. BandCardPay: band_card_pay,
  25709. }
  25710. err = service.CreateOrder(order)
  25711. if err != nil {
  25712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25713. return
  25714. }
  25715. for _, item := range res.Output.Result {
  25716. temp := strings.Split(item.FeedetlSn, "-")
  25717. var advice_id int64 = 0
  25718. var project_id int64 = 0
  25719. var types int64 = 0
  25720. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25721. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25722. if temp[1] == "1" {
  25723. advice_id = id
  25724. project_id = 0
  25725. } else if temp[1] == "2" {
  25726. advice_id = 0
  25727. project_id = id
  25728. }
  25729. if item.MedChrgitmType == "9" {
  25730. item.MedChrgitmType = "09"
  25731. }
  25732. info := &models.HisOrderInfo{
  25733. OrderNumber: order.Number,
  25734. FeedetlSn: item.FeedetlSn,
  25735. UploadDate: time.Now().Unix(),
  25736. AdviceId: advice_id,
  25737. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25738. Cnt: item.Cnt,
  25739. Pric: float64(item.Pric),
  25740. PatientId: his.PatientId,
  25741. PricUplmtAmt: item.PricUplmtAmt,
  25742. SelfpayProp: item.SelfpayProp,
  25743. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25744. OverlmtAmt: item.OverlmtAmt,
  25745. PreselfpayAmt: item.PreselfpayAmt,
  25746. BasMednFlag: item.BasMednFlag,
  25747. MedChrgitmType: item.MedChrgitmType,
  25748. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25749. Status: 1,
  25750. Memo: item.Memo,
  25751. Mtime: time.Now().Unix(),
  25752. InscpScpAmt: item.InscpScpAmt,
  25753. DrtReimFlag: item.DrtReimFlag,
  25754. Ctime: time.Now().Unix(),
  25755. ListSpItemFlag: item.ListSpItemFlag,
  25756. ChldMedcFlag: item.ChldMedcFlag,
  25757. LmtUsedFlag: item.LmtUsedFlag,
  25758. ChrgitmLv: item.ChrgitmLv,
  25759. UserOrgId: adminUser.CurrentOrgId,
  25760. HisPatientId: his.ID,
  25761. OrderId: order.ID,
  25762. ProjectId: project_id,
  25763. Type: types,
  25764. }
  25765. service.CreateOrderInfo(info)
  25766. }
  25767. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25768. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25769. var total float64
  25770. for _, item := range prescriptions {
  25771. if item.Type == 1 { //药品
  25772. for _, subItem := range item.HisDoctorAdviceInfo {
  25773. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25774. total_one := price * subItem.PrescribingNumber
  25775. total = total + total_one
  25776. }
  25777. }
  25778. if item.Type == 2 { //项目
  25779. for _, subItem := range item.HisPrescriptionProject {
  25780. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25781. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25782. total_one := price * cnt
  25783. total = total + total_one
  25784. }
  25785. }
  25786. }
  25787. allTotal := fmt.Sprintf("%.2f", total)
  25788. //if adminUser.CurrentOrgId == 9919 {
  25789. //
  25790. // allTotal = fmt.Sprintf("%.2f", total)
  25791. //
  25792. //} else {
  25793. //
  25794. // allTotal = fmt.Sprintf("%.2f", total)
  25795. //
  25796. //}
  25797. if res.Infcode == 0 {
  25798. var rf []*ResultFive
  25799. json.Unmarshal([]byte(his.Iinfo), &rf)
  25800. chrg_bchno := chrg_bchno
  25801. cert_no := his.Certno
  25802. var insutypes []string
  25803. var insutype string
  25804. var is390 int = 0
  25805. var is310 int = 0
  25806. for _, item := range rf {
  25807. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25808. insutypes = append(insutypes, item.Insutype)
  25809. }
  25810. }
  25811. if len(insutypes) == 1 {
  25812. insutype = insutypes[0]
  25813. } else {
  25814. for _, i := range insutypes {
  25815. if i == "390" {
  25816. is390 = 1
  25817. }
  25818. if i == "310" {
  25819. is310 = 1
  25820. }
  25821. }
  25822. }
  25823. if is390 == 1 {
  25824. insutype = "390"
  25825. }
  25826. if is310 == 1 {
  25827. insutype = "310"
  25828. }
  25829. if len(insutypes) == 0 {
  25830. insutype = "310"
  25831. }
  25832. if len(insutypes) == 2 {
  25833. insutype = strconv.FormatInt(his.SocialType, 10)
  25834. }
  25835. insutype = strconv.FormatInt(his.SocialType, 10)
  25836. //insutype = "390"
  25837. if his.IdCardType == 1 {
  25838. // cert_no = his.MedicalInsuranceNumber
  25839. cert_no = his.Certno
  25840. } else {
  25841. cert_no = his.Certno
  25842. }
  25843. var res ResultSeven
  25844. var resSeven10265 ResultSeven10265
  25845. var gzresSeven10265Two GZResultSeven10265Two
  25846. var src_resquest string
  25847. var result2 string
  25848. if miConfig.MdtrtareaAdmvs == "421300" {
  25849. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25850. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25851. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25852. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25853. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25854. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25855. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25856. resp, requestErr := http.Get(api)
  25857. if requestErr != nil {
  25858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25859. return
  25860. }
  25861. body, ioErr := ioutil.ReadAll(resp.Body)
  25862. if ioErr != nil {
  25863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25865. return
  25866. }
  25867. var respJSON map[string]interface{}
  25868. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25871. return
  25872. }
  25873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25874. result, _ := json.Marshal(respJSON)
  25875. if miConfig.Code == "H15049901371" {
  25876. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25877. utils.ErrorLog("解析失败:%v", err)
  25878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25879. return
  25880. }
  25881. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25882. res.Output = resSeven10265.Output
  25883. res.ErrMsg = resSeven10265.ErrMsg
  25884. res.Cainfo = resSeven10265.Cainfo
  25885. res.WarnMsg = resSeven10265.WarnMsg
  25886. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25887. res.Infcode = infocode
  25888. } else {
  25889. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25890. utils.ErrorLog("解析失败:%v", err)
  25891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25892. return
  25893. }
  25894. }
  25895. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25896. if reg_type == 11 && his.Insutype == "390" {
  25897. reg_type = 110104
  25898. }
  25899. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25900. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25901. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25902. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25903. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25904. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25905. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25906. resp, requestErr := http.Get(api)
  25907. if requestErr != nil {
  25908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25909. return
  25910. }
  25911. body, ioErr := ioutil.ReadAll(resp.Body)
  25912. if ioErr != nil {
  25913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25915. return
  25916. }
  25917. var respJSON map[string]interface{}
  25918. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25921. return
  25922. }
  25923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25924. result, _ := json.Marshal(respJSON)
  25925. if miConfig.Code == "H15049901371" {
  25926. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25927. utils.ErrorLog("解析失败:%v", err)
  25928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25929. return
  25930. }
  25931. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25932. res.Output = resSeven10265.Output
  25933. res.ErrMsg = resSeven10265.ErrMsg
  25934. res.Cainfo = resSeven10265.Cainfo
  25935. res.WarnMsg = resSeven10265.WarnMsg
  25936. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25937. res.Infcode = infocode
  25938. } else {
  25939. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25940. utils.ErrorLog("解析失败:%v", err)
  25941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25942. return
  25943. }
  25944. }
  25945. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25946. if reg_type == 11 && his.Insutype == "390" {
  25947. reg_type = 110104
  25948. }
  25949. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25950. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25951. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25952. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25953. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25954. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25955. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25956. resp, requestErr := http.Get(api)
  25957. if requestErr != nil {
  25958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25959. return
  25960. }
  25961. body, ioErr := ioutil.ReadAll(resp.Body)
  25962. if ioErr != nil {
  25963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25965. return
  25966. }
  25967. var respJSON map[string]interface{}
  25968. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25971. return
  25972. }
  25973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25974. result, _ := json.Marshal(respJSON)
  25975. if miConfig.Code == "H15049901371" {
  25976. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25977. utils.ErrorLog("解析失败:%v", err)
  25978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25979. return
  25980. }
  25981. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25982. res.Output = resSeven10265.Output
  25983. res.ErrMsg = resSeven10265.ErrMsg
  25984. res.Cainfo = resSeven10265.Cainfo
  25985. res.WarnMsg = resSeven10265.WarnMsg
  25986. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25987. res.Infcode = infocode
  25988. } else {
  25989. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25990. utils.ErrorLog("解析失败:%v", err)
  25991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25992. return
  25993. }
  25994. }
  25995. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25996. if reg_type == 11 && his.Insutype == "390" {
  25997. reg_type = 110104
  25998. }
  25999. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26000. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26001. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26002. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26003. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26004. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26005. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26006. resp, requestErr := http.Get(api)
  26007. if requestErr != nil {
  26008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26009. return
  26010. }
  26011. body, ioErr := ioutil.ReadAll(resp.Body)
  26012. if ioErr != nil {
  26013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26015. return
  26016. }
  26017. var respJSON map[string]interface{}
  26018. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26021. return
  26022. }
  26023. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26024. result, _ := json.Marshal(respJSON)
  26025. if miConfig.Code == "H15049901371" {
  26026. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26027. utils.ErrorLog("解析失败:%v", err)
  26028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26029. return
  26030. }
  26031. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26032. res.Output = resSeven10265.Output
  26033. res.ErrMsg = resSeven10265.ErrMsg
  26034. res.Cainfo = resSeven10265.Cainfo
  26035. res.WarnMsg = resSeven10265.WarnMsg
  26036. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26037. res.Infcode = infocode
  26038. } else {
  26039. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26040. utils.ErrorLog("解析失败:%v", err)
  26041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26042. return
  26043. }
  26044. }
  26045. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26046. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26047. if result3101.Infcode == "0" {
  26048. if len(result3101.Output.Result) > 0 {
  26049. var errMsgs []string
  26050. for _, item := range result3101.Output.Result {
  26051. errMsgs = append(errMsgs, item.VolaCont)
  26052. }
  26053. c.ServeSuccessJSON(map[string]interface{}{
  26054. "failed_code": -10,
  26055. "msg": errMsgs,
  26056. })
  26057. return
  26058. } else {
  26059. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26060. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26061. bas := strings.Split(psn_info.CardInfo, "|")
  26062. if his.IdCardType == 1 {
  26063. cert_no = bas[2]
  26064. } else if his.IdCardType == 3 {
  26065. cert_no = his.Certno
  26066. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26067. } else if his.IdCardType == 4 {
  26068. cert_no = his.Certno
  26069. psn_info.VerifyNumber = psn_info.VerifyNumber
  26070. }
  26071. var api string
  26072. if miConfig.MdtrtareaAdmvs == "320921" {
  26073. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26074. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26075. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26076. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26077. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26078. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26079. "&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
  26080. } else {
  26081. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26082. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26083. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26084. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26085. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26086. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26087. "&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
  26088. }
  26089. resp, requestErr := http.Get(api)
  26090. if requestErr != nil {
  26091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26092. return
  26093. }
  26094. body, ioErr := ioutil.ReadAll(resp.Body)
  26095. if ioErr != nil {
  26096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26098. return
  26099. }
  26100. var respJSON map[string]interface{}
  26101. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26104. return
  26105. }
  26106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26107. result, _ := json.Marshal(respJSON)
  26108. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26109. utils.ErrorLog("解析失败:%v", err)
  26110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26111. return
  26112. }
  26113. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26114. res.Output = resSeven10265.Output
  26115. res.ErrMsg = resSeven10265.ErrMsg
  26116. res.Cainfo = resSeven10265.Cainfo
  26117. res.WarnMsg = resSeven10265.WarnMsg
  26118. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26119. res.Infcode = infocode
  26120. }
  26121. }
  26122. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26123. psn_info, _ := service.GetPsnByPatientId(id)
  26124. var verify_number string
  26125. if psn_info.IdCardType == 4 {
  26126. verify_number = psn_info.VerifyNumber
  26127. } else if psn_info.IdCardType == 1 {
  26128. bas := strings.Split(psn_info.CardInfo, "|")
  26129. cardNumber := bas[2]
  26130. verify_number = cardNumber
  26131. } else {
  26132. psn_info.IdCardType = 2
  26133. verify_number = psn_info.Certno
  26134. }
  26135. var api string
  26136. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26137. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26138. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26139. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26140. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26141. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26142. "&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
  26143. resp, requestErr := http.Get(api)
  26144. if requestErr != nil {
  26145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26146. return
  26147. }
  26148. body, ioErr := ioutil.ReadAll(resp.Body)
  26149. if ioErr != nil {
  26150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26152. return
  26153. }
  26154. var respJSON map[string]interface{}
  26155. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26158. return
  26159. }
  26160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26161. result, _ := json.Marshal(respJSON)
  26162. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26163. utils.ErrorLog("解析失败:%v", err)
  26164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26165. return
  26166. }
  26167. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26168. res.Output = resSeven10265.Output
  26169. res.ErrMsg = resSeven10265.ErrMsg
  26170. res.Cainfo = resSeven10265.Cainfo
  26171. res.WarnMsg = resSeven10265.WarnMsg
  26172. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26173. res.Infcode = infocode
  26174. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26175. var cert_no string
  26176. if his.IdCardType == 4 {
  26177. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26178. cert_no = psn_info.VerifyNumber
  26179. 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)
  26180. } else if his.IdCardType == 1 {
  26181. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26182. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26183. 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)
  26184. }
  26185. //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)
  26186. var dat map[string]interface{}
  26187. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26188. fmt.Println(dat)
  26189. } else {
  26190. fmt.Println(err)
  26191. }
  26192. saveLog(result2, src_resquest, "2207", "结算")
  26193. userJSONBytes, _ := json.Marshal(dat)
  26194. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26195. utils.ErrorLog("解析失败:%v", err)
  26196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26197. return
  26198. }
  26199. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26200. res.Output = resSeven10265.Output
  26201. res.ErrMsg = resSeven10265.ErrMsg
  26202. res.Cainfo = resSeven10265.Cainfo
  26203. res.WarnMsg = resSeven10265.WarnMsg
  26204. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26205. res.Infcode = infocode
  26206. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26207. res2 := c.GetoleInfo()
  26208. if res2.Infcode == 0 {
  26209. var result string
  26210. var request_log string
  26211. var result_log string
  26212. if res2.Output.MdtrtCertType == "02" {
  26213. 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)
  26214. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26215. } else if res2.Output.MdtrtCertType == "01" {
  26216. 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)
  26217. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26218. } else {
  26219. 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)
  26220. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26221. }
  26222. var dat map[string]interface{}
  26223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26224. fmt.Println(dat)
  26225. } else {
  26226. fmt.Println(err)
  26227. }
  26228. userJSONBytes, _ := json.Marshal(dat)
  26229. var res5 ResultTwo
  26230. //var resTwo10265 ResultTwo10265
  26231. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26232. utils.ErrorLog("解析失败:%v", err)
  26233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26234. return
  26235. }
  26236. if res5.Infcode == -1 {
  26237. c.ServeSuccessJSON(map[string]interface{}{
  26238. "failed_code": -10,
  26239. "msg": res5.ErrMsg,
  26240. })
  26241. return
  26242. }
  26243. var insutypes []string
  26244. var insutype string
  26245. var is390 int = 0
  26246. var is310 int = 0
  26247. for _, item := range res5.Output.Iinfo {
  26248. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26249. insutypes = append(insutypes, item.Insutype)
  26250. }
  26251. }
  26252. if len(insutypes) == 1 {
  26253. insutype = insutypes[0]
  26254. } else {
  26255. for _, i := range insutypes {
  26256. if i == "390" {
  26257. is390 = 1
  26258. }
  26259. if i == "310" {
  26260. is310 = 1
  26261. }
  26262. }
  26263. }
  26264. if is390 == 1 {
  26265. insutype = "390"
  26266. }
  26267. if is310 == 1 {
  26268. insutype = "310"
  26269. }
  26270. if len(insutypes) == 0 {
  26271. insutype = "310"
  26272. }
  26273. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26274. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26275. infoStr := string(Iinfos)
  26276. idetinfoStr := string(Idetinfos)
  26277. psn := &models.HisPsn{
  26278. PsnNo: res5.Output.Baseinfo.PsnNo,
  26279. PatientId: id,
  26280. Certno: res5.Output.Baseinfo.Certno,
  26281. Gend: res5.Output.Baseinfo.Gend,
  26282. Naty: res5.Output.Baseinfo.Naty,
  26283. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26284. PsnName: res5.Output.Baseinfo.PsnName,
  26285. Idetinfo: idetinfoStr,
  26286. Insuinfo: infoStr,
  26287. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26288. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26289. VerifyNumber: res2.Output.EcToken,
  26290. }
  26291. if res2.Output.MdtrtCertType == "01" {
  26292. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26293. psn.VerifyNumber = res2.Output.EcToken
  26294. } else if res2.Output.MdtrtCertType == "02" {
  26295. psn.VerifyNumber = res2.Output.CardNo
  26296. } else {
  26297. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26298. }
  26299. service.CreateHisPsn(psn)
  26300. if res2.Output.MdtrtCertType == "01" {
  26301. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26302. token := res2.Output.EcToken
  26303. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 4, acct_used_flag, token, admin_user_id)
  26304. } else if res2.Output.MdtrtCertType == "02" {
  26305. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 2, acct_used_flag, "", admin_user_id)
  26306. } else {
  26307. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 1, acct_used_flag, "", admin_user_id)
  26308. }
  26309. var dat2 map[string]interface{}
  26310. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26311. fmt.Println(dat2)
  26312. } else {
  26313. fmt.Println(err)
  26314. }
  26315. userJSONBytes3, _ := json.Marshal(dat2)
  26316. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26317. utils.ErrorLog("解析失败:%v", err)
  26318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26319. return
  26320. }
  26321. saveLog(result2, src_resquest, "2207", "结算")
  26322. } else {
  26323. c.ServeSuccessJSON(map[string]interface{}{
  26324. "failed_code": -10,
  26325. "msg": res2.ErrMsg,
  26326. })
  26327. return
  26328. }
  26329. } else {
  26330. if miConfig.Code == "H15049901371" {
  26331. //赤峰地区国家医保医疗类别
  26332. //职工透析:医疗类别选特殊情况门诊990502
  26333. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26334. var med_type string
  26335. if his.Insutype == "390" {
  26336. if reg_type == 14 {
  26337. med_type = "9933"
  26338. } else if reg_type == 11 {
  26339. med_type = "11"
  26340. }
  26341. } else if his.Insutype == "310" {
  26342. if reg_type == 14 {
  26343. med_type = "990502"
  26344. } else if reg_type == 11 {
  26345. med_type = "11"
  26346. }
  26347. }
  26348. 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)
  26349. } else {
  26350. if his.IdCardType == 4 {
  26351. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26352. var token string
  26353. token = psn_info.VerifyNumber
  26354. 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)
  26355. } else {
  26356. if his.IdCardType == 1 {
  26357. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26358. bas := strings.Split(psn_info.CardInfo, "|")
  26359. basNumber := bas[2]
  26360. cert_no = basNumber
  26361. }
  26362. 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)
  26363. }
  26364. }
  26365. //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)
  26366. var dat map[string]interface{}
  26367. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26368. fmt.Println(dat)
  26369. } else {
  26370. fmt.Println(err)
  26371. }
  26372. saveLog(result2, src_resquest, "2207", "结算")
  26373. userJSONBytes, _ := json.Marshal(dat)
  26374. if miConfig.Code == "H15049901371" {
  26375. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26376. utils.ErrorLog("解析失败:%v", err)
  26377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26378. return
  26379. }
  26380. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26381. res.Output = resSeven10265.Output
  26382. res.ErrMsg = resSeven10265.ErrMsg
  26383. res.Cainfo = resSeven10265.Cainfo
  26384. res.WarnMsg = resSeven10265.WarnMsg
  26385. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26386. res.Infcode = infocode
  26387. } else {
  26388. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26389. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26390. utils.ErrorLog("解析失败:%v", err)
  26391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26392. return
  26393. }
  26394. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26395. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26396. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26397. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26398. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26399. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26400. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26401. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26402. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26403. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26404. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26405. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26406. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26407. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26408. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26409. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26410. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26411. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26412. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26413. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26414. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26415. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26416. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26417. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26418. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26419. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26420. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26421. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26422. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26423. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26424. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26425. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26426. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26427. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26428. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26429. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26430. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26431. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26432. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26433. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26434. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26435. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26436. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26437. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26438. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26439. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26440. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26441. res.Cainfo = gzresSeven10265Two.Cainfo
  26442. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26443. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26444. //res.Infcode = infocode
  26445. } else {
  26446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26447. utils.ErrorLog("解析失败:%v", err)
  26448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26449. return
  26450. }
  26451. }
  26452. }
  26453. }
  26454. if res.Infcode == -1 {
  26455. errlog := &models.HisOrderError{
  26456. UserOrgId: adminUser.CurrentOrgId,
  26457. Ctime: time.Now().Unix(),
  26458. Mtime: time.Now().Unix(),
  26459. Number: chrg_bchno,
  26460. ErrMsg: res.ErrMsg,
  26461. Status: 1,
  26462. PatientId: id,
  26463. RecordTime: recordDateTime,
  26464. Stage: 6,
  26465. }
  26466. service.CreateErrMsgLog(errlog)
  26467. c.ServeSuccessJSON(map[string]interface{}{
  26468. "failed_code": -10,
  26469. "msg": res.ErrMsg,
  26470. })
  26471. return
  26472. } else {
  26473. sickConfig, _ := service.FindSickById(his.SickType)
  26474. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26475. order.OrderStatus = 2
  26476. order.Status = 1
  26477. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26478. order.SetlId = res.Output.Setlinfo.SetlID
  26479. order.PsnNo = res.Output.Setlinfo.PsnNo
  26480. order.PsnName = res.Output.Setlinfo.PsnName
  26481. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26482. order.Certno = res.Output.Setlinfo.Certno
  26483. order.Gend = res.Output.Setlinfo.Gend
  26484. order.Naty = res.Output.Setlinfo.Naty
  26485. order.Age = res.Output.Setlinfo.Age
  26486. order.Insutype = res.Output.Setlinfo.Insutype
  26487. order.PsnType = res.Output.Setlinfo.PsnType
  26488. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26489. order.SetlTime = res.Output.Setlinfo.SetlTime
  26490. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26491. if res.Output.Setlinfo.MedType == "140101" {
  26492. order.MedType = "14"
  26493. } else {
  26494. if res.Output.Setlinfo.MedType == "110104" {
  26495. order.MedType = "11"
  26496. } else {
  26497. order.MedType = res.Output.Setlinfo.MedType
  26498. }
  26499. }
  26500. if reg_type == 1112 {
  26501. order.MedType = "1112"
  26502. }
  26503. if reg_type == 1111 {
  26504. order.MedType = "1111"
  26505. }
  26506. order.ClrType = res.Output.Setlinfo.ClrType
  26507. if adminUser.CurrentOrgId == 10480 {
  26508. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26509. order.ClrType = "11"
  26510. } else {
  26511. order.ClrType = "9903"
  26512. }
  26513. }
  26514. if adminUser.CurrentOrgId == 10721 {
  26515. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26516. order.ClrType = "11"
  26517. } else {
  26518. order.ClrType = "9903"
  26519. }
  26520. }
  26521. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26522. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26523. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26524. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26525. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26526. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26527. order.HifpPay = res.Output.Setlinfo.HifpPay
  26528. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26529. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26530. order.HifesPay = res.Output.Setlinfo.HifesPay
  26531. order.HifobPay = res.Output.Setlinfo.HifobPay
  26532. order.MafPay = res.Output.Setlinfo.MafPay
  26533. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26534. order.OthPay = res.Output.Setlinfo.OthPay
  26535. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26536. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26537. order.AcctPay = res.Output.Setlinfo.AcctPay
  26538. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26539. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26540. order.Balc = res.Output.Setlinfo.Balc
  26541. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26542. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26543. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26544. //order.ClrType = res.Output.Setlinfo.ClrType
  26545. order.ClrWay = res.Output.Setlinfo.ClrWay
  26546. order.Creator = order.Creator
  26547. order.Modify = roles.AdminUserId
  26548. order.RequestLog = src_resquest
  26549. order.FaPiaoNumber = fapiao_number
  26550. order.FaPiaoCode = fapiao_code
  26551. order.SickName = sickConfig.ClassName
  26552. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26553. //detailStr := string(setlDetail)
  26554. //order.SetlDetail = detailStr
  26555. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26556. err = service.UpDateOrder(order)
  26557. if err == nil {
  26558. //判断是否使用了押金
  26559. if dec_way == "true" {
  26560. tmpstring := strconv.FormatInt(order.ID, 10)
  26561. order.Decimal = decimal
  26562. service.UpDateOrder(order)
  26563. //扣押金
  26564. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26565. if errmsg != nil {
  26566. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26567. return
  26568. }
  26569. }
  26570. c.ServeSuccessJSON(map[string]interface{}{
  26571. "msg": "结算成功",
  26572. })
  26573. } else {
  26574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26575. return
  26576. }
  26577. }
  26578. } else {
  26579. adminUser := c.GetAdminUserInfo()
  26580. errlog := &models.HisOrderError{
  26581. UserOrgId: adminUser.CurrentOrgId,
  26582. Ctime: time.Now().Unix(),
  26583. Mtime: time.Now().Unix(),
  26584. ErrMsg: res.ErrMsg,
  26585. Status: 1,
  26586. PatientId: id,
  26587. RecordTime: recordDateTime,
  26588. Stage: 4,
  26589. }
  26590. service.CreateErrMsgLog(errlog)
  26591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26592. return
  26593. }
  26594. } else {
  26595. adminUser := c.GetAdminUserInfo()
  26596. errlog := &models.HisOrderError{
  26597. UserOrgId: adminUser.CurrentOrgId,
  26598. Ctime: time.Now().Unix(),
  26599. Mtime: time.Now().Unix(),
  26600. ErrMsg: res.ErrMsg,
  26601. Status: 1,
  26602. PatientId: id,
  26603. RecordTime: recordDateTime,
  26604. Stage: 4,
  26605. }
  26606. service.CreateErrMsgLog(errlog)
  26607. c.ServeSuccessJSON(map[string]interface{}{
  26608. "failed_code": -10,
  26609. "msg": res.ErrMsg,
  26610. })
  26611. return
  26612. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26613. //return
  26614. }
  26615. }
  26616. }
  26617. } else if tempOrder.ID > 0 {
  26618. if tempOrder.IsPre == 1 {
  26619. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26620. var rf []*ResultFive
  26621. json.Unmarshal([]byte(his.Iinfo), &rf)
  26622. chrg_bchno := tempOrder.Number
  26623. cert_no := his.Certno
  26624. var insutypes []string
  26625. var insutype string
  26626. var is390 int = 0
  26627. var is310 int = 0
  26628. for _, item := range rf {
  26629. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26630. insutypes = append(insutypes, item.Insutype)
  26631. }
  26632. }
  26633. if len(insutypes) == 1 {
  26634. insutype = insutypes[0]
  26635. } else {
  26636. for _, i := range insutypes {
  26637. if i == "390" {
  26638. is390 = 1
  26639. }
  26640. if i == "310" {
  26641. is310 = 1
  26642. }
  26643. }
  26644. }
  26645. if is390 == 1 {
  26646. insutype = "390"
  26647. }
  26648. if is310 == 1 {
  26649. insutype = "310"
  26650. }
  26651. if len(insutypes) == 0 {
  26652. insutype = "310"
  26653. }
  26654. if len(insutypes) == 2 {
  26655. insutype = strconv.FormatInt(his.SocialType, 10)
  26656. }
  26657. //insutype = "390"
  26658. if his.IdCardType == 1 {
  26659. // cert_no = his.MedicalInsuranceNumber
  26660. cert_no = his.Certno
  26661. } else {
  26662. cert_no = his.Certno
  26663. }
  26664. var res ResultSeven
  26665. var ahres ResultSevenAH
  26666. var resSeven10265 ResultSeven10265
  26667. var gzresSeven10265Two GZResultSeven10265Two
  26668. var src_resquest string
  26669. var result2 string
  26670. if miConfig.MdtrtareaAdmvs == "450721" {
  26671. res2 := c.GetoleInfo()
  26672. if res2.Infcode == 0 {
  26673. var result string
  26674. var request_log string
  26675. var result_log string
  26676. if res2.Output.MdtrtCertType == "02" {
  26677. 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)
  26678. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26679. } else if res2.Output.MdtrtCertType == "01" {
  26680. 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)
  26681. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26682. } else {
  26683. 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)
  26684. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26685. }
  26686. var dat map[string]interface{}
  26687. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26688. fmt.Println(dat)
  26689. } else {
  26690. fmt.Println(err)
  26691. }
  26692. userJSONBytes, _ := json.Marshal(dat)
  26693. var res5 ResultTwo
  26694. //var resTwo10265 ResultTwo10265
  26695. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26696. utils.ErrorLog("解析失败:%v", err)
  26697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26698. return
  26699. }
  26700. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26701. if res5.Infcode == -1 {
  26702. c.ServeSuccessJSON(map[string]interface{}{
  26703. "failed_code": -10,
  26704. "msg": res5.ErrMsg,
  26705. })
  26706. return
  26707. }
  26708. var insutypes []string
  26709. var insutype string
  26710. var is390 int = 0
  26711. var is310 int = 0
  26712. for _, item := range res5.Output.Iinfo {
  26713. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26714. insutypes = append(insutypes, item.Insutype)
  26715. }
  26716. }
  26717. if len(insutypes) == 1 {
  26718. insutype = insutypes[0]
  26719. } else {
  26720. for _, i := range insutypes {
  26721. if i == "390" {
  26722. is390 = 1
  26723. }
  26724. if i == "310" {
  26725. is310 = 1
  26726. }
  26727. }
  26728. }
  26729. if is390 == 1 {
  26730. insutype = "390"
  26731. }
  26732. if is310 == 1 {
  26733. insutype = "310"
  26734. }
  26735. if len(insutypes) == 0 {
  26736. insutype = "310"
  26737. }
  26738. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26739. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26740. infoStr := string(Iinfos)
  26741. idetinfoStr := string(Idetinfos)
  26742. psn := &models.HisPsn{
  26743. PsnNo: res5.Output.Baseinfo.PsnNo,
  26744. PatientId: id,
  26745. Certno: res5.Output.Baseinfo.Certno,
  26746. Gend: res5.Output.Baseinfo.Gend,
  26747. Naty: res5.Output.Baseinfo.Naty,
  26748. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26749. PsnName: res5.Output.Baseinfo.PsnName,
  26750. Idetinfo: idetinfoStr,
  26751. Insuinfo: infoStr,
  26752. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26753. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26754. VerifyNumber: res2.Output.EcToken,
  26755. }
  26756. service.CreateHisPsn(psn)
  26757. if res2.Output.MdtrtCertType == "01" {
  26758. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26759. token := res2.Output.EcToken
  26760. 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)
  26761. } else if res2.Output.MdtrtCertType == "02" {
  26762. 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)
  26763. } else {
  26764. 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)
  26765. }
  26766. var dat2 map[string]interface{}
  26767. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26768. fmt.Println(dat2)
  26769. } else {
  26770. fmt.Println(err)
  26771. }
  26772. userJSONBytes3, _ := json.Marshal(dat2)
  26773. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26774. utils.ErrorLog("解析失败:%v", err)
  26775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26776. return
  26777. }
  26778. saveLog(result2, src_resquest, "2207", "结算")
  26779. } else {
  26780. c.ServeSuccessJSON(map[string]interface{}{
  26781. "failed_code": -10,
  26782. "msg": res2.ErrMsg,
  26783. })
  26784. return
  26785. }
  26786. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26787. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26788. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26789. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26790. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26791. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26792. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26793. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26794. resp, requestErr := http.Get(api)
  26795. if requestErr != nil {
  26796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26797. return
  26798. }
  26799. body, ioErr := ioutil.ReadAll(resp.Body)
  26800. if ioErr != nil {
  26801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26803. return
  26804. }
  26805. var respJSON map[string]interface{}
  26806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26809. return
  26810. }
  26811. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26812. result, _ := json.Marshal(respJSON)
  26813. fmt.Println("log")
  26814. fmt.Println(string(result))
  26815. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26816. utils.ErrorLog("解析失败:%v", err)
  26817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26818. return
  26819. }
  26820. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26821. if reg_type == 11 && his.Insutype == "390" {
  26822. reg_type = 110104
  26823. }
  26824. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26825. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26826. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26827. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26828. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26829. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26830. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26831. resp, requestErr := http.Get(api)
  26832. if requestErr != nil {
  26833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26834. return
  26835. }
  26836. body, ioErr := ioutil.ReadAll(resp.Body)
  26837. if ioErr != nil {
  26838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26840. return
  26841. }
  26842. var respJSON map[string]interface{}
  26843. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26846. return
  26847. }
  26848. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26849. result, _ := json.Marshal(respJSON)
  26850. fmt.Println("log")
  26851. fmt.Println(string(result))
  26852. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26853. utils.ErrorLog("解析失败:%v", err)
  26854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26855. return
  26856. }
  26857. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26858. if reg_type == 11 && his.Insutype == "390" {
  26859. reg_type = 110104
  26860. }
  26861. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26862. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26863. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26864. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26865. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26866. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26867. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26868. resp, requestErr := http.Get(api)
  26869. if requestErr != nil {
  26870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26871. return
  26872. }
  26873. body, ioErr := ioutil.ReadAll(resp.Body)
  26874. if ioErr != nil {
  26875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26877. return
  26878. }
  26879. var respJSON map[string]interface{}
  26880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26883. return
  26884. }
  26885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26886. result, _ := json.Marshal(respJSON)
  26887. fmt.Println("log")
  26888. fmt.Println(string(result))
  26889. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26890. utils.ErrorLog("解析失败:%v", err)
  26891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26892. return
  26893. }
  26894. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26895. if reg_type == 11 && his.Insutype == "390" {
  26896. reg_type = 110104
  26897. }
  26898. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26899. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26900. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26901. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26902. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26903. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26904. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26905. resp, requestErr := http.Get(api)
  26906. if requestErr != nil {
  26907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26908. return
  26909. }
  26910. body, ioErr := ioutil.ReadAll(resp.Body)
  26911. if ioErr != nil {
  26912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26914. return
  26915. }
  26916. var respJSON map[string]interface{}
  26917. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26920. return
  26921. }
  26922. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26923. result, _ := json.Marshal(respJSON)
  26924. fmt.Println("log")
  26925. fmt.Println(string(result))
  26926. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26927. utils.ErrorLog("解析失败:%v", err)
  26928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26929. return
  26930. }
  26931. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26932. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  26933. if result3101.Infcode == "0" {
  26934. if len(result3101.Output.Result) > 0 {
  26935. var errMsgs []string
  26936. for _, item := range result3101.Output.Result {
  26937. errMsgs = append(errMsgs, item.VolaCont)
  26938. }
  26939. c.ServeSuccessJSON(map[string]interface{}{
  26940. "failed_code": -10,
  26941. "msg": errMsgs,
  26942. })
  26943. return
  26944. } else {
  26945. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26946. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26947. bas := strings.Split(psn_info.CardInfo, "|")
  26948. if his.IdCardType == 1 {
  26949. cert_no = bas[2]
  26950. } else if his.IdCardType == 3 {
  26951. cert_no = his.Certno
  26952. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26953. } else if his.IdCardType == 4 {
  26954. cert_no = his.Certno
  26955. psn_info.VerifyNumber = psn_info.VerifyNumber
  26956. }
  26957. //江苏地区国家医保医疗类别
  26958. //职工透析:医疗类别选特殊情况门诊9933
  26959. //居民血透门慢: 医疗类别选门诊慢病1402
  26960. //var med_type string
  26961. //if his.Insutype == "310" {
  26962. // if reg_type == 14 {
  26963. // med_type = "9933"
  26964. // } else if reg_type == 11 {
  26965. // med_type = "11"
  26966. //
  26967. // }
  26968. //} else if his.Insutype == "390" {
  26969. // if reg_type == 14 {
  26970. // med_type = "1402"
  26971. // } else if reg_type == 11 {
  26972. // med_type = "11"
  26973. // }
  26974. //}
  26975. var api string
  26976. if miConfig.MdtrtareaAdmvs == "320921" {
  26977. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26978. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26979. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26980. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26981. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26982. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26983. "&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
  26984. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26985. } else {
  26986. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26987. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26988. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26989. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26990. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26991. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26992. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26993. "&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
  26994. }
  26995. resp, requestErr := http.Get(api)
  26996. if requestErr != nil {
  26997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26998. return
  26999. }
  27000. body, ioErr := ioutil.ReadAll(resp.Body)
  27001. if ioErr != nil {
  27002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27004. return
  27005. }
  27006. var respJSON map[string]interface{}
  27007. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27010. return
  27011. }
  27012. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27013. result, _ := json.Marshal(respJSON)
  27014. fmt.Println("log")
  27015. fmt.Println(string(result))
  27016. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27017. utils.ErrorLog("解析失败:%v", err)
  27018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27019. return
  27020. }
  27021. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27022. res.Output = resSeven10265.Output
  27023. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27024. res.ErrMsg = resSeven10265.ErrMsg
  27025. res.Cainfo = resSeven10265.Cainfo
  27026. res.WarnMsg = resSeven10265.WarnMsg
  27027. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27028. res.Infcode = infocode
  27029. }
  27030. }
  27031. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27032. psn_info, _ := service.GetPsnByPatientId(id)
  27033. var verify_number string
  27034. if psn_info.IdCardType == 4 {
  27035. verify_number = psn_info.VerifyNumber
  27036. } else if psn_info.IdCardType == 1 {
  27037. bas := strings.Split(psn_info.CardInfo, "|")
  27038. cardNumber := bas[2]
  27039. verify_number = cardNumber
  27040. } else {
  27041. verify_number = psn_info.Certno
  27042. psn_info.IdCardType = 2
  27043. }
  27044. var api string
  27045. new_chrg_bchno := chrg_bchno
  27046. if adminUser.CurrentOrgId == 10265 {
  27047. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27048. new_chrg_bchno = "0000"
  27049. }
  27050. }
  27051. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27052. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27053. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27054. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27055. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27056. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27057. "&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
  27058. resp, requestErr := http.Get(api)
  27059. if requestErr != nil {
  27060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27061. return
  27062. }
  27063. body, ioErr := ioutil.ReadAll(resp.Body)
  27064. if ioErr != nil {
  27065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27067. return
  27068. }
  27069. var respJSON map[string]interface{}
  27070. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27073. return
  27074. }
  27075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27076. result, _ := json.Marshal(respJSON)
  27077. fmt.Println("log")
  27078. fmt.Println(string(result))
  27079. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27080. utils.ErrorLog("解析失败:%v", err)
  27081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27082. return
  27083. }
  27084. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27085. res.Output = resSeven10265.Output
  27086. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27087. res.ErrMsg = resSeven10265.ErrMsg
  27088. res.Cainfo = resSeven10265.Cainfo
  27089. res.WarnMsg = resSeven10265.WarnMsg
  27090. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27091. res.Infcode = infocode
  27092. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27093. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27094. var cert_no string
  27095. if his.IdCardType == 1 {
  27096. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27097. } else {
  27098. cert_no = psn_info.VerifyNumber
  27099. }
  27100. 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)
  27101. var dat map[string]interface{}
  27102. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27103. fmt.Println(dat)
  27104. } else {
  27105. fmt.Println(err)
  27106. }
  27107. saveLog(result2, src_resquest, "2207", "结算")
  27108. userJSONBytes, _ := json.Marshal(dat)
  27109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27110. utils.ErrorLog("解析失败:%v", err)
  27111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27112. return
  27113. }
  27114. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27115. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27116. var cert_no string
  27117. var card_sn string
  27118. if his.IdCardType == 1 {
  27119. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27120. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27121. bas := strings.Split(psn_info.CardInfo, "|")
  27122. card_sn = bas[3]
  27123. } else if his.IdCardType == 2 {
  27124. cert_no = his.IdCardNo
  27125. } else {
  27126. cert_no = psn_info.VerifyNumber
  27127. }
  27128. var rf []*ResultFive
  27129. json.Unmarshal([]byte(his.Iinfo), &rf)
  27130. var psn_type string
  27131. for _, item := range rf {
  27132. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27133. psn_type = item.PsnType
  27134. }
  27135. }
  27136. 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)
  27137. var dat map[string]interface{}
  27138. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27139. fmt.Println(dat)
  27140. } else {
  27141. fmt.Println(err)
  27142. }
  27143. saveLog(result2, src_resquest, "2207", "结算")
  27144. userJSONBytes, _ := json.Marshal(dat)
  27145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27146. utils.ErrorLog("解析失败:%v", err)
  27147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27148. return
  27149. }
  27150. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27151. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27152. var cert_no string
  27153. var card_sn string
  27154. if his.IdCardType == 1 {
  27155. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27156. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27157. //bas := strings.Split(psn_info.CardInfo, "|")
  27158. card_sn = ""
  27159. } else if his.IdCardType == 2 {
  27160. cert_no = his.IdCardNo
  27161. } else {
  27162. cert_no = psn_info.VerifyNumber
  27163. }
  27164. var rf []*ResultFive
  27165. json.Unmarshal([]byte(his.Iinfo), &rf)
  27166. var psn_type string
  27167. for _, item := range rf {
  27168. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27169. psn_type = item.PsnType
  27170. }
  27171. }
  27172. 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)
  27173. var dat map[string]interface{}
  27174. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27175. fmt.Println(dat)
  27176. } else {
  27177. fmt.Println(err)
  27178. }
  27179. saveLog(result2, src_resquest, "2207", "结算")
  27180. userJSONBytes, _ := json.Marshal(dat)
  27181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27182. utils.ErrorLog("解析失败:%v", err)
  27183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27184. return
  27185. }
  27186. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27187. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27188. if his.IdCardType == 1 {
  27189. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27190. bas := strings.Split(psn_info.CardInfo, "|")
  27191. cert_no = bas[2]
  27192. } else if his.IdCardType == 3 {
  27193. cert_no = his.Certno
  27194. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27195. } else if his.IdCardType == 4 {
  27196. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27197. cert_no = psn_info.VerifyNumber
  27198. psn_info.VerifyNumber = psn_info.VerifyNumber
  27199. } else {
  27200. cert_no = his.Certno
  27201. psn_info.VerifyNumber = his.Certno
  27202. }
  27203. var api string
  27204. var med_type string
  27205. if his.Insutype == "390" {
  27206. if reg_type == 992102 {
  27207. med_type = "992102"
  27208. }
  27209. if reg_type == 140104 {
  27210. med_type = "140104"
  27211. }
  27212. if reg_type == 140201 {
  27213. med_type = "140201"
  27214. }
  27215. if reg_type == 14 {
  27216. med_type = "14"
  27217. }
  27218. } else if his.Insutype == "310" {
  27219. if reg_type == 992102 {
  27220. med_type = "992102"
  27221. }
  27222. if reg_type == 140104 {
  27223. med_type = "140104"
  27224. }
  27225. if reg_type == 140201 {
  27226. med_type = "140201"
  27227. }
  27228. if reg_type == 14 {
  27229. med_type = "14"
  27230. }
  27231. }
  27232. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27233. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27234. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27235. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27236. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27237. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27238. "&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
  27239. resp, requestErr := http.Get(api)
  27240. if requestErr != nil {
  27241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27242. return
  27243. }
  27244. body, ioErr := ioutil.ReadAll(resp.Body)
  27245. if ioErr != nil {
  27246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27248. return
  27249. }
  27250. var respJSON map[string]interface{}
  27251. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27254. return
  27255. }
  27256. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27257. if status == "0" {
  27258. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27259. c.ServeSuccessJSON(map[string]interface{}{
  27260. "failed_code": -10,
  27261. "msg": err_msg,
  27262. })
  27263. return
  27264. }
  27265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27266. result, _ := json.Marshal(respJSON)
  27267. fmt.Println("log")
  27268. fmt.Println(string(result))
  27269. if err := json.Unmarshal(result, &ahres); err != nil {
  27270. utils.ErrorLog("解析失败:%v", err)
  27271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27272. return
  27273. }
  27274. res.InfRefmsgid = ahres.InfRefmsgid
  27275. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27276. // 创建对应的Time类型
  27277. t := time.UnixMilli(timestamp)
  27278. // 格式化成指定的日期字符串
  27279. str := t.Format("2006-01-02 15:04:05")
  27280. res.Output.Setlinfo.SetlTime = str
  27281. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27282. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27283. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27284. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27285. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27286. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27287. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27288. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27289. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27290. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27291. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27292. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27293. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27294. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27295. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27296. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27297. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27298. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27299. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27300. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27301. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27302. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27303. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27304. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27305. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27306. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27307. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27308. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27309. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27310. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27311. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27312. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27313. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27314. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27315. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27316. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27317. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27318. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27319. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27320. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27321. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27322. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27323. res.Output.Setldetail = ahres.Output.Setldetail
  27324. res.ErrMsg = ahres.ErrMsg
  27325. res.Cainfo = ahres.Cainfo
  27326. res.WarnMsg = ahres.WarnMsg
  27327. res.Infcode = ahres.Infcode
  27328. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27329. res.Output.Setlinfo.ClrType = "11"
  27330. } else {
  27331. res.Output.Setlinfo.ClrType = "9903"
  27332. }
  27333. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27334. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27335. if his.IdCardType == 1 {
  27336. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27337. bas := strings.Split(psn_info.CardInfo, "|")
  27338. cert_no = bas[2]
  27339. } else if his.IdCardType == 3 {
  27340. cert_no = his.Certno
  27341. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27342. } else if his.IdCardType == 4 {
  27343. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27344. cert_no = his.Certno
  27345. psn_info.VerifyNumber = psn_info.VerifyNumber
  27346. } else {
  27347. cert_no = his.Certno
  27348. psn_info.VerifyNumber = his.Certno
  27349. }
  27350. var api string
  27351. var med_type string
  27352. if his.Insutype == "390" {
  27353. if reg_type == 992102 {
  27354. med_type = "992102"
  27355. }
  27356. if reg_type == 140104 {
  27357. med_type = "140104"
  27358. }
  27359. if reg_type == 14 {
  27360. med_type = "14"
  27361. }
  27362. if reg_type == 140201 {
  27363. med_type = "140201"
  27364. }
  27365. } else if his.Insutype == "310" {
  27366. if reg_type == 992102 {
  27367. med_type = "992102"
  27368. }
  27369. if reg_type == 14 {
  27370. med_type = "14"
  27371. }
  27372. if reg_type == 140104 {
  27373. med_type = "140104"
  27374. }
  27375. if reg_type == 140201 {
  27376. med_type = "140201"
  27377. }
  27378. }
  27379. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27380. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27381. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27382. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27383. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27384. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27385. "&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
  27386. resp, requestErr := http.Get(api)
  27387. if requestErr != nil {
  27388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27389. return
  27390. }
  27391. body, ioErr := ioutil.ReadAll(resp.Body)
  27392. if ioErr != nil {
  27393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27395. return
  27396. }
  27397. var respJSON map[string]interface{}
  27398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27401. return
  27402. }
  27403. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27404. if status == "0" {
  27405. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27406. c.ServeSuccessJSON(map[string]interface{}{
  27407. "failed_code": -10,
  27408. "msg": err_msg,
  27409. })
  27410. return
  27411. }
  27412. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27413. result, _ := json.Marshal(respJSON)
  27414. fmt.Println("log")
  27415. fmt.Println(string(result))
  27416. if err := json.Unmarshal(result, &ahres); err != nil {
  27417. utils.ErrorLog("解析失败:%v", err)
  27418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27419. return
  27420. }
  27421. res.InfRefmsgid = ahres.InfRefmsgid
  27422. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27423. // 创建对应的Time类型
  27424. t := time.UnixMilli(timestamp)
  27425. // 格式化成指定的日期字符串
  27426. str := t.Format("2006-01-02 15:04:05")
  27427. res.Output.Setlinfo.SetlTime = str
  27428. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27429. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27430. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27431. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27432. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27433. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27434. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27435. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27436. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27437. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27438. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27439. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27440. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27441. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27442. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27443. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27444. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27445. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27446. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27447. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27448. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27449. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27450. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27451. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27452. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27453. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27454. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27455. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27456. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27457. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27458. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27459. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27460. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27461. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27462. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27463. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27464. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27465. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27466. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27467. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27468. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27469. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27470. res.Output.Setldetail = ahres.Output.Setldetail
  27471. res.ErrMsg = ahres.ErrMsg
  27472. res.Cainfo = ahres.Cainfo
  27473. res.WarnMsg = ahres.WarnMsg
  27474. res.Infcode = ahres.Infcode
  27475. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27476. res.Output.Setlinfo.ClrType = "11"
  27477. } else {
  27478. res.Output.Setlinfo.ClrType = "9903"
  27479. }
  27480. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27481. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27482. var cert_no string
  27483. if his.IdCardType == 1 {
  27484. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27485. } else if his.IdCardType == 2 {
  27486. cert_no = his.IdCardNo
  27487. } else {
  27488. cert_no = psn_info.VerifyNumber
  27489. }
  27490. 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, "")
  27491. var dat map[string]interface{}
  27492. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27493. fmt.Println(dat)
  27494. } else {
  27495. fmt.Println(err)
  27496. }
  27497. saveLog(result2, src_resquest, "2207", "结算")
  27498. userJSONBytes, _ := json.Marshal(dat)
  27499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27500. utils.ErrorLog("解析失败:%v", err)
  27501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27502. return
  27503. }
  27504. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27505. psn_info, _ := service.GetPsnByPatientId(id)
  27506. var verify_number string
  27507. if psn_info.IdCardType == 4 {
  27508. verify_number = psn_info.VerifyNumber
  27509. } else if psn_info.IdCardType == 1 {
  27510. bas := strings.Split(psn_info.CardInfo, "|")
  27511. cardNumber := bas[2]
  27512. verify_number = cardNumber
  27513. } else {
  27514. verify_number = psn_info.Certno
  27515. psn_info.IdCardType = 2
  27516. }
  27517. var api string
  27518. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27519. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27520. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27521. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27522. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27523. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27524. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27525. resp, requestErr := http.Get(api)
  27526. if requestErr != nil {
  27527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27528. return
  27529. }
  27530. body, ioErr := ioutil.ReadAll(resp.Body)
  27531. if ioErr != nil {
  27532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27534. return
  27535. }
  27536. var respJSON map[string]interface{}
  27537. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27540. return
  27541. }
  27542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27543. result, _ := json.Marshal(respJSON)
  27544. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27545. utils.ErrorLog("解析失败:%v", err)
  27546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27547. return
  27548. }
  27549. } else {
  27550. var src_resquest string
  27551. if miConfig.Code == "H15049901371" {
  27552. //赤峰地区国家医保医疗类别
  27553. //职工透析:医疗类别选特殊情况门诊990502
  27554. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27555. var med_type string
  27556. if his.Insutype == "390" {
  27557. if reg_type == 14 {
  27558. med_type = "9933"
  27559. } else if reg_type == 11 {
  27560. med_type = "11"
  27561. }
  27562. } else if his.Insutype == "310" {
  27563. if reg_type == 14 {
  27564. med_type = "990502"
  27565. } else if reg_type == 11 {
  27566. med_type = "11"
  27567. }
  27568. }
  27569. 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)
  27570. } else {
  27571. if his.IdCardType == 4 {
  27572. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27573. token := psn_info.VerifyNumber
  27574. 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)
  27575. } else {
  27576. 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)
  27577. }
  27578. }
  27579. var dat map[string]interface{}
  27580. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27581. fmt.Println(dat)
  27582. } else {
  27583. fmt.Println(err)
  27584. }
  27585. saveLog(result2, src_resquest, "2207", "结算")
  27586. userJSONBytes, _ := json.Marshal(dat)
  27587. if miConfig.Code == "H15049901371" {
  27588. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27589. utils.ErrorLog("解析失败:%v", err)
  27590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27591. return
  27592. }
  27593. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27594. res.Output = resSeven10265.Output
  27595. res.ErrMsg = resSeven10265.ErrMsg
  27596. res.Cainfo = resSeven10265.Cainfo
  27597. res.WarnMsg = resSeven10265.WarnMsg
  27598. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27599. res.Infcode = infocode
  27600. } else {
  27601. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27602. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27603. utils.ErrorLog("解析失败:%v", err)
  27604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27605. return
  27606. }
  27607. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27608. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27609. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27610. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27611. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27612. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27613. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27614. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27615. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27616. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27617. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27618. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27619. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27620. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27621. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27622. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27623. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27624. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27625. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27626. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27627. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27628. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27629. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27630. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27631. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27632. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27633. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27634. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27635. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27636. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27637. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27638. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27639. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27640. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27641. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27642. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27643. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27644. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27645. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27646. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27647. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27648. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27649. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27650. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27651. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27652. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27653. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27654. res.Cainfo = gzresSeven10265Two.Cainfo
  27655. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27656. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27657. //res.Infcode = infocode
  27658. } else {
  27659. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27660. utils.ErrorLog("解析失败:%v", err)
  27661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27662. return
  27663. }
  27664. }
  27665. }
  27666. }
  27667. if res.Infcode == -1 {
  27668. errlog := &models.HisOrderError{
  27669. UserOrgId: adminUser.CurrentOrgId,
  27670. Ctime: time.Now().Unix(),
  27671. Mtime: time.Now().Unix(),
  27672. Number: chrg_bchno,
  27673. ErrMsg: res.ErrMsg,
  27674. Status: 1,
  27675. PatientId: id,
  27676. RecordTime: recordDateTime,
  27677. Stage: 6,
  27678. }
  27679. service.CreateErrMsgLog(errlog)
  27680. c.ServeSuccessJSON(map[string]interface{}{
  27681. "failed_code": -10,
  27682. "msg": res.ErrMsg,
  27683. })
  27684. return
  27685. } else {
  27686. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27687. order.OrderStatus = 2
  27688. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27689. order.SetlId = res.Output.Setlinfo.SetlID
  27690. order.PsnNo = res.Output.Setlinfo.PsnNo
  27691. order.PsnName = res.Output.Setlinfo.PsnName
  27692. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27693. order.Certno = res.Output.Setlinfo.Certno
  27694. order.Gend = res.Output.Setlinfo.Gend
  27695. order.Naty = res.Output.Setlinfo.Naty
  27696. order.Age = res.Output.Setlinfo.Age
  27697. order.Insutype = res.Output.Setlinfo.Insutype
  27698. order.PsnType = res.Output.Setlinfo.PsnType
  27699. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27700. order.SetlTime = res.Output.Setlinfo.SetlTime
  27701. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27702. order.PayWays = pay_ways
  27703. order.AcctUsedFlag = acct_used_flag
  27704. order.WechatPay = wechat_pay
  27705. order.AliPay = ali_pay
  27706. order.JifenPay = jifen_pay
  27707. order.BandCardPay = band_card_pay
  27708. order.CashPay = cash_pay
  27709. order.OthDesc = oth_desc
  27710. //order.MedType = res.Output.Setlinfo.MedType
  27711. if reg_type == 1112 {
  27712. order.MedType = "1112"
  27713. }
  27714. if reg_type == 1111 {
  27715. order.MedType = "1111"
  27716. }
  27717. order.ClrType = res.Output.Setlinfo.ClrType
  27718. if adminUser.CurrentOrgId == 10480 {
  27719. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27720. order.ClrType = "11"
  27721. } else {
  27722. order.ClrType = "9903"
  27723. }
  27724. }
  27725. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27726. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27727. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27728. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27729. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27730. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27731. order.HifpPay = res.Output.Setlinfo.HifpPay
  27732. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27733. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27734. order.HifesPay = res.Output.Setlinfo.HifesPay
  27735. order.HifobPay = res.Output.Setlinfo.HifobPay
  27736. order.MafPay = res.Output.Setlinfo.MafPay
  27737. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27738. order.OthPay = res.Output.Setlinfo.OthPay
  27739. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27740. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27741. order.AcctPay = res.Output.Setlinfo.AcctPay
  27742. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27743. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27744. order.Balc = res.Output.Setlinfo.Balc
  27745. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27746. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27747. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27748. order.ClrWay = res.Output.Setlinfo.ClrWay
  27749. order.Creator = order.Creator
  27750. order.Modify = roles.AdminUserId
  27751. order.RequestLog = src_resquest
  27752. order.Diagnosis = diagnosis_id
  27753. order.FaPiaoNumber = fapiao_number
  27754. order.FaPiaoCode = fapiao_code
  27755. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27756. detailStr := string(setlDetail)
  27757. order.SetlDetail = detailStr
  27758. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27759. err = service.UpDateOrder(order)
  27760. if err == nil {
  27761. //判断是否使用了押金
  27762. if dec_way == "true" {
  27763. tmpstring := strconv.FormatInt(order.ID, 10)
  27764. //扣押金
  27765. order.Decimal = decimal
  27766. service.UpDateOrder(order)
  27767. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27768. if errmsg != nil {
  27769. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27770. return
  27771. }
  27772. }
  27773. c.ServeSuccessJSON(map[string]interface{}{
  27774. "msg": "结算成功",
  27775. })
  27776. } else {
  27777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27778. return
  27779. }
  27780. }
  27781. }
  27782. }
  27783. }
  27784. // 上传明细-预结算-
  27785. func (c *HisApiController) GetPreUploadInfo() {
  27786. id, _ := c.GetInt64("id")
  27787. record_time := c.GetString("record_time")
  27788. his_patient_id, _ := c.GetInt64("his_patient_id")
  27789. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27790. admin_user_id, _ := c.GetInt64("admin_user_id")
  27791. diagnosis_id := c.GetString("diagnosis")
  27792. sick_type, _ := c.GetInt64("sick_type")
  27793. reg_type, _ := c.GetInt64("p_type")
  27794. begin_time := c.GetString("begin_time")
  27795. acct_used_flag := c.GetString("acct_used_flag")
  27796. id_str := c.GetString("ids")
  27797. ids_arr := strings.Split(id_str, ",")
  27798. timeLayout := "2006-01-02"
  27799. loc, _ := time.LoadLocation("Local")
  27800. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27801. if err != nil {
  27802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27803. return
  27804. }
  27805. recordDateTime := theTime.Unix()
  27806. adminUser := c.GetAdminUserInfo()
  27807. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27808. var config []*models.HisXtDiagnoseConfig
  27809. for _, item := range diagnosis_ids {
  27810. id, _ := strconv.ParseInt(item, 10, 64)
  27811. if id > 0 {
  27812. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27813. config = append(config, &diagnosisConfig)
  27814. }
  27815. }
  27816. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27817. sickConfig, _ := service.FindSickById(sick_type)
  27818. var prescriptions []*models.HisPrescription
  27819. var start_time int64
  27820. var end_time int64
  27821. var isSuccess bool = true
  27822. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27823. fmt.Println(his_patient_id)
  27824. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27825. timestamp := time.Now().Unix()
  27826. tempTime := time.Unix(timestamp, 0)
  27827. timeFormat := tempTime.Format("20060102150405")
  27828. chrgBchno := rand.Intn(100000) + 10000
  27829. new_chrg_bchno := ""
  27830. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27831. new_chrg_bchno = chrg_bchno
  27832. if adminUser.CurrentOrgId == 10265 {
  27833. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27834. new_chrg_bchno = "0000"
  27835. }
  27836. }
  27837. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27838. var patientPrescription models.HisPrescriptionInfo
  27839. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27840. if patientPrescription.ID == 0 {
  27841. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27842. }
  27843. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27844. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27845. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27846. strconv.FormatInt(his.PatientId, 10)
  27847. var res2406 Result2406
  27848. //安徽单病种处理
  27849. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27850. data := make(map[string]interface{})
  27851. client := &http.Client{}
  27852. data["psn_no"] = his.PsnNo
  27853. data["mdtrt_id"] = his.Number
  27854. data["operator"] = roles.UserName
  27855. data["cert_no"] = his.IdCardNo
  27856. data["org_name"] = miConfig.OrgName
  27857. data["psn_name"] = his.Name
  27858. data["ipt_otp_no"] = his.IptOtpNo
  27859. data["ipt_psn_sp_flag_type"] = "0901"
  27860. data["ipt_psn_sp_flag"] = "1"
  27861. data["fixmedins_code"] = miConfig.Code
  27862. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27863. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27864. data["url"] = miConfig.Url
  27865. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27866. bytesData, _ := json.Marshal(data)
  27867. var req *http.Request
  27868. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27869. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27870. resp, _ := client.Do(req)
  27871. defer resp.Body.Close()
  27872. body, ioErr := ioutil.ReadAll(resp.Body)
  27873. if ioErr != nil {
  27874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27876. return
  27877. }
  27878. var respJSON map[string]interface{}
  27879. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27882. return
  27883. }
  27884. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27885. if status == "0" {
  27886. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27887. c.ServeSuccessJSON(map[string]interface{}{
  27888. "failed_code": -10,
  27889. "msg": err_msg,
  27890. })
  27891. return
  27892. }
  27893. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27894. userJSONBytes, _ := json.Marshal(respJSON)
  27895. fmt.Println("log")
  27896. fmt.Println(string(userJSONBytes))
  27897. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27898. utils.ErrorLog("解析失败:%v", err)
  27899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27900. return
  27901. }
  27902. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  27903. data := make(map[string]interface{})
  27904. client := &http.Client{}
  27905. data["psn_no"] = his.PsnNo
  27906. data["mdtrt_id"] = his.Number
  27907. data["operator"] = roles.UserName
  27908. data["cert_no"] = his.IdCardNo
  27909. data["org_name"] = miConfig.OrgName
  27910. data["psn_name"] = his.Name
  27911. data["ipt_otp_no"] = his.IptOtpNo
  27912. data["ipt_psn_sp_flag_type"] = "0901"
  27913. data["ipt_psn_sp_flag"] = "1"
  27914. data["fixmedins_code"] = miConfig.Code
  27915. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27916. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27917. data["url"] = miConfig.Url
  27918. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27919. bytesData, _ := json.Marshal(data)
  27920. var req *http.Request
  27921. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27922. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27923. resp, _ := client.Do(req)
  27924. defer resp.Body.Close()
  27925. body, ioErr := ioutil.ReadAll(resp.Body)
  27926. if ioErr != nil {
  27927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27929. return
  27930. }
  27931. var respJSON map[string]interface{}
  27932. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27935. return
  27936. }
  27937. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27938. if status == "0" {
  27939. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27940. c.ServeSuccessJSON(map[string]interface{}{
  27941. "failed_code": -10,
  27942. "msg": err_msg,
  27943. })
  27944. return
  27945. }
  27946. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27947. userJSONBytes, _ := json.Marshal(respJSON)
  27948. fmt.Println("log")
  27949. fmt.Println(string(userJSONBytes))
  27950. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27951. utils.ErrorLog("解析失败:%v", err)
  27952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27953. return
  27954. }
  27955. }
  27956. if res2406.Infcode != 0 {
  27957. adminUser := c.GetAdminUserInfo()
  27958. errlog := &models.HisOrderError{
  27959. UserOrgId: adminUser.CurrentOrgId,
  27960. Ctime: time.Now().Unix(),
  27961. Mtime: time.Now().Unix(),
  27962. ErrMsg: res2406.ErrMsg,
  27963. Status: 1,
  27964. PatientId: id,
  27965. RecordTime: recordDateTime,
  27966. Stage: 3,
  27967. }
  27968. service.CreateErrMsgLog(errlog)
  27969. c.ServeSuccessJSON(map[string]interface{}{
  27970. "failed_code": -10,
  27971. "msg": res2406.ErrMsg,
  27972. })
  27973. return
  27974. }
  27975. var res2 ResultSix
  27976. var res3 GZResultSix
  27977. var resSix10265 ResultSix10265
  27978. //var time_stamp string
  27979. if miConfig.MdtrtareaAdmvs == "421300" {
  27980. data := make(map[string]interface{})
  27981. client := &http.Client{}
  27982. data["psn_no"] = his.PsnNo
  27983. data["mdtrt_id"] = his.Number
  27984. data["department"] = department.Name
  27985. data["org_name"] = miConfig.OrgName
  27986. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27987. data["doctor_id"] = doctor_info.DoctorNumber
  27988. data["doctor_name"] = roles.UserName
  27989. data["fixmedins_code"] = miConfig.Code
  27990. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27991. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27992. data["secret_key"] = miConfig.SecretKey
  27993. data["sick_code"] = sickConfig.CountryCode
  27994. data["sick_name"] = sickConfig.ClassName
  27995. data["begin_time"] = begin_time
  27996. data["dept"] = strconv.FormatInt(department.ID, 10)
  27997. data["config"] = config
  27998. data["opter"] = roles.UserName
  27999. fmt.Println(data)
  28000. bytesData, _ := json.Marshal(data)
  28001. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28002. resp, _ := client.Do(req)
  28003. defer resp.Body.Close()
  28004. body, ioErr := ioutil.ReadAll(resp.Body)
  28005. if ioErr != nil {
  28006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28008. return
  28009. }
  28010. var respJSON map[string]interface{}
  28011. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28014. return
  28015. }
  28016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28017. userJSONBytes, _ := json.Marshal(respJSON)
  28018. fmt.Println("log")
  28019. fmt.Println(string(userJSONBytes))
  28020. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28021. utils.ErrorLog("解析失败:%v", err)
  28022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28023. return
  28024. }
  28025. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28026. data := make(map[string]interface{})
  28027. client := &http.Client{}
  28028. data["psn_no"] = his.PsnNo
  28029. data["mdtrt_id"] = his.Number
  28030. data["department"] = department.Name
  28031. data["org_name"] = miConfig.OrgName
  28032. if reg_type == 11 && his.Insutype == "390" {
  28033. data["med_type"] = "110104"
  28034. } else {
  28035. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28036. }
  28037. data["doctor_id"] = doctor_info.DoctorNumber
  28038. data["doctor_name"] = roles.UserName
  28039. data["fixmedins_code"] = miConfig.Code
  28040. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28041. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28042. data["secret_key"] = miConfig.SecretKey
  28043. data["sick_code"] = sickConfig.CountryCode
  28044. data["sick_name"] = sickConfig.ClassName
  28045. data["begin_time"] = begin_time
  28046. data["dept"] = strconv.FormatInt(department.ID, 10)
  28047. data["config"] = config
  28048. data["opter"] = roles.UserName
  28049. fmt.Println(data)
  28050. bytesData, _ := json.Marshal(data)
  28051. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28052. resp, _ := client.Do(req)
  28053. defer resp.Body.Close()
  28054. body, ioErr := ioutil.ReadAll(resp.Body)
  28055. if ioErr != nil {
  28056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28058. return
  28059. }
  28060. var respJSON map[string]interface{}
  28061. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28064. return
  28065. }
  28066. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28067. userJSONBytes, _ := json.Marshal(respJSON)
  28068. fmt.Println("log")
  28069. fmt.Println(string(userJSONBytes))
  28070. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28071. utils.ErrorLog("解析失败:%v", err)
  28072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28073. return
  28074. }
  28075. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28076. data := make(map[string]interface{})
  28077. client := &http.Client{}
  28078. data["psn_no"] = his.PsnNo
  28079. data["mdtrt_id"] = his.Number
  28080. data["department"] = department.Name
  28081. data["org_name"] = miConfig.OrgName
  28082. if reg_type == 11 && his.Insutype == "390" {
  28083. data["med_type"] = "110104"
  28084. } else {
  28085. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28086. }
  28087. data["doctor_id"] = doctor_info.DoctorNumber
  28088. data["doctor_name"] = roles.UserName
  28089. data["fixmedins_code"] = miConfig.Code
  28090. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28091. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28092. data["secret_key"] = miConfig.SecretKey
  28093. data["sick_code"] = sickConfig.CountryCode
  28094. data["sick_name"] = sickConfig.ClassName
  28095. data["begin_time"] = begin_time
  28096. data["dept"] = strconv.FormatInt(department.ID, 10)
  28097. data["config"] = config
  28098. data["opter"] = roles.UserName
  28099. fmt.Println(data)
  28100. bytesData, _ := json.Marshal(data)
  28101. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28102. resp, _ := client.Do(req)
  28103. defer resp.Body.Close()
  28104. body, ioErr := ioutil.ReadAll(resp.Body)
  28105. if ioErr != nil {
  28106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28108. return
  28109. }
  28110. var respJSON map[string]interface{}
  28111. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28114. return
  28115. }
  28116. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28117. userJSONBytes, _ := json.Marshal(respJSON)
  28118. fmt.Println("log")
  28119. fmt.Println(string(userJSONBytes))
  28120. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28121. utils.ErrorLog("解析失败:%v", err)
  28122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28123. return
  28124. }
  28125. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28126. data := make(map[string]interface{})
  28127. client := &http.Client{}
  28128. data["psn_no"] = his.PsnNo
  28129. data["mdtrt_id"] = his.Number
  28130. data["department"] = department.Name
  28131. data["org_name"] = miConfig.OrgName
  28132. if reg_type == 11 && his.Insutype == "390" {
  28133. data["med_type"] = "110104"
  28134. } else {
  28135. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28136. }
  28137. data["doctor_id"] = doctor_info.DoctorNumber
  28138. data["doctor_name"] = roles.UserName
  28139. data["fixmedins_code"] = miConfig.Code
  28140. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28141. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28142. data["secret_key"] = miConfig.SecretKey
  28143. data["sick_code"] = sickConfig.CountryCode
  28144. data["sick_name"] = sickConfig.ClassName
  28145. data["begin_time"] = begin_time
  28146. data["dept"] = strconv.FormatInt(department.ID, 10)
  28147. data["config"] = config
  28148. data["opter"] = roles.UserName
  28149. fmt.Println(data)
  28150. bytesData, _ := json.Marshal(data)
  28151. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28152. resp, _ := client.Do(req)
  28153. defer resp.Body.Close()
  28154. body, ioErr := ioutil.ReadAll(resp.Body)
  28155. if ioErr != nil {
  28156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28158. return
  28159. }
  28160. var respJSON map[string]interface{}
  28161. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28164. return
  28165. }
  28166. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28167. userJSONBytes, _ := json.Marshal(respJSON)
  28168. fmt.Println("log")
  28169. fmt.Println(string(userJSONBytes))
  28170. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28171. utils.ErrorLog("解析失败:%v", err)
  28172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28173. return
  28174. }
  28175. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28176. data := make(map[string]interface{})
  28177. client := &http.Client{}
  28178. data["psn_no"] = his.PsnNo
  28179. data["mdtrt_id"] = his.Number
  28180. data["doctor"] = roles.UserName
  28181. data["department"] = department.Name
  28182. data["org_name"] = miConfig.OrgName
  28183. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28184. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28185. data["fixmedins_code"] = miConfig.Code
  28186. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28187. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28188. data["secret_key"] = miConfig.SecretKey
  28189. data["sick_code"] = sickConfig.CountryCode
  28190. data["sick_name"] = sickConfig.ClassName
  28191. data["begin_time"] = begin_time
  28192. data["dept"] = strconv.FormatInt(department.ID, 10)
  28193. data["config"] = config
  28194. data["url"] = miConfig.Url
  28195. data["ak"] = miConfig.AccessKey
  28196. data["cainfo"] = miConfig.Cainfo
  28197. bytesData, _ := json.Marshal(data)
  28198. var req *http.Request
  28199. if miConfig.MdtrtareaAdmvs == "320921" {
  28200. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28201. } else {
  28202. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28203. }
  28204. resp, _ := client.Do(req)
  28205. defer resp.Body.Close()
  28206. body, ioErr := ioutil.ReadAll(resp.Body)
  28207. if ioErr != nil {
  28208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28210. return
  28211. }
  28212. var respJSON map[string]interface{}
  28213. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28216. return
  28217. }
  28218. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28219. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28220. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28222. userJSONBytes, _ := json.Marshal(respJSON)
  28223. fmt.Println("log")
  28224. fmt.Println(string(userJSONBytes))
  28225. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28226. utils.ErrorLog("解析失败:%v", err)
  28227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28228. return
  28229. }
  28230. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28231. res2.Output = resSix10265.Output
  28232. res2.ErrMsg = resSix10265.ErrMsg
  28233. res2.Cainfo = resSix10265.Cainfo
  28234. res2.WarnMsg = resSix10265.WarnMsg
  28235. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28236. res2.Infcode = infocode
  28237. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28238. data := make(map[string]interface{})
  28239. client := &http.Client{}
  28240. data["psn_no"] = his.PsnNo
  28241. data["mdtrt_id"] = his.Number
  28242. data["doctor"] = roles.UserName
  28243. data["department"] = department.Name
  28244. data["org_name"] = miConfig.OrgName
  28245. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28246. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28247. data["fixmedins_code"] = miConfig.Code
  28248. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28249. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28250. data["secret_key"] = miConfig.SecretKey
  28251. data["sick_code"] = sickConfig.CountryCode
  28252. data["sick_name"] = sickConfig.ClassName
  28253. data["begin_time"] = begin_time
  28254. data["dept"] = strconv.FormatInt(department.ID, 10)
  28255. data["config"] = config
  28256. //data["url"] = miConfig.Url
  28257. //data["ak"] = miConfig.AccessKey
  28258. data["cainfo"] = miConfig.Cainfo
  28259. fmt.Println(data)
  28260. bytesData, _ := json.Marshal(data)
  28261. var req *http.Request
  28262. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28263. resp, _ := client.Do(req)
  28264. defer resp.Body.Close()
  28265. body, ioErr := ioutil.ReadAll(resp.Body)
  28266. if ioErr != nil {
  28267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28269. return
  28270. }
  28271. var respJSON map[string]interface{}
  28272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28275. return
  28276. }
  28277. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28278. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28279. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28281. userJSONBytes, _ := json.Marshal(respJSON)
  28282. fmt.Println("log")
  28283. fmt.Println(string(userJSONBytes))
  28284. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28285. utils.ErrorLog("解析失败:%v", err)
  28286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28287. return
  28288. }
  28289. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28290. res2.Output = resSix10265.Output
  28291. res2.ErrMsg = resSix10265.ErrMsg
  28292. res2.Cainfo = resSix10265.Cainfo
  28293. res2.WarnMsg = resSix10265.WarnMsg
  28294. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28295. res2.Infcode = infocode
  28296. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28297. 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)
  28298. saveLog(result, requestLog, "2203", "上传就诊信息")
  28299. var respJSON2 map[string]interface{}
  28300. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28303. return
  28304. }
  28305. userJSONBytes2, _ := json.Marshal(respJSON2)
  28306. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28307. utils.ErrorLog("解析失败:%v", err)
  28308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28309. return
  28310. }
  28311. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28312. var result string
  28313. var requestLog string
  28314. 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, "")
  28315. saveLog(result, requestLog, "2203", "上传就诊信息")
  28316. var respJSON2 map[string]interface{}
  28317. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28320. return
  28321. }
  28322. userJSONBytes2, _ := json.Marshal(respJSON2)
  28323. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28324. utils.ErrorLog("解析失败:%v", err)
  28325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28326. return
  28327. }
  28328. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28329. var result string
  28330. var requestLog string
  28331. 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, "")
  28332. saveLog(result, requestLog, "2203", "上传就诊信息")
  28333. var respJSON2 map[string]interface{}
  28334. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28337. return
  28338. }
  28339. userJSONBytes2, _ := json.Marshal(respJSON2)
  28340. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28341. utils.ErrorLog("解析失败:%v", err)
  28342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28343. return
  28344. }
  28345. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28346. data := make(map[string]interface{})
  28347. client := &http.Client{}
  28348. data["psn_no"] = his.PsnNo
  28349. data["mdtrt_id"] = his.Number
  28350. data["operator"] = roles.UserName
  28351. data["department"] = department.Name
  28352. data["org_name"] = miConfig.OrgName
  28353. var med_type string
  28354. if his.Insutype == "390" {
  28355. if reg_type == 992102 {
  28356. med_type = "992102"
  28357. data["sick_code"] = "ZDZ940"
  28358. data["sick_name"] = "慢性肾衰竭"
  28359. }
  28360. if reg_type == 140104 {
  28361. med_type = "140104"
  28362. data["sick_code"] = sickConfig.CountryCode
  28363. data["sick_name"] = sickConfig.ClassName
  28364. }
  28365. if reg_type == 14 {
  28366. med_type = "140104"
  28367. data["sick_code"] = sickConfig.CountryCode
  28368. data["sick_name"] = sickConfig.ClassName
  28369. }
  28370. } else if his.Insutype == "310" {
  28371. if reg_type == 992102 {
  28372. med_type = "992102"
  28373. data["sick_code"] = "ZDZ940"
  28374. data["sick_name"] = "慢性肾衰竭"
  28375. }
  28376. if reg_type == 140104 {
  28377. med_type = "140104"
  28378. data["sick_code"] = sickConfig.CountryCode
  28379. data["sick_name"] = sickConfig.ClassName
  28380. }
  28381. if reg_type == 14 {
  28382. med_type = "14"
  28383. data["sick_code"] = sickConfig.CountryCode
  28384. data["sick_name"] = sickConfig.ClassName
  28385. }
  28386. }
  28387. data["med_type"] = med_type
  28388. data["doctor_number"] = doctor_info.DoctorNumber
  28389. data["doctor_name"] = doctor_info.UserName
  28390. data["fixmedins_code"] = miConfig.Code
  28391. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28392. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28393. data["secret_key"] = miConfig.SecretKey
  28394. data["begin_time"] = begin_time
  28395. data["dept"] = strconv.FormatInt(department.ID, 10)
  28396. data["config"] = config
  28397. data["url"] = miConfig.Url
  28398. data["ak"] = miConfig.AccessKey
  28399. data["cainfo"] = miConfig.Cainfo
  28400. bytesData, _ := json.Marshal(data)
  28401. var req *http.Request
  28402. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28403. resp, _ := client.Do(req)
  28404. defer resp.Body.Close()
  28405. body, ioErr := ioutil.ReadAll(resp.Body)
  28406. if ioErr != nil {
  28407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28409. return
  28410. }
  28411. var respJSON map[string]interface{}
  28412. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28415. return
  28416. }
  28417. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28418. if status == "0" {
  28419. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28420. c.ServeSuccessJSON(map[string]interface{}{
  28421. "failed_code": -10,
  28422. "msg": err_msg,
  28423. })
  28424. return
  28425. }
  28426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28427. userJSONBytes, _ := json.Marshal(respJSON)
  28428. fmt.Println("log")
  28429. fmt.Println(string(userJSONBytes))
  28430. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28431. utils.ErrorLog("解析失败:%v", err)
  28432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28433. return
  28434. }
  28435. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28436. data := make(map[string]interface{})
  28437. client := &http.Client{}
  28438. data["psn_no"] = his.PsnNo
  28439. data["mdtrt_id"] = his.Number
  28440. data["operator"] = roles.UserName
  28441. data["department"] = department.Name
  28442. data["org_name"] = miConfig.OrgName
  28443. var med_type string
  28444. if his.Insutype == "390" {
  28445. if reg_type == 992102 {
  28446. med_type = "992102"
  28447. data["sick_code"] = sickConfig.CountryCode
  28448. data["sick_name"] = sickConfig.ClassName
  28449. }
  28450. if reg_type == 140104 {
  28451. med_type = "140104"
  28452. data["sick_code"] = sickConfig.CountryCode
  28453. data["sick_name"] = sickConfig.ClassName
  28454. }
  28455. if reg_type == 140201 {
  28456. med_type = "140201"
  28457. data["sick_code"] = sickConfig.CountryCode
  28458. data["sick_name"] = sickConfig.ClassName
  28459. }
  28460. if reg_type == 14 {
  28461. med_type = "14"
  28462. data["sick_code"] = sickConfig.CountryCode
  28463. data["sick_name"] = sickConfig.ClassName
  28464. }
  28465. } else if his.Insutype == "310" {
  28466. if reg_type == 992102 {
  28467. med_type = "992102"
  28468. data["sick_code"] = sickConfig.CountryCode
  28469. data["sick_name"] = sickConfig.ClassName
  28470. }
  28471. if reg_type == 140104 {
  28472. med_type = "140104"
  28473. data["sick_code"] = sickConfig.CountryCode
  28474. data["sick_name"] = sickConfig.ClassName
  28475. }
  28476. if reg_type == 140201 {
  28477. med_type = "140201"
  28478. data["sick_code"] = sickConfig.CountryCode
  28479. data["sick_name"] = sickConfig.ClassName
  28480. }
  28481. if reg_type == 14 {
  28482. med_type = "14"
  28483. data["sick_code"] = sickConfig.CountryCode
  28484. data["sick_name"] = sickConfig.ClassName
  28485. }
  28486. }
  28487. data["med_type"] = med_type
  28488. data["doctor_number"] = doctor_info.DoctorNumber
  28489. data["doctor_name"] = doctor_info.UserName
  28490. data["fixmedins_code"] = miConfig.Code
  28491. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28492. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28493. data["secret_key"] = miConfig.SecretKey
  28494. data["begin_time"] = begin_time
  28495. data["dept"] = strconv.FormatInt(department.ID, 10)
  28496. data["config"] = config
  28497. data["url"] = miConfig.Url
  28498. data["ak"] = miConfig.AccessKey
  28499. data["cainfo"] = miConfig.Cainfo
  28500. bytesData, _ := json.Marshal(data)
  28501. var req *http.Request
  28502. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28503. resp, _ := client.Do(req)
  28504. defer resp.Body.Close()
  28505. body, ioErr := ioutil.ReadAll(resp.Body)
  28506. if ioErr != nil {
  28507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28509. return
  28510. }
  28511. var respJSON map[string]interface{}
  28512. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28515. return
  28516. }
  28517. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28518. if status == "0" {
  28519. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28520. c.ServeSuccessJSON(map[string]interface{}{
  28521. "failed_code": -10,
  28522. "msg": err_msg,
  28523. })
  28524. return
  28525. }
  28526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28527. userJSONBytes, _ := json.Marshal(respJSON)
  28528. fmt.Println("log")
  28529. fmt.Println(string(userJSONBytes))
  28530. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28531. utils.ErrorLog("解析失败:%v", err)
  28532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28533. return
  28534. }
  28535. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28536. var result string
  28537. var requestLog string
  28538. 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, "")
  28539. saveLog(result, requestLog, "2203", "上传就诊信息")
  28540. var respJSON2 map[string]interface{}
  28541. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28544. return
  28545. }
  28546. userJSONBytes2, _ := json.Marshal(respJSON2)
  28547. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28548. utils.ErrorLog("解析失败:%v", err)
  28549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28550. return
  28551. }
  28552. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28553. data := make(map[string]interface{})
  28554. client := &http.Client{}
  28555. data["psn_no"] = his.PsnNo
  28556. data["mdtrt_id"] = his.Number
  28557. data["doctor"] = roles.UserName
  28558. data["department"] = department.Name
  28559. data["org_name"] = miConfig.OrgName
  28560. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28561. data["doctor_id"] = doctor_info.DoctorNumber
  28562. data["fixmedins_code"] = miConfig.Code
  28563. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28564. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28565. data["secret_key"] = miConfig.SecretKey
  28566. data["sick_code"] = sickConfig.CountryCode
  28567. data["sick_name"] = sickConfig.ClassName
  28568. data["begin_time"] = begin_time
  28569. data["new_doctor_name"] = doctor_info.UserName
  28570. data["dept"] = strconv.FormatInt(department.ID, 10)
  28571. data["config"] = config
  28572. bytesData, _ := json.Marshal(data)
  28573. var req *http.Request
  28574. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28575. resp, _ := client.Do(req)
  28576. defer resp.Body.Close()
  28577. body, ioErr := ioutil.ReadAll(resp.Body)
  28578. if ioErr != nil {
  28579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28581. return
  28582. }
  28583. var respJSON map[string]interface{}
  28584. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28587. return
  28588. }
  28589. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28590. userJSONBytes, _ := json.Marshal(respJSON)
  28591. fmt.Println("log")
  28592. fmt.Println(string(userJSONBytes))
  28593. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28594. utils.ErrorLog("解析失败:%v", err)
  28595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28596. return
  28597. }
  28598. } else {
  28599. var result string
  28600. var requestLog string
  28601. if miConfig.MdtrtareaAdmvs == "440781" { //
  28602. 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)
  28603. } else {
  28604. if miConfig.Code == "H15049901371" {
  28605. //赤峰地区国家医保医疗类别
  28606. //职工透析:医疗类别选特殊情况门诊990502
  28607. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28608. var med_type string
  28609. if his.Insutype == "390" {
  28610. if reg_type == 14 {
  28611. med_type = "9933"
  28612. } else if reg_type == 11 {
  28613. med_type = "11"
  28614. }
  28615. } else if his.Insutype == "310" {
  28616. if reg_type == 14 {
  28617. med_type = "990502"
  28618. } else if reg_type == 11 {
  28619. med_type = "11"
  28620. }
  28621. }
  28622. 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)
  28623. } else {
  28624. 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)
  28625. }
  28626. saveLog(result, requestLog, "2203", "上传就诊信息")
  28627. var respJSON2 map[string]interface{}
  28628. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28631. return
  28632. }
  28633. userJSONBytes2, _ := json.Marshal(respJSON2)
  28634. if miConfig.Code == "H15049901371" {
  28635. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28636. utils.ErrorLog("解析失败:%v", err)
  28637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28638. return
  28639. }
  28640. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28641. res2.Output = resSix10265.Output
  28642. res2.ErrMsg = resSix10265.ErrMsg
  28643. res2.Cainfo = resSix10265.Cainfo
  28644. res2.WarnMsg = resSix10265.WarnMsg
  28645. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28646. res2.Infcode = infocode
  28647. } else {
  28648. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28649. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28650. utils.ErrorLog("解析失败:%v", err)
  28651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28652. return
  28653. }
  28654. res2.Infcode = res3.Infcode
  28655. } else {
  28656. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28657. utils.ErrorLog("解析失败:%v", err)
  28658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28659. return
  28660. }
  28661. }
  28662. }
  28663. }
  28664. }
  28665. if res2.Infcode == -1 {
  28666. adminUser := c.GetAdminUserInfo()
  28667. errlog := &models.HisOrderError{
  28668. UserOrgId: adminUser.CurrentOrgId,
  28669. Ctime: time.Now().Unix(),
  28670. Mtime: time.Now().Unix(),
  28671. ErrMsg: res2.ErrMsg,
  28672. Status: 1,
  28673. PatientId: id,
  28674. RecordTime: recordDateTime,
  28675. Stage: 3,
  28676. }
  28677. service.CreateErrMsgLog(errlog)
  28678. c.ServeSuccessJSON(map[string]interface{}{
  28679. "failed_code": -10,
  28680. "msg": res2.ErrMsg,
  28681. })
  28682. return
  28683. }
  28684. if res2.Infcode != 0 {
  28685. adminUser := c.GetAdminUserInfo()
  28686. errlog := &models.HisOrderError{
  28687. UserOrgId: adminUser.CurrentOrgId,
  28688. Ctime: time.Now().Unix(),
  28689. Mtime: time.Now().Unix(),
  28690. ErrMsg: res2.ErrMsg,
  28691. Status: 1,
  28692. PatientId: id,
  28693. RecordTime: recordDateTime,
  28694. Stage: 3,
  28695. }
  28696. service.CreateErrMsgLog(errlog)
  28697. c.ServeSuccessJSON(map[string]interface{}{
  28698. "failed_code": -10,
  28699. "msg": res2.ErrMsg,
  28700. })
  28701. return
  28702. } else {
  28703. his.Diagnosis = diagnosis_id
  28704. his.SickType = sickConfig.ID
  28705. his.PType = fmt.Sprintf("%d", reg_type)
  28706. service.UpdateHisPatientThree(&his)
  28707. data := make(map[string]interface{})
  28708. if settle_accounts_type == 1 { //日结
  28709. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28710. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28711. } else {
  28712. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28713. }
  28714. data["pre"] = prescriptions
  28715. } else { //月结
  28716. start_time_str := c.GetString("start_time")
  28717. end_time_str := c.GetString("end_time")
  28718. timeLayout := "2006-01-02"
  28719. loc, _ := time.LoadLocation("Local")
  28720. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28721. if err != nil {
  28722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28723. return
  28724. }
  28725. recordStartTime := theStartTime.Unix()
  28726. start_time = recordStartTime
  28727. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28728. if err != nil {
  28729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28730. return
  28731. }
  28732. recordEndTime := theEndTime.Unix()
  28733. end_time = recordEndTime
  28734. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28735. data["pre"] = prescriptions
  28736. }
  28737. client := &http.Client{}
  28738. data["psn_no"] = his.PsnNo
  28739. data["mdtrt_id"] = his.Number
  28740. data["chrg_bchno"] = new_chrg_bchno
  28741. data["org_name"] = miConfig.OrgName
  28742. data["doctor"] = doctor_info.UserName
  28743. data["doctor_id"] = doctor_info.DoctorNumber
  28744. data["dept"] = department.Name
  28745. data["fixmedins_code"] = miConfig.Code
  28746. data["opter"] = roles.UserName
  28747. data["dept_code"] = department.Number
  28748. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28749. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28750. data["secret_key"] = miConfig.SecretKey
  28751. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28752. data["url"] = miConfig.Url
  28753. data["ak"] = miConfig.AccessKey
  28754. data["new_doctor_name"] = patientPrescription.Doctor
  28755. if his.Insutype == "390" {
  28756. if reg_type == 992102 {
  28757. data["diag_code"] = "ZDZ940"
  28758. }
  28759. if reg_type == 140104 {
  28760. data["diag_code"] = sickConfig.CountryCode
  28761. }
  28762. if reg_type == 140201 {
  28763. data["diag_code"] = sickConfig.CountryCode
  28764. }
  28765. if reg_type == 14 {
  28766. data["diag_code"] = sickConfig.CountryCode
  28767. }
  28768. } else if his.Insutype == "310" {
  28769. if miConfig.MdtrtareaAdmvs == "341203" {
  28770. if reg_type == 992102 {
  28771. data["diag_code"] = "ZDZ940"
  28772. }
  28773. if reg_type != 992102 {
  28774. data["diag_code"] = sickConfig.CountryCode
  28775. }
  28776. } else {
  28777. data["diag_code"] = sickConfig.CountryCode
  28778. }
  28779. }
  28780. data["cainfo"] = miConfig.Cainfo
  28781. data["opter"] = roles.UserName
  28782. var ids []int64
  28783. for _, item := range prescriptions {
  28784. ids = append(ids, item.ID)
  28785. }
  28786. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28787. if config.IsOpen == 1 { //对接了医保,走医保流程
  28788. var res ResultFour
  28789. var resFour10265 ResultFour10265
  28790. if miConfig.MdtrtareaAdmvs == "421300" {
  28791. bytesData, _ := json.Marshal(data)
  28792. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28793. resp, _ := client.Do(req)
  28794. defer resp.Body.Close()
  28795. body, ioErr := ioutil.ReadAll(resp.Body)
  28796. if ioErr != nil {
  28797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28799. return
  28800. }
  28801. var respJSON map[string]interface{}
  28802. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28805. return
  28806. }
  28807. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28808. userJSONBytes, _ := json.Marshal(respJSON)
  28809. fmt.Println("log")
  28810. fmt.Println(string(userJSONBytes))
  28811. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28812. utils.ErrorLog("解析失败:%v", err)
  28813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28814. return
  28815. }
  28816. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28817. bytesData, _ := json.Marshal(data)
  28818. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28819. resp, _ := client.Do(req)
  28820. defer resp.Body.Close()
  28821. body, ioErr := ioutil.ReadAll(resp.Body)
  28822. if ioErr != nil {
  28823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28825. return
  28826. }
  28827. var respJSON map[string]interface{}
  28828. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28831. return
  28832. }
  28833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28834. userJSONBytes, _ := json.Marshal(respJSON)
  28835. fmt.Println("log")
  28836. fmt.Println(string(userJSONBytes))
  28837. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28838. utils.ErrorLog("解析失败:%v", err)
  28839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28840. return
  28841. }
  28842. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28843. bytesData, _ := json.Marshal(data)
  28844. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28845. resp, _ := client.Do(req)
  28846. defer resp.Body.Close()
  28847. body, ioErr := ioutil.ReadAll(resp.Body)
  28848. if ioErr != nil {
  28849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28851. return
  28852. }
  28853. var respJSON map[string]interface{}
  28854. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28857. return
  28858. }
  28859. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28860. userJSONBytes, _ := json.Marshal(respJSON)
  28861. fmt.Println("log")
  28862. fmt.Println(string(userJSONBytes))
  28863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28864. utils.ErrorLog("解析失败:%v", err)
  28865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28866. return
  28867. }
  28868. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28869. bytesData, _ := json.Marshal(data)
  28870. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28871. resp, _ := client.Do(req)
  28872. defer resp.Body.Close()
  28873. body, ioErr := ioutil.ReadAll(resp.Body)
  28874. if ioErr != nil {
  28875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28877. return
  28878. }
  28879. var respJSON map[string]interface{}
  28880. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28883. return
  28884. }
  28885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28886. userJSONBytes, _ := json.Marshal(respJSON)
  28887. fmt.Println("log")
  28888. fmt.Println(string(userJSONBytes))
  28889. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28890. utils.ErrorLog("解析失败:%v", err)
  28891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28892. return
  28893. }
  28894. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28895. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28896. if result3101.Infcode == "0" {
  28897. if len(result3101.Output.Result) > 0 {
  28898. var errMsgs []string
  28899. for _, item := range result3101.Output.Result {
  28900. errMsgs = append(errMsgs, item.VolaCont)
  28901. }
  28902. c.ServeSuccessJSON(map[string]interface{}{
  28903. "failed_code": -10,
  28904. "msg": errMsgs,
  28905. })
  28906. return
  28907. } else {
  28908. if miConfig.MdtrtareaAdmvs == "320921" {
  28909. data["doctor_id"] = "D320923012139"
  28910. } else {
  28911. data["doctor_id"] = "D371621008686"
  28912. }
  28913. bytesData, _ := json.Marshal(data)
  28914. var req *http.Request
  28915. if miConfig.MdtrtareaAdmvs == "320921" {
  28916. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28917. } else {
  28918. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28919. }
  28920. resp, _ := client.Do(req)
  28921. defer resp.Body.Close()
  28922. body, ioErr := ioutil.ReadAll(resp.Body)
  28923. if ioErr != nil {
  28924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28926. return
  28927. }
  28928. var respJSON map[string]interface{}
  28929. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28932. return
  28933. }
  28934. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28935. userJSONBytes, _ := json.Marshal(respJSON)
  28936. fmt.Println("log")
  28937. fmt.Println(string(userJSONBytes))
  28938. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28939. utils.ErrorLog("解析失败:%v", err)
  28940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28941. return
  28942. }
  28943. res.InfRefmsgid = resFour10265.InfRefmsgid
  28944. res.Output = resFour10265.Output
  28945. res.ErrMsg = resFour10265.ErrMsg
  28946. res.Cainfo = resFour10265.Cainfo
  28947. res.WarnMsg = resFour10265.WarnMsg
  28948. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28949. res.Infcode = infocode
  28950. }
  28951. }
  28952. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28953. var pagesize int = 5
  28954. var start int = 1
  28955. var stop int
  28956. var pagecount int
  28957. var curpage int
  28958. data["doctor_id"] = doctor_info.DoctorNumber
  28959. var res2 ResultFour
  28960. //var result res.
  28961. //总页数,向上取整,注意除之前要先转换类型为float64
  28962. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  28963. for curpage = 1; curpage <= pagecount; curpage++ {
  28964. if curpage == 1 {
  28965. start = 1
  28966. } else {
  28967. start = (curpage-1)*pagesize + 1
  28968. }
  28969. stop = curpage * pagesize
  28970. if stop > len(prescriptions) {
  28971. stop = len(prescriptions)
  28972. }
  28973. //var requestLog string
  28974. data["pre"] = prescriptions[start-1 : stop]
  28975. fmt.Println(data["pre"])
  28976. bytesData, _ := json.Marshal(data)
  28977. var req *http.Request
  28978. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  28979. resp, _ := client.Do(req)
  28980. defer resp.Body.Close()
  28981. body, ioErr := ioutil.ReadAll(resp.Body)
  28982. if ioErr != nil {
  28983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28985. return
  28986. }
  28987. var respJSON map[string]interface{}
  28988. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28991. return
  28992. }
  28993. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28994. userJSONBytes, _ := json.Marshal(respJSON)
  28995. fmt.Println("log")
  28996. fmt.Println(string(userJSONBytes))
  28997. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28998. utils.ErrorLog("解析失败:%v", err)
  28999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29000. return
  29001. }
  29002. res.InfRefmsgid = resFour10265.InfRefmsgid
  29003. res.Output = resFour10265.Output
  29004. res.ErrMsg = resFour10265.ErrMsg
  29005. res.Cainfo = resFour10265.Cainfo
  29006. res.WarnMsg = resFour10265.WarnMsg
  29007. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29008. res.Infcode = infocode
  29009. if infocode == 0 {
  29010. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29011. } else {
  29012. isSuccess = false
  29013. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29014. res.Infcode = -1
  29015. res.ErrMsg = resFour10265.ErrMsg
  29016. errlog := &models.HisOrderError{
  29017. UserOrgId: adminUser.CurrentOrgId,
  29018. Ctime: time.Now().Unix(),
  29019. Mtime: time.Now().Unix(),
  29020. Number: chrg_bchno,
  29021. ErrMsg: "",
  29022. Status: 1,
  29023. PatientId: id,
  29024. RecordTime: recordDateTime,
  29025. Stage: 4,
  29026. }
  29027. service.CreateErrMsgLog(errlog)
  29028. }
  29029. }
  29030. if isSuccess {
  29031. res.Infcode = 0
  29032. res.Output.Result = res2.Output.Result
  29033. } else {
  29034. order := &models.HisOrder{
  29035. UserOrgId: adminUser.CurrentOrgId,
  29036. HisPatientId: his.ID,
  29037. PatientId: his.PatientId,
  29038. SettleAccountsDate: recordDateTime,
  29039. Ctime: time.Now().Unix(),
  29040. Mtime: time.Now().Unix(),
  29041. MdtrtId: his.Number,
  29042. PsnNo: his.PsnNo,
  29043. MedType: strconv.FormatInt(reg_type, 10),
  29044. Status: 1,
  29045. Number: chrg_bchno,
  29046. Infcode: res.Infcode,
  29047. WarnMsg: res.WarnMsg,
  29048. Cainfo: res.Cainfo,
  29049. ErrMsg: res.ErrMsg,
  29050. RespondTime: res.RefmsgTime,
  29051. InfRefmsgid: res.InfRefmsgid,
  29052. OrderStatus: 1,
  29053. IsMedicineInsurance: 1,
  29054. SettleType: settle_accounts_type,
  29055. SettleStartTime: start_time,
  29056. SettleEndTime: end_time,
  29057. Creator: roles.AdminUserId,
  29058. Modify: roles.AdminUserId,
  29059. PType: 2,
  29060. Diagnosis: diagnosis_id,
  29061. }
  29062. err = service.CreateOrder(order)
  29063. if err != nil {
  29064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29065. return
  29066. }
  29067. c.ServeSuccessJSON(map[string]interface{}{
  29068. "failed_code": -10,
  29069. "msg": res2.ErrMsg,
  29070. })
  29071. return
  29072. }
  29073. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29074. 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)
  29075. var dat map[string]interface{}
  29076. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29077. fmt.Println(dat)
  29078. } else {
  29079. fmt.Println(err)
  29080. }
  29081. saveLog(result, request_log, "2204", "上传费用明细")
  29082. userJSONBytes, _ := json.Marshal(dat)
  29083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29084. utils.ErrorLog("解析失败:%v", err)
  29085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29086. return
  29087. }
  29088. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29089. 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, "", "")
  29090. var dat map[string]interface{}
  29091. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29092. fmt.Println(dat)
  29093. } else {
  29094. fmt.Println(err)
  29095. }
  29096. saveLog(result, request_log, "2204", "上传费用明细")
  29097. userJSONBytes, _ := json.Marshal(dat)
  29098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29099. utils.ErrorLog("解析失败:%v", err)
  29100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29101. return
  29102. }
  29103. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29104. 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, "", "")
  29105. var dat map[string]interface{}
  29106. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29107. fmt.Println(dat)
  29108. } else {
  29109. fmt.Println(err)
  29110. }
  29111. saveLog(result, request_log, "2204", "上传费用明细")
  29112. userJSONBytes, _ := json.Marshal(dat)
  29113. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29114. utils.ErrorLog("解析失败:%v", err)
  29115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29116. return
  29117. }
  29118. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29119. bytesData, _ := json.Marshal(data)
  29120. var req *http.Request
  29121. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29122. resp, _ := client.Do(req)
  29123. defer resp.Body.Close()
  29124. body, ioErr := ioutil.ReadAll(resp.Body)
  29125. if ioErr != nil {
  29126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29128. return
  29129. }
  29130. var respJSON map[string]interface{}
  29131. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29134. return
  29135. }
  29136. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29137. if status == "0" {
  29138. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29139. c.ServeSuccessJSON(map[string]interface{}{
  29140. "failed_code": -10,
  29141. "msg": err_msg,
  29142. })
  29143. return
  29144. }
  29145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29146. userJSONBytes, _ := json.Marshal(respJSON)
  29147. fmt.Println("log")
  29148. fmt.Println(string(userJSONBytes))
  29149. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29150. utils.ErrorLog("解析失败:%v", err)
  29151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29152. return
  29153. }
  29154. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29155. bytesData, _ := json.Marshal(data)
  29156. var req *http.Request
  29157. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29158. resp, _ := client.Do(req)
  29159. defer resp.Body.Close()
  29160. body, ioErr := ioutil.ReadAll(resp.Body)
  29161. if ioErr != nil {
  29162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29164. return
  29165. }
  29166. var respJSON map[string]interface{}
  29167. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29170. return
  29171. }
  29172. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29173. if status == "0" {
  29174. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29175. c.ServeSuccessJSON(map[string]interface{}{
  29176. "failed_code": -10,
  29177. "msg": err_msg,
  29178. })
  29179. return
  29180. }
  29181. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29182. userJSONBytes, _ := json.Marshal(respJSON)
  29183. fmt.Println("log")
  29184. fmt.Println(string(userJSONBytes))
  29185. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29186. utils.ErrorLog("解析失败:%v", err)
  29187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29188. return
  29189. }
  29190. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29191. 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, "", "")
  29192. var dat map[string]interface{}
  29193. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29194. fmt.Println(dat)
  29195. } else {
  29196. fmt.Println(err)
  29197. }
  29198. saveLog(result, request_log, "2204", "上传费用明细")
  29199. userJSONBytes, _ := json.Marshal(dat)
  29200. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29201. utils.ErrorLog("解析失败:%v", err)
  29202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29203. return
  29204. }
  29205. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29206. bytesData, _ := json.Marshal(data)
  29207. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29208. resp, _ := client.Do(req)
  29209. defer resp.Body.Close()
  29210. body, ioErr := ioutil.ReadAll(resp.Body)
  29211. if ioErr != nil {
  29212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29214. return
  29215. }
  29216. var respJSON map[string]interface{}
  29217. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29220. return
  29221. }
  29222. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29223. userJSONBytes, _ := json.Marshal(respJSON)
  29224. fmt.Println("log")
  29225. fmt.Println(string(userJSONBytes))
  29226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29227. utils.ErrorLog("解析失败:%v", err)
  29228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29229. return
  29230. }
  29231. } else {
  29232. if miConfig.MdtrtareaAdmvs == "441202" {
  29233. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29234. if result3101.Infcode == 0 {
  29235. if len(result3101.Output.Result) > 0 {
  29236. var errMsgs []string
  29237. for _, item := range result3101.Output.Result {
  29238. errMsgs = append(errMsgs, item.VolaCont)
  29239. }
  29240. c.ServeSuccessJSON(map[string]interface{}{
  29241. "failed_code": -10,
  29242. "msg": errMsgs,
  29243. })
  29244. return
  29245. } else {
  29246. 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)
  29247. var dat map[string]interface{}
  29248. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29249. fmt.Println(dat)
  29250. } else {
  29251. fmt.Println(err)
  29252. }
  29253. saveLog(result, request_log, "2204", "上传费用明细")
  29254. userJSONBytes, _ := json.Marshal(dat)
  29255. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29256. utils.ErrorLog("解析失败:%v", err)
  29257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29258. return
  29259. }
  29260. }
  29261. } else {
  29262. c.ServeSuccessJSON(map[string]interface{}{
  29263. "failed_code": -10,
  29264. "msg": result3101.ErrMsg,
  29265. })
  29266. return
  29267. }
  29268. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29269. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29270. if result3101.Infcode == 0 {
  29271. if len(result3101.Output.Result) > 0 {
  29272. var errMsgs []string
  29273. for _, item := range result3101.Output.Result {
  29274. errMsgs = append(errMsgs, item.VolaCont)
  29275. }
  29276. c.ServeSuccessJSON(map[string]interface{}{
  29277. "failed_code": -10,
  29278. "msg": errMsgs,
  29279. })
  29280. return
  29281. } else {
  29282. 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)
  29283. var dat map[string]interface{}
  29284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29285. fmt.Println(dat)
  29286. } else {
  29287. fmt.Println(err)
  29288. }
  29289. saveLog(result, request_log, "2204", "上传费用明细")
  29290. userJSONBytes, _ := json.Marshal(dat)
  29291. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29292. utils.ErrorLog("解析失败:%v", err)
  29293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29294. return
  29295. }
  29296. }
  29297. } else {
  29298. c.ServeSuccessJSON(map[string]interface{}{
  29299. "failed_code": -10,
  29300. "msg": result3101.ErrMsg,
  29301. })
  29302. return
  29303. }
  29304. } else {
  29305. if miConfig.Code == "H15049901371" {
  29306. 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)
  29307. var dat map[string]interface{}
  29308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29309. fmt.Println(dat)
  29310. } else {
  29311. fmt.Println(err)
  29312. }
  29313. saveLog(result, request_log, "2204", "上传费用明细")
  29314. userJSONBytes, _ := json.Marshal(dat)
  29315. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29316. utils.ErrorLog("解析失败:%v", err)
  29317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29318. return
  29319. }
  29320. res.InfRefmsgid = resFour10265.InfRefmsgid
  29321. res.Output = resFour10265.Output
  29322. res.ErrMsg = resFour10265.ErrMsg
  29323. res.Cainfo = resFour10265.Cainfo
  29324. res.WarnMsg = resFour10265.WarnMsg
  29325. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29326. res.Infcode = infocode
  29327. } else {
  29328. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" {
  29329. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29330. if result3101.Infcode == 0 {
  29331. if len(result3101.Output.Result) > 0 {
  29332. var errMsgs []string
  29333. for _, item := range result3101.Output.Result {
  29334. errMsgs = append(errMsgs, item.VolaCont)
  29335. }
  29336. c.ServeSuccessJSON(map[string]interface{}{
  29337. "failed_code": -10,
  29338. "msg": errMsgs,
  29339. })
  29340. return
  29341. } else {
  29342. 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)
  29343. var dat map[string]interface{}
  29344. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29345. fmt.Println(dat)
  29346. } else {
  29347. fmt.Println(err)
  29348. }
  29349. saveLog(result, request_log, "2204", "上传费用明细")
  29350. userJSONBytes, _ := json.Marshal(dat)
  29351. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29352. utils.ErrorLog("解析失败:%v", err)
  29353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29354. return
  29355. }
  29356. }
  29357. } else {
  29358. c.ServeSuccessJSON(map[string]interface{}{
  29359. "failed_code": -10,
  29360. "msg": result3101.ErrMsg,
  29361. })
  29362. return
  29363. }
  29364. } else {
  29365. 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)
  29366. var dat map[string]interface{}
  29367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29368. fmt.Println(dat)
  29369. } else {
  29370. fmt.Println(err)
  29371. }
  29372. saveLog(result, request_log, "2204", "上传费用明细")
  29373. userJSONBytes, _ := json.Marshal(dat)
  29374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29375. utils.ErrorLog("解析失败:%v", err)
  29376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29377. return
  29378. }
  29379. }
  29380. }
  29381. }
  29382. }
  29383. var total_two float64
  29384. if res.Infcode == -1 {
  29385. errlog := &models.HisOrderError{
  29386. UserOrgId: adminUser.CurrentOrgId,
  29387. Ctime: time.Now().Unix(),
  29388. Mtime: time.Now().Unix(),
  29389. Number: chrg_bchno,
  29390. ErrMsg: res.ErrMsg,
  29391. Status: 1,
  29392. PatientId: id,
  29393. RecordTime: recordDateTime,
  29394. Stage: 4,
  29395. }
  29396. service.CreateErrMsgLog(errlog)
  29397. c.ServeSuccessJSON(map[string]interface{}{
  29398. "failed_code": -10,
  29399. "msg": res.ErrMsg,
  29400. })
  29401. return
  29402. }
  29403. if res.Infcode == 0 {
  29404. order := &models.HisOrder{
  29405. UserOrgId: adminUser.CurrentOrgId,
  29406. HisPatientId: his.ID,
  29407. PatientId: his.PatientId,
  29408. SettleAccountsDate: recordDateTime,
  29409. Ctime: time.Now().Unix(),
  29410. Mtime: time.Now().Unix(),
  29411. MdtrtId: his.Number,
  29412. PsnNo: his.PsnNo,
  29413. MedType: strconv.FormatInt(reg_type, 10),
  29414. Status: 1,
  29415. Number: chrg_bchno,
  29416. Infcode: res.Infcode,
  29417. WarnMsg: res.WarnMsg,
  29418. Cainfo: res.Cainfo,
  29419. ErrMsg: res.ErrMsg,
  29420. RespondTime: res.RefmsgTime,
  29421. InfRefmsgid: res.InfRefmsgid,
  29422. OrderStatus: 1,
  29423. IsMedicineInsurance: 1,
  29424. SettleType: settle_accounts_type,
  29425. SettleStartTime: start_time,
  29426. SettleEndTime: end_time,
  29427. Creator: roles.AdminUserId,
  29428. Modify: roles.AdminUserId,
  29429. PType: 2,
  29430. Diagnosis: diagnosis_id,
  29431. }
  29432. err = service.CreateOrder(order)
  29433. if err != nil {
  29434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29435. return
  29436. }
  29437. for _, item := range res.Output.Result {
  29438. temp := strings.Split(item.FeedetlSn, "-")
  29439. var advice_id int64 = 0
  29440. var project_id int64 = 0
  29441. var types int64 = 0
  29442. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29443. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29444. if temp[1] == "1" {
  29445. advice_id = id
  29446. project_id = 0
  29447. } else if temp[1] == "2" {
  29448. advice_id = 0
  29449. project_id = id
  29450. }
  29451. total_two = total_two + item.DetItemFeeSumamt
  29452. info := &models.HisOrderInfo{
  29453. OrderNumber: order.Number,
  29454. FeedetlSn: item.FeedetlSn,
  29455. UploadDate: time.Now().Unix(),
  29456. AdviceId: advice_id,
  29457. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29458. Cnt: item.Cnt,
  29459. Pric: float64(item.Pric),
  29460. PatientId: his.PatientId,
  29461. PricUplmtAmt: item.PricUplmtAmt,
  29462. SelfpayProp: item.SelfpayProp,
  29463. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29464. OverlmtAmt: item.OverlmtAmt,
  29465. PreselfpayAmt: item.PreselfpayAmt,
  29466. BasMednFlag: item.BasMednFlag,
  29467. MedChrgitmType: item.MedChrgitmType,
  29468. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29469. Status: 1,
  29470. Memo: item.Memo,
  29471. Mtime: time.Now().Unix(),
  29472. InscpScpAmt: item.InscpScpAmt,
  29473. DrtReimFlag: item.DrtReimFlag,
  29474. Ctime: time.Now().Unix(),
  29475. ListSpItemFlag: item.ListSpItemFlag,
  29476. ChldMedcFlag: item.ChldMedcFlag,
  29477. LmtUsedFlag: item.LmtUsedFlag,
  29478. ChrgitmLv: item.ChrgitmLv,
  29479. UserOrgId: adminUser.CurrentOrgId,
  29480. HisPatientId: his.ID,
  29481. OrderId: order.ID,
  29482. ProjectId: project_id,
  29483. Type: types,
  29484. }
  29485. service.CreateOrderInfo(info)
  29486. }
  29487. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29488. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29489. var total float64
  29490. for _, item := range prescriptions {
  29491. if item.Type == 1 { //药品
  29492. for _, subItem := range item.HisDoctorAdviceInfo {
  29493. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29494. total_one := price * subItem.PrescribingNumber
  29495. fmt.Println("subItem")
  29496. fmt.Println(subItem.Price)
  29497. fmt.Println("price")
  29498. fmt.Println(price)
  29499. fmt.Println("total_one")
  29500. fmt.Println(total_one)
  29501. total = total + total_one
  29502. fmt.Println(total)
  29503. }
  29504. }
  29505. if item.Type == 2 { //项目
  29506. for _, subItem := range item.HisPrescriptionProject {
  29507. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29508. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29509. total_one := price * cnt
  29510. total = total + total_one
  29511. }
  29512. }
  29513. }
  29514. allTotal := fmt.Sprintf("%.2f", total)
  29515. if res.Infcode == 0 {
  29516. var rf []*ResultFive
  29517. json.Unmarshal([]byte(his.Iinfo), &rf)
  29518. chrg_bchno := chrg_bchno
  29519. cert_no := his.Certno
  29520. var insutypes []string
  29521. var insutype string
  29522. var is390 int = 0
  29523. var is310 int = 0
  29524. for _, item := range rf {
  29525. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29526. insutypes = append(insutypes, item.Insutype)
  29527. }
  29528. }
  29529. if len(insutypes) == 1 {
  29530. insutype = insutypes[0]
  29531. } else {
  29532. for _, i := range insutypes {
  29533. if i == "390" {
  29534. is390 = 1
  29535. }
  29536. if i == "310" {
  29537. is310 = 1
  29538. }
  29539. }
  29540. }
  29541. if is390 == 1 {
  29542. insutype = "390"
  29543. }
  29544. if is310 == 1 {
  29545. insutype = "310"
  29546. }
  29547. if len(insutypes) == 0 {
  29548. insutype = "390"
  29549. }
  29550. if len(insutypes) == 2 {
  29551. insutype = strconv.FormatInt(his.SocialType, 10)
  29552. }
  29553. //insutype = "390"
  29554. if his.IdCardType == 1 {
  29555. cert_no = his.MedicalInsuranceNumber
  29556. } else {
  29557. cert_no = his.Certno
  29558. }
  29559. var res ResultSeven
  29560. var ahres ResultSevenAH
  29561. var resSeven10265 ResultSeven10265
  29562. var resSeven10265Two ResultSeven10265Two
  29563. var gzresSeven10265Two GZResultSeven10265Two
  29564. if miConfig.MdtrtareaAdmvs == "421300" {
  29565. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29566. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29567. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29568. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29569. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29570. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29571. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29572. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29573. resp, requestErr := http.Get(api)
  29574. if requestErr != nil {
  29575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29576. return
  29577. }
  29578. body, ioErr := ioutil.ReadAll(resp.Body)
  29579. if ioErr != nil {
  29580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29582. return
  29583. }
  29584. var respJSON map[string]interface{}
  29585. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29588. return
  29589. }
  29590. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29591. result, _ := json.Marshal(respJSON)
  29592. fmt.Println("log")
  29593. fmt.Println(string(result))
  29594. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29595. utils.ErrorLog("解析失败:%v", err)
  29596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29597. return
  29598. }
  29599. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29600. if reg_type == 11 && his.Insutype == "390" {
  29601. reg_type = 110104
  29602. }
  29603. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29604. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29605. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29606. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29607. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29608. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29609. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29610. resp, requestErr := http.Get(api)
  29611. if requestErr != nil {
  29612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29613. return
  29614. }
  29615. body, ioErr := ioutil.ReadAll(resp.Body)
  29616. if ioErr != nil {
  29617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29619. return
  29620. }
  29621. var respJSON map[string]interface{}
  29622. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29625. return
  29626. }
  29627. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29628. result, _ := json.Marshal(respJSON)
  29629. fmt.Println("log")
  29630. fmt.Println(string(result))
  29631. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29632. utils.ErrorLog("解析失败:%v", err)
  29633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29634. return
  29635. }
  29636. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29637. if reg_type == 11 && his.Insutype == "390" {
  29638. reg_type = 110104
  29639. }
  29640. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29641. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29642. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29643. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29644. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29645. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29646. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29647. resp, requestErr := http.Get(api)
  29648. if requestErr != nil {
  29649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29650. return
  29651. }
  29652. body, ioErr := ioutil.ReadAll(resp.Body)
  29653. if ioErr != nil {
  29654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29656. return
  29657. }
  29658. var respJSON map[string]interface{}
  29659. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29662. return
  29663. }
  29664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29665. result, _ := json.Marshal(respJSON)
  29666. fmt.Println("log")
  29667. fmt.Println(string(result))
  29668. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29669. utils.ErrorLog("解析失败:%v", err)
  29670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29671. return
  29672. }
  29673. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29674. if reg_type == 11 && his.Insutype == "390" {
  29675. reg_type = 110104
  29676. }
  29677. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29678. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29679. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29680. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29681. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29682. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29683. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29684. resp, requestErr := http.Get(api)
  29685. if requestErr != nil {
  29686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29687. return
  29688. }
  29689. body, ioErr := ioutil.ReadAll(resp.Body)
  29690. if ioErr != nil {
  29691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29693. return
  29694. }
  29695. var respJSON map[string]interface{}
  29696. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29699. return
  29700. }
  29701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29702. result, _ := json.Marshal(respJSON)
  29703. fmt.Println("log")
  29704. fmt.Println(string(result))
  29705. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29706. utils.ErrorLog("解析失败:%v", err)
  29707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29708. return
  29709. }
  29710. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29711. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29712. if result3101.Infcode == "0" {
  29713. if len(result3101.Output.Result) > 0 {
  29714. var errMsgs []string
  29715. for _, item := range result3101.Output.Result {
  29716. errMsgs = append(errMsgs, item.VolaCont)
  29717. }
  29718. c.ServeSuccessJSON(map[string]interface{}{
  29719. "failed_code": -10,
  29720. "msg": errMsgs,
  29721. })
  29722. return
  29723. } else {
  29724. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29725. if his.IdCardType != 4 {
  29726. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29727. bas := strings.Split(psn_info.CardInfo, "|")
  29728. if his.IdCardType == 1 {
  29729. cert_no = bas[2]
  29730. } else {
  29731. cert_no = bas[1]
  29732. }
  29733. } else {
  29734. cert_no = his.Certno
  29735. }
  29736. //江苏地区国家医保医疗类别
  29737. //职工透析:医疗类别选特殊情况门诊9933
  29738. //居民血透门慢: 医疗类别选门诊慢病1402
  29739. //var med_type string
  29740. //if his.Insutype == "310" {
  29741. // if reg_type == 14 {
  29742. // med_type = "9933"
  29743. // } else if reg_type == 11 {
  29744. // med_type = "11"
  29745. //
  29746. // }
  29747. //} else if his.Insutype == "390" {
  29748. // if reg_type == 14 {
  29749. // med_type = "1402"
  29750. // } else if reg_type == 11 {
  29751. // med_type = "11"
  29752. // }
  29753. //}
  29754. var api string
  29755. if miConfig.MdtrtareaAdmvs == "320921" {
  29756. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29757. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29758. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29759. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29760. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29761. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29762. "&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
  29763. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29764. } else {
  29765. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29766. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29767. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29768. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29769. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29770. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29771. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29772. "&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
  29773. }
  29774. resp, requestErr := http.Get(api)
  29775. if requestErr != nil {
  29776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29777. return
  29778. }
  29779. body, ioErr := ioutil.ReadAll(resp.Body)
  29780. if ioErr != nil {
  29781. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29783. return
  29784. }
  29785. var respJSON map[string]interface{}
  29786. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29789. return
  29790. }
  29791. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29792. result, _ := json.Marshal(respJSON)
  29793. fmt.Println("log")
  29794. fmt.Println(string(result))
  29795. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29796. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29797. utils.ErrorLog("解析失败:%v", err)
  29798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29799. return
  29800. }
  29801. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29802. res.Output = resSeven10265.Output
  29803. res.ErrMsg = resSeven10265.ErrMsg
  29804. res.Cainfo = resSeven10265.Cainfo
  29805. res.WarnMsg = resSeven10265.WarnMsg
  29806. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29807. res.Infcode = infocode
  29808. } else {
  29809. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29810. utils.ErrorLog("解析失败:%v", err)
  29811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29812. return
  29813. }
  29814. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29815. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29816. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29817. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29818. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29819. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29820. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29821. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29822. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29823. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29824. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29825. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29826. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29827. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29828. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29829. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29830. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29831. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29832. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29833. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29834. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29835. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29836. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29837. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29838. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29839. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29840. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29841. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29842. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29843. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29844. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29845. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29846. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29847. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29848. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29849. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29850. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29851. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29852. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29853. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29854. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29855. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29856. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29857. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29858. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29859. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29860. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29861. res.ErrMsg = resSeven10265Two.ErrMsg
  29862. res.Cainfo = resSeven10265Two.Cainfo
  29863. res.WarnMsg = resSeven10265Two.WarnMsg
  29864. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29865. res.Infcode = infocode
  29866. }
  29867. }
  29868. }
  29869. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29870. psn_info, _ := service.GetPsnByPatientId(id)
  29871. var verify_number string
  29872. if psn_info.IdCardType == 4 {
  29873. verify_number = psn_info.VerifyNumber
  29874. } else if psn_info.IdCardType == 1 {
  29875. bas := strings.Split(psn_info.CardInfo, "|")
  29876. cardNumber := bas[2]
  29877. verify_number = cardNumber
  29878. } else {
  29879. psn_info.IdCardType = 2
  29880. verify_number = psn_info.Certno
  29881. }
  29882. var api string
  29883. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29884. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  29885. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29886. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29887. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29888. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29889. "&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
  29890. resp, requestErr := http.Get(api)
  29891. if requestErr != nil {
  29892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29893. return
  29894. }
  29895. body, ioErr := ioutil.ReadAll(resp.Body)
  29896. if ioErr != nil {
  29897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29899. return
  29900. }
  29901. var respJSON map[string]interface{}
  29902. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29905. return
  29906. }
  29907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29908. result, _ := json.Marshal(respJSON)
  29909. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29910. utils.ErrorLog("解析失败:%v", err)
  29911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29912. return
  29913. }
  29914. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29915. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  29916. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  29917. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29918. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  29919. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  29920. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  29921. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  29922. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  29923. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  29924. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  29925. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  29926. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  29927. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29928. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  29929. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  29930. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  29931. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  29932. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  29933. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  29934. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29935. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  29936. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  29937. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  29938. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  29939. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  29940. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  29941. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  29942. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  29943. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  29944. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  29945. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  29946. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  29947. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  29948. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29949. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  29950. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  29951. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  29952. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  29953. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  29954. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  29955. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  29956. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  29957. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  29958. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  29959. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  29960. res.ErrMsg = resSeven10265.ErrMsg
  29961. res.Cainfo = resSeven10265.Cainfo
  29962. res.WarnMsg = resSeven10265.WarnMsg
  29963. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29964. res.Infcode = infocode
  29965. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29966. acct_used_flag := "1"
  29967. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  29968. var result string
  29969. var request_log string
  29970. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  29971. 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)
  29972. } else {
  29973. 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)
  29974. }
  29975. var dat map[string]interface{}
  29976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29977. fmt.Println(dat)
  29978. } else {
  29979. fmt.Println(err)
  29980. }
  29981. saveLog(result, request_log, "2206", "预结算")
  29982. userJSONBytes, _ := json.Marshal(dat)
  29983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29984. utils.ErrorLog("解析失败:%v", err)
  29985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29986. return
  29987. }
  29988. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29989. var result string
  29990. var request_log string
  29991. if his.IdCardType == 2 {
  29992. insutype = strconv.FormatInt(his.SocialType, 10)
  29993. 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, "")
  29994. } else if his.IdCardType == 1 {
  29995. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29996. bas := strings.Split(psn_info.CardInfo, "|")
  29997. basNumber := bas[2]
  29998. card_sn := bas[3]
  29999. var rf []*ResultFive
  30000. json.Unmarshal([]byte(his.Iinfo), &rf)
  30001. var psn_type string
  30002. for _, item := range rf {
  30003. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30004. psn_type = item.PsnType
  30005. }
  30006. }
  30007. insutype = strconv.FormatInt(his.SocialType, 10)
  30008. 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)
  30009. } else {
  30010. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30011. //bas := strings.Split(psn_info.CardInfo, "|")
  30012. //basNumber := bas[2]
  30013. //card_sn := bas[3]
  30014. var rf []*ResultFive
  30015. json.Unmarshal([]byte(his.Iinfo), &rf)
  30016. var psn_type string
  30017. for _, item := range rf {
  30018. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30019. psn_type = item.PsnType
  30020. }
  30021. }
  30022. insutype = strconv.FormatInt(his.SocialType, 10)
  30023. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30024. 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)
  30025. }
  30026. var dat map[string]interface{}
  30027. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30028. fmt.Println(dat)
  30029. } else {
  30030. fmt.Println(err)
  30031. }
  30032. saveLog(result, request_log, "2206", "预结算")
  30033. userJSONBytes, _ := json.Marshal(dat)
  30034. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30035. utils.ErrorLog("解析失败:%v", err)
  30036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30037. return
  30038. }
  30039. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30040. var result string
  30041. var request_log string
  30042. if his.IdCardType == 2 {
  30043. insutype = strconv.FormatInt(his.SocialType, 10)
  30044. 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, "")
  30045. } else if his.IdCardType == 1 {
  30046. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30047. bas := strings.Split(psn_info.CardInfo, "|")
  30048. basNumber := bas[0]
  30049. card_sn := ""
  30050. var rf []*ResultFive
  30051. json.Unmarshal([]byte(his.Iinfo), &rf)
  30052. var psn_type string
  30053. for _, item := range rf {
  30054. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30055. psn_type = item.PsnType
  30056. }
  30057. }
  30058. insutype = strconv.FormatInt(his.SocialType, 10)
  30059. 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)
  30060. } else {
  30061. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30062. //bas := strings.Split(psn_info.CardInfo, "|")
  30063. //basNumber := bas[2]
  30064. //card_sn := bas[3]
  30065. var rf []*ResultFive
  30066. json.Unmarshal([]byte(his.Iinfo), &rf)
  30067. var psn_type string
  30068. for _, item := range rf {
  30069. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30070. psn_type = item.PsnType
  30071. }
  30072. }
  30073. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30074. 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)
  30075. }
  30076. var dat map[string]interface{}
  30077. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30078. fmt.Println(dat)
  30079. } else {
  30080. fmt.Println(err)
  30081. }
  30082. saveLog(result, request_log, "2206", "预结算")
  30083. userJSONBytes, _ := json.Marshal(dat)
  30084. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30085. utils.ErrorLog("解析失败:%v", err)
  30086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30087. return
  30088. }
  30089. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30090. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30091. if his.IdCardType == 4 {
  30092. psn_info.VerifyNumber = psn_info.VerifyNumber
  30093. cert_no = psn_info.VerifyNumber
  30094. } else if his.IdCardType == 2 {
  30095. cert_no = psn_info.Certno
  30096. psn_info.VerifyNumber = psn_info.Certno
  30097. } else {
  30098. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30099. bas := strings.Split(psn_info.CardInfo, "|")
  30100. if his.IdCardType == 1 {
  30101. cert_no = bas[2]
  30102. } else {
  30103. cert_no = bas[1]
  30104. }
  30105. }
  30106. var api string
  30107. var med_type string
  30108. if his.Insutype == "390" {
  30109. if reg_type == 992102 {
  30110. med_type = "992102"
  30111. }
  30112. if reg_type == 140104 {
  30113. med_type = "140104"
  30114. }
  30115. if reg_type == 140201 {
  30116. med_type = "140201"
  30117. }
  30118. if reg_type == 14 {
  30119. med_type = "140104"
  30120. }
  30121. } else if his.Insutype == "310" {
  30122. if reg_type == 992102 {
  30123. med_type = "992102"
  30124. }
  30125. if reg_type == 140104 {
  30126. med_type = "140104"
  30127. }
  30128. if reg_type == 140201 {
  30129. med_type = "140201"
  30130. }
  30131. if reg_type == 14 {
  30132. med_type = "140104"
  30133. }
  30134. }
  30135. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30136. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30137. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30138. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30139. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30140. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30141. "&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
  30142. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30143. resp, requestErr := http.Get(api)
  30144. if requestErr != nil {
  30145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30146. return
  30147. }
  30148. body, ioErr := ioutil.ReadAll(resp.Body)
  30149. if ioErr != nil {
  30150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30152. return
  30153. }
  30154. var respJSON map[string]interface{}
  30155. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30158. return
  30159. }
  30160. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30161. if status == "0" {
  30162. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30163. c.ServeSuccessJSON(map[string]interface{}{
  30164. "failed_code": -10,
  30165. "msg": err_msg,
  30166. })
  30167. return
  30168. }
  30169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30170. result, _ := json.Marshal(respJSON)
  30171. fmt.Println("log")
  30172. fmt.Println(string(result))
  30173. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30174. utils.ErrorLog("解析失败:%v", err)
  30175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30176. return
  30177. }
  30178. res.InfRefmsgid = ahres.InfRefmsgid
  30179. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30180. // 创建对应的Time类型
  30181. t := time.UnixMilli(timestamp)
  30182. // 格式化成指定的日期字符串
  30183. str := t.Format("2006-01-02 15:04:05")
  30184. res.Output.Setlinfo.SetlTime = str
  30185. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30186. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30187. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30188. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30189. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30190. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30191. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30192. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30193. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30194. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30195. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30196. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30197. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30198. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30199. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30200. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30201. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30202. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30203. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30204. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30205. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30206. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30207. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30208. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30209. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30210. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30211. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30212. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30213. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30214. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30215. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30216. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30217. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30218. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30219. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30220. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30221. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30222. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30223. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30224. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30225. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30226. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30227. //res.Output.Setldetail = ahres.Output.Setldetail
  30228. res.ErrMsg = ahres.ErrMsg
  30229. res.Cainfo = ahres.Cainfo
  30230. res.WarnMsg = ahres.WarnMsg
  30231. res.Infcode = ahres.Infcode
  30232. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30233. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30234. if his.IdCardType == 4 {
  30235. psn_info.VerifyNumber = psn_info.VerifyNumber
  30236. cert_no = psn_info.Certno
  30237. } else if his.IdCardType == 2 {
  30238. cert_no = psn_info.Certno
  30239. psn_info.VerifyNumber = psn_info.Certno
  30240. } else {
  30241. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30242. bas := strings.Split(psn_info.CardInfo, "|")
  30243. if his.IdCardType == 1 {
  30244. cert_no = bas[2]
  30245. } else {
  30246. cert_no = bas[1]
  30247. }
  30248. }
  30249. var api string
  30250. var med_type string
  30251. if his.Insutype == "390" {
  30252. if reg_type == 992102 {
  30253. med_type = "992102"
  30254. }
  30255. if reg_type == 140104 {
  30256. med_type = "140104"
  30257. }
  30258. if reg_type == 140201 {
  30259. med_type = "140201"
  30260. }
  30261. if reg_type == 14 {
  30262. med_type = "14"
  30263. }
  30264. } else if his.Insutype == "310" {
  30265. if reg_type == 992102 {
  30266. med_type = "992102"
  30267. }
  30268. if reg_type == 140104 {
  30269. med_type = "140104"
  30270. }
  30271. if reg_type == 140201 {
  30272. med_type = "140201"
  30273. }
  30274. if reg_type == 14 {
  30275. med_type = "14"
  30276. }
  30277. }
  30278. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30279. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30280. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30281. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30282. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30283. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30284. "&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
  30285. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30286. resp, requestErr := http.Get(api)
  30287. if requestErr != nil {
  30288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30289. return
  30290. }
  30291. body, ioErr := ioutil.ReadAll(resp.Body)
  30292. if ioErr != nil {
  30293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30295. return
  30296. }
  30297. var respJSON map[string]interface{}
  30298. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30301. return
  30302. }
  30303. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30304. if status == "0" {
  30305. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30306. c.ServeSuccessJSON(map[string]interface{}{
  30307. "failed_code": -10,
  30308. "msg": err_msg,
  30309. })
  30310. return
  30311. }
  30312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30313. result, _ := json.Marshal(respJSON)
  30314. fmt.Println("log")
  30315. fmt.Println(string(result))
  30316. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30317. utils.ErrorLog("解析失败:%v", err)
  30318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30319. return
  30320. }
  30321. res.InfRefmsgid = ahres.InfRefmsgid
  30322. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30323. // 创建对应的Time类型
  30324. t := time.UnixMilli(timestamp)
  30325. // 格式化成指定的日期字符串
  30326. str := t.Format("2006-01-02 15:04:05")
  30327. res.Output.Setlinfo.SetlTime = str
  30328. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30329. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30330. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30331. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30332. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30333. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30334. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30335. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30336. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30337. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30338. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30339. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30340. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30341. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30342. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30343. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30344. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30345. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30346. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30347. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30348. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30349. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30350. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30351. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30352. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30353. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30354. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30355. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30356. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30357. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30358. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30359. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30360. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30361. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30362. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30363. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30364. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30365. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30366. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30367. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30368. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30369. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30370. //res.Output.Setldetail = ahres.Output.Setldetail
  30371. res.ErrMsg = ahres.ErrMsg
  30372. res.Cainfo = ahres.Cainfo
  30373. res.WarnMsg = ahres.WarnMsg
  30374. res.Infcode = ahres.Infcode
  30375. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30376. var result string
  30377. var request_log string
  30378. if his.IdCardType == 2 {
  30379. 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")
  30380. } else if his.IdCardType == 1 {
  30381. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30382. bas := strings.Split(psn_info.CardInfo, "|")
  30383. basNumber := bas[2]
  30384. card_sn := bas[3]
  30385. 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")
  30386. } else {
  30387. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30388. 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")
  30389. }
  30390. var dat map[string]interface{}
  30391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30392. fmt.Println(dat)
  30393. } else {
  30394. fmt.Println(err)
  30395. }
  30396. saveLog(result, request_log, "2206", "预结算")
  30397. userJSONBytes, _ := json.Marshal(dat)
  30398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30399. utils.ErrorLog("解析失败:%v", err)
  30400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30401. return
  30402. }
  30403. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30404. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30405. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30406. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30407. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30408. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30409. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30410. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30411. resp, requestErr := http.Get(api)
  30412. if requestErr != nil {
  30413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30414. return
  30415. }
  30416. body, ioErr := ioutil.ReadAll(resp.Body)
  30417. if ioErr != nil {
  30418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30420. return
  30421. }
  30422. var respJSON map[string]interface{}
  30423. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30426. return
  30427. }
  30428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30429. result, _ := json.Marshal(respJSON)
  30430. fmt.Println("log")
  30431. fmt.Println(string(result))
  30432. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30433. utils.ErrorLog("解析失败:%v", err)
  30434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30435. return
  30436. }
  30437. } else {
  30438. if miConfig.MdtrtareaAdmvs == "441202" {
  30439. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30440. if result3101.Infcode == 0 {
  30441. if len(result3101.Output.Result) > 0 {
  30442. var errMsgs []string
  30443. for _, item := range result3101.Output.Result {
  30444. errMsgs = append(errMsgs, item.VolaCont)
  30445. }
  30446. c.ServeSuccessJSON(map[string]interface{}{
  30447. "failed_code": -10,
  30448. "msg": errMsgs,
  30449. })
  30450. return
  30451. } else {
  30452. var result string
  30453. var request_log string
  30454. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30455. allTotal = fmt.Sprintf("%.2f", total_two)
  30456. if his.IdCardType == 4 {
  30457. 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)
  30458. } else {
  30459. 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)
  30460. }
  30461. var dat map[string]interface{}
  30462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30463. fmt.Println(dat)
  30464. } else {
  30465. fmt.Println(err)
  30466. }
  30467. saveLog(result, request_log, "2206", "预结算")
  30468. //userJSONBytes, _ := json.Marshal(dat)
  30469. //
  30470. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30471. // utils.ErrorLog("解析失败:%v", err)
  30472. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30473. // return
  30474. //}
  30475. userJSONBytes, _ := json.Marshal(dat)
  30476. if miConfig.Code == "H15049901371" {
  30477. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30478. utils.ErrorLog("解析失败:%v", err)
  30479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30480. return
  30481. }
  30482. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30483. res.Output = resSeven10265.Output
  30484. res.ErrMsg = resSeven10265.ErrMsg
  30485. res.Cainfo = resSeven10265.Cainfo
  30486. res.WarnMsg = resSeven10265.WarnMsg
  30487. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30488. res.Infcode = infocode
  30489. } else {
  30490. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30491. utils.ErrorLog("解析失败:%v", err)
  30492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30493. return
  30494. }
  30495. }
  30496. }
  30497. } else {
  30498. c.ServeSuccessJSON(map[string]interface{}{
  30499. "failed_code": -10,
  30500. "msg": result3101.ErrMsg,
  30501. })
  30502. return
  30503. }
  30504. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30505. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30506. if result3101.Infcode == 0 {
  30507. if len(result3101.Output.Result) > 0 {
  30508. var errMsgs []string
  30509. for _, item := range result3101.Output.Result {
  30510. errMsgs = append(errMsgs, item.VolaCont)
  30511. }
  30512. c.ServeSuccessJSON(map[string]interface{}{
  30513. "failed_code": -10,
  30514. "msg": errMsgs,
  30515. })
  30516. return
  30517. } else {
  30518. var result string
  30519. var request_log string
  30520. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30521. allTotal = fmt.Sprintf("%.2f", total_two)
  30522. if his.IdCardType == 4 {
  30523. 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)
  30524. } else {
  30525. 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)
  30526. }
  30527. var dat map[string]interface{}
  30528. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30529. fmt.Println(dat)
  30530. } else {
  30531. fmt.Println(err)
  30532. }
  30533. saveLog(result, request_log, "2206", "预结算")
  30534. //userJSONBytes, _ := json.Marshal(dat)
  30535. //
  30536. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30537. // utils.ErrorLog("解析失败:%v", err)
  30538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30539. // return
  30540. //}
  30541. userJSONBytes, _ := json.Marshal(dat)
  30542. if miConfig.Code == "H15049901371" {
  30543. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30544. utils.ErrorLog("解析失败:%v", err)
  30545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30546. return
  30547. }
  30548. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30549. res.Output = resSeven10265.Output
  30550. res.ErrMsg = resSeven10265.ErrMsg
  30551. res.Cainfo = resSeven10265.Cainfo
  30552. res.WarnMsg = resSeven10265.WarnMsg
  30553. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30554. res.Infcode = infocode
  30555. } else {
  30556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30557. utils.ErrorLog("解析失败:%v", err)
  30558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30559. return
  30560. }
  30561. }
  30562. }
  30563. } else {
  30564. c.ServeSuccessJSON(map[string]interface{}{
  30565. "failed_code": -10,
  30566. "msg": result3101.ErrMsg,
  30567. })
  30568. return
  30569. }
  30570. } else {
  30571. var result string
  30572. var request_log string
  30573. var dat map[string]interface{}
  30574. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30575. allTotal = fmt.Sprintf("%.2f", total_two)
  30576. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  30577. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30578. if result3101.Infcode == 0 {
  30579. if len(result3101.Output.Result) > 0 {
  30580. var errMsgs []string
  30581. for _, item := range result3101.Output.Result {
  30582. errMsgs = append(errMsgs, item.VolaCont)
  30583. }
  30584. c.ServeSuccessJSON(map[string]interface{}{
  30585. "failed_code": -10,
  30586. "msg": errMsgs,
  30587. })
  30588. return
  30589. } else {
  30590. var result string
  30591. var request_log string
  30592. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30593. allTotal = fmt.Sprintf("%.2f", total_two)
  30594. if his.IdCardType == 4 {
  30595. 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)
  30596. } else {
  30597. if his.IdCardType == 2 {
  30598. cert_no = psn_info.Certno
  30599. psn_info.VerifyNumber = psn_info.Certno
  30600. } else {
  30601. bas := strings.Split(psn_info.CardInfo, "|")
  30602. cert_no = bas[2]
  30603. }
  30604. 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)
  30605. }
  30606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30607. fmt.Println(dat)
  30608. } else {
  30609. fmt.Println(err)
  30610. }
  30611. saveLog(result, request_log, "2206", "预结算")
  30612. }
  30613. } else {
  30614. c.ServeSuccessJSON(map[string]interface{}{
  30615. "failed_code": -10,
  30616. "msg": result3101.ErrMsg,
  30617. })
  30618. return
  30619. }
  30620. } else {
  30621. if his.IdCardType == 4 {
  30622. 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)
  30623. } else {
  30624. if his.IdCardType == 2 {
  30625. cert_no = psn_info.Certno
  30626. psn_info.VerifyNumber = psn_info.Certno
  30627. } else {
  30628. bas := strings.Split(psn_info.CardInfo, "|")
  30629. cert_no = bas[2]
  30630. }
  30631. 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)
  30632. }
  30633. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30634. fmt.Println(dat)
  30635. } else {
  30636. fmt.Println(err)
  30637. }
  30638. saveLog(result, request_log, "2206", "预结算")
  30639. }
  30640. //userJSONBytes, _ := json.Marshal(dat)
  30641. //
  30642. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30643. // utils.ErrorLog("解析失败:%v", err)
  30644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30645. // return
  30646. //}
  30647. userJSONBytes, _ := json.Marshal(dat)
  30648. if miConfig.Code == "H15049901371" {
  30649. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30650. utils.ErrorLog("解析失败:%v", err)
  30651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30652. return
  30653. }
  30654. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30655. res.Output = resSeven10265.Output
  30656. res.ErrMsg = resSeven10265.ErrMsg
  30657. res.Cainfo = resSeven10265.Cainfo
  30658. res.WarnMsg = resSeven10265.WarnMsg
  30659. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30660. res.Infcode = infocode
  30661. } else {
  30662. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30663. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30664. utils.ErrorLog("解析失败:%v", err)
  30665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30666. return
  30667. }
  30668. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30669. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30670. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30671. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30672. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30673. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30674. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30675. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30676. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30677. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30678. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30679. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30680. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30681. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30682. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30683. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30684. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30685. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30686. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30687. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30688. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30689. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30690. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30691. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30692. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30693. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30694. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30695. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30696. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30697. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30698. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30699. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30700. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30701. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30702. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30703. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30704. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30705. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30706. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30707. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30708. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30709. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30710. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30711. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30712. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30713. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30714. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30715. res.Cainfo = gzresSeven10265Two.Cainfo
  30716. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30717. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30718. //res.Infcode = infocode
  30719. } else {
  30720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30721. utils.ErrorLog("解析失败:%v", err)
  30722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30723. return
  30724. }
  30725. }
  30726. }
  30727. }
  30728. }
  30729. utils.ErrorLog("解析失败:%v", res.Infcode)
  30730. if res.Infcode == -1 {
  30731. errlog := &models.HisOrderError{
  30732. UserOrgId: adminUser.CurrentOrgId,
  30733. Ctime: time.Now().Unix(),
  30734. Mtime: time.Now().Unix(),
  30735. Number: chrg_bchno,
  30736. ErrMsg: res.ErrMsg,
  30737. Status: 1,
  30738. PatientId: id,
  30739. RecordTime: recordDateTime,
  30740. Stage: 20,
  30741. }
  30742. service.CreateErrMsgLog(errlog)
  30743. c.ServeSuccessJSON(map[string]interface{}{
  30744. "failed_code": -10,
  30745. "msg": res.ErrMsg,
  30746. })
  30747. return
  30748. }
  30749. if res.Infcode != 0 {
  30750. errlog := &models.HisOrderError{
  30751. UserOrgId: adminUser.CurrentOrgId,
  30752. Ctime: time.Now().Unix(),
  30753. Mtime: time.Now().Unix(),
  30754. Number: chrg_bchno,
  30755. ErrMsg: res.ErrMsg,
  30756. Status: 1,
  30757. PatientId: id,
  30758. RecordTime: recordDateTime,
  30759. Stage: 20,
  30760. }
  30761. service.CreateErrMsgLog(errlog)
  30762. c.ServeSuccessJSON(map[string]interface{}{
  30763. "failed_code": -10,
  30764. "msg": res.ErrMsg,
  30765. })
  30766. return
  30767. } else {
  30768. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30769. order.OrderStatus = 1
  30770. order.IsPre = 1
  30771. order.Status = 1
  30772. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30773. order.SetlId = res.Output.Setlinfo.SetlID
  30774. order.PsnNo = res.Output.Setlinfo.PsnNo
  30775. order.PsnName = res.Output.Setlinfo.PsnName
  30776. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30777. order.Certno = res.Output.Setlinfo.Certno
  30778. order.Gend = res.Output.Setlinfo.Gend
  30779. order.Naty = res.Output.Setlinfo.Naty
  30780. order.Age = res.Output.Setlinfo.Age
  30781. order.Insutype = res.Output.Setlinfo.Insutype
  30782. order.PsnType = res.Output.Setlinfo.PsnType
  30783. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30784. order.SetlTime = res.Output.Setlinfo.SetlTime
  30785. order.AcctUsedFlag = acct_used_flag
  30786. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30787. if res.Output.Setlinfo.MedType == "140101" {
  30788. order.MedType = "14"
  30789. } else {
  30790. if res.Output.Setlinfo.MedType == "110104" {
  30791. order.MedType = "11"
  30792. } else {
  30793. order.MedType = res.Output.Setlinfo.MedType
  30794. }
  30795. }
  30796. if res.Output.Setlinfo.MedType == "992102" {
  30797. order.MedType = "992102"
  30798. }
  30799. if res.Output.Setlinfo.MedType == "140104" {
  30800. order.MedType = "140104"
  30801. }
  30802. if res.Output.Setlinfo.MedType == "140201" {
  30803. order.MedType = "140201"
  30804. }
  30805. if res.Output.Setlinfo.MedType == "14" {
  30806. order.MedType = "14"
  30807. }
  30808. if reg_type == 1112 {
  30809. order.MedType = "1112"
  30810. }
  30811. if reg_type == 1111 {
  30812. order.MedType = "1111"
  30813. }
  30814. order.ClrType = res.Output.Setlinfo.ClrType
  30815. if adminUser.CurrentOrgId == 10480 {
  30816. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30817. order.ClrType = "11"
  30818. } else {
  30819. order.ClrType = "9903"
  30820. }
  30821. }
  30822. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30823. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30824. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30825. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30826. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30827. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30828. order.HifpPay = res.Output.Setlinfo.HifpPay
  30829. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30830. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30831. order.HifesPay = res.Output.Setlinfo.HifesPay
  30832. order.HifobPay = res.Output.Setlinfo.HifobPay
  30833. order.MafPay = res.Output.Setlinfo.MafPay
  30834. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30835. order.OthPay = res.Output.Setlinfo.OthPay
  30836. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30837. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30838. order.AcctPay = res.Output.Setlinfo.AcctPay
  30839. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30840. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30841. order.Balc = res.Output.Setlinfo.Balc
  30842. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30843. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30844. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30845. order.ClrWay = res.Output.Setlinfo.ClrWay
  30846. order.Creator = order.Creator
  30847. order.Modify = roles.AdminUserId
  30848. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30849. //detailStr := string(setlDetail)
  30850. //order.SetlDetail = detailStr
  30851. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30852. err = service.UpDateOrder(order)
  30853. if err == nil {
  30854. c.ServeSuccessJSON(map[string]interface{}{
  30855. "msg": "预结算成功",
  30856. })
  30857. } else {
  30858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30859. return
  30860. }
  30861. }
  30862. } else {
  30863. adminUser := c.GetAdminUserInfo()
  30864. errlog := &models.HisOrderError{
  30865. UserOrgId: adminUser.CurrentOrgId,
  30866. Ctime: time.Now().Unix(),
  30867. Mtime: time.Now().Unix(),
  30868. ErrMsg: res.ErrMsg,
  30869. Status: 1,
  30870. PatientId: id,
  30871. RecordTime: recordDateTime,
  30872. Stage: 4,
  30873. }
  30874. service.CreateErrMsgLog(errlog)
  30875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  30876. return
  30877. }
  30878. } else {
  30879. if miConfig.MdtrtareaAdmvs == "150499" {
  30880. order := &models.HisOrder{
  30881. UserOrgId: adminUser.CurrentOrgId,
  30882. HisPatientId: his.ID,
  30883. PatientId: his.PatientId,
  30884. SettleAccountsDate: recordDateTime,
  30885. Ctime: time.Now().Unix(),
  30886. Mtime: time.Now().Unix(),
  30887. MdtrtId: his.Number,
  30888. PsnNo: his.PsnNo,
  30889. MedType: strconv.FormatInt(reg_type, 10),
  30890. Status: 1,
  30891. Number: chrg_bchno,
  30892. Infcode: res.Infcode,
  30893. WarnMsg: res.WarnMsg,
  30894. Cainfo: res.Cainfo,
  30895. ErrMsg: res.ErrMsg,
  30896. RespondTime: res.RefmsgTime,
  30897. InfRefmsgid: res.InfRefmsgid,
  30898. OrderStatus: 1,
  30899. IsMedicineInsurance: 1,
  30900. SettleType: settle_accounts_type,
  30901. SettleStartTime: start_time,
  30902. SettleEndTime: end_time,
  30903. Creator: roles.AdminUserId,
  30904. Modify: roles.AdminUserId,
  30905. PType: 2,
  30906. Diagnosis: diagnosis_id,
  30907. }
  30908. err = service.CreateOrder(order)
  30909. if err != nil {
  30910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30911. return
  30912. }
  30913. }
  30914. adminUser := c.GetAdminUserInfo()
  30915. errlog := &models.HisOrderError{
  30916. UserOrgId: adminUser.CurrentOrgId,
  30917. Ctime: time.Now().Unix(),
  30918. Mtime: time.Now().Unix(),
  30919. ErrMsg: res.ErrMsg,
  30920. Status: 1,
  30921. PatientId: id,
  30922. RecordTime: recordDateTime,
  30923. Stage: 4,
  30924. }
  30925. service.CreateErrMsgLog(errlog)
  30926. c.ServeSuccessJSON(map[string]interface{}{
  30927. "failed_code": -10,
  30928. "msg": res.ErrMsg,
  30929. })
  30930. return
  30931. }
  30932. }
  30933. }
  30934. }
  30935. // 退款
  30936. func (c *HisApiController) Refund() {
  30937. order_id, _ := c.GetInt64("order_id")
  30938. admin_user_id, _ := c.GetInt64("admin_user_id")
  30939. adminUser := c.GetAdminUserInfo()
  30940. var order models.HisOrder
  30941. order, _ = service.GetHisOrderByID(order_id)
  30942. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  30943. if fapiao.ID > 0 {
  30944. c.ServeSuccessJSON(map[string]interface{}{
  30945. "failed_code": -10,
  30946. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  30947. })
  30948. return
  30949. }
  30950. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30951. if order.ID == 0 {
  30952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30953. return
  30954. }
  30955. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30956. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30957. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30958. if config.IsOpen == 1 { //对接了医保,走医保流程
  30959. var res ResultSixteen
  30960. var ahres ResultSevenAH
  30961. var resSixteen10265 ResultSixteen10265
  30962. var resSixteen10265Two ResultSixteen10265Two
  30963. var gz ResultgzSixteen10265Two
  30964. var src_resquest string
  30965. var result string
  30966. if miConfig.MdtrtareaAdmvs == "421300" {
  30967. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30968. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30969. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30970. resp3, requestErr3 := http.Get(api3)
  30971. if requestErr3 != nil {
  30972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30973. return
  30974. }
  30975. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30976. if ioErr3 != nil {
  30977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30979. return
  30980. }
  30981. var respJSON3 map[string]interface{}
  30982. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30985. return
  30986. }
  30987. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30988. userJSONBytes3, _ := json.Marshal(respJSON3)
  30989. fmt.Println("log")
  30990. fmt.Println(string(userJSONBytes3))
  30991. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30992. utils.ErrorLog("解析失败:%v", err)
  30993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30994. return
  30995. }
  30996. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30997. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30998. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30999. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31000. resp3, requestErr3 := http.Get(api3)
  31001. if requestErr3 != nil {
  31002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31003. return
  31004. }
  31005. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31006. if ioErr3 != nil {
  31007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31009. return
  31010. }
  31011. var respJSON3 map[string]interface{}
  31012. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31015. return
  31016. }
  31017. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31018. userJSONBytes3, _ := json.Marshal(respJSON3)
  31019. fmt.Println("log")
  31020. fmt.Println(string(userJSONBytes3))
  31021. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31022. utils.ErrorLog("解析失败:%v", err)
  31023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31024. return
  31025. }
  31026. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31027. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31028. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31029. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31030. resp3, requestErr3 := http.Get(api3)
  31031. if requestErr3 != nil {
  31032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31033. return
  31034. }
  31035. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31036. if ioErr3 != nil {
  31037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31039. return
  31040. }
  31041. var respJSON3 map[string]interface{}
  31042. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31045. return
  31046. }
  31047. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31048. userJSONBytes3, _ := json.Marshal(respJSON3)
  31049. fmt.Println("log")
  31050. fmt.Println(string(userJSONBytes3))
  31051. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31052. utils.ErrorLog("解析失败:%v", err)
  31053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31054. return
  31055. }
  31056. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31057. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31058. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31059. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31060. resp3, requestErr3 := http.Get(api3)
  31061. if requestErr3 != nil {
  31062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31063. return
  31064. }
  31065. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31066. if ioErr3 != nil {
  31067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31069. return
  31070. }
  31071. var respJSON3 map[string]interface{}
  31072. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31075. return
  31076. }
  31077. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31078. userJSONBytes3, _ := json.Marshal(respJSON3)
  31079. fmt.Println("log")
  31080. fmt.Println(string(userJSONBytes3))
  31081. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31082. utils.ErrorLog("解析失败:%v", err)
  31083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31084. return
  31085. }
  31086. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31087. var api3 string
  31088. if miConfig.MdtrtareaAdmvs == "320921" {
  31089. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31090. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31091. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31092. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31093. } else {
  31094. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31095. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31096. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31097. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31098. }
  31099. resp3, requestErr3 := http.Get(api3)
  31100. if requestErr3 != nil {
  31101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31102. return
  31103. }
  31104. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31105. if ioErr3 != nil {
  31106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31108. return
  31109. }
  31110. var respJSON3 map[string]interface{}
  31111. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31114. return
  31115. }
  31116. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31117. userJSONBytes3, _ := json.Marshal(respJSON3)
  31118. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31119. utils.ErrorLog("解析失败:%v", err)
  31120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31121. return
  31122. }
  31123. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31124. res.Output = resSixteen10265.Output
  31125. res.ErrMsg = resSixteen10265.ErrMsg
  31126. res.Cainfo = resSixteen10265.Cainfo
  31127. res.WarnMsg = resSixteen10265.WarnMsg
  31128. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31129. res.Infcode = infocode
  31130. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31131. var api3 string
  31132. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31133. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31134. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31135. resp3, requestErr3 := http.Get(api3)
  31136. if requestErr3 != nil {
  31137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31138. return
  31139. }
  31140. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31141. if ioErr3 != nil {
  31142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31144. return
  31145. }
  31146. var respJSON3 map[string]interface{}
  31147. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31150. return
  31151. }
  31152. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31153. userJSONBytes3, _ := json.Marshal(respJSON3)
  31154. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31155. utils.ErrorLog("解析失败:%v", err)
  31156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31157. return
  31158. }
  31159. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31160. res.Output = resSixteen10265.Output
  31161. res.ErrMsg = resSixteen10265.ErrMsg
  31162. res.Cainfo = resSixteen10265.Cainfo
  31163. res.WarnMsg = resSixteen10265.WarnMsg
  31164. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31165. res.Infcode = infocode
  31166. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31167. 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)
  31168. var dat map[string]interface{}
  31169. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31170. fmt.Println(dat)
  31171. } else {
  31172. fmt.Println(err)
  31173. }
  31174. saveLog(result, src_resquest, "2208", "退费")
  31175. userJSONBytes, _ := json.Marshal(dat)
  31176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31177. utils.ErrorLog("解析失败:%v", err)
  31178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31179. return
  31180. }
  31181. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31182. 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, "")
  31183. var dat map[string]interface{}
  31184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31185. fmt.Println(dat)
  31186. } else {
  31187. fmt.Println(err)
  31188. }
  31189. saveLog(result, src_resquest, "2208", "退费")
  31190. userJSONBytes, _ := json.Marshal(dat)
  31191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31192. utils.ErrorLog("解析失败:%v", err)
  31193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31194. return
  31195. }
  31196. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31197. 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, "")
  31198. var dat map[string]interface{}
  31199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31200. fmt.Println(dat)
  31201. } else {
  31202. fmt.Println(err)
  31203. }
  31204. saveLog(result, src_resquest, "2208", "退费")
  31205. userJSONBytes, _ := json.Marshal(dat)
  31206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31207. utils.ErrorLog("解析失败:%v", err)
  31208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31209. return
  31210. }
  31211. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31212. var api3 string
  31213. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31214. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31215. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31216. resp3, requestErr3 := http.Get(api3)
  31217. if requestErr3 != nil {
  31218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31219. return
  31220. }
  31221. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31222. if ioErr3 != nil {
  31223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31225. return
  31226. }
  31227. var respJSON3 map[string]interface{}
  31228. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31231. return
  31232. }
  31233. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31234. if status == "0" {
  31235. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31236. c.ServeSuccessJSON(map[string]interface{}{
  31237. "failed_code": -10,
  31238. "msg": err_msg,
  31239. })
  31240. return
  31241. }
  31242. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31243. userJSONBytes3, _ := json.Marshal(respJSON3)
  31244. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31245. // utils.ErrorLog("解析失败:%v", err)
  31246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31247. // return
  31248. //}
  31249. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31250. utils.ErrorLog("解析失败:%v", err)
  31251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31252. return
  31253. }
  31254. res.InfRefmsgid = ahres.InfRefmsgid
  31255. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31256. // 创建对应的Time类型
  31257. t := time.UnixMilli(timestamp)
  31258. // 格式化成指定的日期字符串
  31259. str := t.Format("2006-01-02 15:04:05")
  31260. res.Output.Setlinfo.SetlTime = str
  31261. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31262. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31263. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31264. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31265. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31266. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31267. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31268. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31269. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31270. //
  31271. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31272. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31273. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31274. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31275. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31276. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31277. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31278. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31279. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31280. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31281. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31282. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31283. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31284. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31285. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31286. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31287. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31288. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31289. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31290. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31291. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31292. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31293. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31294. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31295. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31296. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31297. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31298. //res.Output.Setldetail = ahres.Output.Setldetail
  31299. res.ErrMsg = ahres.ErrMsg
  31300. res.Cainfo = ahres.Cainfo
  31301. res.WarnMsg = ahres.WarnMsg
  31302. res.Infcode = ahres.Infcode
  31303. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31304. var api3 string
  31305. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31306. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31307. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31308. resp3, requestErr3 := http.Get(api3)
  31309. if requestErr3 != nil {
  31310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31311. return
  31312. }
  31313. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31314. if ioErr3 != nil {
  31315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31317. return
  31318. }
  31319. var respJSON3 map[string]interface{}
  31320. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31323. return
  31324. }
  31325. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31326. if status == "0" {
  31327. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31328. c.ServeSuccessJSON(map[string]interface{}{
  31329. "failed_code": -10,
  31330. "msg": err_msg,
  31331. })
  31332. return
  31333. }
  31334. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31335. userJSONBytes3, _ := json.Marshal(respJSON3)
  31336. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31337. // utils.ErrorLog("解析失败:%v", err)
  31338. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31339. // return
  31340. //}
  31341. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31342. utils.ErrorLog("解析失败:%v", err)
  31343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31344. return
  31345. }
  31346. res.InfRefmsgid = ahres.InfRefmsgid
  31347. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31348. // 创建对应的Time类型
  31349. t := time.UnixMilli(timestamp)
  31350. // 格式化成指定的日期字符串
  31351. str := t.Format("2006-01-02 15:04:05")
  31352. res.Output.Setlinfo.SetlTime = str
  31353. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31354. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31355. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31356. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31357. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31358. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31359. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31360. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31361. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31362. //
  31363. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31364. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31365. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31366. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31367. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31368. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31369. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31370. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31371. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31372. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31373. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31374. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31375. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31376. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31377. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31378. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31379. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31380. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31381. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31382. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31383. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31384. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31385. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31386. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31387. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31388. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31389. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31390. //res.Output.Setldetail = ahres.Output.Setldetail
  31391. res.ErrMsg = ahres.ErrMsg
  31392. res.Cainfo = ahres.Cainfo
  31393. res.WarnMsg = ahres.WarnMsg
  31394. res.Infcode = ahres.Infcode
  31395. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31396. 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, "")
  31397. var dat map[string]interface{}
  31398. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31399. fmt.Println(dat)
  31400. } else {
  31401. fmt.Println(err)
  31402. }
  31403. saveLog(result, src_resquest, "2208", "退费")
  31404. userJSONBytes, _ := json.Marshal(dat)
  31405. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31406. utils.ErrorLog("解析失败:%v", err)
  31407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31408. return
  31409. }
  31410. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31411. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31412. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31413. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31414. resp3, requestErr3 := http.Get(api3)
  31415. if requestErr3 != nil {
  31416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31417. return
  31418. }
  31419. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31420. if ioErr3 != nil {
  31421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31423. return
  31424. }
  31425. var respJSON3 map[string]interface{}
  31426. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31429. return
  31430. }
  31431. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31432. userJSONBytes3, _ := json.Marshal(respJSON3)
  31433. fmt.Println("log")
  31434. fmt.Println(string(userJSONBytes3))
  31435. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31436. utils.ErrorLog("解析失败:%v", err)
  31437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31438. return
  31439. }
  31440. } else {
  31441. if miConfig.Code == "H15049901371" {
  31442. 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)
  31443. var dat map[string]interface{}
  31444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31445. fmt.Println(dat)
  31446. } else {
  31447. fmt.Println(err)
  31448. }
  31449. saveLog(result, src_resquest, "2208", "退费")
  31450. if strings.Contains(result, "Post") {
  31451. res.Infcode = -1
  31452. res.ErrMsg = result
  31453. }
  31454. userJSONBytes, _ := json.Marshal(dat)
  31455. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31456. utils.ErrorLog("解析失败:%v", err)
  31457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31458. return
  31459. }
  31460. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31461. res.Output = resSixteen10265.Output
  31462. res.ErrMsg = resSixteen10265.ErrMsg
  31463. res.Cainfo = resSixteen10265.Cainfo
  31464. res.WarnMsg = resSixteen10265.WarnMsg
  31465. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31466. res.Infcode = infocode
  31467. } else {
  31468. 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)
  31469. var dat map[string]interface{}
  31470. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31471. fmt.Println(dat)
  31472. } else {
  31473. fmt.Println(err)
  31474. }
  31475. saveLog(result, src_resquest, "2208", "退费")
  31476. userJSONBytes, _ := json.Marshal(dat)
  31477. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31478. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31479. utils.ErrorLog("解析失败:%v", err)
  31480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31481. return
  31482. }
  31483. res.Infcode = gz.Infcode
  31484. } else {
  31485. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31486. utils.ErrorLog("解析失败:%v", err)
  31487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31488. return
  31489. }
  31490. }
  31491. if strings.Contains(result, "Post") {
  31492. res.Infcode = -1
  31493. res.ErrMsg = result
  31494. }
  31495. }
  31496. }
  31497. if res.Infcode == -1 {
  31498. c.ServeSuccessJSON(map[string]interface{}{
  31499. "failed_code": -10,
  31500. "msg": res.ErrMsg,
  31501. })
  31502. return
  31503. }
  31504. if res.Infcode != -1 {
  31505. var res2 ResultSix
  31506. var resSix10265 ResultSix10265
  31507. if miConfig.MdtrtareaAdmvs == "421300" {
  31508. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31509. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31510. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31511. resp3, requestErr3 := http.Get(api3)
  31512. if requestErr3 != nil {
  31513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31514. return
  31515. }
  31516. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31517. if ioErr3 != nil {
  31518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31520. return
  31521. }
  31522. var respJSON3 map[string]interface{}
  31523. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31526. return
  31527. }
  31528. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31529. userJSONBytes3, _ := json.Marshal(respJSON3)
  31530. fmt.Println("log")
  31531. fmt.Println(string(userJSONBytes3))
  31532. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31533. utils.ErrorLog("解析失败:%v", err)
  31534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31535. return
  31536. }
  31537. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31538. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31539. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31540. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31541. resp3, requestErr3 := http.Get(api3)
  31542. if requestErr3 != nil {
  31543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31544. return
  31545. }
  31546. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31547. if ioErr3 != nil {
  31548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31550. return
  31551. }
  31552. var respJSON3 map[string]interface{}
  31553. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31556. return
  31557. }
  31558. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31559. userJSONBytes3, _ := json.Marshal(respJSON3)
  31560. fmt.Println("log")
  31561. fmt.Println(string(userJSONBytes3))
  31562. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31563. utils.ErrorLog("解析失败:%v", err)
  31564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31565. return
  31566. }
  31567. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31568. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31569. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31570. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31571. resp3, requestErr3 := http.Get(api3)
  31572. if requestErr3 != nil {
  31573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31574. return
  31575. }
  31576. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31577. if ioErr3 != nil {
  31578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31580. return
  31581. }
  31582. var respJSON3 map[string]interface{}
  31583. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31586. return
  31587. }
  31588. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31589. userJSONBytes3, _ := json.Marshal(respJSON3)
  31590. fmt.Println("log")
  31591. fmt.Println(string(userJSONBytes3))
  31592. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31593. utils.ErrorLog("解析失败:%v", err)
  31594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31595. return
  31596. }
  31597. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31598. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31599. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31600. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31601. resp3, requestErr3 := http.Get(api3)
  31602. if requestErr3 != nil {
  31603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31604. return
  31605. }
  31606. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31607. if ioErr3 != nil {
  31608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31610. return
  31611. }
  31612. var respJSON3 map[string]interface{}
  31613. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31616. return
  31617. }
  31618. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31619. userJSONBytes3, _ := json.Marshal(respJSON3)
  31620. fmt.Println("log")
  31621. fmt.Println(string(userJSONBytes3))
  31622. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31623. utils.ErrorLog("解析失败:%v", err)
  31624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31625. return
  31626. }
  31627. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31628. var api3 string
  31629. if miConfig.MdtrtareaAdmvs == "320921" {
  31630. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31631. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31632. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31633. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31634. } else {
  31635. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31636. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31637. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31638. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31639. }
  31640. resp3, requestErr3 := http.Get(api3)
  31641. if requestErr3 != nil {
  31642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31643. return
  31644. }
  31645. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31646. if ioErr3 != nil {
  31647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31649. return
  31650. }
  31651. var respJSON3 map[string]interface{}
  31652. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31655. return
  31656. }
  31657. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31658. userJSONBytes3, _ := json.Marshal(respJSON3)
  31659. fmt.Println("log")
  31660. fmt.Println(string(userJSONBytes3))
  31661. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31662. utils.ErrorLog("解析失败:%v", err)
  31663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31664. return
  31665. }
  31666. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31667. res2.Output = resSix10265.Output
  31668. res2.ErrMsg = resSix10265.ErrMsg
  31669. res2.Cainfo = resSix10265.Cainfo
  31670. res2.WarnMsg = resSix10265.WarnMsg
  31671. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31672. res2.Infcode = infocode
  31673. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31674. var api3 string
  31675. new_chrg_bchno := order.Number
  31676. if adminUser.CurrentOrgId == 10265 {
  31677. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31678. new_chrg_bchno = "0000"
  31679. }
  31680. }
  31681. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31682. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31683. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31684. resp3, requestErr3 := http.Get(api3)
  31685. if requestErr3 != nil {
  31686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31687. return
  31688. }
  31689. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31690. if ioErr3 != nil {
  31691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31693. return
  31694. }
  31695. var respJSON3 map[string]interface{}
  31696. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31699. return
  31700. }
  31701. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31702. userJSONBytes3, _ := json.Marshal(respJSON3)
  31703. fmt.Println("log")
  31704. fmt.Println(string(userJSONBytes3))
  31705. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31706. utils.ErrorLog("解析失败:%v", err)
  31707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31708. return
  31709. }
  31710. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31711. res2.Output = resSix10265.Output
  31712. res2.ErrMsg = resSix10265.ErrMsg
  31713. res2.Cainfo = resSix10265.Cainfo
  31714. res2.WarnMsg = resSix10265.WarnMsg
  31715. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31716. res2.Infcode = infocode
  31717. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31718. 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)
  31719. var dat map[string]interface{}
  31720. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31721. fmt.Println(dat)
  31722. } else {
  31723. fmt.Println(err)
  31724. }
  31725. saveLog(result2, src_request, "2205", "撤销明细")
  31726. userJSONBytes, _ := json.Marshal(dat)
  31727. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31728. utils.ErrorLog("解析失败:%v", err)
  31729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31730. return
  31731. }
  31732. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31733. 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, "")
  31734. var dat map[string]interface{}
  31735. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31736. fmt.Println(dat)
  31737. } else {
  31738. fmt.Println(err)
  31739. }
  31740. saveLog(result2, src_request, "2205", "撤销明细")
  31741. userJSONBytes, _ := json.Marshal(dat)
  31742. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31743. utils.ErrorLog("解析失败:%v", err)
  31744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31745. return
  31746. }
  31747. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31748. 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, "")
  31749. var dat map[string]interface{}
  31750. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31751. fmt.Println(dat)
  31752. } else {
  31753. fmt.Println(err)
  31754. }
  31755. saveLog(result2, src_request, "2205", "撤销明细")
  31756. userJSONBytes, _ := json.Marshal(dat)
  31757. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31758. utils.ErrorLog("解析失败:%v", err)
  31759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31760. return
  31761. }
  31762. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31763. var api3 string
  31764. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31765. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31766. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31767. resp3, requestErr3 := http.Get(api3)
  31768. if requestErr3 != nil {
  31769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31770. return
  31771. }
  31772. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31773. if ioErr3 != nil {
  31774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31776. return
  31777. }
  31778. var respJSON3 map[string]interface{}
  31779. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31782. return
  31783. }
  31784. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31785. if status == "0" {
  31786. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31787. c.ServeSuccessJSON(map[string]interface{}{
  31788. "failed_code": -10,
  31789. "msg": err_msg,
  31790. })
  31791. return
  31792. }
  31793. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31794. userJSONBytes3, _ := json.Marshal(respJSON3)
  31795. fmt.Println("log")
  31796. fmt.Println(string(userJSONBytes3))
  31797. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31798. utils.ErrorLog("解析失败:%v", err)
  31799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31800. return
  31801. }
  31802. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31803. 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, "")
  31804. var dat map[string]interface{}
  31805. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31806. fmt.Println(dat)
  31807. } else {
  31808. fmt.Println(err)
  31809. }
  31810. saveLog(result2, src_request, "2205", "撤销明细")
  31811. userJSONBytes, _ := json.Marshal(dat)
  31812. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31813. utils.ErrorLog("解析失败:%v", err)
  31814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31815. return
  31816. }
  31817. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31818. 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, "")
  31819. var dat map[string]interface{}
  31820. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31821. fmt.Println(dat)
  31822. } else {
  31823. fmt.Println(err)
  31824. }
  31825. saveLog(result2, src_request, "2205", "撤销明细")
  31826. userJSONBytes, _ := json.Marshal(dat)
  31827. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31828. utils.ErrorLog("解析失败:%v", err)
  31829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31830. return
  31831. }
  31832. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31833. var api3 string
  31834. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31835. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31836. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31837. resp3, requestErr3 := http.Get(api3)
  31838. if requestErr3 != nil {
  31839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31840. return
  31841. }
  31842. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31843. if ioErr3 != nil {
  31844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31846. return
  31847. }
  31848. var respJSON3 map[string]interface{}
  31849. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31852. return
  31853. }
  31854. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31855. if status == "0" {
  31856. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31857. c.ServeSuccessJSON(map[string]interface{}{
  31858. "failed_code": -10,
  31859. "msg": err_msg,
  31860. })
  31861. return
  31862. }
  31863. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31864. userJSONBytes3, _ := json.Marshal(respJSON3)
  31865. fmt.Println("log")
  31866. fmt.Println(string(userJSONBytes3))
  31867. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31868. utils.ErrorLog("解析失败:%v", err)
  31869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31870. return
  31871. }
  31872. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31873. 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, "")
  31874. var dat map[string]interface{}
  31875. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31876. fmt.Println(dat)
  31877. } else {
  31878. fmt.Println(err)
  31879. }
  31880. saveLog(result2, src_request, "2205", "撤销明细")
  31881. userJSONBytes, _ := json.Marshal(dat)
  31882. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31883. utils.ErrorLog("解析失败:%v", err)
  31884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31885. return
  31886. }
  31887. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31888. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  31889. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31890. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31891. resp3, requestErr3 := http.Get(api3)
  31892. if requestErr3 != nil {
  31893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31894. return
  31895. }
  31896. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31897. if ioErr3 != nil {
  31898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31900. return
  31901. }
  31902. var respJSON3 map[string]interface{}
  31903. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31906. return
  31907. }
  31908. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31909. userJSONBytes3, _ := json.Marshal(respJSON3)
  31910. fmt.Println("log")
  31911. fmt.Println(string(userJSONBytes3))
  31912. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31913. utils.ErrorLog("解析失败:%v", err)
  31914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31915. return
  31916. }
  31917. } else {
  31918. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31919. res2.Infcode = 0
  31920. } else {
  31921. 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)
  31922. var dat map[string]interface{}
  31923. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31924. fmt.Println(dat)
  31925. } else {
  31926. fmt.Println(err)
  31927. }
  31928. saveLog(result2, src_request, "2205", "撤销明细")
  31929. userJSONBytes, _ := json.Marshal(dat)
  31930. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31931. utils.ErrorLog("解析失败:%v", err)
  31932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31933. return
  31934. }
  31935. }
  31936. }
  31937. if res2.Infcode == -1 {
  31938. c.ServeSuccessJSON(map[string]interface{}{
  31939. "failed_code": -10,
  31940. "msg": res2.ErrMsg,
  31941. })
  31942. return
  31943. }
  31944. if res2.Infcode == 0 {
  31945. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  31946. if err == nil {
  31947. //当押金不为零时产生退费记录
  31948. if order.Decimal != 0 {
  31949. tmp := strconv.FormatInt(order.ID, 10)
  31950. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  31951. if err != nil {
  31952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31953. return
  31954. }
  31955. }
  31956. c.ServeSuccessJSON(map[string]interface{}{
  31957. "msg": "退费成功",
  31958. })
  31959. } else {
  31960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31961. return
  31962. }
  31963. } else {
  31964. c.ServeSuccessJSON(map[string]interface{}{
  31965. "failed_code": -10,
  31966. "msg": res2.ErrMsg,
  31967. })
  31968. }
  31969. } else {
  31970. c.ServeSuccessJSON(map[string]interface{}{
  31971. "failed_code": -10,
  31972. "msg": res.ErrMsg,
  31973. })
  31974. }
  31975. }
  31976. }
  31977. func (c *HisApiController) RefundNumber() {
  31978. record_time := c.GetString("record_time")
  31979. //patient_id, _ := c.GetInt64("patient_id")
  31980. admin_user_id, _ := c.GetInt64("admin_user_id")
  31981. his_patient_id, _ := c.GetInt64("id")
  31982. timeLayout := "2006-01-02"
  31983. loc, _ := time.LoadLocation("Local")
  31984. adminUser := c.GetAdminUserInfo()
  31985. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31986. fmt.Println(err)
  31987. if err != nil {
  31988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31989. return
  31990. }
  31991. recordDateTime := theTime.Unix()
  31992. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31993. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  31994. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31995. //order, _ := service.GetHisOrderByID(order_id)
  31996. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31997. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31998. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31999. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32000. if count > 0 {
  32001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32002. return
  32003. }
  32004. if config.IsOpen == 1 { //对接了医保,走医保流程
  32005. var res2 ResultSix
  32006. var res3 GZResultSix
  32007. var resSix10265 ResultSix10265
  32008. if miConfig.MdtrtareaAdmvs == "421300" {
  32009. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32010. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32011. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32012. resp3, requestErr3 := http.Get(api3)
  32013. if requestErr3 != nil {
  32014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32015. return
  32016. }
  32017. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32018. if ioErr3 != nil {
  32019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32021. return
  32022. }
  32023. var respJSON3 map[string]interface{}
  32024. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32027. return
  32028. }
  32029. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32030. userJSONBytes3, _ := json.Marshal(respJSON3)
  32031. fmt.Println("log")
  32032. fmt.Println(string(userJSONBytes3))
  32033. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32034. utils.ErrorLog("解析失败:%v", err)
  32035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32036. return
  32037. }
  32038. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32039. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32040. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32041. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32042. resp3, requestErr3 := http.Get(api3)
  32043. if requestErr3 != nil {
  32044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32045. return
  32046. }
  32047. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32048. if ioErr3 != nil {
  32049. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32051. return
  32052. }
  32053. var respJSON3 map[string]interface{}
  32054. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32057. return
  32058. }
  32059. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32060. userJSONBytes3, _ := json.Marshal(respJSON3)
  32061. fmt.Println("log")
  32062. fmt.Println(string(userJSONBytes3))
  32063. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32064. utils.ErrorLog("解析失败:%v", err)
  32065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32066. return
  32067. }
  32068. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32069. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32070. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32071. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32072. resp3, requestErr3 := http.Get(api3)
  32073. if requestErr3 != nil {
  32074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32075. return
  32076. }
  32077. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32078. if ioErr3 != nil {
  32079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32081. return
  32082. }
  32083. var respJSON3 map[string]interface{}
  32084. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32087. return
  32088. }
  32089. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32090. userJSONBytes3, _ := json.Marshal(respJSON3)
  32091. fmt.Println("log")
  32092. fmt.Println(string(userJSONBytes3))
  32093. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32094. utils.ErrorLog("解析失败:%v", err)
  32095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32096. return
  32097. }
  32098. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32099. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32100. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32101. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32102. resp3, requestErr3 := http.Get(api3)
  32103. if requestErr3 != nil {
  32104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32105. return
  32106. }
  32107. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32108. if ioErr3 != nil {
  32109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32111. return
  32112. }
  32113. var respJSON3 map[string]interface{}
  32114. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32117. return
  32118. }
  32119. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32120. userJSONBytes3, _ := json.Marshal(respJSON3)
  32121. fmt.Println("log")
  32122. fmt.Println(string(userJSONBytes3))
  32123. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32124. utils.ErrorLog("解析失败:%v", err)
  32125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32126. return
  32127. }
  32128. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32129. var api3 string
  32130. if miConfig.MdtrtareaAdmvs == "320921" {
  32131. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32132. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32133. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32134. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32135. } else {
  32136. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32137. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32138. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32139. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32140. }
  32141. resp3, requestErr3 := http.Get(api3)
  32142. if requestErr3 != nil {
  32143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32144. return
  32145. }
  32146. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32147. if ioErr3 != nil {
  32148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32150. return
  32151. }
  32152. var respJSON3 map[string]interface{}
  32153. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32156. return
  32157. }
  32158. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32159. userJSONBytes3, _ := json.Marshal(respJSON3)
  32160. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32161. utils.ErrorLog("解析失败:%v", err)
  32162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32163. return
  32164. }
  32165. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32166. res2.Output = resSix10265.Output
  32167. res2.ErrMsg = resSix10265.ErrMsg
  32168. res2.Cainfo = resSix10265.Cainfo
  32169. res2.WarnMsg = resSix10265.WarnMsg
  32170. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32171. res2.Infcode = infocode
  32172. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32173. var api3 string
  32174. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32175. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32176. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32177. resp3, requestErr3 := http.Get(api3)
  32178. if requestErr3 != nil {
  32179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32180. return
  32181. }
  32182. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32183. if ioErr3 != nil {
  32184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32186. return
  32187. }
  32188. var respJSON3 map[string]interface{}
  32189. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32192. return
  32193. }
  32194. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32195. userJSONBytes3, _ := json.Marshal(respJSON3)
  32196. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32197. utils.ErrorLog("解析失败:%v", err)
  32198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32199. return
  32200. }
  32201. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32202. res2.Output = resSix10265.Output
  32203. res2.ErrMsg = resSix10265.ErrMsg
  32204. res2.Cainfo = resSix10265.Cainfo
  32205. res2.WarnMsg = resSix10265.WarnMsg
  32206. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32207. res2.Infcode = infocode
  32208. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32209. 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)
  32210. var dat map[string]interface{}
  32211. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32212. fmt.Println(dat)
  32213. } else {
  32214. fmt.Println(err)
  32215. }
  32216. saveLog(result, request, "2202", "退号")
  32217. userJSONBytes, _ := json.Marshal(dat)
  32218. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32219. utils.ErrorLog("解析失败:%v", err)
  32220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32221. return
  32222. }
  32223. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32224. 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, "")
  32225. var dat map[string]interface{}
  32226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32227. fmt.Println(dat)
  32228. } else {
  32229. fmt.Println(err)
  32230. }
  32231. saveLog(result, request, "2202", "退号")
  32232. userJSONBytes, _ := json.Marshal(dat)
  32233. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32234. utils.ErrorLog("解析失败:%v", err)
  32235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32236. return
  32237. }
  32238. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32239. 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, "")
  32240. var dat map[string]interface{}
  32241. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32242. fmt.Println(dat)
  32243. } else {
  32244. fmt.Println(err)
  32245. }
  32246. saveLog(result, request, "2202", "退号")
  32247. userJSONBytes, _ := json.Marshal(dat)
  32248. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32249. utils.ErrorLog("解析失败:%v", err)
  32250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32251. return
  32252. }
  32253. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32254. var api3 string
  32255. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32256. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32257. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32258. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32259. resp3, requestErr3 := http.Get(api3)
  32260. if requestErr3 != nil {
  32261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32262. return
  32263. }
  32264. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32265. if ioErr3 != nil {
  32266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32268. return
  32269. }
  32270. var respJSON3 map[string]interface{}
  32271. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32274. return
  32275. }
  32276. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32277. if status == "0" {
  32278. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32279. c.ServeSuccessJSON(map[string]interface{}{
  32280. "failed_code": -10,
  32281. "msg": err_msg,
  32282. })
  32283. return
  32284. }
  32285. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32286. userJSONBytes3, _ := json.Marshal(respJSON3)
  32287. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32288. utils.ErrorLog("解析失败:%v", err)
  32289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32290. return
  32291. }
  32292. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32293. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32294. var api3 string
  32295. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32296. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32297. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32298. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32299. resp3, requestErr3 := http.Get(api3)
  32300. if requestErr3 != nil {
  32301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32302. return
  32303. }
  32304. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32305. if ioErr3 != nil {
  32306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32308. return
  32309. }
  32310. var respJSON3 map[string]interface{}
  32311. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32314. return
  32315. }
  32316. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32317. if status == "0" {
  32318. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32319. c.ServeSuccessJSON(map[string]interface{}{
  32320. "failed_code": -10,
  32321. "msg": err_msg,
  32322. })
  32323. return
  32324. }
  32325. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32326. userJSONBytes3, _ := json.Marshal(respJSON3)
  32327. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32328. utils.ErrorLog("解析失败:%v", err)
  32329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32330. return
  32331. }
  32332. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32333. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32334. 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, "")
  32335. var dat map[string]interface{}
  32336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32337. fmt.Println(dat)
  32338. } else {
  32339. fmt.Println(err)
  32340. }
  32341. saveLog(result, request, "2202", "退号")
  32342. userJSONBytes, _ := json.Marshal(dat)
  32343. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32344. utils.ErrorLog("解析失败:%v", err)
  32345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32346. return
  32347. }
  32348. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32349. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32350. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32351. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32352. resp3, requestErr3 := http.Get(api3)
  32353. if requestErr3 != nil {
  32354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32355. return
  32356. }
  32357. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32358. if ioErr3 != nil {
  32359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32361. return
  32362. }
  32363. var respJSON3 map[string]interface{}
  32364. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32367. return
  32368. }
  32369. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32370. userJSONBytes3, _ := json.Marshal(respJSON3)
  32371. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32372. utils.ErrorLog("解析失败:%v", err)
  32373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32374. return
  32375. }
  32376. } else {
  32377. var api3 string
  32378. if miConfig.Code == "H15049901371" {
  32379. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32380. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32381. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32382. } else {
  32383. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32384. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32385. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32386. }
  32387. resp3, requestErr3 := http.Get(api3)
  32388. if requestErr3 != nil {
  32389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32390. return
  32391. }
  32392. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32393. if ioErr3 != nil {
  32394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32396. return
  32397. }
  32398. var respJSON3 map[string]interface{}
  32399. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32402. return
  32403. }
  32404. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32405. userJSONBytes3, _ := json.Marshal(respJSON3)
  32406. if miConfig.Code == "H15049901371" {
  32407. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32408. utils.ErrorLog("解析失败:%v", err)
  32409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32410. return
  32411. }
  32412. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32413. res2.Output = resSix10265.Output
  32414. res2.ErrMsg = resSix10265.ErrMsg
  32415. res2.Cainfo = resSix10265.Cainfo
  32416. res2.WarnMsg = resSix10265.WarnMsg
  32417. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32418. res2.Infcode = infocode
  32419. } else {
  32420. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32421. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32422. utils.ErrorLog("解析失败:%v", err)
  32423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32424. return
  32425. }
  32426. res2.Infcode = res3.Infcode
  32427. } else {
  32428. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32429. utils.ErrorLog("解析失败:%v", err)
  32430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32431. return
  32432. }
  32433. }
  32434. }
  32435. }
  32436. if res2.Infcode == -1 {
  32437. c.ServeSuccessJSON(map[string]interface{}{
  32438. "failed_code": -10,
  32439. "msg": res2.ErrMsg,
  32440. })
  32441. return
  32442. }
  32443. if res2.Infcode == 0 {
  32444. if err == nil {
  32445. c.ServeSuccessJSON(map[string]interface{}{
  32446. "msg": "退号成功",
  32447. })
  32448. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32449. } else {
  32450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32451. return
  32452. }
  32453. }
  32454. } else {
  32455. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32456. //if err == nil {
  32457. // c.ServeSuccessJSON(map[string]interface{}{
  32458. // "msg": "退费成功",
  32459. // })
  32460. //} else {
  32461. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32462. // return
  32463. //}
  32464. }
  32465. }
  32466. func (c *HisApiController) RefundDetail() {
  32467. order_id, _ := c.GetInt64("order_id")
  32468. admin_user_id, _ := c.GetInt64("admin_user_id")
  32469. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32470. number := c.GetString("number")
  32471. record_time := c.GetString("record_time")
  32472. patient_id, _ := c.GetInt64("patient_id")
  32473. //med_type, _ := c.GetInt64("med_type")
  32474. timeLayout := "2006-01-02"
  32475. loc, _ := time.LoadLocation("Local")
  32476. adminUser := c.GetAdminUserInfo()
  32477. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32478. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32479. fmt.Println(err)
  32480. if err != nil {
  32481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32482. return
  32483. }
  32484. recordDateTime := theTime.Unix()
  32485. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32486. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32487. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32488. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32489. var order models.HisOrder
  32490. order, _ = service.GetHisOrderByID(order_id)
  32491. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32492. if config.IsOpen == 1 { //对接了医保,走医保流程
  32493. var res2 ResultSix
  32494. if miConfig.MdtrtareaAdmvs == "421300" {
  32495. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32496. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32497. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32498. resp3, requestErr3 := http.Get(api3)
  32499. if requestErr3 != nil {
  32500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32501. return
  32502. }
  32503. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32504. if ioErr3 != nil {
  32505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32507. return
  32508. }
  32509. var respJSON3 map[string]interface{}
  32510. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32513. return
  32514. }
  32515. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32516. userJSONBytes3, _ := json.Marshal(respJSON3)
  32517. fmt.Println("log")
  32518. fmt.Println(string(userJSONBytes3))
  32519. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32520. utils.ErrorLog("解析失败:%v", err)
  32521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32522. return
  32523. }
  32524. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32525. if err == nil {
  32526. c.ServeSuccessJSON(map[string]interface{}{
  32527. "msg": "撤销明细成功",
  32528. })
  32529. return
  32530. } else {
  32531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32532. return
  32533. }
  32534. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32535. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32536. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32537. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32538. resp3, requestErr3 := http.Get(api3)
  32539. if requestErr3 != nil {
  32540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32541. return
  32542. }
  32543. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32544. if ioErr3 != nil {
  32545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32547. return
  32548. }
  32549. var respJSON3 map[string]interface{}
  32550. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32553. return
  32554. }
  32555. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32556. userJSONBytes3, _ := json.Marshal(respJSON3)
  32557. fmt.Println("log")
  32558. fmt.Println(string(userJSONBytes3))
  32559. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32560. utils.ErrorLog("解析失败:%v", err)
  32561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32562. return
  32563. }
  32564. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32565. if err == nil {
  32566. c.ServeSuccessJSON(map[string]interface{}{
  32567. "msg": "撤销明细成功",
  32568. })
  32569. return
  32570. } else {
  32571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32572. return
  32573. }
  32574. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32575. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32576. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32577. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32578. resp3, requestErr3 := http.Get(api3)
  32579. if requestErr3 != nil {
  32580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32581. return
  32582. }
  32583. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32584. if ioErr3 != nil {
  32585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32587. return
  32588. }
  32589. var respJSON3 map[string]interface{}
  32590. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32593. return
  32594. }
  32595. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32596. userJSONBytes3, _ := json.Marshal(respJSON3)
  32597. fmt.Println("log")
  32598. fmt.Println(string(userJSONBytes3))
  32599. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32600. utils.ErrorLog("解析失败:%v", err)
  32601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32602. return
  32603. }
  32604. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32605. if err == nil {
  32606. c.ServeSuccessJSON(map[string]interface{}{
  32607. "msg": "撤销明细成功",
  32608. })
  32609. return
  32610. } else {
  32611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32612. return
  32613. }
  32614. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32615. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32616. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32617. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32618. resp3, requestErr3 := http.Get(api3)
  32619. if requestErr3 != nil {
  32620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32621. return
  32622. }
  32623. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32624. if ioErr3 != nil {
  32625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32627. return
  32628. }
  32629. var respJSON3 map[string]interface{}
  32630. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32633. return
  32634. }
  32635. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32636. userJSONBytes3, _ := json.Marshal(respJSON3)
  32637. fmt.Println("log")
  32638. fmt.Println(string(userJSONBytes3))
  32639. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32640. utils.ErrorLog("解析失败:%v", err)
  32641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32642. return
  32643. }
  32644. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32645. if err == nil {
  32646. c.ServeSuccessJSON(map[string]interface{}{
  32647. "msg": "撤销明细成功",
  32648. })
  32649. return
  32650. } else {
  32651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32652. return
  32653. }
  32654. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32655. var resSix10265 ResultSix10265
  32656. var api3 string
  32657. if miConfig.MdtrtareaAdmvs == "320921" {
  32658. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32659. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32660. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32661. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32662. } else {
  32663. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32664. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32665. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32666. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32667. }
  32668. resp3, requestErr3 := http.Get(api3)
  32669. utils.ErrorLog("接口: %v", requestErr3)
  32670. if requestErr3 != nil {
  32671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32672. return
  32673. }
  32674. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32675. if ioErr3 != nil {
  32676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32678. return
  32679. }
  32680. var respJSON3 map[string]interface{}
  32681. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32684. return
  32685. }
  32686. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32687. userJSONBytes3, _ := json.Marshal(respJSON3)
  32688. fmt.Println("log")
  32689. fmt.Println(string(userJSONBytes3))
  32690. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32691. utils.ErrorLog("解析失败:%v", err)
  32692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32693. return
  32694. }
  32695. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32696. res2.Output = resSix10265.Output
  32697. res2.ErrMsg = resSix10265.ErrMsg
  32698. res2.Cainfo = resSix10265.Cainfo
  32699. res2.WarnMsg = resSix10265.WarnMsg
  32700. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32701. res2.Infcode = infocode
  32702. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32703. if err == nil {
  32704. c.ServeSuccessJSON(map[string]interface{}{
  32705. "msg": "撤销明细成功",
  32706. })
  32707. return
  32708. } else {
  32709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32710. return
  32711. }
  32712. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32713. var api3 string
  32714. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32715. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32716. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32717. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32718. resp3, requestErr3 := http.Get(api3)
  32719. utils.ErrorLog("接口: %v", requestErr3)
  32720. if requestErr3 != nil {
  32721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32722. return
  32723. }
  32724. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32725. if ioErr3 != nil {
  32726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32728. return
  32729. }
  32730. var respJSON3 map[string]interface{}
  32731. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32734. return
  32735. }
  32736. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32737. if status == "0" {
  32738. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32739. c.ServeSuccessJSON(map[string]interface{}{
  32740. "failed_code": -10,
  32741. "msg": err_msg,
  32742. })
  32743. return
  32744. }
  32745. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32746. userJSONBytes3, _ := json.Marshal(respJSON3)
  32747. fmt.Println("log")
  32748. fmt.Println(string(userJSONBytes3))
  32749. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32750. utils.ErrorLog("解析失败:%v", err)
  32751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32752. return
  32753. }
  32754. fmt.Println(res2.Infcode)
  32755. if res2.Infcode == -1 {
  32756. c.ServeSuccessJSON(map[string]interface{}{
  32757. "failed_code": -10,
  32758. "msg": res2.ErrMsg,
  32759. })
  32760. return
  32761. }
  32762. if res2.Infcode == 0 {
  32763. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32764. if err == nil {
  32765. c.ServeSuccessJSON(map[string]interface{}{
  32766. "msg": "撤销明细成功",
  32767. })
  32768. return
  32769. } else {
  32770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32771. return
  32772. }
  32773. } else {
  32774. c.ServeSuccessJSON(map[string]interface{}{
  32775. "failed_code": -10,
  32776. "msg": res2.ErrMsg,
  32777. })
  32778. }
  32779. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32780. if err == nil {
  32781. c.ServeSuccessJSON(map[string]interface{}{
  32782. "msg": "撤销明细成功",
  32783. })
  32784. return
  32785. } else {
  32786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32787. return
  32788. }
  32789. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32790. var api3 string
  32791. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32792. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32793. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32794. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32795. resp3, requestErr3 := http.Get(api3)
  32796. utils.ErrorLog("接口: %v", requestErr3)
  32797. if requestErr3 != nil {
  32798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32799. return
  32800. }
  32801. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32802. if ioErr3 != nil {
  32803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32805. return
  32806. }
  32807. var respJSON3 map[string]interface{}
  32808. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32811. return
  32812. }
  32813. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32814. if status == "0" {
  32815. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32816. c.ServeSuccessJSON(map[string]interface{}{
  32817. "failed_code": -10,
  32818. "msg": err_msg,
  32819. })
  32820. return
  32821. }
  32822. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32823. userJSONBytes3, _ := json.Marshal(respJSON3)
  32824. fmt.Println("log")
  32825. fmt.Println(string(userJSONBytes3))
  32826. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32827. utils.ErrorLog("解析失败:%v", err)
  32828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32829. return
  32830. }
  32831. fmt.Println(res2.Infcode)
  32832. if res2.Infcode == -1 {
  32833. c.ServeSuccessJSON(map[string]interface{}{
  32834. "failed_code": -10,
  32835. "msg": res2.ErrMsg,
  32836. })
  32837. return
  32838. }
  32839. if res2.Infcode == 0 {
  32840. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32841. if err == nil {
  32842. c.ServeSuccessJSON(map[string]interface{}{
  32843. "msg": "撤销明细成功",
  32844. })
  32845. return
  32846. } else {
  32847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32848. return
  32849. }
  32850. } else {
  32851. c.ServeSuccessJSON(map[string]interface{}{
  32852. "failed_code": -10,
  32853. "msg": res2.ErrMsg,
  32854. })
  32855. }
  32856. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32857. if err == nil {
  32858. c.ServeSuccessJSON(map[string]interface{}{
  32859. "msg": "撤销明细成功",
  32860. })
  32861. return
  32862. } else {
  32863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32864. return
  32865. }
  32866. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32867. var resSix10265 ResultSix10265
  32868. new_chrg_bchno := order.Number
  32869. if adminUser.CurrentOrgId == 10265 {
  32870. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32871. new_chrg_bchno = "0000"
  32872. }
  32873. }
  32874. var api3 string
  32875. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32876. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32877. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32878. resp3, requestErr3 := http.Get(api3)
  32879. if requestErr3 != nil {
  32880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32881. return
  32882. }
  32883. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32884. if ioErr3 != nil {
  32885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32887. return
  32888. }
  32889. var respJSON3 map[string]interface{}
  32890. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32893. return
  32894. }
  32895. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32896. userJSONBytes3, _ := json.Marshal(respJSON3)
  32897. fmt.Println("log")
  32898. fmt.Println(string(userJSONBytes3))
  32899. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32900. utils.ErrorLog("解析失败:%v", err)
  32901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32902. return
  32903. }
  32904. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32905. res2.Output = resSix10265.Output
  32906. res2.ErrMsg = resSix10265.ErrMsg
  32907. res2.Cainfo = resSix10265.Cainfo
  32908. res2.WarnMsg = resSix10265.WarnMsg
  32909. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32910. res2.Infcode = infocode
  32911. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32912. if err == nil {
  32913. c.ServeSuccessJSON(map[string]interface{}{
  32914. "msg": "撤销明细成功",
  32915. })
  32916. return
  32917. } else {
  32918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32919. return
  32920. }
  32921. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32922. 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)
  32923. var dat map[string]interface{}
  32924. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32925. fmt.Println(dat)
  32926. } else {
  32927. fmt.Println(err)
  32928. }
  32929. saveLog(result2, src_request, "2205", "撤销明细")
  32930. userJSONBytes, _ := json.Marshal(dat)
  32931. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32932. utils.ErrorLog("解析失败:%v", err)
  32933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32934. return
  32935. }
  32936. if res2.Infcode == 0 {
  32937. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32938. if err == nil {
  32939. c.ServeSuccessJSON(map[string]interface{}{
  32940. "msg": "撤销明细成功",
  32941. })
  32942. return
  32943. } else {
  32944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32945. return
  32946. }
  32947. } else {
  32948. c.ServeSuccessJSON(map[string]interface{}{
  32949. "failed_code": -10,
  32950. "msg": res2.ErrMsg,
  32951. })
  32952. }
  32953. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32954. 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, "")
  32955. var dat map[string]interface{}
  32956. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32957. fmt.Println(dat)
  32958. } else {
  32959. fmt.Println(err)
  32960. }
  32961. saveLog(result2, src_request, "2205", "撤销明细")
  32962. userJSONBytes, _ := json.Marshal(dat)
  32963. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32964. utils.ErrorLog("解析失败:%v", err)
  32965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32966. return
  32967. }
  32968. if res2.Infcode == 0 {
  32969. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32970. if err == nil {
  32971. c.ServeSuccessJSON(map[string]interface{}{
  32972. "msg": "撤销明细成功",
  32973. })
  32974. return
  32975. } else {
  32976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32977. return
  32978. }
  32979. } else {
  32980. c.ServeSuccessJSON(map[string]interface{}{
  32981. "failed_code": -10,
  32982. "msg": res2.ErrMsg,
  32983. })
  32984. }
  32985. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32986. 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, "")
  32987. var dat map[string]interface{}
  32988. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32989. fmt.Println(dat)
  32990. } else {
  32991. fmt.Println(err)
  32992. }
  32993. saveLog(result2, src_request, "2205", "撤销明细")
  32994. userJSONBytes, _ := json.Marshal(dat)
  32995. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32996. utils.ErrorLog("解析失败:%v", err)
  32997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32998. return
  32999. }
  33000. if res2.Infcode == 0 {
  33001. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33002. if err == nil {
  33003. c.ServeSuccessJSON(map[string]interface{}{
  33004. "msg": "撤销明细成功",
  33005. })
  33006. return
  33007. } else {
  33008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33009. return
  33010. }
  33011. } else {
  33012. c.ServeSuccessJSON(map[string]interface{}{
  33013. "failed_code": -10,
  33014. "msg": res2.ErrMsg,
  33015. })
  33016. }
  33017. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33018. 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, "")
  33019. var dat map[string]interface{}
  33020. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33021. fmt.Println(dat)
  33022. } else {
  33023. fmt.Println(err)
  33024. }
  33025. saveLog(result2, src_request, "2205", "撤销明细")
  33026. userJSONBytes, _ := json.Marshal(dat)
  33027. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33028. utils.ErrorLog("解析失败:%v", err)
  33029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33030. return
  33031. }
  33032. if res2.Infcode == 0 {
  33033. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33034. if err == nil {
  33035. c.ServeSuccessJSON(map[string]interface{}{
  33036. "msg": "撤销明细成功",
  33037. })
  33038. return
  33039. } else {
  33040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33041. return
  33042. }
  33043. } else {
  33044. c.ServeSuccessJSON(map[string]interface{}{
  33045. "failed_code": -10,
  33046. "msg": res2.ErrMsg,
  33047. })
  33048. }
  33049. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33050. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33051. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33052. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33053. resp2, requestErr2 := http.Get(api2)
  33054. if requestErr2 != nil {
  33055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33056. return
  33057. }
  33058. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33059. if ioErr2 != nil {
  33060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33062. return
  33063. }
  33064. var respJSON2 map[string]interface{}
  33065. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33068. return
  33069. }
  33070. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33071. userJSONBytes3, _ := json.Marshal(respJSON2)
  33072. fmt.Println("log")
  33073. fmt.Println(string(userJSONBytes3))
  33074. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33075. utils.ErrorLog("解析失败:%v", err)
  33076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33077. return
  33078. }
  33079. if res2.Infcode == 0 {
  33080. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33081. if err == nil {
  33082. c.ServeSuccessJSON(map[string]interface{}{
  33083. "msg": "撤销明细成功",
  33084. })
  33085. return
  33086. } else {
  33087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33088. return
  33089. }
  33090. } else {
  33091. c.ServeSuccessJSON(map[string]interface{}{
  33092. "failed_code": -10,
  33093. "msg": res2.ErrMsg,
  33094. })
  33095. }
  33096. } else {
  33097. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33098. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33099. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33100. resp2, requestErr2 := http.Get(api2)
  33101. if requestErr2 != nil {
  33102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33103. return
  33104. }
  33105. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33106. if ioErr2 != nil {
  33107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33109. return
  33110. }
  33111. var respJSON2 map[string]interface{}
  33112. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33115. return
  33116. }
  33117. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33118. userJSONBytes3, _ := json.Marshal(respJSON2)
  33119. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33120. utils.ErrorLog("解析失败:%v", err)
  33121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33122. return
  33123. }
  33124. if res2.Infcode == -1 {
  33125. c.ServeSuccessJSON(map[string]interface{}{
  33126. "failed_code": -10,
  33127. "msg": res2.ErrMsg,
  33128. })
  33129. return
  33130. } else {
  33131. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33132. if err == nil {
  33133. c.ServeSuccessJSON(map[string]interface{}{
  33134. "msg": "撤销明细成功",
  33135. })
  33136. return
  33137. } else {
  33138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33139. return
  33140. }
  33141. }
  33142. }
  33143. } else {
  33144. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33145. if err == nil {
  33146. c.ServeSuccessJSON(map[string]interface{}{
  33147. "msg": "退费成功",
  33148. })
  33149. } else {
  33150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33151. return
  33152. }
  33153. }
  33154. }
  33155. // 对账
  33156. func (c *HisApiController) GetCheckAccount() {
  33157. start_time := c.GetString("start_time")
  33158. end_time := c.GetString("end_time")
  33159. insutype := c.GetString("insutype")
  33160. clr_type := c.GetString("clr_type")
  33161. clr_org := c.GetString("clr_optins")
  33162. admin_user_id, _ := c.GetInt64("admin_user_id")
  33163. adminUser := c.GetAdminUserInfo()
  33164. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33165. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33166. if len(clr_org) == 0 {
  33167. clr_org = miConfig.InsuplcAdmdvs
  33168. }
  33169. timeLayout := "2006-01-02"
  33170. loc, _ := time.LoadLocation("Local")
  33171. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33172. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33173. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33174. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33175. fixmedins_setl_cnt := int64(len(orders))
  33176. var medfee_sumamt float64
  33177. var acct_pay float64
  33178. var fund_pay_sumamt float64
  33179. for _, item := range orders {
  33180. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33181. acct_pay = acct_pay + item.AcctPay
  33182. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33183. }
  33184. var user_name string
  33185. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33186. if role.ID == 0 {
  33187. user_name = "xxx"
  33188. } else {
  33189. user_name = role.UserName
  33190. }
  33191. var res ResultEight
  33192. var res10188 ResultEightFor10188
  33193. if config.IsOpen == 1 {
  33194. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33195. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33196. "insutype=" + insutype +
  33197. "&clr_type=" + clr_type +
  33198. "&setl_optins=" + clr_org +
  33199. "&stmt_begndate=" + start_time +
  33200. "&stm_enddate=" + end_time +
  33201. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33202. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33203. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33204. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33205. "&fixmedins_code=" + miConfig.Code +
  33206. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33207. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33208. "&secret_key=" + miConfig.SecretKey +
  33209. "&org_name=" + miConfig.OrgName +
  33210. "&doctor=" + user_name +
  33211. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33212. fmt.Println(api)
  33213. resp, requestErr := http.Get(api)
  33214. if requestErr != nil {
  33215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33216. return
  33217. }
  33218. body, ioErr := ioutil.ReadAll(resp.Body)
  33219. fmt.Println(body)
  33220. if ioErr != nil {
  33221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33223. return
  33224. }
  33225. var respJSON map[string]interface{}
  33226. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33229. return
  33230. }
  33231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33232. userJSONBytes, _ := json.Marshal(respJSON)
  33233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33234. utils.ErrorLog("解析失败:%v", err)
  33235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33236. return
  33237. }
  33238. res.InfRefmsgid = res10188.InfRefmsgid
  33239. res.Output = res10188.Output
  33240. res.ErrMsg = res10188.ErrMsg
  33241. res.Cainfo = res10188.Cainfo
  33242. res.WarnMsg = res10188.WarnMsg
  33243. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33244. res.Infcode = infocode
  33245. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33246. if clr_type != "9903" {
  33247. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33248. }
  33249. if clr_type == "9903" {
  33250. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33251. }
  33252. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33253. "insutype=" + insutype +
  33254. "&clr_type=" + clr_type +
  33255. "&setl_optins=" + clr_org +
  33256. "&stmt_begndate=" + start_time +
  33257. "&stm_enddate=" + end_time +
  33258. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33259. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33260. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33261. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33262. "&fixmedins_code=" + miConfig.Code +
  33263. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33264. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33265. "&secret_key=" + miConfig.SecretKey +
  33266. "&org_name=" + miConfig.OrgName +
  33267. "&doctor=" + user_name
  33268. resp, requestErr := http.Get(api)
  33269. if requestErr != nil {
  33270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33271. return
  33272. }
  33273. body, ioErr := ioutil.ReadAll(resp.Body)
  33274. if ioErr != nil {
  33275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33277. return
  33278. }
  33279. var respJSON map[string]interface{}
  33280. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33283. return
  33284. }
  33285. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33286. result, _ := json.Marshal(respJSON)
  33287. fmt.Println("log")
  33288. fmt.Println(string(result))
  33289. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33290. utils.ErrorLog("解析失败:%v", err)
  33291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33292. return
  33293. }
  33294. res.InfRefmsgid = res10188.InfRefmsgid
  33295. res.Output = res10188.Output
  33296. res.ErrMsg = res10188.ErrMsg
  33297. res.Cainfo = res10188.Cainfo
  33298. res.WarnMsg = res10188.WarnMsg
  33299. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33300. res.Infcode = infocode
  33301. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33302. var baseParams models.BaseParams
  33303. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33304. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33305. baseParams.SecretKey = miConfig.SecretKey
  33306. baseParams.OrgName = miConfig.OrgName
  33307. baseParams.FixmedinsCode = miConfig.Code
  33308. baseParams.EncKey = miConfig.EncKey
  33309. baseParams.AppSecret = miConfig.AppSecret
  33310. baseParams.SignKey = miConfig.SignKey
  33311. baseParams.AppID = miConfig.Code
  33312. baseParams.Doctor = role.UserName
  33313. baseParams.RequestUrl = miConfig.Url
  33314. businessParams := models.BusinessParams{
  33315. Insutype: insutype,
  33316. ClrType: clr_type,
  33317. SetlOptins: clr_org,
  33318. StmtBegndate: start_time,
  33319. StmtEnddate: end_time,
  33320. MedfeeSumamt: medfee_sumamt,
  33321. FundPaySumamt: fund_pay_sumamt,
  33322. AcctPay: acct_pay,
  33323. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33324. }
  33325. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33326. fmt.Println(requestLog)
  33327. fmt.Println(result)
  33328. fmt.Println(err_msg)
  33329. var dat map[string]interface{}
  33330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33331. fmt.Println(dat)
  33332. } else {
  33333. fmt.Println(err)
  33334. }
  33335. userJSONBytes, _ := json.Marshal(dat)
  33336. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33337. utils.ErrorLog("解析失败:%v", err)
  33338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33339. return
  33340. }
  33341. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33342. var baseParams models.BaseParams
  33343. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33344. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33345. baseParams.SecretKey = miConfig.SecretKey
  33346. baseParams.OrgName = miConfig.OrgName
  33347. baseParams.FixmedinsCode = miConfig.Code
  33348. baseParams.EncKey = miConfig.EncKey
  33349. baseParams.AppSecret = miConfig.AppSecret
  33350. baseParams.SignKey = miConfig.SignKey
  33351. baseParams.AppID = miConfig.Code
  33352. baseParams.Doctor = role.UserName
  33353. baseParams.RequestUrl = miConfig.Url
  33354. baseParams.AccessKey = miConfig.AccessKey
  33355. businessParams := models.BusinessParams{
  33356. Insutype: insutype,
  33357. ClrType: clr_type,
  33358. SetlOptins: "430822",
  33359. StmtBegndate: start_time,
  33360. StmtEnddate: end_time,
  33361. MedfeeSumamt: medfee_sumamt,
  33362. FundPaySumamt: fund_pay_sumamt,
  33363. AcctPay: acct_pay,
  33364. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33365. }
  33366. 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)
  33367. fmt.Println(requestLog)
  33368. fmt.Println(result)
  33369. var dat map[string]interface{}
  33370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33371. fmt.Println(dat)
  33372. } else {
  33373. fmt.Println(err)
  33374. }
  33375. userJSONBytes, _ := json.Marshal(dat)
  33376. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33377. utils.ErrorLog("解析失败:%v", err)
  33378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33379. return
  33380. }
  33381. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33382. var baseParams models.BaseParams
  33383. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33384. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33385. baseParams.SecretKey = miConfig.SecretKey
  33386. baseParams.OrgName = miConfig.OrgName
  33387. baseParams.FixmedinsCode = miConfig.Code
  33388. baseParams.EncKey = miConfig.EncKey
  33389. baseParams.AppSecret = miConfig.AppSecret
  33390. baseParams.SignKey = miConfig.SignKey
  33391. baseParams.AppID = miConfig.Code
  33392. baseParams.Doctor = role.UserName
  33393. baseParams.RequestUrl = miConfig.Url
  33394. businessParams := models.BusinessParams{
  33395. Insutype: insutype,
  33396. ClrType: clr_type,
  33397. SetlOptins: clr_org,
  33398. StmtBegndate: start_time,
  33399. StmtEnddate: end_time,
  33400. MedfeeSumamt: medfee_sumamt,
  33401. FundPaySumamt: fund_pay_sumamt,
  33402. AcctPay: acct_pay,
  33403. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33404. }
  33405. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33406. fmt.Println(requestLog)
  33407. fmt.Println(result)
  33408. fmt.Println(err_msg)
  33409. var dat map[string]interface{}
  33410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33411. fmt.Println(dat)
  33412. } else {
  33413. fmt.Println(err)
  33414. }
  33415. userJSONBytes, _ := json.Marshal(dat)
  33416. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33417. utils.ErrorLog("解析失败:%v", err)
  33418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33419. return
  33420. }
  33421. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33422. if len(clr_type) == 0 {
  33423. clr_type = "11"
  33424. }
  33425. api := miConfig.Url + "gdyb/ten?" +
  33426. "insutype=" + insutype +
  33427. "&clr_type=" + clr_type +
  33428. "&setl_optins=" + clr_org +
  33429. "&stmt_begndate=" + start_time +
  33430. "&stm_enddate=" + end_time +
  33431. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33432. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33433. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33434. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33435. "&fixmedins_code=" + miConfig.Code +
  33436. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33437. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33438. "&secret_key=" + miConfig.SecretKey +
  33439. "&org_name=" + miConfig.OrgName +
  33440. "&doctor=" + user_name
  33441. fmt.Println(api)
  33442. resp, requestErr := http.Get(api)
  33443. if requestErr != nil {
  33444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33445. return
  33446. }
  33447. body, ioErr := ioutil.ReadAll(resp.Body)
  33448. fmt.Println(body)
  33449. if ioErr != nil {
  33450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33452. return
  33453. }
  33454. var respJSON map[string]interface{}
  33455. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33458. return
  33459. }
  33460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33461. userJSONBytes, _ := json.Marshal(respJSON)
  33462. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33463. utils.ErrorLog("解析失败:%v", err)
  33464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33465. return
  33466. }
  33467. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33468. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33469. //fixmedins_setl_cnt := int64(len(orders_two))
  33470. //var medfee_sumamt float64
  33471. //var acct_pay float64
  33472. //var fund_pay_sumamt float64
  33473. //for _, item := range orders_two {
  33474. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33475. // acct_pay = acct_pay + item.AcctPay
  33476. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33477. //}
  33478. var baseParams models.BaseParams
  33479. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33480. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33481. baseParams.SecretKey = miConfig.SecretKey
  33482. baseParams.OrgName = miConfig.OrgName
  33483. baseParams.FixmedinsCode = miConfig.Code
  33484. baseParams.EncKey = miConfig.EncKey
  33485. baseParams.AppSecret = miConfig.AppSecret
  33486. baseParams.SignKey = miConfig.SignKey
  33487. baseParams.AppID = miConfig.Code
  33488. baseParams.Doctor = role.UserName
  33489. baseParams.RequestUrl = miConfig.Url
  33490. if clr_type == "9903" {
  33491. clr_type = "9994"
  33492. }
  33493. businessParams := models.BusinessParams{
  33494. Insutype: insutype,
  33495. ClrType: clr_type,
  33496. SetlOptins: "360302",
  33497. StmtBegndate: start_time,
  33498. StmtEnddate: end_time,
  33499. MedfeeSumamt: 0,
  33500. FundPaySumamt: 0,
  33501. AcctPay: 0,
  33502. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33503. }
  33504. 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))
  33505. fmt.Println(requestLog)
  33506. fmt.Println(result)
  33507. var dat map[string]interface{}
  33508. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33509. fmt.Println(dat)
  33510. } else {
  33511. fmt.Println(err)
  33512. }
  33513. userJSONBytes, _ := json.Marshal(dat)
  33514. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33515. utils.ErrorLog("解析失败:%v", err)
  33516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33517. return
  33518. }
  33519. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33520. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33521. fixmedins_setl_cnt := int64(len(orders_two))
  33522. var medfee_sumamt float64
  33523. var acct_pay float64
  33524. var fund_pay_sumamt float64
  33525. for _, item := range orders_two {
  33526. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33527. acct_pay = acct_pay + item.AcctPay
  33528. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33529. }
  33530. var baseParams models.BaseParams
  33531. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33532. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33533. baseParams.SecretKey = miConfig.SecretKey
  33534. baseParams.OrgName = miConfig.OrgName
  33535. baseParams.FixmedinsCode = miConfig.Code
  33536. baseParams.EncKey = miConfig.EncKey
  33537. baseParams.AppSecret = miConfig.AppSecret
  33538. baseParams.SignKey = miConfig.SignKey
  33539. baseParams.AppID = miConfig.Code
  33540. baseParams.Doctor = role.UserName
  33541. baseParams.RequestUrl = miConfig.Url
  33542. if clr_type == "9903" {
  33543. clr_type = "9994"
  33544. }
  33545. businessParams := models.BusinessParams{
  33546. Insutype: insutype,
  33547. ClrType: clr_type,
  33548. SetlOptins: "361025",
  33549. StmtBegndate: start_time,
  33550. StmtEnddate: end_time,
  33551. MedfeeSumamt: 0,
  33552. FundPaySumamt: 0,
  33553. AcctPay: 0,
  33554. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33555. }
  33556. 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))
  33557. fmt.Println(requestLog)
  33558. fmt.Println(result)
  33559. var dat map[string]interface{}
  33560. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33561. fmt.Println(dat)
  33562. } else {
  33563. fmt.Println(err)
  33564. }
  33565. userJSONBytes, _ := json.Marshal(dat)
  33566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33567. utils.ErrorLog("解析失败:%v", err)
  33568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33569. return
  33570. }
  33571. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33572. var api string
  33573. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33574. "&clr_type=" + clr_type +
  33575. "&setl_optins=" + clr_org +
  33576. "&stmt_begndate=" + start_time +
  33577. "&stm_enddate=" + end_time +
  33578. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33579. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33580. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33581. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33582. "&fixmedins_code=" + miConfig.Code +
  33583. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33584. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33585. "&secret_key=" + miConfig.SecretKey +
  33586. "&org_name=" + miConfig.OrgName +
  33587. "&doctor=" + user_name + "&url=" + miConfig.Url
  33588. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33589. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33590. resp, requestErr := http.Get(api)
  33591. if requestErr != nil {
  33592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33593. return
  33594. }
  33595. body, ioErr := ioutil.ReadAll(resp.Body)
  33596. if ioErr != nil {
  33597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33599. return
  33600. }
  33601. var respJSON map[string]interface{}
  33602. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33605. return
  33606. }
  33607. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33608. if status == "0" {
  33609. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33610. c.ServeSuccessJSON(map[string]interface{}{
  33611. "failed_code": -10,
  33612. "msg": err_msg,
  33613. })
  33614. return
  33615. }
  33616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33617. userJSONBytes, _ := json.Marshal(respJSON)
  33618. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33619. utils.ErrorLog("解析失败:%v", err)
  33620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33621. return
  33622. }
  33623. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33624. var api string
  33625. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33626. "&clr_type=" + clr_type +
  33627. "&setl_optins=" + clr_org +
  33628. "&stmt_begndate=" + start_time +
  33629. "&stm_enddate=" + end_time +
  33630. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33631. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33632. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33633. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33634. "&fixmedins_code=" + miConfig.Code +
  33635. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33636. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33637. "&secret_key=" + miConfig.SecretKey +
  33638. "&org_name=" + miConfig.OrgName +
  33639. "&doctor=" + user_name + "&url=" + miConfig.Url
  33640. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33641. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33642. resp, requestErr := http.Get(api)
  33643. if requestErr != nil {
  33644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33645. return
  33646. }
  33647. body, ioErr := ioutil.ReadAll(resp.Body)
  33648. if ioErr != nil {
  33649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33651. return
  33652. }
  33653. var respJSON map[string]interface{}
  33654. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33657. return
  33658. }
  33659. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33660. if status == "0" {
  33661. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33662. c.ServeSuccessJSON(map[string]interface{}{
  33663. "failed_code": -10,
  33664. "msg": err_msg,
  33665. })
  33666. return
  33667. }
  33668. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33669. userJSONBytes, _ := json.Marshal(respJSON)
  33670. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33671. utils.ErrorLog("解析失败:%v", err)
  33672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33673. return
  33674. }
  33675. } else {
  33676. if len(clr_type) == 0 {
  33677. clr_type = "11"
  33678. }
  33679. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33680. "insutype=" + insutype +
  33681. "&clr_type=" + clr_type +
  33682. "&setl_optins=" + clr_org +
  33683. "&stmt_begndate=" + start_time +
  33684. "&stm_enddate=" + end_time +
  33685. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33686. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33687. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33688. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33689. "&fixmedins_code=" + miConfig.Code +
  33690. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33691. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33692. "&secret_key=" + miConfig.SecretKey +
  33693. "&org_name=" + miConfig.OrgName +
  33694. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33695. fmt.Println(api)
  33696. resp, requestErr := http.Get(api)
  33697. if requestErr != nil {
  33698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33699. return
  33700. }
  33701. body, ioErr := ioutil.ReadAll(resp.Body)
  33702. fmt.Println(body)
  33703. if ioErr != nil {
  33704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33706. return
  33707. }
  33708. var respJSON map[string]interface{}
  33709. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33712. return
  33713. }
  33714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33715. userJSONBytes, _ := json.Marshal(respJSON)
  33716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33717. utils.ErrorLog("解析失败:%v", err)
  33718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33719. return
  33720. }
  33721. }
  33722. if res.Infcode == 0 {
  33723. if res.Output.Stmtinfo.StmtRslt == "0" {
  33724. micc := &models.MedicalInsuranceCostCompare{
  33725. StartTime: startime.Unix(),
  33726. EndTime: endtime.Unix(),
  33727. Insutype: insutype,
  33728. CheckType: 1,
  33729. Num: fixmedins_setl_cnt,
  33730. Mtime: time.Now().Unix(),
  33731. Status: 1,
  33732. UserOrgId: adminUser.CurrentOrgId,
  33733. CostTotal: medfee_sumamt,
  33734. FuncTotal: fund_pay_sumamt,
  33735. PsnPay: acct_pay,
  33736. Creator: admin_user_id,
  33737. Ctime: time.Now().Unix(),
  33738. ClrType: clr_type,
  33739. }
  33740. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33741. if err == nil {
  33742. c.ServeSuccessJSON(map[string]interface{}{
  33743. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33744. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33745. })
  33746. } else {
  33747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33748. }
  33749. } else {
  33750. c.ServeSuccessJSON(map[string]interface{}{
  33751. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33752. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33753. })
  33754. }
  33755. } else {
  33756. c.ServeSuccessJSON(map[string]interface{}{
  33757. "failed_code": -10,
  33758. "msg": res.ErrMsg,
  33759. })
  33760. }
  33761. }
  33762. }
  33763. func (c *HisApiController) Check310() {
  33764. adminUser := c.GetAdminUserInfo()
  33765. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33766. var user_name string
  33767. user_name = "高慧裕"
  33768. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33769. "insutype=" + "310" +
  33770. "&clr_type=" + "" +
  33771. "&setl_optins=" + "441202" +
  33772. "&stmt_begndate=" + "2022-03-01" +
  33773. "&stm_enddate=" + "2022-03-31" +
  33774. "&medfee_sumamt=" + "194930.12" +
  33775. "&fund_pay_sumamt=" + "188741.46" +
  33776. "&acct_pay=" + "0" +
  33777. "&fixmedins_setl_cnt=" + "452" +
  33778. "&fixmedins_code=" + miConfig.Code +
  33779. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33780. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33781. "&secret_key=" + miConfig.SecretKey +
  33782. "&org_name=" + miConfig.OrgName +
  33783. "&doctor=" + user_name
  33784. fmt.Println(api)
  33785. resp, requestErr := http.Get(api)
  33786. if requestErr != nil {
  33787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33788. return
  33789. }
  33790. body, ioErr := ioutil.ReadAll(resp.Body)
  33791. fmt.Println(body)
  33792. if ioErr != nil {
  33793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33795. return
  33796. }
  33797. var respJSON map[string]interface{}
  33798. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33801. return
  33802. }
  33803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33804. userJSONBytes, _ := json.Marshal(respJSON)
  33805. var res ResultEight
  33806. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33807. utils.ErrorLog("解析失败:%v", err)
  33808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33809. return
  33810. }
  33811. }
  33812. func (c *HisApiController) Check390() {
  33813. adminUser := c.GetAdminUserInfo()
  33814. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33815. var user_name string
  33816. user_name = "高慧裕"
  33817. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33818. "insutype=" + "390" +
  33819. "&clr_type=" + "" +
  33820. "&setl_optins=" + "441202" +
  33821. "&stmt_begndate=" + "2022-03-01" +
  33822. "&stm_enddate=" + "2022-03-31" +
  33823. "&medfee_sumamt=" + "1068448.89" +
  33824. "&fund_pay_sumamt=" + "1014677.62" +
  33825. "&acct_pay=" + "0" +
  33826. "&fixmedins_setl_cnt=" + "1950" +
  33827. "&fixmedins_code=" + miConfig.Code +
  33828. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33829. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33830. "&secret_key=" + miConfig.SecretKey +
  33831. "&org_name=" + miConfig.OrgName +
  33832. "&doctor=" + user_name
  33833. fmt.Println(api)
  33834. resp, requestErr := http.Get(api)
  33835. if requestErr != nil {
  33836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33837. return
  33838. }
  33839. body, ioErr := ioutil.ReadAll(resp.Body)
  33840. fmt.Println(body)
  33841. if ioErr != nil {
  33842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33844. return
  33845. }
  33846. var respJSON map[string]interface{}
  33847. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33850. return
  33851. }
  33852. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33853. userJSONBytes, _ := json.Marshal(respJSON)
  33854. var res ResultEight
  33855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33856. utils.ErrorLog("解析失败:%v", err)
  33857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33858. return
  33859. }
  33860. }
  33861. // 对账明细
  33862. func (c *HisApiController) GetCheckDetailAccount() {
  33863. start_time := c.GetString("start_time")
  33864. end_time := c.GetString("end_time")
  33865. admin_user_id, _ := c.GetInt64("admin_user_id")
  33866. adminUser := c.GetAdminUserInfo()
  33867. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33868. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33869. timeLayout := "2006-01-02"
  33870. loc, _ := time.LoadLocation("Local")
  33871. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33872. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33873. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33874. rand.Seed(time.Now().UnixNano())
  33875. num := rand.Intn(30000)
  33876. Mkdir(miConfig.OrgName)
  33877. file := strconv.FormatInt(int64(num), 10)
  33878. file_name := file + ".txt"
  33879. zip_name := file + ".zip"
  33880. zip_path := miConfig.OrgName + "/" + zip_name
  33881. file_path := miConfig.OrgName + "/" + file_name
  33882. decimal.DivisionPrecision = 2
  33883. var medfee_sumamt float64
  33884. var psn_cash_pay float64
  33885. var fund_pay_sumamt float64
  33886. fixmedins_setl_cnt := int64(len(orders))
  33887. for _, item := range orders {
  33888. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33889. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  33890. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33891. }
  33892. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  33893. defer f.Close()
  33894. if err != nil {
  33895. fmt.Println(err.Error())
  33896. } else {
  33897. for _, item := range orders {
  33898. var refd_setl_flag string
  33899. if item.OrderStatus == 2 {
  33900. refd_setl_flag = "0"
  33901. var str string
  33902. str = item.SetlId + " " +
  33903. item.MdtrtId + " " +
  33904. item.PsnNo + " " +
  33905. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33906. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33907. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  33908. _, err = f.Write([]byte(str))
  33909. }
  33910. if item.OrderStatus == 3 {
  33911. var str string
  33912. str = item.SetlId + " " +
  33913. item.MdtrtId + " " +
  33914. item.PsnNo + " " +
  33915. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33916. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33917. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  33918. _, err = f.Write([]byte(str))
  33919. var str2 string
  33920. str2 = item.SetlId + " " +
  33921. item.MdtrtId + " " +
  33922. item.PsnNo + " " +
  33923. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  33924. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  33925. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  33926. _, err = f.Write([]byte(str2))
  33927. }
  33928. }
  33929. }
  33930. Zip(file_path, zip_path)
  33931. fmt.Println(ReadFile(zip_path))
  33932. fmt.Println(string(ReadFile(zip_path)))
  33933. if config.IsOpen == 1 {
  33934. var user_name string
  33935. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33936. if role.ID == 0 {
  33937. user_name = "管理员"
  33938. } else {
  33939. user_name = role.UserName
  33940. }
  33941. baseParams := models.BaseParams{
  33942. SecretKey: miConfig.SecretKey,
  33943. FixmedinsCode: miConfig.Code,
  33944. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33945. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33946. OrgName: miConfig.OrgName,
  33947. Doctor: user_name,
  33948. }
  33949. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  33950. var dat map[string]interface{}
  33951. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33952. fmt.Println(dat)
  33953. } else {
  33954. fmt.Println(err)
  33955. }
  33956. userJSONBytes, _ := json.Marshal(dat)
  33957. var res ResultNine
  33958. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33959. utils.ErrorLog("解析失败:%v", err)
  33960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33961. return
  33962. }
  33963. if res.Infcode == 0 {
  33964. fileNo := res.Output.FileQuryNo
  33965. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  33966. "file_qury_no=" + fileNo +
  33967. "&setl_optins=" + "定点医保中心" +
  33968. "&stmt_begndate=" + start_time +
  33969. "&stm_enddate=" + end_time +
  33970. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33971. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33972. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  33973. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33974. "&fixmedins_code=" + miConfig.Code +
  33975. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33976. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33977. "&secret_key=" + miConfig.SecretKey +
  33978. "&org_name=" + miConfig.OrgName +
  33979. "&doctor=" + user_name
  33980. resp, requestErr := http.Get(api)
  33981. if requestErr != nil {
  33982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33983. return
  33984. }
  33985. body, ioErr := ioutil.ReadAll(resp.Body)
  33986. if ioErr != nil {
  33987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33989. return
  33990. }
  33991. var respJSON map[string]interface{}
  33992. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33995. return
  33996. }
  33997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33998. userJSONBytes, _ := json.Marshal(respJSON)
  33999. var res ResultTen
  34000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34001. utils.ErrorLog("解析失败:%v", err)
  34002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34003. return
  34004. }
  34005. if res.Infcode == 0 {
  34006. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34007. micc := &models.MedicalInsuranceCostCompare{
  34008. StartTime: startime.Unix(),
  34009. EndTime: endtime.Unix(),
  34010. Insutype: "0",
  34011. CheckType: 2,
  34012. Num: fixmedins_setl_cnt,
  34013. Mtime: time.Now().Unix(),
  34014. Status: 1,
  34015. UserOrgId: adminUser.CurrentOrgId,
  34016. CostTotal: medfee_sumamt,
  34017. FuncTotal: fund_pay_sumamt,
  34018. PsnPay: psn_cash_pay,
  34019. Creator: admin_user_id,
  34020. Ctime: time.Now().Unix(),
  34021. }
  34022. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34023. c.ServeSuccessJSON(map[string]interface{}{
  34024. "msg": "明细对账成功",
  34025. })
  34026. }
  34027. } else {
  34028. }
  34029. }
  34030. }
  34031. type CustomOrderInfo struct {
  34032. Name string
  34033. Spec string
  34034. Unit string
  34035. Count float64
  34036. Price float64
  34037. Total float64
  34038. }
  34039. func (c *HisApiController) GetBatchSettleAccounts() {
  34040. admin_user_id, _ := c.GetInt64("admin_user_id")
  34041. order_ids := c.GetString("order_ids")
  34042. order_ids_arr := strings.Split(order_ids, ",")
  34043. data3 := []map[string]interface{}{}
  34044. for _, item := range order_ids_arr {
  34045. id, _ := strconv.ParseInt(item, 10, 64)
  34046. order_id := id
  34047. adminUser := c.GetAdminUserInfo()
  34048. order, _ := service.GetHisOrderByID(order_id)
  34049. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34050. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34051. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34052. orderInfos = append(orderInfos, orderInfos_two...)
  34053. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34054. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34055. var diagnosis_ids []string
  34056. if his.ID > 0 {
  34057. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34058. } else {
  34059. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34060. }
  34061. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34062. var dia_config []*models.HisXtDiagnoseConfig
  34063. var name string
  34064. for _, item := range diagnosis_ids {
  34065. id, _ := strconv.ParseInt(item, 10, 64)
  34066. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34067. dia_config = append(dia_config, &diagnosisConfig)
  34068. if len(name) == 0 {
  34069. name = diagnosisConfig.ClassName
  34070. }
  34071. //} else {
  34072. // name = name + "," + diagnosisConfig.ClassName
  34073. //}
  34074. }
  34075. var bedCostTotal float64 = 0 //床位总费
  34076. var bedCostSelfTotal float64 = 0 //床位自费
  34077. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34078. var bedSelfTotal float64 = 0 //床位部分项目自费
  34079. var bedInscpTotal float64 = 0 //床位部分项目自费
  34080. var operationCostTotal float64 = 0 //手术费
  34081. var operationCostSelfTotal float64 = 0 //手术费
  34082. var operationCostPartSelfTotal float64 = 0 //手术费
  34083. var operationSelfTotal float64 = 0 //床位部分项目自费
  34084. var operationInscpTotal float64 = 0 //床位部分项目自费
  34085. var otherCostTotal float64 = 0 //其他费用
  34086. var otherCostSelfTotal float64 = 0 //其他费用
  34087. var otherCostPartSelfTotal float64 = 0 //其他费用
  34088. var otherSelfTotal float64 = 0 //床位部分项目自费
  34089. var otherInscpTotal float64 = 0 //床位部分项目自费
  34090. var materialCostTotal float64 = 0 //材料费
  34091. var materialCostSelfTotal float64 = 0 //材料费
  34092. var materialCostPartSelfTotal float64 = 0 //材料费
  34093. var materialSelfTotal float64 = 0 //床位部分项目自费
  34094. var materialInscpTotal float64 = 0 //床位部分项目自费
  34095. var westernMedicineCostTotal float64 = 0 //西药费
  34096. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34097. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34098. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34099. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34100. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34101. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34102. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34103. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34104. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34105. var checkCostTotal float64 = 0 //检查费
  34106. var checkCostSelfTotal float64 = 0 //检查费
  34107. var checkCostPartSelfTotal float64 = 0 //检查费
  34108. var checkSelfTotal float64 = 0 //床位部分项目自费
  34109. var checkInscpTotal float64 = 0 //床位部分项目自费
  34110. var laboratoryCostTotal float64 = 0 //化验费
  34111. var laboratoryCostSelfTotal float64 = 0 //化验费
  34112. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34113. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34114. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34115. var treatCostTotal float64 = 0 //治疗费用
  34116. var treatCostSelfTotal float64 = 0 //治疗费用
  34117. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34118. var treatSelfTotal float64 = 0 //床位部分项目自费
  34119. var treatInscpTotal float64 = 0 //床位部分项目自费
  34120. decimal.DivisionPrecision = 2
  34121. for _, item := range orderInfos {
  34122. if item.MedChrgitmType == "01" { //床位费
  34123. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34124. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34125. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34126. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34127. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34128. }
  34129. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34130. if item.MedChrgitmType == "03" { //检查费
  34131. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34132. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34133. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34134. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34135. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34136. }
  34137. } else {
  34138. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34139. fmt.Println("------------")
  34140. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34141. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34142. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34143. }
  34144. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34145. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34146. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34147. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34148. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34149. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34150. }
  34151. }
  34152. if item.MedChrgitmType == "04" { //化验费
  34153. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34154. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34155. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34156. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34157. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34158. }
  34159. if item.MedChrgitmType == "05" { //治疗费
  34160. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34161. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34162. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34163. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34164. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34165. }
  34166. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34167. fmt.Println("------------")
  34168. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34169. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34170. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34171. }
  34172. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34173. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34174. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34175. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34176. }
  34177. //if item.MedChrgitmType == "06" { //手术费
  34178. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34179. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34180. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34181. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34182. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34183. //
  34184. //}
  34185. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34186. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34187. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34188. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34189. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34190. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34191. }
  34192. if item.MedChrgitmType == "09" { //西药费
  34193. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34194. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34195. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34196. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34197. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34198. }
  34199. if item.MedChrgitmType == "11" { //中成费
  34200. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34201. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34202. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34203. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34204. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34205. }
  34206. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34207. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34208. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34209. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34210. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34211. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34212. }
  34213. }
  34214. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34215. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34216. var user_name string
  34217. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34218. if role.ID == 0 {
  34219. user_name = "管理员"
  34220. } else {
  34221. user_name = role.UserName
  34222. }
  34223. baseParams := models.BaseParams{
  34224. SecretKey: miConfig.SecretKey,
  34225. FixmedinsCode: miConfig.Code,
  34226. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34227. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34228. OrgName: miConfig.OrgName,
  34229. Doctor: user_name,
  34230. RequestUrl: miConfig.Url,
  34231. AccessKey: miConfig.AccessKey,
  34232. }
  34233. businessParams := models.BusinessParams{
  34234. PsnNo: order.PsnNo,
  34235. MdtrtId: order.MdtrtId,
  34236. SetlId: order.SetlId,
  34237. }
  34238. var res ResultEleven
  34239. var resEleven10265 ResultEleven10265
  34240. if config.IsOpen == 1 {
  34241. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34242. result := service.Gdyb5203(baseParams, businessParams)
  34243. service.Gdyb5204(baseParams, businessParams)
  34244. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34245. var dat map[string]interface{}
  34246. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34247. fmt.Println(dat)
  34248. } else {
  34249. fmt.Println(err)
  34250. }
  34251. userJSONBytes, _ := json.Marshal(dat)
  34252. if miConfig.Code == "H15049901371" {
  34253. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34254. utils.ErrorLog("解析失败:%v", err)
  34255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34256. return
  34257. }
  34258. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34259. res.Output = resEleven10265.Output
  34260. res.ErrMsg = resEleven10265.ErrMsg
  34261. res.Cainfo = resEleven10265.Cainfo
  34262. res.WarnMsg = resEleven10265.WarnMsg
  34263. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34264. res.Infcode = infocode
  34265. } else {
  34266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34267. utils.ErrorLog("解析失败:%v", err)
  34268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34269. return
  34270. }
  34271. }
  34272. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34273. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34274. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34275. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34276. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34277. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34278. var doctor_name string
  34279. if roles.ID == 0 {
  34280. doctor_name = "管理员"
  34281. } else {
  34282. doctor_name = roles.UserName
  34283. }
  34284. yiliao_leibie := ""
  34285. switch order.MedType {
  34286. case "11":
  34287. yiliao_leibie = "普通门诊"
  34288. break
  34289. case "12":
  34290. yiliao_leibie = "门诊挂号"
  34291. break
  34292. case "13":
  34293. yiliao_leibie = "急诊"
  34294. break
  34295. case "14":
  34296. yiliao_leibie = "门诊特殊病"
  34297. break
  34298. case "15":
  34299. yiliao_leibie = "门诊统筹"
  34300. break
  34301. case "16":
  34302. yiliao_leibie = "门诊慢性病"
  34303. break
  34304. case "21":
  34305. yiliao_leibie = "普通住院"
  34306. break
  34307. }
  34308. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34309. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34310. if res.Infcode == 0 {
  34311. data2 := map[string]interface{}{
  34312. "diagnosis": name,
  34313. "order_infos": orderInfos,
  34314. "number": order.MdtrtId,
  34315. "date": order.SettleAccountsDate,
  34316. "charge_admin": charge_admin,
  34317. "printor_admin": printor_admin,
  34318. "info": res.Output.Setlinfo,
  34319. "order": order,
  34320. "bedCostTotal": bedCostTotal,
  34321. "bedCostSelfTotal": bedCostSelfTotal,
  34322. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34323. "bedSelfTotal": bedSelfTotal,
  34324. "bedInscpTotal": bedInscpTotal,
  34325. "operationCostTotal": operationCostTotal,
  34326. "operationCostSelfTotal": operationCostSelfTotal,
  34327. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34328. "operationSelfTotal": operationSelfTotal,
  34329. "operationInscpTotal": operationInscpTotal,
  34330. "otherCostTotal": otherCostTotal,
  34331. "otherCostSelfTotal": otherCostSelfTotal,
  34332. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34333. "otherSelfTotal": otherSelfTotal,
  34334. "otherInscpTotal": otherInscpTotal,
  34335. "materialCostTotal": materialCostTotal,
  34336. "materialCostSelfTotal": materialCostSelfTotal,
  34337. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34338. "materialSelfTotal": materialSelfTotal,
  34339. "materialInscpTotal": materialInscpTotal,
  34340. "westernMedicineCostTotal": westernMedicineCostTotal,
  34341. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34342. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34343. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34344. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34345. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34346. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34347. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34348. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34349. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34350. "checkCostTotal": checkCostTotal,
  34351. "checkCostSelfTotal": checkCostSelfTotal,
  34352. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34353. "checkSelfTotal": checkSelfTotal,
  34354. "checkInscpTotal": checkInscpTotal,
  34355. "laboratoryCostTotal": laboratoryCostTotal,
  34356. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34357. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34358. "laboratorySelfTotal": laboratorySelfTotal,
  34359. "laboratoryInscpTotal": laboratoryInscpTotal,
  34360. "treatCostTotal": treatCostTotal,
  34361. "treatCostSelfTotal": treatCostSelfTotal,
  34362. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34363. "treatSelfTotal": treatSelfTotal,
  34364. "treatInscpTotal": treatInscpTotal,
  34365. "doctor_info": doctor_info,
  34366. "doctor_code": adminRole_two.DoctorCode,
  34367. "doctor_name": doctor_name,
  34368. "health_card_no": order.PsnNo,
  34369. "department": departments.Name,
  34370. "yiliao_leibie": yiliao_leibie,
  34371. "after_money": order.AccountPrice,
  34372. "patient": patient,
  34373. "org_name": miConfig.OrgName,
  34374. "org_code": miConfig.Code,
  34375. "order_number": order.Number,
  34376. "his_hospital": his_hospital,
  34377. "his": his,
  34378. "dia_config": dia_config,
  34379. "psn_cash_pay": order.PsnCashPay,
  34380. //"check_order_info": cus_slice,
  34381. }
  34382. data3 = append(data3, data2)
  34383. }
  34384. }
  34385. }
  34386. c.ServeSuccessJSON(map[string]interface{}{
  34387. "infos": data3,
  34388. })
  34389. }
  34390. func (c *HisApiController) GetSettleAccounts() {
  34391. //id, _ := c.GetInt64("id")
  34392. //record_time := c.GetString("record_time")
  34393. order_id, _ := c.GetInt64("order_id")
  34394. admin_user_id, _ := c.GetInt64("admin_user_id")
  34395. //timeLayout := "2006-01-02"
  34396. //loc, _ := time.LoadLocation("Local")
  34397. //
  34398. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34399. //if err != nil {
  34400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34401. // return
  34402. //}Hbyb5203
  34403. //recordDateTime := theTime.Unix()
  34404. adminUser := c.GetAdminUserInfo()
  34405. order, _ := service.GetHisOrderByID(order_id)
  34406. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34407. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34408. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34409. orderInfos = append(orderInfos, orderInfos_two...)
  34410. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34411. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34412. var diagnosis_ids []string
  34413. if his.ID > 0 {
  34414. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34415. } else {
  34416. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34417. }
  34418. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34419. var dia_config []*models.HisXtDiagnoseConfig
  34420. var name string
  34421. for _, item := range diagnosis_ids {
  34422. id, _ := strconv.ParseInt(item, 10, 64)
  34423. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34424. dia_config = append(dia_config, &diagnosisConfig)
  34425. if len(name) == 0 {
  34426. name = diagnosisConfig.ClassName
  34427. } else {
  34428. name = name + "," + diagnosisConfig.ClassName
  34429. }
  34430. }
  34431. if patient.UserOrgId == 10215 {
  34432. name = "慢性肾功能不全(血透治疗)"
  34433. }
  34434. var bedCostTotal float64 = 0 //床位总费
  34435. var bedCostSelfTotal float64 = 0 //床位自费
  34436. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34437. var bedSelfTotal float64 = 0 //床位部分项目自费
  34438. var bedInscpTotal float64 = 0 //床位部分项目自费
  34439. var operationCostTotal float64 = 0 //手术费
  34440. var operationCostSelfTotal float64 = 0 //手术费
  34441. var operationCostPartSelfTotal float64 = 0 //手术费
  34442. var operationSelfTotal float64 = 0 //床位部分项目自费
  34443. var operationInscpTotal float64 = 0 //床位部分项目自费
  34444. var otherCostTotal float64 = 0 //其他费用
  34445. var otherCostSelfTotal float64 = 0 //其他费用
  34446. var otherCostPartSelfTotal float64 = 0 //其他费用
  34447. var otherSelfTotal float64 = 0 //床位部分项目自费
  34448. var otherInscpTotal float64 = 0 //床位部分项目自费
  34449. var materialCostTotal float64 = 0 //材料费
  34450. var materialCostSelfTotal float64 = 0 //材料费
  34451. var materialCostPartSelfTotal float64 = 0 //材料费
  34452. var materialSelfTotal float64 = 0 //床位部分项目自费
  34453. var materialInscpTotal float64 = 0 //床位部分项目自费
  34454. var westernMedicineCostTotal float64 = 0 //西药费
  34455. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34456. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34457. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34458. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34459. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34460. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34461. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34462. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34463. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34464. var checkCostTotal float64 = 0 //检查费
  34465. var checkCostSelfTotal float64 = 0 //检查费
  34466. var checkCostPartSelfTotal float64 = 0 //检查费
  34467. var checkSelfTotal float64 = 0 //床位部分项目自费
  34468. var checkInscpTotal float64 = 0 //床位部分项目自费
  34469. var laboratoryCostTotal float64 = 0 //化验费
  34470. var laboratoryCostSelfTotal float64 = 0 //化验费
  34471. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34472. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34473. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34474. var treatCostTotal float64 = 0 //治疗费用
  34475. var treatCostSelfTotal float64 = 0 //治疗费用
  34476. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34477. var treatSelfTotal float64 = 0 //床位部分项目自费
  34478. var treatInscpTotal float64 = 0 //床位部分项目自费
  34479. var zcCostTotal float64 = 0 //治疗费用
  34480. var zcCostSelfTotal float64 = 0 //治疗费用
  34481. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34482. var zcSelfTotal float64 = 0 //床位部分项目自费
  34483. var zcInscpTotal float64 = 0 //床位部分项目自费
  34484. var huliCostTotal float64 = 0 //治疗费用
  34485. var huliCostSelfTotal float64 = 0 //治疗费用
  34486. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34487. var huliSelfTotal float64 = 0 //床位部分项目自费
  34488. var huliInscpTotal float64 = 0 //床位部分项目自费
  34489. decimal.DivisionPrecision = 2
  34490. for _, item := range orderInfos {
  34491. if item.MedChrgitmType == "01" { //床位费
  34492. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34493. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34494. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34495. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34496. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34497. }
  34498. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34499. if item.MedChrgitmType == "03" { //检查费
  34500. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34501. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34502. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34503. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34504. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34505. }
  34506. } else {
  34507. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34508. fmt.Println("------------")
  34509. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34510. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34511. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34512. }
  34513. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34514. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34515. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34516. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34517. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34518. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34519. }
  34520. }
  34521. if item.MedChrgitmType == "04" { //化验费
  34522. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34523. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34524. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34525. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34526. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34527. }
  34528. if item.MedChrgitmType == "05" { //治疗费
  34529. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34530. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34531. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34532. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34533. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34534. }
  34535. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34536. fmt.Println("------------")
  34537. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34538. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34539. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34540. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34541. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34542. }
  34543. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34544. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34545. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34546. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34547. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34548. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34549. }
  34550. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34551. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34552. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34553. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34554. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34555. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34556. }
  34557. if item.MedChrgitmType == "09" { //西药费
  34558. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34559. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34560. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34561. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34562. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34563. }
  34564. if item.MedChrgitmType == "11" { //中成费
  34565. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34566. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34567. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34568. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34569. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34570. }
  34571. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34572. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34573. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34574. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34575. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34576. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34577. }
  34578. if item.MedChrgitmType == "02" { //其他费
  34579. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34580. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34581. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34582. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34583. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34584. }
  34585. if item.MedChrgitmType == "07" { //其他费
  34586. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34587. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34588. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34589. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34590. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34591. }
  34592. }
  34593. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34594. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34595. var user_name string
  34596. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34597. if role.ID == 0 {
  34598. user_name = "管理员"
  34599. } else {
  34600. user_name = role.UserName
  34601. }
  34602. baseParams := models.BaseParams{
  34603. SecretKey: miConfig.SecretKey,
  34604. FixmedinsCode: miConfig.Code,
  34605. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34606. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34607. OrgName: miConfig.OrgName,
  34608. Doctor: user_name,
  34609. RequestUrl: miConfig.Url,
  34610. AccessKey: miConfig.AccessKey,
  34611. }
  34612. businessParams := models.BusinessParams{
  34613. PsnNo: order.PsnNo,
  34614. MdtrtId: order.MdtrtId,
  34615. SetlId: order.SetlId,
  34616. }
  34617. var res ResultEleven
  34618. var resah ResultElevenah
  34619. var resEleven10265 ResultEleven10265
  34620. if config.IsOpen == 1 {
  34621. if miConfig.MdtrtareaAdmvs == "421300" {
  34622. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34623. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34624. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34625. resp, requestErr := http.Get(api)
  34626. if requestErr != nil {
  34627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34628. return
  34629. }
  34630. body, ioErr := ioutil.ReadAll(resp.Body)
  34631. if ioErr != nil {
  34632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34634. return
  34635. }
  34636. var respJSON map[string]interface{}
  34637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34640. return
  34641. }
  34642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34643. result, _ := json.Marshal(respJSON)
  34644. fmt.Println("log")
  34645. fmt.Println(string(result))
  34646. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34647. utils.ErrorLog("解析失败:%v", err)
  34648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34649. return
  34650. }
  34651. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34652. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34653. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34654. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34655. resp, requestErr := http.Get(api)
  34656. if requestErr != nil {
  34657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34658. return
  34659. }
  34660. body, ioErr := ioutil.ReadAll(resp.Body)
  34661. if ioErr != nil {
  34662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34664. return
  34665. }
  34666. var respJSON map[string]interface{}
  34667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34670. return
  34671. }
  34672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34673. result, _ := json.Marshal(respJSON)
  34674. fmt.Println("log")
  34675. fmt.Println(string(result))
  34676. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34677. utils.ErrorLog("解析失败:%v", err)
  34678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34679. return
  34680. }
  34681. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34682. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34683. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34684. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34685. resp, requestErr := http.Get(api)
  34686. if requestErr != nil {
  34687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34688. return
  34689. }
  34690. body, ioErr := ioutil.ReadAll(resp.Body)
  34691. if ioErr != nil {
  34692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34694. return
  34695. }
  34696. var respJSON map[string]interface{}
  34697. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34700. return
  34701. }
  34702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34703. result, _ := json.Marshal(respJSON)
  34704. fmt.Println("log")
  34705. fmt.Println(string(result))
  34706. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34707. utils.ErrorLog("解析失败:%v", err)
  34708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34709. return
  34710. }
  34711. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34712. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34713. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34714. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34715. resp, requestErr := http.Get(api)
  34716. if requestErr != nil {
  34717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34718. return
  34719. }
  34720. body, ioErr := ioutil.ReadAll(resp.Body)
  34721. if ioErr != nil {
  34722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34724. return
  34725. }
  34726. var respJSON map[string]interface{}
  34727. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34730. return
  34731. }
  34732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34733. result, _ := json.Marshal(respJSON)
  34734. fmt.Println("log")
  34735. fmt.Println(string(result))
  34736. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34737. utils.ErrorLog("解析失败:%v", err)
  34738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34739. return
  34740. }
  34741. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34742. var api string
  34743. if miConfig.MdtrtareaAdmvs == "320921" {
  34744. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34745. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34746. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34747. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34748. } else {
  34749. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34750. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34751. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34752. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34753. }
  34754. resp, requestErr := http.Get(api)
  34755. if requestErr != nil {
  34756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34757. return
  34758. }
  34759. body, ioErr := ioutil.ReadAll(resp.Body)
  34760. if ioErr != nil {
  34761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34763. return
  34764. }
  34765. var respJSON map[string]interface{}
  34766. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34769. return
  34770. }
  34771. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34772. result, _ := json.Marshal(respJSON)
  34773. fmt.Println("log")
  34774. fmt.Println(string(result))
  34775. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34776. utils.ErrorLog("解析失败:%v", err)
  34777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34778. return
  34779. }
  34780. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34781. res.Output = resEleven10265.Output
  34782. res.ErrMsg = resEleven10265.ErrMsg
  34783. res.Cainfo = resEleven10265.Cainfo
  34784. res.WarnMsg = resEleven10265.WarnMsg
  34785. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34786. res.Infcode = infocode
  34787. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34788. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34789. saveLog(result, requestLog, "5203", "结算单")
  34790. var dat map[string]interface{}
  34791. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34792. fmt.Println(dat)
  34793. } else {
  34794. fmt.Println(err)
  34795. }
  34796. userJSONBytes, _ := json.Marshal(dat)
  34797. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34798. utils.ErrorLog("解析失败:%v", err)
  34799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34800. return
  34801. }
  34802. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34803. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34804. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34805. saveLog(result, requestLog, "5203", "结算单")
  34806. var dat map[string]interface{}
  34807. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34808. fmt.Println(dat)
  34809. } else {
  34810. fmt.Println(err)
  34811. }
  34812. userJSONBytes, _ := json.Marshal(dat)
  34813. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34814. utils.ErrorLog("解析失败:%v", err)
  34815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34816. return
  34817. }
  34818. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34819. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34820. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34821. saveLog(result, requestLog, "5203", "结算单")
  34822. var dat map[string]interface{}
  34823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34824. fmt.Println(dat)
  34825. } else {
  34826. fmt.Println(err)
  34827. }
  34828. userJSONBytes, _ := json.Marshal(dat)
  34829. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34830. utils.ErrorLog("解析失败:%v", err)
  34831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34832. return
  34833. }
  34834. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34835. var api string
  34836. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34837. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34838. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34839. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34840. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34841. resp, requestErr := http.Get(api)
  34842. if requestErr != nil {
  34843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34844. return
  34845. }
  34846. body, ioErr := ioutil.ReadAll(resp.Body)
  34847. if ioErr != nil {
  34848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34850. return
  34851. }
  34852. var respJSON map[string]interface{}
  34853. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34856. return
  34857. }
  34858. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34859. if status == "0" {
  34860. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34861. c.ServeSuccessJSON(map[string]interface{}{
  34862. "failed_code": -10,
  34863. "msg": err_msg,
  34864. })
  34865. return
  34866. }
  34867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34868. result, _ := json.Marshal(respJSON)
  34869. fmt.Println("log")
  34870. fmt.Println(string(result))
  34871. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34872. utils.ErrorLog("解析失败:%v", err)
  34873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34874. return
  34875. }
  34876. res.InfRefmsgid = resah.InfRefmsgid
  34877. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34878. // 创建对应的Time类型
  34879. t := time.UnixMilli(timestamp)
  34880. // 格式化成指定的日期字符串
  34881. str := t.Format("2006-01-02 15:04:05")
  34882. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34883. // 创建对应的Time类型
  34884. t3 := time.UnixMilli(timestamp2)
  34885. // 格式化成指定的日期字符串
  34886. str2 := t3.Format("2006-01-02 15:04:05")
  34887. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34888. // 创建对应的Time类型
  34889. t4 := time.UnixMilli(timestamp3)
  34890. // 格式化成指定的日期字符串
  34891. str3 := t4.Format("2006-01-02 15:04:05")
  34892. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34893. // 创建对应的Time类型
  34894. t5 := time.UnixMilli(timestamp4)
  34895. // 格式化成指定的日期字符串
  34896. str5 := t5.Format("2006-01-02 15:04:05")
  34897. res.Output.Setlinfo.Brdy = str2
  34898. res.Output.Setlinfo.SetlTime = str
  34899. res.Output.Setlinfo.Begndate = str3
  34900. res.Output.Setlinfo.Enddate = str5
  34901. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34902. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34903. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34904. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34905. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34906. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34907. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34908. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34909. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34910. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34911. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34912. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34913. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34914. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34915. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34916. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34917. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34918. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34919. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34920. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34921. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34922. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34923. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34924. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34925. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34926. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34927. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34928. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34929. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34930. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34931. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34932. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34933. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34934. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34935. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34936. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34937. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34938. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34939. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34940. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34941. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34942. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34943. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34944. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34945. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34946. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34947. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34948. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34949. //res.Output.Setldetail = resah.Output.Setldetail
  34950. res.ErrMsg = resah.ErrMsg
  34951. res.Cainfo = resah.Cainfo
  34952. res.WarnMsg = resah.WarnMsg
  34953. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34954. var api string
  34955. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34956. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34957. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34958. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34959. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34960. resp, requestErr := http.Get(api)
  34961. if requestErr != nil {
  34962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34963. return
  34964. }
  34965. body, ioErr := ioutil.ReadAll(resp.Body)
  34966. if ioErr != nil {
  34967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34969. return
  34970. }
  34971. var respJSON map[string]interface{}
  34972. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34975. return
  34976. }
  34977. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34978. if status == "0" {
  34979. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34980. c.ServeSuccessJSON(map[string]interface{}{
  34981. "failed_code": -10,
  34982. "msg": err_msg,
  34983. })
  34984. return
  34985. }
  34986. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34987. result, _ := json.Marshal(respJSON)
  34988. fmt.Println("log")
  34989. fmt.Println(string(result))
  34990. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34991. utils.ErrorLog("解析失败:%v", err)
  34992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34993. return
  34994. }
  34995. res.InfRefmsgid = resah.InfRefmsgid
  34996. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34997. // 创建对应的Time类型
  34998. t := time.UnixMilli(timestamp)
  34999. // 格式化成指定的日期字符串
  35000. str := t.Format("2006-01-02 15:04:05")
  35001. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35002. // 创建对应的Time类型
  35003. t3 := time.UnixMilli(timestamp2)
  35004. // 格式化成指定的日期字符串
  35005. str2 := t3.Format("2006-01-02 15:04:05")
  35006. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35007. // 创建对应的Time类型
  35008. t4 := time.UnixMilli(timestamp3)
  35009. // 格式化成指定的日期字符串
  35010. str3 := t4.Format("2006-01-02 15:04:05")
  35011. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35012. // 创建对应的Time类型
  35013. t5 := time.UnixMilli(timestamp4)
  35014. // 格式化成指定的日期字符串
  35015. str5 := t5.Format("2006-01-02 15:04:05")
  35016. res.Output.Setlinfo.Brdy = str2
  35017. res.Output.Setlinfo.SetlTime = str
  35018. res.Output.Setlinfo.Begndate = str3
  35019. res.Output.Setlinfo.Enddate = str5
  35020. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35021. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35022. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35023. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35024. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35025. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35026. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35027. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35028. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35029. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35030. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35031. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35032. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35033. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35034. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35035. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35036. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35037. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35038. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35039. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35040. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35041. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35042. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35043. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35044. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35045. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35046. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35047. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35048. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35049. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35050. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35051. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35052. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35053. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35054. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35055. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35056. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35057. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35058. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35059. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35060. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35061. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35062. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35063. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35064. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35065. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35066. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35067. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35068. //res.Output.Setldetail = resah.Output.Setldetail
  35069. res.ErrMsg = resah.ErrMsg
  35070. res.Cainfo = resah.Cainfo
  35071. res.WarnMsg = resah.WarnMsg
  35072. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35073. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35074. saveLog(result, requestLog, "5203", "结算单")
  35075. var dat map[string]interface{}
  35076. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35077. fmt.Println(dat)
  35078. } else {
  35079. fmt.Println(err)
  35080. }
  35081. userJSONBytes, _ := json.Marshal(dat)
  35082. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35083. utils.ErrorLog("解析失败:%v", err)
  35084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35085. return
  35086. }
  35087. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35088. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35089. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35090. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35091. resp, requestErr := http.Get(api)
  35092. if requestErr != nil {
  35093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35094. return
  35095. }
  35096. body, ioErr := ioutil.ReadAll(resp.Body)
  35097. if ioErr != nil {
  35098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35100. return
  35101. }
  35102. var respJSON map[string]interface{}
  35103. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35106. return
  35107. }
  35108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35109. result, _ := json.Marshal(respJSON)
  35110. fmt.Println("log")
  35111. fmt.Println(string(result))
  35112. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35113. utils.ErrorLog("解析失败:%v", err)
  35114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35115. return
  35116. }
  35117. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35118. res.Output = resEleven10265.Output
  35119. res.ErrMsg = resEleven10265.ErrMsg
  35120. res.Cainfo = resEleven10265.Cainfo
  35121. res.WarnMsg = resEleven10265.WarnMsg
  35122. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35123. res.Infcode = infocode
  35124. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35125. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35126. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35127. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35128. resp, requestErr := http.Get(api)
  35129. if requestErr != nil {
  35130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35131. return
  35132. }
  35133. body, ioErr := ioutil.ReadAll(resp.Body)
  35134. if ioErr != nil {
  35135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35137. return
  35138. }
  35139. var respJSON map[string]interface{}
  35140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35143. return
  35144. }
  35145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35146. result, _ := json.Marshal(respJSON)
  35147. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35148. utils.ErrorLog("解析失败:%v", err)
  35149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35150. return
  35151. }
  35152. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35153. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35154. //return
  35155. } else {
  35156. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35157. if len(his.InsuplcAdmdvs) == 0 {
  35158. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35159. } else {
  35160. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35161. }
  35162. result := service.Gdyb5203(baseParams, businessParams)
  35163. //service.Gdyb5204(baseParams, businessParams)
  35164. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35165. var dat map[string]interface{}
  35166. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35167. fmt.Println(dat)
  35168. } else {
  35169. fmt.Println(err)
  35170. }
  35171. userJSONBytes, _ := json.Marshal(dat)
  35172. if miConfig.Code == "H15049901371" {
  35173. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35174. utils.ErrorLog("解析失败:%v", err)
  35175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35176. return
  35177. }
  35178. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35179. res.Output = resEleven10265.Output
  35180. res.ErrMsg = resEleven10265.ErrMsg
  35181. res.Cainfo = resEleven10265.Cainfo
  35182. res.WarnMsg = resEleven10265.WarnMsg
  35183. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35184. res.Infcode = infocode
  35185. } else {
  35186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35187. utils.ErrorLog("解析失败:%v", err)
  35188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35189. return
  35190. }
  35191. }
  35192. }
  35193. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35194. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35195. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35196. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35197. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35198. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35199. var doctor_name string
  35200. if roles.ID == 0 {
  35201. doctor_name = "管理员"
  35202. } else {
  35203. doctor_name = roles.UserName
  35204. }
  35205. yiliao_leibie := ""
  35206. switch order.MedType {
  35207. case "11":
  35208. yiliao_leibie = "普通门诊"
  35209. break
  35210. case "12":
  35211. yiliao_leibie = "门诊挂号"
  35212. break
  35213. case "13":
  35214. yiliao_leibie = "急诊"
  35215. break
  35216. case "14":
  35217. yiliao_leibie = "门诊特殊病"
  35218. break
  35219. case "15":
  35220. yiliao_leibie = "门诊统筹"
  35221. break
  35222. case "16":
  35223. yiliao_leibie = "门诊慢性病"
  35224. break
  35225. case "21":
  35226. yiliao_leibie = "普通住院"
  35227. break
  35228. }
  35229. //var rf []CustomFundPay
  35230. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35231. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35232. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35233. if res.Infcode == 0 {
  35234. 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 {
  35235. c.ServeSuccessJSON(map[string]interface{}{
  35236. "diagnosis": name,
  35237. "order_infos": orderInfos,
  35238. "number": order.MdtrtId,
  35239. "date": order.SettleAccountsDate,
  35240. "charge_admin": charge_admin,
  35241. "printor_admin": printor_admin,
  35242. "info": res.Output.Setlinfo,
  35243. "order": order,
  35244. "bedCostTotal": bedCostTotal,
  35245. "bedCostSelfTotal": bedCostSelfTotal,
  35246. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35247. "bedSelfTotal": bedSelfTotal,
  35248. "bedInscpTotal": bedInscpTotal,
  35249. "operationCostTotal": operationCostTotal,
  35250. "operationCostSelfTotal": operationCostSelfTotal,
  35251. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35252. "operationSelfTotal": operationSelfTotal,
  35253. "operationInscpTotal": operationInscpTotal,
  35254. "otherCostTotal": otherCostTotal,
  35255. "otherCostSelfTotal": otherCostSelfTotal,
  35256. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35257. "otherSelfTotal": otherSelfTotal,
  35258. "otherInscpTotal": otherInscpTotal,
  35259. "materialCostTotal": materialCostTotal,
  35260. "materialCostSelfTotal": materialCostSelfTotal,
  35261. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35262. "materialSelfTotal": materialSelfTotal,
  35263. "materialInscpTotal": materialInscpTotal,
  35264. "westernMedicineCostTotal": westernMedicineCostTotal,
  35265. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35266. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35267. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35268. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35269. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35270. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35271. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35272. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35273. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35274. "checkCostTotal": checkCostTotal,
  35275. "checkCostSelfTotal": checkCostSelfTotal,
  35276. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35277. "checkSelfTotal": checkSelfTotal,
  35278. "checkInscpTotal": checkInscpTotal,
  35279. "laboratoryCostTotal": laboratoryCostTotal,
  35280. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35281. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35282. "laboratorySelfTotal": laboratorySelfTotal,
  35283. "laboratoryInscpTotal": laboratoryInscpTotal,
  35284. "treatCostTotal": treatCostTotal,
  35285. "treatCostSelfTotal": treatCostSelfTotal,
  35286. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35287. "treatSelfTotal": treatSelfTotal,
  35288. "treatInscpTotal": treatInscpTotal,
  35289. "doctor_info": doctor_info,
  35290. "doctor_code": adminRole_two.DoctorCode,
  35291. "doctor_name": doctor_name,
  35292. "health_card_no": order.PsnNo,
  35293. "department": departments.Name,
  35294. "yiliao_leibie": yiliao_leibie,
  35295. "after_money": order.AccountPrice,
  35296. "patient": patient,
  35297. "org_name": miConfig.OrgName,
  35298. "org_code": miConfig.Code,
  35299. "order_number": order.Number,
  35300. "his_hospital": his_hospital,
  35301. "his": his,
  35302. "dia_config": dia_config,
  35303. "psn_cash_pay": order.PsnCashPay,
  35304. "zcCostTotal": zcCostTotal,
  35305. "zcCostSelfTotal": zcCostSelfTotal,
  35306. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35307. "zcSelfTotal": zcSelfTotal,
  35308. "zcInscpTotal": zcInscpTotal,
  35309. "huliCostTotal": huliCostTotal,
  35310. "huliCostSelfTotal": huliCostSelfTotal,
  35311. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35312. "huliSelfTotal": huliSelfTotal,
  35313. "huliInscpTotal": huliInscpTotal,
  35314. //"funds": rf,
  35315. //"check_order_info": cus_slice,
  35316. })
  35317. } else {
  35318. c.ServeSuccessJSON(map[string]interface{}{
  35319. "diagnosis": name,
  35320. "order_infos": orderInfos,
  35321. "number": order.MdtrtId,
  35322. "date": order.SettleAccountsDate,
  35323. "charge_admin": charge_admin,
  35324. "printor_admin": printor_admin,
  35325. "info": order,
  35326. "order": order,
  35327. "bedCostTotal": bedCostTotal,
  35328. "bedCostSelfTotal": bedCostSelfTotal,
  35329. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35330. "bedSelfTotal": bedSelfTotal,
  35331. "bedInscpTotal": bedInscpTotal,
  35332. "operationCostTotal": operationCostTotal,
  35333. "operationCostSelfTotal": operationCostSelfTotal,
  35334. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35335. "operationSelfTotal": operationSelfTotal,
  35336. "operationInscpTotal": operationInscpTotal,
  35337. "otherCostTotal": otherCostTotal,
  35338. "otherCostSelfTotal": otherCostSelfTotal,
  35339. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35340. "otherSelfTotal": otherSelfTotal,
  35341. "otherInscpTotal": otherInscpTotal,
  35342. "materialCostTotal": materialCostTotal,
  35343. "materialCostSelfTotal": materialCostSelfTotal,
  35344. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35345. "materialSelfTotal": materialSelfTotal,
  35346. "materialInscpTotal": materialInscpTotal,
  35347. "westernMedicineCostTotal": westernMedicineCostTotal,
  35348. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35349. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35350. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35351. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35352. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35353. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35354. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35355. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35356. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35357. "checkCostTotal": checkCostTotal,
  35358. "checkCostSelfTotal": checkCostSelfTotal,
  35359. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35360. "checkSelfTotal": checkSelfTotal,
  35361. "checkInscpTotal": checkInscpTotal,
  35362. "laboratoryCostTotal": laboratoryCostTotal,
  35363. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35364. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35365. "laboratorySelfTotal": laboratorySelfTotal,
  35366. "laboratoryInscpTotal": laboratoryInscpTotal,
  35367. "treatCostTotal": treatCostTotal,
  35368. "treatCostSelfTotal": treatCostSelfTotal,
  35369. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35370. "treatSelfTotal": treatSelfTotal,
  35371. "treatInscpTotal": treatInscpTotal,
  35372. "doctor_info": doctor_info,
  35373. "doctor_code": adminRole_two.DoctorCode,
  35374. "doctor_name": doctor_name,
  35375. "health_card_no": order.PsnNo,
  35376. "department": departments.Name,
  35377. "yiliao_leibie": yiliao_leibie,
  35378. "after_money": order.AccountPrice,
  35379. "patient": patient,
  35380. "org_name": miConfig.OrgName,
  35381. "org_code": miConfig.Code,
  35382. "order_number": order.Number,
  35383. "his_hospital": his_hospital,
  35384. "his": his,
  35385. "dia_config": dia_config,
  35386. "psn_cash_pay": order.PsnCashPay,
  35387. "zcCostTotal": zcCostTotal,
  35388. "zcCostSelfTotal": zcCostSelfTotal,
  35389. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35390. "zcSelfTotal": zcSelfTotal,
  35391. "zcInscpTotal": zcInscpTotal,
  35392. "huliCostTotal": huliCostTotal,
  35393. "huliCostSelfTotal": huliCostSelfTotal,
  35394. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35395. "huliSelfTotal": huliSelfTotal,
  35396. "huliInscpTotal": huliInscpTotal,
  35397. //"funds": rf,
  35398. //"check_order_info": cus_slice,
  35399. })
  35400. }
  35401. }
  35402. }
  35403. }
  35404. //func (c *HisApiController) CheckTreatment() {
  35405. // patient_id, _ := c.GetInt64("patient_id")
  35406. // id_card_no := c.GetString("id_card_no")
  35407. // insutype := c.GetString("insutype")
  35408. // med_type := c.GetString("med_type")
  35409. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35410. //
  35411. // adminUser := c.GetAdminUserInfo()
  35412. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35413. //
  35414. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35415. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35416. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35417. //
  35418. // if miConfig.MdtrtareaAdmvs == "421300" {
  35419. // var res ResultTwo
  35420. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35421. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35422. // "&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)
  35423. // resp, requestErr := http.Get(api)
  35424. // if requestErr != nil {
  35425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35426. // return
  35427. // }
  35428. //
  35429. // body, ioErr := ioutil.ReadAll(resp.Body)
  35430. // if ioErr != nil {
  35431. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35433. // return
  35434. // }
  35435. // var respJSON map[string]interface{}
  35436. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35437. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35438. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35439. // return
  35440. // }
  35441. //
  35442. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35443. // result, _ := json.Marshal(respJSON)
  35444. //
  35445. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35446. // utils.ErrorLog("解析失败:%v", err)
  35447. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35448. // return
  35449. // }
  35450. //
  35451. // if res.Infcode == 0 {
  35452. //
  35453. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35454. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35455. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35456. // resp, requestErr := http.Get(api)
  35457. // if requestErr != nil {
  35458. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35459. // return
  35460. // }
  35461. //
  35462. // body, ioErr := ioutil.ReadAll(resp.Body)
  35463. // if ioErr != nil {
  35464. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35465. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35466. // return
  35467. // }
  35468. // var respJSON map[string]interface{}
  35469. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35470. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35471. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35472. // return
  35473. // }
  35474. // var res Result2001
  35475. //
  35476. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35477. // result2, _ := json.Marshal(respJSON)
  35478. //
  35479. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35480. // utils.ErrorLog("解析失败:%v", err)
  35481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35482. // return
  35483. // }
  35484. //
  35485. // if res.Infcode == 0 {
  35486. // c.ServeSuccessJSON(map[string]interface{}{
  35487. // "msg": res.Output.Trtinfo,
  35488. // })
  35489. // }
  35490. //
  35491. // } else {
  35492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35493. // return
  35494. // }
  35495. //
  35496. // } else {
  35497. //
  35498. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35499. // var dat map[string]interface{}
  35500. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35501. // fmt.Println(dat)
  35502. // } else {
  35503. // fmt.Println(err)
  35504. // }
  35505. // userJSONBytes, _ := json.Marshal(dat)
  35506. // var res ResultTwo
  35507. // var res10265 ResultTwo10265
  35508. // if miConfig.Code == "H15049901371" {
  35509. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35510. // utils.ErrorLog("解析失败:%v", err)
  35511. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35512. // return
  35513. // }
  35514. // res.ErrMsg = res10265.ErrMsg
  35515. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35516. // res.Infcode = infocode
  35517. // res.Output = res10265.Output
  35518. // res.InfRefmsgid = res10265.InfRefmsgid
  35519. // } else {
  35520. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35521. // utils.ErrorLog("解析失败:%v", err)
  35522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35523. // return
  35524. // }
  35525. // }
  35526. //
  35527. // var user_name string
  35528. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35529. // if role.ID == 0 {
  35530. // user_name = "xxx"
  35531. // } else {
  35532. // user_name = role.UserName
  35533. // }
  35534. //
  35535. // baseParams := models.BaseParams{
  35536. // SecretKey: miConfig.SecretKey,
  35537. // FixmedinsCode: miConfig.Code,
  35538. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35539. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35540. // OrgName: miConfig.OrgName,
  35541. // Doctor: user_name,
  35542. // }
  35543. //
  35544. // if config.IsOpen == 1 {
  35545. // if miConfig.Code == "H15049901371" {
  35546. // if med_type == "14" {
  35547. // if insutype == "390" {
  35548. // med_type = "9933"
  35549. // } else if insutype == "310" {
  35550. // med_type = "990502"
  35551. // }
  35552. // } else if med_type == "11" {
  35553. // med_type = "11"
  35554. // }
  35555. // }
  35556. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35557. // var dat map[string]interface{}
  35558. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35559. // fmt.Println(dat)
  35560. // } else {
  35561. // fmt.Println(err)
  35562. // }
  35563. // var res Result2001
  35564. // var res10265 Result2001Org10265
  35565. // if miConfig.Code == "H15049901371" {
  35566. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35567. // utils.ErrorLog("解析失败:%v", err)
  35568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35569. // return
  35570. // }
  35571. // res.ErrMsg = res10265.ErrMsg
  35572. // res.Output = res10265.Output
  35573. // res.InfRefmsgid = res10265.InfRefmsgid
  35574. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35575. // res.Infcode = infocode
  35576. // } else {
  35577. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35578. // utils.ErrorLog("解析失败:%v", err)
  35579. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35580. // return
  35581. // }
  35582. // }
  35583. // if res.Infcode == 0 {
  35584. // c.ServeSuccessJSON(map[string]interface{}{
  35585. // "msg": res.Output.Trtinfo,
  35586. // })
  35587. // }
  35588. // }
  35589. // }
  35590. //}
  35591. //func (c *HisApiController) PutRecord() {
  35592. // id, _ := c.GetInt64("id")
  35593. // record_time := c.GetString("record_time")
  35594. // timeLayout := "2006-01-02"
  35595. // loc, _ := time.LoadLocation("Local")
  35596. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35597. // if err != nil {
  35598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35599. // return
  35600. // }
  35601. // recordDateTime := theTime.Unix()
  35602. //
  35603. // adminInfo := c.GetAdminUserInfo()
  35604. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35605. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35606. //
  35607. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35608. //
  35609. // fmt.Println(miConfig.SecretKey)
  35610. //
  35611. // if patient == nil {
  35612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35613. // return
  35614. // }
  35615. // if len(patient.IdCardNo) == 0 {
  35616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35617. // return
  35618. // }
  35619. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35620. // if config.IsOpen == 1 {
  35621. // 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
  35622. // resp, requestErr := http.Get(api)
  35623. // if requestErr != nil {
  35624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35625. // return
  35626. // }
  35627. // defer resp.Body.Close()
  35628. // body, ioErr := ioutil.ReadAll(resp.Body)
  35629. // if ioErr != nil {
  35630. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35631. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35632. // return
  35633. // }
  35634. // var respJSON map[string]interface{}
  35635. //
  35636. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35637. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35639. // return
  35640. // }
  35641. //
  35642. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35643. // userJSONBytes, _ := json.Marshal(userJSON)
  35644. // var res ResultTwo
  35645. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35646. // utils.ErrorLog("解析失败:%v", err)
  35647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35648. // return
  35649. // }
  35650. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35651. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35652. // infoStr := string(Iinfos)
  35653. // idetinfoStr := string(Idetinfos)
  35654. //
  35655. // if res.Infcode == 0 {
  35656. // his := models.VMHisPatient{
  35657. // Status: 1,
  35658. // Ctime: time.Now().Unix(),
  35659. // Mtime: time.Now().Unix(),
  35660. // PsnNo: res.Output.Baseinfo.PsnNo,
  35661. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35662. // Certno: res.Output.Baseinfo.Certno,
  35663. // PsnName: res.Output.Baseinfo.PsnName,
  35664. // Gend: res.Output.Baseinfo.Gend,
  35665. // Naty: res.Output.Baseinfo.Naty,
  35666. // Brdy: res.Output.Baseinfo.Brdy,
  35667. // Age: res.Output.Baseinfo.Age,
  35668. // Iinfo: infoStr,
  35669. // Idetinfo: idetinfoStr,
  35670. // PatientId: patient.ID,
  35671. // RecordDate: theTime.Unix(),
  35672. // UserOrgId: adminInfo.CurrentOrgId,
  35673. // AdminUserId: adminInfo.AdminUser.Id,
  35674. // IsReturn: 1,
  35675. // }
  35676. //
  35677. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35678. // //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")
  35679. // //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")
  35680. //
  35681. // //var dat map[string]interface{}
  35682. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35683. // // fmt.Println(dat)
  35684. // //} else {
  35685. // // fmt.Println(err)
  35686. // //}
  35687. //
  35688. // var dat2 map[string]interface{}
  35689. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35690. // fmt.Println(dat2)
  35691. // } else {
  35692. // fmt.Println(err)
  35693. // }
  35694. //
  35695. // } else {
  35696. // adminUser := c.GetAdminUserInfo()
  35697. // errlog := &models.HisOrderError{
  35698. // UserOrgId: adminUser.CurrentOrgId,
  35699. // Ctime: time.Now().Unix(),
  35700. // Mtime: time.Now().Unix(),
  35701. // ErrMsg: res.ErrMsg,
  35702. // Status: 1,
  35703. // PatientId: id,
  35704. // RecordTime: recordDateTime,
  35705. // Stage: 1,
  35706. // }
  35707. // service.CreateErrMsgLog(errlog)
  35708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35709. // return
  35710. // }
  35711. // }
  35712. //
  35713. //}
  35714. //func (c *HisApiController) GetUploadDiag() {
  35715. // id, _ := c.GetInt64("id")
  35716. // record_time := c.GetString("record_time")
  35717. //
  35718. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35719. // sick_type, _ := c.GetInt64("sick_type")
  35720. // reg_type, _ := c.GetInt64("reg_type")
  35721. //
  35722. // timeLayout := "2006-01-02"
  35723. // loc, _ := time.LoadLocation("Local")
  35724. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35725. // if err != nil {
  35726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35727. // return
  35728. // }
  35729. //
  35730. // var patientPrescription models.HisPrescriptionInfo
  35731. // recordDateTime := theTime.Unix()
  35732. // adminInfo := c.GetAdminUserInfo()
  35733. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35734. //
  35735. // if patientPrescription.ID == 0 {
  35736. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35737. // }
  35738. //
  35739. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35740. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35741. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35742. // sickConfig, _ := service.FindSickById(sick_type)
  35743. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35744. //
  35745. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35746. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35747. // "&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 +
  35748. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35749. // resp2, requestErr2 := http.Get(api2)
  35750. // if requestErr2 != nil {
  35751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35752. // return
  35753. // }
  35754. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35755. // if ioErr2 != nil {
  35756. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35758. // return
  35759. // }
  35760. // var respJSON2 map[string]interface{}
  35761. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35762. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35764. // return
  35765. // }
  35766. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35767. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35768. //
  35769. // var res2 ResultSix
  35770. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35771. // utils.ErrorLog("解析失败:%v", err)
  35772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35773. // return
  35774. // }
  35775. // if res2.Infcode != 0 {
  35776. // adminUser := c.GetAdminUserInfo()
  35777. // errlog := &models.HisOrderError{
  35778. // UserOrgId: adminUser.CurrentOrgId,
  35779. // Ctime: time.Now().Unix(),
  35780. // Mtime: time.Now().Unix(),
  35781. // ErrMsg: res2.ErrMsg,
  35782. // Status: 1,
  35783. // PatientId: id,
  35784. // RecordTime: recordDateTime,
  35785. // Stage: 3,
  35786. // }
  35787. // service.CreateErrMsgLog(errlog)
  35788. //
  35789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35790. // return
  35791. // }
  35792. //
  35793. // c.ServeSuccessJSON(map[string]interface{}{
  35794. // "msg": "上传成功",
  35795. // })
  35796. //
  35797. //}
  35798. type QueryResult struct {
  35799. ID int64
  35800. Name string
  35801. Code string
  35802. List_type_code string
  35803. }
  35804. func (c *HisApiController) GetCheckCode() {
  35805. ids_str := c.GetString("ids")
  35806. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35807. ids_arr := strings.Split(ids_str, ",")
  35808. var queryResult []QueryResult
  35809. ids := make([]int64, 0)
  35810. for _, item := range ids_arr {
  35811. id, _ := strconv.ParseInt(item, 10, 64)
  35812. ids = append(ids, id)
  35813. }
  35814. if record_type == 1 {
  35815. drugs, _ := service.GetBatchDrugList(ids)
  35816. for _, item := range drugs {
  35817. result := QueryResult{
  35818. ID: item.ID,
  35819. Name: item.DrugName,
  35820. Code: item.MedicalInsuranceNumber,
  35821. List_type_code: "101",
  35822. }
  35823. queryResult = append(queryResult, result)
  35824. }
  35825. } else if record_type == 2 {
  35826. goods, _ := service.GetBatchGoodInformationList(ids)
  35827. fmt.Println(goods)
  35828. for _, item := range goods {
  35829. result := QueryResult{
  35830. ID: item.ID,
  35831. Name: item.GoodName,
  35832. Code: item.SocialSecurityDirectoryCode,
  35833. List_type_code: "301",
  35834. }
  35835. queryResult = append(queryResult, result)
  35836. }
  35837. } else if record_type == 3 {
  35838. projects, _ := service.GetBathchMyPorjecgList(ids)
  35839. for _, item := range projects {
  35840. result := QueryResult{
  35841. ID: item.ID,
  35842. Name: item.ProjectName,
  35843. Code: item.MedicalCode,
  35844. List_type_code: "201",
  35845. }
  35846. queryResult = append(queryResult, result)
  35847. }
  35848. }
  35849. admin_user_id, _ := c.GetInt64("admin_user_id")
  35850. adminUser := c.GetAdminUserInfo()
  35851. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35852. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35853. var user_name string
  35854. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35855. if role.ID == 0 {
  35856. user_name = "管理员"
  35857. } else {
  35858. user_name = role.UserName
  35859. }
  35860. baseParams := models.BaseParams{
  35861. SecretKey: miConfig.SecretKey,
  35862. FixmedinsCode: miConfig.Code,
  35863. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35864. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35865. OrgName: miConfig.OrgName,
  35866. Doctor: user_name,
  35867. }
  35868. var result string
  35869. if miConfig.MdtrtareaAdmvs == "430800" {
  35870. for _, item := range queryResult {
  35871. if record_type == 1 {
  35872. 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)
  35873. } else if record_type == 2 {
  35874. fmt.Println(item.Code)
  35875. 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)
  35876. } else if record_type == 3 {
  35877. 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)
  35878. }
  35879. var dat map[string]interface{}
  35880. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35881. fmt.Println(dat)
  35882. } else {
  35883. fmt.Println(err)
  35884. }
  35885. userJSONBytes, _ := json.Marshal(dat)
  35886. var res ResultSix
  35887. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35888. utils.ErrorLog("解析失败:%v", err)
  35889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35890. return
  35891. }
  35892. if res.Infcode == 0 {
  35893. if record_type == 1 {
  35894. service.UpdateBaseDrugById(item.ID)
  35895. } else if record_type == 2 {
  35896. service.UpdateGoodInformaitonByDetail(item.ID)
  35897. } else if record_type == 3 {
  35898. service.UpdateProjectById(item.ID)
  35899. }
  35900. c.ServeSuccessJSON(map[string]interface{}{
  35901. "failed_code": 0,
  35902. "msg": "目录对照成功",
  35903. })
  35904. } else {
  35905. c.ServeSuccessJSON(map[string]interface{}{
  35906. "failed_code": -10,
  35907. "msg": res.ErrMsg,
  35908. })
  35909. }
  35910. }
  35911. } else {
  35912. for _, item := range queryResult {
  35913. var result string
  35914. if record_type == 1 {
  35915. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35916. } else if record_type == 2 {
  35917. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35918. } else if record_type == 3 {
  35919. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35920. }
  35921. var dat map[string]interface{}
  35922. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35923. fmt.Println(dat)
  35924. } else {
  35925. fmt.Println(err)
  35926. }
  35927. userJSONBytes, _ := json.Marshal(dat)
  35928. var res ResultSix
  35929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35930. utils.ErrorLog("解析失败:%v", err)
  35931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35932. return
  35933. }
  35934. if res.Infcode == 0 {
  35935. if record_type == 1 {
  35936. service.UpdateBaseDrugById(item.ID)
  35937. } else if record_type == 2 {
  35938. service.UpdateGoodInformaitonByDetail(item.ID)
  35939. } else if record_type == 3 {
  35940. service.UpdateProjectById(item.ID)
  35941. }
  35942. c.ServeSuccessJSON(map[string]interface{}{
  35943. "failed_code": 0,
  35944. "msg": "目录对照成功",
  35945. })
  35946. } else {
  35947. c.ServeSuccessJSON(map[string]interface{}{
  35948. "failed_code": -10,
  35949. "msg": res.ErrMsg,
  35950. })
  35951. }
  35952. }
  35953. }
  35954. }
  35955. func (c *HisApiController) UnCheckCode() {
  35956. ids_str := c.GetString("ids")
  35957. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35958. admin_user_id, _ := c.GetInt64("admin_user_id")
  35959. ids_arr := strings.Split(ids_str, ",")
  35960. var queryResult []QueryResult
  35961. ids := make([]int64, 0)
  35962. for _, item := range ids_arr {
  35963. id, _ := strconv.ParseInt(item, 10, 64)
  35964. ids = append(ids, id)
  35965. }
  35966. if record_type == 1 {
  35967. drugs, _ := service.GetBatchDrugList(ids)
  35968. for _, item := range drugs {
  35969. result := QueryResult{
  35970. ID: item.ID,
  35971. Name: item.DrugName,
  35972. Code: item.MedicalInsuranceNumber,
  35973. List_type_code: "101",
  35974. }
  35975. queryResult = append(queryResult, result)
  35976. }
  35977. } else if record_type == 2 {
  35978. goods, _ := service.GetBatchGoodInformationList(ids)
  35979. for _, item := range goods {
  35980. result := QueryResult{
  35981. ID: item.ID,
  35982. Name: item.GoodName,
  35983. Code: item.SocialSecurityDirectoryCode,
  35984. List_type_code: "301",
  35985. }
  35986. queryResult = append(queryResult, result)
  35987. }
  35988. } else if record_type == 3 {
  35989. projects, _ := service.GetBathchMyPorjecgList(ids)
  35990. for _, item := range projects {
  35991. result := QueryResult{
  35992. ID: item.ID,
  35993. Name: item.ProjectName,
  35994. Code: item.MedicalCode,
  35995. List_type_code: "201",
  35996. }
  35997. queryResult = append(queryResult, result)
  35998. }
  35999. }
  36000. adminUser := c.GetAdminUserInfo()
  36001. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36002. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36003. var user_name string
  36004. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36005. if role.ID == 0 {
  36006. user_name = "xxx"
  36007. } else {
  36008. user_name = role.UserName
  36009. }
  36010. baseParams := &models.BaseParams{
  36011. SecretKey: miConfig.SecretKey,
  36012. FixmedinsCode: miConfig.Code,
  36013. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36014. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36015. OrgName: miConfig.OrgName,
  36016. Doctor: user_name,
  36017. }
  36018. if config.IsOpen == 1 {
  36019. if miConfig.MdtrtareaAdmvs == "430800" {
  36020. for _, item := range queryResult {
  36021. var result string
  36022. if record_type == 1 {
  36023. 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)
  36024. } else if record_type == 2 {
  36025. fmt.Println(item.Code)
  36026. 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)
  36027. } else if record_type == 3 {
  36028. 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)
  36029. }
  36030. var dat map[string]interface{}
  36031. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36032. fmt.Println(dat)
  36033. } else {
  36034. fmt.Println(err)
  36035. }
  36036. userJSONBytes, _ := json.Marshal(dat)
  36037. var res ResultSix
  36038. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36039. utils.ErrorLog("解析失败:%v", err)
  36040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36041. return
  36042. }
  36043. if res.Infcode == 0 {
  36044. if record_type == 1 {
  36045. service.UpdateBaseDrugById(item.ID)
  36046. } else if record_type == 2 {
  36047. service.UpdateGoodInformaitonByDetail(item.ID)
  36048. } else if record_type == 3 {
  36049. service.UpdateProjectById(item.ID)
  36050. }
  36051. c.ServeSuccessJSON(map[string]interface{}{
  36052. "failed_code": 0,
  36053. "msg": "目录对照成功",
  36054. })
  36055. } else {
  36056. c.ServeSuccessJSON(map[string]interface{}{
  36057. "failed_code": -10,
  36058. "msg": res.ErrMsg,
  36059. })
  36060. }
  36061. }
  36062. } else {
  36063. for _, item := range queryResult {
  36064. var result string
  36065. if record_type == 1 {
  36066. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36067. } else if record_type == 2 {
  36068. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36069. } else if record_type == 3 {
  36070. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36071. }
  36072. var dat2 map[string]interface{}
  36073. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36074. fmt.Println(dat2)
  36075. } else {
  36076. fmt.Println(err)
  36077. }
  36078. userJSONBytes, _ := json.Marshal(dat2)
  36079. var res ResultSix
  36080. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36081. utils.ErrorLog("解析失败:%v", err)
  36082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36083. return
  36084. }
  36085. if res.Infcode == 0 {
  36086. if record_type == 1 {
  36087. service.UpdateDrugByIdDetail(item.ID)
  36088. } else if record_type == 2 {
  36089. service.UpdateGoodInfoById(item.ID)
  36090. } else if record_type == 3 {
  36091. service.UpdateMyProjectById(item.ID)
  36092. }
  36093. c.ServeSuccessJSON(map[string]interface{}{
  36094. "failed_code": 0,
  36095. "msg": "撤销目录对照成功",
  36096. })
  36097. } else {
  36098. c.ServeSuccessJSON(map[string]interface{}{
  36099. "failed_code": -10,
  36100. "msg": res.ErrMsg,
  36101. })
  36102. }
  36103. }
  36104. }
  36105. }
  36106. }
  36107. func (c *HisApiController) GetPatientInfo() {
  36108. id_card_no := c.GetString("id_card_no")
  36109. admin_user_id, _ := c.GetInt64("admin_user_id")
  36110. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36111. if patient.ID == 0 {
  36112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36113. return
  36114. }
  36115. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36116. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36117. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36118. var res ResultTwo
  36119. var res10265 ResultTwo10265
  36120. if config.IsOpen == 1 {
  36121. if miConfig.MdtrtareaAdmvs == "150499" {
  36122. //请求内网数据
  36123. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36124. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36125. "&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
  36126. resp, requestErr := http.Get(api)
  36127. if requestErr != nil {
  36128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36129. return
  36130. }
  36131. body, ioErr := ioutil.ReadAll(resp.Body)
  36132. if ioErr != nil {
  36133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36135. return
  36136. }
  36137. var respJSON map[string]interface{}
  36138. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36141. return
  36142. }
  36143. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36144. result_byte, _ := json.Marshal(respJSON)
  36145. result := string(result_byte)
  36146. var dat map[string]interface{}
  36147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36148. fmt.Println(dat)
  36149. } else {
  36150. fmt.Println(err)
  36151. }
  36152. userJSONBytes, _ := json.Marshal(dat)
  36153. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36154. utils.ErrorLog("解析失败:%v", err)
  36155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36156. return
  36157. }
  36158. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36159. res.Infcode = Infcode
  36160. res.ErrMsg = res10265.ErrMsg
  36161. res.Output = res10265.Output
  36162. res.InfRefmsgid = res10265.InfRefmsgid
  36163. res.RespondTime = res10265.RespondTime
  36164. res.WarnInfo = res10265.WarnInfo
  36165. } else {
  36166. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36167. var dat map[string]interface{}
  36168. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36169. fmt.Println(dat)
  36170. } else {
  36171. fmt.Println(err)
  36172. }
  36173. userJSONBytes, _ := json.Marshal(dat)
  36174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36175. utils.ErrorLog("解析失败:%v", err)
  36176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36177. return
  36178. }
  36179. }
  36180. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36181. // utils.ErrorLog("解析失败:%v", err)
  36182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36183. // return
  36184. //}
  36185. for index, item := range res.Output.Iinfo {
  36186. if item.PsnInsuStas == "2" {
  36187. fmt.Println("--------")
  36188. res.Output.Iinfo[index].Insutype = "300"
  36189. res.Output.Iinfo[index].PsnInsuStas = "1"
  36190. }
  36191. }
  36192. fmt.Println(res.Output.Iinfo)
  36193. if res.Infcode != 0 {
  36194. c.ServeSuccessJSON(map[string]interface{}{
  36195. "failed_code": -10,
  36196. "msg": res.ErrMsg,
  36197. })
  36198. } else {
  36199. c.ServeSuccessJSON(map[string]interface{}{
  36200. "failed_code": 0,
  36201. "info": res,
  36202. })
  36203. }
  36204. }
  36205. }
  36206. func (c *HisApiController) PsnPutOnRecord() {
  36207. record_type, _ := c.GetInt64("type")
  36208. patient_id, _ := c.GetInt64("patient_id")
  36209. admin_user_id, _ := c.GetInt64("admin_user_id")
  36210. start_time := c.GetString("start_time")
  36211. end_time := c.GetString("end_time")
  36212. adminUser := c.GetAdminUserInfo()
  36213. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36214. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36215. var patients []*models.Patients
  36216. if record_type == 1 { //全部备案
  36217. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36218. patients = append(patients, patient...)
  36219. } else { //单个备案
  36220. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36221. patients = append(patients, patient)
  36222. }
  36223. var user_name string
  36224. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36225. if role.ID == 0 {
  36226. user_name = "xxx"
  36227. } else {
  36228. user_name = role.UserName
  36229. }
  36230. if config.IsOpen == 1 {
  36231. for _, item := range patients {
  36232. 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
  36233. resp, requestErr := http.Get(api)
  36234. if requestErr != nil {
  36235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36236. return
  36237. }
  36238. defer resp.Body.Close()
  36239. body, ioErr := ioutil.ReadAll(resp.Body)
  36240. if ioErr != nil {
  36241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36243. return
  36244. }
  36245. var respJSON map[string]interface{}
  36246. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36249. return
  36250. }
  36251. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36252. userJSONBytes, _ := json.Marshal(userJSON)
  36253. var res ResultTwo
  36254. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36255. utils.ErrorLog("解析失败:%v", err)
  36256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36257. return
  36258. }
  36259. if res.Infcode == 0 {
  36260. 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)
  36261. var dat map[string]interface{}
  36262. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36263. fmt.Println(dat)
  36264. } else {
  36265. fmt.Println(err)
  36266. }
  36267. userJSONBytes, _ := json.Marshal(dat)
  36268. var res2 ResultThirteen
  36269. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36270. utils.ErrorLog("解析失败:%v", err)
  36271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36272. return
  36273. }
  36274. if res2.Infcode == 0 {
  36275. psnResult := &models.GdybPsnRecord{
  36276. UserOrgId: adminUser.CurrentOrgId,
  36277. PatientId: item.ID,
  36278. PsnNo: res.Output.Baseinfo.PsnNo,
  36279. Ctime: time.Now().Unix(),
  36280. Mtime: time.Now().Unix(),
  36281. Status: 1,
  36282. IsCancel: 1,
  36283. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36284. }
  36285. service.CreatePsnRecord(psnResult)
  36286. } else {
  36287. c.ServeSuccessJSON(map[string]interface{}{
  36288. "failed_code": -10,
  36289. "msg": res2.ErrMsg,
  36290. })
  36291. return
  36292. }
  36293. }
  36294. }
  36295. }
  36296. }
  36297. func (c *HisApiController) PsnUnPutOnRecord() {
  36298. id, _ := c.GetInt64("id")
  36299. //record_type, _ := c.GetInt64("type")
  36300. admin_user_id, _ := c.GetInt64("admin_user_id")
  36301. adminUser := c.GetAdminUserInfo()
  36302. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36303. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36304. var user_name string
  36305. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36306. if role.ID == 0 {
  36307. user_name = "xxx"
  36308. } else {
  36309. user_name = role.UserName
  36310. }
  36311. psn_record, _ := service.GetPsnRecordById(id)
  36312. if psn_record.ID == 0 {
  36313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36314. return
  36315. }
  36316. if config.IsOpen == 1 {
  36317. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36318. var dat map[string]interface{}
  36319. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36320. fmt.Println(dat)
  36321. } else {
  36322. fmt.Println(err)
  36323. }
  36324. userJSONBytes, _ := json.Marshal(dat)
  36325. var res ResultFourteen
  36326. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36327. utils.ErrorLog("解析失败:%v", err)
  36328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36329. return
  36330. }
  36331. if res.Infcode == 0 {
  36332. psn_record.IsCancel = 2
  36333. service.CreatePsnRecord(&psn_record)
  36334. } else {
  36335. c.ServeSuccessJSON(map[string]interface{}{
  36336. "failed_code": -10,
  36337. "msg": res.ErrMsg,
  36338. })
  36339. return
  36340. }
  36341. }
  36342. }
  36343. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36344. patient_id, _ := c.GetInt64("patient_id")
  36345. insutype_two := c.GetString("insutype")
  36346. psn_no := c.GetString("psn_no")
  36347. doctor_id, _ := c.GetInt64("doctor_id")
  36348. sick_id, _ := c.GetInt64("sick_id")
  36349. department_id, _ := c.GetInt64("department_id")
  36350. start_time := c.GetString("start_time")
  36351. end_time := c.GetString("end_time")
  36352. check_time := c.GetString("check_time")
  36353. hospital_code := c.GetString("hospital_code")
  36354. hospital_name := c.GetString("hospital_name")
  36355. adminUser := c.GetAdminUserInfo()
  36356. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36357. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36358. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36359. sick, _ := service.FindSickById(sick_id)
  36360. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36361. if len(hospital_code) == 0 {
  36362. hospital_code = miConfig.Code
  36363. }
  36364. if len(hospital_name) == 0 {
  36365. hospital_name = miConfig.OrgName
  36366. }
  36367. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36368. var res ResultTwo
  36369. var res10265 ResultTwo10265
  36370. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36371. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36372. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36373. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36374. "&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
  36375. resp, requestErr := http.Get(api)
  36376. if requestErr != nil {
  36377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36378. return
  36379. }
  36380. body, ioErr := ioutil.ReadAll(resp.Body)
  36381. if ioErr != nil {
  36382. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36384. return
  36385. }
  36386. var respJSON map[string]interface{}
  36387. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36390. return
  36391. }
  36392. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36393. result, _ := json.Marshal(respJSON)
  36394. fmt.Println("log")
  36395. fmt.Println(string(result))
  36396. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36397. utils.ErrorLog("解析失败:%v", err)
  36398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36399. return
  36400. }
  36401. res.ErrMsg = res10265.ErrMsg
  36402. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36403. res.Infcode = infocode
  36404. res.Output = res10265.Output
  36405. res.InfRefmsgid = res10265.InfRefmsgid
  36406. } else {
  36407. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36408. if miConfig.Code == "H15049901371" {
  36409. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36410. utils.ErrorLog("解析失败:%v", err)
  36411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36412. return
  36413. }
  36414. res.ErrMsg = res10265.ErrMsg
  36415. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36416. res.Infcode = infocode
  36417. res.Output = res10265.Output
  36418. res.InfRefmsgid = res10265.InfRefmsgid
  36419. } else {
  36420. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36421. utils.ErrorLog("解析失败:%v", err)
  36422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36423. return
  36424. }
  36425. }
  36426. }
  36427. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36428. infoStr := string(Iinfos)
  36429. var rf []*ResultFive
  36430. json.Unmarshal([]byte(infoStr), &rf)
  36431. var insuplc_admdvs string
  36432. var insutype string
  36433. var is390 int = 0
  36434. var is310 int = 0
  36435. var insutypes []*ResultFive
  36436. for _, item := range rf {
  36437. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36438. insutypes = append(insutypes, item)
  36439. }
  36440. }
  36441. if len(insutypes) == 1 {
  36442. insutype = insutypes[0].Insutype
  36443. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36444. } else {
  36445. for _, i := range insutypes {
  36446. if i.Insutype == "390" {
  36447. is390 = 1
  36448. }
  36449. if i.Insutype == "310" {
  36450. is310 = 1
  36451. }
  36452. }
  36453. }
  36454. if is390 == 1 {
  36455. insutype = "390"
  36456. }
  36457. if is310 == 1 {
  36458. insutype = "310"
  36459. }
  36460. if len(insutypes) == 2 {
  36461. insutype = insutype_two
  36462. }
  36463. if len(insutypes) == 0 {
  36464. insutype = "310"
  36465. }
  36466. insutype = insutype_two
  36467. fmt.Println(insutype)
  36468. for _, item := range rf {
  36469. fmt.Println(item.Insutype)
  36470. fmt.Println(insutype)
  36471. if item.Insutype == insutype {
  36472. fmt.Println(item.Insutype)
  36473. fmt.Println(insutype)
  36474. insuplc_admdvs = item.InsuplcAdmdvs
  36475. }
  36476. }
  36477. fmt.Println(insuplc_admdvs)
  36478. var res2 ResultThirteen
  36479. var res10265_2 ResultThirteen10265
  36480. if config.IsOpen == 1 {
  36481. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36482. } else {
  36483. if miConfig.MdtrtareaAdmvs == "150499" {
  36484. //
  36485. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36486. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36487. // "&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
  36488. //resp, requestErr := http.Get(api)
  36489. //if requestErr != nil {
  36490. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36491. // return
  36492. //}
  36493. //
  36494. //body, ioErr := ioutil.ReadAll(resp.Body)
  36495. //if ioErr != nil {
  36496. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36497. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36498. // return
  36499. //}
  36500. //var respJSON map[string]interface{}
  36501. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36502. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36504. // return
  36505. //}
  36506. //
  36507. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36508. //result, _ := json.Marshal(respJSON)
  36509. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36510. // utils.ErrorLog("解析失败:%v", err)
  36511. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36512. // return
  36513. //}
  36514. //infocode = resThree.Infcode
  36515. //result, _ := json.Marshal(respJSON)
  36516. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36517. // utils.ErrorLog("解析失败:%v", err)
  36518. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36519. // return
  36520. //}
  36521. //
  36522. //resThree.ErrMsg = resThree10265.ErrMsg
  36523. //
  36524. //resThree.Output = resThree10265.Output
  36525. //
  36526. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36527. //
  36528. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36529. //
  36530. } else {
  36531. 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)
  36532. var dat map[string]interface{}
  36533. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36534. fmt.Println(dat)
  36535. } else {
  36536. fmt.Println(err)
  36537. }
  36538. userJSONBytes, _ := json.Marshal(dat)
  36539. if miConfig.Code == "H15049901371" {
  36540. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36541. utils.ErrorLog("解析失败:%v", err)
  36542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36543. return
  36544. }
  36545. res2.ErrMsg = res10265_2.ErrMsg
  36546. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36547. res2.Infcode = infocode
  36548. res2.Output = res10265_2.Output
  36549. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36550. } else {
  36551. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36552. utils.ErrorLog("解析失败:%v", err)
  36553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36554. return
  36555. }
  36556. }
  36557. }
  36558. }
  36559. if res2.Infcode == 0 {
  36560. psnResult := &models.GdybPsnNcdsRecord{
  36561. UserOrgId: adminUser.CurrentOrgId,
  36562. PatientId: patient.ID,
  36563. PsnNo: psn_no,
  36564. DoctorId: doctor.AdminUserId,
  36565. DepartmentId: department_id,
  36566. SickType: sick_id,
  36567. Insutype: insutype,
  36568. Ctime: time.Now().Unix(),
  36569. Mtime: time.Now().Unix(),
  36570. Status: 1,
  36571. IsCancel: 1,
  36572. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36573. }
  36574. service.CreatePsnNCDSRecord(psnResult)
  36575. c.ServeSuccessJSON(map[string]interface{}{
  36576. "failed_code": 0,
  36577. "msg": "备案成功",
  36578. "result": psnResult,
  36579. })
  36580. } else {
  36581. c.ServeSuccessJSON(map[string]interface{}{
  36582. "failed_code": -10,
  36583. "msg": res2.ErrMsg,
  36584. })
  36585. return
  36586. }
  36587. }
  36588. }
  36589. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36590. id, _ := c.GetInt64("id")
  36591. admin_user_id, _ := c.GetInt64("admin_user_id")
  36592. adminUser := c.GetAdminUserInfo()
  36593. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36594. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36595. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36596. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36597. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36598. //var user_name string
  36599. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36600. //if role.ID == 0 {
  36601. // user_name = "xxx"
  36602. //} else {
  36603. // user_name = role.UserName
  36604. //}
  36605. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36606. if psn_record.ID == 0 {
  36607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36608. return
  36609. }
  36610. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36611. var res ResultTwo
  36612. var res10265 ResultTwo10265
  36613. if miConfig.Code == "H15049901371" {
  36614. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36615. utils.ErrorLog("解析失败:%v", err)
  36616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36617. return
  36618. }
  36619. res.ErrMsg = res10265.ErrMsg
  36620. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36621. res.Infcode = infocode
  36622. res.Output = res10265.Output
  36623. res.InfRefmsgid = res10265.InfRefmsgid
  36624. } else {
  36625. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36626. utils.ErrorLog("解析失败:%v", err)
  36627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36628. return
  36629. }
  36630. }
  36631. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36632. infoStr := string(Iinfos)
  36633. var rf []*ResultFive
  36634. json.Unmarshal([]byte(infoStr), &rf)
  36635. var insuplc_admdvs string
  36636. var insutype string
  36637. var is390 int = 0
  36638. var is310 int = 0
  36639. var insutypes []*ResultFive
  36640. for _, item := range rf {
  36641. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36642. insutypes = append(insutypes, item)
  36643. }
  36644. }
  36645. if len(insutypes) == 1 {
  36646. insutype = insutypes[0].Insutype
  36647. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36648. } else {
  36649. for _, i := range insutypes {
  36650. if i.Insutype == "390" {
  36651. is390 = 1
  36652. }
  36653. if i.Insutype == "310" {
  36654. is310 = 1
  36655. }
  36656. }
  36657. }
  36658. if is390 == 1 {
  36659. insutype = "390"
  36660. }
  36661. if is310 == 1 {
  36662. insutype = "310"
  36663. }
  36664. if len(insutypes) == 0 {
  36665. insutype = "310"
  36666. }
  36667. insutype = psn_record.Insutype
  36668. for _, item := range rf {
  36669. if item.Insutype == insutype {
  36670. insuplc_admdvs = item.InsuplcAdmdvs
  36671. }
  36672. }
  36673. if config.IsOpen == 1 {
  36674. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36675. var dat map[string]interface{}
  36676. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36677. fmt.Println(dat)
  36678. } else {
  36679. fmt.Println(err)
  36680. }
  36681. userJSONBytes, _ := json.Marshal(dat)
  36682. var res ResultFourteen
  36683. var res10265 ResultFourteen10265
  36684. if miConfig.Code == "H15049901371" {
  36685. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36686. utils.ErrorLog("解析失败:%v", err)
  36687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36688. return
  36689. }
  36690. res.ErrMsg = res10265.ErrMsg
  36691. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36692. res.Infcode = infocode
  36693. res.Output = res10265.Output
  36694. res.InfRefmsgid = res10265.InfRefmsgid
  36695. } else {
  36696. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36697. utils.ErrorLog("解析失败:%v", err)
  36698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36699. return
  36700. }
  36701. }
  36702. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36703. // utils.ErrorLog("解析失败:%v", err)
  36704. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36705. // return
  36706. //}
  36707. if res.Infcode == 0 {
  36708. psn_record.IsCancel = 2
  36709. service.CreatePsnNCDSRecord(&psn_record)
  36710. c.ServeSuccessJSON(map[string]interface{}{
  36711. "failed_code": 0,
  36712. "msg": "撤销备案成功",
  36713. })
  36714. } else {
  36715. c.ServeSuccessJSON(map[string]interface{}{
  36716. "failed_code": -10,
  36717. "msg": res.ErrMsg,
  36718. })
  36719. return
  36720. }
  36721. }
  36722. }
  36723. func (c *HisApiController) TestTest() {
  36724. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36725. fmt.Println(patient.Iinfo)
  36726. }
  36727. type CustomData struct {
  36728. MsgId string
  36729. PsnNo string
  36730. Info string
  36731. }
  36732. func (c *HisApiController) ReversalData() {
  36733. var customData []*CustomData
  36734. custom := &CustomData{
  36735. MsgId: "H44022900158202103301714472004",
  36736. PsnNo: "44020000001101329945",
  36737. Info: "2207",
  36738. }
  36739. customData = append(customData, custom)
  36740. custom1 := &CustomData{
  36741. MsgId: "H4402290015820210330172057803",
  36742. PsnNo: "44020000001101161813",
  36743. Info: "2207",
  36744. }
  36745. customData = append(customData, custom1)
  36746. custom2 := &CustomData{
  36747. MsgId: "H44022900158202103301705198813",
  36748. PsnNo: "44190000133097375417",
  36749. Info: "2207",
  36750. }
  36751. customData = append(customData, custom2)
  36752. custom3 := &CustomData{
  36753. MsgId: "H44022900158202103301715524756",
  36754. PsnNo: "44020000001100187221",
  36755. Info: "2207",
  36756. }
  36757. customData = append(customData, custom3)
  36758. custom4 := &CustomData{
  36759. MsgId: "H44022900158202103301730376224",
  36760. PsnNo: "44020000001101959155",
  36761. Info: "2207",
  36762. }
  36763. customData = append(customData, custom4)
  36764. custom5 := &CustomData{
  36765. MsgId: "H44022900158202103301748008725",
  36766. PsnNo: "44020000001104246641",
  36767. Info: "2207",
  36768. }
  36769. customData = append(customData, custom5)
  36770. custom6 := &CustomData{
  36771. MsgId: "H44022900158202103301718096755",
  36772. PsnNo: "44020000001102211860",
  36773. Info: "2207",
  36774. }
  36775. customData = append(customData, custom6)
  36776. custom7 := &CustomData{
  36777. MsgId: "H44022900158202103301736551640",
  36778. PsnNo: "44020000001102687718",
  36779. Info: "2207",
  36780. }
  36781. customData = append(customData, custom7)
  36782. custom8 := &CustomData{
  36783. MsgId: "H44022900158202103301743097676",
  36784. PsnNo: "44020000001102127785",
  36785. Info: "2207",
  36786. }
  36787. customData = append(customData, custom8)
  36788. custom9 := &CustomData{
  36789. MsgId: "H44022900158202103301712304203",
  36790. PsnNo: "44020000001101518097",
  36791. Info: "2207",
  36792. }
  36793. customData = append(customData, custom9)
  36794. custom10 := &CustomData{
  36795. MsgId: "H44022900158202103301738448785",
  36796. PsnNo: "44020000001100500813",
  36797. Info: "2207",
  36798. }
  36799. customData = append(customData, custom10)
  36800. custom11 := &CustomData{
  36801. MsgId: "H44022900158202103301732455843",
  36802. PsnNo: "44020000001102690557",
  36803. Info: "2207",
  36804. }
  36805. customData = append(customData, custom11)
  36806. custom12 := &CustomData{
  36807. MsgId: "H44022900158202103301745421708",
  36808. PsnNo: "44020000001102211928",
  36809. Info: "2207",
  36810. }
  36811. customData = append(customData, custom12)
  36812. custom1212 := &CustomData{
  36813. MsgId: "H440229001582021033017351627",
  36814. PsnNo: "44020000001102481733",
  36815. Info: "2207",
  36816. }
  36817. customData = append(customData, custom1212)
  36818. custom13 := &CustomData{
  36819. MsgId: "H44022900158202103301740327951",
  36820. PsnNo: "44020000001103174866",
  36821. Info: "2207",
  36822. }
  36823. customData = append(customData, custom13)
  36824. custom14 := &CustomData{
  36825. MsgId: "H4402290015820210330174922668",
  36826. PsnNo: "44020000001102927272",
  36827. Info: "2207",
  36828. }
  36829. customData = append(customData, custom14)
  36830. custom15 := &CustomData{
  36831. MsgId: "H44022900158202103301752362273",
  36832. PsnNo: "44020000001102942890",
  36833. Info: "2207",
  36834. }
  36835. customData = append(customData, custom15)
  36836. custom16 := &CustomData{
  36837. MsgId: "H44022900158202103301751082917",
  36838. PsnNo: "44020000001101662162",
  36839. Info: "2207",
  36840. }
  36841. customData = append(customData, custom16)
  36842. custom17 := &CustomData{
  36843. MsgId: "H44022900158202103301754147728",
  36844. PsnNo: "44020000000229014511",
  36845. Info: "2207",
  36846. }
  36847. customData = append(customData, custom17)
  36848. adminUser := c.GetAdminUserInfo()
  36849. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36850. for _, item := range customData {
  36851. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36852. fmt.Println(result)
  36853. }
  36854. }
  36855. func (c *HisApiController) GetAllopatry() {
  36856. year := c.GetString("year")
  36857. month := c.GetString("month")
  36858. admin_user_id, _ := c.GetInt64("admin_user_id")
  36859. adminUser := c.GetAdminUserInfo()
  36860. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36861. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36862. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36863. var dat map[string]interface{}
  36864. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36865. fmt.Println(dat)
  36866. } else {
  36867. fmt.Println(err)
  36868. }
  36869. userJSONBytes, _ := json.Marshal(dat)
  36870. var res models.Result9001
  36871. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36872. utils.ErrorLog("解析失败:%v", err)
  36873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36874. return
  36875. }
  36876. fmt.Println(res.Output.Signinoutb)
  36877. fmt.Println(res.Output.Signinoutb.SignNo)
  36878. fmt.Println(string(userJSONBytes))
  36879. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36880. var dat3 map[string]interface{}
  36881. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  36882. fmt.Println(dat3)
  36883. } else {
  36884. fmt.Println(err)
  36885. }
  36886. userJSONBytes3, _ := json.Marshal(dat3)
  36887. var res3 models.Result3260
  36888. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  36889. utils.ErrorLog("解析失败:%v", err)
  36890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36891. return
  36892. }
  36893. var curpage int
  36894. var pagesize int = 100
  36895. var start int = 1
  36896. //var stop int
  36897. //pagecount := 10
  36898. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  36899. var res22 []models.Result3260
  36900. for curpage = 1; curpage <= pagecount; curpage++ {
  36901. if curpage == 1 {
  36902. start = 0
  36903. } else {
  36904. start = (curpage-1)*pagesize + 1
  36905. }
  36906. fmt.Println(start)
  36907. //stop = curpage * pagesize
  36908. //if stop > int(res3.Output.Totalrow) {
  36909. // stop =int(res3.Output.Totalrow)
  36910. //}
  36911. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  36912. var dat2 map[string]interface{}
  36913. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36914. fmt.Println(dat)
  36915. } else {
  36916. fmt.Println(err)
  36917. }
  36918. userJSONBytes2, _ := json.Marshal(dat2)
  36919. var res2 models.Result3260
  36920. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36921. utils.ErrorLog("解析失败:%v", err)
  36922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36923. return
  36924. }
  36925. if res2.Infcode == 0 {
  36926. res22 = append(res22, res2)
  36927. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36928. //var dat2 map[string]interface{}
  36929. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36930. // fmt.Println(dat)
  36931. //} else {
  36932. // fmt.Println(err)
  36933. //}
  36934. //c.ServeSuccessJSON(map[string]interface{}{
  36935. // "list": res2.Output.Data,
  36936. //})
  36937. //continue
  36938. }
  36939. }
  36940. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36941. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36942. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  36943. //var dat2 map[string]interface{}
  36944. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36945. // fmt.Println(dat)
  36946. //} else {
  36947. // fmt.Println(err)
  36948. //}
  36949. //userJSONBytes2, _ := json.Marshal(dat2)
  36950. //var res2 models.Result3260
  36951. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36952. // utils.ErrorLog("解析失败:%v", err)
  36953. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36954. // return
  36955. //}
  36956. //if res2.Infcode == 0 {
  36957. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36958. // var dat2 map[string]interface{}
  36959. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36960. // fmt.Println(dat)
  36961. // } else {
  36962. // fmt.Println(err)
  36963. // }
  36964. // c.ServeSuccessJSON(map[string]interface{}{
  36965. // "list": res2.Output.Data,
  36966. // })
  36967. //}
  36968. }
  36969. func (c *HisApiController) ComfirmAllopatry() {
  36970. year := c.GetString("year")
  36971. month := c.GetString("month")
  36972. admin_user_id, _ := c.GetInt64("admin_user_id")
  36973. adminUser := c.GetAdminUserInfo()
  36974. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36975. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36976. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36977. var dat map[string]interface{}
  36978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36979. fmt.Println(dat)
  36980. } else {
  36981. fmt.Println(err)
  36982. }
  36983. userJSONBytes, _ := json.Marshal(dat)
  36984. var res models.Result9001
  36985. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36986. utils.ErrorLog("解析失败:%v", err)
  36987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36988. return
  36989. }
  36990. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36991. var dat2 map[string]interface{}
  36992. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36993. fmt.Println(dat)
  36994. } else {
  36995. fmt.Println(err)
  36996. }
  36997. userJSONBytes2, _ := json.Marshal(dat2)
  36998. var res2 models.Result3260
  36999. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37000. utils.ErrorLog("解析失败:%v", err)
  37001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37002. return
  37003. }
  37004. //if res2.Infcode == 0 {
  37005. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37006. // var dat map[string]interface{}
  37007. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37008. // fmt.Println(dat)
  37009. // } else {
  37010. // fmt.Println(err)
  37011. // }
  37012. // userJSONBytes, _ := json.Marshal(dat)
  37013. // var res3 models.Result3261
  37014. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37015. // utils.ErrorLog("解析失败:%v", err)
  37016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37017. // return
  37018. // }
  37019. //
  37020. // if res3.Infcode == 0 {
  37021. // record := &models.HisYidiClearRecord{
  37022. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37023. // Ctime: time.Now().Unix(),
  37024. // Mtime: time.Now().Unix(),
  37025. // Status: 1,
  37026. // MsgId: msgId,
  37027. // }
  37028. // service.SaveClearRecord(record)
  37029. // c.ServeSuccessJSON(map[string]interface{}{
  37030. // "msg": "提取成功",
  37031. // })
  37032. // }
  37033. //}
  37034. }
  37035. func (c *HisApiController) RefundAllopatry() {
  37036. year := c.GetString("year")
  37037. month := c.GetString("month")
  37038. //id, _ := c.GetInt64("id")
  37039. admin_user_id, _ := c.GetInt64("admin_user_id")
  37040. adminUser := c.GetAdminUserInfo()
  37041. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37042. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37043. //record, _ := service.GetClearRecordById(id)
  37044. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37045. var dat map[string]interface{}
  37046. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37047. fmt.Println(dat)
  37048. } else {
  37049. fmt.Println(err)
  37050. }
  37051. userJSONBytes, _ := json.Marshal(dat)
  37052. var res models.Result9001
  37053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37054. utils.ErrorLog("解析失败:%v", err)
  37055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37056. return
  37057. }
  37058. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37059. var dat2 map[string]interface{}
  37060. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37061. fmt.Println(dat)
  37062. } else {
  37063. fmt.Println(err)
  37064. }
  37065. userJSONBytes2, _ := json.Marshal(dat2)
  37066. var empty ResultFourteen
  37067. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37068. utils.ErrorLog("解析失败:%v", err)
  37069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37070. return
  37071. }
  37072. if empty.Infcode == 0 {
  37073. c.ServeSuccessJSON(map[string]interface{}{
  37074. "msg": "撤销成功",
  37075. })
  37076. return
  37077. }
  37078. }
  37079. func (c *HisApiController) ReversalOtherData() {
  37080. var customData []*CustomData
  37081. custom := &CustomData{
  37082. MsgId: "H44022900158202103301714472004",
  37083. PsnNo: "44020000001101329945",
  37084. Info: "2208",
  37085. }
  37086. customData = append(customData, custom)
  37087. custom1 := &CustomData{
  37088. MsgId: "H4402290015820210330172057803",
  37089. PsnNo: "44020000001101161813",
  37090. Info: "2208",
  37091. }
  37092. customData = append(customData, custom1)
  37093. custom2 := &CustomData{
  37094. MsgId: "H44022900158202103301705198813",
  37095. PsnNo: "44190000133097375417",
  37096. Info: "2208",
  37097. }
  37098. customData = append(customData, custom2)
  37099. custom3 := &CustomData{
  37100. MsgId: "H44022900158202103301715524756",
  37101. PsnNo: "44020000001100187221",
  37102. Info: "2208",
  37103. }
  37104. customData = append(customData, custom3)
  37105. custom4 := &CustomData{
  37106. MsgId: "H44022900158202103301730376224",
  37107. PsnNo: "44020000001101959155",
  37108. Info: "2208",
  37109. }
  37110. customData = append(customData, custom4)
  37111. custom5 := &CustomData{
  37112. MsgId: "H44022900158202103301748008725",
  37113. PsnNo: "44020000001104246641",
  37114. Info: "2208",
  37115. }
  37116. customData = append(customData, custom5)
  37117. custom6 := &CustomData{
  37118. MsgId: "H44022900158202103301718096755",
  37119. PsnNo: "44020000001102211860",
  37120. Info: "2208",
  37121. }
  37122. customData = append(customData, custom6)
  37123. custom7 := &CustomData{
  37124. MsgId: "H44022900158202103301736551640",
  37125. PsnNo: "44020000001102687718",
  37126. Info: "2208",
  37127. }
  37128. customData = append(customData, custom7)
  37129. custom8 := &CustomData{
  37130. MsgId: "H44022900158202103301743097676",
  37131. PsnNo: "44020000001102127785",
  37132. Info: "2208",
  37133. }
  37134. customData = append(customData, custom8)
  37135. custom9 := &CustomData{
  37136. MsgId: "H44022900158202103301712304203",
  37137. PsnNo: "44020000001101518097",
  37138. Info: "2208",
  37139. }
  37140. customData = append(customData, custom9)
  37141. custom10 := &CustomData{
  37142. MsgId: "H44022900158202103301738448785",
  37143. PsnNo: "44020000001100500813",
  37144. Info: "2208",
  37145. }
  37146. customData = append(customData, custom10)
  37147. custom11 := &CustomData{
  37148. MsgId: "H44022900158202103301732455843",
  37149. PsnNo: "44020000001102690557",
  37150. Info: "2208",
  37151. }
  37152. customData = append(customData, custom11)
  37153. custom12 := &CustomData{
  37154. MsgId: "H44022900158202103301745421708",
  37155. PsnNo: "44020000001102211928",
  37156. Info: "2208",
  37157. }
  37158. customData = append(customData, custom12)
  37159. custom1212 := &CustomData{
  37160. MsgId: "H440229001582021033017351627",
  37161. PsnNo: "44020000001102481733",
  37162. Info: "2208",
  37163. }
  37164. customData = append(customData, custom1212)
  37165. custom13 := &CustomData{
  37166. MsgId: "H44022900158202103301740327951",
  37167. PsnNo: "44020000001103174866",
  37168. Info: "2208",
  37169. }
  37170. customData = append(customData, custom13)
  37171. custom14 := &CustomData{
  37172. MsgId: "H4402290015820210330174922668",
  37173. PsnNo: "44020000001102927272",
  37174. Info: "2208",
  37175. }
  37176. customData = append(customData, custom14)
  37177. custom15 := &CustomData{
  37178. MsgId: "H44022900158202103301752362273",
  37179. PsnNo: "44020000001102942890",
  37180. Info: "2208",
  37181. }
  37182. customData = append(customData, custom15)
  37183. custom16 := &CustomData{
  37184. MsgId: "H44022900158202103301751082917",
  37185. PsnNo: "44020000001101662162",
  37186. Info: "2208",
  37187. }
  37188. customData = append(customData, custom16)
  37189. custom17 := &CustomData{
  37190. MsgId: "H44022900158202103301754147728",
  37191. PsnNo: "44020000000229014511",
  37192. Info: "2208",
  37193. }
  37194. customData = append(customData, custom17)
  37195. adminUser := c.GetAdminUserInfo()
  37196. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37197. for _, item := range customData {
  37198. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37199. fmt.Println(result)
  37200. }
  37201. }
  37202. func PathExists(path string) (bool, error) {
  37203. _, err := os.Stat(path)
  37204. if err == nil {
  37205. return true, nil
  37206. }
  37207. if os.IsNotExist(err) {
  37208. return false, nil
  37209. }
  37210. return false, err
  37211. }
  37212. // 创建文件夹
  37213. func Mkdir(dir string) {
  37214. // 创建文件夹
  37215. exist, err := PathExists(dir)
  37216. if err != nil {
  37217. fmt.Println(err.Error())
  37218. } else {
  37219. if exist {
  37220. fmt.Println(dir + "文件夹已存在!")
  37221. } else {
  37222. // 文件夹名称,权限
  37223. err := os.Mkdir(dir, os.ModePerm)
  37224. if err != nil {
  37225. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37226. } else {
  37227. fmt.Println(dir + "文件夹创建成功!")
  37228. }
  37229. }
  37230. }
  37231. }
  37232. // 压缩文件
  37233. func Zip(srcFile string, destZip string) error {
  37234. zipfile, err := os.Create(destZip)
  37235. if err != nil {
  37236. return err
  37237. }
  37238. defer zipfile.Close()
  37239. archive := zip.NewWriter(zipfile)
  37240. defer archive.Close()
  37241. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37242. if err != nil {
  37243. return err
  37244. }
  37245. header, err := zip.FileInfoHeader(info)
  37246. if err != nil {
  37247. return err
  37248. }
  37249. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37250. // header.Name = path
  37251. if info.IsDir() {
  37252. header.Name += "/"
  37253. } else {
  37254. header.Method = zip.Deflate
  37255. }
  37256. writer, err := archive.CreateHeader(header)
  37257. if err != nil {
  37258. return err
  37259. }
  37260. if !info.IsDir() {
  37261. file, err := os.Open(path)
  37262. if err != nil {
  37263. return err
  37264. }
  37265. defer file.Close()
  37266. _, err = io.Copy(writer, file)
  37267. }
  37268. return err
  37269. })
  37270. return err
  37271. }
  37272. func ReadFile(filePath string) []byte {
  37273. f, err := os.Open(filePath)
  37274. if err != nil {
  37275. fmt.Println("read file fail", err)
  37276. return nil
  37277. }
  37278. defer f.Close()
  37279. fd, err := ioutil.ReadAll(f)
  37280. if err != nil {
  37281. fmt.Println("read to fd fail", err)
  37282. return nil
  37283. }
  37284. return fd
  37285. }
  37286. func saveLogq(result string, request string, infno string, desc string) {
  37287. dir := "日志"
  37288. utils.Mkdir(dir)
  37289. month := time.Unix(1557042972, 0).Format("1")
  37290. year := time.Now().Format("2006")
  37291. month = time.Now().Format("01")
  37292. day := time.Now().Format("02")
  37293. hour := time.Now().Format("15")
  37294. min := time.Now().Format("04")
  37295. sec := time.Now().Format("05")
  37296. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37297. file := year + month + day + "_log"
  37298. file_name := file + ".txt"
  37299. file_path := "日志" + "/" + file_name
  37300. exist, _ := utils.PathExists(file_path)
  37301. if exist { //存在
  37302. fmt.Println("存在")
  37303. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37304. if err != nil {
  37305. fmt.Println("read fail")
  37306. }
  37307. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37308. n, _ := f.Seek(0, 2)
  37309. _, err = f.WriteAt([]byte(content), n)
  37310. } else { //不存在
  37311. fmt.Println("文件不存在,创建文件")
  37312. f, err := os.Create("日志" + "/" + file_name)
  37313. defer f.Close()
  37314. if err != nil {
  37315. } else {
  37316. _, err = f.Write([]byte("记录日志"))
  37317. }
  37318. }
  37319. }
  37320. func saveLog(result string, request string, infno string, desc string) {
  37321. org_id, _ := beego.AppConfig.Int64("org_id")
  37322. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37323. dir := miConfig.OrgName + "日志"
  37324. utils.Mkdir(dir)
  37325. month := time.Unix(1557042972, 0).Format("1")
  37326. year := time.Now().Format("2006")
  37327. month = time.Now().Format("01")
  37328. day := time.Now().Format("02")
  37329. hour := time.Now().Format("15")
  37330. min := time.Now().Format("04")
  37331. sec := time.Now().Format("05")
  37332. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37333. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37334. file_name := file + ".txt"
  37335. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37336. exist, _ := utils.PathExists(file_path)
  37337. if exist { //存在
  37338. fmt.Println("存在")
  37339. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37340. if err != nil {
  37341. fmt.Println("read fail")
  37342. }
  37343. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37344. n, _ := f.Seek(0, 2)
  37345. _, err = f.WriteAt([]byte(content), n)
  37346. } else { //不存在
  37347. fmt.Println("文件不存在,创建文件")
  37348. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37349. defer f.Close()
  37350. if err != nil {
  37351. } else {
  37352. _, err = f.Write([]byte("记录日志"))
  37353. }
  37354. }
  37355. }
  37356. type Charset string
  37357. const (
  37358. UTF8 = Charset("UTF-8")
  37359. GB18030 = Charset("GB18030")
  37360. )
  37361. func ConvertToString(src string, srcCode string, tagCode string) string {
  37362. srcCoder := mahonia.NewDecoder(srcCode)
  37363. srcResult := srcCoder.ConvertString(src)
  37364. tagCoder := mahonia.NewDecoder(tagCode)
  37365. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37366. result := string(cdata)
  37367. return result
  37368. }
  37369. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37370. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37371. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37372. var token string
  37373. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37374. var api string
  37375. if miConfig.MdtrtareaAdmvs == "320921" {
  37376. 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 +
  37377. "&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
  37378. fmt.Println(api)
  37379. } else {
  37380. 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 +
  37381. "&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
  37382. }
  37383. resp, requestErr := http.Get(api)
  37384. if requestErr != nil {
  37385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37386. return ""
  37387. }
  37388. body, ioErr := ioutil.ReadAll(resp.Body)
  37389. if ioErr != nil {
  37390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37392. return ""
  37393. }
  37394. var respJSON map[string]interface{}
  37395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37398. return ""
  37399. }
  37400. var status string
  37401. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37402. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37403. var res ResultTwo //1101结果
  37404. var res10265 ResultTwo10265 //1101结果
  37405. if status == "0" { //读卡成功
  37406. var card_info string //卡信息
  37407. var busi_card_info string
  37408. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37409. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37410. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37411. fmt.Println(card_info)
  37412. fmt.Println(busi_card_info)
  37413. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37414. result, _ := json.Marshal(respJSON)
  37415. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37416. utils.ErrorLog("解析失败:%v", err)
  37417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37418. return ""
  37419. }
  37420. res.ErrMsg = res10265.ErrMsg
  37421. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37422. res.Infcode = infocode
  37423. res.Output = res10265.Output
  37424. res.InfRefmsgid = res10265.InfRefmsgid
  37425. if res.Infcode == 0 {
  37426. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37427. if err == gorm.ErrRecordNotFound {
  37428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37429. return ""
  37430. } else if err != nil {
  37431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37432. return ""
  37433. } else {
  37434. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37435. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37436. infoStr := string(Iinfos)
  37437. idetinfoStr := string(Idetinfos)
  37438. psn := &models.HisPsn{
  37439. PsnNo: res.Output.Baseinfo.PsnNo,
  37440. PatientId: patient.ID,
  37441. Certno: res.Output.Baseinfo.Certno,
  37442. Gend: res.Output.Baseinfo.Gend,
  37443. Naty: res.Output.Baseinfo.Naty,
  37444. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37445. PsnName: res.Output.Baseinfo.PsnName,
  37446. Idetinfo: idetinfoStr,
  37447. Insuinfo: infoStr,
  37448. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37449. CardInfo: card_info,
  37450. VerifyNumber: token,
  37451. }
  37452. service.CreateHisPsn(psn)
  37453. return token
  37454. }
  37455. }
  37456. } else {
  37457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37458. return ""
  37459. }
  37460. } else { //读卡失败
  37461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37462. return ""
  37463. }
  37464. return token
  37465. }
  37466. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37467. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37468. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37469. var token string
  37470. var api string
  37471. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37472. "&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
  37473. fmt.Println(api)
  37474. resp, requestErr := http.Get(api)
  37475. if requestErr != nil {
  37476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37477. return ""
  37478. }
  37479. body, ioErr := ioutil.ReadAll(resp.Body)
  37480. if ioErr != nil {
  37481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37483. return ""
  37484. }
  37485. var respJSON map[string]interface{}
  37486. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37489. return ""
  37490. }
  37491. var status string
  37492. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37493. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37494. var res ResultTwo //1101结果
  37495. if status == "1" { //读卡成功
  37496. var card_info string //卡信息
  37497. var busi_card_info string
  37498. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37499. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37500. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37501. fmt.Println(card_info)
  37502. fmt.Println(busi_card_info)
  37503. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37504. result, _ := json.Marshal(respJSON)
  37505. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37506. utils.ErrorLog("解析失败:%v", err)
  37507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37508. return ""
  37509. }
  37510. if res.Infcode == 0 {
  37511. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37512. if err == gorm.ErrRecordNotFound {
  37513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37514. return ""
  37515. } else if err != nil {
  37516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37517. return ""
  37518. } else {
  37519. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37520. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37521. infoStr := string(Iinfos)
  37522. idetinfoStr := string(Idetinfos)
  37523. psn := &models.HisPsn{
  37524. PsnNo: res.Output.Baseinfo.PsnNo,
  37525. PatientId: patient.ID,
  37526. Certno: res.Output.Baseinfo.Certno,
  37527. Gend: res.Output.Baseinfo.Gend,
  37528. Naty: res.Output.Baseinfo.Naty,
  37529. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37530. PsnName: res.Output.Baseinfo.PsnName,
  37531. Idetinfo: idetinfoStr,
  37532. Insuinfo: infoStr,
  37533. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37534. CardInfo: card_info,
  37535. VerifyNumber: token,
  37536. }
  37537. service.CreateHisPsn(psn)
  37538. return token
  37539. }
  37540. }
  37541. } else {
  37542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37543. return ""
  37544. }
  37545. return token
  37546. }
  37547. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37548. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37549. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37550. var token string
  37551. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37552. var api string
  37553. if miConfig.MdtrtareaAdmvs == "320921" {
  37554. 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 +
  37555. "&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
  37556. fmt.Println(api)
  37557. } else {
  37558. 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 +
  37559. "&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
  37560. }
  37561. resp, requestErr := http.Get(api)
  37562. if requestErr != nil {
  37563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37564. return ""
  37565. }
  37566. body, ioErr := ioutil.ReadAll(resp.Body)
  37567. if ioErr != nil {
  37568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37570. return ""
  37571. }
  37572. var respJSON map[string]interface{}
  37573. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37576. return ""
  37577. }
  37578. var status string
  37579. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37580. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37581. var res ResultTwo //1101结果
  37582. var res10265 ResultTwo10265 //1101结果
  37583. if status == "0" { //读卡成功
  37584. var card_info string //卡信息
  37585. var busi_card_info string
  37586. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37587. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37588. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37589. fmt.Println(card_info)
  37590. fmt.Println(busi_card_info)
  37591. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37592. result, _ := json.Marshal(respJSON)
  37593. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37594. utils.ErrorLog("解析失败:%v", err)
  37595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37596. return ""
  37597. }
  37598. res.ErrMsg = res10265.ErrMsg
  37599. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37600. res.Infcode = infocode
  37601. res.Output = res10265.Output
  37602. res.InfRefmsgid = res10265.InfRefmsgid
  37603. if res.Infcode == 0 {
  37604. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37605. if err == gorm.ErrRecordNotFound {
  37606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37607. return ""
  37608. } else if err != nil {
  37609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37610. return ""
  37611. } else {
  37612. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37613. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37614. infoStr := string(Iinfos)
  37615. idetinfoStr := string(Idetinfos)
  37616. psn := &models.HisPsn{
  37617. PsnNo: res.Output.Baseinfo.PsnNo,
  37618. PatientId: patient.ID,
  37619. Certno: res.Output.Baseinfo.Certno,
  37620. Gend: res.Output.Baseinfo.Gend,
  37621. Naty: res.Output.Baseinfo.Naty,
  37622. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37623. PsnName: res.Output.Baseinfo.PsnName,
  37624. Idetinfo: idetinfoStr,
  37625. Insuinfo: infoStr,
  37626. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37627. CardInfo: card_info,
  37628. VerifyNumber: token,
  37629. }
  37630. service.CreateHisPsn(psn)
  37631. return token
  37632. }
  37633. }
  37634. } else {
  37635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37636. return ""
  37637. }
  37638. } else { //读卡失败
  37639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37640. return ""
  37641. }
  37642. return token
  37643. }
  37644. func DeleteExtraSpaceTwo(s string) string {
  37645. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37646. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37647. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37648. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37649. s2 := make([]byte, len(s1)) //定义字符数组切片
  37650. copy(s2, s1) //将字符串复制到切片
  37651. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37652. for len(spc_index) > 0 { //找到适配项
  37653. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37654. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37655. }
  37656. return string(s2)
  37657. }
  37658. func Remove0000(s string) string {
  37659. str := make([]rune, 0, len(s))
  37660. for _, v := range []rune(s) {
  37661. if v == 0 {
  37662. continue
  37663. }
  37664. str = append(str, v)
  37665. }
  37666. return string(str)
  37667. }
  37668. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37669. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37670. readCard := DllDef.MustFindProc("EcQuery")
  37671. pCardInfo := make([]byte, 8192)
  37672. pBusiCardInfo := make([]byte, 8192)
  37673. data := make(map[string]interface{})
  37674. //pData := make(map[string]interface{})
  37675. inputData := make(map[string]interface{})
  37676. inputData["orgId"] = code
  37677. inputData["businessType"] = "01101"
  37678. inputData["operatorId"] = operator_id
  37679. inputData["operatorName"] = operator_name
  37680. inputData["officeId"] = "001"
  37681. inputData["officeName"] = "血透室"
  37682. //
  37683. data["data"] = inputData
  37684. data["transType"] = "ec.query"
  37685. data["orgId"] = code
  37686. bytesData, _ := json.Marshal(data)
  37687. pCardInfo = bytesData
  37688. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37689. fmt.Println(ret2)
  37690. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37691. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37692. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37693. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37694. if ret2 != 0 {
  37695. return "", ""
  37696. }
  37697. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37698. }
  37699. func DeleteExtraSpace(s string) string {
  37700. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37701. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37702. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37703. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37704. s2 := make([]byte, len(s1)) //定义字符数组切片
  37705. copy(s2, s1) //将字符串复制到切片
  37706. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37707. for len(spc_index) > 0 { //找到适配项
  37708. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37709. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37710. }
  37711. return string(s2)
  37712. }
  37713. // 对账
  37714. func (c *HisApiController) Post3202() {
  37715. start_time := c.GetString("start_time")
  37716. end_time := c.GetString("end_time")
  37717. //insutype := c.GetString("insutype")
  37718. clr_type := c.GetString("clr_type")
  37719. clr_org := c.GetString("clr_optins")
  37720. admin_user_id, _ := c.GetInt64("admin_user_id")
  37721. adminUser := c.GetAdminUserInfo()
  37722. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37723. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37724. if len(clr_org) == 0 {
  37725. clr_org = miConfig.MdtrtareaAdmvs
  37726. }
  37727. timeLayout := "2006-01-02"
  37728. loc, _ := time.LoadLocation("Local")
  37729. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37730. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37731. var orders []*models.HisOrder
  37732. if clr_org == "421300" {
  37733. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37734. } else if clr_org == "420902" {
  37735. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37736. } else {
  37737. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37738. }
  37739. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37740. //fixmedins_setl_cnt := int64(len(orders))
  37741. var medfee_sumamt float64
  37742. var acct_pay float64
  37743. var fund_pay_sumamt float64
  37744. for _, item := range orders {
  37745. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37746. acct_pay = acct_pay + item.AcctPay
  37747. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37748. }
  37749. //var medfee_sumamt_two float64
  37750. //var acct_pay_two float64
  37751. //var fund_pay_sumamt_two float64
  37752. //for _, item := range orders_two {
  37753. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37754. // acct_pay_two = acct_pay_two + item.AcctPay
  37755. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37756. //}
  37757. //var user_name string
  37758. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37759. //if role.ID == 0 {
  37760. // user_name = "xxx"
  37761. //} else {
  37762. // user_name = role.UserName
  37763. //}
  37764. var res ResultSix
  37765. if config.IsOpen == 1 {
  37766. var bps []*models.BusinessParamsTwo
  37767. var bp models.BusinessParamsTwo
  37768. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37769. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37770. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37771. bp.MedfeeSumamt = medfee_sumamt_str
  37772. bp.AcctPay = acct_pay_str
  37773. bp.FundPaySumamt = fund_pay_sumamt_str
  37774. bp.Insutype = ""
  37775. bp.StmtBegndate = start_time
  37776. bp.ClrType = clr_type
  37777. bp.SetlOptins = clr_org
  37778. bp.StmtEnddate = end_time
  37779. bps = append(bps, &bp)
  37780. data := make(map[string]interface{})
  37781. data["bps"] = bps
  37782. data["org_name"] = miConfig.OrgName
  37783. data["doctor"] = role.UserName
  37784. data["fixmedins_code"] = miConfig.Code
  37785. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37786. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37787. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37788. if miConfig.MdtrtareaAdmvs == "421300" {
  37789. client := &http.Client{}
  37790. bytesData, _ := json.Marshal(data)
  37791. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37792. resp, _ := client.Do(req)
  37793. defer resp.Body.Close()
  37794. body, ioErr := ioutil.ReadAll(resp.Body)
  37795. if ioErr != nil {
  37796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37798. return
  37799. }
  37800. var respJSON map[string]interface{}
  37801. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37804. return
  37805. }
  37806. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37807. userJSONBytes, _ := json.Marshal(respJSON)
  37808. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37809. utils.ErrorLog("解析失败:%v", err)
  37810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37811. return
  37812. }
  37813. }
  37814. if miConfig.MdtrtareaAdmvs == "420200" {
  37815. client := &http.Client{}
  37816. bytesData, _ := json.Marshal(data)
  37817. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37818. resp, _ := client.Do(req)
  37819. defer resp.Body.Close()
  37820. body, ioErr := ioutil.ReadAll(resp.Body)
  37821. if ioErr != nil {
  37822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37824. return
  37825. }
  37826. var respJSON map[string]interface{}
  37827. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37830. return
  37831. }
  37832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37833. userJSONBytes, _ := json.Marshal(respJSON)
  37834. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37835. utils.ErrorLog("解析失败:%v", err)
  37836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37837. return
  37838. }
  37839. }
  37840. if miConfig.MdtrtareaAdmvs == "421182" {
  37841. client := &http.Client{}
  37842. bytesData, _ := json.Marshal(data)
  37843. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37844. resp, _ := client.Do(req)
  37845. defer resp.Body.Close()
  37846. body, ioErr := ioutil.ReadAll(resp.Body)
  37847. if ioErr != nil {
  37848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37850. return
  37851. }
  37852. var respJSON map[string]interface{}
  37853. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37856. return
  37857. }
  37858. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37859. userJSONBytes, _ := json.Marshal(respJSON)
  37860. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37861. utils.ErrorLog("解析失败:%v", err)
  37862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37863. return
  37864. }
  37865. }
  37866. if miConfig.MdtrtareaAdmvs == "420902" {
  37867. client := &http.Client{}
  37868. bytesData, _ := json.Marshal(data)
  37869. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37870. resp, _ := client.Do(req)
  37871. defer resp.Body.Close()
  37872. body, ioErr := ioutil.ReadAll(resp.Body)
  37873. if ioErr != nil {
  37874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37876. return
  37877. }
  37878. var respJSON map[string]interface{}
  37879. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37882. return
  37883. }
  37884. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37885. userJSONBytes, _ := json.Marshal(respJSON)
  37886. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37887. utils.ErrorLog("解析失败:%v", err)
  37888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37889. return
  37890. }
  37891. }
  37892. if res.Infcode == 0 {
  37893. c.ServeSuccessJSON(map[string]interface{}{
  37894. "msg": "发起成功",
  37895. })
  37896. } else {
  37897. c.ServeSuccessJSON(map[string]interface{}{
  37898. "failed_code": -10,
  37899. "msg": res.ErrMsg,
  37900. })
  37901. }
  37902. }
  37903. }
  37904. func (c *HisApiController) Post3204a() {
  37905. start_time := c.GetString("start_time")
  37906. end_time := c.GetString("end_time")
  37907. //insutype := c.GetString("insutype")
  37908. clr_type := c.GetString("clr_type")
  37909. clr_org := c.GetString("clr_optins")
  37910. admin_user_id, _ := c.GetInt64("admin_user_id")
  37911. adminUser := c.GetAdminUserInfo()
  37912. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37913. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37914. if len(clr_org) == 0 {
  37915. clr_org = miConfig.MdtrtareaAdmvs
  37916. }
  37917. timeLayout := "2006-01-02"
  37918. loc, _ := time.LoadLocation("Local")
  37919. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37920. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37921. var orders []*models.HisOrder
  37922. if clr_org == "421300" {
  37923. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37924. } else if clr_org == "420902" {
  37925. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37926. } else {
  37927. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37928. }
  37929. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37930. //fixmedins_setl_cnt := int64(len(orders))
  37931. var medfee_sumamt float64
  37932. var acct_pay float64
  37933. var fund_pay_sumamt float64
  37934. for _, item := range orders {
  37935. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37936. acct_pay = acct_pay + item.AcctPay
  37937. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37938. }
  37939. //var medfee_sumamt_two float64
  37940. //var acct_pay_two float64
  37941. //var fund_pay_sumamt_two float64
  37942. //for _, item := range orders_two {
  37943. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37944. // acct_pay_two = acct_pay_two + item.AcctPay
  37945. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37946. //}
  37947. //var user_name string
  37948. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37949. //if role.ID == 0 {
  37950. // user_name = "xxx"
  37951. //} else {
  37952. // user_name = role.UserName
  37953. //}
  37954. var res ResultSix
  37955. if config.IsOpen == 1 {
  37956. var bps []*models.BusinessParamsTwo
  37957. var bp models.BusinessParamsTwo
  37958. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37959. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37960. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37961. bp.MedfeeSumamt = medfee_sumamt_str
  37962. bp.AcctPay = acct_pay_str
  37963. bp.FundPaySumamt = fund_pay_sumamt_str
  37964. bp.Insutype = ""
  37965. bp.StmtBegndate = start_time
  37966. bp.ClrType = clr_type
  37967. bp.SetlOptins = clr_org
  37968. bp.StmtEnddate = end_time
  37969. bps = append(bps, &bp)
  37970. data := make(map[string]interface{})
  37971. data["bps"] = bps
  37972. data["org_name"] = miConfig.OrgName
  37973. data["doctor"] = role.UserName
  37974. data["fixmedins_code"] = miConfig.Code
  37975. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37976. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37977. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37978. if miConfig.MdtrtareaAdmvs == "421300" {
  37979. client := &http.Client{}
  37980. bytesData, _ := json.Marshal(data)
  37981. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37982. resp, _ := client.Do(req)
  37983. defer resp.Body.Close()
  37984. body, ioErr := ioutil.ReadAll(resp.Body)
  37985. if ioErr != nil {
  37986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37988. return
  37989. }
  37990. var respJSON map[string]interface{}
  37991. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37994. return
  37995. }
  37996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37997. userJSONBytes, _ := json.Marshal(respJSON)
  37998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37999. utils.ErrorLog("解析失败:%v", err)
  38000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38001. return
  38002. }
  38003. }
  38004. if miConfig.MdtrtareaAdmvs == "420200" {
  38005. client := &http.Client{}
  38006. bytesData, _ := json.Marshal(data)
  38007. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38008. resp, _ := client.Do(req)
  38009. defer resp.Body.Close()
  38010. body, ioErr := ioutil.ReadAll(resp.Body)
  38011. if ioErr != nil {
  38012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38014. return
  38015. }
  38016. var respJSON map[string]interface{}
  38017. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38020. return
  38021. }
  38022. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38023. userJSONBytes, _ := json.Marshal(respJSON)
  38024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38025. utils.ErrorLog("解析失败:%v", err)
  38026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38027. return
  38028. }
  38029. }
  38030. if miConfig.MdtrtareaAdmvs == "421182" {
  38031. client := &http.Client{}
  38032. bytesData, _ := json.Marshal(data)
  38033. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38034. resp, _ := client.Do(req)
  38035. defer resp.Body.Close()
  38036. body, ioErr := ioutil.ReadAll(resp.Body)
  38037. if ioErr != nil {
  38038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38040. return
  38041. }
  38042. var respJSON map[string]interface{}
  38043. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38046. return
  38047. }
  38048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38049. userJSONBytes, _ := json.Marshal(respJSON)
  38050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38051. utils.ErrorLog("解析失败:%v", err)
  38052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38053. return
  38054. }
  38055. }
  38056. if miConfig.MdtrtareaAdmvs == "420902" {
  38057. client := &http.Client{}
  38058. bytesData, _ := json.Marshal(data)
  38059. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38060. resp, _ := client.Do(req)
  38061. defer resp.Body.Close()
  38062. body, ioErr := ioutil.ReadAll(resp.Body)
  38063. if ioErr != nil {
  38064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38066. return
  38067. }
  38068. var respJSON map[string]interface{}
  38069. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38072. return
  38073. }
  38074. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38075. userJSONBytes, _ := json.Marshal(respJSON)
  38076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38077. utils.ErrorLog("解析失败:%v", err)
  38078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38079. return
  38080. }
  38081. }
  38082. if res.Infcode == 0 {
  38083. c.ServeSuccessJSON(map[string]interface{}{
  38084. "msg": "撤销成功",
  38085. })
  38086. } else {
  38087. c.ServeSuccessJSON(map[string]interface{}{
  38088. "failed_code": -10,
  38089. "msg": res.ErrMsg,
  38090. })
  38091. }
  38092. }
  38093. }
  38094. func (c *HisApiController) Post3204() {
  38095. admin_user_id, _ := c.GetInt64("admin_user_id")
  38096. id := c.GetString("id")
  38097. adminUser := c.GetAdminUserInfo()
  38098. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38099. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38100. //clr_org := miConfig.MdtrtareaAdmvs
  38101. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38102. var res ResultSix
  38103. if config.IsOpen == 1 {
  38104. data := make(map[string]interface{})
  38105. data["id"] = id
  38106. data["org_name"] = miConfig.OrgName
  38107. data["doctor"] = role.UserName
  38108. data["fixmedins_code"] = miConfig.Code
  38109. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38110. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38111. client := &http.Client{}
  38112. bytesData, _ := json.Marshal(data)
  38113. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38114. resp, _ := client.Do(req)
  38115. defer resp.Body.Close()
  38116. body, ioErr := ioutil.ReadAll(resp.Body)
  38117. if ioErr != nil {
  38118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38120. return
  38121. }
  38122. var respJSON map[string]interface{}
  38123. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38126. return
  38127. }
  38128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38129. userJSONBytes, _ := json.Marshal(respJSON)
  38130. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38131. utils.ErrorLog("解析失败:%v", err)
  38132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38133. return
  38134. }
  38135. if res.Infcode == 0 {
  38136. c.ServeSuccessJSON(map[string]interface{}{
  38137. "msg": "发起成功",
  38138. })
  38139. } else {
  38140. c.ServeSuccessJSON(map[string]interface{}{
  38141. "failed_code": -10,
  38142. "msg": res.ErrMsg,
  38143. })
  38144. }
  38145. }
  38146. }
  38147. func (c *HisApiController) Post8404() {
  38148. admin_user_id, _ := c.GetInt64("admin_user_id")
  38149. month := c.GetString("month")
  38150. adminUser := c.GetAdminUserInfo()
  38151. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38152. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38153. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38154. var res ResultSix
  38155. if config.IsOpen == 1 {
  38156. data := make(map[string]interface{})
  38157. data["month"] = month
  38158. data["org_name"] = miConfig.OrgName
  38159. data["doctor"] = role.UserName
  38160. data["fixmedins_code"] = miConfig.Code
  38161. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38162. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38163. client := &http.Client{}
  38164. bytesData, _ := json.Marshal(data)
  38165. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38166. resp, _ := client.Do(req)
  38167. defer resp.Body.Close()
  38168. body, ioErr := ioutil.ReadAll(resp.Body)
  38169. if ioErr != nil {
  38170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38172. return
  38173. }
  38174. var respJSON map[string]interface{}
  38175. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38178. return
  38179. }
  38180. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38181. userJSONBytes, _ := json.Marshal(respJSON)
  38182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38183. utils.ErrorLog("解析失败:%v", err)
  38184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38185. return
  38186. }
  38187. if res.Infcode == 0 {
  38188. c.ServeSuccessJSON(map[string]interface{}{
  38189. "msg": "查询成功",
  38190. })
  38191. } else {
  38192. c.ServeSuccessJSON(map[string]interface{}{
  38193. "failed_code": -10,
  38194. "msg": res.ErrMsg,
  38195. })
  38196. }
  38197. }
  38198. }
  38199. func (c *HisApiController) Post3202b() {
  38200. start_time := c.GetString("start_time")
  38201. end_time := c.GetString("end_time")
  38202. //insutype := c.GetString("insutype")
  38203. clr_type := c.GetString("clr_type")
  38204. clr_org := c.GetString("clr_optins")
  38205. admin_user_id, _ := c.GetInt64("admin_user_id")
  38206. adminUser := c.GetAdminUserInfo()
  38207. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38208. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38209. if len(clr_org) == 0 {
  38210. clr_org = miConfig.MdtrtareaAdmvs
  38211. }
  38212. timeLayout := "2006-01-02"
  38213. loc, _ := time.LoadLocation("Local")
  38214. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38215. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38216. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38217. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38218. //fixmedins_setl_cnt := int64(len(orders))
  38219. var medfee_sumamt float64
  38220. var acct_pay float64
  38221. var fund_pay_sumamt float64
  38222. for _, item := range orders {
  38223. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38224. acct_pay = acct_pay + item.AcctPay
  38225. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38226. }
  38227. //var medfee_sumamt_two float64
  38228. //var acct_pay_two float64
  38229. //var fund_pay_sumamt_two float64
  38230. //for _, item := range orders_two {
  38231. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38232. // acct_pay_two = acct_pay_two + item.AcctPay
  38233. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38234. //}
  38235. //var user_name string
  38236. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38237. //if role.ID == 0 {
  38238. // user_name = "xxx"
  38239. //} else {
  38240. // user_name = role.UserName
  38241. //}
  38242. var res ResultSix
  38243. if config.IsOpen == 1 {
  38244. var bps []*models.BusinessParamsTwo
  38245. var bp models.BusinessParamsTwo
  38246. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38247. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38248. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38249. bp.MedfeeSumamt = medfee_sumamt_str
  38250. bp.AcctPay = acct_pay_str
  38251. bp.FundPaySumamt = fund_pay_sumamt_str
  38252. bp.Insutype = "390"
  38253. bp.StmtBegndate = start_time
  38254. bp.ClrType = clr_type
  38255. bp.SetlOptins = clr_org
  38256. bp.StmtEnddate = end_time
  38257. bps = append(bps, &bp)
  38258. data := make(map[string]interface{})
  38259. data["bps"] = bps
  38260. data["org_name"] = miConfig.OrgName
  38261. data["doctor"] = role.UserName
  38262. data["fixmedins_code"] = miConfig.Code
  38263. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38264. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38265. if miConfig.MdtrtareaAdmvs == "421300" {
  38266. client := &http.Client{}
  38267. bytesData, _ := json.Marshal(data)
  38268. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38269. resp, _ := client.Do(req)
  38270. defer resp.Body.Close()
  38271. body, ioErr := ioutil.ReadAll(resp.Body)
  38272. if ioErr != nil {
  38273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38275. return
  38276. }
  38277. var respJSON map[string]interface{}
  38278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38281. return
  38282. }
  38283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38284. userJSONBytes, _ := json.Marshal(respJSON)
  38285. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38286. utils.ErrorLog("解析失败:%v", err)
  38287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38288. return
  38289. }
  38290. }
  38291. if miConfig.MdtrtareaAdmvs == "420200" {
  38292. client := &http.Client{}
  38293. bytesData, _ := json.Marshal(data)
  38294. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38295. resp, _ := client.Do(req)
  38296. defer resp.Body.Close()
  38297. body, ioErr := ioutil.ReadAll(resp.Body)
  38298. if ioErr != nil {
  38299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38301. return
  38302. }
  38303. var respJSON map[string]interface{}
  38304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38307. return
  38308. }
  38309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38310. userJSONBytes, _ := json.Marshal(respJSON)
  38311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38312. utils.ErrorLog("解析失败:%v", err)
  38313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38314. return
  38315. }
  38316. }
  38317. if miConfig.MdtrtareaAdmvs == "421182" {
  38318. client := &http.Client{}
  38319. bytesData, _ := json.Marshal(data)
  38320. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38321. resp, _ := client.Do(req)
  38322. defer resp.Body.Close()
  38323. body, ioErr := ioutil.ReadAll(resp.Body)
  38324. if ioErr != nil {
  38325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38327. return
  38328. }
  38329. var respJSON map[string]interface{}
  38330. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38333. return
  38334. }
  38335. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38336. userJSONBytes, _ := json.Marshal(respJSON)
  38337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38338. utils.ErrorLog("解析失败:%v", err)
  38339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38340. return
  38341. }
  38342. }
  38343. if res.Infcode == 0 {
  38344. c.ServeSuccessJSON(map[string]interface{}{
  38345. "msg": "发起成功",
  38346. })
  38347. } else {
  38348. c.ServeSuccessJSON(map[string]interface{}{
  38349. "failed_code": -10,
  38350. "msg": res.ErrMsg,
  38351. })
  38352. }
  38353. }
  38354. }
  38355. func (c *HisApiController) Post1608() {
  38356. start_time := c.GetString("start_time")
  38357. end_time := c.GetString("end_time")
  38358. admin_user_id, _ := c.GetInt64("admin_user_id")
  38359. adminUser := c.GetAdminUserInfo()
  38360. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38361. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38362. timeLayout := "2006-01-02"
  38363. loc, _ := time.LoadLocation("Local")
  38364. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38365. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38366. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38367. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38368. fixmedins_setl_cnt := int64(len(orders))
  38369. var medfee_sumamt float64
  38370. var func_smamt float64
  38371. for _, item := range orders {
  38372. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38373. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38374. }
  38375. times := strings.Split(start_time, "-")
  38376. time_tows := strings.Split(end_time, "-")
  38377. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38378. var res ResultSix
  38379. if config.IsOpen == 1 {
  38380. //var bps []*models.BusinessParamsTwo
  38381. //var bp models.BusinessParamsTwo
  38382. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38383. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38384. data := make(map[string]interface{})
  38385. data["org_name"] = miConfig.OrgName
  38386. data["doctor"] = role.UserName
  38387. data["func_smamt"] = func_smamt_str
  38388. data["fixmedins_code"] = miConfig.Code
  38389. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38390. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38391. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38392. data["medfee_sumamt"] = medfee_sumamt_str
  38393. data["start_time"] = times[0] + times[1] + times[2]
  38394. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38395. if miConfig.MdtrtareaAdmvs == "421300" {
  38396. client := &http.Client{}
  38397. bytesData, _ := json.Marshal(data)
  38398. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38399. resp, _ := client.Do(req)
  38400. defer resp.Body.Close()
  38401. body, ioErr := ioutil.ReadAll(resp.Body)
  38402. if ioErr != nil {
  38403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38405. return
  38406. }
  38407. var respJSON map[string]interface{}
  38408. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38411. return
  38412. }
  38413. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38414. userJSONBytes, _ := json.Marshal(respJSON)
  38415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38416. utils.ErrorLog("解析失败:%v", err)
  38417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38418. return
  38419. }
  38420. }
  38421. if miConfig.MdtrtareaAdmvs == "420200" {
  38422. client := &http.Client{}
  38423. bytesData, _ := json.Marshal(data)
  38424. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38425. resp, _ := client.Do(req)
  38426. defer resp.Body.Close()
  38427. body, ioErr := ioutil.ReadAll(resp.Body)
  38428. if ioErr != nil {
  38429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38431. return
  38432. }
  38433. var respJSON map[string]interface{}
  38434. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38437. return
  38438. }
  38439. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38440. userJSONBytes, _ := json.Marshal(respJSON)
  38441. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38442. utils.ErrorLog("解析失败:%v", err)
  38443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38444. return
  38445. }
  38446. }
  38447. if miConfig.MdtrtareaAdmvs == "421182" {
  38448. client := &http.Client{}
  38449. bytesData, _ := json.Marshal(data)
  38450. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38451. resp, _ := client.Do(req)
  38452. defer resp.Body.Close()
  38453. body, ioErr := ioutil.ReadAll(resp.Body)
  38454. if ioErr != nil {
  38455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38457. return
  38458. }
  38459. var respJSON map[string]interface{}
  38460. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38463. return
  38464. }
  38465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38466. userJSONBytes, _ := json.Marshal(respJSON)
  38467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38468. utils.ErrorLog("解析失败:%v", err)
  38469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38470. return
  38471. }
  38472. }
  38473. if res.Infcode == 0 {
  38474. c.ServeSuccessJSON(map[string]interface{}{
  38475. "msg": "发起成功",
  38476. })
  38477. } else {
  38478. c.ServeSuccessJSON(map[string]interface{}{
  38479. "failed_code": -10,
  38480. "msg": res.ErrMsg,
  38481. })
  38482. }
  38483. }
  38484. }
  38485. // 5.11.1.1【5262】结算信息按时间段查询
  38486. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38487. admin_user_id, _ := c.GetInt64("admin_user_id")
  38488. adminUser := c.GetAdminUserInfo()
  38489. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38490. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38491. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38492. var res Result5262
  38493. if config.IsOpen == 1 {
  38494. if miConfig.MdtrtareaAdmvs == "421300" {
  38495. data := make(map[string]interface{})
  38496. data["bps"] = bp
  38497. data["org_name"] = miConfig.OrgName
  38498. data["doctor"] = role.UserName
  38499. data["fixmedins_code"] = miConfig.Code
  38500. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38501. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38502. data["page"] = strconv.FormatInt(page, 10)
  38503. data["limit"] = strconv.FormatInt(limit, 10)
  38504. fmt.Println(data)
  38505. client := &http.Client{}
  38506. bytesData, _ := json.Marshal(data)
  38507. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38508. resp, _ := client.Do(req)
  38509. defer resp.Body.Close()
  38510. body, ioErr := ioutil.ReadAll(resp.Body)
  38511. if ioErr != nil {
  38512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38514. return
  38515. }
  38516. var respJSON map[string]interface{}
  38517. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38520. return
  38521. }
  38522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38523. userJSONBytes, _ := json.Marshal(respJSON)
  38524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38525. utils.ErrorLog("解析失败:%v", err)
  38526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38527. return
  38528. }
  38529. }
  38530. if miConfig.MdtrtareaAdmvs == "420200" {
  38531. data := make(map[string]interface{})
  38532. data["bps"] = bp
  38533. data["org_name"] = miConfig.OrgName
  38534. data["doctor"] = role.UserName
  38535. data["fixmedins_code"] = miConfig.Code
  38536. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38537. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38538. data["page"] = strconv.FormatInt(page, 10)
  38539. data["limit"] = strconv.FormatInt(limit, 10)
  38540. fmt.Println(data)
  38541. client := &http.Client{}
  38542. bytesData, _ := json.Marshal(data)
  38543. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38544. resp, _ := client.Do(req)
  38545. defer resp.Body.Close()
  38546. body, ioErr := ioutil.ReadAll(resp.Body)
  38547. if ioErr != nil {
  38548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38550. return
  38551. }
  38552. var respJSON map[string]interface{}
  38553. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38556. return
  38557. }
  38558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38559. userJSONBytes, _ := json.Marshal(respJSON)
  38560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38561. utils.ErrorLog("解析失败:%v", err)
  38562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38563. return
  38564. }
  38565. }
  38566. if miConfig.MdtrtareaAdmvs == "421182" {
  38567. data := make(map[string]interface{})
  38568. data["bps"] = bp
  38569. data["org_name"] = miConfig.OrgName
  38570. data["doctor"] = role.UserName
  38571. data["fixmedins_code"] = miConfig.Code
  38572. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38573. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38574. data["page"] = strconv.FormatInt(page, 10)
  38575. data["limit"] = strconv.FormatInt(limit, 10)
  38576. fmt.Println(data)
  38577. client := &http.Client{}
  38578. bytesData, _ := json.Marshal(data)
  38579. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38580. resp, _ := client.Do(req)
  38581. defer resp.Body.Close()
  38582. body, ioErr := ioutil.ReadAll(resp.Body)
  38583. if ioErr != nil {
  38584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38586. return
  38587. }
  38588. var respJSON map[string]interface{}
  38589. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38592. return
  38593. }
  38594. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38595. userJSONBytes, _ := json.Marshal(respJSON)
  38596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38597. utils.ErrorLog("解析失败:%v", err)
  38598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38599. return
  38600. }
  38601. }
  38602. if miConfig.MdtrtareaAdmvs == "420902" {
  38603. data := make(map[string]interface{})
  38604. data["bps"] = bp
  38605. data["org_name"] = miConfig.OrgName
  38606. data["doctor"] = role.UserName
  38607. data["fixmedins_code"] = miConfig.Code
  38608. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38609. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38610. data["page"] = strconv.FormatInt(page, 10)
  38611. data["limit"] = strconv.FormatInt(limit, 10)
  38612. fmt.Println(data)
  38613. client := &http.Client{}
  38614. bytesData, _ := json.Marshal(data)
  38615. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38616. resp, _ := client.Do(req)
  38617. defer resp.Body.Close()
  38618. body, ioErr := ioutil.ReadAll(resp.Body)
  38619. if ioErr != nil {
  38620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38622. return
  38623. }
  38624. var respJSON map[string]interface{}
  38625. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38628. return
  38629. }
  38630. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38631. userJSONBytes, _ := json.Marshal(respJSON)
  38632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38633. utils.ErrorLog("解析失败:%v", err)
  38634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38635. return
  38636. }
  38637. }
  38638. if res.Infcode == 0 {
  38639. c.ServeSuccessJSON(map[string]interface{}{
  38640. "order": res.Output.Result,
  38641. "total": res.Output.PageInfo.RecordCounts,
  38642. })
  38643. } else {
  38644. c.ServeSuccessJSON(map[string]interface{}{
  38645. "failed_code": -10,
  38646. "msg": res.ErrMsg,
  38647. })
  38648. }
  38649. }
  38650. }
  38651. // 5.11.1.2【5267】异地结算信息时间段查询
  38652. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38653. admin_user_id, _ := c.GetInt64("admin_user_id")
  38654. adminUser := c.GetAdminUserInfo()
  38655. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38656. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38657. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38658. var res Result5267
  38659. if config.IsOpen == 1 {
  38660. if miConfig.MdtrtareaAdmvs == "421300" {
  38661. data := make(map[string]interface{})
  38662. data["bps"] = bp
  38663. data["org_name"] = miConfig.OrgName
  38664. data["doctor"] = role.UserName
  38665. data["fixmedins_code"] = miConfig.Code
  38666. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38667. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38668. data["page"] = page
  38669. data["limit"] = limit
  38670. fmt.Println(data)
  38671. client := &http.Client{}
  38672. bytesData, _ := json.Marshal(data)
  38673. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38674. resp, _ := client.Do(req)
  38675. defer resp.Body.Close()
  38676. body, ioErr := ioutil.ReadAll(resp.Body)
  38677. if ioErr != nil {
  38678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38680. return
  38681. }
  38682. var respJSON map[string]interface{}
  38683. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38686. return
  38687. }
  38688. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38689. userJSONBytes, _ := json.Marshal(respJSON)
  38690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38691. utils.ErrorLog("解析失败:%v", err)
  38692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38693. return
  38694. }
  38695. }
  38696. if miConfig.MdtrtareaAdmvs == "420200" {
  38697. data := make(map[string]interface{})
  38698. data["bps"] = bp
  38699. data["org_name"] = miConfig.OrgName
  38700. data["doctor"] = role.UserName
  38701. data["fixmedins_code"] = miConfig.Code
  38702. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38703. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38704. data["page"] = page
  38705. data["limit"] = limit
  38706. fmt.Println(data)
  38707. client := &http.Client{}
  38708. bytesData, _ := json.Marshal(data)
  38709. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38710. resp, _ := client.Do(req)
  38711. defer resp.Body.Close()
  38712. body, ioErr := ioutil.ReadAll(resp.Body)
  38713. if ioErr != nil {
  38714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38716. return
  38717. }
  38718. var respJSON map[string]interface{}
  38719. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38722. return
  38723. }
  38724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38725. userJSONBytes, _ := json.Marshal(respJSON)
  38726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38727. utils.ErrorLog("解析失败:%v", err)
  38728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38729. return
  38730. }
  38731. }
  38732. if miConfig.MdtrtareaAdmvs == "421182" {
  38733. data := make(map[string]interface{})
  38734. data["bps"] = bp
  38735. data["org_name"] = miConfig.OrgName
  38736. data["doctor"] = role.UserName
  38737. data["fixmedins_code"] = miConfig.Code
  38738. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38739. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38740. data["page"] = page
  38741. data["limit"] = limit
  38742. fmt.Println(data)
  38743. client := &http.Client{}
  38744. bytesData, _ := json.Marshal(data)
  38745. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38746. resp, _ := client.Do(req)
  38747. defer resp.Body.Close()
  38748. body, ioErr := ioutil.ReadAll(resp.Body)
  38749. if ioErr != nil {
  38750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38752. return
  38753. }
  38754. var respJSON map[string]interface{}
  38755. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38758. return
  38759. }
  38760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38761. userJSONBytes, _ := json.Marshal(respJSON)
  38762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38763. utils.ErrorLog("解析失败:%v", err)
  38764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38765. return
  38766. }
  38767. }
  38768. if res.Infcode == 0 {
  38769. c.ServeSuccessJSON(map[string]interface{}{
  38770. "order": res.Output.Result,
  38771. "total": res.Output.PageInfo.RecordCounts,
  38772. })
  38773. } else {
  38774. c.ServeSuccessJSON(map[string]interface{}{
  38775. "failed_code": -10,
  38776. "msg": res.ErrMsg,
  38777. })
  38778. }
  38779. }
  38780. }
  38781. func (c *HisApiController) Post3501() {
  38782. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38783. data := make(map[string]interface{})
  38784. var struct3501s []models.Struct3501
  38785. var struct3501 models.Struct3501
  38786. struct3501.OrgName = miConfig.OrgName
  38787. struct3501.AccessKey = miConfig.AccessKey
  38788. struct3501.RequestUrl = miConfig.Url
  38789. struct3501.SecretKey = miConfig.SecretKey
  38790. struct3501.ManuDate = "2022-08-17"
  38791. struct3501.FixmedinsBchno = ""
  38792. struct3501.ManuLotnum = ""
  38793. struct3501.RxFlag = "0"
  38794. struct3501.ExpyEnd = "2022-08-17"
  38795. struct3501.Invdate = "2022-08-17"
  38796. struct3501.InvCnt = "20.25"
  38797. struct3501.Memo = ""
  38798. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38799. struct3501.FixmedinsHilistId = miConfig.Code
  38800. struct3501.FixmedinsHilistName = miConfig.OrgName
  38801. struct3501s = append(struct3501s, struct3501)
  38802. data["struct_3501s"] = struct3501s
  38803. client := &http.Client{}
  38804. bytesData, _ := json.Marshal(data)
  38805. var req *http.Request
  38806. if miConfig.MdtrtareaAdmvs == "320921" {
  38807. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38808. } else {
  38809. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38810. }
  38811. resp, _ := client.Do(req)
  38812. defer resp.Body.Close()
  38813. body, ioErr := ioutil.ReadAll(resp.Body)
  38814. if ioErr != nil {
  38815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38817. return
  38818. }
  38819. var respJSON map[string]interface{}
  38820. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38823. return
  38824. }
  38825. var res ResultSix
  38826. var resSix10265 ResultSix10265 //1101结果
  38827. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38828. result, _ := json.Marshal(respJSON)
  38829. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38830. utils.ErrorLog("解析失败:%v", err)
  38831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38832. return
  38833. }
  38834. res.InfRefmsgid = resSix10265.InfRefmsgid
  38835. res.Output = resSix10265.Output
  38836. res.ErrMsg = resSix10265.ErrMsg
  38837. res.Cainfo = resSix10265.Cainfo
  38838. res.WarnMsg = resSix10265.WarnMsg
  38839. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38840. res.Infcode = infocode
  38841. if infocode == 0 {
  38842. c.ServeSuccessJSON(map[string]interface{}{
  38843. "msg": "上传成功",
  38844. })
  38845. return
  38846. } else {
  38847. c.ServeSuccessJSON(map[string]interface{}{
  38848. "failed_code": -10,
  38849. "msg": res.ErrMsg,
  38850. })
  38851. return
  38852. }
  38853. }
  38854. func (c *HisApiController) Post3502() {
  38855. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38856. data := make(map[string]interface{})
  38857. var struct3502s []models.Struct3502
  38858. var struct3502 models.Struct3502
  38859. struct3502.OrgName = miConfig.OrgName
  38860. struct3502.AccessKey = miConfig.AccessKey
  38861. struct3502.RequestUrl = miConfig.Url
  38862. struct3502.SecretKey = miConfig.SecretKey
  38863. struct3502.ManuDate = "2022-08-15"
  38864. struct3502.FixmedinsBchno = ""
  38865. struct3502.ManuLotnum = ""
  38866. struct3502.RxFlag = "0"
  38867. struct3502.ExpyEnd = "2022-08-15"
  38868. struct3502.Invdate = "2022-08-15"
  38869. struct3502.InvCnt = "20.25"
  38870. struct3502.Memo = ""
  38871. struct3502.MedListCodg = "XB01ABD056B002020200517"
  38872. struct3502.FixmedinsHilistId = miConfig.Code
  38873. struct3502.FixmedinsHilistName = miConfig.OrgName
  38874. struct3502s = append(struct3502s, struct3502)
  38875. data["struct_3502s"] = struct3502s
  38876. client := &http.Client{}
  38877. bytesData, _ := json.Marshal(data)
  38878. var req *http.Request
  38879. if miConfig.MdtrtareaAdmvs == "320921" {
  38880. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38881. } else {
  38882. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38883. }
  38884. resp, _ := client.Do(req)
  38885. defer resp.Body.Close()
  38886. body, ioErr := ioutil.ReadAll(resp.Body)
  38887. if ioErr != nil {
  38888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38890. return
  38891. }
  38892. var respJSON map[string]interface{}
  38893. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38896. return
  38897. }
  38898. var res ResultSix
  38899. var resSix10265 ResultSix10265 //1101结果
  38900. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38901. result, _ := json.Marshal(respJSON)
  38902. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38903. utils.ErrorLog("解析失败:%v", err)
  38904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38905. return
  38906. }
  38907. res.InfRefmsgid = resSix10265.InfRefmsgid
  38908. res.Output = resSix10265.Output
  38909. res.ErrMsg = resSix10265.ErrMsg
  38910. res.Cainfo = resSix10265.Cainfo
  38911. res.WarnMsg = resSix10265.WarnMsg
  38912. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38913. res.Infcode = infocode
  38914. if infocode == 0 {
  38915. c.ServeSuccessJSON(map[string]interface{}{
  38916. "msg": "上传成功",
  38917. })
  38918. return
  38919. } else {
  38920. c.ServeSuccessJSON(map[string]interface{}{
  38921. "failed_code": -10,
  38922. "msg": res.ErrMsg,
  38923. })
  38924. return
  38925. }
  38926. }
  38927. func (c *HisApiController) Post3503() {
  38928. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38929. data := make(map[string]interface{})
  38930. var struct3501s []models.Struct3501
  38931. var struct3501 models.Struct3501
  38932. struct3501.OrgName = miConfig.OrgName
  38933. struct3501.AccessKey = miConfig.AccessKey
  38934. struct3501.RequestUrl = miConfig.Url
  38935. struct3501.SecretKey = miConfig.SecretKey
  38936. struct3501.ManuDate = "2022-08-15"
  38937. struct3501.FixmedinsBchno = ""
  38938. struct3501.ManuLotnum = ""
  38939. struct3501.RxFlag = "0"
  38940. struct3501.ExpyEnd = "2022-08-15"
  38941. struct3501.Invdate = "2022-08-15"
  38942. struct3501.InvCnt = "20.25"
  38943. struct3501.Memo = ""
  38944. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38945. struct3501.FixmedinsHilistId = miConfig.Code
  38946. struct3501.FixmedinsHilistName = miConfig.OrgName
  38947. struct3501s = append(struct3501s, struct3501)
  38948. data["struct_3501s"] = struct3501s
  38949. client := &http.Client{}
  38950. bytesData, _ := json.Marshal(data)
  38951. var req *http.Request
  38952. if miConfig.MdtrtareaAdmvs == "320921" {
  38953. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38954. } else {
  38955. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38956. }
  38957. resp, _ := client.Do(req)
  38958. defer resp.Body.Close()
  38959. body, ioErr := ioutil.ReadAll(resp.Body)
  38960. if ioErr != nil {
  38961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38963. return
  38964. }
  38965. var respJSON map[string]interface{}
  38966. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38969. return
  38970. }
  38971. var res ResultSix
  38972. var resSix10265 ResultSix10265 //1101结果
  38973. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38974. result, _ := json.Marshal(respJSON)
  38975. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38976. utils.ErrorLog("解析失败:%v", err)
  38977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38978. return
  38979. }
  38980. res.InfRefmsgid = resSix10265.InfRefmsgid
  38981. res.Output = resSix10265.Output
  38982. res.ErrMsg = resSix10265.ErrMsg
  38983. res.Cainfo = resSix10265.Cainfo
  38984. res.WarnMsg = resSix10265.WarnMsg
  38985. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38986. res.Infcode = infocode
  38987. if infocode == 0 {
  38988. c.ServeSuccessJSON(map[string]interface{}{
  38989. "msg": "上传成功",
  38990. })
  38991. return
  38992. } else {
  38993. c.ServeSuccessJSON(map[string]interface{}{
  38994. "failed_code": -10,
  38995. "msg": res.ErrMsg,
  38996. })
  38997. return
  38998. }
  38999. }
  39000. func (c *HisApiController) Post3504() {
  39001. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39002. data := make(map[string]interface{})
  39003. var struct3501s []models.Struct3501
  39004. var struct3501 models.Struct3501
  39005. struct3501.OrgName = miConfig.OrgName
  39006. struct3501.AccessKey = miConfig.AccessKey
  39007. struct3501.RequestUrl = miConfig.Url
  39008. struct3501.SecretKey = miConfig.SecretKey
  39009. struct3501.ManuDate = "2022-08-15"
  39010. struct3501.FixmedinsBchno = ""
  39011. struct3501.ManuLotnum = ""
  39012. struct3501.RxFlag = "0"
  39013. struct3501.ExpyEnd = "2022-08-15"
  39014. struct3501.Invdate = "2022-08-15"
  39015. struct3501.InvCnt = "20.25"
  39016. struct3501.Memo = ""
  39017. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39018. struct3501.FixmedinsHilistId = miConfig.Code
  39019. struct3501.FixmedinsHilistName = miConfig.OrgName
  39020. struct3501s = append(struct3501s, struct3501)
  39021. data["struct_3501s"] = struct3501s
  39022. client := &http.Client{}
  39023. bytesData, _ := json.Marshal(data)
  39024. var req *http.Request
  39025. if miConfig.MdtrtareaAdmvs == "320921" {
  39026. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39027. } else {
  39028. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39029. }
  39030. resp, _ := client.Do(req)
  39031. defer resp.Body.Close()
  39032. body, ioErr := ioutil.ReadAll(resp.Body)
  39033. if ioErr != nil {
  39034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39036. return
  39037. }
  39038. var respJSON map[string]interface{}
  39039. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39042. return
  39043. }
  39044. var res ResultSix
  39045. var resSix10265 ResultSix10265 //1101结果
  39046. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39047. result, _ := json.Marshal(respJSON)
  39048. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39049. utils.ErrorLog("解析失败:%v", err)
  39050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39051. return
  39052. }
  39053. res.InfRefmsgid = resSix10265.InfRefmsgid
  39054. res.Output = resSix10265.Output
  39055. res.ErrMsg = resSix10265.ErrMsg
  39056. res.Cainfo = resSix10265.Cainfo
  39057. res.WarnMsg = resSix10265.WarnMsg
  39058. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39059. res.Infcode = infocode
  39060. if infocode == 0 {
  39061. c.ServeSuccessJSON(map[string]interface{}{
  39062. "msg": "上传成功",
  39063. })
  39064. return
  39065. } else {
  39066. c.ServeSuccessJSON(map[string]interface{}{
  39067. "failed_code": -10,
  39068. "msg": res.ErrMsg,
  39069. })
  39070. return
  39071. }
  39072. }
  39073. func (c *HisApiController) Post3505() {
  39074. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39075. data := make(map[string]interface{})
  39076. var struct3501s []models.Struct3501
  39077. var struct3501 models.Struct3501
  39078. struct3501.OrgName = miConfig.OrgName
  39079. struct3501.AccessKey = miConfig.AccessKey
  39080. struct3501.RequestUrl = miConfig.Url
  39081. struct3501.SecretKey = miConfig.SecretKey
  39082. struct3501.ManuDate = "2022-08-15"
  39083. struct3501.FixmedinsBchno = ""
  39084. struct3501.ManuLotnum = ""
  39085. struct3501.RxFlag = "0"
  39086. struct3501.ExpyEnd = "2022-08-15"
  39087. struct3501.Invdate = "2022-08-15"
  39088. struct3501.InvCnt = "20.25"
  39089. struct3501.Memo = ""
  39090. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39091. struct3501.FixmedinsHilistId = miConfig.Code
  39092. struct3501.FixmedinsHilistName = miConfig.OrgName
  39093. struct3501s = append(struct3501s, struct3501)
  39094. data["struct_3501s"] = struct3501s
  39095. client := &http.Client{}
  39096. bytesData, _ := json.Marshal(data)
  39097. var req *http.Request
  39098. if miConfig.MdtrtareaAdmvs == "320921" {
  39099. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39100. } else {
  39101. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39102. }
  39103. resp, _ := client.Do(req)
  39104. defer resp.Body.Close()
  39105. body, ioErr := ioutil.ReadAll(resp.Body)
  39106. if ioErr != nil {
  39107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39109. return
  39110. }
  39111. var respJSON map[string]interface{}
  39112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39115. return
  39116. }
  39117. var res ResultSix
  39118. var resSix10265 ResultSix10265 //1101结果
  39119. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39120. result, _ := json.Marshal(respJSON)
  39121. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39122. utils.ErrorLog("解析失败:%v", err)
  39123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39124. return
  39125. }
  39126. res.InfRefmsgid = resSix10265.InfRefmsgid
  39127. res.Output = resSix10265.Output
  39128. res.ErrMsg = resSix10265.ErrMsg
  39129. res.Cainfo = resSix10265.Cainfo
  39130. res.WarnMsg = resSix10265.WarnMsg
  39131. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39132. res.Infcode = infocode
  39133. if infocode == 0 {
  39134. c.ServeSuccessJSON(map[string]interface{}{
  39135. "msg": "上传成功",
  39136. })
  39137. return
  39138. } else {
  39139. c.ServeSuccessJSON(map[string]interface{}{
  39140. "failed_code": -10,
  39141. "msg": res.ErrMsg,
  39142. })
  39143. return
  39144. }
  39145. }
  39146. func (c *HisApiController) Post3506() {
  39147. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39148. data := make(map[string]interface{})
  39149. var struct3501s []models.Struct3501
  39150. var struct3501 models.Struct3501
  39151. struct3501.OrgName = miConfig.OrgName
  39152. struct3501.AccessKey = miConfig.AccessKey
  39153. struct3501.RequestUrl = miConfig.Url
  39154. struct3501.SecretKey = miConfig.SecretKey
  39155. struct3501.ManuDate = "2022-08-15"
  39156. struct3501.FixmedinsBchno = ""
  39157. struct3501.ManuLotnum = ""
  39158. struct3501.RxFlag = "0"
  39159. struct3501.ExpyEnd = "2022-08-15"
  39160. struct3501.Invdate = "2022-08-15"
  39161. struct3501.InvCnt = "20.25"
  39162. struct3501.Memo = ""
  39163. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39164. struct3501.FixmedinsHilistId = miConfig.Code
  39165. struct3501.FixmedinsHilistName = miConfig.OrgName
  39166. struct3501s = append(struct3501s, struct3501)
  39167. data["struct_3501s"] = struct3501s
  39168. client := &http.Client{}
  39169. bytesData, _ := json.Marshal(data)
  39170. var req *http.Request
  39171. if miConfig.MdtrtareaAdmvs == "320921" {
  39172. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39173. } else {
  39174. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39175. }
  39176. resp, _ := client.Do(req)
  39177. defer resp.Body.Close()
  39178. body, ioErr := ioutil.ReadAll(resp.Body)
  39179. if ioErr != nil {
  39180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39182. return
  39183. }
  39184. var respJSON map[string]interface{}
  39185. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39188. return
  39189. }
  39190. var res ResultSix
  39191. var resSix10265 ResultSix10265 //1101结果
  39192. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39193. result, _ := json.Marshal(respJSON)
  39194. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39195. utils.ErrorLog("解析失败:%v", err)
  39196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39197. return
  39198. }
  39199. res.InfRefmsgid = resSix10265.InfRefmsgid
  39200. res.Output = resSix10265.Output
  39201. res.ErrMsg = resSix10265.ErrMsg
  39202. res.Cainfo = resSix10265.Cainfo
  39203. res.WarnMsg = resSix10265.WarnMsg
  39204. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39205. res.Infcode = infocode
  39206. if infocode == 0 {
  39207. c.ServeSuccessJSON(map[string]interface{}{
  39208. "msg": "上传成功",
  39209. })
  39210. return
  39211. } else {
  39212. c.ServeSuccessJSON(map[string]interface{}{
  39213. "failed_code": -10,
  39214. "msg": res.ErrMsg,
  39215. })
  39216. return
  39217. }
  39218. }
  39219. func (c *HisApiController) Post3507() {
  39220. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39221. data := make(map[string]interface{})
  39222. var struct3501s []models.Struct3501
  39223. var struct3501 models.Struct3501
  39224. struct3501.OrgName = miConfig.OrgName
  39225. struct3501.AccessKey = miConfig.AccessKey
  39226. struct3501.RequestUrl = miConfig.Url
  39227. struct3501.SecretKey = miConfig.SecretKey
  39228. struct3501.ManuDate = "2022-08-15"
  39229. struct3501.FixmedinsBchno = ""
  39230. struct3501.ManuLotnum = ""
  39231. struct3501.RxFlag = "0"
  39232. struct3501.ExpyEnd = "2022-08-15"
  39233. struct3501.Invdate = "2022-08-15"
  39234. struct3501.InvCnt = "20.25"
  39235. struct3501.Memo = ""
  39236. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39237. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39238. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39239. struct3501s = append(struct3501s, struct3501)
  39240. data["struct_3501s"] = struct3501s
  39241. client := &http.Client{}
  39242. bytesData, _ := json.Marshal(data)
  39243. var req *http.Request
  39244. if miConfig.MdtrtareaAdmvs == "320921" {
  39245. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39246. } else {
  39247. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39248. }
  39249. resp, _ := client.Do(req)
  39250. defer resp.Body.Close()
  39251. body, ioErr := ioutil.ReadAll(resp.Body)
  39252. if ioErr != nil {
  39253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39255. return
  39256. }
  39257. var respJSON map[string]interface{}
  39258. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39261. return
  39262. }
  39263. var res ResultSix
  39264. var resSix10265 ResultSix10265 //1101结果
  39265. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39266. result, _ := json.Marshal(respJSON)
  39267. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39268. utils.ErrorLog("解析失败:%v", err)
  39269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39270. return
  39271. }
  39272. res.InfRefmsgid = resSix10265.InfRefmsgid
  39273. res.Output = resSix10265.Output
  39274. res.ErrMsg = resSix10265.ErrMsg
  39275. res.Cainfo = resSix10265.Cainfo
  39276. res.WarnMsg = resSix10265.WarnMsg
  39277. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39278. res.Infcode = infocode
  39279. if infocode == 0 {
  39280. c.ServeSuccessJSON(map[string]interface{}{
  39281. "msg": "上传成功",
  39282. })
  39283. return
  39284. } else {
  39285. c.ServeSuccessJSON(map[string]interface{}{
  39286. "failed_code": -10,
  39287. "msg": res.ErrMsg,
  39288. })
  39289. return
  39290. }
  39291. }
  39292. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39293. // WebSocket服务器地址
  39294. serverURL := "ws://127.0.0.1:8899"
  39295. // 解析WebSocket服务器地址
  39296. u, err := url.Parse(serverURL)
  39297. if err != nil {
  39298. }
  39299. // 建立WebSocket连接
  39300. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39301. if err != nil {
  39302. }
  39303. defer conn.Close()
  39304. input2 := make(map[string]interface{})
  39305. input := make(map[string]interface{})
  39306. inputData := make(map[string]interface{})
  39307. inputData["orgId"] = code
  39308. inputData["businessType"] = "01101"
  39309. inputData["operatorId"] = operator_id
  39310. inputData["operatorName"] = operator_name
  39311. inputData["officeId"] = "001"
  39312. inputData["officeName"] = "血透室"
  39313. inputData["deviceType"] = ""
  39314. input["data"] = inputData
  39315. input["orgId"] = code
  39316. input["transType"] = "ec.query"
  39317. //if md == ""
  39318. if md[:4] == "4403" {
  39319. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39320. } else if md[:4] == "4401" {
  39321. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39322. } else {
  39323. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39324. }
  39325. input2["indata"] = input
  39326. fmt.Println(input2)
  39327. bytesData, _ := json.Marshal(input2)
  39328. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39329. if err != nil {
  39330. fmt.Println(err)
  39331. }
  39332. // 接收消息
  39333. _, receivedMessage, err := conn.ReadMessage()
  39334. if err != nil {
  39335. fmt.Println(err)
  39336. }
  39337. return "", string(receivedMessage)
  39338. }
  39339. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39340. // WebSocket服务器地址
  39341. serverURL := "ws://127.0.0.1:8899"
  39342. // 解析WebSocket服务器地址
  39343. u, err := url.Parse(serverURL)
  39344. if err != nil {
  39345. }
  39346. // 建立WebSocket连接
  39347. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39348. if err != nil {
  39349. }
  39350. defer conn.Close()
  39351. input2 := make(map[string]interface{})
  39352. input := make(map[string]interface{})
  39353. inputData := make(map[string]interface{})
  39354. inputData["orgId"] = code
  39355. inputData["businessType"] = "01101"
  39356. inputData["operatorId"] = operator_id
  39357. inputData["operatorName"] = operator_name
  39358. inputData["officeId"] = "001"
  39359. inputData["officeName"] = "血透室"
  39360. inputData["deviceType"] = ""
  39361. input["data"] = inputData
  39362. input["orgId"] = code
  39363. input["transType"] = "ec.query"
  39364. //if md == ""
  39365. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39366. input2["indata"] = input
  39367. fmt.Println(input2)
  39368. bytesData, _ := json.Marshal(input2)
  39369. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39370. if err != nil {
  39371. fmt.Println(err)
  39372. }
  39373. // 接收消息
  39374. _, receivedMessage, err := conn.ReadMessage()
  39375. if err != nil {
  39376. fmt.Println(err)
  39377. }
  39378. return "", string(receivedMessage)
  39379. }
  39380. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39381. // WebSocket服务器地址
  39382. serverURL := "ws://127.0.0.1:8899"
  39383. // 解析WebSocket服务器地址
  39384. u, err := url.Parse(serverURL)
  39385. if err != nil {
  39386. }
  39387. // 建立WebSocket连接
  39388. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39389. if err != nil {
  39390. }
  39391. defer conn.Close()
  39392. input2 := make(map[string]interface{})
  39393. input := make(map[string]interface{})
  39394. inputData := make(map[string]interface{})
  39395. inputData["orgId"] = code
  39396. inputData["businessType"] = "01301"
  39397. inputData["operatorId"] = operator_id
  39398. inputData["operatorName"] = operator_name
  39399. inputData["officeId"] = "001"
  39400. inputData["officeName"] = "血透室"
  39401. inputData["deviceType"] = ""
  39402. input["data"] = inputData
  39403. input["orgId"] = code
  39404. input["transType"] = "ec.query"
  39405. //if md == ""
  39406. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39407. input2["indata"] = input
  39408. fmt.Println(input2)
  39409. bytesData, _ := json.Marshal(input2)
  39410. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39411. if err != nil {
  39412. fmt.Println(err)
  39413. }
  39414. // 接收消息
  39415. _, receivedMessage, err := conn.ReadMessage()
  39416. if err != nil {
  39417. fmt.Println(err)
  39418. }
  39419. return "", string(receivedMessage)
  39420. }
  39421. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39422. // WebSocket服务器地址
  39423. serverURL := "ws://127.0.0.1:8899"
  39424. // 解析WebSocket服务器地址
  39425. u, err := url.Parse(serverURL)
  39426. if err != nil {
  39427. }
  39428. // 建立WebSocket连接
  39429. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39430. if err != nil {
  39431. }
  39432. defer conn.Close()
  39433. input2 := make(map[string]interface{})
  39434. input := make(map[string]interface{})
  39435. inputData := make(map[string]interface{})
  39436. inputData["orgId"] = code
  39437. inputData["businessType"] = "01103"
  39438. inputData["operatorId"] = operator_id
  39439. inputData["operatorName"] = operator_name
  39440. inputData["officeId"] = "001"
  39441. inputData["officeName"] = "血透室"
  39442. inputData["deviceType"] = ""
  39443. input["data"] = inputData
  39444. input["orgId"] = code
  39445. input["transType"] = "ec.query"
  39446. //if md ==
  39447. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39448. input2["indata"] = input
  39449. fmt.Println(input2)
  39450. bytesData, _ := json.Marshal(input2)
  39451. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39452. if err != nil {
  39453. fmt.Println(err)
  39454. }
  39455. // 接收消息
  39456. _, receivedMessage, err := conn.ReadMessage()
  39457. if err != nil {
  39458. fmt.Println(err)
  39459. }
  39460. return "", string(receivedMessage)
  39461. }
  39462. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39463. // WebSocket服务器地址
  39464. serverURL := "ws://127.0.0.1:8899"
  39465. // 解析WebSocket服务器地址
  39466. u, err := url.Parse(serverURL)
  39467. if err != nil {
  39468. }
  39469. // 建立WebSocket连接
  39470. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39471. if err != nil {
  39472. }
  39473. defer conn.Close()
  39474. input2 := make(map[string]interface{})
  39475. input := make(map[string]interface{})
  39476. inputData := make(map[string]interface{})
  39477. inputData["orgId"] = code
  39478. inputData["businessType"] = "01101"
  39479. inputData["operatorId"] = operator_id
  39480. inputData["operatorName"] = operator_name
  39481. inputData["officeId"] = "001"
  39482. inputData["officeName"] = "血透室"
  39483. inputData["deviceType"] = ""
  39484. input["data"] = inputData
  39485. input["orgId"] = code
  39486. input["transType"] = "ec.query"
  39487. //if md == ""
  39488. if md[:4] == "4403" {
  39489. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39490. } else if md[:4] == "4401" {
  39491. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39492. } else {
  39493. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39494. }
  39495. input2["indata"] = input
  39496. fmt.Println(input2)
  39497. bytesData, _ := json.Marshal(input2)
  39498. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39499. if err != nil {
  39500. fmt.Println(err)
  39501. }
  39502. // 接收消息
  39503. _, receivedMessage, err := conn.ReadMessage()
  39504. if err != nil {
  39505. fmt.Println(err)
  39506. }
  39507. return "", string(receivedMessage)
  39508. }
  39509. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39510. // WebSocket服务器地址
  39511. serverURL := "ws://127.0.0.1:8899"
  39512. // 解析WebSocket服务器地址
  39513. u, err := url.Parse(serverURL)
  39514. if err != nil {
  39515. }
  39516. // 建立WebSocket连接
  39517. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39518. if err != nil {
  39519. }
  39520. defer conn.Close()
  39521. input2 := make(map[string]interface{})
  39522. input := make(map[string]interface{})
  39523. inputData := make(map[string]interface{})
  39524. inputData["orgId"] = code
  39525. inputData["businessType"] = "01301"
  39526. inputData["operatorId"] = operator_id
  39527. inputData["operatorName"] = operator_name
  39528. inputData["officeId"] = "001"
  39529. inputData["officeName"] = "血透室"
  39530. inputData["deviceType"] = ""
  39531. input["data"] = inputData
  39532. input["orgId"] = code
  39533. input["transType"] = "ec.query"
  39534. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39535. input2["indata"] = input
  39536. bytesData, _ := json.Marshal(input2)
  39537. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39538. if err != nil {
  39539. fmt.Println(err)
  39540. }
  39541. // 接收消息
  39542. _, receivedMessage, err := conn.ReadMessage()
  39543. if err != nil {
  39544. fmt.Println(err)
  39545. }
  39546. return "", string(receivedMessage)
  39547. }
  39548. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39549. newArr = make([]string, 0)
  39550. for i := 0; i < len(arr); i++ {
  39551. repeat := false
  39552. for j := i + 1; j < len(arr); j++ {
  39553. if arr[i] == arr[j] {
  39554. repeat = true
  39555. break
  39556. }
  39557. }
  39558. if !repeat {
  39559. newArr = append(newArr, arr[i])
  39560. }
  39561. }
  39562. return
  39563. }
  39564. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39565. if len(idNumber) != 18 {
  39566. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39567. }
  39568. // 提取出生日期
  39569. year, err := strconv.Atoi(idNumber[6:10])
  39570. if err != nil {
  39571. return "", 0, err
  39572. }
  39573. month, err := strconv.Atoi(idNumber[10:12])
  39574. if err != nil {
  39575. return "", 0, err
  39576. }
  39577. day, err := strconv.Atoi(idNumber[12:14])
  39578. if err != nil {
  39579. return "", 0, err
  39580. }
  39581. // 格式化生日字符串
  39582. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39583. birthdateFormatted := birthdate.Format("2006-01-02")
  39584. // 计算年龄
  39585. today := time.Now()
  39586. age := today.Year() - birthdate.Year()
  39587. if today.YearDay() < birthdate.YearDay() {
  39588. age--
  39589. }
  39590. return birthdateFormatted, age, nil
  39591. }
  39592. // 从身份证号码中提取出生年月日
  39593. func getBirthDateFromIDCard(idCard string) (string, error) {
  39594. // 身份证号码长度应为18位
  39595. if len(idCard) != 18 {
  39596. return "", fmt.Errorf("身份证号码长度应为18位")
  39597. }
  39598. // 提取出生日期部分 (YYYYMMDD)
  39599. birthDateStr := idCard[6:14]
  39600. // 解析出生日期
  39601. birthDate, err := time.Parse("20060102", birthDateStr)
  39602. if err != nil {
  39603. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39604. }
  39605. // 格式化出生日期为 YYYY-MM-DD
  39606. formattedDate := birthDate.Format("2006-01-02")
  39607. return formattedDate, nil
  39608. }