his_api_controller.go 1.6MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161
  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. //"github.com/tjfoc/gmsm/sm3"
  23. "math"
  24. "math/rand"
  25. "net/http"
  26. "net/url"
  27. "os"
  28. "path/filepath"
  29. "regexp"
  30. "strconv"
  31. "strings"
  32. "syscall"
  33. "time"
  34. "unsafe"
  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/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  169. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  170. }
  171. func (c *HisApiController) Get3201() {
  172. adminUser := c.GetAdminUserInfo()
  173. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  174. 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)
  175. var response Response
  176. if err := json.Unmarshal([]byte(result), &response); err != nil {
  177. fmt.Println("Error decoding JSON:", err)
  178. return
  179. }
  180. }
  181. func (c *HisApiController) TestNet() {
  182. c.ServeSuccessJSON(map[string]interface{}{
  183. "msg": "成功",
  184. })
  185. }
  186. func (c *HisApiController) Get3508() {
  187. admin_user_id, _ := c.GetInt64("admin_user_id")
  188. drug_id, _ := c.GetInt64("id")
  189. start_time := c.GetString("start_time")
  190. end_time := c.GetString("end_time")
  191. adminUser := c.GetAdminUserInfo()
  192. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  193. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  194. drug, _ := service.GetDrugByID(drug_id)
  195. var struct3508 models.Struct3508
  196. struct3508.OrgName = miConfig.OrgName
  197. struct3508.FixmedinsCode = miConfig.Code
  198. struct3508.AccessKey = miConfig.AccessKey
  199. struct3508.Opter = curRoles.UserName
  200. struct3508.RequestUrl = miConfig.Url
  201. struct3508.Url = miConfig.Url
  202. struct3508.AppId = miConfig.Cainfo
  203. struct3508.AppSecret = miConfig.AppSecret
  204. struct3508.Enckey = miConfig.EncKey
  205. struct3508.SignKey = miConfig.SignKey
  206. struct3508.SecretKey = miConfig.SecretKey
  207. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  208. struct3508.Begndate = start_time
  209. struct3508.Enddate = end_time
  210. result1, result2, _ := service.FJyb3508(struct3508)
  211. saveLog(result1, result2, "3508", "3508")
  212. var res models.Result3508
  213. var respJSON2 map[string]interface{}
  214. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  217. return
  218. }
  219. userJSONBytes2, _ := json.Marshal(respJSON2)
  220. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  221. utils.ErrorLog("解析失败:%v", err)
  222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  223. return
  224. }
  225. if res.Infcode == -1 {
  226. c.ServeSuccessJSON(map[string]interface{}{
  227. "failed_code": -10,
  228. "msg": res.ErrMsg,
  229. })
  230. } else {
  231. c.ServeSuccessJSON(map[string]interface{}{
  232. "info": res.Output,
  233. })
  234. }
  235. }
  236. func (c *HisApiController) Get3509() {
  237. admin_user_id, _ := c.GetInt64("admin_user_id")
  238. drug_id, _ := c.GetInt64("id")
  239. start_time := c.GetString("start_time")
  240. end_time := c.GetString("end_time")
  241. adminUser := c.GetAdminUserInfo()
  242. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  243. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  244. drug, _ := service.GetDrugByID(drug_id)
  245. var struct3508 models.Struct3509
  246. struct3508.OrgName = miConfig.OrgName
  247. struct3508.FixmedinsCode = miConfig.Code
  248. struct3508.AccessKey = miConfig.AccessKey
  249. struct3508.Opter = curRoles.UserName
  250. struct3508.RequestUrl = miConfig.Url
  251. struct3508.Url = miConfig.Url
  252. struct3508.AppId = miConfig.Cainfo
  253. struct3508.AppSecret = miConfig.AppSecret
  254. struct3508.Enckey = miConfig.EncKey
  255. struct3508.SignKey = miConfig.SignKey
  256. struct3508.SecretKey = miConfig.SecretKey
  257. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  258. struct3508.Begndate = start_time
  259. struct3508.Enddate = end_time
  260. result1, result2, _ := service.FJyb3509(struct3508)
  261. saveLog(result1, result2, "3509", "3509")
  262. var res models.Result3509
  263. var respJSON2 map[string]interface{}
  264. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  267. return
  268. }
  269. userJSONBytes2, _ := json.Marshal(respJSON2)
  270. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  271. utils.ErrorLog("解析失败:%v", err)
  272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  273. return
  274. }
  275. if res.Infcode == -1 {
  276. c.ServeSuccessJSON(map[string]interface{}{
  277. "failed_code": -10,
  278. "msg": res.ErrMsg,
  279. })
  280. } else {
  281. c.ServeSuccessJSON(map[string]interface{}{
  282. "info": res.Output,
  283. })
  284. }
  285. }
  286. func (c *HisApiController) Get3510() {
  287. admin_user_id, _ := c.GetInt64("admin_user_id")
  288. drug_id, _ := c.GetInt64("id")
  289. start_time := c.GetString("start_time")
  290. end_time := c.GetString("end_time")
  291. adminUser := c.GetAdminUserInfo()
  292. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  293. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  294. drug, _ := service.GetDrugByID(drug_id)
  295. var struct3508 models.Struct3510
  296. struct3508.FixmedinsCode = miConfig.Code
  297. struct3508.OrgName = miConfig.OrgName
  298. struct3508.AccessKey = miConfig.AccessKey
  299. struct3508.Opter = curRoles.UserName
  300. struct3508.RequestUrl = miConfig.Url
  301. struct3508.Url = miConfig.Url
  302. struct3508.AppId = miConfig.Cainfo
  303. struct3508.AppSecret = miConfig.AppSecret
  304. struct3508.Enckey = miConfig.EncKey
  305. struct3508.SignKey = miConfig.SignKey
  306. struct3508.SecretKey = miConfig.SecretKey
  307. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  308. struct3508.Begndate = start_time
  309. struct3508.Enddate = end_time
  310. result1, result2, _ := service.FJyb3510(struct3508)
  311. saveLog(result1, result2, "3510", "3510")
  312. var res models.Result3510
  313. var respJSON2 map[string]interface{}
  314. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  315. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  317. return
  318. }
  319. userJSONBytes2, _ := json.Marshal(respJSON2)
  320. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  321. utils.ErrorLog("解析失败:%v", err)
  322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  323. return
  324. }
  325. if res.Infcode == -1 {
  326. c.ServeSuccessJSON(map[string]interface{}{
  327. "failed_code": -10,
  328. "msg": res.ErrMsg,
  329. })
  330. } else {
  331. c.ServeSuccessJSON(map[string]interface{}{
  332. "info": res.Output,
  333. })
  334. }
  335. }
  336. func (c *HisApiController) Get3511() {
  337. admin_user_id, _ := c.GetInt64("admin_user_id")
  338. drug_id, _ := c.GetInt64("id")
  339. start_time := c.GetString("start_time")
  340. end_time := c.GetString("end_time")
  341. adminUser := c.GetAdminUserInfo()
  342. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  343. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  344. drug, _ := service.GetDrugByID(drug_id)
  345. var struct3508 models.Struct3511
  346. struct3508.FixmedinsCode = miConfig.Code
  347. struct3508.OrgName = miConfig.OrgName
  348. struct3508.AccessKey = miConfig.AccessKey
  349. struct3508.Opter = curRoles.UserName
  350. struct3508.RequestUrl = miConfig.Url
  351. struct3508.Url = miConfig.Url
  352. struct3508.AppId = miConfig.Cainfo
  353. struct3508.AppSecret = miConfig.AppSecret
  354. struct3508.Enckey = miConfig.EncKey
  355. struct3508.SignKey = miConfig.SignKey
  356. struct3508.SecretKey = miConfig.SecretKey
  357. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  358. struct3508.Begndate = start_time
  359. struct3508.Enddate = end_time
  360. result1, result2, _ := service.FJyb3511(struct3508)
  361. saveLog(result1, result2, "3511", "3511")
  362. var res models.Result3511
  363. var respJSON2 map[string]interface{}
  364. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  367. return
  368. }
  369. userJSONBytes2, _ := json.Marshal(respJSON2)
  370. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  371. utils.ErrorLog("解析失败:%v", err)
  372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  373. return
  374. }
  375. if res.Infcode == -1 {
  376. c.ServeSuccessJSON(map[string]interface{}{
  377. "failed_code": -10,
  378. "msg": res.ErrMsg,
  379. })
  380. } else {
  381. c.ServeSuccessJSON(map[string]interface{}{
  382. "info": res.Output,
  383. })
  384. }
  385. }
  386. func (c *HisApiController) Get3512() {
  387. admin_user_id, _ := c.GetInt64("admin_user_id")
  388. drug_id, _ := c.GetInt64("id")
  389. start_time := c.GetString("start_time")
  390. end_time := c.GetString("end_time")
  391. adminUser := c.GetAdminUserInfo()
  392. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  393. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  394. drug, _ := service.GetDrugByID(drug_id)
  395. var struct3508 models.Struct3512
  396. struct3508.FixmedinsCode = miConfig.Code
  397. struct3508.OrgName = miConfig.OrgName
  398. struct3508.AccessKey = miConfig.AccessKey
  399. struct3508.Opter = curRoles.UserName
  400. struct3508.RequestUrl = miConfig.Url
  401. struct3508.Url = miConfig.Url
  402. struct3508.AppId = miConfig.Cainfo
  403. struct3508.AppSecret = miConfig.AppSecret
  404. struct3508.Enckey = miConfig.EncKey
  405. struct3508.SignKey = miConfig.SignKey
  406. struct3508.SecretKey = miConfig.SecretKey
  407. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  408. struct3508.Begndate = start_time
  409. struct3508.Enddate = end_time
  410. result1, result2, _ := service.FJyb3512(struct3508)
  411. saveLog(result1, result2, "3512", "3512")
  412. var res models.Result3512
  413. var respJSON2 map[string]interface{}
  414. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  417. return
  418. }
  419. userJSONBytes2, _ := json.Marshal(respJSON2)
  420. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  421. utils.ErrorLog("解析失败:%v", err)
  422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  423. return
  424. }
  425. if res.Infcode == -1 {
  426. c.ServeSuccessJSON(map[string]interface{}{
  427. "failed_code": -10,
  428. "msg": res.ErrMsg,
  429. })
  430. } else {
  431. c.ServeSuccessJSON(map[string]interface{}{
  432. "info": res.Output,
  433. })
  434. }
  435. }
  436. func (c *HisApiController) Get3513() {
  437. admin_user_id, _ := c.GetInt64("admin_user_id")
  438. drug_id, _ := c.GetInt64("id")
  439. start_time := c.GetString("start_time")
  440. end_time := c.GetString("end_time")
  441. adminUser := c.GetAdminUserInfo()
  442. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  443. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  444. drug, _ := service.GetDrugByID(drug_id)
  445. var struct3508 models.Struct3513
  446. struct3508.FixmedinsCode = miConfig.Code
  447. struct3508.OrgName = miConfig.OrgName
  448. struct3508.AccessKey = miConfig.AccessKey
  449. struct3508.Opter = curRoles.UserName
  450. struct3508.RequestUrl = miConfig.Url
  451. struct3508.Url = miConfig.Url
  452. struct3508.AppId = miConfig.Cainfo
  453. struct3508.AppSecret = miConfig.AppSecret
  454. struct3508.Enckey = miConfig.EncKey
  455. struct3508.SignKey = miConfig.SignKey
  456. struct3508.SecretKey = miConfig.SecretKey
  457. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  458. struct3508.Begndate = start_time
  459. struct3508.Enddate = end_time
  460. result1, result2, _ := service.FJyb3513(struct3508)
  461. saveLog(result1, result2, "3513", "3513")
  462. var res models.Result3513
  463. var respJSON2 map[string]interface{}
  464. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  467. return
  468. }
  469. userJSONBytes2, _ := json.Marshal(respJSON2)
  470. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  471. utils.ErrorLog("解析失败:%v", err)
  472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  473. return
  474. }
  475. if res.Infcode == -1 {
  476. c.ServeSuccessJSON(map[string]interface{}{
  477. "failed_code": -10,
  478. "msg": res.ErrMsg,
  479. })
  480. } else {
  481. c.ServeSuccessJSON(map[string]interface{}{
  482. "info": res.Output,
  483. })
  484. }
  485. }
  486. func (c *HisApiController) Get35081() {
  487. admin_user_id, _ := c.GetInt64("admin_user_id")
  488. drug_id, _ := c.GetInt64("id")
  489. //start_time := c.GetString("start_time")
  490. //end_time := c.GetString("end_time")
  491. page, _ := c.GetInt("page")
  492. adminUser := c.GetAdminUserInfo()
  493. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  494. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  495. drug, _ := service.GetDrugByID(drug_id)
  496. var struct3508 models.Struct35081
  497. struct3508.FixmedinsCode = miConfig.Code
  498. struct3508.OrgName = miConfig.OrgName
  499. struct3508.AccessKey = miConfig.AccessKey
  500. struct3508.Opter = curRoles.UserName
  501. struct3508.RequestUrl = miConfig.Url
  502. struct3508.Url = miConfig.Url
  503. struct3508.AppId = miConfig.Cainfo
  504. struct3508.AppSecret = miConfig.AppSecret
  505. struct3508.Enckey = miConfig.EncKey
  506. struct3508.SignKey = miConfig.SignKey
  507. struct3508.SecretKey = miConfig.SecretKey
  508. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  509. struct3508.PageNum = page
  510. struct3508.PageSize = 10
  511. result1, result2, _ := service.FJyb35081(struct3508)
  512. saveLog(result1, result2, "35081", "35081")
  513. var res models.Result35081
  514. var respJSON2 map[string]interface{}
  515. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  518. return
  519. }
  520. userJSONBytes2, _ := json.Marshal(respJSON2)
  521. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  522. utils.ErrorLog("解析失败:%v", err)
  523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  524. return
  525. }
  526. if res.Infcode == -1 {
  527. c.ServeSuccessJSON(map[string]interface{}{
  528. "failed_code": -10,
  529. "msg": res.ErrMsg,
  530. })
  531. } else {
  532. c.ServeSuccessJSON(map[string]interface{}{
  533. "info": res.Output,
  534. })
  535. }
  536. }
  537. func (c *HisApiController) Get35082() {
  538. admin_user_id, _ := c.GetInt64("admin_user_id")
  539. drug_id, _ := c.GetInt64("id")
  540. //start_time := c.GetString("start_time")
  541. //end_time := c.GetString("end_time")
  542. page, _ := c.GetInt("page")
  543. adminUser := c.GetAdminUserInfo()
  544. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  545. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  546. drug, _ := service.GetDrugByID(drug_id)
  547. var struct3508 models.Struct35082
  548. struct3508.FixmedinsCode = miConfig.Code
  549. struct3508.OrgName = miConfig.OrgName
  550. struct3508.AccessKey = miConfig.AccessKey
  551. struct3508.Opter = curRoles.UserName
  552. struct3508.RequestUrl = miConfig.Url
  553. struct3508.Url = miConfig.Url
  554. struct3508.AppId = miConfig.Cainfo
  555. struct3508.AppSecret = miConfig.AppSecret
  556. struct3508.Enckey = miConfig.EncKey
  557. struct3508.SignKey = miConfig.SignKey
  558. struct3508.SecretKey = miConfig.SecretKey
  559. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  560. struct3508.PageNum = page
  561. struct3508.PageSize = 10
  562. result1, result2, _ := service.FJyb35082(struct3508)
  563. saveLog(result1, result2, "35082", "35082")
  564. var res models.Result35082
  565. var respJSON2 map[string]interface{}
  566. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  569. return
  570. }
  571. userJSONBytes2, _ := json.Marshal(respJSON2)
  572. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  573. utils.ErrorLog("解析失败:%v", err)
  574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  575. return
  576. }
  577. if res.Infcode == -1 {
  578. c.ServeSuccessJSON(map[string]interface{}{
  579. "failed_code": -10,
  580. "msg": res.ErrMsg,
  581. })
  582. } else {
  583. c.ServeSuccessJSON(map[string]interface{}{
  584. "info": res.Output,
  585. })
  586. }
  587. }
  588. func (c *HisApiController) FJ3501AND3502() {
  589. ids := c.GetString("ids")
  590. admin_user_id, _ := c.GetInt64("admin_user_id")
  591. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  592. id_arr := strings.Split(ids, ",")
  593. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  594. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  595. //库盘
  596. var errs []string
  597. for _, drug := range drugs {
  598. if drug.IsPc == 0 && drug.IsBg == 0 {
  599. var res2 ResultSix
  600. var res3 ResultSix
  601. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  602. var struct3501 models.Struct3501
  603. struct3501.Code = miConfig.Code
  604. struct3501.OrgName = miConfig.OrgName
  605. struct3501.AccessKey = miConfig.AccessKey
  606. struct3501.Opter = roles.UserName
  607. struct3501.RequestUrl = miConfig.Url
  608. struct3501.Url = miConfig.Url
  609. struct3501.AppId = miConfig.Cainfo
  610. struct3501.AppSecret = miConfig.AppSecret
  611. struct3501.Enckey = miConfig.EncKey
  612. struct3501.SignKey = miConfig.SignKey
  613. struct3501.SecretKey = miConfig.SecretKey
  614. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  615. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  616. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  617. struct3501.RxFlag = "1"
  618. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  619. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  620. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  621. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  622. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  623. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  624. struct3501.FixmedinsBchno = number
  625. struct3501.DrugTracCodg = drug.DrugCode
  626. memo := make(map[string]interface{})
  627. memo["pric"] = drug.Price
  628. bytesData, _ := json.Marshal(memo)
  629. struct3501.Memo = string(bytesData)
  630. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  631. result1, result2, _ := service.FJyb3501(struct3501)
  632. saveLog(result1, result2, "3501", "3501")
  633. //saveLog(result, requestLog, "2201", "挂号")
  634. var respJSON2 map[string]interface{}
  635. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  638. return
  639. }
  640. userJSONBytes2, _ := json.Marshal(respJSON2)
  641. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  642. utils.ErrorLog("解析失败:%v", err)
  643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  644. return
  645. }
  646. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  647. data := make(map[string]interface{})
  648. data["struct_3501s"] = struct3501
  649. client := &http.Client{}
  650. bytesData, _ := json.Marshal(data)
  651. var req *http.Request
  652. if miConfig.MdtrtareaAdmvs == "320921" {
  653. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  654. } else {
  655. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  656. }
  657. resp, _ := client.Do(req)
  658. defer resp.Body.Close()
  659. body, ioErr := ioutil.ReadAll(resp.Body)
  660. if ioErr != nil {
  661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  662. }
  663. var respJSON map[string]interface{}
  664. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  667. return
  668. }
  669. var resSix10265 ResultSix10265 //1101结果
  670. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  671. result, _ := json.Marshal(respJSON)
  672. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  673. utils.ErrorLog("解析失败:%v", err)
  674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  675. return
  676. }
  677. res2.InfRefmsgid = resSix10265.InfRefmsgid
  678. res2.Output = resSix10265.Output
  679. res2.ErrMsg = resSix10265.ErrMsg
  680. res2.Cainfo = resSix10265.Cainfo
  681. res2.WarnMsg = resSix10265.WarnMsg
  682. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  683. res2.Infcode = infocode
  684. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  685. data := make(map[string]interface{})
  686. data["struct_3501s"] = struct3501
  687. client := &http.Client{}
  688. bytesData, _ := json.Marshal(data)
  689. var req *http.Request
  690. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  691. resp, _ := client.Do(req)
  692. defer resp.Body.Close()
  693. body, ioErr := ioutil.ReadAll(resp.Body)
  694. if ioErr != nil {
  695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  696. }
  697. var respJSON map[string]interface{}
  698. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  701. return
  702. }
  703. var resSix10265 ResultSix10265 //1101结果
  704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  705. result, _ := json.Marshal(respJSON)
  706. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  707. utils.ErrorLog("解析失败:%v", err)
  708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  709. return
  710. }
  711. res2.InfRefmsgid = resSix10265.InfRefmsgid
  712. res2.Output = resSix10265.Output
  713. res2.ErrMsg = resSix10265.ErrMsg
  714. res2.Cainfo = resSix10265.Cainfo
  715. res2.WarnMsg = resSix10265.WarnMsg
  716. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  717. res2.Infcode = infocode
  718. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  719. data := make(map[string]interface{})
  720. data["struct_3501s"] = struct3501
  721. client := &http.Client{}
  722. bytesData, _ := json.Marshal(data)
  723. var req *http.Request
  724. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  725. resp, _ := client.Do(req)
  726. defer resp.Body.Close()
  727. body, ioErr := ioutil.ReadAll(resp.Body)
  728. if ioErr != nil {
  729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  730. }
  731. var respJSON map[string]interface{}
  732. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  735. return
  736. }
  737. var resSix10265 ResultSix10265 //1101结果
  738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  739. result, _ := json.Marshal(respJSON)
  740. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  741. utils.ErrorLog("解析失败:%v", err)
  742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  743. return
  744. }
  745. res2.InfRefmsgid = resSix10265.InfRefmsgid
  746. res2.Output = resSix10265.Output
  747. res2.ErrMsg = resSix10265.ErrMsg
  748. res2.Cainfo = resSix10265.Cainfo
  749. res2.WarnMsg = resSix10265.WarnMsg
  750. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  751. res2.Infcode = infocode
  752. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  753. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  754. saveLog(result1, result2, "3501", "3501")
  755. //saveLog(result, requestLog, "2201", "挂号")
  756. var respJSON2 map[string]interface{}
  757. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  760. return
  761. }
  762. userJSONBytes2, _ := json.Marshal(respJSON2)
  763. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  764. utils.ErrorLog("解析失败:%v", err)
  765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  766. return
  767. }
  768. }
  769. if res2.Infcode != -1 {
  770. drug.IsPc = 1
  771. drug.Bchno = number
  772. drug.PcDate = time.Now().Unix()
  773. err := service.SaveW(drug)
  774. if err == nil {
  775. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  776. var struct3502 models.Struct3502
  777. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  778. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  779. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  780. struct3502.FixmedinsCode = miConfig.Code
  781. struct3502.Code = miConfig.Code
  782. struct3502.RxFlag = "0"
  783. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  784. struct3502.OrgName = miConfig.OrgName
  785. struct3502.Opter = roles.UserName
  786. struct3502.AccessKey = miConfig.AccessKey
  787. struct3502.RequestUrl = miConfig.Url
  788. struct3502.SecretKey = miConfig.SecretKey
  789. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  790. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  791. struct3502.Url = miConfig.Url
  792. struct3502.AppId = miConfig.Cainfo
  793. struct3502.AppSecret = miConfig.AppSecret
  794. struct3502.Enckey = miConfig.EncKey
  795. struct3502.SignKey = miConfig.SignKey
  796. struct3502.SecretKey = miConfig.SecretKey
  797. struct3502.DrugTracCodg = drug.DrugCode
  798. struct3502.Memo = ""
  799. struct3502.InvChgType = "108"
  800. struct3502.FixmedinsBchno = bg_number
  801. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  802. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  803. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  804. result11, result22, _ := service.FJyb3502(struct3502)
  805. saveLog(result11, result22, "3502", "3502")
  806. var respJSON3 map[string]interface{}
  807. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  810. return
  811. }
  812. userJSONBytes3, _ := json.Marshal(respJSON3)
  813. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  814. utils.ErrorLog("解析失败:%v", err)
  815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  816. return
  817. }
  818. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  819. data := make(map[string]interface{})
  820. data["struct_3502s"] = struct3502
  821. client := &http.Client{}
  822. bytesData, _ := json.Marshal(data)
  823. var req *http.Request
  824. if miConfig.MdtrtareaAdmvs == "320921" {
  825. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  826. } else {
  827. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  828. }
  829. resp, _ := client.Do(req)
  830. defer resp.Body.Close()
  831. body, ioErr := ioutil.ReadAll(resp.Body)
  832. if ioErr != nil {
  833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  834. }
  835. var respJSON map[string]interface{}
  836. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  839. return
  840. }
  841. var resSix10265 ResultSix10265 //1101结果
  842. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  843. result, _ := json.Marshal(respJSON)
  844. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  845. utils.ErrorLog("解析失败:%v", err)
  846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  847. return
  848. }
  849. res3.InfRefmsgid = resSix10265.InfRefmsgid
  850. res3.Output = resSix10265.Output
  851. res3.ErrMsg = resSix10265.ErrMsg
  852. res3.Cainfo = resSix10265.Cainfo
  853. res3.WarnMsg = resSix10265.WarnMsg
  854. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  855. res3.Infcode = infocode
  856. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  857. data := make(map[string]interface{})
  858. data["struct_3502s"] = struct3502
  859. client := &http.Client{}
  860. bytesData, _ := json.Marshal(data)
  861. var req *http.Request
  862. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  863. resp, _ := client.Do(req)
  864. defer resp.Body.Close()
  865. body, ioErr := ioutil.ReadAll(resp.Body)
  866. if ioErr != nil {
  867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  868. }
  869. var respJSON map[string]interface{}
  870. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  873. return
  874. }
  875. var resSix10265 ResultSix10265 //1101结果
  876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  877. result, _ := json.Marshal(respJSON)
  878. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  879. utils.ErrorLog("解析失败:%v", err)
  880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  881. return
  882. }
  883. res3.InfRefmsgid = resSix10265.InfRefmsgid
  884. res3.Output = resSix10265.Output
  885. res3.ErrMsg = resSix10265.ErrMsg
  886. res3.Cainfo = resSix10265.Cainfo
  887. res3.WarnMsg = resSix10265.WarnMsg
  888. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  889. res3.Infcode = infocode
  890. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  891. data := make(map[string]interface{})
  892. data["struct_3501s"] = struct3501
  893. client := &http.Client{}
  894. bytesData, _ := json.Marshal(data)
  895. var req *http.Request
  896. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  897. resp, _ := client.Do(req)
  898. defer resp.Body.Close()
  899. body, ioErr := ioutil.ReadAll(resp.Body)
  900. if ioErr != nil {
  901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  902. }
  903. var respJSON map[string]interface{}
  904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  907. return
  908. }
  909. var resSix10265 ResultSix10265 //1101结果
  910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  911. result, _ := json.Marshal(respJSON)
  912. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  913. utils.ErrorLog("解析失败:%v", err)
  914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  915. return
  916. }
  917. res2.InfRefmsgid = resSix10265.InfRefmsgid
  918. res2.Output = resSix10265.Output
  919. res2.ErrMsg = resSix10265.ErrMsg
  920. res2.Cainfo = resSix10265.Cainfo
  921. res2.WarnMsg = resSix10265.WarnMsg
  922. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  923. res2.Infcode = infocode
  924. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  925. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  926. saveLog(result11, result22, "3502", "3502")
  927. var respJSON3 map[string]interface{}
  928. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  931. return
  932. }
  933. userJSONBytes3, _ := json.Marshal(respJSON3)
  934. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  935. utils.ErrorLog("解析失败:%v", err)
  936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  937. return
  938. }
  939. }
  940. if res3.Infcode == -1 {
  941. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  942. c.ServeSuccessJSON(map[string]interface{}{
  943. "failed_code": -10,
  944. "msg": res3.ErrMsg,
  945. })
  946. } else {
  947. drug.IsBg = 1
  948. drug.BgBchno = bg_number
  949. service.SaveW(drug)
  950. }
  951. }
  952. } else {
  953. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  954. }
  955. }
  956. //变更
  957. if drug.IsPc == 1 && drug.IsBg == 0 {
  958. var res3 ResultSix
  959. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  960. var struct3502 models.Struct3502
  961. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  962. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  963. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  964. struct3502.FixmedinsCode = miConfig.Code
  965. struct3502.Code = miConfig.Code
  966. struct3502.Opter = roles.UserName
  967. struct3502.RxFlag = "0"
  968. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  969. struct3502.OrgName = miConfig.OrgName
  970. struct3502.AccessKey = miConfig.AccessKey
  971. struct3502.RequestUrl = miConfig.Url
  972. struct3502.SecretKey = miConfig.SecretKey
  973. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  974. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  975. struct3502.InvChgType = "108"
  976. struct3502.DrugTracCodg = drug.DrugCode
  977. struct3502.Url = miConfig.Url
  978. struct3502.AppId = miConfig.Cainfo
  979. struct3502.AppSecret = miConfig.AppSecret
  980. struct3502.Enckey = miConfig.EncKey
  981. struct3502.SignKey = miConfig.SignKey
  982. struct3502.SecretKey = miConfig.SecretKey
  983. struct3502.FixmedinsBchno = bg_number
  984. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  985. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  986. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  987. result1, result2, _ := service.FJyb3502(struct3502)
  988. saveLog(result1, result2, "3502", "3502")
  989. var respJSON3 map[string]interface{}
  990. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  993. return
  994. }
  995. userJSONBytes3, _ := json.Marshal(respJSON3)
  996. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  997. utils.ErrorLog("解析失败:%v", err)
  998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  999. return
  1000. }
  1001. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1002. data := make(map[string]interface{})
  1003. data["struct_3502s"] = struct3502
  1004. client := &http.Client{}
  1005. bytesData, _ := json.Marshal(data)
  1006. var req *http.Request
  1007. if miConfig.MdtrtareaAdmvs == "320921" {
  1008. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1009. } else {
  1010. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1011. }
  1012. resp, _ := client.Do(req)
  1013. defer resp.Body.Close()
  1014. body, ioErr := ioutil.ReadAll(resp.Body)
  1015. if ioErr != nil {
  1016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1017. }
  1018. var respJSON map[string]interface{}
  1019. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1022. return
  1023. }
  1024. var resSix10265 ResultSix10265 //1101结果
  1025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1026. result, _ := json.Marshal(respJSON)
  1027. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1028. utils.ErrorLog("解析失败:%v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1033. res3.Output = resSix10265.Output
  1034. res3.ErrMsg = resSix10265.ErrMsg
  1035. res3.Cainfo = resSix10265.Cainfo
  1036. res3.WarnMsg = resSix10265.WarnMsg
  1037. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1038. res3.Infcode = infocode
  1039. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1040. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1041. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  1042. }
  1043. if res3.Infcode == -1 {
  1044. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1045. } else {
  1046. drug.IsBg = 1
  1047. drug.BgBchno = bg_number
  1048. service.SaveW(drug)
  1049. }
  1050. }
  1051. }
  1052. if len(errs) == 0 {
  1053. c.ServeSuccessJSON(map[string]interface{}{
  1054. "msg": "盘存变更成功",
  1055. })
  1056. } else {
  1057. c.ServeSuccessJSON(map[string]interface{}{
  1058. "failed_code": -10,
  1059. "msg": errs,
  1060. })
  1061. }
  1062. }
  1063. func (c *HisApiController) DeletePCandBG() {
  1064. ids := c.GetString("ids")
  1065. id_arr := strings.Split(ids, ",")
  1066. admin_user_id, _ := c.GetInt64("admin_user_id")
  1067. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1068. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1069. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1070. var err []string
  1071. for _, item := range drugs {
  1072. if item.IsPc == 1 && item.IsBg == 1 {
  1073. var res FJ3507Result
  1074. var res2 FJ3507Result
  1075. var struct3507 models.Struct3507
  1076. struct3507.FixmedinsBchno = item.Bchno
  1077. struct3507.InvDataType = "1"
  1078. struct3507.Opter = roles.UserName
  1079. struct3507.OrgName = miConfig.OrgName
  1080. struct3507.AccessKey = miConfig.AccessKey
  1081. struct3507.RequestUrl = miConfig.Url
  1082. struct3507.FixmedinsCode = miConfig.Code
  1083. struct3507.Code = miConfig.Code
  1084. struct3507.SecretKey = miConfig.SecretKey
  1085. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1086. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1087. struct3507.Url = miConfig.Url
  1088. struct3507.AppId = miConfig.Cainfo
  1089. struct3507.AppSecret = miConfig.AppSecret
  1090. struct3507.Enckey = miConfig.EncKey
  1091. struct3507.SignKey = miConfig.SignKey
  1092. struct3507.SecretKey = miConfig.SecretKey
  1093. if miConfig.MdtrtareaAdmvs == "350500" {
  1094. result, result1, _ := service.FJyb3507(struct3507)
  1095. saveLog(result, result1, "3507", "3507")
  1096. var respJSON2 map[string]interface{}
  1097. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1100. return
  1101. }
  1102. userJSONBytes2, _ := json.Marshal(respJSON2)
  1103. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1104. utils.ErrorLog("解析失败:%v", err)
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1106. return
  1107. }
  1108. } else {
  1109. data := make(map[string]interface{})
  1110. data["struct_3507s"] = struct3507
  1111. client := &http.Client{}
  1112. bytesData, _ := json.Marshal(data)
  1113. var req *http.Request
  1114. if miConfig.MdtrtareaAdmvs == "320921" {
  1115. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1116. } else {
  1117. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1118. }
  1119. resp, _ := client.Do(req)
  1120. defer resp.Body.Close()
  1121. body, ioErr := ioutil.ReadAll(resp.Body)
  1122. if ioErr != nil {
  1123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1124. }
  1125. var respJSON map[string]interface{}
  1126. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1129. return
  1130. }
  1131. var resSix10265 ResultSix10265 //1101结果
  1132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1133. result, _ := json.Marshal(respJSON)
  1134. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1135. utils.ErrorLog("解析失败:%v", err)
  1136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1137. return
  1138. }
  1139. res.InfRefmsgid = resSix10265.InfRefmsgid
  1140. //res.Output = resSix10265.Output
  1141. res.ErrMsg = resSix10265.ErrMsg
  1142. res.Cainfo = resSix10265.Cainfo
  1143. res.WarnMsg = resSix10265.WarnMsg
  1144. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1145. res.Infcode = infocode
  1146. }
  1147. if res.Infcode == 0 {
  1148. item.IsPc = 0
  1149. err2 := service.SaveW(item)
  1150. if err2 == nil {
  1151. var struct3507_2 models.Struct3507
  1152. struct3507_2.OrgName = miConfig.OrgName
  1153. struct3507_2.AccessKey = miConfig.AccessKey
  1154. struct3507_2.RequestUrl = miConfig.Url
  1155. struct3507_2.Opter = roles.UserName
  1156. struct3507_2.FixmedinsCode = miConfig.Code
  1157. struct3507_2.Code = miConfig.Code
  1158. struct3507_2.SecretKey = miConfig.SecretKey
  1159. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1160. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1161. struct3507_2.Url = miConfig.Url
  1162. struct3507_2.AppId = miConfig.Cainfo
  1163. struct3507_2.AppSecret = miConfig.AppSecret
  1164. struct3507_2.Enckey = miConfig.EncKey
  1165. struct3507_2.SignKey = miConfig.SignKey
  1166. struct3507_2.SecretKey = miConfig.SecretKey
  1167. struct3507_2.FixmedinsBchno = item.BgBchno
  1168. struct3507_2.InvDataType = "2"
  1169. if miConfig.MdtrtareaAdmvs == "350500" {
  1170. result11, result22, _ := service.FJyb3507(struct3507_2)
  1171. saveLog(result11, result22, "3507", "3507")
  1172. var respJSON3 map[string]interface{}
  1173. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1176. return
  1177. }
  1178. userJSONBytes3, _ := json.Marshal(respJSON3)
  1179. if err := json.Unmarshal(userJSONBytes3, &res2); 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_2
  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. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1216. //res2.Output = resSix10265.Output
  1217. res2.ErrMsg = resSix10265.ErrMsg
  1218. res2.Cainfo = resSix10265.Cainfo
  1219. res2.WarnMsg = resSix10265.WarnMsg
  1220. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1221. res2.Infcode = infocode
  1222. }
  1223. if res2.Infcode != -1 {
  1224. item.IsBg = 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. } else {
  1234. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1235. }
  1236. }
  1237. if item.IsPc == 1 && item.IsBg == 0 {
  1238. var res FJ3507Result
  1239. var struct3507 models.Struct3507
  1240. struct3507.FixmedinsBchno = item.Bchno
  1241. struct3507.InvDataType = "1"
  1242. struct3507.Opter = roles.UserName
  1243. struct3507.FixmedinsCode = miConfig.Code
  1244. struct3507.Code = miConfig.Code
  1245. struct3507.OrgName = miConfig.OrgName
  1246. struct3507.AccessKey = miConfig.AccessKey
  1247. struct3507.RequestUrl = miConfig.Url
  1248. struct3507.SecretKey = miConfig.SecretKey
  1249. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1250. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1251. struct3507.Url = miConfig.Url
  1252. struct3507.AppId = miConfig.Cainfo
  1253. struct3507.AppSecret = miConfig.AppSecret
  1254. struct3507.Enckey = miConfig.EncKey
  1255. struct3507.SignKey = miConfig.SignKey
  1256. struct3507.SecretKey = miConfig.SecretKey
  1257. //result, result1, _ := service.FJyb3507(struct3507)
  1258. //saveLog(result, result1, "3507", "3507")
  1259. if miConfig.MdtrtareaAdmvs == "350500" {
  1260. result, result1, _ := service.FJyb3507(struct3507)
  1261. saveLog(result, result1, "3507", "3507")
  1262. var respJSON2 map[string]interface{}
  1263. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1266. return
  1267. }
  1268. userJSONBytes2, _ := json.Marshal(respJSON2)
  1269. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1270. utils.ErrorLog("解析失败:%v", err)
  1271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1272. return
  1273. }
  1274. } else {
  1275. data := make(map[string]interface{})
  1276. data["struct_3507s"] = struct3507
  1277. client := &http.Client{}
  1278. bytesData, _ := json.Marshal(data)
  1279. var req *http.Request
  1280. if miConfig.MdtrtareaAdmvs == "320921" {
  1281. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1282. } else {
  1283. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1284. }
  1285. resp, _ := client.Do(req)
  1286. defer resp.Body.Close()
  1287. body, ioErr := ioutil.ReadAll(resp.Body)
  1288. if ioErr != nil {
  1289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1290. }
  1291. var respJSON map[string]interface{}
  1292. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1295. return
  1296. }
  1297. var resSix10265 ResultSix10265 //1101结果
  1298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1299. result, _ := json.Marshal(respJSON)
  1300. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1301. utils.ErrorLog("解析失败:%v", err)
  1302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1303. return
  1304. }
  1305. res.InfRefmsgid = resSix10265.InfRefmsgid
  1306. //res.Output = resSix10265.Output
  1307. res.ErrMsg = resSix10265.ErrMsg
  1308. res.Cainfo = resSix10265.Cainfo
  1309. res.WarnMsg = resSix10265.WarnMsg
  1310. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1311. res.Infcode = infocode
  1312. }
  1313. if res.Infcode == 0 {
  1314. item.IsPc = 0
  1315. item.Bchno = ""
  1316. item.BgBchno = ""
  1317. item.PcDate = 0
  1318. service.SaveW(item)
  1319. } else {
  1320. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1321. }
  1322. }
  1323. if item.IsPc == 0 && item.IsBg == 1 {
  1324. var res FJ3507Result
  1325. var struct3507 models.Struct3507
  1326. struct3507.FixmedinsBchno = item.BgBchno
  1327. struct3507.InvDataType = "2"
  1328. struct3507.Opter = roles.UserName
  1329. struct3507.FixmedinsCode = miConfig.Code
  1330. struct3507.OrgName = miConfig.OrgName
  1331. struct3507.AccessKey = miConfig.AccessKey
  1332. struct3507.RequestUrl = miConfig.Url
  1333. struct3507.SecretKey = miConfig.SecretKey
  1334. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1335. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1336. struct3507.Url = miConfig.Url
  1337. struct3507.AppId = miConfig.Cainfo
  1338. struct3507.AppSecret = miConfig.AppSecret
  1339. struct3507.Enckey = miConfig.EncKey
  1340. struct3507.SignKey = miConfig.SignKey
  1341. struct3507.SecretKey = miConfig.SecretKey
  1342. //result, result1, _ := service.FJyb3507(struct3507)
  1343. //saveLog(result, result1, "3507", "3507")
  1344. if miConfig.MdtrtareaAdmvs == "350500" {
  1345. result, result1, _ := service.FJyb3507(struct3507)
  1346. saveLog(result, result1, "3507", "3507")
  1347. var respJSON2 map[string]interface{}
  1348. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1351. return
  1352. }
  1353. userJSONBytes2, _ := json.Marshal(respJSON2)
  1354. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1355. utils.ErrorLog("解析失败:%v", err)
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1357. return
  1358. }
  1359. } else {
  1360. data := make(map[string]interface{})
  1361. data["struct_3507s"] = struct3507
  1362. client := &http.Client{}
  1363. bytesData, _ := json.Marshal(data)
  1364. var req *http.Request
  1365. if miConfig.MdtrtareaAdmvs == "320921" {
  1366. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1367. } else {
  1368. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1369. }
  1370. resp, _ := client.Do(req)
  1371. defer resp.Body.Close()
  1372. body, ioErr := ioutil.ReadAll(resp.Body)
  1373. if ioErr != nil {
  1374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1375. }
  1376. var respJSON map[string]interface{}
  1377. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1380. return
  1381. }
  1382. var resSix10265 ResultSix10265 //1101结果
  1383. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1384. result, _ := json.Marshal(respJSON)
  1385. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1386. utils.ErrorLog("解析失败:%v", err)
  1387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1388. return
  1389. }
  1390. res.InfRefmsgid = resSix10265.InfRefmsgid
  1391. //res.Output = resSix10265.Output
  1392. res.ErrMsg = resSix10265.ErrMsg
  1393. res.Cainfo = resSix10265.Cainfo
  1394. res.WarnMsg = resSix10265.WarnMsg
  1395. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1396. res.Infcode = infocode
  1397. }
  1398. if res.Infcode == 0 {
  1399. item.IsBg = 0
  1400. item.Bchno = ""
  1401. item.BgBchno = ""
  1402. item.PcDate = 0
  1403. service.SaveW(item)
  1404. } else {
  1405. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1406. }
  1407. }
  1408. }
  1409. if len(err) == 0 {
  1410. c.ServeSuccessJSON(map[string]interface{}{
  1411. "msg": "删除盘存变更成功",
  1412. })
  1413. } else {
  1414. c.ServeSuccessJSON(map[string]interface{}{
  1415. "failed_code": -10,
  1416. "msg": err,
  1417. })
  1418. }
  1419. }
  1420. func (c *HisApiController) DeleteXSandBG() {
  1421. ids := c.GetString("ids")
  1422. id_arr := strings.Split(ids, ",")
  1423. admin_user_id, _ := c.GetInt64("admin_user_id")
  1424. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1425. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1426. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1427. var err []string
  1428. for _, item := range flows {
  1429. if item.IsSale == 1 && item.IsChange == 1 {
  1430. var res FJ3507Result
  1431. var res2 FJ3507Result
  1432. var struct3507 models.Struct3507
  1433. struct3507.FixmedinsBchno = item.Bchno
  1434. struct3507.InvDataType = "4"
  1435. struct3507.Opter = roles.UserName
  1436. struct3507.OrgName = miConfig.OrgName
  1437. struct3507.AccessKey = miConfig.AccessKey
  1438. struct3507.RequestUrl = miConfig.Url
  1439. struct3507.FixmedinsCode = miConfig.Code
  1440. struct3507.SecretKey = miConfig.SecretKey
  1441. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1442. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1443. struct3507.Url = miConfig.Url
  1444. struct3507.AppId = miConfig.Cainfo
  1445. struct3507.AppSecret = miConfig.AppSecret
  1446. struct3507.Enckey = miConfig.EncKey
  1447. struct3507.SignKey = miConfig.SignKey
  1448. struct3507.SecretKey = miConfig.SecretKey
  1449. //result, result1, _ := service.FJyb3507(struct3507)
  1450. //saveLog(result, result1, "3507", "3507")
  1451. if miConfig.MdtrtareaAdmvs == "350500" {
  1452. result, result1, _ := service.FJyb3507(struct3507)
  1453. saveLog(result, result1, "3507", "3507")
  1454. var respJSON2 map[string]interface{}
  1455. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1458. return
  1459. }
  1460. userJSONBytes2, _ := json.Marshal(respJSON2)
  1461. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1462. utils.ErrorLog("解析失败:%v", err)
  1463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1464. return
  1465. }
  1466. } else {
  1467. data := make(map[string]interface{})
  1468. data["struct_3507s"] = struct3507
  1469. client := &http.Client{}
  1470. bytesData, _ := json.Marshal(data)
  1471. var req *http.Request
  1472. if miConfig.MdtrtareaAdmvs == "320921" {
  1473. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1474. } else {
  1475. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1476. }
  1477. resp, _ := client.Do(req)
  1478. defer resp.Body.Close()
  1479. body, ioErr := ioutil.ReadAll(resp.Body)
  1480. if ioErr != nil {
  1481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1482. }
  1483. var respJSON map[string]interface{}
  1484. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1487. return
  1488. }
  1489. var resSix10265 ResultSix10265 //1101结果
  1490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1491. result, _ := json.Marshal(respJSON)
  1492. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1493. utils.ErrorLog("解析失败:%v", err)
  1494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1495. return
  1496. }
  1497. res.InfRefmsgid = resSix10265.InfRefmsgid
  1498. //res.Output = resSix10265.Output
  1499. res.ErrMsg = resSix10265.ErrMsg
  1500. res.Cainfo = resSix10265.Cainfo
  1501. res.WarnMsg = resSix10265.WarnMsg
  1502. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1503. res.Infcode = infocode
  1504. }
  1505. if res.Infcode == 0 {
  1506. item.IsSale = 0
  1507. item.SaleDate = ""
  1508. item.Bchno = ""
  1509. err2 := service.SaveDF(item)
  1510. if err2 == nil {
  1511. var struct3507_2 models.Struct3507
  1512. struct3507_2.OrgName = miConfig.OrgName
  1513. struct3507_2.AccessKey = miConfig.AccessKey
  1514. struct3507_2.RequestUrl = miConfig.Url
  1515. struct3507_2.Opter = roles.UserName
  1516. struct3507_2.FixmedinsCode = miConfig.Code
  1517. struct3507_2.Code = miConfig.Code
  1518. struct3507_2.SecretKey = miConfig.SecretKey
  1519. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1520. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1521. struct3507_2.Url = miConfig.Url
  1522. struct3507_2.AppId = miConfig.Cainfo
  1523. struct3507_2.AppSecret = miConfig.AppSecret
  1524. struct3507_2.Enckey = miConfig.EncKey
  1525. struct3507_2.SignKey = miConfig.SignKey
  1526. struct3507_2.SecretKey = miConfig.SecretKey
  1527. struct3507_2.FixmedinsBchno = item.BgBchno
  1528. struct3507_2.InvDataType = "2"
  1529. if miConfig.MdtrtareaAdmvs == "350500" {
  1530. result11, result22, _ := service.FJyb3507(struct3507_2)
  1531. saveLog(result11, result22, "3507", "3507")
  1532. var respJSON3 map[string]interface{}
  1533. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1536. return
  1537. }
  1538. userJSONBytes3, _ := json.Marshal(respJSON3)
  1539. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1540. utils.ErrorLog("解析失败:%v", err)
  1541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1542. return
  1543. }
  1544. } else {
  1545. data := make(map[string]interface{})
  1546. data["struct_3507s"] = struct3507_2
  1547. client := &http.Client{}
  1548. bytesData, _ := json.Marshal(data)
  1549. var req *http.Request
  1550. if miConfig.MdtrtareaAdmvs == "320921" {
  1551. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1552. } else {
  1553. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1554. }
  1555. resp, _ := client.Do(req)
  1556. defer resp.Body.Close()
  1557. body, ioErr := ioutil.ReadAll(resp.Body)
  1558. if ioErr != nil {
  1559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1560. }
  1561. var respJSON map[string]interface{}
  1562. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1565. return
  1566. }
  1567. var resSix10265 ResultSix10265 //1101结果
  1568. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1569. result, _ := json.Marshal(respJSON)
  1570. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1571. utils.ErrorLog("解析失败:%v", err)
  1572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1573. return
  1574. }
  1575. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1576. //res.Output = resSix10265.Output
  1577. res2.ErrMsg = resSix10265.ErrMsg
  1578. res2.Cainfo = resSix10265.Cainfo
  1579. res2.WarnMsg = resSix10265.WarnMsg
  1580. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1581. res2.Infcode = infocode
  1582. }
  1583. if res2.Infcode == 0 {
  1584. item.IsChange = 0
  1585. item.BgBchno = ""
  1586. service.SaveDF2(item)
  1587. } else {
  1588. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1589. }
  1590. }
  1591. } else {
  1592. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1593. }
  1594. }
  1595. if item.IsSale == 2 && item.IsChange == 1 {
  1596. var res FJ3507Result
  1597. var res2 FJ3507Result
  1598. var struct3507 models.Struct3507
  1599. struct3507.FixmedinsBchno = item.Bchno
  1600. struct3507.InvDataType = "4"
  1601. struct3507.Opter = roles.UserName
  1602. struct3507.OrgName = miConfig.OrgName
  1603. struct3507.AccessKey = miConfig.AccessKey
  1604. struct3507.RequestUrl = miConfig.Url
  1605. struct3507.FixmedinsCode = miConfig.Code
  1606. struct3507.Code = miConfig.Code
  1607. struct3507.SecretKey = miConfig.SecretKey
  1608. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1609. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1610. struct3507.Url = miConfig.Url
  1611. struct3507.AppId = miConfig.Cainfo
  1612. struct3507.AppSecret = miConfig.AppSecret
  1613. struct3507.Enckey = miConfig.EncKey
  1614. struct3507.SignKey = miConfig.SignKey
  1615. struct3507.SecretKey = miConfig.SecretKey
  1616. //result, result1, _ := service.FJyb3507(struct3507)
  1617. //saveLog(result, result1, "3507", "3507")
  1618. //
  1619. //var respJSON2 map[string]interface{}
  1620. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1621. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1623. // return
  1624. //}
  1625. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1626. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1627. // utils.ErrorLog("解析失败:%v", err)
  1628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1629. // return
  1630. //}
  1631. if miConfig.MdtrtareaAdmvs == "350500" {
  1632. result, result1, _ := service.FJyb3507(struct3507)
  1633. saveLog(result, result1, "3507", "3507")
  1634. var respJSON2 map[string]interface{}
  1635. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1638. return
  1639. }
  1640. userJSONBytes2, _ := json.Marshal(respJSON2)
  1641. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1642. utils.ErrorLog("解析失败:%v", err)
  1643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1644. return
  1645. }
  1646. } else {
  1647. data := make(map[string]interface{})
  1648. data["struct_3507s"] = struct3507
  1649. client := &http.Client{}
  1650. bytesData, _ := json.Marshal(data)
  1651. var req *http.Request
  1652. if miConfig.MdtrtareaAdmvs == "320921" {
  1653. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1654. } else {
  1655. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. }
  1657. resp, _ := client.Do(req)
  1658. defer resp.Body.Close()
  1659. body, ioErr := ioutil.ReadAll(resp.Body)
  1660. if ioErr != nil {
  1661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1662. }
  1663. var respJSON map[string]interface{}
  1664. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1667. return
  1668. }
  1669. var resSix10265 ResultSix10265 //1101结果
  1670. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1671. result, _ := json.Marshal(respJSON)
  1672. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1673. utils.ErrorLog("解析失败:%v", err)
  1674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1675. return
  1676. }
  1677. res.InfRefmsgid = resSix10265.InfRefmsgid
  1678. //res.Output = resSix10265.Output
  1679. res.ErrMsg = resSix10265.ErrMsg
  1680. res.Cainfo = resSix10265.Cainfo
  1681. res.WarnMsg = resSix10265.WarnMsg
  1682. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1683. res.Infcode = infocode
  1684. }
  1685. if res.Infcode == 0 {
  1686. item.IsSale = 0
  1687. item.SaleDate = ""
  1688. item.Bchno = ""
  1689. err2 := service.SaveDF(item)
  1690. if err2 == nil {
  1691. var struct3507_2 models.Struct3507
  1692. struct3507_2.OrgName = miConfig.OrgName
  1693. struct3507_2.AccessKey = miConfig.AccessKey
  1694. struct3507_2.RequestUrl = miConfig.Url
  1695. struct3507_2.Opter = roles.UserName
  1696. struct3507_2.FixmedinsCode = miConfig.Code
  1697. struct3507_2.Code = miConfig.Code
  1698. struct3507_2.SecretKey = miConfig.SecretKey
  1699. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1700. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1701. struct3507_2.Url = miConfig.Url
  1702. struct3507_2.AppId = miConfig.Cainfo
  1703. struct3507_2.AppSecret = miConfig.AppSecret
  1704. struct3507_2.Enckey = miConfig.EncKey
  1705. struct3507_2.SignKey = miConfig.SignKey
  1706. struct3507_2.SecretKey = miConfig.SecretKey
  1707. struct3507_2.FixmedinsBchno = item.BgBchno
  1708. struct3507_2.InvDataType = "2"
  1709. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1710. //saveLog(result11, result22, "3507", "3507")
  1711. //var respJSON3 map[string]interface{}
  1712. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1713. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1715. // return
  1716. //}
  1717. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1718. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1719. // utils.ErrorLog("解析失败:%v", err)
  1720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1721. // return
  1722. //}
  1723. if miConfig.MdtrtareaAdmvs == "350500" {
  1724. result11, result22, _ := service.FJyb3507(struct3507_2)
  1725. saveLog(result11, result22, "3507", "3507")
  1726. var respJSON3 map[string]interface{}
  1727. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1730. return
  1731. }
  1732. userJSONBytes3, _ := json.Marshal(respJSON3)
  1733. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1734. utils.ErrorLog("解析失败:%v", err)
  1735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1736. return
  1737. }
  1738. } else {
  1739. data := make(map[string]interface{})
  1740. data["struct_3507s"] = struct3507_2
  1741. client := &http.Client{}
  1742. bytesData, _ := json.Marshal(data)
  1743. var req *http.Request
  1744. if miConfig.MdtrtareaAdmvs == "320921" {
  1745. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1746. } else {
  1747. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1748. }
  1749. resp, _ := client.Do(req)
  1750. defer resp.Body.Close()
  1751. body, ioErr := ioutil.ReadAll(resp.Body)
  1752. if ioErr != nil {
  1753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1754. }
  1755. var respJSON map[string]interface{}
  1756. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1759. return
  1760. }
  1761. var resSix10265 ResultSix10265 //1101结果
  1762. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1763. result, _ := json.Marshal(respJSON)
  1764. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1765. utils.ErrorLog("解析失败:%v", err)
  1766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1767. return
  1768. }
  1769. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1770. //res.Output = resSix10265.Output
  1771. res2.ErrMsg = resSix10265.ErrMsg
  1772. res2.Cainfo = resSix10265.Cainfo
  1773. res2.WarnMsg = resSix10265.WarnMsg
  1774. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1775. res2.Infcode = infocode
  1776. }
  1777. if res2.Infcode == 0 {
  1778. item.IsChange = 0
  1779. item.BgBchno = ""
  1780. service.SaveDF2(item)
  1781. } else {
  1782. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1783. }
  1784. }
  1785. } else {
  1786. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1787. }
  1788. }
  1789. if item.IsSale == 1 && item.IsChange == 0 {
  1790. var res FJ3507Result
  1791. var struct3507 models.Struct3507
  1792. struct3507.FixmedinsBchno = item.Bchno
  1793. struct3507.InvDataType = "4"
  1794. struct3507.Opter = roles.UserName
  1795. struct3507.FixmedinsCode = miConfig.Code
  1796. struct3507.Code = miConfig.Code
  1797. struct3507.OrgName = miConfig.OrgName
  1798. struct3507.AccessKey = miConfig.AccessKey
  1799. struct3507.RequestUrl = miConfig.Url
  1800. struct3507.SecretKey = miConfig.SecretKey
  1801. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1802. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1803. struct3507.Url = miConfig.Url
  1804. struct3507.AppId = miConfig.Cainfo
  1805. struct3507.AppSecret = miConfig.AppSecret
  1806. struct3507.Enckey = miConfig.EncKey
  1807. struct3507.SignKey = miConfig.SignKey
  1808. struct3507.SecretKey = miConfig.SecretKey
  1809. //result, result1, _ := service.FJyb3507(struct3507)
  1810. //saveLog(result, result1, "3507", "3507")
  1811. //
  1812. //var respJSON3 map[string]interface{}
  1813. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1814. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1816. // return
  1817. //}
  1818. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1819. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1820. // utils.ErrorLog("解析失败:%v", err)
  1821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1822. // return
  1823. //}
  1824. if miConfig.MdtrtareaAdmvs == "350500" {
  1825. result, result1, _ := service.FJyb3507(struct3507)
  1826. saveLog(result, result1, "3507", "3507")
  1827. var respJSON2 map[string]interface{}
  1828. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1831. return
  1832. }
  1833. userJSONBytes2, _ := json.Marshal(respJSON2)
  1834. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1835. utils.ErrorLog("解析失败:%v", err)
  1836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1837. return
  1838. }
  1839. } else {
  1840. data := make(map[string]interface{})
  1841. data["struct_3507s"] = struct3507
  1842. client := &http.Client{}
  1843. bytesData, _ := json.Marshal(data)
  1844. var req *http.Request
  1845. if miConfig.MdtrtareaAdmvs == "320921" {
  1846. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1847. } else {
  1848. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1849. }
  1850. resp, _ := client.Do(req)
  1851. defer resp.Body.Close()
  1852. body, ioErr := ioutil.ReadAll(resp.Body)
  1853. if ioErr != nil {
  1854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1855. }
  1856. var respJSON map[string]interface{}
  1857. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1860. return
  1861. }
  1862. var resSix10265 ResultSix10265 //1101结果
  1863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1864. result, _ := json.Marshal(respJSON)
  1865. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1866. utils.ErrorLog("解析失败:%v", err)
  1867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1868. return
  1869. }
  1870. res.InfRefmsgid = resSix10265.InfRefmsgid
  1871. //res.Output = resSix10265.Output
  1872. res.ErrMsg = resSix10265.ErrMsg
  1873. res.Cainfo = resSix10265.Cainfo
  1874. res.WarnMsg = resSix10265.WarnMsg
  1875. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1876. res.Infcode = infocode
  1877. }
  1878. if res.Infcode == 0 {
  1879. item.IsSale = 0
  1880. item.SaleDate = ""
  1881. service.SaveDF(item)
  1882. } else {
  1883. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1884. }
  1885. }
  1886. if item.IsSale == 2 && item.IsChange == 0 {
  1887. var res FJ3507Result
  1888. var struct3507 models.Struct3507
  1889. struct3507.FixmedinsBchno = item.Bchno
  1890. struct3507.InvDataType = "4"
  1891. struct3507.Opter = roles.UserName
  1892. struct3507.FixmedinsCode = miConfig.Code
  1893. struct3507.Code = miConfig.Code
  1894. struct3507.OrgName = miConfig.OrgName
  1895. struct3507.AccessKey = miConfig.AccessKey
  1896. struct3507.RequestUrl = miConfig.Url
  1897. struct3507.SecretKey = miConfig.SecretKey
  1898. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1899. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1900. struct3507.Url = miConfig.Url
  1901. struct3507.AppId = miConfig.Cainfo
  1902. struct3507.AppSecret = miConfig.AppSecret
  1903. struct3507.Enckey = miConfig.EncKey
  1904. struct3507.SignKey = miConfig.SignKey
  1905. struct3507.SecretKey = miConfig.SecretKey
  1906. //result, result1, _ := service.FJyb3507(struct3507)
  1907. //saveLog(result, result1, "3507", "3507")
  1908. //
  1909. //var respJSON3 map[string]interface{}
  1910. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1911. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1913. // return
  1914. //}
  1915. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1916. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1917. // utils.ErrorLog("解析失败:%v", err)
  1918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1919. // return
  1920. //}
  1921. if miConfig.MdtrtareaAdmvs == "350500" {
  1922. result, result1, _ := service.FJyb3507(struct3507)
  1923. saveLog(result, result1, "3507", "3507")
  1924. var respJSON2 map[string]interface{}
  1925. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1928. return
  1929. }
  1930. userJSONBytes2, _ := json.Marshal(respJSON2)
  1931. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1932. utils.ErrorLog("解析失败:%v", err)
  1933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1934. return
  1935. }
  1936. } else {
  1937. data := make(map[string]interface{})
  1938. data["struct_3507s"] = struct3507
  1939. client := &http.Client{}
  1940. bytesData, _ := json.Marshal(data)
  1941. var req *http.Request
  1942. if miConfig.MdtrtareaAdmvs == "320921" {
  1943. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1944. } else {
  1945. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1946. }
  1947. resp, _ := client.Do(req)
  1948. defer resp.Body.Close()
  1949. body, ioErr := ioutil.ReadAll(resp.Body)
  1950. if ioErr != nil {
  1951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1952. }
  1953. var respJSON map[string]interface{}
  1954. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1957. return
  1958. }
  1959. var resSix10265 ResultSix10265 //1101结果
  1960. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1961. result, _ := json.Marshal(respJSON)
  1962. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1963. utils.ErrorLog("解析失败:%v", err)
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1965. return
  1966. }
  1967. res.InfRefmsgid = resSix10265.InfRefmsgid
  1968. //res.Output = resSix10265.Output
  1969. res.ErrMsg = resSix10265.ErrMsg
  1970. res.Cainfo = resSix10265.Cainfo
  1971. res.WarnMsg = resSix10265.WarnMsg
  1972. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1973. res.Infcode = infocode
  1974. }
  1975. if res.Infcode == 0 {
  1976. item.IsSale = 0
  1977. item.SaleDate = ""
  1978. item.Bchno = ""
  1979. service.SaveDF(item)
  1980. } else {
  1981. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1982. }
  1983. }
  1984. if item.IsSale == 0 && item.IsChange == 1 {
  1985. var res FJ3507Result
  1986. var struct3507 models.Struct3507
  1987. struct3507.FixmedinsBchno = item.BgBchno
  1988. struct3507.InvDataType = "2"
  1989. struct3507.Opter = roles.UserName
  1990. struct3507.FixmedinsCode = miConfig.Code
  1991. struct3507.Code = miConfig.Code
  1992. struct3507.OrgName = miConfig.OrgName
  1993. struct3507.AccessKey = miConfig.AccessKey
  1994. struct3507.RequestUrl = miConfig.Url
  1995. struct3507.SecretKey = miConfig.SecretKey
  1996. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1997. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1998. struct3507.Url = miConfig.Url
  1999. struct3507.AppId = miConfig.Cainfo
  2000. struct3507.AppSecret = miConfig.AppSecret
  2001. struct3507.Enckey = miConfig.EncKey
  2002. struct3507.SignKey = miConfig.SignKey
  2003. struct3507.SecretKey = miConfig.SecretKey
  2004. //result, result1, _ := service.FJyb3507(struct3507)
  2005. //saveLog(result, result1, "3507", "3507")
  2006. //
  2007. //var respJSON3 map[string]interface{}
  2008. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2009. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2010. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2011. // return
  2012. //}
  2013. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2014. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2015. // utils.ErrorLog("解析失败:%v", err)
  2016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2017. // return
  2018. //}
  2019. if miConfig.MdtrtareaAdmvs == "350500" {
  2020. result, result1, _ := service.FJyb3507(struct3507)
  2021. saveLog(result, result1, "3507", "3507")
  2022. var respJSON2 map[string]interface{}
  2023. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2026. return
  2027. }
  2028. userJSONBytes2, _ := json.Marshal(respJSON2)
  2029. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2030. utils.ErrorLog("解析失败:%v", err)
  2031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2032. return
  2033. }
  2034. } else {
  2035. data := make(map[string]interface{})
  2036. data["struct_3507s"] = struct3507
  2037. client := &http.Client{}
  2038. bytesData, _ := json.Marshal(data)
  2039. var req *http.Request
  2040. if miConfig.MdtrtareaAdmvs == "320921" {
  2041. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2042. } else {
  2043. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2044. }
  2045. resp, _ := client.Do(req)
  2046. defer resp.Body.Close()
  2047. body, ioErr := ioutil.ReadAll(resp.Body)
  2048. if ioErr != nil {
  2049. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2050. }
  2051. var respJSON map[string]interface{}
  2052. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2055. return
  2056. }
  2057. var resSix10265 ResultSix10265 //1101结果
  2058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2059. result, _ := json.Marshal(respJSON)
  2060. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2061. utils.ErrorLog("解析失败:%v", err)
  2062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2063. return
  2064. }
  2065. res.InfRefmsgid = resSix10265.InfRefmsgid
  2066. //res.Output = resSix10265.Output
  2067. res.ErrMsg = resSix10265.ErrMsg
  2068. res.Cainfo = resSix10265.Cainfo
  2069. res.WarnMsg = resSix10265.WarnMsg
  2070. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2071. res.Infcode = infocode
  2072. }
  2073. if res.Infcode == 0 {
  2074. item.IsChange = 0
  2075. item.BgBchno = ""
  2076. service.SaveDF2(item)
  2077. } else {
  2078. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2079. }
  2080. }
  2081. }
  2082. if len(err) == 0 {
  2083. c.ServeSuccessJSON(map[string]interface{}{
  2084. "msg": "删除销售变更成功",
  2085. })
  2086. } else {
  2087. c.ServeSuccessJSON(map[string]interface{}{
  2088. "failed_code": -10,
  2089. "msg": err,
  2090. })
  2091. }
  2092. }
  2093. //func (c *HisApiController) BatchFJ3501AND3502() {
  2094. // //ids := c.GetString("ids")
  2095. // start_time := c.GetString("start_time")
  2096. // end_time := c.GetString("end_time")
  2097. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2098. //
  2099. //
  2100. // timeLayout := "2006-01-02"
  2101. // loc, _ := time.LoadLocation("Local")
  2102. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2103. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2104. //
  2105. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2106. // //id_arr := strings.Split(ids, ",")
  2107. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2108. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2109. // //库盘
  2110. // var errs []string
  2111. // for _, drug := range drugs {
  2112. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2113. // var res2 ResultSix
  2114. // var res3 ResultSix
  2115. //
  2116. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2117. // var struct3501 models.Struct3501
  2118. // struct3501.Code = miConfig.Code
  2119. // struct3501.OrgName = miConfig.OrgName
  2120. // struct3501.AccessKey = miConfig.AccessKey
  2121. // struct3501.Opter = roles.UserName
  2122. // struct3501.RequestUrl = miConfig.Url
  2123. // struct3501.Url = miConfig.Url
  2124. // struct3501.AppId = miConfig.Cainfo
  2125. // struct3501.AppSecret = miConfig.AppSecret
  2126. // struct3501.Enckey = miConfig.EncKey
  2127. // struct3501.SignKey = miConfig.SignKey
  2128. // struct3501.SecretKey = miConfig.SecretKey
  2129. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2130. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2131. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2132. // struct3501.RxFlag = "1"
  2133. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2134. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2135. //
  2136. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2137. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2138. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2139. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2140. // struct3501.FixmedinsBchno = number
  2141. // struct3501.DrugTracCodg = drug.DrugCode
  2142. // memo := make(map[string]interface{})
  2143. // memo["pric"] = drug.Price
  2144. // bytesData, _ := json.Marshal(memo)
  2145. // struct3501.Memo = string(bytesData)
  2146. //
  2147. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2148. //
  2149. // result1, result2, _ := service.FJyb3501(struct3501)
  2150. // saveLog(result1, result2, "3501", "3501")
  2151. // //saveLog(result, requestLog, "2201", "挂号")
  2152. //
  2153. // var respJSON2 map[string]interface{}
  2154. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2155. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2157. // return
  2158. // }
  2159. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2160. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2161. // utils.ErrorLog("解析失败:%v", err)
  2162. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2163. // return
  2164. // }
  2165. //
  2166. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2167. // data := make(map[string]interface{})
  2168. // data["struct_3501s"] = struct3501
  2169. // client := &http.Client{}
  2170. // bytesData, _ := json.Marshal(data)
  2171. // var req *http.Request
  2172. // if miConfig.MdtrtareaAdmvs == "320921" {
  2173. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2174. // } else {
  2175. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2176. // }
  2177. //
  2178. // resp, _ := client.Do(req)
  2179. // defer resp.Body.Close()
  2180. // body, ioErr := ioutil.ReadAll(resp.Body)
  2181. // if ioErr != nil {
  2182. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2183. // }
  2184. // var respJSON map[string]interface{}
  2185. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2186. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2188. // return
  2189. // }
  2190. // var resSix10265 ResultSix10265 //1101结果
  2191. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2192. // result, _ := json.Marshal(respJSON)
  2193. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2194. // utils.ErrorLog("解析失败:%v", err)
  2195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2196. // return
  2197. // }
  2198. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2199. // res2.Output = resSix10265.Output
  2200. // res2.ErrMsg = resSix10265.ErrMsg
  2201. // res2.Cainfo = resSix10265.Cainfo
  2202. // res2.WarnMsg = resSix10265.WarnMsg
  2203. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2204. // res2.Infcode = infocode
  2205. //
  2206. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2207. // data := make(map[string]interface{})
  2208. // data["struct_3501s"] = struct3501
  2209. // client := &http.Client{}
  2210. // bytesData, _ := json.Marshal(data)
  2211. // var req *http.Request
  2212. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2213. // resp, _ := client.Do(req)
  2214. // defer resp.Body.Close()
  2215. // body, ioErr := ioutil.ReadAll(resp.Body)
  2216. // if ioErr != nil {
  2217. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2218. // }
  2219. // var respJSON map[string]interface{}
  2220. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2221. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2223. // return
  2224. // }
  2225. // var resSix10265 ResultSix10265 //1101结果
  2226. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2227. // result, _ := json.Marshal(respJSON)
  2228. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2229. // utils.ErrorLog("解析失败:%v", err)
  2230. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2231. // return
  2232. // }
  2233. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2234. // res2.Output = resSix10265.Output
  2235. // res2.ErrMsg = resSix10265.ErrMsg
  2236. // res2.Cainfo = resSix10265.Cainfo
  2237. // res2.WarnMsg = resSix10265.WarnMsg
  2238. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2239. // res2.Infcode = infocode
  2240. //
  2241. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2242. // data := make(map[string]interface{})
  2243. // data["struct_3501s"] = struct3501
  2244. // client := &http.Client{}
  2245. // bytesData, _ := json.Marshal(data)
  2246. // var req *http.Request
  2247. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2248. // resp, _ := client.Do(req)
  2249. // defer resp.Body.Close()
  2250. // body, ioErr := ioutil.ReadAll(resp.Body)
  2251. // if ioErr != nil {
  2252. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2253. // }
  2254. // var respJSON map[string]interface{}
  2255. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2256. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2258. // return
  2259. // }
  2260. // var resSix10265 ResultSix10265 //1101结果
  2261. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2262. // result, _ := json.Marshal(respJSON)
  2263. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2264. // utils.ErrorLog("解析失败:%v", err)
  2265. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2266. // return
  2267. // }
  2268. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2269. // res2.Output = resSix10265.Output
  2270. // res2.ErrMsg = resSix10265.ErrMsg
  2271. // res2.Cainfo = resSix10265.Cainfo
  2272. // res2.WarnMsg = resSix10265.WarnMsg
  2273. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2274. // res2.Infcode = infocode
  2275. //
  2276. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2277. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2278. // saveLog(result1, result2, "3501", "3501")
  2279. // //saveLog(result, requestLog, "2201", "挂号")
  2280. //
  2281. // var respJSON2 map[string]interface{}
  2282. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2283. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2285. // return
  2286. // }
  2287. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2288. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2289. // utils.ErrorLog("解析失败:%v", err)
  2290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2291. // return
  2292. // }
  2293. //
  2294. // }
  2295. //
  2296. // if res2.Infcode != -1 {
  2297. // drug.IsPc = 1
  2298. // drug.Bchno = number
  2299. // drug.PcDate = time.Now().Unix()
  2300. // err := service.SaveW(drug)
  2301. // if err == nil {
  2302. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2303. // var struct3502 models.Struct3502
  2304. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2305. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2306. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2307. // struct3502.FixmedinsCode = miConfig.Code
  2308. // struct3502.Code = miConfig.Code
  2309. //
  2310. // struct3502.RxFlag = "0"
  2311. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2312. // struct3502.OrgName = miConfig.OrgName
  2313. // struct3502.Opter = roles.UserName
  2314. // struct3502.AccessKey = miConfig.AccessKey
  2315. // struct3502.RequestUrl = miConfig.Url
  2316. // struct3502.SecretKey = miConfig.SecretKey
  2317. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2318. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2319. // struct3502.Url = miConfig.Url
  2320. // struct3502.AppId = miConfig.Cainfo
  2321. // struct3502.AppSecret = miConfig.AppSecret
  2322. // struct3502.Enckey = miConfig.EncKey
  2323. // struct3502.SignKey = miConfig.SignKey
  2324. // struct3502.SecretKey = miConfig.SecretKey
  2325. // struct3502.DrugTracCodg = drug.DrugCode
  2326. //
  2327. // struct3502.Memo = ""
  2328. // struct3502.InvChgType = "108"
  2329. // struct3502.FixmedinsBchno = bg_number
  2330. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2331. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2332. //
  2333. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2334. // result11, result22, _ := service.FJyb3502(struct3502)
  2335. // saveLog(result11, result22, "3502", "3502")
  2336. //
  2337. // var respJSON3 map[string]interface{}
  2338. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2339. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2340. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2341. // return
  2342. // }
  2343. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2344. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2345. // utils.ErrorLog("解析失败:%v", err)
  2346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2347. // return
  2348. // }
  2349. //
  2350. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2351. // data := make(map[string]interface{})
  2352. // data["struct_3502s"] = struct3502
  2353. // client := &http.Client{}
  2354. // bytesData, _ := json.Marshal(data)
  2355. // var req *http.Request
  2356. // if miConfig.MdtrtareaAdmvs == "320921" {
  2357. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2358. // } else {
  2359. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2360. // }
  2361. //
  2362. // resp, _ := client.Do(req)
  2363. // defer resp.Body.Close()
  2364. // body, ioErr := ioutil.ReadAll(resp.Body)
  2365. // if ioErr != nil {
  2366. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2367. // }
  2368. // var respJSON map[string]interface{}
  2369. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2370. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2371. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2372. // return
  2373. // }
  2374. // var resSix10265 ResultSix10265 //1101结果
  2375. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2376. // result, _ := json.Marshal(respJSON)
  2377. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2378. // utils.ErrorLog("解析失败:%v", err)
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. // return
  2381. // }
  2382. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2383. // res3.Output = resSix10265.Output
  2384. // res3.ErrMsg = resSix10265.ErrMsg
  2385. // res3.Cainfo = resSix10265.Cainfo
  2386. // res3.WarnMsg = resSix10265.WarnMsg
  2387. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2388. // res3.Infcode = infocode
  2389. //
  2390. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2391. //
  2392. // data := make(map[string]interface{})
  2393. // data["struct_3502s"] = struct3502
  2394. // client := &http.Client{}
  2395. // bytesData, _ := json.Marshal(data)
  2396. // var req *http.Request
  2397. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2398. // resp, _ := client.Do(req)
  2399. // defer resp.Body.Close()
  2400. // body, ioErr := ioutil.ReadAll(resp.Body)
  2401. // if ioErr != nil {
  2402. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2403. // }
  2404. // var respJSON map[string]interface{}
  2405. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2406. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2408. // return
  2409. // }
  2410. // var resSix10265 ResultSix10265 //1101结果
  2411. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2412. // result, _ := json.Marshal(respJSON)
  2413. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2414. // utils.ErrorLog("解析失败:%v", err)
  2415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2416. // return
  2417. // }
  2418. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2419. // res3.Output = resSix10265.Output
  2420. // res3.ErrMsg = resSix10265.ErrMsg
  2421. // res3.Cainfo = resSix10265.Cainfo
  2422. // res3.WarnMsg = resSix10265.WarnMsg
  2423. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2424. // res3.Infcode = infocode
  2425. //
  2426. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2427. //
  2428. // data := make(map[string]interface{})
  2429. // data["struct_3501s"] = struct3501
  2430. // client := &http.Client{}
  2431. // bytesData, _ := json.Marshal(data)
  2432. // var req *http.Request
  2433. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2434. // resp, _ := client.Do(req)
  2435. // defer resp.Body.Close()
  2436. // body, ioErr := ioutil.ReadAll(resp.Body)
  2437. // if ioErr != nil {
  2438. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2439. // }
  2440. // var respJSON map[string]interface{}
  2441. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2442. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2444. // return
  2445. // }
  2446. // var resSix10265 ResultSix10265 //1101结果
  2447. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2448. // result, _ := json.Marshal(respJSON)
  2449. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2450. // utils.ErrorLog("解析失败:%v", err)
  2451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2452. // return
  2453. // }
  2454. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2455. // res2.Output = resSix10265.Output
  2456. // res2.ErrMsg = resSix10265.ErrMsg
  2457. // res2.Cainfo = resSix10265.Cainfo
  2458. // res2.WarnMsg = resSix10265.WarnMsg
  2459. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2460. // res2.Infcode = infocode
  2461. //
  2462. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2463. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2464. // saveLog(result11, result22, "3502", "3502")
  2465. //
  2466. // var respJSON3 map[string]interface{}
  2467. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2468. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2469. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2470. // return
  2471. // }
  2472. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2473. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2474. // utils.ErrorLog("解析失败:%v", err)
  2475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2476. // return
  2477. // }
  2478. // }
  2479. // if res3.Infcode == -1 {
  2480. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2481. // c.ServeSuccessJSON(map[string]interface{}{
  2482. // "failed_code": -10,
  2483. // "msg": res3.ErrMsg,
  2484. // })
  2485. // } else {
  2486. // drug.IsBg = 1
  2487. // drug.BgBchno = bg_number
  2488. // service.SaveW(drug)
  2489. // }
  2490. // }
  2491. // } else {
  2492. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2493. // }
  2494. // }
  2495. // //变更
  2496. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2497. // var res3 ResultSix
  2498. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2499. //
  2500. // var struct3502 models.Struct3502
  2501. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2502. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2503. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2504. // struct3502.FixmedinsCode = miConfig.Code
  2505. // struct3502.Code = miConfig.Code
  2506. //
  2507. // struct3502.Opter = roles.UserName
  2508. // struct3502.RxFlag = "0"
  2509. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2510. // struct3502.OrgName = miConfig.OrgName
  2511. // struct3502.AccessKey = miConfig.AccessKey
  2512. // struct3502.RequestUrl = miConfig.Url
  2513. // struct3502.SecretKey = miConfig.SecretKey
  2514. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2515. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2516. // struct3502.InvChgType = "108"
  2517. // struct3502.DrugTracCodg = drug.DrugCode
  2518. //
  2519. // struct3502.Url = miConfig.Url
  2520. // struct3502.AppId = miConfig.Cainfo
  2521. // struct3502.AppSecret = miConfig.AppSecret
  2522. // struct3502.Enckey = miConfig.EncKey
  2523. // struct3502.SignKey = miConfig.SignKey
  2524. // struct3502.SecretKey = miConfig.SecretKey
  2525. //
  2526. // struct3502.FixmedinsBchno = bg_number
  2527. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2528. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2529. //
  2530. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2531. // result1, result2, _ := service.FJyb3502(struct3502)
  2532. // saveLog(result1, result2, "3502", "3502")
  2533. // var respJSON3 map[string]interface{}
  2534. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2535. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2537. // return
  2538. // }
  2539. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2540. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2541. // utils.ErrorLog("解析失败:%v", err)
  2542. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2543. // return
  2544. // }
  2545. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2546. // data := make(map[string]interface{})
  2547. // data["struct_3502s"] = struct3502
  2548. // client := &http.Client{}
  2549. // bytesData, _ := json.Marshal(data)
  2550. // var req *http.Request
  2551. // if miConfig.MdtrtareaAdmvs == "320921" {
  2552. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2553. // } else {
  2554. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2555. // }
  2556. // resp, _ := client.Do(req)
  2557. // defer resp.Body.Close()
  2558. // body, ioErr := ioutil.ReadAll(resp.Body)
  2559. // if ioErr != nil {
  2560. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2561. // }
  2562. // var respJSON map[string]interface{}
  2563. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2564. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2565. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2566. // return
  2567. // }
  2568. // var resSix10265 ResultSix10265 //1101结果
  2569. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2570. // result, _ := json.Marshal(respJSON)
  2571. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2572. // utils.ErrorLog("解析失败:%v", err)
  2573. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2574. // return
  2575. // }
  2576. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2577. // res3.Output = resSix10265.Output
  2578. // res3.ErrMsg = resSix10265.ErrMsg
  2579. // res3.Cainfo = resSix10265.Cainfo
  2580. // res3.WarnMsg = resSix10265.WarnMsg
  2581. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2582. // res3.Infcode = infocode
  2583. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2584. //
  2585. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2586. //
  2587. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2588. //
  2589. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2590. //
  2591. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2592. // saveLog(result1, result2, "3501", "3501")
  2593. // //saveLog(result, requestLog, "2201", "挂号")
  2594. //
  2595. // var respJSON2 map[string]interface{}
  2596. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2597. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2599. // return
  2600. // }
  2601. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2602. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2603. // utils.ErrorLog("解析失败:%v", err)
  2604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2605. // return
  2606. // }
  2607. //
  2608. // }
  2609. // if res3.Infcode == -1 {
  2610. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2611. // } else {
  2612. // drug.IsBg = 1
  2613. // drug.BgBchno = bg_number
  2614. // service.SaveW(drug)
  2615. // }
  2616. // }
  2617. // }
  2618. //
  2619. // if len(errs) == 0 {
  2620. // c.ServeSuccessJSON(map[string]interface{}{
  2621. // "msg": "盘存变更成功",
  2622. // })
  2623. // } else {
  2624. // c.ServeSuccessJSON(map[string]interface{}{
  2625. // "failed_code": -10,
  2626. // "msg": errs,
  2627. // })
  2628. // }
  2629. //}
  2630. //func (c *HisApiController) DeleteXSandBGTwo() {
  2631. // patient_id, _ := c.GetInt64("patient_id")
  2632. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2633. // //id_arr := strings.Split(ids, ",")
  2634. // times := c.GetString("time", "")
  2635. // timeLayout := "2006-01-02"
  2636. // loc, _ := time.LoadLocation("Local")
  2637. // var stime, etime int64
  2638. // if times == "" {
  2639. // stime, etime = GetNowTime()
  2640. // } else {
  2641. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2642. // stime = stmp.Unix()
  2643. // etime = stime + 86399
  2644. // }
  2645. // advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2646. // var flows []*models.DrugFlow
  2647. // for _, item := range advicelist {
  2648. // flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2649. // flows = append(flows, flow...)
  2650. // }
  2651. //
  2652. // //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2653. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2654. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2655. //
  2656. // var err []string
  2657. // for _, item := range flows {
  2658. // if item.IsSale == 1 && item.IsChange == 1 {
  2659. // var res FJ3507Result
  2660. // var res2 FJ3507Result
  2661. //
  2662. // var struct3507 models.Struct3507
  2663. // struct3507.FixmedinsBchno = item.Bchno
  2664. // struct3507.InvDataType = "4"
  2665. // struct3507.Opter = roles.UserName
  2666. // struct3507.OrgName = miConfig.OrgName
  2667. // struct3507.AccessKey = miConfig.AccessKey
  2668. // struct3507.RequestUrl = miConfig.Url
  2669. // struct3507.FixmedinsCode = miConfig.Code
  2670. // struct3507.SecretKey = miConfig.SecretKey
  2671. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2672. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2673. // struct3507.Url = miConfig.Url
  2674. // struct3507.AppId = miConfig.Cainfo
  2675. // struct3507.AppSecret = miConfig.AppSecret
  2676. // struct3507.Enckey = miConfig.EncKey
  2677. // struct3507.SignKey = miConfig.SignKey
  2678. // struct3507.SecretKey = miConfig.SecretKey
  2679. //
  2680. // //result, result1, _ := service.FJyb3507(struct3507)
  2681. // //saveLog(result, result1, "3507", "3507")
  2682. //
  2683. // if miConfig.MdtrtareaAdmvs == "350500" {
  2684. // result, result1, _ := service.FJyb3507(struct3507)
  2685. // saveLog(result, result1, "3507", "3507")
  2686. // var respJSON2 map[string]interface{}
  2687. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2688. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2690. // return
  2691. // }
  2692. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2693. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2694. // utils.ErrorLog("解析失败:%v", err)
  2695. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2696. // return
  2697. // }
  2698. // } else {
  2699. // data := make(map[string]interface{})
  2700. // data["struct_3507s"] = struct3507
  2701. // client := &http.Client{}
  2702. // bytesData, _ := json.Marshal(data)
  2703. // var req *http.Request
  2704. // if miConfig.MdtrtareaAdmvs == "320921" {
  2705. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2706. // } else {
  2707. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2708. // }
  2709. //
  2710. // resp, _ := client.Do(req)
  2711. // defer resp.Body.Close()
  2712. // body, ioErr := ioutil.ReadAll(resp.Body)
  2713. // if ioErr != nil {
  2714. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2715. // }
  2716. // var respJSON map[string]interface{}
  2717. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2718. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2720. // return
  2721. // }
  2722. // var resSix10265 ResultSix10265 //1101结果
  2723. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2724. // result, _ := json.Marshal(respJSON)
  2725. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2726. // utils.ErrorLog("解析失败:%v", err)
  2727. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2728. // return
  2729. // }
  2730. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2731. // //res.Output = resSix10265.Output
  2732. // res.ErrMsg = resSix10265.ErrMsg
  2733. // res.Cainfo = resSix10265.Cainfo
  2734. // res.WarnMsg = resSix10265.WarnMsg
  2735. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2736. // res.Infcode = infocode
  2737. // }
  2738. //
  2739. // if res.Infcode == 0 {
  2740. // item.IsSale = 0
  2741. // item.SaleDate = ""
  2742. // item.Bchno = ""
  2743. //
  2744. // err2 := service.SaveDF(item)
  2745. // if err2 == nil {
  2746. // var struct3507_2 models.Struct3507
  2747. // struct3507_2.OrgName = miConfig.OrgName
  2748. // struct3507_2.AccessKey = miConfig.AccessKey
  2749. // struct3507_2.RequestUrl = miConfig.Url
  2750. // struct3507_2.Opter = roles.UserName
  2751. // struct3507_2.FixmedinsCode = miConfig.Code
  2752. // struct3507_2.Code = miConfig.Code
  2753. //
  2754. // struct3507_2.SecretKey = miConfig.SecretKey
  2755. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2756. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2757. // struct3507_2.Url = miConfig.Url
  2758. // struct3507_2.AppId = miConfig.Cainfo
  2759. // struct3507_2.AppSecret = miConfig.AppSecret
  2760. // struct3507_2.Enckey = miConfig.EncKey
  2761. // struct3507_2.SignKey = miConfig.SignKey
  2762. // struct3507_2.SecretKey = miConfig.SecretKey
  2763. // struct3507_2.FixmedinsBchno = item.BgBchno
  2764. // struct3507_2.InvDataType = "2"
  2765. //
  2766. // if miConfig.MdtrtareaAdmvs == "350500" {
  2767. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2768. // saveLog(result11, result22, "3507", "3507")
  2769. //
  2770. // var respJSON3 map[string]interface{}
  2771. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2772. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2773. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2774. // return
  2775. // }
  2776. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2777. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2778. // utils.ErrorLog("解析失败:%v", err)
  2779. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2780. // return
  2781. // }
  2782. // } else {
  2783. //
  2784. // data := make(map[string]interface{})
  2785. // data["struct_3507s"] = struct3507_2
  2786. // client := &http.Client{}
  2787. // bytesData, _ := json.Marshal(data)
  2788. // var req *http.Request
  2789. // if miConfig.MdtrtareaAdmvs == "320921" {
  2790. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2791. // } else {
  2792. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2793. // }
  2794. //
  2795. // resp, _ := client.Do(req)
  2796. // defer resp.Body.Close()
  2797. // body, ioErr := ioutil.ReadAll(resp.Body)
  2798. // if ioErr != nil {
  2799. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2800. // }
  2801. // var respJSON map[string]interface{}
  2802. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2803. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2805. // return
  2806. // }
  2807. // var resSix10265 ResultSix10265 //1101结果
  2808. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2809. // result, _ := json.Marshal(respJSON)
  2810. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2811. // utils.ErrorLog("解析失败:%v", err)
  2812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2813. // return
  2814. // }
  2815. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2816. // //res.Output = resSix10265.Output
  2817. // res2.ErrMsg = resSix10265.ErrMsg
  2818. // res2.Cainfo = resSix10265.Cainfo
  2819. // res2.WarnMsg = resSix10265.WarnMsg
  2820. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2821. // res2.Infcode = infocode
  2822. // }
  2823. //
  2824. // if res2.Infcode == 0 {
  2825. // item.IsChange = 0
  2826. // item.BgBchno = ""
  2827. // service.SaveDF2(item)
  2828. // } else {
  2829. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2830. // }
  2831. // }
  2832. // } else {
  2833. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2834. // }
  2835. //
  2836. // }
  2837. // if item.IsSale == 2 && item.IsChange == 1 {
  2838. // var res FJ3507Result
  2839. // var res2 FJ3507Result
  2840. //
  2841. // var struct3507 models.Struct3507
  2842. // struct3507.FixmedinsBchno = item.Bchno
  2843. // struct3507.InvDataType = "4"
  2844. // struct3507.Opter = roles.UserName
  2845. // struct3507.OrgName = miConfig.OrgName
  2846. // struct3507.AccessKey = miConfig.AccessKey
  2847. // struct3507.RequestUrl = miConfig.Url
  2848. // struct3507.FixmedinsCode = miConfig.Code
  2849. // struct3507.Code = miConfig.Code
  2850. //
  2851. // struct3507.SecretKey = miConfig.SecretKey
  2852. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2853. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2854. // struct3507.Url = miConfig.Url
  2855. // struct3507.AppId = miConfig.Cainfo
  2856. // struct3507.AppSecret = miConfig.AppSecret
  2857. // struct3507.Enckey = miConfig.EncKey
  2858. // struct3507.SignKey = miConfig.SignKey
  2859. // struct3507.SecretKey = miConfig.SecretKey
  2860. // //result, result1, _ := service.FJyb3507(struct3507)
  2861. // //saveLog(result, result1, "3507", "3507")
  2862. // //
  2863. // //var respJSON2 map[string]interface{}
  2864. // //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2865. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2866. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2867. // // return
  2868. // //}
  2869. // //userJSONBytes2, _ := json.Marshal(respJSON2)
  2870. // //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2871. // // utils.ErrorLog("解析失败:%v", err)
  2872. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2873. // // return
  2874. // //}
  2875. //
  2876. // if miConfig.MdtrtareaAdmvs == "350500" {
  2877. // result, result1, _ := service.FJyb3507(struct3507)
  2878. // saveLog(result, result1, "3507", "3507")
  2879. // var respJSON2 map[string]interface{}
  2880. // if err := json.Unmarshal([]byte(string(result)), &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 {
  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. // if miConfig.MdtrtareaAdmvs == "320921" {
  2898. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2899. // } else {
  2900. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2901. // }
  2902. //
  2903. // resp, _ := client.Do(req)
  2904. // defer resp.Body.Close()
  2905. // body, ioErr := ioutil.ReadAll(resp.Body)
  2906. // if ioErr != nil {
  2907. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2908. // }
  2909. // var respJSON map[string]interface{}
  2910. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2911. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2913. // return
  2914. // }
  2915. // var resSix10265 ResultSix10265 //1101结果
  2916. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2917. // result, _ := json.Marshal(respJSON)
  2918. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2919. // utils.ErrorLog("解析失败:%v", err)
  2920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2921. // return
  2922. // }
  2923. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2924. // //res.Output = resSix10265.Output
  2925. // res.ErrMsg = resSix10265.ErrMsg
  2926. // res.Cainfo = resSix10265.Cainfo
  2927. // res.WarnMsg = resSix10265.WarnMsg
  2928. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2929. // res.Infcode = infocode
  2930. // }
  2931. //
  2932. // if res.Infcode == 0 {
  2933. // item.IsSale = 0
  2934. // item.SaleDate = ""
  2935. // item.Bchno = ""
  2936. // err2 := service.SaveDF(item)
  2937. // if err2 == nil {
  2938. // var struct3507_2 models.Struct3507
  2939. // struct3507_2.OrgName = miConfig.OrgName
  2940. // struct3507_2.AccessKey = miConfig.AccessKey
  2941. // struct3507_2.RequestUrl = miConfig.Url
  2942. // struct3507_2.Opter = roles.UserName
  2943. // struct3507_2.FixmedinsCode = miConfig.Code
  2944. // struct3507_2.Code = miConfig.Code
  2945. //
  2946. // struct3507_2.SecretKey = miConfig.SecretKey
  2947. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2948. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2949. // struct3507_2.Url = miConfig.Url
  2950. // struct3507_2.AppId = miConfig.Cainfo
  2951. // struct3507_2.AppSecret = miConfig.AppSecret
  2952. // struct3507_2.Enckey = miConfig.EncKey
  2953. // struct3507_2.SignKey = miConfig.SignKey
  2954. // struct3507_2.SecretKey = miConfig.SecretKey
  2955. // struct3507_2.FixmedinsBchno = item.BgBchno
  2956. // struct3507_2.InvDataType = "2"
  2957. //
  2958. // //result11, result22, _ := service.FJyb3507(struct3507_2)
  2959. // //saveLog(result11, result22, "3507", "3507")
  2960. // //var respJSON3 map[string]interface{}
  2961. // //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2962. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2963. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2964. // // return
  2965. // //}
  2966. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2967. // //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2968. // // utils.ErrorLog("解析失败:%v", err)
  2969. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2970. // // return
  2971. // //}
  2972. //
  2973. // if miConfig.MdtrtareaAdmvs == "350500" {
  2974. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2975. // saveLog(result11, result22, "3507", "3507")
  2976. //
  2977. // var respJSON3 map[string]interface{}
  2978. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2979. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2980. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2981. // return
  2982. // }
  2983. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2984. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2985. // utils.ErrorLog("解析失败:%v", err)
  2986. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2987. // return
  2988. // }
  2989. // } else {
  2990. //
  2991. // data := make(map[string]interface{})
  2992. // data["struct_3507s"] = struct3507_2
  2993. // client := &http.Client{}
  2994. // bytesData, _ := json.Marshal(data)
  2995. // var req *http.Request
  2996. // if miConfig.MdtrtareaAdmvs == "320921" {
  2997. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2998. // } else {
  2999. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3000. // }
  3001. //
  3002. // resp, _ := client.Do(req)
  3003. // defer resp.Body.Close()
  3004. // body, ioErr := ioutil.ReadAll(resp.Body)
  3005. // if ioErr != nil {
  3006. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3007. // }
  3008. // var respJSON map[string]interface{}
  3009. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3010. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3011. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3012. // return
  3013. // }
  3014. // var resSix10265 ResultSix10265 //1101结果
  3015. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3016. // result, _ := json.Marshal(respJSON)
  3017. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3018. // utils.ErrorLog("解析失败:%v", err)
  3019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3020. // return
  3021. // }
  3022. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  3023. // //res.Output = resSix10265.Output
  3024. // res2.ErrMsg = resSix10265.ErrMsg
  3025. // res2.Cainfo = resSix10265.Cainfo
  3026. // res2.WarnMsg = resSix10265.WarnMsg
  3027. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3028. // res2.Infcode = infocode
  3029. // }
  3030. // if res2.Infcode == 0 {
  3031. // item.IsChange = 0
  3032. // item.BgBchno = ""
  3033. // service.SaveDF2(item)
  3034. // } else {
  3035. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  3036. // }
  3037. // }
  3038. // } else {
  3039. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3040. // }
  3041. //
  3042. // }
  3043. // if item.IsSale == 1 && item.IsChange == 0 {
  3044. //
  3045. // var res FJ3507Result
  3046. // var struct3507 models.Struct3507
  3047. // struct3507.FixmedinsBchno = item.Bchno
  3048. // struct3507.InvDataType = "4"
  3049. // struct3507.Opter = roles.UserName
  3050. // struct3507.FixmedinsCode = miConfig.Code
  3051. // struct3507.Code = miConfig.Code
  3052. //
  3053. // struct3507.OrgName = miConfig.OrgName
  3054. // struct3507.AccessKey = miConfig.AccessKey
  3055. // struct3507.RequestUrl = miConfig.Url
  3056. // struct3507.SecretKey = miConfig.SecretKey
  3057. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3058. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3059. // struct3507.Url = miConfig.Url
  3060. // struct3507.AppId = miConfig.Cainfo
  3061. // struct3507.AppSecret = miConfig.AppSecret
  3062. // struct3507.Enckey = miConfig.EncKey
  3063. // struct3507.SignKey = miConfig.SignKey
  3064. // struct3507.SecretKey = miConfig.SecretKey
  3065. // //result, result1, _ := service.FJyb3507(struct3507)
  3066. // //saveLog(result, result1, "3507", "3507")
  3067. // //
  3068. // //var respJSON3 map[string]interface{}
  3069. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3070. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3071. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3072. // // return
  3073. // //}
  3074. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  3075. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3076. // // utils.ErrorLog("解析失败:%v", err)
  3077. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3078. // // return
  3079. // //}
  3080. // if miConfig.MdtrtareaAdmvs == "350500" {
  3081. // result, result1, _ := service.FJyb3507(struct3507)
  3082. // saveLog(result, result1, "3507", "3507")
  3083. // var respJSON2 map[string]interface{}
  3084. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3085. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3086. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3087. // return
  3088. // }
  3089. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3090. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3091. // utils.ErrorLog("解析失败:%v", err)
  3092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3093. // return
  3094. // }
  3095. // } else {
  3096. // data := make(map[string]interface{})
  3097. // data["struct_3507s"] = struct3507
  3098. // client := &http.Client{}
  3099. // bytesData, _ := json.Marshal(data)
  3100. // var req *http.Request
  3101. // if miConfig.MdtrtareaAdmvs == "320921" {
  3102. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3103. // } else {
  3104. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3105. // }
  3106. //
  3107. // resp, _ := client.Do(req)
  3108. // defer resp.Body.Close()
  3109. // body, ioErr := ioutil.ReadAll(resp.Body)
  3110. // if ioErr != nil {
  3111. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3112. // }
  3113. // var respJSON map[string]interface{}
  3114. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3115. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3116. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3117. // return
  3118. // }
  3119. // var resSix10265 ResultSix10265 //1101结果
  3120. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3121. // result, _ := json.Marshal(respJSON)
  3122. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3123. // utils.ErrorLog("解析失败:%v", err)
  3124. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3125. // return
  3126. // }
  3127. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3128. // //res.Output = resSix10265.Output
  3129. // res.ErrMsg = resSix10265.ErrMsg
  3130. // res.Cainfo = resSix10265.Cainfo
  3131. // res.WarnMsg = resSix10265.WarnMsg
  3132. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3133. // res.Infcode = infocode
  3134. // }
  3135. //
  3136. // if res.Infcode == 0 {
  3137. // item.IsSale = 0
  3138. // item.SaleDate = ""
  3139. // service.SaveDF(item)
  3140. // } else {
  3141. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  3142. // }
  3143. // }
  3144. // if item.IsSale == 2 && item.IsChange == 0 {
  3145. //
  3146. // var res FJ3507Result
  3147. // var struct3507 models.Struct3507
  3148. // struct3507.FixmedinsBchno = item.Bchno
  3149. // struct3507.InvDataType = "4"
  3150. // struct3507.Opter = roles.UserName
  3151. // struct3507.FixmedinsCode = miConfig.Code
  3152. // struct3507.Code = miConfig.Code
  3153. //
  3154. // struct3507.OrgName = miConfig.OrgName
  3155. // struct3507.AccessKey = miConfig.AccessKey
  3156. // struct3507.RequestUrl = miConfig.Url
  3157. // struct3507.SecretKey = miConfig.SecretKey
  3158. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3159. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3160. // struct3507.Url = miConfig.Url
  3161. // struct3507.AppId = miConfig.Cainfo
  3162. // struct3507.AppSecret = miConfig.AppSecret
  3163. // struct3507.Enckey = miConfig.EncKey
  3164. // struct3507.SignKey = miConfig.SignKey
  3165. // struct3507.SecretKey = miConfig.SecretKey
  3166. // //result, result1, _ := service.FJyb3507(struct3507)
  3167. // //saveLog(result, result1, "3507", "3507")
  3168. // //
  3169. // //var respJSON3 map[string]interface{}
  3170. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3171. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3172. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3173. // // return
  3174. // //}
  3175. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  3176. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3177. // // utils.ErrorLog("解析失败:%v", err)
  3178. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3179. // // return
  3180. // //}
  3181. // if miConfig.MdtrtareaAdmvs == "350500" {
  3182. // result, result1, _ := service.FJyb3507(struct3507)
  3183. // saveLog(result, result1, "3507", "3507")
  3184. // var respJSON2 map[string]interface{}
  3185. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3186. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3188. // return
  3189. // }
  3190. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3191. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3192. // utils.ErrorLog("解析失败:%v", err)
  3193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3194. // return
  3195. // }
  3196. // } else {
  3197. // data := make(map[string]interface{})
  3198. // data["struct_3507s"] = struct3507
  3199. // client := &http.Client{}
  3200. // bytesData, _ := json.Marshal(data)
  3201. // var req *http.Request
  3202. // if miConfig.MdtrtareaAdmvs == "320921" {
  3203. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3204. // } else {
  3205. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3206. // }
  3207. //
  3208. // resp, _ := client.Do(req)
  3209. // defer resp.Body.Close()
  3210. // body, ioErr := ioutil.ReadAll(resp.Body)
  3211. // if ioErr != nil {
  3212. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3213. // }
  3214. // var respJSON map[string]interface{}
  3215. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3216. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3218. // return
  3219. // }
  3220. // var resSix10265 ResultSix10265 //1101结果
  3221. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3222. // result, _ := json.Marshal(respJSON)
  3223. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3224. // utils.ErrorLog("解析失败:%v", err)
  3225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3226. // return
  3227. // }
  3228. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3229. // //res.Output = resSix10265.Output
  3230. // res.ErrMsg = resSix10265.ErrMsg
  3231. // res.Cainfo = resSix10265.Cainfo
  3232. // res.WarnMsg = resSix10265.WarnMsg
  3233. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3234. // res.Infcode = infocode
  3235. // }
  3236. //
  3237. // if res.Infcode == 0 {
  3238. // item.IsSale = 0
  3239. // item.SaleDate = ""
  3240. // item.Bchno = ""
  3241. //
  3242. // service.SaveDF(item)
  3243. // } else {
  3244. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  3245. // }
  3246. // }
  3247. // if item.IsSale == 0 && item.IsChange == 1 {
  3248. //
  3249. // var res FJ3507Result
  3250. // var struct3507 models.Struct3507
  3251. // struct3507.FixmedinsBchno = item.BgBchno
  3252. // struct3507.InvDataType = "2"
  3253. // struct3507.Opter = roles.UserName
  3254. // struct3507.FixmedinsCode = miConfig.Code
  3255. // struct3507.Code = miConfig.Code
  3256. //
  3257. // struct3507.OrgName = miConfig.OrgName
  3258. // struct3507.AccessKey = miConfig.AccessKey
  3259. // struct3507.RequestUrl = miConfig.Url
  3260. // struct3507.SecretKey = miConfig.SecretKey
  3261. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3262. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3263. // struct3507.Url = miConfig.Url
  3264. // struct3507.AppId = miConfig.Cainfo
  3265. // struct3507.AppSecret = miConfig.AppSecret
  3266. // struct3507.Enckey = miConfig.EncKey
  3267. // struct3507.SignKey = miConfig.SignKey
  3268. // struct3507.SecretKey = miConfig.SecretKey
  3269. // //result, result1, _ := service.FJyb3507(struct3507)
  3270. // //saveLog(result, result1, "3507", "3507")
  3271. // //
  3272. // //var respJSON3 map[string]interface{}
  3273. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3274. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3275. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3276. // // return
  3277. // //}
  3278. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  3279. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3280. // // utils.ErrorLog("解析失败:%v", err)
  3281. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3282. // // return
  3283. // //}
  3284. // if miConfig.MdtrtareaAdmvs == "350500" {
  3285. // result, result1, _ := service.FJyb3507(struct3507)
  3286. // saveLog(result, result1, "3507", "3507")
  3287. // var respJSON2 map[string]interface{}
  3288. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3289. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3291. // return
  3292. // }
  3293. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3294. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3295. // utils.ErrorLog("解析失败:%v", err)
  3296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3297. // return
  3298. // }
  3299. // } else {
  3300. // data := make(map[string]interface{})
  3301. // data["struct_3507s"] = struct3507
  3302. // client := &http.Client{}
  3303. // bytesData, _ := json.Marshal(data)
  3304. // var req *http.Request
  3305. // if miConfig.MdtrtareaAdmvs == "320921" {
  3306. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3307. // } else {
  3308. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3309. // }
  3310. //
  3311. // resp, _ := client.Do(req)
  3312. // defer resp.Body.Close()
  3313. // body, ioErr := ioutil.ReadAll(resp.Body)
  3314. // if ioErr != nil {
  3315. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3316. // }
  3317. // var respJSON map[string]interface{}
  3318. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3319. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3320. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3321. // return
  3322. // }
  3323. // var resSix10265 ResultSix10265 //1101结果
  3324. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3325. // result, _ := json.Marshal(respJSON)
  3326. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3327. // utils.ErrorLog("解析失败:%v", err)
  3328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3329. // return
  3330. // }
  3331. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3332. // //res.Output = resSix10265.Output
  3333. // res.ErrMsg = resSix10265.ErrMsg
  3334. // res.Cainfo = resSix10265.Cainfo
  3335. // res.WarnMsg = resSix10265.WarnMsg
  3336. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3337. // res.Infcode = infocode
  3338. // }
  3339. //
  3340. // if res.Infcode == 0 {
  3341. // item.IsChange = 0
  3342. // item.BgBchno = ""
  3343. // service.SaveDF2(item)
  3344. // } else {
  3345. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  3346. // }
  3347. // }
  3348. // }
  3349. // if len(err) == 0 {
  3350. // c.ServeSuccessJSON(map[string]interface{}{
  3351. // "msg": "删除销售变更成功",
  3352. // })
  3353. //
  3354. // } else {
  3355. // c.ServeSuccessJSON(map[string]interface{}{
  3356. // "failed_code": -10,
  3357. // "msg": err,
  3358. // })
  3359. //
  3360. // }
  3361. //
  3362. //}
  3363. // 获取当天起止时间戳
  3364. func GetNowTime() (int64, int64) {
  3365. t := time.Now()
  3366. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3367. timesamp := addTime.Unix()
  3368. return timesamp, timesamp + 86399
  3369. }
  3370. func (c *HisApiController) ChangeDrugfour() {
  3371. patient_id, _ := c.GetInt64("patient_id")
  3372. admin_user_id, _ := c.GetInt64("admin_user_id")
  3373. //id_arr := strings.Split(ids, ",")
  3374. times := c.GetString("time", "")
  3375. timeLayout := "2006-01-02"
  3376. loc, _ := time.LoadLocation("Local")
  3377. var stime, etime int64
  3378. if times == "" {
  3379. stime, etime = GetNowTime()
  3380. } else {
  3381. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3382. stime = stmp.Unix()
  3383. etime = stime + 86399
  3384. }
  3385. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3386. var flows []*models.DrugFlow
  3387. for _, item := range advicelist {
  3388. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.ID, stime, c.GetAdminUserInfo().CurrentOrgId)
  3389. flows = append(flows, flow...)
  3390. }
  3391. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3392. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3393. var err []string
  3394. for _, item := range flows {
  3395. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3396. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3397. if prescription.OrderStatus == 2 {
  3398. //已经结算
  3399. //判断是否已经销售
  3400. if item.IsSale == 1 { //是否已经销售,1是 0否
  3401. //是否已经变更 1是 0否
  3402. //if item.IsChange == 0 { //没变更,进行变更操作
  3403. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3404. //
  3405. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3406. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3407. // var respJSON3 map[string]interface{}
  3408. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3409. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3411. // return
  3412. // }
  3413. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3414. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3415. // utils.ErrorLog("解析失败:%v", err)
  3416. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3417. // return
  3418. // }
  3419. // if res3.Infcode == 0 {
  3420. // item.IsChange = 1
  3421. // item.BgBchno = bg_number
  3422. // service.SaveDF2(item)
  3423. // } else {
  3424. //
  3425. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3426. // }
  3427. //}
  3428. } else { //没销售,
  3429. var res FJ3507Result
  3430. var res3507for10188 FJ3507ResultFor10188
  3431. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3432. //进行商品销售接口
  3433. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3434. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3435. var respJSON3 map[string]interface{}
  3436. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3439. return
  3440. }
  3441. userJSONBytes3, _ := json.Marshal(respJSON3)
  3442. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3443. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3444. utils.ErrorLog("解析失败:%v", err)
  3445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3446. return
  3447. }
  3448. //if res3507for10188.Infcode
  3449. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3450. //res.Output = resSix10265.Output
  3451. res.ErrMsg = res3507for10188.ErrMsg
  3452. res.Cainfo = res3507for10188.Cainfo
  3453. res.WarnMsg = res3507for10188.WarnMsg
  3454. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3455. res.Infcode = infocode
  3456. } else {
  3457. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3458. utils.ErrorLog("解析失败:%v", err)
  3459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3460. return
  3461. }
  3462. }
  3463. if res.Infcode == 0 {
  3464. item.IsSale = 1
  3465. item.Bchno = number
  3466. item.SaleDate = time.Now().Format("2006-01-02")
  3467. service.SaveDF(item)
  3468. //if err5 == nil {
  3469. // if item.IsChange == 0 { //没变更,进行变更操作
  3470. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3471. //
  3472. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3473. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3474. //
  3475. // var respJSON3 map[string]interface{}
  3476. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3477. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3479. // return
  3480. // }
  3481. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3482. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3483. // utils.ErrorLog("解析失败:%v", err)
  3484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3485. // return
  3486. // }
  3487. // //if res3507for10188.Infcode
  3488. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3489. // //res.Output = resSix10265.Output
  3490. // res3.ErrMsg = res3507for10188.ErrMsg
  3491. // res3.Cainfo = res3507for10188.Cainfo
  3492. // res3.WarnMsg = res3507for10188.WarnMsg
  3493. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3494. // res3.Infcode = infocode
  3495. // } else {
  3496. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3497. // utils.ErrorLog("解析失败:%v", err)
  3498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3499. // return
  3500. // }
  3501. // }
  3502. // if res3.Infcode == 0 {
  3503. // item.IsChange = 1
  3504. // item.BgBchno = bg_number
  3505. // service.SaveDF2(item)
  3506. // } else {
  3507. //
  3508. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3509. // }
  3510. // }
  3511. //}
  3512. } else {
  3513. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3514. }
  3515. }
  3516. } else { //还没结,提示用户去结算,并药品追溯上传
  3517. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3518. }
  3519. }
  3520. }
  3521. if len(err) == 0 {
  3522. c.ServeSuccessJSON(map[string]interface{}{
  3523. "msg": "销售成功",
  3524. })
  3525. } else {
  3526. c.ServeSuccessJSON(map[string]interface{}{
  3527. "failed_code": -10,
  3528. "msg": err,
  3529. })
  3530. }
  3531. }
  3532. //func (c *HisApiController) ChangeDrugfour() {
  3533. // patient_id, _ := c.GetInt64("patient_id")
  3534. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3535. // //id_arr := strings.Split(ids, ",")
  3536. // times := c.GetString("time", "")
  3537. // timeLayout := "2006-01-02"
  3538. // loc, _ := time.LoadLocation("Local")
  3539. // var stime, etime int64
  3540. // if times == "" {
  3541. // stime, etime = GetNowTime()
  3542. // } else {
  3543. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3544. // stime = stmp.Unix()
  3545. // etime = stime + 86399
  3546. // }
  3547. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3548. // var flows []*models.DrugFlow
  3549. // for _, item := range advicelist {
  3550. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3551. // flows = append(flows, flow...)
  3552. // }
  3553. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3554. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3555. // var err []string
  3556. //
  3557. // for _, item := range flows {
  3558. // var res3 ResultSix
  3559. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3560. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3561. // if prescription.OrderStatus == 2 {
  3562. // //已经结算
  3563. // //判断是否已经销售
  3564. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3565. // //是否已经变更 1是 0否
  3566. // if item.IsChange == 0 { //没变更,进行变更操作
  3567. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3568. //
  3569. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3570. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3571. // var respJSON3 map[string]interface{}
  3572. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3573. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3575. // return
  3576. // }
  3577. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3578. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3579. // utils.ErrorLog("解析失败:%v", err)
  3580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3581. // return
  3582. // }
  3583. // if res3.Infcode == 0 {
  3584. // item.IsChange = 1
  3585. // item.BgBchno = bg_number
  3586. // service.SaveDF2(item)
  3587. // } else {
  3588. //
  3589. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3590. // }
  3591. // }
  3592. // } else { //没销售,
  3593. // var res FJ3507Result
  3594. // var res3507for10188 FJ3507ResultFor10188
  3595. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3596. //
  3597. // //进行商品销售接口
  3598. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3599. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3600. // var respJSON3 map[string]interface{}
  3601. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3602. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3604. // return
  3605. // }
  3606. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3607. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3608. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3609. // utils.ErrorLog("解析失败:%v", err)
  3610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3611. // return
  3612. // }
  3613. // //if res3507for10188.Infcode
  3614. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3615. // //res.Output = resSix10265.Output
  3616. // res.ErrMsg = res3507for10188.ErrMsg
  3617. // res.Cainfo = res3507for10188.Cainfo
  3618. // res.WarnMsg = res3507for10188.WarnMsg
  3619. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3620. // res.Infcode = infocode
  3621. // } else {
  3622. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3623. // utils.ErrorLog("解析失败:%v", err)
  3624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3625. // return
  3626. // }
  3627. //
  3628. // }
  3629. // if res.Infcode == 0 {
  3630. // item.IsSale = 1
  3631. // item.Bchno = number
  3632. // item.SaleDate = time.Now().Format("2006-01-02")
  3633. //
  3634. // err5 := service.SaveDF(item)
  3635. // if err5 == nil {
  3636. // if item.IsChange == 0 { //没变更,进行变更操作
  3637. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3638. //
  3639. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3640. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3641. //
  3642. // var respJSON3 map[string]interface{}
  3643. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3644. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3646. // return
  3647. // }
  3648. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3649. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3650. // utils.ErrorLog("解析失败:%v", err)
  3651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3652. // return
  3653. // }
  3654. // //if res3507for10188.Infcode
  3655. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3656. // //res.Output = resSix10265.Output
  3657. // res3.ErrMsg = res3507for10188.ErrMsg
  3658. // res3.Cainfo = res3507for10188.Cainfo
  3659. // res3.WarnMsg = res3507for10188.WarnMsg
  3660. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3661. // res3.Infcode = infocode
  3662. // } else {
  3663. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3664. // utils.ErrorLog("解析失败:%v", err)
  3665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3666. // return
  3667. // }
  3668. // }
  3669. // if res3.Infcode == 0 {
  3670. // item.IsChange = 1
  3671. // item.BgBchno = bg_number
  3672. // service.SaveDF2(item)
  3673. // } else {
  3674. //
  3675. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3676. // }
  3677. // }
  3678. // }
  3679. // } else {
  3680. //
  3681. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3682. // }
  3683. // }
  3684. //
  3685. // } else { //还没结,提示用户去结算,并药品追溯上传
  3686. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3687. // }
  3688. // }
  3689. // }
  3690. // if len(err) == 0 {
  3691. // c.ServeSuccessJSON(map[string]interface{}{
  3692. // "msg": "销售变更成功",
  3693. // })
  3694. // } else {
  3695. // c.ServeSuccessJSON(map[string]interface{}{
  3696. // "failed_code": -10,
  3697. // "msg": err,
  3698. // })
  3699. // }
  3700. //}
  3701. func (c *HisApiController) ChangeDrug() {
  3702. ids := c.GetString("ids")
  3703. id_arr := strings.Split(ids, ",")
  3704. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3705. admin_user_id, _ := c.GetInt64("admin_user_id")
  3706. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3707. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3708. var err []string
  3709. for _, item := range flows {
  3710. var res3 ResultSix
  3711. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3712. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3713. if prescription.OrderStatus == 2 {
  3714. //已经结算
  3715. //判断是否已经销售
  3716. if item.IsSale == 1 { //是否已经销售,1是 0否
  3717. //是否已经变更 1是 0否
  3718. if item.IsChange == 0 { //没变更,进行变更操作
  3719. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3720. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3721. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3722. var respJSON3 map[string]interface{}
  3723. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3726. return
  3727. }
  3728. userJSONBytes3, _ := json.Marshal(respJSON3)
  3729. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3730. utils.ErrorLog("解析失败:%v", err)
  3731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3732. return
  3733. }
  3734. if res3.Infcode == 0 {
  3735. item.IsChange = 1
  3736. item.BgBchno = bg_number
  3737. service.SaveDF2(item)
  3738. } else {
  3739. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3740. }
  3741. }
  3742. } else { //没销售,
  3743. var res FJ3507Result
  3744. var res3507for10188 FJ3507ResultFor10188
  3745. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3746. //进行商品销售接口
  3747. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3748. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3749. var respJSON3 map[string]interface{}
  3750. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3753. return
  3754. }
  3755. userJSONBytes3, _ := json.Marshal(respJSON3)
  3756. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3757. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3758. utils.ErrorLog("解析失败:%v", err)
  3759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3760. return
  3761. }
  3762. //if res3507for10188.Infcode
  3763. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3764. //res.Output = resSix10265.Output
  3765. res.ErrMsg = res3507for10188.ErrMsg
  3766. res.Cainfo = res3507for10188.Cainfo
  3767. res.WarnMsg = res3507for10188.WarnMsg
  3768. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3769. res.Infcode = infocode
  3770. } else {
  3771. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3772. utils.ErrorLog("解析失败:%v", err)
  3773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3774. return
  3775. }
  3776. }
  3777. if res.Infcode == 0 {
  3778. item.IsSale = 1
  3779. item.Bchno = number
  3780. item.SaleDate = time.Now().Format("2006-01-02")
  3781. err5 := service.SaveDF(item)
  3782. if err5 == nil {
  3783. if item.IsChange == 0 { //没变更,进行变更操作
  3784. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3785. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3786. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3787. var respJSON3 map[string]interface{}
  3788. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3791. return
  3792. }
  3793. userJSONBytes3, _ := json.Marshal(respJSON3)
  3794. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3795. utils.ErrorLog("解析失败:%v", err)
  3796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3797. return
  3798. }
  3799. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3800. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3801. utils.ErrorLog("解析失败:%v", err)
  3802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3803. return
  3804. }
  3805. //if res3507for10188.Infcode
  3806. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3807. //res.Output = resSix10265.Output
  3808. res3.ErrMsg = res3507for10188.ErrMsg
  3809. res3.Cainfo = res3507for10188.Cainfo
  3810. res3.WarnMsg = res3507for10188.WarnMsg
  3811. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3812. res3.Infcode = infocode
  3813. } else {
  3814. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3815. utils.ErrorLog("解析失败:%v", err)
  3816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3817. return
  3818. }
  3819. }
  3820. if res3.Infcode == 0 {
  3821. item.IsChange = 1
  3822. item.BgBchno = bg_number
  3823. service.SaveDF2(item)
  3824. } else {
  3825. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3826. }
  3827. }
  3828. }
  3829. } else {
  3830. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3831. }
  3832. }
  3833. } else { //还没结算
  3834. var res3507for10188 FJ3507ResultFor10188
  3835. if item.IsChange == 0 { //没变更,进行变更操作
  3836. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3837. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3838. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  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. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3862. utils.ErrorLog("解析失败:%v", err)
  3863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. return
  3865. }
  3866. }
  3867. if res3.Infcode == 0 {
  3868. item.IsChange = 1
  3869. item.BgBchno = bg_number
  3870. service.SaveDF2(item)
  3871. } else {
  3872. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3873. }
  3874. }
  3875. }
  3876. } else if item.ConsumableType == 7 {
  3877. var res3507for10188 FJ3507ResultFor10188
  3878. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3879. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3880. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3881. //判断是否已经销售
  3882. if item.IsSale == 2 { //是否已经销售,1是 0否
  3883. //是否已经变更 1是 0否
  3884. if item.IsChange == 0 { //没变更,进行变更操作
  3885. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3886. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3887. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3888. var respJSON3 map[string]interface{}
  3889. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3892. return
  3893. }
  3894. userJSONBytes3, _ := json.Marshal(respJSON3)
  3895. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3896. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3897. utils.ErrorLog("解析失败:%v", err)
  3898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3899. return
  3900. }
  3901. //if res3507for10188.Infcode
  3902. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3903. //res.Output = resSix10265.Output
  3904. res3.ErrMsg = res3507for10188.ErrMsg
  3905. res3.Cainfo = res3507for10188.Cainfo
  3906. res3.WarnMsg = res3507for10188.WarnMsg
  3907. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3908. res3.Infcode = infocode
  3909. } else {
  3910. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3911. utils.ErrorLog("解析失败:%v", err)
  3912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3913. return
  3914. }
  3915. }
  3916. if res3.Infcode == 0 {
  3917. item.IsChange = 1
  3918. item.BgBchno = bg_number
  3919. service.SaveDF2(item)
  3920. } else {
  3921. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3922. }
  3923. }
  3924. } else { //没销售,
  3925. //进行商品销售退货接口
  3926. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3927. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3928. saveLog(result111, result222, "3506", "销售退货")
  3929. var res7 FJ3507Result
  3930. //进行商品销售接口
  3931. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3932. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3933. var respJSON3 map[string]interface{}
  3934. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3937. return
  3938. }
  3939. userJSONBytes3, _ := json.Marshal(respJSON3)
  3940. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3941. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3942. utils.ErrorLog("解析失败:%v", err)
  3943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3944. return
  3945. }
  3946. //if res3507for10188.Infcode
  3947. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3948. //res.Output = resSix10265.Output
  3949. res7.ErrMsg = res3507for10188.ErrMsg
  3950. res7.Cainfo = res3507for10188.Cainfo
  3951. res7.WarnMsg = res3507for10188.WarnMsg
  3952. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3953. res7.Infcode = infocode
  3954. } else {
  3955. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3956. utils.ErrorLog("解析失败:%v", err)
  3957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3958. return
  3959. }
  3960. }
  3961. if res7.Infcode == 0 {
  3962. item.IsSale = 2
  3963. item.SaleDate = item.SaleDate
  3964. item.Bchno = number
  3965. service.SaveDF(item)
  3966. if item.IsChange == 0 { //没变更,进行变更操作
  3967. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3968. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3969. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3970. var respJSON3 map[string]interface{}
  3971. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3974. return
  3975. }
  3976. userJSONBytes3, _ := json.Marshal(respJSON3)
  3977. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3978. // utils.ErrorLog("解析失败:%v", err)
  3979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3980. // return
  3981. //}
  3982. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3983. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3984. utils.ErrorLog("解析失败:%v", err)
  3985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3986. return
  3987. }
  3988. //if res3507for10188.Infcode
  3989. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3990. //res.Output = resSix10265.Output
  3991. res3.ErrMsg = res3507for10188.ErrMsg
  3992. res3.Cainfo = res3507for10188.Cainfo
  3993. res3.WarnMsg = res3507for10188.WarnMsg
  3994. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3995. res3.Infcode = infocode
  3996. } else {
  3997. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3998. utils.ErrorLog("解析失败:%v", err)
  3999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4000. return
  4001. }
  4002. }
  4003. if res3.Infcode == 0 {
  4004. item.IsChange = 1
  4005. item.BgBchno = bg_number
  4006. service.SaveDF2(item)
  4007. } else {
  4008. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4009. }
  4010. }
  4011. } else {
  4012. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4013. }
  4014. }
  4015. } else { //还没结算
  4016. if item.IsChange == 0 { //没变更,进行变更操作
  4017. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4018. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4019. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4020. var respJSON3 map[string]interface{}
  4021. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4024. return
  4025. }
  4026. userJSONBytes3, _ := json.Marshal(respJSON3)
  4027. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4028. // utils.ErrorLog("解析失败:%v", err)
  4029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4030. // return
  4031. //}
  4032. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4033. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4034. utils.ErrorLog("解析失败:%v", err)
  4035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4036. return
  4037. }
  4038. //if res3507for10188.Infcode
  4039. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4040. //res.Output = resSix10265.Output
  4041. res3.ErrMsg = res3507for10188.ErrMsg
  4042. res3.Cainfo = res3507for10188.Cainfo
  4043. res3.WarnMsg = res3507for10188.WarnMsg
  4044. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4045. res3.Infcode = infocode
  4046. } else {
  4047. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4048. utils.ErrorLog("解析失败:%v", err)
  4049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4050. return
  4051. }
  4052. }
  4053. if res3.Infcode == 0 {
  4054. item.IsChange = 1
  4055. item.BgBchno = bg_number
  4056. service.SaveDF2(item)
  4057. } else {
  4058. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4059. }
  4060. }
  4061. }
  4062. }
  4063. }
  4064. if len(err) == 0 {
  4065. c.ServeSuccessJSON(map[string]interface{}{
  4066. "msg": "销售变更成功",
  4067. })
  4068. } else {
  4069. c.ServeSuccessJSON(map[string]interface{}{
  4070. "failed_code": -10,
  4071. "msg": err,
  4072. })
  4073. }
  4074. }
  4075. func (c *HisApiController) ChangeDrugtwo() {
  4076. //ids := c.GetString("ids")
  4077. //id_arr := strings.Split(ids, ",")
  4078. flows, _ := service.GetNewDrugFlowInfothree123()
  4079. admin_user_id, _ := c.GetInt64("admin_user_id")
  4080. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4081. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4082. var err []string
  4083. for _, item := range flows {
  4084. var res3 ResultSix
  4085. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4086. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4087. if prescription.OrderStatus == 2 {
  4088. //已经结算
  4089. //判断是否已经销售
  4090. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4091. // //是否已经变更 1是 0否
  4092. // if item.IsChange == 0 { //没变更,进行变更操作
  4093. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4094. //
  4095. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4096. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4097. // var respJSON3 map[string]interface{}
  4098. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4099. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4101. // return
  4102. // }
  4103. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4104. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4105. // utils.ErrorLog("解析失败:%v", err)
  4106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4107. // return
  4108. // }
  4109. // if res3.Infcode == 0 {
  4110. // item.IsChange = 1
  4111. // item.BgBchno = bg_number
  4112. // service.SaveDF2(item)
  4113. // } else {
  4114. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4115. // }
  4116. // }
  4117. //}
  4118. //else
  4119. { //没销售,
  4120. var res FJ3507Result
  4121. var res3507for10188 FJ3507ResultFor10188
  4122. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4123. //进行商品销售接口
  4124. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4125. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4126. var respJSON3 map[string]interface{}
  4127. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4130. return
  4131. }
  4132. userJSONBytes3, _ := json.Marshal(respJSON3)
  4133. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4134. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4135. utils.ErrorLog("解析失败:%v", err)
  4136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4137. return
  4138. }
  4139. //if res3507for10188.Infcode
  4140. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4141. //res.Output = resSix10265.Output
  4142. res.ErrMsg = res3507for10188.ErrMsg
  4143. res.Cainfo = res3507for10188.Cainfo
  4144. res.WarnMsg = res3507for10188.WarnMsg
  4145. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4146. res.Infcode = infocode
  4147. } else {
  4148. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4149. utils.ErrorLog("解析失败:%v", err)
  4150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4151. return
  4152. }
  4153. }
  4154. if res.Infcode == 0 {
  4155. item.IsSale = 1
  4156. item.Bchno = number
  4157. item.SaleDate = time.Now().Format("2006-01-02")
  4158. service.SaveDF(item)
  4159. //if err5 == nil {
  4160. // if item.IsChange == 0 { //没变更,进行变更操作
  4161. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4162. //
  4163. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4164. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4165. //
  4166. // var respJSON3 map[string]interface{}
  4167. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4168. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4169. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4170. // return
  4171. // }
  4172. //
  4173. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4174. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4175. // utils.ErrorLog("解析失败:%v", err)
  4176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4177. // return
  4178. // }
  4179. // //if res3507for10188.Infcode
  4180. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4181. // //res.Output = resSix10265.Output
  4182. // res3.ErrMsg = res3507for10188.ErrMsg
  4183. // res3.Cainfo = res3507for10188.Cainfo
  4184. // res3.WarnMsg = res3507for10188.WarnMsg
  4185. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4186. // res3.Infcode = infocode
  4187. // } else {
  4188. //
  4189. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4190. // utils.ErrorLog("解析失败:%v", err)
  4191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4192. // return
  4193. // }
  4194. //
  4195. // }
  4196. //
  4197. // if res3.Infcode == 0 {
  4198. // item.IsChange = 1
  4199. // item.BgBchno = bg_number
  4200. // service.SaveDF2(item)
  4201. // } else {
  4202. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4203. // }
  4204. // }
  4205. //}
  4206. } else {
  4207. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4208. }
  4209. }
  4210. } else { //还没结算
  4211. var res3507for10188 FJ3507ResultFor10188
  4212. if item.IsChange == 0 { //没变更,进行变更操作
  4213. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4214. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4215. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4216. var respJSON3 map[string]interface{}
  4217. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4220. return
  4221. }
  4222. userJSONBytes3, _ := json.Marshal(respJSON3)
  4223. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4224. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4225. utils.ErrorLog("解析失败:%v", err)
  4226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4227. return
  4228. }
  4229. //if res3507for10188.Infcode
  4230. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4231. //res.Output = resSix10265.Output
  4232. res3.ErrMsg = res3507for10188.ErrMsg
  4233. res3.Cainfo = res3507for10188.Cainfo
  4234. res3.WarnMsg = res3507for10188.WarnMsg
  4235. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4236. res3.Infcode = infocode
  4237. } else {
  4238. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4239. utils.ErrorLog("解析失败:%v", err)
  4240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4241. return
  4242. }
  4243. }
  4244. if res3.Infcode == 0 {
  4245. item.IsChange = 1
  4246. item.BgBchno = bg_number
  4247. service.SaveDF2(item)
  4248. } else {
  4249. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4250. }
  4251. }
  4252. }
  4253. }
  4254. //if item.ConsumableType == 7 {
  4255. // var res3507for10188 FJ3507ResultFor10188
  4256. //
  4257. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4258. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4259. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4260. // //判断是否已经销售
  4261. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4262. // //是否已经变更 1是 0否
  4263. // if item.IsChange == 0 { //没变更,进行变更操作
  4264. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4265. //
  4266. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4267. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4268. //
  4269. // var respJSON3 map[string]interface{}
  4270. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4271. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4272. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4273. // return
  4274. // }
  4275. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4276. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4277. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4278. // utils.ErrorLog("解析失败:%v", err)
  4279. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4280. // return
  4281. // }
  4282. // //if res3507for10188.Infcode
  4283. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4284. // //res.Output = resSix10265.Output
  4285. // res3.ErrMsg = res3507for10188.ErrMsg
  4286. // res3.Cainfo = res3507for10188.Cainfo
  4287. // res3.WarnMsg = res3507for10188.WarnMsg
  4288. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4289. // res3.Infcode = infocode
  4290. // } else {
  4291. //
  4292. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4293. // utils.ErrorLog("解析失败:%v", err)
  4294. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4295. // return
  4296. // }
  4297. //
  4298. // }
  4299. // if res3.Infcode == 0 {
  4300. // item.IsChange = 1
  4301. // item.BgBchno = bg_number
  4302. // service.SaveDF2(item)
  4303. // } else {
  4304. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4305. // }
  4306. // }
  4307. // } else { //没销售,
  4308. // //进行商品销售退货接口
  4309. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4310. //
  4311. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4312. // saveLog(result111, result222, "3506", "销售退货")
  4313. // var res7 FJ3507Result
  4314. //
  4315. // //进行商品销售接口
  4316. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4317. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4318. // var respJSON3 map[string]interface{}
  4319. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4320. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4322. // return
  4323. // }
  4324. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4325. //
  4326. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4327. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4328. // utils.ErrorLog("解析失败:%v", err)
  4329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4330. // return
  4331. // }
  4332. // //if res3507for10188.Infcode
  4333. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4334. // //res.Output = resSix10265.Output
  4335. // res7.ErrMsg = res3507for10188.ErrMsg
  4336. // res7.Cainfo = res3507for10188.Cainfo
  4337. // res7.WarnMsg = res3507for10188.WarnMsg
  4338. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4339. // res7.Infcode = infocode
  4340. // } else {
  4341. //
  4342. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4343. // utils.ErrorLog("解析失败:%v", err)
  4344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4345. // return
  4346. // }
  4347. //
  4348. // }
  4349. // if res7.Infcode == 0 {
  4350. // item.IsSale = 2
  4351. // item.SaleDate = item.SaleDate
  4352. // item.Bchno = number
  4353. // service.SaveDF(item)
  4354. // if item.IsChange == 0 { //没变更,进行变更操作
  4355. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4356. //
  4357. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4358. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4359. //
  4360. // var respJSON3 map[string]interface{}
  4361. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4362. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4363. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4364. // return
  4365. // }
  4366. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4367. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4368. // // utils.ErrorLog("解析失败:%v", err)
  4369. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4370. // // return
  4371. // //}
  4372. //
  4373. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4374. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4375. // utils.ErrorLog("解析失败:%v", err)
  4376. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4377. // return
  4378. // }
  4379. // //if res3507for10188.Infcode
  4380. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4381. // //res.Output = resSix10265.Output
  4382. // res3.ErrMsg = res3507for10188.ErrMsg
  4383. // res3.Cainfo = res3507for10188.Cainfo
  4384. // res3.WarnMsg = res3507for10188.WarnMsg
  4385. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4386. // res3.Infcode = infocode
  4387. // } else {
  4388. //
  4389. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4390. // utils.ErrorLog("解析失败:%v", err)
  4391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4392. // return
  4393. // }
  4394. //
  4395. // }
  4396. // if res3.Infcode == 0 {
  4397. // item.IsChange = 1
  4398. // item.BgBchno = bg_number
  4399. // service.SaveDF2(item)
  4400. // } else {
  4401. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4402. // }
  4403. // }
  4404. // } else {
  4405. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4406. // }
  4407. // }
  4408. // } else { //还没结算
  4409. // if item.IsChange == 0 { //没变更,进行变更操作
  4410. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4411. //
  4412. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4413. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4414. //
  4415. // var respJSON3 map[string]interface{}
  4416. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4417. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4418. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4419. // return
  4420. // }
  4421. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4422. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4423. // // utils.ErrorLog("解析失败:%v", err)
  4424. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4425. // // return
  4426. // //}
  4427. //
  4428. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4429. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4430. // utils.ErrorLog("解析失败:%v", err)
  4431. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4432. // return
  4433. // }
  4434. // //if res3507for10188.Infcode
  4435. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4436. // //res.Output = resSix10265.Output
  4437. // res3.ErrMsg = res3507for10188.ErrMsg
  4438. // res3.Cainfo = res3507for10188.Cainfo
  4439. // res3.WarnMsg = res3507for10188.WarnMsg
  4440. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4441. // res3.Infcode = infocode
  4442. // } else {
  4443. //
  4444. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4445. // utils.ErrorLog("解析失败:%v", err)
  4446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4447. // return
  4448. // }
  4449. //
  4450. // }
  4451. // if res3.Infcode == 0 {
  4452. // item.IsChange = 1
  4453. // item.BgBchno = bg_number
  4454. // service.SaveDF2(item)
  4455. // } else {
  4456. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4457. // }
  4458. // }
  4459. // }
  4460. //}
  4461. }
  4462. if len(err) == 0 {
  4463. c.ServeSuccessJSON(map[string]interface{}{
  4464. "msg": "销售变更成功",
  4465. })
  4466. } else {
  4467. c.ServeSuccessJSON(map[string]interface{}{
  4468. "failed_code": -10,
  4469. "msg": err,
  4470. })
  4471. }
  4472. }
  4473. func (c *HisApiController) ChangeDrugthree() {
  4474. //ids := c.GetString("ids")
  4475. //id_arr := strings.Split(ids, ",")
  4476. flows, _ := service.GetNewDrugFlowInfothree()
  4477. admin_user_id, _ := c.GetInt64("admin_user_id")
  4478. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4479. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4480. var err []string
  4481. for _, item := range flows {
  4482. var res3 ResultSix
  4483. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4484. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4485. if prescription.OrderStatus == 2 {
  4486. //已经结算
  4487. //判断是否已经销售
  4488. if item.IsSale == 1 { //是否已经销售,1是 0否
  4489. //是否已经变更 1是 0否
  4490. if item.IsChange == 0 { //没变更,进行变更操作
  4491. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4492. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4493. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4494. var respJSON3 map[string]interface{}
  4495. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4498. return
  4499. }
  4500. userJSONBytes3, _ := json.Marshal(respJSON3)
  4501. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4502. utils.ErrorLog("解析失败:%v", err)
  4503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4504. return
  4505. }
  4506. if res3.Infcode == 0 {
  4507. item.IsChange = 1
  4508. item.BgBchno = bg_number
  4509. service.SaveDF2(item)
  4510. } else {
  4511. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4512. }
  4513. }
  4514. } else { //没销售,
  4515. var res FJ3507Result
  4516. var res3507for10188 FJ3507ResultFor10188
  4517. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4518. //进行商品销售接口
  4519. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4520. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4521. var respJSON3 map[string]interface{}
  4522. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4525. return
  4526. }
  4527. userJSONBytes3, _ := json.Marshal(respJSON3)
  4528. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4529. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4530. utils.ErrorLog("解析失败:%v", err)
  4531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4532. return
  4533. }
  4534. //if res3507for10188.Infcode
  4535. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4536. //res.Output = resSix10265.Output
  4537. res.ErrMsg = res3507for10188.ErrMsg
  4538. res.Cainfo = res3507for10188.Cainfo
  4539. res.WarnMsg = res3507for10188.WarnMsg
  4540. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4541. res.Infcode = infocode
  4542. } else {
  4543. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4544. utils.ErrorLog("解析失败:%v", err)
  4545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4546. return
  4547. }
  4548. }
  4549. if res.Infcode == 0 {
  4550. item.IsSale = 1
  4551. item.Bchno = number
  4552. item.SaleDate = time.Now().Format("2006-01-02")
  4553. err5 := service.SaveDF(item)
  4554. if err5 == nil {
  4555. if item.IsChange == 0 { //没变更,进行变更操作
  4556. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4557. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4558. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4559. var respJSON3 map[string]interface{}
  4560. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4563. return
  4564. }
  4565. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4566. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4567. utils.ErrorLog("解析失败:%v", err)
  4568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4569. return
  4570. }
  4571. //if res3507for10188.Infcode
  4572. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4573. //res.Output = resSix10265.Output
  4574. res3.ErrMsg = res3507for10188.ErrMsg
  4575. res3.Cainfo = res3507for10188.Cainfo
  4576. res3.WarnMsg = res3507for10188.WarnMsg
  4577. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4578. res3.Infcode = infocode
  4579. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4580. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4581. utils.ErrorLog("解析失败:%v", err)
  4582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4583. return
  4584. }
  4585. //if res3507for10188.Infcode
  4586. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4587. //res.Output = resSix10265.Output
  4588. res3.ErrMsg = res3507for10188.ErrMsg
  4589. res3.Cainfo = res3507for10188.Cainfo
  4590. res3.WarnMsg = res3507for10188.WarnMsg
  4591. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4592. res3.Infcode = infocode
  4593. } else {
  4594. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4595. utils.ErrorLog("解析失败:%v", err)
  4596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4597. return
  4598. }
  4599. }
  4600. if res3.Infcode == 0 {
  4601. item.IsChange = 1
  4602. item.BgBchno = bg_number
  4603. service.SaveDF2(item)
  4604. } else {
  4605. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4606. }
  4607. }
  4608. }
  4609. } else {
  4610. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4611. }
  4612. }
  4613. } else { //还没结算
  4614. var res3507for10188 FJ3507ResultFor10188
  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, "102", 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 {
  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 if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4641. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. //if res3507for10188.Infcode
  4647. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4648. //res.Output = resSix10265.Output
  4649. res3.ErrMsg = res3507for10188.ErrMsg
  4650. res3.Cainfo = res3507for10188.Cainfo
  4651. res3.WarnMsg = res3507for10188.WarnMsg
  4652. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4653. res3.Infcode = infocode
  4654. } else {
  4655. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4656. utils.ErrorLog("解析失败:%v", err)
  4657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4658. return
  4659. }
  4660. }
  4661. if res3.Infcode == 0 {
  4662. item.IsChange = 1
  4663. item.BgBchno = bg_number
  4664. service.SaveDF2(item)
  4665. } else {
  4666. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4667. }
  4668. }
  4669. }
  4670. } else if item.ConsumableType == 7 {
  4671. var res3507for10188 FJ3507ResultFor10188
  4672. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4673. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4674. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4675. //判断是否已经销售
  4676. if item.IsSale == 2 { //是否已经销售,1是 0否
  4677. //是否已经变更 1是 0否
  4678. if item.IsChange == 0 { //没变更,进行变更操作
  4679. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4680. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4681. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4682. var respJSON3 map[string]interface{}
  4683. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4686. return
  4687. }
  4688. userJSONBytes3, _ := json.Marshal(respJSON3)
  4689. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4690. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4691. utils.ErrorLog("解析失败:%v", err)
  4692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4693. return
  4694. }
  4695. //if res3507for10188.Infcode
  4696. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4697. //res.Output = resSix10265.Output
  4698. res3.ErrMsg = res3507for10188.ErrMsg
  4699. res3.Cainfo = res3507for10188.Cainfo
  4700. res3.WarnMsg = res3507for10188.WarnMsg
  4701. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4702. res3.Infcode = infocode
  4703. } else {
  4704. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4705. utils.ErrorLog("解析失败:%v", err)
  4706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4707. return
  4708. }
  4709. }
  4710. if res3.Infcode == 0 {
  4711. item.IsChange = 1
  4712. item.BgBchno = bg_number
  4713. service.SaveDF2(item)
  4714. } else {
  4715. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4716. }
  4717. }
  4718. } else { //没销售,
  4719. //进行商品销售退货接口
  4720. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4721. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4722. saveLog(result111, result222, "3506", "销售退货")
  4723. var res7 FJ3507Result
  4724. //进行商品销售接口
  4725. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4726. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4727. var respJSON3 map[string]interface{}
  4728. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4731. return
  4732. }
  4733. userJSONBytes3, _ := json.Marshal(respJSON3)
  4734. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4735. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4736. utils.ErrorLog("解析失败:%v", err)
  4737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4738. return
  4739. }
  4740. //if res3507for10188.Infcode
  4741. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4742. //res.Output = resSix10265.Output
  4743. res7.ErrMsg = res3507for10188.ErrMsg
  4744. res7.Cainfo = res3507for10188.Cainfo
  4745. res7.WarnMsg = res3507for10188.WarnMsg
  4746. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4747. res7.Infcode = infocode
  4748. } else {
  4749. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4750. utils.ErrorLog("解析失败:%v", err)
  4751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4752. return
  4753. }
  4754. }
  4755. if res7.Infcode == 0 {
  4756. item.IsSale = 2
  4757. item.SaleDate = item.SaleDate
  4758. item.Bchno = number
  4759. service.SaveDF(item)
  4760. if item.IsChange == 0 { //没变更,进行变更操作
  4761. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4762. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4763. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4764. var respJSON3 map[string]interface{}
  4765. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4768. return
  4769. }
  4770. userJSONBytes3, _ := json.Marshal(respJSON3)
  4771. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4772. // utils.ErrorLog("解析失败:%v", err)
  4773. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4774. // return
  4775. //}
  4776. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4777. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4778. utils.ErrorLog("解析失败:%v", err)
  4779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4780. return
  4781. }
  4782. //if res3507for10188.Infcode
  4783. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4784. //res.Output = resSix10265.Output
  4785. res3.ErrMsg = res3507for10188.ErrMsg
  4786. res3.Cainfo = res3507for10188.Cainfo
  4787. res3.WarnMsg = res3507for10188.WarnMsg
  4788. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4789. res3.Infcode = infocode
  4790. } else {
  4791. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4792. utils.ErrorLog("解析失败:%v", err)
  4793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4794. return
  4795. }
  4796. }
  4797. if res3.Infcode == 0 {
  4798. item.IsChange = 1
  4799. item.BgBchno = bg_number
  4800. service.SaveDF2(item)
  4801. } else {
  4802. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4803. }
  4804. }
  4805. } else {
  4806. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4807. }
  4808. }
  4809. } else { //还没结算
  4810. if item.IsChange == 0 { //没变更,进行变更操作
  4811. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4812. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4813. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4814. var respJSON3 map[string]interface{}
  4815. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4818. return
  4819. }
  4820. userJSONBytes3, _ := json.Marshal(respJSON3)
  4821. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4822. // utils.ErrorLog("解析失败:%v", err)
  4823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4824. // return
  4825. //}
  4826. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4827. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4828. utils.ErrorLog("解析失败:%v", err)
  4829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4830. return
  4831. }
  4832. //if res3507for10188.Infcode
  4833. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4834. //res.Output = resSix10265.Output
  4835. res3.ErrMsg = res3507for10188.ErrMsg
  4836. res3.Cainfo = res3507for10188.Cainfo
  4837. res3.WarnMsg = res3507for10188.WarnMsg
  4838. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4839. res3.Infcode = infocode
  4840. } else {
  4841. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4842. utils.ErrorLog("解析失败:%v", err)
  4843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4844. return
  4845. }
  4846. }
  4847. if res3.Infcode == 0 {
  4848. item.IsChange = 1
  4849. item.BgBchno = bg_number
  4850. service.SaveDF2(item)
  4851. } else {
  4852. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4853. }
  4854. }
  4855. }
  4856. }
  4857. }
  4858. if len(err) == 0 {
  4859. c.ServeSuccessJSON(map[string]interface{}{
  4860. "msg": "销售变更成功",
  4861. })
  4862. } else {
  4863. c.ServeSuccessJSON(map[string]interface{}{
  4864. "failed_code": -10,
  4865. "msg": err,
  4866. })
  4867. }
  4868. }
  4869. func (c *HisApiController) ChangeDrugTen() {
  4870. start_time_str := c.GetString("start_time")
  4871. end_time_str := c.GetString("end_time")
  4872. //ids := c.GetString("ids")
  4873. //id_arr := strings.Split(ids, ",")
  4874. timeLayout := "2006-01-02"
  4875. loc, _ := time.LoadLocation("Local")
  4876. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4877. recordStartTime := theStartTime.Unix()
  4878. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4879. recordEndTime := theEndTime.Unix()
  4880. //timestamp := int64(1729612800)
  4881. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4882. admin_user_id, _ := c.GetInt64("admin_user_id")
  4883. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4884. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4885. var err []string
  4886. for _, item := range flows {
  4887. var res3 ResultSix
  4888. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4889. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4890. continue
  4891. }
  4892. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4893. continue
  4894. }
  4895. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4896. if prescription.OrderStatus == 2 {
  4897. //已经结算
  4898. //判断 是否已经销售
  4899. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4900. ////是否已经变更 1是 0否
  4901. //if item.IsChange == 0 { //没变更,进行变更操作
  4902. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4903. //
  4904. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4905. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4906. // var respJSON3 map[string]interface{}
  4907. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4908. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4910. // return
  4911. // }
  4912. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4913. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4914. // utils.ErrorLog("解析失败:%v", err)
  4915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4916. // return
  4917. // }
  4918. // if res3.Infcode == 0 {
  4919. // item.IsChange = 1
  4920. // item.BgBchno = bg_number
  4921. // service.SaveDF2(item)
  4922. // } else {
  4923. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4924. // }
  4925. //}
  4926. //} else
  4927. if item.IsSale == 0 { //没销售,
  4928. var res FJ3507Result
  4929. var res3507for10188 FJ3507ResultFor10188
  4930. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4931. //进行商品销售接口
  4932. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4933. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4934. var respJSON3 map[string]interface{}
  4935. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4938. return
  4939. }
  4940. userJSONBytes3, _ := json.Marshal(respJSON3)
  4941. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4942. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4943. utils.ErrorLog("解析失败:%v", err)
  4944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4945. return
  4946. }
  4947. //if res3507for10188.Infcode
  4948. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4949. //res.Output = resSix10265.Output
  4950. res.ErrMsg = res3507for10188.ErrMsg
  4951. res.Cainfo = res3507for10188.Cainfo
  4952. res.WarnMsg = res3507for10188.WarnMsg
  4953. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4954. res.Infcode = infocode
  4955. } else {
  4956. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4957. utils.ErrorLog("解析失败:%v", err)
  4958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4959. return
  4960. }
  4961. }
  4962. if res.Infcode == 0 {
  4963. item.IsSale = 1
  4964. item.Bchno = number
  4965. item.SaleDate = time.Now().Format("2006-01-02")
  4966. err5 := service.SaveDF(item)
  4967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4968. //if err5 == nil {
  4969. //
  4970. // if item.IsChange == 1 { //没变更,进行变更操作
  4971. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4972. //
  4973. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4974. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4975. //
  4976. // var respJSON3 map[string]interface{}
  4977. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4978. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4980. // return
  4981. // }
  4982. //
  4983. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4984. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4985. // utils.ErrorLog("解析失败:%v", err)
  4986. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4987. // return
  4988. // }
  4989. // //if res3507for10188.Infcode
  4990. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4991. // //res.Output = resSix10265.Output
  4992. // res3.ErrMsg = res3507for10188.ErrMsg
  4993. // res3.Cainfo = res3507for10188.Cainfo
  4994. // res3.WarnMsg = res3507for10188.WarnMsg
  4995. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4996. // res3.Infcode = infocode
  4997. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4998. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4999. // utils.ErrorLog("解析失败:%v", err)
  5000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5001. // return
  5002. // }
  5003. // //if res3507for10188.Infcode
  5004. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5005. // //res.Output = resSix10265.Output
  5006. // res3.ErrMsg = res3507for10188.ErrMsg
  5007. // res3.Cainfo = res3507for10188.Cainfo
  5008. // res3.WarnMsg = res3507for10188.WarnMsg
  5009. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5010. // res3.Infcode = infocode
  5011. //
  5012. // } else {
  5013. //
  5014. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5015. // utils.ErrorLog("解析失败:%v", err)
  5016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5017. // return
  5018. // }
  5019. //
  5020. // }
  5021. //
  5022. // if res3.Infcode == 0 {
  5023. // item.IsChange = 1
  5024. // item.BgBchno = bg_number
  5025. // service.SaveDF2(item)
  5026. // return
  5027. // } else {
  5028. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5029. // }
  5030. // }
  5031. //}
  5032. } else {
  5033. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5034. }
  5035. }
  5036. }
  5037. } else if item.ConsumableType == 7 {
  5038. var res3507for10188 FJ3507ResultFor10188
  5039. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5040. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  5041. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  5042. //判断是否已经销售
  5043. if item.IsSale == 2 { //是否已经销售,1是 0否
  5044. //是否已经变更 1是 0否
  5045. if item.IsChange == 0 { //没变更,进行变更操作
  5046. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5047. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5048. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5049. var respJSON3 map[string]interface{}
  5050. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5053. return
  5054. }
  5055. userJSONBytes3, _ := json.Marshal(respJSON3)
  5056. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5057. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5058. utils.ErrorLog("解析失败:%v", err)
  5059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5060. return
  5061. }
  5062. //if res3507for10188.Infcode
  5063. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5064. //res.Output = resSix10265.Output
  5065. res3.ErrMsg = res3507for10188.ErrMsg
  5066. res3.Cainfo = res3507for10188.Cainfo
  5067. res3.WarnMsg = res3507for10188.WarnMsg
  5068. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5069. res3.Infcode = infocode
  5070. } else {
  5071. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5072. utils.ErrorLog("解析失败:%v", err)
  5073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5074. return
  5075. }
  5076. }
  5077. if res3.Infcode == 0 {
  5078. item.IsChange = 1
  5079. item.BgBchno = bg_number
  5080. service.SaveDF2(item)
  5081. } else {
  5082. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5083. }
  5084. }
  5085. } else { //没销售,
  5086. //进行商品销售退货接口
  5087. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  5088. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  5089. saveLog(result111, result222, "3506", "销售退货")
  5090. var res7 FJ3507Result
  5091. //进行商品销售接口
  5092. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  5093. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  5094. var respJSON3 map[string]interface{}
  5095. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  5096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5098. return
  5099. }
  5100. userJSONBytes3, _ := json.Marshal(respJSON3)
  5101. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5102. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5103. utils.ErrorLog("解析失败:%v", err)
  5104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5105. return
  5106. }
  5107. //if res3507for10188.Infcode
  5108. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  5109. //res.Output = resSix10265.Output
  5110. res7.ErrMsg = res3507for10188.ErrMsg
  5111. res7.Cainfo = res3507for10188.Cainfo
  5112. res7.WarnMsg = res3507for10188.WarnMsg
  5113. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5114. res7.Infcode = infocode
  5115. } else {
  5116. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5117. utils.ErrorLog("解析失败:%v", err)
  5118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5119. return
  5120. }
  5121. }
  5122. if res7.Infcode == 0 {
  5123. item.IsSale = 2
  5124. item.SaleDate = item.SaleDate
  5125. item.Bchno = number
  5126. service.SaveDF(item)
  5127. if item.IsChange == 0 { //没变更,进行变更操作
  5128. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5129. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5130. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5131. var respJSON3 map[string]interface{}
  5132. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5135. return
  5136. }
  5137. userJSONBytes3, _ := json.Marshal(respJSON3)
  5138. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5139. // utils.ErrorLog("解析失败:%v", err)
  5140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5141. // return
  5142. //}
  5143. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5144. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5145. utils.ErrorLog("解析失败:%v", err)
  5146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5147. return
  5148. }
  5149. //if res3507for10188.Infcode
  5150. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5151. //res.Output = resSix10265.Output
  5152. res3.ErrMsg = res3507for10188.ErrMsg
  5153. res3.Cainfo = res3507for10188.Cainfo
  5154. res3.WarnMsg = res3507for10188.WarnMsg
  5155. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5156. res3.Infcode = infocode
  5157. } else {
  5158. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5159. utils.ErrorLog("解析失败:%v", err)
  5160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5161. return
  5162. }
  5163. }
  5164. if res3.Infcode == 0 {
  5165. item.IsChange = 1
  5166. item.BgBchno = bg_number
  5167. service.SaveDF2(item)
  5168. } else {
  5169. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5170. }
  5171. }
  5172. } else {
  5173. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5174. }
  5175. }
  5176. } else { //还没结算
  5177. if item.IsChange == 0 { //没变更,进行变更操作
  5178. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5179. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5180. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5181. var respJSON3 map[string]interface{}
  5182. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5185. return
  5186. }
  5187. userJSONBytes3, _ := json.Marshal(respJSON3)
  5188. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5189. // utils.ErrorLog("解析失败:%v", err)
  5190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5191. // return
  5192. //}
  5193. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5194. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5195. utils.ErrorLog("解析失败:%v", err)
  5196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5197. return
  5198. }
  5199. //if res3507for10188.Infcode
  5200. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5201. //res.Output = resSix10265.Output
  5202. res3.ErrMsg = res3507for10188.ErrMsg
  5203. res3.Cainfo = res3507for10188.Cainfo
  5204. res3.WarnMsg = res3507for10188.WarnMsg
  5205. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5206. res3.Infcode = infocode
  5207. } else {
  5208. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5209. utils.ErrorLog("解析失败:%v", err)
  5210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5211. return
  5212. }
  5213. }
  5214. if res3.Infcode == 0 {
  5215. item.IsChange = 1
  5216. item.BgBchno = bg_number
  5217. service.SaveDF2(item)
  5218. } else {
  5219. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5220. }
  5221. }
  5222. }
  5223. }
  5224. }
  5225. if len(err) == 0 {
  5226. c.ServeSuccessJSON(map[string]interface{}{
  5227. "msg": "销售变更成功",
  5228. })
  5229. } else {
  5230. c.ServeSuccessJSON(map[string]interface{}{
  5231. "failed_code": -10,
  5232. "msg": err,
  5233. })
  5234. }
  5235. }
  5236. func ChangeDrugTenone() {
  5237. //ids := c.GetString("ids")
  5238. //id_arr := strings.Split(ids, ",")
  5239. now := time.Now()
  5240. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  5241. //timestamp := int64(1729612800)
  5242. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  5243. admin_user_id := int64(2463)
  5244. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  5245. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  5246. var err []string
  5247. for _, item := range flows {
  5248. var res3 ResultSix
  5249. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  5250. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5251. continue
  5252. }
  5253. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5254. continue
  5255. }
  5256. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5257. if prescription.OrderStatus == 2 {
  5258. //已经结算
  5259. //判断是否已经销售
  5260. if item.IsSale == 1 { //是否已经销售,1是 0否
  5261. //是否已经变更 1是 0否
  5262. if item.IsChange == 0 { //没变更,进行变更操作
  5263. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5264. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5265. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  5266. var respJSON3 map[string]interface{}
  5267. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5269. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5270. return
  5271. }
  5272. userJSONBytes3, _ := json.Marshal(respJSON3)
  5273. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5274. utils.ErrorLog("解析失败:%v", err)
  5275. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5276. return
  5277. }
  5278. if res3.Infcode == 0 {
  5279. item.IsChange = 1
  5280. item.BgBchno = bg_number
  5281. service.SaveDF2(item)
  5282. } else {
  5283. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5284. }
  5285. }
  5286. } else { //没销售,
  5287. var res FJ3507Result
  5288. var res3507for10188 FJ3507ResultFor10188
  5289. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  5290. //进行商品销售接口
  5291. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  5292. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  5293. var respJSON3 map[string]interface{}
  5294. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  5295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5296. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5297. return
  5298. }
  5299. userJSONBytes3, _ := json.Marshal(respJSON3)
  5300. {
  5301. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5302. utils.ErrorLog("解析失败:%v", err)
  5303. return
  5304. }
  5305. //if res3507for10188.Infcode
  5306. res.InfRefmsgid = res3507for10188.InfRefmsgid
  5307. //res.Output = resSix10265.Output
  5308. res.ErrMsg = res3507for10188.ErrMsg
  5309. res.Cainfo = res3507for10188.Cainfo
  5310. res.WarnMsg = res3507for10188.WarnMsg
  5311. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5312. res.Infcode = infocode
  5313. }
  5314. if res.Infcode == 0 {
  5315. item.IsSale = 1
  5316. item.Bchno = number
  5317. item.SaleDate = time.Now().Format("2006-01-02")
  5318. err5 := service.SaveDF(item)
  5319. if err5 == nil {
  5320. if item.IsChange == 1 { //没变更,进行变更操作
  5321. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5322. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5323. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5324. var respJSON3 map[string]interface{}
  5325. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5327. return
  5328. }
  5329. {
  5330. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5331. utils.ErrorLog("解析失败:%v", err)
  5332. return
  5333. }
  5334. //if res3507for10188.Infcode
  5335. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5336. //res.Output = resSix10265.Output
  5337. res3.ErrMsg = res3507for10188.ErrMsg
  5338. res3.Cainfo = res3507for10188.Cainfo
  5339. res3.WarnMsg = res3507for10188.WarnMsg
  5340. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5341. res3.Infcode = infocode
  5342. }
  5343. if res3.Infcode == 0 {
  5344. item.IsChange = 1
  5345. item.BgBchno = bg_number
  5346. service.SaveDF2(item)
  5347. } else {
  5348. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5349. }
  5350. }
  5351. }
  5352. } else {
  5353. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5354. }
  5355. }
  5356. }
  5357. }
  5358. }
  5359. }
  5360. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5361. var struct3502 models.Struct3502
  5362. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5363. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5364. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5365. struct3502.FixmedinsCode = miConfig.Code
  5366. struct3502.Code = miConfig.Code
  5367. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5368. struct3502.Opter = role.UserName
  5369. struct3502.RxFlag = "1"
  5370. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5371. struct3502.OrgName = miConfig.OrgName
  5372. struct3502.AccessKey = miConfig.AccessKey
  5373. struct3502.RequestUrl = miConfig.Url
  5374. struct3502.SecretKey = miConfig.SecretKey
  5375. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5376. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5377. struct3502.Url = miConfig.Url
  5378. struct3502.AppId = miConfig.Cainfo
  5379. struct3502.AppSecret = miConfig.AppSecret
  5380. struct3502.Enckey = miConfig.EncKey
  5381. struct3502.SignKey = miConfig.SignKey
  5382. struct3502.SecretKey = miConfig.SecretKey
  5383. struct3502.InvChgType = chgType
  5384. struct3502.FixmedinsBchno = number
  5385. struct3502.Cnt = strconv.FormatInt(count, 10)
  5386. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5387. //result1, result2, _ := service.FJyb3502(struct3502)
  5388. if miConfig.MdtrtareaAdmvs == "350500" {
  5389. result1, result2, _ := service.FJyb3502(struct3502)
  5390. //saveLog(result1, result2, "3502", "3502")
  5391. return result1, result2
  5392. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5393. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5394. return result1, result2
  5395. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5396. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5397. return result1, result2
  5398. } else {
  5399. data := make(map[string]interface{})
  5400. data["struct_3502s"] = struct3502
  5401. client := &http.Client{}
  5402. bytesData, _ := json.Marshal(data)
  5403. var req *http.Request
  5404. if miConfig.MdtrtareaAdmvs == "320921" {
  5405. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5406. } else {
  5407. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5408. }
  5409. resp, _ := client.Do(req)
  5410. defer resp.Body.Close()
  5411. body, ioErr := ioutil.ReadAll(resp.Body)
  5412. if ioErr != nil {
  5413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5414. }
  5415. var respJSON map[string]interface{}
  5416. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5418. }
  5419. //var resSix10265 ResultSix10265 //1101结果
  5420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5421. result, _ := json.Marshal(respJSON)
  5422. return string(result), ""
  5423. }
  5424. }
  5425. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5426. var struct3505 models.Struct3505
  5427. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5428. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5429. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5430. struct3505.FixmedinsBchno = number
  5431. struct3505.Opter = role.UserName
  5432. struct3505.Bchno = "---"
  5433. struct3505.FixmedinsCode = miConfig.Code
  5434. struct3505.Code = miConfig.Code
  5435. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5436. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5437. struct3505.PrscDrName = roles.UserName
  5438. if org_id == 10191 {
  5439. struct3505.PharName = "刘水山"
  5440. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5441. }
  5442. if org_id == 10188 {
  5443. struct3505.PharName = "李汉清"
  5444. struct3505.PharPracCertNo = "30220200932022010034"
  5445. }
  5446. if org_id == 10217 {
  5447. struct3505.PharName = "张敏"
  5448. struct3505.PharPracCertNo = "30220230432090100108"
  5449. }
  5450. if org_id == 10318 {
  5451. struct3505.PharName = "邹刘阳"
  5452. struct3505.PharPracCertNo = "210441200001378"
  5453. }
  5454. if org_id == 10402 {
  5455. struct3505.PharName = "刘韶健"
  5456. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5457. }
  5458. if org_id == 9919 {
  5459. struct3505.PharName = "周君权"
  5460. struct3505.PharPracCertNo = "089644396094401375"
  5461. }
  5462. if org_id == 10644 {
  5463. struct3505.PharName = "陈金娣"
  5464. struct3505.PharPracCertNo = "20181441500320100066"
  5465. }
  5466. if org_id == 10567 {
  5467. struct3505.PharName = "范小兰"
  5468. struct3505.PharPracCertNo = "0200102079485"
  5469. }
  5470. if org_id == 10721 {
  5471. struct3505.PharName = "孙莉侠"
  5472. struct3505.PharPracCertNo = "060399"
  5473. }
  5474. if org_id == 10726 {
  5475. struct3505.PharName = "彭建福"
  5476. struct3505.PharPracCertNo = "D445281006261"
  5477. }
  5478. if org_id == 10265 {
  5479. struct3505.PharName = "李彩星"
  5480. struct3505.PharPracCertNo = "20171110600110100019"
  5481. }
  5482. if org_id == 10028 {
  5483. struct3505.PharName = "曾细平"
  5484. struct3505.PharPracCertNo = "D440307022134"
  5485. }
  5486. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5487. struct3505.SetlId = order.SetlId
  5488. struct3505.MdtrtSn = order.MdtrtId
  5489. struct3505.ManuLotnum = drug.BatchNumber
  5490. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5491. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5492. struct3505.RxFlag = "1"
  5493. struct3505.TrdnFlag = "0"
  5494. struct3505.RtalDocno = order.Number
  5495. struct3505.PsnCertType = "01"
  5496. struct3505.CertNo = order.Certno
  5497. struct3505.PsnNo = order.PsnNo
  5498. struct3505.PsnName = order.PsnName
  5499. struct3505.Url = miConfig.Url
  5500. struct3505.AppId = miConfig.Cainfo
  5501. struct3505.AppSecret = miConfig.AppSecret
  5502. struct3505.Enckey = miConfig.EncKey
  5503. struct3505.SignKey = miConfig.SignKey
  5504. struct3505.SecretKey = miConfig.SecretKey
  5505. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5506. struct3505.SelRetnCnt = strValue
  5507. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5508. struct3505.SelRetnOpterName = role.UserName
  5509. if order.IsMedicineInsurance == 1 {
  5510. struct3505.MdtrtSetlType = "1"
  5511. } else {
  5512. struct3505.MdtrtSetlType = "2"
  5513. }
  5514. struct3505.OrgName = miConfig.OrgName
  5515. struct3505.AccessKey = miConfig.AccessKey
  5516. struct3505.RequestUrl = miConfig.Url
  5517. struct3505.SecretKey = miConfig.SecretKey
  5518. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5519. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5520. struct3505.Cainfo = miConfig.Cainfo
  5521. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5522. if miConfig.MdtrtareaAdmvs == "350500" {
  5523. result1, result2, _ := service.FJyb3505(struct3505)
  5524. return result1, result2
  5525. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5526. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5527. return result1, result2
  5528. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5529. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5530. return result1, result2
  5531. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5532. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5533. return result1, result2
  5534. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5535. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5536. return result1, result2
  5537. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5538. data := make(map[string]interface{})
  5539. data["struct_3505s"] = struct3505
  5540. client := &http.Client{}
  5541. bytesData, _ := json.Marshal(data)
  5542. var req *http.Request
  5543. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5544. resp, _ := client.Do(req)
  5545. defer resp.Body.Close()
  5546. body, ioErr := ioutil.ReadAll(resp.Body)
  5547. if ioErr != nil {
  5548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5549. }
  5550. var respJSON map[string]interface{}
  5551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5553. }
  5554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5555. result, _ := json.Marshal(respJSON)
  5556. return string(result), ""
  5557. } else {
  5558. data := make(map[string]interface{})
  5559. data["struct_3505s"] = struct3505
  5560. client := &http.Client{}
  5561. bytesData, _ := json.Marshal(data)
  5562. var req *http.Request
  5563. if miConfig.MdtrtareaAdmvs == "320921" {
  5564. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5565. } else {
  5566. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5567. }
  5568. resp, _ := client.Do(req)
  5569. defer resp.Body.Close()
  5570. body, ioErr := ioutil.ReadAll(resp.Body)
  5571. if ioErr != nil {
  5572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5573. }
  5574. var respJSON map[string]interface{}
  5575. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5577. }
  5578. //var resSix10265 ResultSix10265 //1101结果
  5579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5580. result, _ := json.Marshal(respJSON)
  5581. return string(result), ""
  5582. }
  5583. }
  5584. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5585. var struct3505 models.Struct3505
  5586. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5587. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5588. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5589. struct3505.FixmedinsBchno = number
  5590. struct3505.Opter = role.UserName
  5591. struct3505.FixmedinsCode = miConfig.Code
  5592. struct3505.Code = miConfig.Code
  5593. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5594. struct3505.PrscDrName = roles.UserName
  5595. if org_id == 10191 {
  5596. struct3505.PharName = "刘水山"
  5597. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5598. }
  5599. if org_id == 10188 {
  5600. struct3505.PharName = "李汉清"
  5601. struct3505.PharPracCertNo = "30220200932022010034"
  5602. }
  5603. if org_id == 10217 {
  5604. struct3505.PharName = "张敏"
  5605. struct3505.PharPracCertNo = "30220230432090100108"
  5606. }
  5607. if org_id == 10318 {
  5608. struct3505.PharName = "邹刘阳"
  5609. struct3505.PharPracCertNo = "210441200001378"
  5610. }
  5611. if org_id == 10402 {
  5612. struct3505.PharName = "刘韶健"
  5613. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5614. }
  5615. if org_id == 9919 {
  5616. struct3505.PharName = "周君权"
  5617. struct3505.PharPracCertNo = "089644396094401375"
  5618. }
  5619. if org_id == 10644 {
  5620. struct3505.PharName = "陈金娣"
  5621. struct3505.PharPracCertNo = "20181441500320100066"
  5622. }
  5623. if org_id == 10567 {
  5624. struct3505.PharName = "范小兰"
  5625. struct3505.PharPracCertNo = "0200102079485"
  5626. }
  5627. if org_id == 10721 {
  5628. struct3505.PharName = "孙莉侠"
  5629. struct3505.PharPracCertNo = "060399"
  5630. }
  5631. if org_id == 10726 {
  5632. struct3505.PharName = "彭建福"
  5633. struct3505.PharPracCertNo = "D445281006261"
  5634. }
  5635. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5636. struct3505.SetlId = order.SetlId
  5637. struct3505.MdtrtSn = order.MdtrtId
  5638. struct3505.ManuLotnum = drug.Number
  5639. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5640. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5641. struct3505.RxFlag = "1"
  5642. struct3505.TrdnFlag = "0"
  5643. struct3505.RtalDocno = order.Number
  5644. struct3505.PsnCertType = "01"
  5645. struct3505.CertNo = order.Certno
  5646. struct3505.PsnNo = order.PsnNo
  5647. struct3505.PsnName = order.PsnName
  5648. struct3505.Url = miConfig.Url
  5649. struct3505.AppId = miConfig.Cainfo
  5650. struct3505.AppSecret = miConfig.AppSecret
  5651. struct3505.Enckey = miConfig.EncKey
  5652. struct3505.SignKey = miConfig.SignKey
  5653. struct3505.SecretKey = miConfig.SecretKey
  5654. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5655. struct3505.SelRetnCnt = strValue
  5656. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5657. struct3505.SelRetnOpterName = role.UserName
  5658. if order.IsMedicineInsurance == 1 {
  5659. struct3505.MdtrtSetlType = "1"
  5660. } else {
  5661. struct3505.MdtrtSetlType = "2"
  5662. }
  5663. struct3505.OrgName = miConfig.OrgName
  5664. struct3505.AccessKey = miConfig.AccessKey
  5665. struct3505.RequestUrl = miConfig.Url
  5666. struct3505.SecretKey = miConfig.SecretKey
  5667. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5668. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5669. struct3505.Cainfo = miConfig.Cainfo
  5670. struct3505.DrugTracCodg = drug.DrugCode
  5671. if miConfig.MdtrtareaAdmvs == "350500" {
  5672. result1, result2, _ := service.FJyb3505(struct3505)
  5673. return result1, result2
  5674. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5675. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5676. return result1, result2
  5677. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5678. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5679. return result1, result2
  5680. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5681. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5682. return result1, result2
  5683. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5684. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5685. return result1, result2
  5686. } else {
  5687. data := make(map[string]interface{})
  5688. data["struct_3505s"] = struct3505
  5689. client := &http.Client{}
  5690. bytesData, _ := json.Marshal(data)
  5691. var req *http.Request
  5692. if miConfig.MdtrtareaAdmvs == "320921" {
  5693. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5694. } else {
  5695. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5696. }
  5697. resp, _ := client.Do(req)
  5698. defer resp.Body.Close()
  5699. body, ioErr := ioutil.ReadAll(resp.Body)
  5700. if ioErr != nil {
  5701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5702. }
  5703. var respJSON map[string]interface{}
  5704. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5706. }
  5707. //var resSix10265 ResultSix10265 //1101结果
  5708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5709. result, _ := json.Marshal(respJSON)
  5710. return string(result), ""
  5711. }
  5712. }
  5713. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5714. var struct3506 models.Struct3506
  5715. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5716. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5717. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5718. struct3506.FixmedinsCode = miConfig.Code
  5719. struct3506.Code = miConfig.Code
  5720. struct3506.FixmedinsBchno = number
  5721. struct3506.Opter = role.UserName
  5722. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5723. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5724. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5725. struct3506.MdtrtSn = order.MdtrtId
  5726. struct3506.ExpyEnd = ""
  5727. struct3506.RxFlag = "0"
  5728. struct3506.TrdnFlag = "1"
  5729. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5730. struct3506.SelRetnCnt = strValue
  5731. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5732. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5733. struct3506.SelRetnOpterName = role.UserName
  5734. struct3506.OrgName = miConfig.OrgName
  5735. struct3506.AccessKey = miConfig.AccessKey
  5736. struct3506.RequestUrl = miConfig.Url
  5737. struct3506.SecretKey = miConfig.SecretKey
  5738. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5739. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5740. struct3506.Url = miConfig.Url
  5741. struct3506.AppId = miConfig.Cainfo
  5742. struct3506.AppSecret = miConfig.AppSecret
  5743. struct3506.Enckey = miConfig.EncKey
  5744. struct3506.SignKey = miConfig.SignKey
  5745. struct3506.SecretKey = miConfig.SecretKey
  5746. struct3506.DrugTracCodg = drug.DrugCode
  5747. if miConfig.MdtrtareaAdmvs == "350500" {
  5748. result1, result2, _ := service.FJyb3506(struct3506)
  5749. return result1, result2
  5750. } else {
  5751. data := make(map[string]interface{})
  5752. data["struct_3506s"] = struct3506
  5753. client := &http.Client{}
  5754. bytesData, _ := json.Marshal(data)
  5755. var req *http.Request
  5756. if miConfig.MdtrtareaAdmvs == "320921" {
  5757. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5758. } else {
  5759. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5760. }
  5761. resp, _ := client.Do(req)
  5762. defer resp.Body.Close()
  5763. body, ioErr := ioutil.ReadAll(resp.Body)
  5764. if ioErr != nil {
  5765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5766. }
  5767. var respJSON map[string]interface{}
  5768. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5770. }
  5771. //var resSix10265 ResultSix10265 //1101结果
  5772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5773. result, _ := json.Marshal(respJSON)
  5774. return string(result), ""
  5775. }
  5776. }
  5777. func (c *HisApiController) Get1318() {
  5778. adminUser := c.GetAdminUserInfo()
  5779. admin_user_id, _ := c.GetInt64("admin_user_id")
  5780. code := c.GetString("code")
  5781. code = ""
  5782. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5784. api := ""
  5785. if miConfig.MdtrtareaAdmvs == "320921" {
  5786. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5787. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5788. } else {
  5789. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5790. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5791. }
  5792. resp, requestErr := http.Get(api)
  5793. if requestErr != nil {
  5794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5795. return
  5796. }
  5797. body, ioErr := ioutil.ReadAll(resp.Body)
  5798. if ioErr != nil {
  5799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5801. return
  5802. }
  5803. var respJSON map[string]interface{}
  5804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5807. return
  5808. }
  5809. //var res Result2406
  5810. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5811. result, _ := json.Marshal(respJSON)
  5812. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5813. utils.ErrorLog("解析失败:%v", err)
  5814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5815. return
  5816. }
  5817. if res.Infcode == "0" {
  5818. c.ServeSuccessJSON(map[string]interface{}{
  5819. "result": "",
  5820. })
  5821. } else {
  5822. c.ServeSuccessJSON(map[string]interface{}{
  5823. "failed_code": -10,
  5824. "msg": res.ErrMsg,
  5825. })
  5826. */return
  5827. //}
  5828. }
  5829. func (c *HisApiController) Get2503() {
  5830. adminUser := c.GetAdminUserInfo()
  5831. admin_user_id, _ := c.GetInt64("admin_user_id")
  5832. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5833. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5834. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5835. }
  5836. func (c *HisApiController) Get2406() {
  5837. id, _ := c.GetInt64("id")
  5838. record_time := c.GetString("record_time")
  5839. his_patient_id, _ := c.GetInt64("his_patient_id")
  5840. admin_user_id, _ := c.GetInt64("admin_user_id")
  5841. diagnosis_id := c.GetString("diagnosis")
  5842. timeLayout := "2006-01-02"
  5843. loc, _ := time.LoadLocation("Local")
  5844. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5845. if err != nil {
  5846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5847. return
  5848. }
  5849. recordDateTime := theTime.Unix()
  5850. adminUser := c.GetAdminUserInfo()
  5851. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5852. var config []*models.HisXtDiagnoseConfig
  5853. for _, item := range diagnosis_ids {
  5854. id, _ := strconv.ParseInt(item, 10, 64)
  5855. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5856. config = append(config, &diagnosisConfig)
  5857. }
  5858. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5859. fmt.Println(his_patient_id)
  5860. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5861. //timestamp := time.Now().Unix()
  5862. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5863. var patientPrescription models.HisPrescriptionInfo
  5864. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5865. if patientPrescription.ID == 0 {
  5866. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5867. }
  5868. var res2 Result2406
  5869. if miConfig.MdtrtareaAdmvs == "341203" {
  5870. data := make(map[string]interface{})
  5871. client := &http.Client{}
  5872. data["psn_no"] = his.PsnNo
  5873. data["mdtrt_id"] = his.Number
  5874. data["operator"] = roles.UserName
  5875. data["cert_no"] = his.IdCardNo
  5876. data["org_name"] = miConfig.OrgName
  5877. data["psn_name"] = his.Name
  5878. data["ipt_otp_no"] = his.IptOtpNo
  5879. data["ipt_psn_sp_flag_type"] = "0901"
  5880. data["ipt_psn_sp_flag"] = "1"
  5881. data["fixmedins_code"] = miConfig.Code
  5882. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5883. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5884. data["url"] = miConfig.Url
  5885. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5886. bytesData, _ := json.Marshal(data)
  5887. var req *http.Request
  5888. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5889. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5890. resp, _ := client.Do(req)
  5891. defer resp.Body.Close()
  5892. body, ioErr := ioutil.ReadAll(resp.Body)
  5893. if ioErr != nil {
  5894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5896. return
  5897. }
  5898. var respJSON map[string]interface{}
  5899. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5902. return
  5903. }
  5904. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5905. if status == "0" {
  5906. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5907. c.ServeSuccessJSON(map[string]interface{}{
  5908. "failed_code": -10,
  5909. "msg": err_msg,
  5910. })
  5911. return
  5912. }
  5913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5914. userJSONBytes, _ := json.Marshal(respJSON)
  5915. fmt.Println("log")
  5916. fmt.Println(string(userJSONBytes))
  5917. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5918. utils.ErrorLog("解析失败:%v", err)
  5919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5920. return
  5921. }
  5922. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5923. data := make(map[string]interface{})
  5924. client := &http.Client{}
  5925. data["psn_no"] = his.PsnNo
  5926. data["mdtrt_id"] = his.Number
  5927. data["operator"] = roles.UserName
  5928. data["cert_no"] = his.IdCardNo
  5929. data["org_name"] = miConfig.OrgName
  5930. data["psn_name"] = his.Name
  5931. data["ipt_otp_no"] = his.IptOtpNo
  5932. data["ipt_psn_sp_flag_type"] = "0901"
  5933. data["ipt_psn_sp_flag"] = "1"
  5934. data["fixmedins_code"] = miConfig.Code
  5935. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5936. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5937. data["url"] = miConfig.Url
  5938. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5939. bytesData, _ := json.Marshal(data)
  5940. var req *http.Request
  5941. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5942. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5943. resp, _ := client.Do(req)
  5944. defer resp.Body.Close()
  5945. body, ioErr := ioutil.ReadAll(resp.Body)
  5946. if ioErr != nil {
  5947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5949. return
  5950. }
  5951. var respJSON map[string]interface{}
  5952. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5955. return
  5956. }
  5957. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5958. if status == "0" {
  5959. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5960. c.ServeSuccessJSON(map[string]interface{}{
  5961. "failed_code": -10,
  5962. "msg": err_msg,
  5963. })
  5964. return
  5965. }
  5966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5967. userJSONBytes, _ := json.Marshal(respJSON)
  5968. fmt.Println("log")
  5969. fmt.Println(string(userJSONBytes))
  5970. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5971. utils.ErrorLog("解析失败:%v", err)
  5972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5973. return
  5974. }
  5975. }
  5976. if res2.Infcode != 0 {
  5977. adminUser := c.GetAdminUserInfo()
  5978. errlog := &models.HisOrderError{
  5979. UserOrgId: adminUser.CurrentOrgId,
  5980. Ctime: time.Now().Unix(),
  5981. Mtime: time.Now().Unix(),
  5982. ErrMsg: res2.ErrMsg,
  5983. Status: 1,
  5984. PatientId: id,
  5985. RecordTime: recordDateTime,
  5986. Stage: 3,
  5987. }
  5988. service.CreateErrMsgLog(errlog)
  5989. c.ServeSuccessJSON(map[string]interface{}{
  5990. "failed_code": -10,
  5991. "msg": res2.ErrMsg,
  5992. })
  5993. return
  5994. } else {
  5995. c.ServeSuccessJSON(map[string]interface{}{
  5996. "msg": "上传成功",
  5997. })
  5998. return
  5999. }
  6000. }
  6001. func (c *HisApiController) Get4105() {
  6002. }
  6003. func (c *HisApiController) Post5302() {
  6004. patient_id, _ := c.GetInt64("id")
  6005. admin_user_id, _ := c.GetInt64("admin_user_id")
  6006. p, _ := service.GetHisPatientById(patient_id)
  6007. adminUser := c.GetAdminUserInfo()
  6008. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6009. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6010. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6011. }
  6012. func (c *HisApiController) Get4104() {
  6013. }
  6014. type Output struct {
  6015. CertNo string `json:"certno"`
  6016. PsnName string `json:"psn_name"`
  6017. CardNo string `json:"card_no"`
  6018. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6019. CardSN string `json:"card_sn"`
  6020. PsnCertType string `json:"psn_cert_type"`
  6021. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6022. MdtrtCertType string `json:"mdtrt_cert_type"`
  6023. QRCode string `json:"qrCode"`
  6024. EcToken string `json:"ecToken"`
  6025. }
  6026. type AHResponse struct {
  6027. Body AHBody `json:"body"`
  6028. Code int `json:"code"`
  6029. CSBCode int `json:"csbCode"`
  6030. Message string `json:"message"`
  6031. RequestID string `json:"requestId"`
  6032. State struct{} `json:"state"`
  6033. }
  6034. type AHBody struct {
  6035. ErrMsg string `json:"err_msg"`
  6036. InfRefMsgID string `json:"inf_refmsgid"`
  6037. InfCode int `json:"infcode"`
  6038. Output struct {
  6039. Result []struct {
  6040. BasMednFlag string `json:"bas_medn_flag"`
  6041. ChldMedcFlag string `json:"chld_medc_flag"`
  6042. ChrgitmLv string `json:"chrgitm_lv"`
  6043. Cnt float64 `json:"cnt"`
  6044. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6045. DrtReimFlag string `json:"drt_reim_flag"`
  6046. FeedetlSn string `json:"feedetl_sn"`
  6047. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6048. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6049. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6050. ListSpItemFlag string `json:"list_sp_item_flag"`
  6051. LmtUsedFlag string `json:"lmt_used_flag"`
  6052. MedChrgitmType string `json:"med_chrgitm_type"`
  6053. Memo string `json:"memo"`
  6054. OverlmtAmt float64 `json:"overlmt_amt"`
  6055. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6056. Pric float64 `json:"pric"`
  6057. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6058. SelfpayProp float64 `json:"selfpay_prop"`
  6059. } `json:"result"`
  6060. } `json:"output"`
  6061. }
  6062. type Response struct {
  6063. Output Output `json:"output"`
  6064. Infcode int `json:"infcode"`
  6065. InfRefMsgID string `json:"inf_refmsgid"`
  6066. RefMsgTime string `json:"refmsg_time"`
  6067. RespondTime string `json:"respond_time"`
  6068. ErrMsg string `json:"err_msg"`
  6069. WarnMsg string `json:"warn_msg"`
  6070. SignType string `json:"signtype"`
  6071. CAInfo string `json:"cainfo"`
  6072. }
  6073. func (c *HisApiController) Getquerydata() {
  6074. query_type, _ := c.GetInt64("type")
  6075. refd_setl_flag := c.GetString("refd_setl_flag")
  6076. med_type := c.GetString("med_type")
  6077. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6078. cert_no := c.GetString("cert_no")
  6079. psn_no := c.GetString("psn_no")
  6080. start_time := c.GetString("start_time")
  6081. end_time := c.GetString("end_time")
  6082. page, _ := c.GetInt64("page")
  6083. limit, _ := c.GetInt64("limit")
  6084. var bp models.BusinessParams5262
  6085. bp.RefdSetlFlag = refd_setl_flag
  6086. bp.MedType = med_type
  6087. bp.Certno = cert_no
  6088. bp.Psnno = psn_no
  6089. bp.QBegntime = start_time
  6090. bp.QEndtime = end_time
  6091. if query_type == 1 { //本地
  6092. Post5262(c, bp, page, limit)
  6093. } else { //异地
  6094. Post5267(c, bp, page, limit)
  6095. }
  6096. }
  6097. func (c *HisApiController) Drugscheck() {
  6098. admin_user_id, _ := c.GetInt64("admin_user_id")
  6099. adminUser := c.GetAdminUserInfo()
  6100. var queryResult []QueryResult
  6101. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6102. for _, item := range drugs {
  6103. result := QueryResult{
  6104. ID: item.ID,
  6105. Name: item.DrugName,
  6106. Code: item.MedicalInsuranceNumber,
  6107. List_type_code: "101",
  6108. }
  6109. queryResult = append(queryResult, result)
  6110. }
  6111. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6112. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6113. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6114. for _, item := range queryResult {
  6115. 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)
  6116. }
  6117. }
  6118. func (c *HisApiController) Goodcheck() {
  6119. admin_user_id, _ := c.GetInt64("admin_user_id")
  6120. adminUser := c.GetAdminUserInfo()
  6121. var queryResult []QueryResult
  6122. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6123. for _, item := range goods {
  6124. result := QueryResult{
  6125. ID: item.ID,
  6126. Name: item.GoodName,
  6127. Code: item.SocialSecurityDirectoryCode,
  6128. List_type_code: "301",
  6129. }
  6130. queryResult = append(queryResult, result)
  6131. }
  6132. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6133. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6134. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6135. for _, item := range queryResult {
  6136. 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)
  6137. //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)
  6138. }
  6139. }
  6140. func (c *HisApiController) Projectcheck() {
  6141. admin_user_id, _ := c.GetInt64("admin_user_id")
  6142. adminUser := c.GetAdminUserInfo()
  6143. var queryResult []QueryResult
  6144. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6145. for _, item := range projects {
  6146. result := QueryResult{
  6147. ID: item.ID,
  6148. Name: item.ProjectName,
  6149. Code: item.MedicalCode,
  6150. List_type_code: "201",
  6151. }
  6152. queryResult = append(queryResult, result)
  6153. }
  6154. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6155. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6156. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6157. for _, item := range queryResult {
  6158. 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)
  6159. }
  6160. }
  6161. //func (c *HisApiController)CancleDia(){
  6162. //
  6163. // id, _ := c.GetInt64("id")
  6164. // record_time := c.GetString("record_time")
  6165. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6166. //
  6167. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6168. //
  6169. // diagnosis_id := c.GetString("diagnosis")
  6170. // sick_type, _ := c.GetInt64("sick_type")
  6171. // reg_type, _ := c.GetInt64("p_type")
  6172. // begin_time := c.GetString("begin_time")
  6173. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6174. //
  6175. //
  6176. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6177. //
  6178. // fmt.Println(acct_used_flag)
  6179. //
  6180. //
  6181. // timeLayout := "2006-01-02"
  6182. // loc, _ := time.LoadLocation("Local")
  6183. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6184. // if err != nil {
  6185. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6186. // return
  6187. // }
  6188. // recordDateTime := theTime.Unix()
  6189. // adminUser := c.GetAdminUserInfo()
  6190. //
  6191. //
  6192. //
  6193. //
  6194. //
  6195. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6196. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6197. // var patientPrescription models.HisPrescriptionInfo
  6198. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6199. // if patientPrescription.ID == 0 {
  6200. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6201. // }
  6202. // //if patientPrescription.Do
  6203. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6204. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6205. //
  6206. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6207. //
  6208. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6209. //
  6210. // var config []*models.HisXtDiagnoseConfig
  6211. // for _, item := range diagnosis_ids {
  6212. // id, _ := strconv.ParseInt(item, 10, 64)
  6213. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6214. // config = append(config, &diagnosisConfig)
  6215. // }
  6216. //
  6217. // sickConfig, _ := service.FindSickById(sick_type)
  6218. //
  6219. //
  6220. // data := make(map[string]interface{})
  6221. // client := &http.Client{}
  6222. // data["psn_no"] = his.PsnNo
  6223. // data["mdtrt_id"] = his.Number
  6224. // data["doctor"] = roles.UserName
  6225. // data["department"] = department.Name
  6226. // data["org_name"] = miConfig.OrgName
  6227. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6228. // data["doctor_id"] = doctor_info.DoctorNumber
  6229. // data["new_doctor_name"] = doctor_info.UserName
  6230. // data["fixmedins_code"] = miConfig.Code
  6231. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6232. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6233. // data["secret_key"] = miConfig.SecretKey
  6234. // data["sick_code"] = sickConfig.CountryCode
  6235. // data["sick_name"] = sickConfig.ClassName
  6236. // data["url"] = miConfig.Url
  6237. // data["ak"] = miConfig.AccessKey
  6238. // data["begin_time"] = begin_time
  6239. // data["cainfo"] = miConfig.Cainfo
  6240. // data["is_vaild"] = "0"
  6241. //
  6242. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6243. // data["config"] = config
  6244. // bytesData, _ := json.Marshal(data)
  6245. //
  6246. // var req *http.Request
  6247. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6248. // resp, _ := client.Do(req)
  6249. // defer resp.Body.Close()
  6250. // body, ioErr := ioutil.ReadAll(resp.Body)
  6251. // if ioErr != nil {
  6252. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6254. // return
  6255. // }
  6256. // var respJSON map[string]interface{}
  6257. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6258. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6260. // return
  6261. // }
  6262. //
  6263. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6264. // userJSONBytes, _ := json.Marshal(respJSON)
  6265. // fmt.Println("log")
  6266. // fmt.Println(string(userJSONBytes))
  6267. //
  6268. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6269. // utils.ErrorLog("解析失败:%v", err)
  6270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6271. // return
  6272. // }
  6273. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6274. // res2.Output = ressix10265.Output
  6275. // res2.ErrMsg = ressix10265.ErrMsg
  6276. // res2.Cainfo = ressix10265.Cainfo
  6277. // res2.WarnMsg = ressix10265.WarnMsg
  6278. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6279. // res2.Infcode = infocode
  6280. //
  6281. //}
  6282. func (c *HisApiController) Get4102() {
  6283. order_id, _ := c.GetInt64("order_id")
  6284. admin_user_id, _ := c.GetInt64("admin_user_id")
  6285. stas_type := c.GetString("stas_type")
  6286. order, _ := service.GetHisOrderByIDTwo(order_id)
  6287. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6288. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6289. var pp models.PublicParams
  6290. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6291. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6292. pp.FixmedinsName = miConfig.OrgName
  6293. pp.FixmedinsCode = miConfig.Code
  6294. pp.RequestUrl = miConfig.Url
  6295. pp.Cainfo = miConfig.Cainfo
  6296. pp.SecretKey = miConfig.SecretKey
  6297. pp.AccessKey = miConfig.AccessKey
  6298. pp.OpterName = curRoles.UserName
  6299. if miConfig.MdtrtareaAdmvs == "350500" {
  6300. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6301. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6302. saveLog(result, request, "4102", "清单确认")
  6303. var dat map[string]interface{}
  6304. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6305. fmt.Println(dat)
  6306. } else {
  6307. fmt.Println(err)
  6308. }
  6309. var empty ResultFourteen
  6310. userJSONBytes, _ := json.Marshal(dat)
  6311. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6312. utils.ErrorLog("解析失败:%v", err)
  6313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6314. return
  6315. }
  6316. if empty.Infcode == 0 {
  6317. c.ServeSuccessJSON(map[string]interface{}{
  6318. "msg": "确认成功",
  6319. })
  6320. return
  6321. }
  6322. } else {
  6323. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6324. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6325. result3, request3 := service.Jxyb4105(pp)
  6326. saveLog(result, request, "4102", "清单确认")
  6327. saveLog(result2, request2, "4103", "清单确认")
  6328. saveLog(result3, request3, "4105", "清单统计")
  6329. var dat map[string]interface{}
  6330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6331. fmt.Println(dat)
  6332. } else {
  6333. fmt.Println(err)
  6334. }
  6335. var empty ResultFourteen
  6336. userJSONBytes, _ := json.Marshal(dat)
  6337. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6338. utils.ErrorLog("解析失败:%v", err)
  6339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6340. return
  6341. }
  6342. if empty.Infcode == 0 {
  6343. c.ServeSuccessJSON(map[string]interface{}{
  6344. "msg": "确认成功",
  6345. })
  6346. return
  6347. }
  6348. }
  6349. }
  6350. // 对账权限查询
  6351. func (c *HisApiController) Get3260() {
  6352. admin_user_id, _ := c.GetInt64("admin_user_id")
  6353. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6354. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6355. var api string
  6356. var res models.JSResult3260
  6357. if miConfig.MdtrtareaAdmvs == "320921" {
  6358. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6359. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6360. } else {
  6361. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6362. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6363. }
  6364. resp, requestErr := http.Get(api)
  6365. if requestErr != nil {
  6366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6367. return
  6368. }
  6369. body, ioErr := ioutil.ReadAll(resp.Body)
  6370. if ioErr != nil {
  6371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6373. return
  6374. }
  6375. var respJSON map[string]interface{}
  6376. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6379. return
  6380. }
  6381. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6382. result, _ := json.Marshal(respJSON)
  6383. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6384. utils.ErrorLog("解析失败:%v", err)
  6385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6386. return
  6387. }
  6388. if res.Infcode == "0" {
  6389. c.ServeSuccessJSON(map[string]interface{}{
  6390. "result": res.Output.Data,
  6391. })
  6392. } else {
  6393. c.ServeSuccessJSON(map[string]interface{}{
  6394. "failed_code": -10,
  6395. "msg": res.ErrMsg,
  6396. })
  6397. return
  6398. }
  6399. }
  6400. func (c *HisApiController) Get3261() {
  6401. admin_user_id, _ := c.GetInt64("admin_user_id")
  6402. //month := c.GetString("month")
  6403. startTime := c.GetString("start_time")
  6404. //endTime, _ := c.GetString("end_time")
  6405. times := strings.Split(startTime, "-")
  6406. stmt_mon := times[0] + times[1]
  6407. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6408. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6409. var api string
  6410. var res models.JSResult3261
  6411. //var res10265 Result5301For10265
  6412. if miConfig.MdtrtareaAdmvs == "320921" {
  6413. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6414. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6415. } else {
  6416. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6417. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6418. }
  6419. resp, requestErr := http.Get(api)
  6420. if requestErr != nil {
  6421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6422. return
  6423. }
  6424. body, ioErr := ioutil.ReadAll(resp.Body)
  6425. if ioErr != nil {
  6426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6428. return
  6429. }
  6430. var respJSON map[string]interface{}
  6431. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6434. return
  6435. }
  6436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6437. result, _ := json.Marshal(respJSON)
  6438. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6439. utils.ErrorLog("解析失败:%v", err)
  6440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6441. return
  6442. }
  6443. if res.Infcode == "0" {
  6444. c.ServeSuccessJSON(map[string]interface{}{
  6445. "result": res.Output,
  6446. })
  6447. } else {
  6448. c.ServeSuccessJSON(map[string]interface{}{
  6449. "failed_code": -10,
  6450. "msg": res.ErrMsg,
  6451. })
  6452. return
  6453. }
  6454. }
  6455. type TempFun struct {
  6456. FundKey string
  6457. FundCode string
  6458. }
  6459. func (c *HisApiController) Get3262() {
  6460. admin_user_id, _ := c.GetInt64("admin_user_id")
  6461. startTime := c.GetString("start_time")
  6462. endTime := c.GetString("end_time")
  6463. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6464. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6465. //timeLayout := "2006-01-02"
  6466. //loc, _ := time.LoadLocation("Local")
  6467. //var theStartTIme int64
  6468. //if len(startTime) > 0 {
  6469. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6470. // if err != nil {
  6471. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6472. // return
  6473. // }
  6474. // theStartTIme = theTime.Unix()
  6475. //}
  6476. //var theEndtTIme int64
  6477. //if len(endTime) > 0 {
  6478. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6479. // if err != nil {
  6480. // utils.ErrorLog(err.Error())
  6481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6482. // return
  6483. // }
  6484. // theEndtTIme = theTime.Unix()
  6485. //}
  6486. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6487. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6488. for _, team := range datas {
  6489. fmt.Println(team.PsnTime)
  6490. for _, team_two := range datas_two {
  6491. fmt.Println(team_two.PsnTime)
  6492. if team.FundKey == team_two.FundKey {
  6493. fmt.Println(team_two.PsnTime)
  6494. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6495. fmt.Println(team.PsnTime)
  6496. }
  6497. }
  6498. }
  6499. fmt.Println("1111")
  6500. fmt.Println(datas)
  6501. fmt.Println("1111")
  6502. var twos []models.FixMonRecDetailFileInTwo
  6503. for _, team := range datas {
  6504. var two models.FixMonRecDetailFileInTwo
  6505. two.MedType = team.MedType
  6506. two.Insutype = team.Insutype
  6507. two.PsnType = team.PsnType
  6508. two.MedType = team.MedType
  6509. two.FixBlngAdmdvs = "999999"
  6510. two.InsuAdmdvs = "555555"
  6511. two.PsnTime = team.PsnTime
  6512. two.PsnCnt = team.PsnCnt
  6513. two.FundKey = team.FundKey
  6514. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6515. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6516. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6517. two.MedfeeSumAmt = ms
  6518. two.InscpAmt = ia
  6519. two.FundPaySumAmt = fps
  6520. twos = append(twos, two)
  6521. }
  6522. //startTime := c.GetString("start_time")
  6523. //endTime, _ := c.GetString("end_time")
  6524. times := strings.Split(startTime, "-")
  6525. stmt_mon := times[0] + times[1]
  6526. var funs []models.FundDetail
  6527. for _, item := range datas {
  6528. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6529. funs = append(funs, fun...)
  6530. }
  6531. var funInfos []models.Fund
  6532. //for _, item := range funs {
  6533. // var rf []models.FundInfo
  6534. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6535. // for _, subitem := range rf {
  6536. // var fund models.Fund
  6537. // fund.FundCode = subitem.FundPayType
  6538. // fund.FundName = subitem.FundPayTypeName
  6539. // fund.FundAmt = subitem.FundPayAmt
  6540. // fund.FundKey = item.FundKey
  6541. // fund.InsuAdmdvs = "555555"
  6542. // fund.FixBlngAdmdvs = "999999"
  6543. // funInfos = append(funInfos, fund)
  6544. // }
  6545. //}
  6546. var tempFuns []TempFun
  6547. for _, funInfo := range funInfos {
  6548. var tempFun TempFun
  6549. tempFun.FundKey = funInfo.FundKey
  6550. tempFun.FundCode = funInfo.FundCode
  6551. tempFuns = append(tempFuns, tempFun)
  6552. }
  6553. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6554. fmt.Println(tempFuns)
  6555. var funInfosTwo []models.Fund
  6556. decimal.DivisionPrecision = 2
  6557. for _, item := range tempFuns {
  6558. var fund models.Fund
  6559. for _, subItem := range funInfos {
  6560. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6561. fund.FundKey = subItem.FundKey
  6562. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6563. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6564. fund.FundName = subItem.FundName
  6565. fund.FundCode = subItem.FundCode
  6566. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6567. }
  6568. }
  6569. funInfosTwo = append(funInfosTwo, fund)
  6570. }
  6571. fmt.Println("funInfosTwo")
  6572. fmt.Println(funInfosTwo)
  6573. var upld_btch string
  6574. var empty models.JSResultEmpty
  6575. data := make(map[string]interface{})
  6576. data["org_name"] = miConfig.OrgName
  6577. data["doctor"] = curRoles.UserName
  6578. data["doctor_name"] = curRoles.UserName
  6579. data["fixmedins_code"] = miConfig.Code
  6580. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6581. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6582. data["secret_key"] = miConfig.SecretKey
  6583. data["url"] = miConfig.Url
  6584. data["ak"] = miConfig.AccessKey
  6585. data["cainfo"] = miConfig.Cainfo
  6586. data["datas"] = twos
  6587. data["fund"] = funInfosTwo
  6588. fmt.Println(twos)
  6589. month := time.Unix(1557042972, 0).Format("1")
  6590. year := time.Now().Format("2006")
  6591. month = time.Now().Format("01")
  6592. day := time.Now().Format("02")
  6593. hour := time.Now().Format("15")
  6594. min := time.Now().Format("04")
  6595. sec := time.Now().Format("05")
  6596. fix_fill_date := year + month + day + hour + min + sec
  6597. data["fix_fill_dept"] = miConfig.OrgName
  6598. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6599. data["fix_fill_psn"] = curRoles.UserName
  6600. data["fix_fill_date"] = fix_fill_date
  6601. data["stmt_loc"] = "2"
  6602. data["setl_mon"] = stmt_mon
  6603. upld_btch = "0"
  6604. data["upld_btch"] = upld_btch
  6605. //fmt.Println(data)
  6606. client := &http.Client{}
  6607. bytesData, _ := json.Marshal(data)
  6608. var req *http.Request
  6609. if miConfig.MdtrtareaAdmvs == "320921" {
  6610. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6611. } else {
  6612. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6613. }
  6614. resp, _ := client.Do(req)
  6615. defer resp.Body.Close()
  6616. body, ioErr := ioutil.ReadAll(resp.Body)
  6617. if ioErr != nil {
  6618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6620. }
  6621. var respJSON map[string]interface{}
  6622. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6625. }
  6626. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6627. //fmt.Println(respJSON)
  6628. result, _ := json.Marshal(respJSON)
  6629. //fmt.Println(result)
  6630. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6631. utils.ErrorLog("解析失败:%v", err)
  6632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6633. }
  6634. if empty.Infcode != "0" {
  6635. c.ServeSuccessJSON(map[string]interface{}{
  6636. "failed_code": -10,
  6637. "msg": empty.ErrMsg,
  6638. })
  6639. return
  6640. } else {
  6641. c.ServeSuccessJSON(map[string]interface{}{
  6642. "msg": "上传成功",
  6643. })
  6644. return
  6645. }
  6646. }
  6647. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6648. newArr = make([]TempFun, 0)
  6649. for i := 0; i < len(arr); i++ {
  6650. repeat := false
  6651. for j := i + 1; j < len(arr); j++ {
  6652. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6653. repeat = true
  6654. break
  6655. }
  6656. }
  6657. if !repeat {
  6658. newArr = append(newArr, arr[i])
  6659. }
  6660. }
  6661. return
  6662. }
  6663. func (c *HisApiController) Get3263() {
  6664. admin_user_id, _ := c.GetInt64("admin_user_id")
  6665. startTime := c.GetString("start_time")
  6666. //endTime, _ := c.GetString("end_time")
  6667. times := strings.Split(startTime, "-")
  6668. setl_mon := times[0] + times[1]
  6669. upld_btch := "0"
  6670. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6671. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6672. var result3263 models.JSResult3263
  6673. data := make(map[string]interface{})
  6674. data["org_name"] = miConfig.OrgName
  6675. data["doctor"] = curRoles.UserName
  6676. data["doctor_name"] = curRoles.UserName
  6677. data["fixmedins_code"] = miConfig.Code
  6678. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6679. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6680. data["secret_key"] = miConfig.SecretKey
  6681. data["url"] = miConfig.Url
  6682. data["ak"] = miConfig.AccessKey
  6683. data["cainfo"] = miConfig.Cainfo
  6684. data["setl_mon"] = setl_mon
  6685. data["stmt_loc"] = "2"
  6686. data["upld_btch"] = upld_btch
  6687. client := &http.Client{}
  6688. bytesData, _ := json.Marshal(data)
  6689. var req *http.Request
  6690. if miConfig.MdtrtareaAdmvs == "320921" {
  6691. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6692. } else {
  6693. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6694. }
  6695. resp, _ := client.Do(req)
  6696. defer resp.Body.Close()
  6697. body, ioErr := ioutil.ReadAll(resp.Body)
  6698. if ioErr != nil {
  6699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6701. }
  6702. var respJSON map[string]interface{}
  6703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6706. }
  6707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6708. fmt.Println(respJSON)
  6709. result, _ := json.Marshal(respJSON)
  6710. fmt.Println(result)
  6711. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6712. utils.ErrorLog("解析失败:%v", err)
  6713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6714. }
  6715. if result3263.Infcode != "0" {
  6716. c.ServeSuccessJSON(map[string]interface{}{
  6717. "failed_code": -10,
  6718. "msg": result3263.ErrMsg,
  6719. })
  6720. return
  6721. } else {
  6722. c.ServeSuccessJSON(map[string]interface{}{
  6723. "list": result3263.Output,
  6724. })
  6725. return
  6726. }
  6727. }
  6728. func (c *HisApiController) Get3264() {
  6729. admin_user_id, _ := c.GetInt64("admin_user_id")
  6730. startTime := c.GetString("start_time")
  6731. //endTime, _ := c.GetString("end_time")
  6732. times := strings.Split(startTime, "-")
  6733. setl_mon := times[0] + times[1]
  6734. upld_btch := "0"
  6735. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6736. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6737. //solidify_id := []
  6738. var result3263 models.JSResult3263
  6739. data := make(map[string]interface{})
  6740. data["org_name"] = miConfig.OrgName
  6741. data["doctor"] = curRoles.UserName
  6742. data["doctor_name"] = curRoles.UserName
  6743. data["fixmedins_code"] = miConfig.Code
  6744. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6745. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6746. data["secret_key"] = miConfig.SecretKey
  6747. data["url"] = miConfig.Url
  6748. data["ak"] = miConfig.AccessKey
  6749. data["cainfo"] = miConfig.Cainfo
  6750. data["setl_mon"] = setl_mon
  6751. data["stmt_loc"] = "2"
  6752. data["upld_btch"] = upld_btch
  6753. client := &http.Client{}
  6754. bytesData, _ := json.Marshal(data)
  6755. var req3263 *http.Request
  6756. if miConfig.MdtrtareaAdmvs == "320921" {
  6757. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6758. } else {
  6759. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6760. }
  6761. resp, _ := client.Do(req3263)
  6762. defer resp.Body.Close()
  6763. body, ioErr := ioutil.ReadAll(resp.Body)
  6764. if ioErr != nil {
  6765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6767. }
  6768. var respJSON3263 map[string]interface{}
  6769. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6772. }
  6773. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6774. fmt.Println(respJSON3263)
  6775. result, _ := json.Marshal(respJSON3263)
  6776. fmt.Println(result)
  6777. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6778. utils.ErrorLog("解析失败:%v", err)
  6779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6780. }
  6781. var ids []string
  6782. for _, item := range result3263.Output {
  6783. ids = append(ids, item.SolidifyID)
  6784. }
  6785. var empty models.JSResultEmpty
  6786. data2 := make(map[string]interface{})
  6787. data2["org_name"] = miConfig.OrgName
  6788. data2["doctor"] = curRoles.UserName
  6789. data2["doctor_name"] = curRoles.UserName
  6790. data2["fixmedins_code"] = miConfig.Code
  6791. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6792. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6793. data2["secret_key"] = miConfig.SecretKey
  6794. data2["url"] = miConfig.Url
  6795. data2["ak"] = miConfig.AccessKey
  6796. data2["cainfo"] = miConfig.Cainfo
  6797. data2["setl_mon"] = setl_mon
  6798. data2["stmt_loc"] = "2"
  6799. data2["upld_btch"] = upld_btch
  6800. data2["solidify_id"] = ids
  6801. client2 := &http.Client{}
  6802. bytesData2, _ := json.Marshal(data2)
  6803. var req *http.Request
  6804. if miConfig.MdtrtareaAdmvs == "320921" {
  6805. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6806. } else {
  6807. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6808. }
  6809. resp2, _ := client2.Do(req)
  6810. defer resp.Body.Close()
  6811. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6812. if ioErr2 != nil {
  6813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6815. }
  6816. var respJSON map[string]interface{}
  6817. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6820. }
  6821. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6822. fmt.Println(respJSON)
  6823. result2, _ := json.Marshal(respJSON)
  6824. fmt.Println(result2)
  6825. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6826. utils.ErrorLog("解析失败:%v", err)
  6827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6828. }
  6829. if empty.Infcode != "0" {
  6830. c.ServeSuccessJSON(map[string]interface{}{
  6831. "failed_code": -10,
  6832. "msg": empty.ErrMsg,
  6833. })
  6834. return
  6835. } else {
  6836. c.ServeSuccessJSON(map[string]interface{}{
  6837. "msg": "",
  6838. })
  6839. return
  6840. }
  6841. }
  6842. func (c *HisApiController) Get3265() {
  6843. admin_user_id, _ := c.GetInt64("admin_user_id")
  6844. startTime := c.GetString("start_time")
  6845. //endTime, _ := c.GetString("end_time")
  6846. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6847. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6848. times := strings.Split(startTime, "-")
  6849. setl_mon := times[0] + times[1]
  6850. var upld_btch string
  6851. upld_btch = "0"
  6852. //var empty models.JSResultEmpty
  6853. var result3265 models.JSResult3264
  6854. var result3263 models.JSResult3263
  6855. data2 := make(map[string]interface{})
  6856. data2["org_name"] = miConfig.OrgName
  6857. data2["doctor"] = curRoles.UserName
  6858. data2["doctor_name"] = curRoles.UserName
  6859. data2["fixmedins_code"] = miConfig.Code
  6860. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6861. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6862. data2["secret_key"] = miConfig.SecretKey
  6863. data2["url"] = miConfig.Url
  6864. data2["ak"] = miConfig.AccessKey
  6865. data2["cainfo"] = miConfig.Cainfo
  6866. data2["setl_mon"] = setl_mon
  6867. data2["stmt_loc"] = "2"
  6868. data2["upld_btch"] = upld_btch
  6869. client2 := &http.Client{}
  6870. bytesData2, _ := json.Marshal(data2)
  6871. var req3263 *http.Request
  6872. if miConfig.MdtrtareaAdmvs == "320921" {
  6873. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6874. } else {
  6875. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6876. }
  6877. resp2, _ := client2.Do(req3263)
  6878. defer resp2.Body.Close()
  6879. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6880. if ioErr2 != nil {
  6881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6883. }
  6884. var respJSON3263 map[string]interface{}
  6885. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6888. }
  6889. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6890. fmt.Println(respJSON3263)
  6891. result2, _ := json.Marshal(respJSON3263)
  6892. fmt.Println(result2)
  6893. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6894. utils.ErrorLog("解析失败:%v", err)
  6895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6896. }
  6897. var ids []string
  6898. for _, item := range result3263.Output {
  6899. ids = append(ids, item.SolidifyID)
  6900. }
  6901. data := make(map[string]interface{})
  6902. data["org_name"] = miConfig.OrgName
  6903. data["doctor"] = curRoles.UserName
  6904. data["doctor_name"] = curRoles.UserName
  6905. data["fixmedins_code"] = miConfig.Code
  6906. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6907. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6908. data["secret_key"] = miConfig.SecretKey
  6909. data["url"] = miConfig.Url
  6910. data["ak"] = miConfig.AccessKey
  6911. data["cainfo"] = miConfig.Cainfo
  6912. data["setl_mon"] = setl_mon
  6913. data["solidify_id"] = ids
  6914. month := time.Unix(1557042972, 0).Format("1")
  6915. year := time.Now().Format("2006")
  6916. month = time.Now().Format("01")
  6917. day := time.Now().Format("02")
  6918. hour := time.Now().Format("15")
  6919. min := time.Now().Format("04")
  6920. sec := time.Now().Format("05")
  6921. fix_fill_date := year + month + day + hour + min + sec
  6922. data["fix_fill_dept"] = miConfig.OrgName
  6923. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6924. data["fix_fill_psn"] = curRoles.UserName
  6925. data["fix_fill_date"] = fix_fill_date
  6926. data["stmt_loc"] = "2"
  6927. data["upld_btch"] = upld_btch
  6928. client := &http.Client{}
  6929. bytesData, _ := json.Marshal(data)
  6930. var req *http.Request
  6931. if miConfig.MdtrtareaAdmvs == "320921" {
  6932. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6933. } else {
  6934. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6935. }
  6936. resp, _ := client.Do(req)
  6937. defer resp.Body.Close()
  6938. body, ioErr := ioutil.ReadAll(resp.Body)
  6939. if ioErr != nil {
  6940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6942. }
  6943. var respJSON map[string]interface{}
  6944. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6947. }
  6948. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6949. fmt.Println(respJSON)
  6950. result, _ := json.Marshal(respJSON)
  6951. fmt.Println(result)
  6952. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6953. utils.ErrorLog("解析失败:%v", err)
  6954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6955. }
  6956. if result3265.Infcode != "0" {
  6957. c.ServeSuccessJSON(map[string]interface{}{
  6958. "failed_code": -10,
  6959. "msg": result3265.ErrMsg,
  6960. })
  6961. return
  6962. } else {
  6963. c.ServeSuccessJSON(map[string]interface{}{
  6964. "info": result3265.Output,
  6965. })
  6966. return
  6967. }
  6968. }
  6969. func (c *HisApiController) Get3266() {
  6970. admin_user_id, _ := c.GetInt64("admin_user_id")
  6971. startTime := c.GetString("start_time")
  6972. //endTime, _ := c.GetString("end_time")
  6973. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6974. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6975. times := strings.Split(startTime, "-")
  6976. stmt_mon := times[0] + times[1]
  6977. var upld_btch string
  6978. //var empty models.JSResultEmpty
  6979. var result3265 models.JSResult3264
  6980. data := make(map[string]interface{})
  6981. data["org_name"] = miConfig.OrgName
  6982. data["doctor"] = curRoles.UserName
  6983. data["doctor_name"] = curRoles.UserName
  6984. data["fixmedins_code"] = miConfig.Code
  6985. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6986. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6987. data["secret_key"] = miConfig.SecretKey
  6988. data["url"] = miConfig.Url
  6989. data["ak"] = miConfig.AccessKey
  6990. data["cainfo"] = miConfig.Cainfo
  6991. data["setl_mon"] = stmt_mon
  6992. month := time.Unix(1557042972, 0).Format("1")
  6993. year := time.Now().Format("2006")
  6994. month = time.Now().Format("01")
  6995. day := time.Now().Format("02")
  6996. hour := time.Now().Format("15")
  6997. min := time.Now().Format("04")
  6998. sec := time.Now().Format("05")
  6999. fix_fill_date := year + month + day + hour + min + sec
  7000. data["fix_fill_dept"] = miConfig.OrgName
  7001. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7002. data["fix_fill_psn"] = curRoles.UserName
  7003. data["fix_fill_date"] = fix_fill_date
  7004. data["stmt_loc"] = "2"
  7005. upld_btch = "0"
  7006. data["upld_btch"] = upld_btch
  7007. client := &http.Client{}
  7008. bytesData, _ := json.Marshal(data)
  7009. var req *http.Request
  7010. if miConfig.MdtrtareaAdmvs == "320921" {
  7011. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7012. } else {
  7013. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7014. }
  7015. resp, _ := client.Do(req)
  7016. defer resp.Body.Close()
  7017. body, ioErr := ioutil.ReadAll(resp.Body)
  7018. if ioErr != nil {
  7019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7021. }
  7022. var respJSON map[string]interface{}
  7023. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7026. }
  7027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7028. fmt.Println(respJSON)
  7029. result, _ := json.Marshal(respJSON)
  7030. fmt.Println(result)
  7031. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7032. utils.ErrorLog("解析失败:%v", err)
  7033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7034. }
  7035. if result3265.Infcode != "0" {
  7036. c.ServeSuccessJSON(map[string]interface{}{
  7037. "failed_code": -10,
  7038. "msg": result3265.ErrMsg,
  7039. })
  7040. return
  7041. } else {
  7042. c.ServeSuccessJSON(map[string]interface{}{
  7043. "info": result3265.Output,
  7044. })
  7045. return
  7046. }
  7047. }
  7048. func (c *HisApiController) Get3267() {
  7049. admin_user_id, _ := c.GetInt64("admin_user_id")
  7050. startTime := c.GetString("start_time")
  7051. //endTime, _ := c.GetString("end_time")
  7052. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7053. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7054. times := strings.Split(startTime, "-")
  7055. setl_mon := times[0] + times[1]
  7056. var upld_btch string
  7057. //var empty models.JSResultEmpty
  7058. var result3265 models.JSResult3264
  7059. upld_btch = "0"
  7060. data := make(map[string]interface{})
  7061. data["org_name"] = miConfig.OrgName
  7062. data["doctor"] = curRoles.UserName
  7063. data["doctor_name"] = curRoles.UserName
  7064. data["fixmedins_code"] = miConfig.Code
  7065. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7066. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7067. data["secret_key"] = miConfig.SecretKey
  7068. data["url"] = miConfig.Url
  7069. data["ak"] = miConfig.AccessKey
  7070. data["cainfo"] = miConfig.Cainfo
  7071. data["setl_mon"] = setl_mon
  7072. data["stmt_loc"] = "2"
  7073. data["upld_btch"] = upld_btch
  7074. client := &http.Client{}
  7075. bytesData, _ := json.Marshal(data)
  7076. var req *http.Request
  7077. if miConfig.MdtrtareaAdmvs == "320921" {
  7078. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7079. } else {
  7080. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7081. }
  7082. resp, _ := client.Do(req)
  7083. defer resp.Body.Close()
  7084. body, ioErr := ioutil.ReadAll(resp.Body)
  7085. if ioErr != nil {
  7086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7088. }
  7089. var respJSON map[string]interface{}
  7090. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7093. }
  7094. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7095. fmt.Println(respJSON)
  7096. result, _ := json.Marshal(respJSON)
  7097. fmt.Println(result)
  7098. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7099. utils.ErrorLog("解析失败:%v", err)
  7100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7101. }
  7102. if result3265.Infcode != "0" {
  7103. c.ServeSuccessJSON(map[string]interface{}{
  7104. "failed_code": -10,
  7105. "msg": result3265.ErrMsg,
  7106. })
  7107. return
  7108. } else {
  7109. c.ServeSuccessJSON(map[string]interface{}{
  7110. "info": result3265.Output.Data,
  7111. })
  7112. return
  7113. }
  7114. }
  7115. func (c *HisApiController) Get3268() {
  7116. admin_user_id, _ := c.GetInt64("admin_user_id")
  7117. startTime := c.GetString("start_time")
  7118. endTime := c.GetString("end_time")
  7119. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7120. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7121. times := strings.Split(startTime, "-")
  7122. setl_mon := times[0] + times[1]
  7123. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7124. var twos []models.FixMonRecDetailFileInTwo
  7125. var funs []models.FundDetail
  7126. for _, item := range datas {
  7127. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7128. funs = append(funs, fun...)
  7129. }
  7130. var funInfos []models.Fund
  7131. //for _, item := range funs {
  7132. // var rf []models.FundInfo
  7133. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7134. // for _, subitem := range rf {
  7135. // var fund models.Fund
  7136. // fund.FundCode = subitem.FundPayType
  7137. // fund.FundName = subitem.FundPayTypeName
  7138. // fund.FundAmt = subitem.FundPayAmt
  7139. // fund.FundKey = item.FundKey
  7140. // fund.InsuAdmdvs = "555555"
  7141. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7142. // funInfos = append(funInfos, fund)
  7143. // }
  7144. //}
  7145. for _, team := range datas {
  7146. var two models.FixMonRecDetailFileInTwo
  7147. two.SetlDate = time.Now().Format("2006-01-02")
  7148. two.MedType = team.MedType
  7149. two.Insutype = team.Insutype
  7150. two.PsnType = team.PsnType
  7151. two.MedType = team.MedType
  7152. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7153. two.InsuAdmdvs = team.InsuAdmdvs
  7154. two.PsnTime = team.PsnTime
  7155. two.PsnCnt = team.PsnCnt
  7156. two.FundKey = team.FundKey
  7157. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7158. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7159. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7160. two.MedfeeSumAmt = ms
  7161. two.InscpAmt = ia
  7162. two.FundPaySumAmt = fps
  7163. twos = append(twos, two)
  7164. }
  7165. var upld_btch string
  7166. upld_btch = "0"
  7167. var empty models.JSResultEmpty
  7168. data := make(map[string]interface{})
  7169. data["org_name"] = miConfig.OrgName
  7170. data["doctor"] = curRoles.UserName
  7171. data["doctor_name"] = curRoles.UserName
  7172. data["fixmedins_code"] = miConfig.Code
  7173. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7174. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7175. data["secret_key"] = miConfig.SecretKey
  7176. data["url"] = miConfig.Url
  7177. data["ak"] = miConfig.AccessKey
  7178. data["cainfo"] = miConfig.Cainfo
  7179. data["datas"] = twos
  7180. data["fund"] = funInfos
  7181. data["setl_mon"] = setl_mon
  7182. month := time.Unix(1557042972, 0).Format("1")
  7183. year := time.Now().Format("2006")
  7184. month = time.Now().Format("01")
  7185. day := time.Now().Format("02")
  7186. hour := time.Now().Format("15")
  7187. min := time.Now().Format("04")
  7188. sec := time.Now().Format("05")
  7189. fix_fill_date := year + month + day + hour + min + sec
  7190. data["fix_fill_dept"] = miConfig.OrgName
  7191. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7192. data["fix_fill_psn"] = curRoles.UserName
  7193. data["fix_fill_date"] = fix_fill_date
  7194. data["stmt_loc"] = "2"
  7195. data["upld_btch"] = upld_btch
  7196. client := &http.Client{}
  7197. bytesData, _ := json.Marshal(data)
  7198. var req *http.Request
  7199. if miConfig.MdtrtareaAdmvs == "320921" {
  7200. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7201. } else {
  7202. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7203. }
  7204. resp, _ := client.Do(req)
  7205. defer resp.Body.Close()
  7206. body, ioErr := ioutil.ReadAll(resp.Body)
  7207. if ioErr != nil {
  7208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7210. }
  7211. var respJSON map[string]interface{}
  7212. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7215. }
  7216. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7217. fmt.Println(respJSON)
  7218. result, _ := json.Marshal(respJSON)
  7219. fmt.Println(result)
  7220. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7221. utils.ErrorLog("解析失败:%v", err)
  7222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7223. }
  7224. if empty.Infcode != "0" {
  7225. c.ServeSuccessJSON(map[string]interface{}{
  7226. "failed_code": -10,
  7227. "msg": empty.ErrMsg,
  7228. })
  7229. return
  7230. } else {
  7231. c.ServeSuccessJSON(map[string]interface{}{
  7232. "msg": "上传成功",
  7233. })
  7234. return
  7235. }
  7236. }
  7237. func (c *HisApiController) Get3269() {
  7238. admin_user_id, _ := c.GetInt64("admin_user_id")
  7239. startTime := c.GetString("start_time")
  7240. //endTime, _ := c.GetString("end_time")
  7241. times := strings.Split(startTime, "-")
  7242. setl_mon := times[0] + times[1]
  7243. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7244. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7245. var result3263 models.JSResult3263
  7246. data := make(map[string]interface{})
  7247. data["org_name"] = miConfig.OrgName
  7248. data["doctor"] = curRoles.UserName
  7249. data["doctor_name"] = curRoles.UserName
  7250. data["fixmedins_code"] = miConfig.Code
  7251. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7252. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7253. data["secret_key"] = miConfig.SecretKey
  7254. data["url"] = miConfig.Url
  7255. data["ak"] = miConfig.AccessKey
  7256. data["cainfo"] = miConfig.Cainfo
  7257. data["setl_mon"] = setl_mon
  7258. data["stmt_loc"] = "2"
  7259. client := &http.Client{}
  7260. bytesData, _ := json.Marshal(data)
  7261. var req *http.Request
  7262. if miConfig.MdtrtareaAdmvs == "320921" {
  7263. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7264. } else {
  7265. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7266. }
  7267. resp, _ := client.Do(req)
  7268. defer resp.Body.Close()
  7269. body, ioErr := ioutil.ReadAll(resp.Body)
  7270. if ioErr != nil {
  7271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7273. }
  7274. var respJSON map[string]interface{}
  7275. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7278. }
  7279. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7280. fmt.Println(respJSON)
  7281. result, _ := json.Marshal(respJSON)
  7282. fmt.Println(result)
  7283. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7284. utils.ErrorLog("解析失败:%v", err)
  7285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7286. }
  7287. if result3263.Infcode != "0" {
  7288. c.ServeSuccessJSON(map[string]interface{}{
  7289. "failed_code": -10,
  7290. "msg": result3263.ErrMsg,
  7291. })
  7292. return
  7293. } else {
  7294. c.ServeSuccessJSON(map[string]interface{}{
  7295. "msg": "上传成功",
  7296. })
  7297. return
  7298. }
  7299. }
  7300. func (c *HisApiController) Get3270() {
  7301. admin_user_id, _ := c.GetInt64("admin_user_id")
  7302. startTime := c.GetString("start_time")
  7303. //endTime, _ := c.GetString("end_time")
  7304. times := strings.Split(startTime, "-")
  7305. setl_mon := times[0] + times[1]
  7306. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7307. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7308. var result3263 models.JSResult3263
  7309. data2 := make(map[string]interface{})
  7310. data2["org_name"] = miConfig.OrgName
  7311. data2["doctor"] = curRoles.UserName
  7312. data2["doctor_name"] = curRoles.UserName
  7313. data2["fixmedins_code"] = miConfig.Code
  7314. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7315. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7316. data2["secret_key"] = miConfig.SecretKey
  7317. data2["url"] = miConfig.Url
  7318. data2["ak"] = miConfig.AccessKey
  7319. data2["cainfo"] = miConfig.Cainfo
  7320. data2["setl_mon"] = setl_mon
  7321. data2["stmt_loc"] = "2"
  7322. client2 := &http.Client{}
  7323. bytesData2, _ := json.Marshal(data2)
  7324. var req3263 *http.Request
  7325. if miConfig.MdtrtareaAdmvs == "320921" {
  7326. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7327. } else {
  7328. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7329. }
  7330. resp2, _ := client2.Do(req3263)
  7331. defer resp2.Body.Close()
  7332. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7333. if ioErr2 != nil {
  7334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7336. }
  7337. var respJSON3263 map[string]interface{}
  7338. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7341. }
  7342. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7343. fmt.Println(respJSON3263)
  7344. result2, _ := json.Marshal(respJSON3263)
  7345. fmt.Println(result2)
  7346. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7347. utils.ErrorLog("解析失败:%v", err)
  7348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. }
  7350. var ids []string
  7351. for _, item := range result3263.Output {
  7352. ids = append(ids, item.SolidifyID)
  7353. }
  7354. var result3264 models.JSResult3264
  7355. data := make(map[string]interface{})
  7356. data["org_name"] = miConfig.OrgName
  7357. data["doctor"] = curRoles.UserName
  7358. data["doctor_name"] = curRoles.UserName
  7359. data["fixmedins_code"] = miConfig.Code
  7360. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7361. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7362. data["secret_key"] = miConfig.SecretKey
  7363. data["url"] = miConfig.Url
  7364. data["ak"] = miConfig.AccessKey
  7365. data["cainfo"] = miConfig.Cainfo
  7366. data["setl_mon"] = setl_mon
  7367. data["stmt_loc"] = "2"
  7368. data["solidify_id"] = ids
  7369. client := &http.Client{}
  7370. bytesData, _ := json.Marshal(data)
  7371. var req *http.Request
  7372. if miConfig.MdtrtareaAdmvs == "320921" {
  7373. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7374. } else {
  7375. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7376. }
  7377. resp, _ := client.Do(req)
  7378. defer resp.Body.Close()
  7379. body, ioErr := ioutil.ReadAll(resp.Body)
  7380. if ioErr != nil {
  7381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7383. }
  7384. var respJSON map[string]interface{}
  7385. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7388. }
  7389. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7390. fmt.Println(respJSON)
  7391. result, _ := json.Marshal(respJSON)
  7392. fmt.Println(result)
  7393. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7394. utils.ErrorLog("解析失败:%v", err)
  7395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7396. }
  7397. if result3264.Infcode != "0" {
  7398. c.ServeSuccessJSON(map[string]interface{}{
  7399. "failed_code": -10,
  7400. "msg": result3264.ErrMsg,
  7401. })
  7402. return
  7403. } else {
  7404. c.ServeSuccessJSON(map[string]interface{}{
  7405. "info": result3264.Output,
  7406. })
  7407. return
  7408. }
  7409. }
  7410. func (c *HisApiController) Get3271() {
  7411. admin_user_id, _ := c.GetInt64("admin_user_id")
  7412. startTime := c.GetString("start_time")
  7413. //endTime, _ := c.GetString("end_time")
  7414. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7415. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7416. times := strings.Split(startTime, "-")
  7417. setl_mon := times[0] + times[1]
  7418. //var empty models.JSResultEmpty
  7419. var result3265 models.JSResult3264
  7420. var result3263 models.JSResult3263
  7421. data2 := make(map[string]interface{})
  7422. data2["org_name"] = miConfig.OrgName
  7423. data2["doctor"] = curRoles.UserName
  7424. data2["doctor_name"] = curRoles.UserName
  7425. data2["fixmedins_code"] = miConfig.Code
  7426. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7427. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7428. data2["secret_key"] = miConfig.SecretKey
  7429. data2["url"] = miConfig.Url
  7430. data2["ak"] = miConfig.AccessKey
  7431. data2["cainfo"] = miConfig.Cainfo
  7432. data2["setl_mon"] = setl_mon
  7433. data2["stmt_loc"] = "2"
  7434. client2 := &http.Client{}
  7435. bytesData2, _ := json.Marshal(data2)
  7436. var req3263 *http.Request
  7437. if miConfig.MdtrtareaAdmvs == "320921" {
  7438. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7439. } else {
  7440. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7441. }
  7442. resp2, _ := client2.Do(req3263)
  7443. defer resp2.Body.Close()
  7444. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7445. if ioErr2 != nil {
  7446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7448. }
  7449. var respJSON3263 map[string]interface{}
  7450. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7453. }
  7454. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7455. fmt.Println(respJSON3263)
  7456. result2, _ := json.Marshal(respJSON3263)
  7457. fmt.Println(result2)
  7458. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7459. utils.ErrorLog("解析失败:%v", err)
  7460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7461. }
  7462. var ids []string
  7463. for _, item := range result3263.Output {
  7464. ids = append(ids, item.SolidifyID)
  7465. }
  7466. data := make(map[string]interface{})
  7467. data["org_name"] = miConfig.OrgName
  7468. data["doctor"] = curRoles.UserName
  7469. data["doctor_name"] = curRoles.UserName
  7470. data["fixmedins_code"] = miConfig.Code
  7471. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7472. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7473. data["secret_key"] = miConfig.SecretKey
  7474. data["url"] = miConfig.Url
  7475. data["ak"] = miConfig.AccessKey
  7476. data["cainfo"] = miConfig.Cainfo
  7477. data["setl_mon"] = setl_mon
  7478. data["solidify_id"] = ids
  7479. month := time.Unix(1557042972, 0).Format("1")
  7480. year := time.Now().Format("2006")
  7481. month = time.Now().Format("01")
  7482. day := time.Now().Format("02")
  7483. hour := time.Now().Format("15")
  7484. min := time.Now().Format("04")
  7485. sec := time.Now().Format("05")
  7486. fix_fill_date := year + month + day + hour + min + sec
  7487. data["fix_fill_dept"] = miConfig.OrgName
  7488. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7489. data["fix_fill_psn"] = curRoles.UserName
  7490. data["fix_fill_date"] = fix_fill_date
  7491. data["stmt_loc"] = "2"
  7492. client := &http.Client{}
  7493. bytesData, _ := json.Marshal(data)
  7494. var req *http.Request
  7495. if miConfig.MdtrtareaAdmvs == "320921" {
  7496. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7497. } else {
  7498. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7499. }
  7500. resp, _ := client.Do(req)
  7501. defer resp.Body.Close()
  7502. body, ioErr := ioutil.ReadAll(resp.Body)
  7503. if ioErr != nil {
  7504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7506. }
  7507. var respJSON map[string]interface{}
  7508. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7511. }
  7512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7513. fmt.Println(respJSON)
  7514. result, _ := json.Marshal(respJSON)
  7515. fmt.Println(result)
  7516. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7517. utils.ErrorLog("解析失败:%v", err)
  7518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7519. }
  7520. if result3265.Infcode != "0" {
  7521. c.ServeSuccessJSON(map[string]interface{}{
  7522. "failed_code": -10,
  7523. "msg": result3265.ErrMsg,
  7524. })
  7525. return
  7526. } else {
  7527. c.ServeSuccessJSON(map[string]interface{}{
  7528. "info": result3265.Output.Data,
  7529. })
  7530. return
  7531. }
  7532. }
  7533. func (c *HisApiController) Get3272() {
  7534. admin_user_id, _ := c.GetInt64("admin_user_id")
  7535. startTime := c.GetString("start_time")
  7536. //endTime, _ := c.GetString("end_time")
  7537. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7538. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7539. times := strings.Split(startTime, "-")
  7540. setl_mon := times[0] + times[1]
  7541. var upld_btch string
  7542. //var empty models.JSResultEmpty
  7543. var result3265 models.JSResult3264
  7544. data := make(map[string]interface{})
  7545. data["org_name"] = miConfig.OrgName
  7546. data["doctor"] = curRoles.UserName
  7547. data["doctor_name"] = curRoles.UserName
  7548. data["fixmedins_code"] = miConfig.Code
  7549. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7550. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7551. data["secret_key"] = miConfig.SecretKey
  7552. data["url"] = miConfig.Url
  7553. data["ak"] = miConfig.AccessKey
  7554. data["cainfo"] = miConfig.Cainfo
  7555. data["setl_mon"] = setl_mon
  7556. month := time.Unix(1557042972, 0).Format("1")
  7557. year := time.Now().Format("2006")
  7558. month = time.Now().Format("01")
  7559. day := time.Now().Format("02")
  7560. hour := time.Now().Format("15")
  7561. min := time.Now().Format("04")
  7562. sec := time.Now().Format("05")
  7563. fix_fill_date := year + month + day + hour + min + sec
  7564. data["fix_fill_dept"] = miConfig.OrgName
  7565. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7566. data["fix_fill_psn"] = curRoles.UserName
  7567. data["fix_fill_date"] = fix_fill_date
  7568. data["stmt_loc"] = "2"
  7569. data["upld_btch"] = upld_btch
  7570. client := &http.Client{}
  7571. bytesData, _ := json.Marshal(data)
  7572. var req *http.Request
  7573. if miConfig.MdtrtareaAdmvs == "320921" {
  7574. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7575. } else {
  7576. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7577. }
  7578. resp, _ := client.Do(req)
  7579. defer resp.Body.Close()
  7580. body, ioErr := ioutil.ReadAll(resp.Body)
  7581. if ioErr != nil {
  7582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7584. }
  7585. var respJSON map[string]interface{}
  7586. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7589. }
  7590. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7591. fmt.Println(respJSON)
  7592. result, _ := json.Marshal(respJSON)
  7593. fmt.Println(result)
  7594. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7595. utils.ErrorLog("解析失败:%v", err)
  7596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7597. }
  7598. if result3265.Infcode != "0" {
  7599. c.ServeSuccessJSON(map[string]interface{}{
  7600. "failed_code": -10,
  7601. "msg": result3265.ErrMsg,
  7602. })
  7603. return
  7604. } else {
  7605. c.ServeSuccessJSON(map[string]interface{}{
  7606. "info": result3265.Output,
  7607. })
  7608. return
  7609. }
  7610. }
  7611. func (c *HisApiController) Get3273() {
  7612. admin_user_id, _ := c.GetInt64("admin_user_id")
  7613. startTime := c.GetString("start_time")
  7614. //endTime, _ := c.GetString("end_time")
  7615. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7616. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7617. times := strings.Split(startTime, "-")
  7618. setl_mon := times[0] + times[1]
  7619. var result3265 models.JSResult3264
  7620. data := make(map[string]interface{})
  7621. data["org_name"] = miConfig.OrgName
  7622. data["doctor"] = curRoles.UserName
  7623. data["doctor_name"] = curRoles.UserName
  7624. data["fixmedins_code"] = miConfig.Code
  7625. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7626. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7627. data["secret_key"] = miConfig.SecretKey
  7628. data["url"] = miConfig.Url
  7629. data["ak"] = miConfig.AccessKey
  7630. data["cainfo"] = miConfig.Cainfo
  7631. data["setl_mon"] = setl_mon
  7632. data["stmt_loc"] = "2"
  7633. client := &http.Client{}
  7634. bytesData, _ := json.Marshal(data)
  7635. var req *http.Request
  7636. if miConfig.MdtrtareaAdmvs == "320921" {
  7637. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7638. } else {
  7639. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7640. }
  7641. resp, _ := client.Do(req)
  7642. defer resp.Body.Close()
  7643. body, ioErr := ioutil.ReadAll(resp.Body)
  7644. if ioErr != nil {
  7645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7647. }
  7648. var respJSON map[string]interface{}
  7649. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7652. }
  7653. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7654. fmt.Println(respJSON)
  7655. result, _ := json.Marshal(respJSON)
  7656. fmt.Println(result)
  7657. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7658. utils.ErrorLog("解析失败:%v", err)
  7659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7660. }
  7661. if result3265.Infcode != "0" {
  7662. c.ServeSuccessJSON(map[string]interface{}{
  7663. "failed_code": -10,
  7664. "msg": result3265.ErrMsg,
  7665. })
  7666. return
  7667. } else {
  7668. c.ServeSuccessJSON(map[string]interface{}{
  7669. "info": result3265.Output.Data,
  7670. })
  7671. return
  7672. }
  7673. }
  7674. func (c *HisApiController) Get3274() {
  7675. //if miConfig.MdtrtareaAdmvs == "320921" {
  7676. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7677. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7678. // "&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
  7679. //
  7680. //} else {
  7681. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7682. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7683. // "&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
  7684. //
  7685. //}
  7686. }
  7687. func (c *HisApiController) Get3275() {
  7688. //if miConfig.MdtrtareaAdmvs == "320921" {
  7689. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7690. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7691. // "&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
  7692. //
  7693. //} else {
  7694. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7695. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7696. // "&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
  7697. //
  7698. //}
  7699. }
  7700. func (c *HisApiController) Get3276() {
  7701. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7702. //month := c.GetString("month")
  7703. //
  7704. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7705. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7706. //var api string
  7707. //var res Result5301
  7708. //
  7709. //if miConfig.MdtrtareaAdmvs == "320921" {
  7710. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7711. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7712. //} else {
  7713. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7714. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7715. //}
  7716. //
  7717. //resp, requestErr := http.Get(api)
  7718. //if requestErr != nil {
  7719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7720. // return
  7721. //}
  7722. //
  7723. //body, ioErr := ioutil.ReadAll(resp.Body)
  7724. //if ioErr != nil {
  7725. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7727. // return
  7728. //}
  7729. //var respJSON map[string]interface{}
  7730. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7731. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7732. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7733. // return
  7734. //}
  7735. //
  7736. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7737. //result, _ := json.Marshal(respJSON)
  7738. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7739. // utils.ErrorLog("解析失败:%v", err)
  7740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7741. // return
  7742. //}
  7743. }
  7744. func (c *HisApiController) Get3277() {
  7745. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7746. //month := c.GetString("month")
  7747. //
  7748. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7749. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7750. //var api string
  7751. //var res Result5301
  7752. //
  7753. //if miConfig.MdtrtareaAdmvs == "320921" {
  7754. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7755. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7756. //} else {
  7757. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7758. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7759. //}
  7760. //
  7761. //resp, requestErr := http.Get(api)
  7762. //if requestErr != nil {
  7763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7764. // return
  7765. //}
  7766. //
  7767. //body, ioErr := ioutil.ReadAll(resp.Body)
  7768. //if ioErr != nil {
  7769. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7771. // return
  7772. //}
  7773. //var respJSON map[string]interface{}
  7774. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7775. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7777. // return
  7778. //}
  7779. //
  7780. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7781. //result, _ := json.Marshal(respJSON)
  7782. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7783. // utils.ErrorLog("解析失败:%v", err)
  7784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. // return
  7786. //}
  7787. }
  7788. func (c *HisApiController) GetCFYLJG001() {
  7789. admin_user_id, _ := c.GetInt64("admin_user_id")
  7790. patient_id, _ := c.GetInt64("patient_id")
  7791. his_patient_id, _ := c.GetInt64("his_patient_id")
  7792. record_time := c.GetString("record_time")
  7793. admin_user_id = 3626
  7794. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7795. psn, _ := service.GetPsnByPatientId(patient_id)
  7796. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7797. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7798. var cFYLJG001 models.CFYLJG001
  7799. timeLayout := "2006-01-02"
  7800. loc, _ := time.LoadLocation("Local")
  7801. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7802. if err != nil {
  7803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7804. return
  7805. }
  7806. recordDateTime := theTime.Unix()
  7807. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7808. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7809. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7810. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7811. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7812. for _, item := range prescriptions {
  7813. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7814. if his.IdCardType == 1 {
  7815. bas := strings.Split(psn.CardInfo, "|")
  7816. basNumber := bas[1]
  7817. fmt.Println(basNumber)
  7818. card_sn := bas[3]
  7819. card_no := bas[2]
  7820. cFYLJG001.MdtrtCertType = "03"
  7821. cFYLJG001.CardSn = card_sn
  7822. cFYLJG001.MdtrtCertNo = card_no
  7823. cFYLJG001.EcToken = ""
  7824. cFYLJG001.AuthNo = ""
  7825. } else if his.IdCardType == 2 {
  7826. cFYLJG001.MdtrtCertType = "02"
  7827. cFYLJG001.CardSn = ""
  7828. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7829. cFYLJG001.EcToken = ""
  7830. cFYLJG001.AuthNo = ""
  7831. } else if his.IdCardType == 4 {
  7832. cFYLJG001.MdtrtCertType = "01"
  7833. cFYLJG001.CardSn = ""
  7834. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7835. cFYLJG001.EcToken = psn.VerifyNumber
  7836. cFYLJG001.AuthNo = ""
  7837. }
  7838. cFYLJG001.BizTypeCode = "01"
  7839. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7840. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7841. cFYLJG001.RxTypeCode = "1"
  7842. tempTime := time.Unix(item.PreTime, 0)
  7843. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7844. cFYLJG001.PrscTime = timeFormatOne
  7845. var count float64
  7846. if item.Type == 1 {
  7847. for _, sumItem := range item.HisDoctorAdviceInfo {
  7848. count = count + sumItem.PrescribingNumber
  7849. }
  7850. }
  7851. cFYLJG001.RxDrugCnt = count
  7852. cFYLJG001.ValiDays = "5"
  7853. ts := time.Unix(item.PreTime, 0)
  7854. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7855. tempTime3 := time.Unix(record_time2, 0)
  7856. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7857. cFYLJG001.ValiEndTime = timeFormat3
  7858. cFYLJG001.RxCotnFlag = "0"
  7859. for _, subItem := range item.HisDoctorAdviceInfo {
  7860. var drug models.RxDrug
  7861. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7862. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7863. drug.RxItemTypeCode = "11"
  7864. drug.DrugDosform = "乳膏剂" //TODO
  7865. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7866. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7867. }
  7868. drug.MedcWayDscr = subItem.DeliveryWay
  7869. tempTime2 := time.Unix(subItem.StartTime, 0)
  7870. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7871. drug.MedcBegntime = timeFormatTwo
  7872. if subItem.Day > 0 {
  7873. ts := time.Unix(subItem.StartTime, 0)
  7874. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7875. tempTime4 := time.Unix(record_time, 0)
  7876. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7877. drug.MedcEndtime = timeFormat5
  7878. } else {
  7879. tempTime2 := time.Unix(subItem.StartTime, 0)
  7880. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7881. drug.MedcEndtime = timeFormatTwo
  7882. }
  7883. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7884. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7885. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7886. drug.DrugCnt = subItem.PrescribingNumber
  7887. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7888. drug.DrugGenname = subItem.AdviceName
  7889. drug.MedcWayCodg = subItem.DeliveryWay
  7890. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7891. drug.SinDoscnt = subItem.SingleDose
  7892. drug.SinDosunt = subItem.SingleDoseUnit
  7893. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7894. drug.UsedFrquName = subItem.ExecutionFrequency
  7895. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7896. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7897. drug.HospApprFlag = "1"
  7898. cFYLJG001.List = append(cFYLJG001.List, drug)
  7899. }
  7900. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7901. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7902. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7903. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7904. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7905. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7906. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7907. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7908. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7909. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7910. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7911. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7912. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7913. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7914. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7915. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7916. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7917. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7918. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7919. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7920. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7921. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7922. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7923. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7924. tempTime2 := time.Now().Unix()
  7925. tempTime6 := time.Unix(tempTime2, 0)
  7926. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7927. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7928. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7929. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7930. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7931. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7932. //memo := make(map[string]interface{})
  7933. //inputData := make(map[string]interface{}, 0)
  7934. //type MyData struct {
  7935. // Insutype string `json:"insutype"`
  7936. //}
  7937. //
  7938. // data := MyData{
  7939. // Insutype: his.Insutype,
  7940. //}
  7941. //
  7942. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7943. var config []*models.HisXtDiagnoseConfig
  7944. for _, item := range diagnosis_ids {
  7945. id, _ := strconv.ParseInt(item, 10, 64)
  7946. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7947. config = append(config, &diagnosisConfig)
  7948. }
  7949. for index, subitem := range config {
  7950. if index == 0 {
  7951. var dia models.DiseInfo
  7952. dia.DiagType = "1"
  7953. dia.MaindiagFlag = "1"
  7954. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7955. dia.DiagCode = subitem.CountryCode
  7956. dia.DiagName = subitem.ClassName
  7957. dia.DiagDept = "肾内科"
  7958. dia.DiagDrNo = doctor.DoctorNumber
  7959. dia.DiagDrName = doctor.UserName
  7960. tempTime3 := time.Unix(item.PreTime, 0)
  7961. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7962. dia.DiagTime = timeFormatTwo
  7963. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7964. } else {
  7965. var dia models.DiseInfo
  7966. dia.DiagType = "1"
  7967. dia.MaindiagFlag = "0"
  7968. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7969. dia.DiagCode = subitem.CountryCode
  7970. dia.DiagName = subitem.ClassName
  7971. dia.DiagDept = "肾内科"
  7972. dia.DiagDrNo = doctor.DoctorNumber
  7973. dia.DiagDrName = doctor.UserName
  7974. tempTime3 := time.Unix(item.PreTime, 0)
  7975. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7976. dia.DiagTime = timeFormatTwo
  7977. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7978. }
  7979. }
  7980. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7981. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7982. var res ResultCFYLJG001
  7983. var respJSON2 map[string]interface{}
  7984. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7987. return
  7988. }
  7989. userJSONBytes2, _ := json.Marshal(respJSON2)
  7990. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7991. utils.ErrorLog("解析失败:%v", err)
  7992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7993. return
  7994. }
  7995. if res.Infcode == -1 {
  7996. c.ServeSuccessJSON(map[string]interface{}{
  7997. "failed_code": -10,
  7998. "msg": res.ErrMsg,
  7999. })
  8000. return
  8001. } else {
  8002. var flow models.HisPrescriptionFlow
  8003. flow.Ctime = time.Now().Unix()
  8004. flow.SignDigest = ""
  8005. flow.RxTraceCode = res.Output.RxTraceCode
  8006. flow.HiRxno = res.Output.HiRxno
  8007. flow.MID = his.Number
  8008. flow.Status = 1
  8009. flow.DCode = doctor_info.DoctorNumber
  8010. flow.OriginalRxFile = ""
  8011. flow.OriginalValue = ""
  8012. flow.SignCertDn = ""
  8013. flow.UserOrgId = 10454
  8014. flow.SignCertSn = ""
  8015. flow.Mtime = time.Now().Unix()
  8016. service.Createflow(&flow)
  8017. c.ServeSuccessJSON(map[string]interface{}{
  8018. "msg": "上传成功",
  8019. })
  8020. }
  8021. }
  8022. }
  8023. func (c *HisApiController) GetCFYLJG002() {
  8024. admin_user_id, _ := c.GetInt64("admin_user_id")
  8025. his_patient_id, _ := c.GetInt64("his_patient_id")
  8026. record_time := c.GetString("record_time")
  8027. admin_user_id = 3626
  8028. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8029. //id, _ := c.GetInt64("id")
  8030. admin_user_id = 3626
  8031. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8032. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8033. flow, _ := service.Getflowtwo(his.Number)
  8034. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8035. //record_time := c.GetString("record_time")
  8036. patient_id, _ := c.GetInt64("patient_id")
  8037. //patient_id = 23834
  8038. //record_time = "2023-09-18"
  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. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8049. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8050. dept, _ := service.GetDepartMentDetail(info.Departments)
  8051. inputData := make(map[string]interface{})
  8052. inputData["rxTraceCode"] = flow.RxTraceCode
  8053. inputData["hiRxno"] = flow.HiRxno
  8054. inputData["mdtrtId"] = flow.MID
  8055. inputData["patnName"] = his.PsnName
  8056. inputData["psnCertType"] = his.PsnCertType
  8057. inputData["certno"] = his.Certno
  8058. inputData["fixmedinsName"] = miConfig.OrgName
  8059. inputData["fixmedinsCode"] = miConfig.Code
  8060. inputData["drCode"] = doctor_info.DoctorNumber
  8061. inputData["prscDrName"] = doctor_info.UserName
  8062. inputData["pharDeptName"] = dept.Name
  8063. inputData["pharDeptCode"] = dept.Number
  8064. inputData["pharProfttlCodg"] = dept.Name
  8065. inputData["pharProfttlName"] = ""
  8066. inputData["pharCode"] = "HY440309002107"
  8067. inputData["pharCertType"] = "01"
  8068. inputData["pharCertno"] = "430482199408260023"
  8069. inputData["pharName"] = "彭斯遥"
  8070. inputData["pharPracCertNo"] = ""
  8071. tempTime2 := time.Unix(info.Ctime, 0)
  8072. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8073. inputData["pharChkTime"] = timeFormatTwo
  8074. bytesData, _ := json.Marshal(inputData)
  8075. fmt.Println(string(bytesData))
  8076. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8077. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8078. if err != nil {
  8079. fmt.Println("Error reading PDF file:", err)
  8080. return
  8081. }
  8082. // 将 PDF 文件内容进行 Base64 编码
  8083. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8084. fmt.Println(err)
  8085. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8086. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8087. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8088. var res2 Result002
  8089. var respJSON2 map[string]interface{}
  8090. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8093. return
  8094. }
  8095. userJSONBytes2, _ := json.Marshal(respJSON2)
  8096. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8097. utils.ErrorLog("解析失败:%v", err)
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8099. return
  8100. }
  8101. if res2.Infcode == 0 {
  8102. flow.Ctime = time.Now().Unix()
  8103. flow.SignDigest = res2.Output.SignDigest
  8104. flow.RxFile = res2.Output.RxFile
  8105. flow.MID = his.Number
  8106. flow.Status = 1
  8107. flow.DCode = doctor_info.DoctorNumber
  8108. flow.OriginalRxFile = rx_encoded
  8109. flow.OriginalValue = encoded
  8110. flow.SignCertDn = res2.Output.SignCertDn
  8111. flow.SignCertSn = res2.Output.SignCertSn
  8112. flow.Mtime = time.Now().Unix()
  8113. service.Saveflow(flow)
  8114. c.ServeSuccessJSON(map[string]interface{}{
  8115. "msg": "预签名成功",
  8116. })
  8117. } else {
  8118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8119. return
  8120. }
  8121. }
  8122. func (c *HisApiController) GetCFYLJG003() {
  8123. admin_user_id, _ := c.GetInt64("admin_user_id")
  8124. his_patient_id, _ := c.GetInt64("his_patient_id")
  8125. record_time := c.GetString("record_time")
  8126. admin_user_id = 3626
  8127. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8128. //id, _ := c.GetInt64("id")
  8129. admin_user_id = 3626
  8130. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8131. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8132. flow, _ := service.Getflowtwo(his.Number)
  8133. //id = 3
  8134. patient_id, _ := c.GetInt64("patient_id")
  8135. //patient_id = 23834
  8136. //record_time = "2023-09-18"
  8137. timeLayout := "2006-01-02"
  8138. loc, _ := time.LoadLocation("Local")
  8139. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8140. if err != nil {
  8141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8142. return
  8143. }
  8144. recordDateTime := theTime.Unix()
  8145. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8146. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8147. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8148. dept, _ := service.GetDepartMentDetail(info.Departments)
  8149. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8150. var cFYLJG003 models.CFYLJG003
  8151. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8152. cFYLJG003.HiRxno = flow.HiRxno
  8153. cFYLJG003.MdtrtID = flow.MID
  8154. cFYLJG003.PatnName = his.Name
  8155. cFYLJG003.Certno = his.Certno
  8156. cFYLJG003.FixmedinsName = miConfig.OrgName
  8157. cFYLJG003.FixmedinsCode = miConfig.Code
  8158. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8159. cFYLJG003.PrscDrName = doctor_info.UserName
  8160. cFYLJG003.PharDeptName = dept.Name
  8161. cFYLJG003.PharDeptCode = dept.Number
  8162. cFYLJG003.PharCode = "HY440309002107"
  8163. cFYLJG003.PharCertType = "01"
  8164. cFYLJG003.PharCertno = "430482199408260023"
  8165. cFYLJG003.PharName = "彭斯遥"
  8166. cFYLJG003.PsnCertType = "01"
  8167. cFYLJG003.RxFile = flow.RxFile
  8168. cFYLJG003.SignDigest = flow.SignDigest
  8169. cFYLJG003.FixmedinsCode = miConfig.Code
  8170. cFYLJG003.PsnCertType = "01"
  8171. cFYLJG003.PharProfttlCodg = dept.Name
  8172. //inputData["pharProfttlCodg"] =dept.Name
  8173. tempTime2 := time.Unix(info.Ctime, 0)
  8174. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8175. cFYLJG003.PharChkTime = timeFormatTwo
  8176. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8177. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8178. var res ResultCFYLJG003
  8179. var respJSON2 map[string]interface{}
  8180. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8183. return
  8184. }
  8185. userJSONBytes2, _ := json.Marshal(respJSON2)
  8186. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8187. utils.ErrorLog("解析失败:%v", err)
  8188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8189. return
  8190. }
  8191. if res.Infcode == -1 {
  8192. c.ServeSuccessJSON(map[string]interface{}{
  8193. "failed_code": -10,
  8194. "msg": res.ErrMsg,
  8195. })
  8196. return
  8197. } else {
  8198. c.ServeSuccessJSON(map[string]interface{}{
  8199. "info": res.Output,
  8200. })
  8201. }
  8202. }
  8203. func (c *HisApiController) GetCFYLJG004() {
  8204. admin_user_id, _ := c.GetInt64("admin_user_id")
  8205. his_patient_id, _ := c.GetInt64("his_patient_id")
  8206. record_time := c.GetString("record_time")
  8207. admin_user_id = 3626
  8208. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8209. //id, _ := c.GetInt64("id")
  8210. admin_user_id = 3626
  8211. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8212. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8213. flow, _ := service.Getflowtwo(his.Number)
  8214. //id = 3
  8215. patient_id, _ := c.GetInt64("patient_id")
  8216. //patient_id = 23834
  8217. //record_time = "2023-09-18"
  8218. timeLayout := "2006-01-02"
  8219. loc, _ := time.LoadLocation("Local")
  8220. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8221. if err != nil {
  8222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8223. return
  8224. }
  8225. recordDateTime := theTime.Unix()
  8226. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8227. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8228. var cFYLJG004 models.CFYLJG004
  8229. cFYLJG004.HiRxno = flow.HiRxno
  8230. cFYLJG004.FixmedinsCode = miConfig.Code
  8231. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8232. cFYLJG004.UndoDrCertType = "01"
  8233. cFYLJG004.UndoRea = "撤销处方"
  8234. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8235. cFYLJG004.UndoDrName = doctor_info.UserName
  8236. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8237. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8238. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8239. var res ResultCFYLJG004
  8240. var respJSON2 map[string]interface{}
  8241. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8244. return
  8245. }
  8246. userJSONBytes2, _ := json.Marshal(respJSON2)
  8247. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8248. utils.ErrorLog("解析失败:%v", err)
  8249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8250. return
  8251. }
  8252. if res.Infcode == -1 {
  8253. c.ServeSuccessJSON(map[string]interface{}{
  8254. "failed_code": -10,
  8255. "msg": res.ErrMsg,
  8256. })
  8257. return
  8258. } else {
  8259. flow.Status = 0
  8260. service.Saveflow(flow)
  8261. c.ServeSuccessJSON(map[string]interface{}{
  8262. "msg": "撤销成功",
  8263. })
  8264. return
  8265. }
  8266. }
  8267. func (c *HisApiController) GetCFYLJG005() {
  8268. admin_user_id, _ := c.GetInt64("admin_user_id")
  8269. his_patient_id, _ := c.GetInt64("his_patient_id")
  8270. //record_time := c.GetString("record_time")
  8271. admin_user_id = 3626
  8272. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8273. //id, _ := c.GetInt64("id")
  8274. admin_user_id = 3626
  8275. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8276. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8277. flow, _ := service.Getflowtwo(his.Number)
  8278. //id = 3
  8279. var cFYLJG005 models.CFYLJG005
  8280. //patient_id, _ := c.GetInt64("patient_id")
  8281. cFYLJG005.HiRxno = flow.HiRxno
  8282. cFYLJG005.MdtrtID = flow.MID
  8283. cFYLJG005.EcToken = ""
  8284. cFYLJG005.PsnName = his.Name
  8285. cFYLJG005.PsnCertType = "01"
  8286. cFYLJG005.Certno = his.IdCardNo
  8287. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8288. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8289. var res ResultCFYLJG005
  8290. var respJSON2 map[string]interface{}
  8291. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8294. return
  8295. }
  8296. userJSONBytes2, _ := json.Marshal(respJSON2)
  8297. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8298. utils.ErrorLog("解析失败:%v", err)
  8299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8300. return
  8301. }
  8302. if res.Infcode == -1 {
  8303. c.ServeSuccessJSON(map[string]interface{}{
  8304. "failed_code": -10,
  8305. "msg": res.ErrMsg,
  8306. })
  8307. return
  8308. } else {
  8309. c.ServeSuccessJSON(map[string]interface{}{
  8310. "info": res.Output,
  8311. })
  8312. return
  8313. }
  8314. }
  8315. func (c *HisApiController) GetCFYLJG006() {
  8316. admin_user_id, _ := c.GetInt64("admin_user_id")
  8317. his_patient_id, _ := c.GetInt64("his_patient_id")
  8318. admin_user_id = 3626
  8319. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8320. //id, _ := c.GetInt64("id")
  8321. admin_user_id = 3626
  8322. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8323. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8324. flow, _ := service.Getflowtwo(his.Number)
  8325. //id = 3
  8326. patient_id, _ := c.GetInt64("patient_id")
  8327. var cFYLJG006 models.CFYLJG006
  8328. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8329. cFYLJG006.HiRxno = flow.HiRxno
  8330. cFYLJG006.MdtrtID = flow.MID
  8331. cFYLJG006.PsnName = patient.Name
  8332. cFYLJG006.PsnCertType = "01"
  8333. cFYLJG006.Certno = patient.IdCardNo
  8334. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8335. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8336. var res ResultCFYLJG006
  8337. var respJSON2 map[string]interface{}
  8338. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8341. return
  8342. }
  8343. userJSONBytes2, _ := json.Marshal(respJSON2)
  8344. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8345. utils.ErrorLog("解析失败:%v", err)
  8346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8347. return
  8348. }
  8349. if res.Infcode == -1 {
  8350. c.ServeSuccessJSON(map[string]interface{}{
  8351. "failed_code": -10,
  8352. "msg": res.ErrMsg,
  8353. })
  8354. return
  8355. } else {
  8356. c.ServeSuccessJSON(map[string]interface{}{
  8357. "info": res.Output,
  8358. })
  8359. return
  8360. }
  8361. }
  8362. func (c *HisApiController) GetCFYLJG007() {
  8363. admin_user_id, _ := c.GetInt64("admin_user_id")
  8364. his_patient_id, _ := c.GetInt64("his_patient_id")
  8365. admin_user_id = 3626
  8366. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8367. //id, _ := c.GetInt64("id")
  8368. admin_user_id = 3626
  8369. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8371. flow, _ := service.Getflowtwo(his.Number)
  8372. //id = 3
  8373. patient_id, _ := c.GetInt64("patient_id")
  8374. var cFYLJG007 models.CFYLJG007
  8375. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8376. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8377. cFYLJG007.HiRxno = flow.HiRxno
  8378. cFYLJG007.MdtrtID = flow.MID
  8379. cFYLJG007.PsnNo = his.PsnNo
  8380. cFYLJG007.PsnCertType = "01"
  8381. cFYLJG007.Certno = patient.IdCardNo
  8382. cFYLJG007.PsnName = patient.Name
  8383. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8384. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8385. var res ResultCFYLJG007
  8386. var respJSON2 map[string]interface{}
  8387. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8390. return
  8391. }
  8392. userJSONBytes2, _ := json.Marshal(respJSON2)
  8393. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8394. utils.ErrorLog("解析失败:%v", err)
  8395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8396. return
  8397. }
  8398. if res.Infcode == -1 {
  8399. c.ServeSuccessJSON(map[string]interface{}{
  8400. "failed_code": -10,
  8401. "msg": res.ErrMsg,
  8402. })
  8403. return
  8404. } else {
  8405. c.ServeSuccessJSON(map[string]interface{}{
  8406. "info": res,
  8407. })
  8408. return
  8409. }
  8410. }
  8411. func (c *HisApiController) GetCFYLJG008() {
  8412. admin_user_id, _ := c.GetInt64("admin_user_id")
  8413. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8414. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8415. var cFYLJG008 models.CFYLJG008
  8416. //id, _ := c.GetInt64("id")
  8417. patient_id, _ := c.GetInt64("patient_id")
  8418. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8419. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8420. //id = 3
  8421. //flow, _ := service.Getflow(id)
  8422. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8423. //
  8424. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8425. //patient_id, _ := c.GetInt64("patient_id")
  8426. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8427. record_time := c.GetString("record_time")
  8428. admin_user_id = 3626
  8429. patient_id = 19424
  8430. //his_patient_id = 263947
  8431. record_time = "2023-08-29"
  8432. timeLayout := "2006-01-02"
  8433. loc, _ := time.LoadLocation("Local")
  8434. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8435. if err != nil {
  8436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8437. return
  8438. }
  8439. recordDateTime := theTime.Unix()
  8440. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8441. cFYLJG008.FixmedinsName = ""
  8442. cFYLJG008.Lat = ""
  8443. cFYLJG008.Lng = ""
  8444. cFYLJG008.OrderType = "1"
  8445. cFYLJG008.PoolareaNo = ""
  8446. cFYLJG008.Lng = ""
  8447. cFYLJG008.PageNum = 1
  8448. cFYLJG008.PageSize = 10
  8449. var MPI models.MedinsProdInvChgDDTO
  8450. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8451. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8452. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8453. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8454. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8455. var res ResultCFYLJG008
  8456. var respJSON2 map[string]interface{}
  8457. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8460. return
  8461. }
  8462. userJSONBytes2, _ := json.Marshal(respJSON2)
  8463. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8464. utils.ErrorLog("解析失败:%v", err)
  8465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8466. return
  8467. }
  8468. if res.Infcode == -1 {
  8469. c.ServeSuccessJSON(map[string]interface{}{
  8470. "failed_code": -10,
  8471. "msg": res.ErrMsg,
  8472. })
  8473. return
  8474. } else {
  8475. c.ServeSuccessJSON(map[string]interface{}{
  8476. "info": res.Output,
  8477. })
  8478. return
  8479. }
  8480. }
  8481. func (c *HisApiController) GetBL4201A() {
  8482. order_id, _ := c.GetInt64("order_id")
  8483. admin_user_id, _ := c.GetInt64("admin_user_id")
  8484. order, _ := service.GetHisOrderByIDTwo(order_id)
  8485. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8486. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8487. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8488. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8489. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8490. department, _ := service.GetDepartMentDetail(his.Departments)
  8491. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8492. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8493. if order.ID == 0 {
  8494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8495. return
  8496. }
  8497. var struct4201A models.Struct4201A
  8498. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8499. for _, items := range order_info {
  8500. memo := make(map[string]interface{})
  8501. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8502. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8503. fsiOPFLD.MedType = "14"
  8504. fsiOPFLD.BkkpSn = items.FeedetlSn
  8505. fsiOPFLD.FixmedinsCode = miConfig.Code
  8506. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8507. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8508. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8509. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8510. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8511. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8512. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8513. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8514. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8515. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8516. fsiOPFLD.BilgDeptName = department.Name
  8517. fsiOPFLD.BilgDeptCodg = department.Number
  8518. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8519. fsiOPFLD.BilgDrName = doctor.UserName
  8520. fsiOPFLD.MedChrgitmType = "09"
  8521. memo["hosp_appr_flag"] = "1"
  8522. memo["invoice_no"] = order.MdtrtId
  8523. memo["memo"] = "自费"
  8524. bytesData, _ := json.Marshal(memo)
  8525. fsiOPFLD.Memo = string(bytesData)
  8526. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8527. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8528. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8529. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8530. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8531. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8532. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8533. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8534. fsiOPFLD.BilgDeptName = department.Name
  8535. fsiOPFLD.BilgDeptCodg = department.Number
  8536. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8537. fsiOPFLD.BilgDrName = doctor.UserName
  8538. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8539. case 0:
  8540. break
  8541. case 1:
  8542. fsiOPFLD.MedChrgitmType = "14"
  8543. break
  8544. case 2:
  8545. fsiOPFLD.MedChrgitmType = "05"
  8546. break
  8547. case 3:
  8548. fsiOPFLD.MedChrgitmType = "03"
  8549. break
  8550. case 4:
  8551. fsiOPFLD.MedChrgitmType = "03"
  8552. break
  8553. case 5:
  8554. fsiOPFLD.MedChrgitmType = "08"
  8555. break
  8556. case 6:
  8557. fsiOPFLD.MedChrgitmType = "14"
  8558. break
  8559. case 7:
  8560. fsiOPFLD.MedChrgitmType = "14"
  8561. break
  8562. case 8:
  8563. fsiOPFLD.MedChrgitmType = "03"
  8564. break
  8565. case 9:
  8566. fsiOPFLD.MedChrgitmType = "14"
  8567. break
  8568. case 10:
  8569. fsiOPFLD.MedChrgitmType = "14"
  8570. break
  8571. case 11:
  8572. fsiOPFLD.MedChrgitmType = "06"
  8573. break
  8574. case 12:
  8575. fsiOPFLD.MedChrgitmType = "12"
  8576. break
  8577. case 13:
  8578. fsiOPFLD.MedChrgitmType = "01"
  8579. break
  8580. case 14:
  8581. fsiOPFLD.MedChrgitmType = "04"
  8582. break
  8583. case 15:
  8584. fsiOPFLD.MedChrgitmType = "14"
  8585. break
  8586. }
  8587. memo["hosp_appr_flag"] = "1"
  8588. memo["invoice_no"] = order.MdtrtId
  8589. memo["memo"] = "自费"
  8590. bytesData, _ := json.Marshal(memo)
  8591. fsiOPFLD.Memo = string(bytesData)
  8592. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8593. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8594. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8595. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8596. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8597. fsiOPFLD.BilgDeptName = department.Name
  8598. fsiOPFLD.BilgDeptCodg = department.Number
  8599. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8600. fsiOPFLD.BilgDrName = doctor.UserName
  8601. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8602. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8603. fsiOPFLD.MedChrgitmType = "08"
  8604. memo["hosp_appr_flag"] = "1"
  8605. memo["invoice_no"] = order.MdtrtId
  8606. memo["memo"] = "自费"
  8607. bytesData, _ := json.Marshal(memo)
  8608. fsiOPFLD.Memo = string(bytesData)
  8609. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8610. }
  8611. }
  8612. }
  8613. for _, items := range order_info_two {
  8614. memo := make(map[string]interface{})
  8615. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8616. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8617. fsiOPFLD.MedType = "14"
  8618. fsiOPFLD.BkkpSn = items.FeedetlSn
  8619. fsiOPFLD.FixmedinsCode = miConfig.Code
  8620. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8621. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8622. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8623. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8624. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8625. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8626. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8627. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8628. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8629. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8630. fsiOPFLD.BilgDeptName = department.Name
  8631. fsiOPFLD.BilgDeptCodg = department.Number
  8632. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8633. fsiOPFLD.BilgDrName = doctor.UserName
  8634. fsiOPFLD.MedChrgitmType = "09"
  8635. memo["hosp_appr_flag"] = "1"
  8636. memo["invoice_no"] = order.MdtrtId
  8637. memo["memo"] = "自费"
  8638. bytesData, _ := json.Marshal(memo)
  8639. fsiOPFLD.Memo = string(bytesData)
  8640. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8641. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8642. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8643. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8644. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8645. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8646. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8647. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8648. fsiOPFLD.BilgDeptName = department.Name
  8649. fsiOPFLD.BilgDeptCodg = department.Number
  8650. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8651. fsiOPFLD.BilgDrName = doctor.UserName
  8652. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8653. case 0:
  8654. break
  8655. case 1:
  8656. fsiOPFLD.MedChrgitmType = "14"
  8657. break
  8658. case 2:
  8659. fsiOPFLD.MedChrgitmType = "05"
  8660. break
  8661. case 3:
  8662. fsiOPFLD.MedChrgitmType = "03"
  8663. break
  8664. case 4:
  8665. fsiOPFLD.MedChrgitmType = "03"
  8666. break
  8667. case 5:
  8668. fsiOPFLD.MedChrgitmType = "08"
  8669. break
  8670. case 6:
  8671. fsiOPFLD.MedChrgitmType = "14"
  8672. break
  8673. case 7:
  8674. fsiOPFLD.MedChrgitmType = "14"
  8675. break
  8676. case 8:
  8677. fsiOPFLD.MedChrgitmType = "03"
  8678. break
  8679. case 9:
  8680. fsiOPFLD.MedChrgitmType = "14"
  8681. break
  8682. case 10:
  8683. fsiOPFLD.MedChrgitmType = "14"
  8684. break
  8685. case 11:
  8686. fsiOPFLD.MedChrgitmType = "06"
  8687. break
  8688. case 12:
  8689. fsiOPFLD.MedChrgitmType = "12"
  8690. break
  8691. case 13:
  8692. fsiOPFLD.MedChrgitmType = "01"
  8693. break
  8694. case 14:
  8695. fsiOPFLD.MedChrgitmType = "04"
  8696. break
  8697. case 15:
  8698. fsiOPFLD.MedChrgitmType = "14"
  8699. break
  8700. }
  8701. memo["hosp_appr_flag"] = "1"
  8702. memo["invoice_no"] = order.MdtrtId
  8703. memo["memo"] = "自费"
  8704. bytesData, _ := json.Marshal(memo)
  8705. fsiOPFLD.Memo = string(bytesData)
  8706. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8707. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8708. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8709. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8710. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8711. fsiOPFLD.BilgDeptName = department.Name
  8712. fsiOPFLD.BilgDeptCodg = department.Number
  8713. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8714. fsiOPFLD.BilgDrName = doctor.UserName
  8715. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8716. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8717. fsiOPFLD.MedChrgitmType = "08"
  8718. memo["hosp_appr_flag"] = "1"
  8719. memo["invoice_no"] = order.MdtrtId
  8720. memo["memo"] = "自费"
  8721. bytesData, _ := json.Marshal(memo)
  8722. fsiOPFLD.Memo = string(bytesData)
  8723. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8724. }
  8725. }
  8726. }
  8727. fmt.Println(fsiOPFLDs)
  8728. struct4201A.Fopfd = fsiOPFLDs
  8729. fmt.Println(struct4201A.Fopfd)
  8730. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8731. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8732. var res2 ResultSix
  8733. var respJSON2 map[string]interface{}
  8734. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8737. return
  8738. }
  8739. userJSONBytes2, _ := json.Marshal(respJSON2)
  8740. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8741. utils.ErrorLog("解析失败:%v", err)
  8742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8743. return
  8744. }
  8745. if res2.Infcode != 0 {
  8746. c.ServeSuccessJSON(map[string]interface{}{
  8747. "failed_code": -10,
  8748. "msg": res2.ErrMsg,
  8749. })
  8750. return
  8751. } else {
  8752. order.IsUploadOrderInfo = 1
  8753. service.UpdateOrder(order)
  8754. c.ServeSuccessJSON(map[string]interface{}{
  8755. "msg": "上传成功",
  8756. })
  8757. }
  8758. }
  8759. func (c *HisApiController) Get2505() {
  8760. admin_user_id, _ := c.GetInt64("admin_user_id")
  8761. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8762. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8763. 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)
  8764. }
  8765. func (c *HisApiController) Get4201A() {
  8766. order_id, _ := c.GetInt64("order_id")
  8767. admin_user_id, _ := c.GetInt64("admin_user_id")
  8768. order, _ := service.GetHisOrderByIDTwo(order_id)
  8769. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8770. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8771. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8772. //order_info = append(order_info, order_info_two...)
  8773. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8774. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8775. department, _ := service.GetDepartMentDetail(his.Departments)
  8776. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8777. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8778. if order.ID == 0 {
  8779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8780. return
  8781. }
  8782. var struct4201A models.Struct4201A
  8783. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8784. for _, items := range order_info {
  8785. memo := make(map[string]interface{})
  8786. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8787. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8788. fsiOPFLD.MedType = "14"
  8789. fsiOPFLD.BkkpSn = items.FeedetlSn
  8790. fsiOPFLD.FixmedinsCode = miConfig.Code
  8791. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8792. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8793. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8794. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8795. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8796. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8797. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8798. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8799. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8800. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8801. fsiOPFLD.BilgDeptName = department.Name
  8802. fsiOPFLD.BilgDeptCodg = department.Number
  8803. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8804. fsiOPFLD.BilgDrName = doctor.UserName
  8805. fsiOPFLD.MedChrgitmType = "09"
  8806. memo["hosp_appr_flag"] = "1"
  8807. memo["invoice_no"] = order.MdtrtId
  8808. memo["memo"] = "自费"
  8809. bytesData, _ := json.Marshal(memo)
  8810. fsiOPFLD.Memo = string(bytesData)
  8811. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8812. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8813. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8814. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8815. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8816. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8817. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8818. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8819. fsiOPFLD.BilgDeptName = department.Name
  8820. fsiOPFLD.BilgDeptCodg = department.Number
  8821. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8822. fsiOPFLD.BilgDrName = doctor.UserName
  8823. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8824. case 0:
  8825. break
  8826. case 1:
  8827. fsiOPFLD.MedChrgitmType = "14"
  8828. break
  8829. case 2:
  8830. fsiOPFLD.MedChrgitmType = "05"
  8831. break
  8832. case 3:
  8833. fsiOPFLD.MedChrgitmType = "03"
  8834. break
  8835. case 4:
  8836. fsiOPFLD.MedChrgitmType = "03"
  8837. break
  8838. case 5:
  8839. fsiOPFLD.MedChrgitmType = "08"
  8840. break
  8841. case 6:
  8842. fsiOPFLD.MedChrgitmType = "14"
  8843. break
  8844. case 7:
  8845. fsiOPFLD.MedChrgitmType = "14"
  8846. break
  8847. case 8:
  8848. fsiOPFLD.MedChrgitmType = "03"
  8849. break
  8850. case 9:
  8851. fsiOPFLD.MedChrgitmType = "14"
  8852. break
  8853. case 10:
  8854. fsiOPFLD.MedChrgitmType = "14"
  8855. break
  8856. case 11:
  8857. fsiOPFLD.MedChrgitmType = "06"
  8858. break
  8859. case 12:
  8860. fsiOPFLD.MedChrgitmType = "12"
  8861. break
  8862. case 13:
  8863. fsiOPFLD.MedChrgitmType = "01"
  8864. break
  8865. case 14:
  8866. fsiOPFLD.MedChrgitmType = "04"
  8867. break
  8868. case 15:
  8869. fsiOPFLD.MedChrgitmType = "14"
  8870. break
  8871. }
  8872. memo["hosp_appr_flag"] = "1"
  8873. memo["invoice_no"] = order.MdtrtId
  8874. memo["memo"] = "自费"
  8875. bytesData, _ := json.Marshal(memo)
  8876. fsiOPFLD.Memo = string(bytesData)
  8877. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8878. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8879. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8880. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8881. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8882. fsiOPFLD.BilgDeptName = department.Name
  8883. fsiOPFLD.BilgDeptCodg = department.Number
  8884. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8885. fsiOPFLD.BilgDrName = doctor.UserName
  8886. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8887. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8888. fsiOPFLD.MedChrgitmType = "08"
  8889. memo["hosp_appr_flag"] = "1"
  8890. memo["invoice_no"] = order.MdtrtId
  8891. memo["memo"] = "自费"
  8892. bytesData, _ := json.Marshal(memo)
  8893. fsiOPFLD.Memo = string(bytesData)
  8894. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8895. }
  8896. }
  8897. }
  8898. for _, items := range order_info_two {
  8899. memo := make(map[string]interface{})
  8900. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8901. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8902. fsiOPFLD.MedType = "14"
  8903. fsiOPFLD.BkkpSn = items.FeedetlSn
  8904. fsiOPFLD.FixmedinsCode = miConfig.Code
  8905. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8906. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8907. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8908. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8909. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8910. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8911. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8912. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8913. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8914. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8915. fsiOPFLD.BilgDeptName = department.Name
  8916. fsiOPFLD.BilgDeptCodg = department.Number
  8917. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8918. fsiOPFLD.BilgDrName = doctor.UserName
  8919. fsiOPFLD.MedChrgitmType = "09"
  8920. memo["hosp_appr_flag"] = "1"
  8921. memo["invoice_no"] = order.MdtrtId
  8922. memo["memo"] = "自费"
  8923. bytesData, _ := json.Marshal(memo)
  8924. fsiOPFLD.Memo = string(bytesData)
  8925. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8926. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8927. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8928. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8929. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8930. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8931. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8932. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8933. fsiOPFLD.BilgDeptName = department.Name
  8934. fsiOPFLD.BilgDeptCodg = department.Number
  8935. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8936. fsiOPFLD.BilgDrName = doctor.UserName
  8937. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8938. case 0:
  8939. break
  8940. case 1:
  8941. fsiOPFLD.MedChrgitmType = "14"
  8942. break
  8943. case 2:
  8944. fsiOPFLD.MedChrgitmType = "05"
  8945. break
  8946. case 3:
  8947. fsiOPFLD.MedChrgitmType = "03"
  8948. break
  8949. case 4:
  8950. fsiOPFLD.MedChrgitmType = "03"
  8951. break
  8952. case 5:
  8953. fsiOPFLD.MedChrgitmType = "08"
  8954. break
  8955. case 6:
  8956. fsiOPFLD.MedChrgitmType = "14"
  8957. break
  8958. case 7:
  8959. fsiOPFLD.MedChrgitmType = "14"
  8960. break
  8961. case 8:
  8962. fsiOPFLD.MedChrgitmType = "03"
  8963. break
  8964. case 9:
  8965. fsiOPFLD.MedChrgitmType = "14"
  8966. break
  8967. case 10:
  8968. fsiOPFLD.MedChrgitmType = "14"
  8969. break
  8970. case 11:
  8971. fsiOPFLD.MedChrgitmType = "06"
  8972. break
  8973. case 12:
  8974. fsiOPFLD.MedChrgitmType = "12"
  8975. break
  8976. case 13:
  8977. fsiOPFLD.MedChrgitmType = "01"
  8978. break
  8979. case 14:
  8980. fsiOPFLD.MedChrgitmType = "04"
  8981. break
  8982. case 15:
  8983. fsiOPFLD.MedChrgitmType = "14"
  8984. break
  8985. }
  8986. memo["hosp_appr_flag"] = "1"
  8987. memo["invoice_no"] = order.MdtrtId
  8988. memo["memo"] = "自费"
  8989. bytesData, _ := json.Marshal(memo)
  8990. fsiOPFLD.Memo = string(bytesData)
  8991. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8992. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8993. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8994. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8995. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8996. fsiOPFLD.BilgDeptName = department.Name
  8997. fsiOPFLD.BilgDeptCodg = department.Number
  8998. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8999. fsiOPFLD.BilgDrName = doctor.UserName
  9000. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9001. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9002. fsiOPFLD.MedChrgitmType = "08"
  9003. memo["hosp_appr_flag"] = "1"
  9004. memo["invoice_no"] = order.MdtrtId
  9005. memo["memo"] = "自费"
  9006. bytesData, _ := json.Marshal(memo)
  9007. fsiOPFLD.Memo = string(bytesData)
  9008. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9009. }
  9010. }
  9011. }
  9012. fmt.Println(fsiOPFLDs)
  9013. struct4201A.Fopfd = fsiOPFLDs
  9014. fmt.Println(struct4201A.Fopfd)
  9015. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9016. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9017. var res2 ResultSix
  9018. var respJSON2 map[string]interface{}
  9019. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9022. return
  9023. }
  9024. userJSONBytes2, _ := json.Marshal(respJSON2)
  9025. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9026. utils.ErrorLog("解析失败:%v", err)
  9027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9028. return
  9029. }
  9030. if res2.Infcode != 0 {
  9031. c.ServeSuccessJSON(map[string]interface{}{
  9032. "failed_code": -10,
  9033. "msg": res2.ErrMsg,
  9034. })
  9035. return
  9036. } else {
  9037. order.IsUploadOrderInfo = 1
  9038. service.UpdateOrder(order)
  9039. c.ServeSuccessJSON(map[string]interface{}{
  9040. "msg": "上传成功",
  9041. })
  9042. }
  9043. }
  9044. func (c *HisApiController) Get4202() {
  9045. order_id, _ := c.GetInt64("order_id")
  9046. admin_user_id, _ := c.GetInt64("admin_user_id")
  9047. order, _ := service.GetHisOrderByIDTwo(order_id)
  9048. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9049. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9050. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9051. if order.ID == 0 {
  9052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9053. return
  9054. }
  9055. var struct4202 models.Struct4202
  9056. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9057. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9058. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9059. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9060. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9061. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9062. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9063. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9064. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9065. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9066. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9067. var config []*models.HisXtDiagnoseConfig
  9068. for _, item := range diagnosis_ids {
  9069. id, _ := strconv.ParseInt(item, 10, 64)
  9070. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9071. config = append(config, &diagnosisConfig)
  9072. }
  9073. var tempDiaginfos []models.OwnPayPatnDiagListD
  9074. for index, item := range config {
  9075. if index == 0 {
  9076. var tempDiaginfo models.OwnPayPatnDiagListD
  9077. tempDiaginfo.InoutDiagType = "1"
  9078. tempDiaginfo.DiagCode = item.CountryCode
  9079. tempDiaginfo.DiagName = item.CountryContentName
  9080. tempDiaginfo.DiagType = "1"
  9081. tempDiaginfo.DiagSrtNo = "1"
  9082. tempDiaginfo.MaindiagFlag = "1"
  9083. tempDiaginfo.ValiFlag = "1"
  9084. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9085. } else {
  9086. var tempDiaginfo models.OwnPayPatnDiagListD
  9087. tempDiaginfo.DiagCode = item.CountryCode
  9088. tempDiaginfo.DiagName = item.CountryContentName
  9089. tempDiaginfo.DiagType = "2"
  9090. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9091. tempDiaginfo.MaindiagFlag = "0"
  9092. tempDiaginfo.ValiFlag = "1"
  9093. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9094. }
  9095. }
  9096. struct4202.ODiagListD = tempDiaginfos
  9097. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9098. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9099. var res2 ResultSix
  9100. var respJSON2 map[string]interface{}
  9101. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9104. return
  9105. }
  9106. userJSONBytes2, _ := json.Marshal(respJSON2)
  9107. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9108. utils.ErrorLog("解析失败:%v", err)
  9109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9110. return
  9111. }
  9112. if res2.Infcode != 0 {
  9113. c.ServeSuccessJSON(map[string]interface{}{
  9114. "failed_code": -10,
  9115. "msg": res2.ErrMsg,
  9116. })
  9117. return
  9118. } else {
  9119. order.IsUploadDiagnose = 1
  9120. service.UpdateOrder(order)
  9121. c.ServeSuccessJSON(map[string]interface{}{
  9122. "msg": "上传成功",
  9123. })
  9124. }
  9125. }
  9126. func (c *HisApiController) Get4203() {
  9127. admin_user_id, _ := c.GetInt64("admin_user_id")
  9128. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9129. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9130. order_id, _ := c.GetInt64("order_id")
  9131. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9132. number := ""
  9133. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9134. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9135. if his.ID == 0 {
  9136. number = hospital.Number
  9137. } else {
  9138. number = his.Number
  9139. }
  9140. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9141. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9142. var res2 ResultSix
  9143. var respJSON2 map[string]interface{}
  9144. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9147. return
  9148. }
  9149. userJSONBytes2, _ := json.Marshal(respJSON2)
  9150. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9151. utils.ErrorLog("解析失败:%v", err)
  9152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9153. return
  9154. }
  9155. if res2.Infcode != 0 {
  9156. c.ServeSuccessJSON(map[string]interface{}{
  9157. "failed_code": -10,
  9158. "msg": res2.ErrMsg,
  9159. })
  9160. return
  9161. } else {
  9162. order.IsUploadSuccess = 1
  9163. service.UpdateOrderTwo(order)
  9164. c.ServeSuccessJSON(map[string]interface{}{
  9165. "msg": "上传成功",
  9166. })
  9167. }
  9168. }
  9169. func (c *HisApiController) Get4205() {
  9170. order_id, _ := c.GetInt64("order_id")
  9171. admin_user_id, _ := c.GetInt64("admin_user_id")
  9172. fapiao_code := c.GetString("fapiao_code")
  9173. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9174. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9175. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9176. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9177. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9178. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9179. //order_info = append(order_info, order_info_two...)
  9180. department, _ := service.GetDepartMentDetail(his.Departments)
  9181. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9182. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9183. if order.ID == 0 {
  9184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9185. return
  9186. }
  9187. var struct4201A models.Struct4201A
  9188. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9189. for _, items := range order_info {
  9190. memo := make(map[string]interface{})
  9191. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9192. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9193. fsiOPFLD.MedType = pre.MedType
  9194. fsiOPFLD.FixmedinsCode = miConfig.Code
  9195. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9196. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9197. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9198. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9199. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9200. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9201. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9202. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9203. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9204. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9205. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9206. fsiOPFLD.BilgDeptName = department.Name
  9207. fsiOPFLD.BilgDeptCodg = department.Number
  9208. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9209. fsiOPFLD.BilgDrName = doctor.UserName
  9210. fsiOPFLD.MedChrgitmType = "09"
  9211. memo["hosp_appr_flag"] = "1"
  9212. memo["invoice_no"] = fapiao_code
  9213. memo["memo"] = "自费"
  9214. bytesData, _ := json.Marshal(memo)
  9215. fsiOPFLD.Memo = string(bytesData)
  9216. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9217. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9218. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9219. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9220. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9221. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9222. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9223. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9224. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9225. fsiOPFLD.BilgDeptName = department.Name
  9226. fsiOPFLD.BilgDeptCodg = department.Number
  9227. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9228. fsiOPFLD.BilgDrName = doctor.UserName
  9229. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9230. case 0:
  9231. break
  9232. case 1:
  9233. fsiOPFLD.MedChrgitmType = "14"
  9234. break
  9235. case 2:
  9236. fsiOPFLD.MedChrgitmType = "05"
  9237. break
  9238. case 3:
  9239. fsiOPFLD.MedChrgitmType = "03"
  9240. break
  9241. case 4:
  9242. fsiOPFLD.MedChrgitmType = "03"
  9243. break
  9244. case 5:
  9245. fsiOPFLD.MedChrgitmType = "08"
  9246. break
  9247. case 6:
  9248. fsiOPFLD.MedChrgitmType = "14"
  9249. break
  9250. case 7:
  9251. fsiOPFLD.MedChrgitmType = "14"
  9252. break
  9253. case 8:
  9254. fsiOPFLD.MedChrgitmType = "03"
  9255. break
  9256. case 9:
  9257. fsiOPFLD.MedChrgitmType = "14"
  9258. break
  9259. case 10:
  9260. fsiOPFLD.MedChrgitmType = "14"
  9261. break
  9262. case 11:
  9263. fsiOPFLD.MedChrgitmType = "06"
  9264. break
  9265. case 12:
  9266. fsiOPFLD.MedChrgitmType = "12"
  9267. break
  9268. case 13:
  9269. fsiOPFLD.MedChrgitmType = "01"
  9270. break
  9271. case 14:
  9272. fsiOPFLD.MedChrgitmType = "04"
  9273. break
  9274. case 15:
  9275. fsiOPFLD.MedChrgitmType = "14"
  9276. break
  9277. }
  9278. memo["hosp_appr_flag"] = "1"
  9279. memo["invoice_no"] = fapiao_code
  9280. memo["memo"] = "自费"
  9281. bytesData, _ := json.Marshal(memo)
  9282. fsiOPFLD.Memo = string(bytesData)
  9283. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9284. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9285. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9286. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9287. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9288. fsiOPFLD.BilgDeptName = department.Name
  9289. fsiOPFLD.BilgDeptCodg = department.Number
  9290. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9291. fsiOPFLD.BilgDrName = doctor.UserName
  9292. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9293. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9294. fsiOPFLD.MedChrgitmType = "08"
  9295. memo["hosp_appr_flag"] = "1"
  9296. memo["invoice_no"] = fapiao_code
  9297. memo["memo"] = "自费"
  9298. bytesData, _ := json.Marshal(memo)
  9299. fsiOPFLD.Memo = string(bytesData)
  9300. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9301. }
  9302. }
  9303. }
  9304. for _, items := range order_info_two {
  9305. memo := make(map[string]interface{})
  9306. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9307. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9308. fsiOPFLD.MedType = pre.MedType
  9309. fsiOPFLD.BkkpSn = items.FeedetlSn
  9310. fsiOPFLD.FixmedinsCode = miConfig.Code
  9311. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9312. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9313. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9314. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9315. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9316. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9317. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9318. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9319. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9320. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9321. fsiOPFLD.BilgDeptName = department.Name
  9322. fsiOPFLD.BilgDeptCodg = department.Number
  9323. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9324. fsiOPFLD.BilgDrName = doctor.UserName
  9325. fsiOPFLD.MedChrgitmType = "09"
  9326. memo["hosp_appr_flag"] = "1"
  9327. memo["invoice_no"] = fapiao_code
  9328. memo["memo"] = "自费"
  9329. bytesData, _ := json.Marshal(memo)
  9330. fsiOPFLD.Memo = string(bytesData)
  9331. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9332. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9333. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9334. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9335. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9336. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9337. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9338. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9339. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9340. fsiOPFLD.BilgDeptName = department.Name
  9341. fsiOPFLD.BilgDeptCodg = department.Number
  9342. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9343. fsiOPFLD.BilgDrName = doctor.UserName
  9344. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9345. case 0:
  9346. break
  9347. case 1:
  9348. fsiOPFLD.MedChrgitmType = "14"
  9349. break
  9350. case 2:
  9351. fsiOPFLD.MedChrgitmType = "05"
  9352. break
  9353. case 3:
  9354. fsiOPFLD.MedChrgitmType = "03"
  9355. break
  9356. case 4:
  9357. fsiOPFLD.MedChrgitmType = "03"
  9358. break
  9359. case 5:
  9360. fsiOPFLD.MedChrgitmType = "08"
  9361. break
  9362. case 6:
  9363. fsiOPFLD.MedChrgitmType = "14"
  9364. break
  9365. case 7:
  9366. fsiOPFLD.MedChrgitmType = "14"
  9367. break
  9368. case 8:
  9369. fsiOPFLD.MedChrgitmType = "03"
  9370. break
  9371. case 9:
  9372. fsiOPFLD.MedChrgitmType = "14"
  9373. break
  9374. case 10:
  9375. fsiOPFLD.MedChrgitmType = "14"
  9376. break
  9377. case 11:
  9378. fsiOPFLD.MedChrgitmType = "06"
  9379. break
  9380. case 12:
  9381. fsiOPFLD.MedChrgitmType = "12"
  9382. break
  9383. case 13:
  9384. fsiOPFLD.MedChrgitmType = "01"
  9385. break
  9386. case 14:
  9387. fsiOPFLD.MedChrgitmType = "04"
  9388. break
  9389. case 15:
  9390. fsiOPFLD.MedChrgitmType = "14"
  9391. break
  9392. }
  9393. memo["hosp_appr_flag"] = "1"
  9394. memo["invoice_no"] = fapiao_code
  9395. memo["memo"] = "自费"
  9396. bytesData, _ := json.Marshal(memo)
  9397. fsiOPFLD.Memo = string(bytesData)
  9398. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9399. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9400. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9401. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9402. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9403. fsiOPFLD.BilgDeptName = department.Name
  9404. fsiOPFLD.BilgDeptCodg = department.Number
  9405. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9406. fsiOPFLD.BilgDrName = doctor.UserName
  9407. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9408. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9409. fsiOPFLD.MedChrgitmType = "08"
  9410. memo["hosp_appr_flag"] = "1"
  9411. memo["invoice_no"] = fapiao_code
  9412. memo["memo"] = "自费"
  9413. bytesData, _ := json.Marshal(memo)
  9414. fsiOPFLD.Memo = string(bytesData)
  9415. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9416. }
  9417. }
  9418. }
  9419. fmt.Println(fsiOPFLDs)
  9420. struct4201A.Fopfd = fsiOPFLDs
  9421. fmt.Println(struct4201A.Fopfd)
  9422. var struct4202 models.Struct4202
  9423. timeLayout := "2006-01-02 15:04:05"
  9424. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9425. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9426. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9427. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9428. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9429. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9430. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9431. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9432. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9433. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9434. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9435. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9436. var config []*models.HisXtDiagnoseConfig
  9437. for _, item := range diagnosis_ids {
  9438. id, _ := strconv.ParseInt(item, 10, 64)
  9439. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9440. config = append(config, &diagnosisConfig)
  9441. }
  9442. var tempDiaginfos []models.OwnPayPatnDiagListD
  9443. for index, item := range config {
  9444. if index == 0 {
  9445. var tempDiaginfo models.OwnPayPatnDiagListD
  9446. tempDiaginfo.InoutDiagType = "1"
  9447. tempDiaginfo.DiagCode = item.CountryCode
  9448. tempDiaginfo.DiagName = item.CountryContentName
  9449. tempDiaginfo.DiagType = "1"
  9450. tempDiaginfo.DiagSrtNo = "1"
  9451. tempDiaginfo.MaindiagFlag = "1"
  9452. tempDiaginfo.ValiFlag = "1"
  9453. tempDiaginfo.DiagDrName = doctor.UserName
  9454. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9455. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9456. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9457. } else {
  9458. var tempDiaginfo models.OwnPayPatnDiagListD
  9459. tempDiaginfo.DiagCode = item.CountryCode
  9460. tempDiaginfo.DiagName = item.CountryContentName
  9461. tempDiaginfo.DiagType = "2"
  9462. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9463. tempDiaginfo.MaindiagFlag = "0"
  9464. tempDiaginfo.ValiFlag = "1"
  9465. tempDiaginfo.DiagDrName = doctor.UserName
  9466. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9467. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9468. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9469. }
  9470. }
  9471. struct4202.ODiagListD = tempDiaginfos
  9472. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9473. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9474. var res2 ResultSix
  9475. var respJSON2 map[string]interface{}
  9476. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9479. return
  9480. }
  9481. userJSONBytes2, _ := json.Marshal(respJSON2)
  9482. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9483. utils.ErrorLog("解析失败:%v", err)
  9484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9485. return
  9486. }
  9487. if res2.Infcode != 0 {
  9488. c.ServeSuccessJSON(map[string]interface{}{
  9489. "failed_code": -10,
  9490. "msg": res2.ErrMsg,
  9491. })
  9492. return
  9493. } else {
  9494. order.IsUploadDiagnose = 1
  9495. order.IsUploadOrderInfo = 1
  9496. service.UpdateOrderTwo(order)
  9497. c.ServeSuccessJSON(map[string]interface{}{
  9498. "msg": "上传成功",
  9499. })
  9500. }
  9501. }
  9502. func (c *HisApiController) Get4207() {
  9503. admin_user_id, _ := c.GetInt64("admin_user_id")
  9504. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9505. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9506. order_id, _ := c.GetInt64("order_id")
  9507. order, _ := service.GetHisOrderByIDTwo(order_id)
  9508. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9509. var struct4207 models.Struct4207
  9510. struct4207.PageNum = "1"
  9511. struct4207.PageSize = "1000"
  9512. struct4207.FixmedinsCode = miConfig.Code
  9513. struct4207.FixmedinsMdtrtID = order.Number
  9514. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9515. saveLog(result, requestLog, "4207", "查询")
  9516. var res2 ResultSix
  9517. var respJSON2 map[string]interface{}
  9518. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9521. return
  9522. }
  9523. userJSONBytes2, _ := json.Marshal(respJSON2)
  9524. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9525. utils.ErrorLog("解析失败:%v", err)
  9526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9527. return
  9528. }
  9529. if res2.Infcode != 0 {
  9530. c.ServeSuccessJSON(map[string]interface{}{
  9531. "failed_code": -10,
  9532. "msg": res2.ErrMsg,
  9533. })
  9534. return
  9535. } else {
  9536. c.ServeSuccessJSON(map[string]interface{}{
  9537. "msg": "查询成功",
  9538. })
  9539. }
  9540. }
  9541. func (c *HisApiController) Get4208() {
  9542. admin_user_id, _ := c.GetInt64("admin_user_id")
  9543. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9544. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9545. order_id, _ := c.GetInt64("order_id")
  9546. order, _ := service.GetHisOrderByIDTwo(order_id)
  9547. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9548. var struct4208 models.Struct4208
  9549. struct4208.PageNum = "1"
  9550. struct4208.PageSize = "1000"
  9551. struct4208.PsnCertType = "01"
  9552. struct4208.Certno = his.Certno
  9553. struct4208.MedType = order.MedType
  9554. struct4208.PsnName = his.Name
  9555. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9556. saveLog(result, requestLog, "4208", "查询")
  9557. var res2 ResultSix
  9558. var respJSON2 map[string]interface{}
  9559. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9562. return
  9563. }
  9564. userJSONBytes2, _ := json.Marshal(respJSON2)
  9565. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9566. utils.ErrorLog("解析失败:%v", err)
  9567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9568. return
  9569. }
  9570. if res2.Infcode != 0 {
  9571. c.ServeSuccessJSON(map[string]interface{}{
  9572. "failed_code": -10,
  9573. "msg": res2.ErrMsg,
  9574. })
  9575. return
  9576. } else {
  9577. c.ServeSuccessJSON(map[string]interface{}{
  9578. "msg": "查询成功",
  9579. })
  9580. }
  9581. }
  9582. func (c *HisApiController) Get4209() {
  9583. admin_user_id, _ := c.GetInt64("admin_user_id")
  9584. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9585. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9586. order_id, _ := c.GetInt64("order_id")
  9587. order, _ := service.GetHisOrderByIDTwo(order_id)
  9588. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9589. var struct4209 models.Struct4209
  9590. struct4209.FixmedinsMdtrtID = order.Number
  9591. struct4209.FixmedinsCode = miConfig.Code
  9592. struct4209.PageSize = "1000"
  9593. struct4209.PageNum = "1"
  9594. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9595. saveLog(result, requestLog, "4209", "查询")
  9596. var res2 ResultSix
  9597. var respJSON2 map[string]interface{}
  9598. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9601. return
  9602. }
  9603. userJSONBytes2, _ := json.Marshal(respJSON2)
  9604. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9605. utils.ErrorLog("解析失败:%v", err)
  9606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9607. return
  9608. }
  9609. if res2.Infcode != 0 {
  9610. c.ServeSuccessJSON(map[string]interface{}{
  9611. "failed_code": -10,
  9612. "msg": res2.ErrMsg,
  9613. })
  9614. return
  9615. } else {
  9616. c.ServeSuccessJSON(map[string]interface{}{
  9617. "msg": "查询成功",
  9618. })
  9619. }
  9620. }
  9621. type Result3101 struct {
  9622. Infcode string `json:"infcode"`
  9623. InfRefmsgid string `json:"inf_refmsgid"`
  9624. RefmsgTime string `json:"refmsg_time"`
  9625. RespondTime string `json:"respond_time"`
  9626. Enctype string `json:"enctype"`
  9627. Signtype string `json:"signtype"`
  9628. ErrMsg string `json:"err_msg"`
  9629. Output struct {
  9630. Result []struct {
  9631. JudgeResultDetailDtos []struct {
  9632. VolaItemType string `json:"vola_item_type"`
  9633. MdtrtID string `json:"mdtrt_id"`
  9634. JrdID string `json:"jrd_id"`
  9635. PatnID string `json:"patn_id"`
  9636. RxID string `json:"rx_id"`
  9637. VolaAmt interface{} `json:"vola_amt"`
  9638. } `json:"judge_result_detail_dtos"`
  9639. RuleID string `json:"rule_id"`
  9640. VolaEvid string `json:"vola_evid"`
  9641. MdtrtID string `json:"mdtrt_id"`
  9642. RuleName string `json:"rule_name"`
  9643. VolaAmtStas string `json:"vola_amt_stas"`
  9644. JrID string `json:"jr_id"`
  9645. PatnID string `json:"patn_id"`
  9646. SevDeg string `json:"sev_deg"`
  9647. VolaAmt float64 `json:"vola_amt"`
  9648. VolaBhvrType string `json:"vola_bhvr_type"`
  9649. VolaCont string `json:"vola_cont"`
  9650. } `json:"result"`
  9651. } `json:"output"`
  9652. }
  9653. type Resultgd3101 struct {
  9654. Infcode int64 `json:"infcode"`
  9655. InfRefmsgid string `json:"inf_refmsgid"`
  9656. RefmsgTime string `json:"refmsg_time"`
  9657. RespondTime string `json:"respond_time"`
  9658. Enctype string `json:"enctype"`
  9659. Signtype string `json:"signtype"`
  9660. ErrMsg string `json:"err_msg"`
  9661. Output struct {
  9662. Result []struct {
  9663. JudgeResultDetailDtos []struct {
  9664. VolaItemType string `json:"vola_item_type"`
  9665. MdtrtID string `json:"mdtrt_id"`
  9666. JrdID string `json:"jrd_id"`
  9667. PatnID string `json:"patn_id"`
  9668. RxID string `json:"rx_id"`
  9669. VolaAmt interface{} `json:"vola_amt"`
  9670. } `json:"judge_result_detail_dtos"`
  9671. RuleID string `json:"rule_id"`
  9672. VolaEvid string `json:"vola_evid"`
  9673. MdtrtID string `json:"mdtrt_id"`
  9674. RuleName string `json:"rule_name"`
  9675. VolaAmtStas string `json:"vola_amt_stas"`
  9676. JrID string `json:"jr_id"`
  9677. PatnID string `json:"patn_id"`
  9678. SevDeg string `json:"sev_deg"`
  9679. VolaAmt float64 `json:"vola_amt"`
  9680. VolaBhvrType string `json:"vola_bhvr_type"`
  9681. VolaCont string `json:"vola_cont"`
  9682. } `json:"result"`
  9683. } `json:"output"`
  9684. }
  9685. func (c *HisApiController) ReadEleToken() {
  9686. admin_user_id, _ := c.GetInt64("admin_user_id")
  9687. his_patient_id, _ := c.GetInt64("his_patient_id")
  9688. adminUser := c.GetAdminUserInfo()
  9689. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9690. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9691. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9692. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9693. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9694. if len(tokens) > 0 {
  9695. c.ServeSuccessJSON(map[string]interface{}{
  9696. "msg": "读取成功",
  9697. })
  9698. } else {
  9699. c.ServeSuccessJSON(map[string]interface{}{
  9700. "failed_code": -10,
  9701. "msg": "读取失败",
  9702. })
  9703. }
  9704. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9705. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9706. if len(tokens) > 0 {
  9707. c.ServeSuccessJSON(map[string]interface{}{
  9708. "msg": "读取成功",
  9709. })
  9710. } else {
  9711. c.ServeSuccessJSON(map[string]interface{}{
  9712. "failed_code": -10,
  9713. "msg": "读取失败",
  9714. })
  9715. }
  9716. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9717. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9718. if len(tokens) > 0 {
  9719. c.ServeSuccessJSON(map[string]interface{}{
  9720. "msg": "读取成功",
  9721. })
  9722. } else {
  9723. c.ServeSuccessJSON(map[string]interface{}{
  9724. "failed_code": -10,
  9725. "msg": "读取失败",
  9726. })
  9727. }
  9728. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9729. var api string
  9730. 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 +
  9731. "&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"
  9732. resp, requestErr := http.Get(api)
  9733. if requestErr != nil {
  9734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9735. }
  9736. body, ioErr := ioutil.ReadAll(resp.Body)
  9737. if ioErr != nil {
  9738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9740. }
  9741. var respJSON map[string]interface{}
  9742. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9745. return
  9746. }
  9747. var status string
  9748. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9749. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9750. var token string
  9751. var res ResultTwo //1101结果
  9752. var res10265 ResultTwo10265 //1101结果
  9753. if status == "0" { //读卡成功
  9754. var card_info string //卡信息
  9755. var busi_card_info string
  9756. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9757. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9758. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9759. fmt.Println(card_info)
  9760. fmt.Println(busi_card_info)
  9761. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9762. result, _ := json.Marshal(respJSON)
  9763. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9764. utils.ErrorLog("解析失败:%v", err)
  9765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9766. return
  9767. }
  9768. res.ErrMsg = res10265.ErrMsg
  9769. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9770. res.Infcode = infocode
  9771. res.Output = res10265.Output
  9772. res.InfRefmsgid = res10265.InfRefmsgid
  9773. if res.Infcode == 0 {
  9774. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9775. if err == gorm.ErrRecordNotFound {
  9776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9777. return
  9778. } else if err != nil {
  9779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9780. return
  9781. } else {
  9782. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9783. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9784. infoStr := string(Iinfos)
  9785. idetinfoStr := string(Idetinfos)
  9786. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9787. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9788. psn := &models.HisPsn{
  9789. PsnNo: res.Output.Baseinfo.PsnNo,
  9790. PatientId: patient.ID,
  9791. Certno: res.Output.Baseinfo.Certno,
  9792. Gend: res.Output.Baseinfo.Gend,
  9793. Naty: res.Output.Baseinfo.Naty,
  9794. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9795. PsnName: res.Output.Baseinfo.PsnName,
  9796. Age: float64(age),
  9797. Brdy: b,
  9798. Idetinfo: idetinfoStr,
  9799. Insuinfo: infoStr,
  9800. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9801. CardInfo: card_info,
  9802. VerifyNumber: token,
  9803. IdCardType: 4,
  9804. }
  9805. var rf []*ResultFive
  9806. json.Unmarshal([]byte(infoStr), &rf)
  9807. var insutypes []*ResultFive
  9808. var insutype string
  9809. var is390 int = 0
  9810. var is310 int = 0
  9811. for _, item := range rf {
  9812. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9813. insutypes = append(insutypes, item)
  9814. }
  9815. }
  9816. if len(insutypes) == 1 {
  9817. insutype = insutypes[0].Insutype
  9818. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9819. } else {
  9820. for _, i := range insutypes {
  9821. if i.Insutype == "390" {
  9822. is390 = 1
  9823. }
  9824. if i.Insutype == "310" {
  9825. is310 = 1
  9826. }
  9827. }
  9828. }
  9829. if is390 == 1 {
  9830. insutype = "390"
  9831. }
  9832. if is310 == 1 {
  9833. insutype = "310"
  9834. }
  9835. if len(insutypes) == 0 {
  9836. insutype = "310"
  9837. }
  9838. service.CreateHisPsn(psn)
  9839. c.ServeSuccessJSON(map[string]interface{}{
  9840. "patient": patient,
  9841. "number": token,
  9842. "insutype": insutype,
  9843. })
  9844. }
  9845. } else {
  9846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9847. return
  9848. }
  9849. } else { //读卡失败
  9850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9851. return
  9852. }
  9853. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9854. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9855. if len(errMsg) == 0 {
  9856. type ELeData struct {
  9857. Data struct {
  9858. IdNo string `json:"idNo"`
  9859. IdType string `json:"idType"`
  9860. UserName string `json:"userName"`
  9861. EcToken string `json:"ecToken"`
  9862. InsuOrg string `json:"insuOrg"`
  9863. Gender string `json:"gender"`
  9864. Birthday string `json:"birthday"`
  9865. Nationality string `json:"nationality"`
  9866. Email string `json:"email"`
  9867. Extra string `json:"extra"`
  9868. } `json:"data"`
  9869. Code int `json:"code"`
  9870. Message string `json:"message"`
  9871. }
  9872. var ele ELeData
  9873. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9874. if err != nil {
  9875. utils.ErrorLog("解析失败:%v", err)
  9876. }
  9877. token := ele.Data.EcToken
  9878. if len(token) > 0 {
  9879. psn := &models.HisPsn{
  9880. PsnNo: his.PsnNo,
  9881. Age: 0,
  9882. PatientId: his.PatientId,
  9883. Certno: his.Certno,
  9884. Brdy: his.Brdy,
  9885. Gend: his.Gend,
  9886. Naty: his.Naty,
  9887. PsnCertType: his.PsnCertType,
  9888. PsnName: his.PsnName,
  9889. Idetinfo: his.Idetinfo,
  9890. Insuinfo: his.Iinfo,
  9891. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9892. CardInfo: outPutInfo,
  9893. VerifyNumber: token,
  9894. }
  9895. service.CreateHisPsn(psn)
  9896. }
  9897. if len(token) > 0 {
  9898. c.ServeSuccessJSON(map[string]interface{}{
  9899. "msg": "读取成功",
  9900. })
  9901. } else {
  9902. c.ServeSuccessJSON(map[string]interface{}{
  9903. "failed_code": -10,
  9904. "msg": "读取失败",
  9905. })
  9906. }
  9907. }
  9908. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9909. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9910. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9911. type ELeData struct {
  9912. Data struct {
  9913. IdNo string `json:"idNo"`
  9914. IdType string `json:"idType"`
  9915. UserName string `json:"userName"`
  9916. EcToken string `json:"ecToken"`
  9917. InsuOrg string `json:"insuOrg"`
  9918. Gender string `json:"gender"`
  9919. Birthday string `json:"birthday"`
  9920. Nationality string `json:"nationality"`
  9921. Email string `json:"email"`
  9922. Extra string `json:"extra"`
  9923. } `json:"data"`
  9924. Code int `json:"code"`
  9925. Message string `json:"message"`
  9926. }
  9927. var ele ELeData
  9928. err := json.Unmarshal([]byte(result), &ele)
  9929. if err != nil {
  9930. utils.ErrorLog("解析失败:%v", err)
  9931. }
  9932. token := ele.Data.EcToken
  9933. token = Remove0000(token)
  9934. fmt.Println(ele.Data.UserName)
  9935. 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)
  9936. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9937. var res ResultTwo
  9938. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9939. utils.ErrorLog("解析失败:%v", err)
  9940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9941. return
  9942. }
  9943. if res.Infcode == 0 {
  9944. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9945. if err == gorm.ErrRecordNotFound {
  9946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9947. return
  9948. } else if err != nil {
  9949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9950. return
  9951. } else {
  9952. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9953. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9954. infoStr := string(Iinfos)
  9955. idetinfoStr := string(Idetinfos)
  9956. psn := &models.HisPsn{
  9957. PsnNo: res.Output.Baseinfo.PsnNo,
  9958. PatientId: patient.ID,
  9959. Certno: res.Output.Baseinfo.Certno,
  9960. Gend: res.Output.Baseinfo.Gend,
  9961. Naty: res.Output.Baseinfo.Naty,
  9962. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9963. PsnName: res.Output.Baseinfo.PsnName,
  9964. Idetinfo: idetinfoStr,
  9965. Insuinfo: infoStr,
  9966. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9967. CardInfo: "",
  9968. VerifyNumber: token,
  9969. }
  9970. service.CreateHisPsn(psn)
  9971. c.ServeSuccessJSON(map[string]interface{}{
  9972. "patient": patient,
  9973. "number": token,
  9974. })
  9975. }
  9976. } else {
  9977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9978. return
  9979. }
  9980. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9981. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9982. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9983. type ELeData struct {
  9984. Data struct {
  9985. IdNo string `json:"idNo"`
  9986. IdType string `json:"idType"`
  9987. UserName string `json:"userName"`
  9988. EcToken string `json:"ecToken"`
  9989. InsuOrg string `json:"insuOrg"`
  9990. Gender string `json:"gender"`
  9991. Birthday string `json:"birthday"`
  9992. Nationality string `json:"nationality"`
  9993. Email string `json:"email"`
  9994. Extra string `json:"extra"`
  9995. } `json:"data"`
  9996. Code int `json:"code"`
  9997. Message string `json:"message"`
  9998. }
  9999. var ele ELeData
  10000. err := json.Unmarshal([]byte(result), &ele)
  10001. if err != nil {
  10002. utils.ErrorLog("解析失败:%v", err)
  10003. }
  10004. token := ele.Data.EcToken
  10005. token = Remove0000(token)
  10006. fmt.Println(ele.Data.UserName)
  10007. 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)
  10008. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10009. var res ResultTwo
  10010. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10011. utils.ErrorLog("解析失败:%v", err)
  10012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10013. return
  10014. }
  10015. if res.Infcode == 0 {
  10016. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10017. if err == gorm.ErrRecordNotFound {
  10018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10019. return
  10020. } else if err != nil {
  10021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10022. return
  10023. } else {
  10024. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10025. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10026. infoStr := string(Iinfos)
  10027. idetinfoStr := string(Idetinfos)
  10028. psn := &models.HisPsn{
  10029. PsnNo: res.Output.Baseinfo.PsnNo,
  10030. PatientId: patient.ID,
  10031. Certno: res.Output.Baseinfo.Certno,
  10032. Gend: res.Output.Baseinfo.Gend,
  10033. Naty: res.Output.Baseinfo.Naty,
  10034. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10035. PsnName: res.Output.Baseinfo.PsnName,
  10036. Idetinfo: idetinfoStr,
  10037. Insuinfo: infoStr,
  10038. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10039. CardInfo: "",
  10040. VerifyNumber: token,
  10041. }
  10042. service.CreateHisPsn(psn)
  10043. c.ServeSuccessJSON(map[string]interface{}{
  10044. "patient": patient,
  10045. "number": token,
  10046. })
  10047. }
  10048. } else {
  10049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10050. return
  10051. }
  10052. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10053. //if initFlag == 0 {
  10054. //c.TestGetJiangXiBasBaseInit()
  10055. //}
  10056. //if initEleFlag == 0 {
  10057. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10058. //}
  10059. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10060. utils.ErrorLog("解析失败:%v", json_result)
  10061. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10062. type ELeData struct {
  10063. Data struct {
  10064. IdNo string `json:"idNo"`
  10065. IdType string `json:"idType"`
  10066. UserName string `json:"userName"`
  10067. EcToken string `json:"ecToken"`
  10068. InsuOrg string `json:"insuOrg"`
  10069. Gender string `json:"gender"`
  10070. Birthday string `json:"birthday"`
  10071. Nationality string `json:"nationality"`
  10072. Email string `json:"email"`
  10073. Extra string `json:"extra"`
  10074. } `json:"data"`
  10075. Code int `json:"code"`
  10076. Message string `json:"message"`
  10077. }
  10078. var ele ELeData
  10079. err := json.Unmarshal([]byte(json_result), &ele)
  10080. if err != nil {
  10081. utils.ErrorLog("解析失败:%v", err)
  10082. }
  10083. token := ele.Data.EcToken
  10084. token = Remove0000(token)
  10085. //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)
  10086. 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)
  10087. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10088. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10089. var res ResultTwo
  10090. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10091. utils.ErrorLog("解析失败:%v", err)
  10092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10093. return
  10094. }
  10095. if res.Infcode == 0 {
  10096. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10097. if err == gorm.ErrRecordNotFound {
  10098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10099. return
  10100. } else if err != nil {
  10101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10102. return
  10103. } else {
  10104. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10105. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10106. infoStr := string(Iinfos)
  10107. idetinfoStr := string(Idetinfos)
  10108. psn := &models.HisPsn{
  10109. PsnNo: res.Output.Baseinfo.PsnNo,
  10110. PatientId: patient.ID,
  10111. Certno: res.Output.Baseinfo.Certno,
  10112. Gend: res.Output.Baseinfo.Gend,
  10113. Naty: res.Output.Baseinfo.Naty,
  10114. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10115. PsnName: res.Output.Baseinfo.PsnName,
  10116. Idetinfo: idetinfoStr,
  10117. Insuinfo: infoStr,
  10118. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10119. CardInfo: "",
  10120. VerifyNumber: token,
  10121. InsuplcAdmdvs: ele.Data.InsuOrg,
  10122. }
  10123. service.CreateHisPsn(psn)
  10124. c.ServeSuccessJSON(map[string]interface{}{
  10125. "patient": patient,
  10126. "number": token,
  10127. })
  10128. }
  10129. } else {
  10130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10131. return
  10132. }
  10133. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10134. res := c.GetoleInfo()
  10135. if res.Infcode == 0 {
  10136. var result string
  10137. if res.Output.MdtrtCertType == "01" {
  10138. 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)
  10139. } else if res.Output.MdtrtCertType == "02" {
  10140. 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)
  10141. } else if res.Output.MdtrtCertType == "03" {
  10142. 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)
  10143. }
  10144. var dat map[string]interface{}
  10145. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10146. fmt.Println(dat)
  10147. } else {
  10148. fmt.Println(err)
  10149. }
  10150. userJSONBytes, _ := json.Marshal(dat)
  10151. var res2 ResultTwo
  10152. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10153. utils.ErrorLog("解析失败:%v", err)
  10154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10155. return
  10156. }
  10157. if res2.Infcode == 0 {
  10158. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10159. if err == gorm.ErrRecordNotFound {
  10160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10161. return
  10162. } else if err != nil {
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10164. return
  10165. } else {
  10166. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10167. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10168. infoStr := string(Iinfos)
  10169. idetinfoStr := string(Idetinfos)
  10170. var rf []*ResultFive
  10171. json.Unmarshal([]byte(infoStr), &rf)
  10172. var insutypes []*ResultFive
  10173. var insutype string
  10174. var is390 int = 0
  10175. var is310 int = 0
  10176. //var insuplc_admdvs string
  10177. for _, item := range rf {
  10178. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10179. insutypes = append(insutypes, item)
  10180. }
  10181. }
  10182. if len(insutypes) == 1 {
  10183. insutype = insutypes[0].Insutype
  10184. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10185. } else {
  10186. for _, i := range insutypes {
  10187. if i.Insutype == "390" {
  10188. is390 = 1
  10189. }
  10190. if i.Insutype == "310" {
  10191. is310 = 1
  10192. }
  10193. }
  10194. }
  10195. if is390 == 1 {
  10196. insutype = "390"
  10197. }
  10198. if is310 == 1 {
  10199. insutype = "310"
  10200. }
  10201. if len(insutypes) == 0 {
  10202. insutype = "310"
  10203. }
  10204. psn := &models.HisPsn{
  10205. PsnNo: res2.Output.Baseinfo.PsnNo,
  10206. PatientId: patient.ID,
  10207. Certno: res2.Output.Baseinfo.Certno,
  10208. Gend: res2.Output.Baseinfo.Gend,
  10209. Naty: res2.Output.Baseinfo.Naty,
  10210. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10211. PsnName: res2.Output.Baseinfo.PsnName,
  10212. Idetinfo: idetinfoStr,
  10213. Insuinfo: infoStr,
  10214. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10215. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10216. VerifyNumber: res.Output.EcToken,
  10217. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10218. }
  10219. service.CreateHisPsn(psn)
  10220. c.ServeSuccessJSON(map[string]interface{}{
  10221. "patient": patient,
  10222. "number": res.Output.CardNo,
  10223. "insutype": insutype,
  10224. })
  10225. }
  10226. } else {
  10227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10228. return
  10229. }
  10230. } else {
  10231. c.ServeSuccessJSON(map[string]interface{}{
  10232. "failed_code": -10,
  10233. "msg": res.ErrMsg,
  10234. })
  10235. }
  10236. } else {
  10237. //if initFlag == 0 {
  10238. // c.TestGetBasBaseInit()
  10239. //}
  10240. //token := c.GetEleBaseInfo()
  10241. //token = Remove0000(token)
  10242. type ELeData struct {
  10243. Code string `json:"code"`
  10244. Data struct {
  10245. Aac002 string `json:"aac002"`
  10246. Aaz500 string `json:"aaz500"`
  10247. ActCardNo string `json:"actCardNo"`
  10248. Bab520 string `json:"bab520"`
  10249. Bkz543 string `json:"bkz543"`
  10250. BusinessType string `json:"businessType"`
  10251. CertfCodg string `json:"certfCodg"`
  10252. EcIndexNo string `json:"ecIndexNo"`
  10253. EcToken string `json:"ecToken"`
  10254. ID0000 string `json:"id0000"`
  10255. IDNo string `json:"idNo"`
  10256. IDType string `json:"idType"`
  10257. Idcode string `json:"idcode"`
  10258. IdentityToken string `json:"identity_token"`
  10259. InsuOrg string `json:"insuOrg"`
  10260. OfficeID string `json:"officeId"`
  10261. OfficeName string `json:"officeName"`
  10262. OperatorID string `json:"operatorId"`
  10263. OperatorName string `json:"operatorName"`
  10264. OrgID string `json:"orgId"`
  10265. UserName string `json:"userName"`
  10266. } `json:"data"`
  10267. Infno interface{} `json:"infno"`
  10268. Message string `json:"message"`
  10269. OrgID string `json:"orgId"`
  10270. TransType string `json:"transType"`
  10271. }
  10272. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10273. fmt.Println(result)
  10274. outPutInfo := Remove0000(result)
  10275. fmt.Println(outPutInfo)
  10276. var ele ELeData
  10277. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10278. if err != nil {
  10279. utils.ErrorLog("解析失败:%v", err)
  10280. }
  10281. token := ele.Data.EcToken
  10282. var result2 string
  10283. var requestLog2 string
  10284. if len(token) > 0 {
  10285. if strings.Contains(ele.Data.IDNo, "HKG") {
  10286. 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)
  10287. } else {
  10288. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10289. }
  10290. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10291. var res ResultTwo
  10292. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10293. utils.ErrorLog("解析失败:%v", err)
  10294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10295. return
  10296. }
  10297. if res.Infcode == 0 {
  10298. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10299. if err == gorm.ErrRecordNotFound {
  10300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10301. return
  10302. } else if err != nil {
  10303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10304. return
  10305. } else {
  10306. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10307. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10308. infoStr := string(Iinfos)
  10309. idetinfoStr := string(Idetinfos)
  10310. psn := &models.HisPsn{
  10311. PsnNo: res.Output.Baseinfo.PsnNo,
  10312. PatientId: patient.ID,
  10313. Certno: res.Output.Baseinfo.Certno,
  10314. Gend: res.Output.Baseinfo.Gend,
  10315. Naty: res.Output.Baseinfo.Naty,
  10316. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10317. PsnName: res.Output.Baseinfo.PsnName,
  10318. Idetinfo: idetinfoStr,
  10319. Insuinfo: infoStr,
  10320. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10321. CardInfo: "",
  10322. VerifyNumber: token,
  10323. }
  10324. service.CreateHisPsn(psn)
  10325. c.ServeSuccessJSON(map[string]interface{}{
  10326. "msg": "读取成功",
  10327. })
  10328. }
  10329. } else {
  10330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10331. return
  10332. }
  10333. } else {
  10334. c.ServeSuccessJSON(map[string]interface{}{
  10335. "failed_code": -10,
  10336. "msg": "读取失败",
  10337. })
  10338. }
  10339. }
  10340. }
  10341. func (c *HisApiController) ReadEleFace() {
  10342. admin_user_id, _ := c.GetInt64("admin_user_id")
  10343. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10344. adminUser := c.GetAdminUserInfo()
  10345. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10346. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10347. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10348. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10349. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10350. if len(tokens) > 0 {
  10351. c.ServeSuccessJSON(map[string]interface{}{
  10352. "msg": "读取成功",
  10353. })
  10354. } else {
  10355. c.ServeSuccessJSON(map[string]interface{}{
  10356. "failed_code": -10,
  10357. "msg": "读取失败",
  10358. })
  10359. }
  10360. }
  10361. }
  10362. func (c *HisApiController) Get9001() {
  10363. adminUser := c.GetAdminUserInfo()
  10364. admin_user_id, _ := c.GetInt64("admin_user_id")
  10365. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10366. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10367. if miConfig.MdtrtareaAdmvs == "350500" {
  10368. service.GetFjAuthorizationInfo(miConfig.Code)
  10369. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10370. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10371. var dat map[string]interface{}
  10372. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10373. fmt.Println(dat)
  10374. } else {
  10375. fmt.Println(err)
  10376. }
  10377. userJSONBytes, _ := json.Marshal(dat)
  10378. var res models.Result9001
  10379. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10380. utils.ErrorLog("解析失败:%v", err)
  10381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10382. return
  10383. }
  10384. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10385. fmt.Println(miConfig.SecretKey)
  10386. var res models.Result9001Two
  10387. 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 +
  10388. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10389. resp, requestErr := http.Get(api)
  10390. if requestErr != nil {
  10391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10392. return
  10393. }
  10394. body, ioErr := ioutil.ReadAll(resp.Body)
  10395. if ioErr != nil {
  10396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10398. return
  10399. }
  10400. var respJSON map[string]interface{}
  10401. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10404. return
  10405. }
  10406. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10407. if status == "0" {
  10408. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10409. c.ServeSuccessJSON(map[string]interface{}{
  10410. "failed_code": -10,
  10411. "msg": err_msg,
  10412. })
  10413. return
  10414. }
  10415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10416. result, _ := json.Marshal(respJSON)
  10417. fmt.Println("log")
  10418. fmt.Println(string(result))
  10419. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10420. utils.ErrorLog("解析失败:%v", err)
  10421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10422. return
  10423. }
  10424. if res.Infcode == 0 {
  10425. sign := models.HisSignIn{
  10426. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10427. SignNo: res.Output.Signinoutb.SignNo,
  10428. SignTime: "",
  10429. Ctime: time.Now().Unix(),
  10430. Mtime: time.Now().Unix(),
  10431. Status: 1,
  10432. InputLog: "",
  10433. OutputLog: "",
  10434. FixmedinsCode: miConfig.Code,
  10435. }
  10436. err := service.CreateSignIn(&sign)
  10437. if err == nil {
  10438. c.ServeSuccessJSON(map[string]interface{}{
  10439. "msg": "签到成功",
  10440. })
  10441. }
  10442. } else {
  10443. c.ServeSuccessJSON(map[string]interface{}{
  10444. "failed_code": -10,
  10445. "msg": res.ErrMsg,
  10446. })
  10447. return
  10448. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10449. //return
  10450. }
  10451. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10452. fmt.Println(miConfig.SecretKey)
  10453. var res models.Result9001Two
  10454. 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 +
  10455. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10456. resp, requestErr := http.Get(api)
  10457. if requestErr != nil {
  10458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10459. return
  10460. }
  10461. body, ioErr := ioutil.ReadAll(resp.Body)
  10462. if ioErr != nil {
  10463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10465. return
  10466. }
  10467. var respJSON map[string]interface{}
  10468. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10471. return
  10472. }
  10473. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10474. if status == "0" {
  10475. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10476. c.ServeSuccessJSON(map[string]interface{}{
  10477. "failed_code": -10,
  10478. "msg": err_msg,
  10479. })
  10480. return
  10481. }
  10482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10483. result, _ := json.Marshal(respJSON)
  10484. fmt.Println("log")
  10485. fmt.Println(string(result))
  10486. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10487. utils.ErrorLog("解析失败:%v", err)
  10488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10489. return
  10490. }
  10491. if res.Infcode == 0 {
  10492. sign := models.HisSignIn{
  10493. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10494. SignNo: res.Output.Signinoutb.SignNo,
  10495. SignTime: "",
  10496. Ctime: time.Now().Unix(),
  10497. Mtime: time.Now().Unix(),
  10498. Status: 1,
  10499. InputLog: "",
  10500. OutputLog: "",
  10501. FixmedinsCode: miConfig.Code,
  10502. }
  10503. err := service.CreateSignIn(&sign)
  10504. if err == nil {
  10505. c.ServeSuccessJSON(map[string]interface{}{
  10506. "msg": "签到成功",
  10507. })
  10508. }
  10509. } else {
  10510. c.ServeSuccessJSON(map[string]interface{}{
  10511. "failed_code": -10,
  10512. "msg": res.ErrMsg,
  10513. })
  10514. return
  10515. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10516. //return
  10517. }
  10518. } else {
  10519. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10520. var dat map[string]interface{}
  10521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10522. fmt.Println(dat)
  10523. } else {
  10524. fmt.Println(err)
  10525. }
  10526. userJSONBytes, _ := json.Marshal(dat)
  10527. var res models.Result9001
  10528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10529. utils.ErrorLog("解析失败:%v", err)
  10530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10531. return
  10532. }
  10533. if res.Infcode == 0 {
  10534. sign := models.HisSignIn{
  10535. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10536. SignNo: res.Output.Signinoutb.SignNo,
  10537. SignTime: res.Output.Signinoutb.SignTime,
  10538. Ctime: time.Now().Unix(),
  10539. Mtime: time.Now().Unix(),
  10540. Status: 1,
  10541. InputLog: "",
  10542. OutputLog: "",
  10543. FixmedinsCode: miConfig.Code,
  10544. }
  10545. err := service.CreateSignIn(&sign)
  10546. if err == nil {
  10547. c.ServeSuccessJSON(map[string]interface{}{
  10548. "msg": "签到成功",
  10549. })
  10550. }
  10551. }
  10552. }
  10553. }
  10554. 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) {
  10555. var res Result3101
  10556. adminUser := c.GetAdminUserInfo()
  10557. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10558. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10559. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10560. //record_time := c.GetString("record_time")
  10561. //trig_scen := c.GetString("trig_scen")
  10562. timeLayout := "2006-01-02"
  10563. loc, _ := time.LoadLocation("Local")
  10564. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10565. if err != nil {
  10566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10567. return res
  10568. }
  10569. recordDateTime := theTime.Unix()
  10570. var patientPrescription models.HisPrescriptionInfo
  10571. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10572. //if patientPrescription.ID == 0 {
  10573. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10574. //}
  10575. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10576. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10577. //
  10578. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10579. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10580. var pp models.PublicParams
  10581. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10582. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10583. pp.FixmedinsName = miConfig.OrgName
  10584. pp.FixmedinsCode = miConfig.Code
  10585. pp.RequestUrl = miConfig.Url
  10586. pp.Cainfo = miConfig.Cainfo
  10587. pp.SecretKey = miConfig.SecretKey
  10588. pp.AccessKey = miConfig.AccessKey
  10589. pp.OpterName = roles.UserName
  10590. var config []*models.HisXtDiagnoseConfig
  10591. for _, item := range diagnosis_ids {
  10592. id, _ := strconv.ParseInt(item, 10, 64)
  10593. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10594. config = append(config, &diagnosisConfig)
  10595. }
  10596. var pd models.PatientDtos
  10597. pd.PatnID = his.PsnNo
  10598. pd.PatnName = his.Name
  10599. pd.Gend = his.Gend
  10600. pd.Brdy = his.Brdy
  10601. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10602. pd.CurrMdtrtID = his.Number
  10603. var fed models.FsiEncounterDtos
  10604. fed.MdtrtID = his.Number
  10605. fed.MedinsID = miConfig.Code
  10606. fed.MedinsName = miConfig.OrgName
  10607. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10608. fed.MedMdtrtType = "1"
  10609. fed.MedinsType = "1"
  10610. fed.MedinsLv = "11"
  10611. tm := time.Unix(his.RecordDate, 0)
  10612. s_tm := tm.Format("2006-01-02 15:04:05")
  10613. fed.AdmDate = s_tm
  10614. fed.DscgDate = s_tm
  10615. fed.DscgMainDiseCodg = config[0].CountryCode
  10616. fed.DscgMainDiseName = config[0].CountryContentName
  10617. //诊断信息
  10618. var fdds []*models.FsiDiagnoseDtos
  10619. for index, item := range config {
  10620. if index == 0 {
  10621. var fdd models.FsiDiagnoseDtos
  10622. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10623. fdd.InoutDiseType = "1"
  10624. fdd.MaindiseFlag = "1"
  10625. fdd.DiseDate = s_tm
  10626. fdd.DiasSrtNo = "1"
  10627. fdd.DiseName = item.CountryContentName
  10628. fdd.DiseCodg = item.CountryCode
  10629. fdds = append(fdds, &fdd)
  10630. } else {
  10631. var fdd models.FsiDiagnoseDtos
  10632. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10633. fdd.InoutDiseType = "1"
  10634. fdd.MaindiseFlag = "1"
  10635. fdd.DiseDate = s_tm
  10636. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10637. fdd.DiseName = item.CountryContentName
  10638. fdd.DiseCodg = item.CountryCode
  10639. fdds = append(fdds, &fdd)
  10640. }
  10641. }
  10642. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10643. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10644. fed.AdmDeptName = de.Name
  10645. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10646. fed.DscgDeptName = de.Name
  10647. fed.MedMdtrtType = "1"
  10648. fed.MedType = "11"
  10649. //if his.Insutype == "390" {
  10650. // fed.MedType = "1402"
  10651. //} else {
  10652. // fed.MedType = "9933"
  10653. //}
  10654. var orders []*models.FsiOrderDtos
  10655. if trig_scen == "2" {
  10656. //处方医嘱信息
  10657. for _, item := range prescriptions {
  10658. for _, subItem := range item.HisDoctorAdviceInfo {
  10659. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10660. var order models.FsiOrderDtos
  10661. order.RxID = strconv.FormatInt(item.ID, 10)
  10662. order.Rxno = strconv.FormatInt(item.ID, 10)
  10663. order.LongDrordFlag = "0"
  10664. order.HilistType = "1"
  10665. order.ChrgType = "1"
  10666. order.DrordBhvr = "-"
  10667. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10668. order.HosplistName = subItem.BaseDrugLib.DrugName
  10669. order.HilistLv = "1"
  10670. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10671. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10672. order.HosplistName = subItem.BaseDrugLib.DrugName
  10673. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10674. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10675. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10676. order.OwnpayAmt = ""
  10677. order.SelfpayAmt = ""
  10678. order.Spec = ""
  10679. order.SpecUnt = ""
  10680. order.DrordBegnDate = s_tm
  10681. order.DrordStopDate = ""
  10682. order.DrordDrCodg = doctor_info.DoctorNumber
  10683. order.DrordDeptName = department.Name
  10684. order.DrordDeptCodg = department.Number
  10685. order.DrordDrName = doctor_info.UserName
  10686. order.DrordDrProfttl = "234"
  10687. order.CurrDrordFlag = "1"
  10688. orders = append(orders, &order)
  10689. }
  10690. }
  10691. for _, subItem := range item.HisPrescriptionProject {
  10692. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10693. var order models.FsiOrderDtos
  10694. order.RxID = strconv.FormatInt(item.ID, 10)
  10695. order.Rxno = strconv.FormatInt(item.ID, 10)
  10696. order.LongDrordFlag = "0"
  10697. order.HilistType = "1"
  10698. order.ChrgType = "1"
  10699. order.DrordBhvr = "-"
  10700. order.HilistCode = subItem.HisProject.MedicalCode
  10701. order.HosplistName = subItem.HisProject.ProjectName
  10702. order.HilistLv = "1"
  10703. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10704. order.HosplistCode = subItem.HisProject.MedicalCode
  10705. order.HosplistName = subItem.HisProject.ProjectName
  10706. order.Cnt = subItem.Count
  10707. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10708. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10709. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10710. order.OwnpayAmt = ""
  10711. order.SelfpayAmt = ""
  10712. order.Spec = ""
  10713. order.SpecUnt = ""
  10714. order.DrordBegnDate = s_tm
  10715. order.DrordStopDate = ""
  10716. order.DrordDrCodg = doctor_info.DoctorNumber
  10717. order.DrordDeptName = department.Name
  10718. order.DrordDeptCodg = department.Number
  10719. order.DrordDrName = doctor_info.UserName
  10720. order.DrordDrProfttl = "234"
  10721. order.CurrDrordFlag = "1"
  10722. orders = append(orders, &order)
  10723. }
  10724. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10725. var order models.FsiOrderDtos
  10726. order.RxID = strconv.FormatInt(item.ID, 10)
  10727. order.Rxno = strconv.FormatInt(item.ID, 10)
  10728. order.LongDrordFlag = "0"
  10729. order.HilistType = "1"
  10730. order.ChrgType = "1"
  10731. order.DrordBhvr = "-"
  10732. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10733. order.HosplistName = subItem.GoodInfo.GoodName
  10734. order.HilistLv = "1"
  10735. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10736. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10737. order.HosplistName = subItem.GoodInfo.GoodName
  10738. order.Cnt = subItem.Count
  10739. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10740. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10741. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10742. order.OwnpayAmt = ""
  10743. order.SelfpayAmt = ""
  10744. order.Spec = ""
  10745. order.SpecUnt = ""
  10746. order.DrordBegnDate = s_tm
  10747. order.DrordStopDate = ""
  10748. order.DrordDrCodg = doctor_info.DoctorNumber
  10749. order.DrordDeptName = department.Name
  10750. order.DrordDeptCodg = department.Number
  10751. order.DrordDrName = doctor_info.UserName
  10752. order.DrordDrProfttl = "234"
  10753. order.CurrDrordFlag = "1"
  10754. orders = append(orders, &order)
  10755. }
  10756. }
  10757. }
  10758. //处方医嘱信息
  10759. }
  10760. fed.MatnStas = "0"
  10761. fed.MedfeeSumamt = "0"
  10762. fed.OwnpayAmt = "0"
  10763. fed.SelfpayAmt = "0"
  10764. fed.AcctPayamt = "0"
  10765. fed.MaAmt = "0"
  10766. fed.HifpPayamt = "0"
  10767. fed.SetlTotlnum = "1"
  10768. fed.Insutype = his.Insutype
  10769. fed.ReimFlag = "0"
  10770. fed.OutSetlFlag = "0"
  10771. var fopd []*models.FsiOperationDtosData
  10772. data := make(map[string]interface{})
  10773. data["fed"] = fed
  10774. data["fdd"] = fdds
  10775. data["fod"] = orders
  10776. data["pd"] = pd
  10777. data["pp"] = pp
  10778. data["fopd"] = fopd
  10779. data["trig_scen"] = trig_scen
  10780. fmt.Println(data)
  10781. fmt.Println(fed)
  10782. fmt.Println(fdds)
  10783. fmt.Println(orders)
  10784. fmt.Println(pd)
  10785. fmt.Println(pp)
  10786. fmt.Println(fopd)
  10787. client := &http.Client{}
  10788. bytesData, _ := json.Marshal(data)
  10789. var req *http.Request
  10790. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10791. if miConfig.MdtrtareaAdmvs == "320921" {
  10792. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10793. } else {
  10794. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10795. }
  10796. resp, _ := client.Do(req)
  10797. defer resp.Body.Close()
  10798. body, ioErr := ioutil.ReadAll(resp.Body)
  10799. if ioErr != nil {
  10800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10802. return res
  10803. }
  10804. var respJSON map[string]interface{}
  10805. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10808. return res
  10809. }
  10810. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10811. fmt.Println(respJSON)
  10812. result, _ := json.Marshal(respJSON)
  10813. fmt.Println(result)
  10814. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10815. utils.ErrorLog("解析失败:%v", err)
  10816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10817. return res
  10818. }
  10819. return res
  10820. } else {
  10821. //if miConfig.MdtrtareaAdmvs == "441202" {
  10822. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10823. saveLog(output, input, "3101", "事前")
  10824. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10825. utils.ErrorLog("解析失败:%v", err)
  10826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10827. return
  10828. }
  10829. return res
  10830. //}
  10831. }
  10832. }
  10833. 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) {
  10834. adminUser := c.GetAdminUserInfo()
  10835. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10836. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10837. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10838. //record_time := c.GetString("record_time")
  10839. //trig_scen := c.GetString("trig_scen")
  10840. timeLayout := "2006-01-02"
  10841. loc, _ := time.LoadLocation("Local")
  10842. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10843. if err != nil {
  10844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10845. return res
  10846. }
  10847. recordDateTime := theTime.Unix()
  10848. var patientPrescription models.HisPrescriptionInfo
  10849. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10850. if patientPrescription.ID == 0 {
  10851. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10852. }
  10853. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10854. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10855. //
  10856. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10857. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10858. var pp models.PublicParams
  10859. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10860. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10861. pp.FixmedinsName = miConfig.OrgName
  10862. pp.FixmedinsCode = miConfig.Code
  10863. pp.RequestUrl = miConfig.Url
  10864. pp.Cainfo = miConfig.Cainfo
  10865. pp.SecretKey = miConfig.SecretKey
  10866. pp.AccessKey = miConfig.AccessKey
  10867. pp.OpterName = roles.UserName
  10868. var config []*models.HisXtDiagnoseConfig
  10869. for _, item := range diagnosis_ids {
  10870. id, _ := strconv.ParseInt(item, 10, 64)
  10871. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10872. config = append(config, &diagnosisConfig)
  10873. }
  10874. var pd models.PatientDtos
  10875. pd.PatnID = his.PsnNo
  10876. pd.PatnName = his.Name
  10877. pd.Gend = his.Gend
  10878. pd.Brdy = his.Brdy
  10879. pd.Poolarea = his.InsuplcAdmdvs
  10880. pd.CurrMdtrtID = his.Number
  10881. var fed models.FsiEncounterDtos
  10882. fed.MdtrtID = his.Number
  10883. fed.MedinsID = miConfig.Code
  10884. fed.MedinsName = miConfig.OrgName
  10885. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10886. fed.MedMdtrtType = "1"
  10887. fed.MedinsType = "1"
  10888. fed.MedinsLv = "11"
  10889. tm := time.Unix(his.RecordDate, 0)
  10890. s_tm := tm.Format("2006-01-02 15:04:05")
  10891. fed.AdmDate = s_tm
  10892. fed.DscgDate = s_tm
  10893. fed.DscgMainDiseCodg = config[0].CountryCode
  10894. fed.DscgMainDiseName = config[0].CountryContentName
  10895. //诊断信息
  10896. var fdds []*models.FsiDiagnoseDtos
  10897. for index, item := range config {
  10898. if index == 0 {
  10899. var fdd models.FsiDiagnoseDtos
  10900. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10901. fdd.InoutDiseType = "1"
  10902. fdd.MaindiseFlag = "1"
  10903. fdd.DiseDate = s_tm
  10904. fdd.DiasSrtNo = "1"
  10905. fdd.DiseName = item.CountryContentName
  10906. fdd.DiseCodg = item.CountryCode
  10907. fdds = append(fdds, &fdd)
  10908. } else {
  10909. var fdd models.FsiDiagnoseDtos
  10910. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10911. fdd.InoutDiseType = "1"
  10912. fdd.MaindiseFlag = "1"
  10913. fdd.DiseDate = s_tm
  10914. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10915. fdd.DiseName = item.CountryContentName
  10916. fdd.DiseCodg = item.CountryCode
  10917. fdds = append(fdds, &fdd)
  10918. }
  10919. }
  10920. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10921. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10922. fed.AdmDeptName = department.Name
  10923. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10924. fed.DscgDeptName = department.Name
  10925. fed.MedMdtrtType = "1"
  10926. fed.MedType = "11"
  10927. //if his.Insutype == "390" {
  10928. // fed.MedType = "1402"
  10929. //} else {
  10930. // fed.MedType = "9933"
  10931. //}
  10932. var orders []*models.FsiOrderDtos
  10933. if trig_scen == "2" {
  10934. //处方医嘱信息
  10935. for _, item := range prescriptions {
  10936. for _, subItem := range item.HisDoctorAdviceInfo {
  10937. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10938. var order models.FsiOrderDtos
  10939. order.RxID = strconv.FormatInt(item.ID, 10)
  10940. order.Rxno = strconv.FormatInt(item.ID, 10)
  10941. order.LongDrordFlag = "0"
  10942. order.HilistType = "1"
  10943. order.ChrgType = "1"
  10944. order.DrordBhvr = "-"
  10945. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10946. order.HosplistName = subItem.BaseDrugLib.DrugName
  10947. order.HilistLv = "1"
  10948. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10949. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10950. order.HosplistName = subItem.BaseDrugLib.DrugName
  10951. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10952. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10953. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10954. order.OwnpayAmt = ""
  10955. order.SelfpayAmt = ""
  10956. order.Spec = ""
  10957. order.SpecUnt = ""
  10958. order.DrordBegnDate = s_tm
  10959. order.DrordStopDate = ""
  10960. order.DrordDrCodg = doctor_info.DoctorNumber
  10961. order.DrordDeptName = department.Name
  10962. order.DrordDeptCodg = department.Number
  10963. order.DrordDrName = doctor_info.UserName
  10964. order.DrordDrProfttl = "234"
  10965. order.CurrDrordFlag = "1"
  10966. orders = append(orders, &order)
  10967. }
  10968. }
  10969. for _, subItem := range item.HisPrescriptionProject {
  10970. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10971. var order models.FsiOrderDtos
  10972. order.RxID = strconv.FormatInt(item.ID, 10)
  10973. order.Rxno = strconv.FormatInt(item.ID, 10)
  10974. order.LongDrordFlag = "0"
  10975. order.HilistType = "1"
  10976. order.ChrgType = "1"
  10977. order.DrordBhvr = "-"
  10978. order.HilistCode = subItem.HisProject.MedicalCode
  10979. order.HosplistName = subItem.HisProject.ProjectName
  10980. order.HilistLv = "1"
  10981. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10982. order.HosplistCode = subItem.HisProject.MedicalCode
  10983. order.HosplistName = subItem.HisProject.ProjectName
  10984. order.Cnt = subItem.Count
  10985. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10986. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10987. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10988. order.OwnpayAmt = ""
  10989. order.SelfpayAmt = ""
  10990. order.Spec = ""
  10991. order.SpecUnt = ""
  10992. order.DrordBegnDate = s_tm
  10993. order.DrordStopDate = ""
  10994. order.DrordDrCodg = doctor_info.DoctorNumber
  10995. order.DrordDeptName = department.Name
  10996. order.DrordDeptCodg = department.Number
  10997. order.DrordDrName = doctor_info.UserName
  10998. order.DrordDrProfttl = "234"
  10999. order.CurrDrordFlag = "1"
  11000. orders = append(orders, &order)
  11001. }
  11002. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11003. var order models.FsiOrderDtos
  11004. order.RxID = strconv.FormatInt(item.ID, 10)
  11005. order.Rxno = strconv.FormatInt(item.ID, 10)
  11006. order.LongDrordFlag = "0"
  11007. order.HilistType = "1"
  11008. order.ChrgType = "1"
  11009. order.DrordBhvr = "-"
  11010. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11011. order.HosplistName = subItem.GoodInfo.GoodName
  11012. order.HilistLv = "1"
  11013. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11014. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11015. order.HosplistName = subItem.GoodInfo.GoodName
  11016. order.Cnt = subItem.Count
  11017. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11018. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11019. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11020. order.OwnpayAmt = ""
  11021. order.SelfpayAmt = ""
  11022. order.Spec = ""
  11023. order.SpecUnt = ""
  11024. order.DrordBegnDate = s_tm
  11025. order.DrordStopDate = ""
  11026. order.DrordDrCodg = doctor_info.DoctorNumber
  11027. order.DrordDeptName = department.Name
  11028. order.DrordDeptCodg = department.Number
  11029. order.DrordDrName = doctor_info.UserName
  11030. order.DrordDrProfttl = "234"
  11031. order.CurrDrordFlag = "1"
  11032. orders = append(orders, &order)
  11033. }
  11034. }
  11035. }
  11036. //处方医嘱信息
  11037. }
  11038. fed.MatnStas = "0"
  11039. fed.MedfeeSumamt = "0"
  11040. fed.OwnpayAmt = "0"
  11041. fed.SelfpayAmt = "0"
  11042. fed.AcctPayamt = "0"
  11043. fed.MaAmt = "0"
  11044. fed.HifpPayamt = "0"
  11045. fed.SetlTotlnum = "1"
  11046. fed.Insutype = his.Insutype
  11047. fed.ReimFlag = "0"
  11048. fed.OutSetlFlag = "0"
  11049. var fopd []*models.FsiOperationDtosData
  11050. data := make(map[string]interface{})
  11051. data["fed"] = fed
  11052. data["fdd"] = fdds
  11053. data["fod"] = orders
  11054. data["pd"] = pd
  11055. data["pp"] = pp
  11056. data["fopd"] = fopd
  11057. data["trig_scen"] = trig_scen
  11058. fmt.Println(data)
  11059. fmt.Println(fed)
  11060. fmt.Println(fdds)
  11061. fmt.Println(orders)
  11062. fmt.Println(pd)
  11063. fmt.Println(pp)
  11064. fmt.Println(fopd)
  11065. client := &http.Client{}
  11066. bytesData, _ := json.Marshal(data)
  11067. var req *http.Request
  11068. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11069. if miConfig.MdtrtareaAdmvs == "320921" {
  11070. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11071. } else {
  11072. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11073. }
  11074. resp, _ := client.Do(req)
  11075. defer resp.Body.Close()
  11076. body, ioErr := ioutil.ReadAll(resp.Body)
  11077. if ioErr != nil {
  11078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11080. return res
  11081. }
  11082. var respJSON map[string]interface{}
  11083. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11086. return res
  11087. }
  11088. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11089. fmt.Println(respJSON)
  11090. result, _ := json.Marshal(respJSON)
  11091. fmt.Println(result)
  11092. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11093. utils.ErrorLog("解析失败:%v", err)
  11094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11095. return res
  11096. }
  11097. return res
  11098. } else {
  11099. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11100. saveLog(output, input, "3101", "事前")
  11101. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11102. utils.ErrorLog("解析失败:%v", err)
  11103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11104. return
  11105. }
  11106. return res
  11107. }
  11108. return res
  11109. }
  11110. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11111. ////patient_id, _ := c.GetInt64("patient_id")
  11112. //order_id, _ := c.GetInt64("order_id")
  11113. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11114. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11115. //trig_scen := c.GetString("trig_scen")
  11116. adminUser := c.GetAdminUserInfo()
  11117. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11118. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11119. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11120. record_time := c.GetString("record_time")
  11121. order, _ := service.GetHisOrderByID(order_id)
  11122. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11123. timeLayout := "2006-01-02"
  11124. loc, _ := time.LoadLocation("Local")
  11125. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11126. if err != nil {
  11127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11128. return
  11129. }
  11130. recordDateTime := theTime.Unix()
  11131. var patientPrescription models.HisPrescriptionInfo
  11132. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11133. if patientPrescription.ID == 0 {
  11134. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11135. }
  11136. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11137. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11138. //
  11139. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11140. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11141. var pp models.PublicParams
  11142. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11143. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11144. pp.FixmedinsName = miConfig.OrgName
  11145. pp.FixmedinsCode = miConfig.Code
  11146. pp.RequestUrl = miConfig.Url
  11147. pp.Cainfo = miConfig.Cainfo
  11148. pp.SecretKey = miConfig.SecretKey
  11149. pp.AccessKey = miConfig.AccessKey
  11150. pp.OpterName = roles.UserName
  11151. var config []*models.HisXtDiagnoseConfig
  11152. for _, item := range diagnosis_ids {
  11153. id, _ := strconv.ParseInt(item, 10, 64)
  11154. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11155. config = append(config, &diagnosisConfig)
  11156. }
  11157. var pd models.PatientDtos
  11158. pd.PatnID = his.PsnNo
  11159. pd.PatnName = his.Name
  11160. pd.Gend = his.Gend
  11161. pd.Brdy = psn_info.Brdy
  11162. pd.Poolarea = his.InsuplcAdmdvs
  11163. pd.CurrMdtrtID = his.Number
  11164. var fed models.FsiEncounterDtos
  11165. fed.MdtrtID = his.Number
  11166. fed.MedinsID = miConfig.Code
  11167. fed.MedinsName = miConfig.OrgName
  11168. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11169. fed.MedMdtrtType = "1"
  11170. fed.MedinsType = "1"
  11171. fed.MedinsLv = "11"
  11172. tm := time.Unix(his.RecordDate, 0)
  11173. s_tm := tm.Format("2006-01-02 15:04:05")
  11174. fed.AdmDate = s_tm
  11175. fed.DscgDate = s_tm
  11176. fed.DscgMainDiseCodg = config[0].CountryCode
  11177. fed.DscgMainDiseName = config[0].CountryContentName
  11178. //诊断信息
  11179. var fdds []*models.FsiDiagnoseDtos
  11180. for index, item := range config {
  11181. if index == 0 {
  11182. var fdd models.FsiDiagnoseDtos
  11183. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11184. fdd.InoutDiseType = "1"
  11185. fdd.MaindiseFlag = "1"
  11186. fdd.DiseDate = s_tm
  11187. fdd.DiasSrtNo = "1"
  11188. fdd.DiseName = item.CountryContentName
  11189. fdd.DiseCodg = item.CountryCode
  11190. fdds = append(fdds, &fdd)
  11191. } else {
  11192. var fdd models.FsiDiagnoseDtos
  11193. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11194. fdd.InoutDiseType = "1"
  11195. fdd.MaindiseFlag = "1"
  11196. fdd.DiseDate = s_tm
  11197. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11198. fdd.DiseName = item.CountryContentName
  11199. fdd.DiseCodg = item.CountryCode
  11200. fdds = append(fdds, &fdd)
  11201. }
  11202. }
  11203. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11204. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11205. fed.AdmDeptName = department.Name
  11206. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11207. fed.DscgDeptName = department.Name
  11208. fed.MedType = order.MedType
  11209. //处方医嘱信息
  11210. var orders []*models.FsiOrderDtos
  11211. //for _, item := range prescriptions {
  11212. // for _, subItem := range item.HisDoctorAdviceInfo {
  11213. // var order models.FsiOrderDtos
  11214. // order.RxID = strconv.FormatInt(item.ID, 10)
  11215. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11216. // order.LongDrordFlag = "0"
  11217. // order.HilistType = "1"
  11218. // order.ChrgType = "1"
  11219. // order.DrordBhvr = "-"
  11220. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11221. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11222. // order.HilistLv = "1"
  11223. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11224. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11225. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11226. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11227. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11228. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11229. // order.OwnpayAmt = ""
  11230. // order.SelfpayAmt = ""
  11231. // order.Spec = ""
  11232. // order.SpecUnt = ""
  11233. // order.DrordBegnDate = s_tm
  11234. // order.DrordStopDate = ""
  11235. // order.DrordDrCodg = "1"
  11236. // order.DrordDeptName = department.Name
  11237. // order.DrordDrCodg = "1"
  11238. // order.DrordDrName = doctor_info.UserName
  11239. // order.DrordDrProfttl = ""
  11240. // order.CurrDrordFlag = "1"
  11241. // orders = append(orders, &order)
  11242. // }
  11243. // for _, subItem := range item.HisPrescriptionProject {
  11244. // if subItem.Type == 2 {
  11245. // var order models.FsiOrderDtos
  11246. // order.RxID = strconv.FormatInt(item.ID, 10)
  11247. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11248. // order.LongDrordFlag = "0"
  11249. // order.HilistType = "1"
  11250. // order.ChrgType = "1"
  11251. // order.DrordBhvr = "-"
  11252. // order.HilistCode = subItem.HisProject.MedicalCode
  11253. // order.HosplistName = subItem.HisProject.ProjectName
  11254. // order.HilistLv = "1"
  11255. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11256. // order.HosplistCode = subItem.HisProject.MedicalCode
  11257. // order.HosplistName = subItem.HisProject.ProjectName
  11258. // order.Cnt = subItem.Count
  11259. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11260. //
  11261. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11262. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11263. // order.OwnpayAmt = ""
  11264. // order.SelfpayAmt = ""
  11265. // order.Spec = ""
  11266. // order.SpecUnt = ""
  11267. // order.DrordBegnDate = s_tm
  11268. // order.DrordStopDate = ""
  11269. // order.DrordDrCodg = "1"
  11270. // order.DrordDeptName = department.Name
  11271. // order.DrordDrCodg = "1"
  11272. // order.DrordDrName = doctor_info.UserName
  11273. // order.DrordDrProfttl = ""
  11274. // order.CurrDrordFlag = "1"
  11275. // orders = append(orders, &order)
  11276. //
  11277. // }
  11278. // if subItem.Type == 3 {
  11279. //
  11280. // var order models.FsiOrderDtos
  11281. // order.RxID = strconv.FormatInt(item.ID, 10)
  11282. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11283. // order.LongDrordFlag = "0"
  11284. // order.HilistType = "1"
  11285. // order.ChrgType = "1"
  11286. // order.DrordBhvr = "-"
  11287. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11288. // order.HosplistName = subItem.GoodInfo.GoodName
  11289. // order.HilistLv = "1"
  11290. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11291. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11292. // order.HosplistName = subItem.GoodInfo.GoodName
  11293. // order.Cnt = subItem.Count
  11294. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11295. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11296. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11297. // order.OwnpayAmt = ""
  11298. // order.SelfpayAmt = ""
  11299. // order.Spec = ""
  11300. // order.SpecUnt = ""
  11301. // order.DrordBegnDate = s_tm
  11302. // order.DrordStopDate = ""
  11303. // order.DrordDrCodg = "1"
  11304. // order.DrordDeptName = department.Name
  11305. // order.DrordDrCodg = "1"
  11306. // order.DrordDrName = doctor_info.UserName
  11307. // order.DrordDrProfttl = ""
  11308. // order.CurrDrordFlag = "1"
  11309. // orders = append(orders, &order)
  11310. //
  11311. // }
  11312. // }
  11313. //}
  11314. for _, item := range prescriptions {
  11315. for _, subItem := range item.HisDoctorAdviceInfo {
  11316. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11317. var order models.FsiOrderDtos
  11318. order.RxID = strconv.FormatInt(item.ID, 10)
  11319. order.Rxno = strconv.FormatInt(item.ID, 10)
  11320. order.LongDrordFlag = "0"
  11321. order.HilistType = "1"
  11322. order.ChrgType = "1"
  11323. order.DrordBhvr = "-"
  11324. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11325. order.HosplistName = subItem.BaseDrugLib.DrugName
  11326. order.HilistLv = "1"
  11327. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11328. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11329. order.HosplistName = subItem.BaseDrugLib.DrugName
  11330. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11331. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11332. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11333. order.OwnpayAmt = ""
  11334. order.SelfpayAmt = ""
  11335. order.Spec = ""
  11336. order.SpecUnt = ""
  11337. order.DrordBegnDate = s_tm
  11338. order.DrordStopDate = ""
  11339. order.DrordDrCodg = doctor_info.DoctorNumber
  11340. order.DrordDeptName = department.Name
  11341. order.DrordDeptCodg = department.Number
  11342. order.DrordDrName = doctor_info.UserName
  11343. order.DrordDrProfttl = "234"
  11344. order.CurrDrordFlag = "1"
  11345. orders = append(orders, &order)
  11346. }
  11347. }
  11348. for _, subItem := range item.HisPrescriptionProject {
  11349. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11350. var order models.FsiOrderDtos
  11351. order.RxID = strconv.FormatInt(item.ID, 10)
  11352. order.Rxno = strconv.FormatInt(item.ID, 10)
  11353. order.LongDrordFlag = "0"
  11354. order.HilistType = "1"
  11355. order.ChrgType = "1"
  11356. order.DrordBhvr = "-"
  11357. order.HilistCode = subItem.HisProject.MedicalCode
  11358. order.HosplistName = subItem.HisProject.ProjectName
  11359. order.HilistLv = "1"
  11360. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11361. order.HosplistCode = subItem.HisProject.MedicalCode
  11362. order.HosplistName = subItem.HisProject.ProjectName
  11363. order.Cnt = subItem.Count
  11364. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11365. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11366. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11367. order.OwnpayAmt = ""
  11368. order.SelfpayAmt = ""
  11369. order.Spec = ""
  11370. order.SpecUnt = ""
  11371. order.DrordBegnDate = s_tm
  11372. order.DrordStopDate = ""
  11373. order.DrordDrCodg = doctor_info.DoctorNumber
  11374. order.DrordDeptName = department.Name
  11375. order.DrordDeptCodg = department.Number
  11376. order.DrordDrName = doctor_info.UserName
  11377. order.DrordDrProfttl = "234"
  11378. order.CurrDrordFlag = "1"
  11379. orders = append(orders, &order)
  11380. }
  11381. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11382. var order models.FsiOrderDtos
  11383. order.RxID = strconv.FormatInt(item.ID, 10)
  11384. order.Rxno = strconv.FormatInt(item.ID, 10)
  11385. order.LongDrordFlag = "0"
  11386. order.HilistType = "1"
  11387. order.ChrgType = "1"
  11388. order.DrordBhvr = "0"
  11389. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11390. order.HosplistName = subItem.GoodInfo.GoodName
  11391. order.HilistLv = "1"
  11392. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11393. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11394. order.HosplistName = subItem.GoodInfo.GoodName
  11395. order.Cnt = subItem.Count
  11396. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11397. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11398. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11399. order.OwnpayAmt = ""
  11400. order.SelfpayAmt = ""
  11401. order.Spec = ""
  11402. order.SpecUnt = ""
  11403. order.DrordBegnDate = s_tm
  11404. order.DrordStopDate = ""
  11405. order.DrordDrCodg = doctor_info.DoctorNumber
  11406. order.DrordDeptName = department.Name
  11407. order.DrordDeptCodg = department.Number
  11408. order.DrordDrName = doctor_info.UserName
  11409. order.DrordDrProfttl = "234"
  11410. order.CurrDrordFlag = "1"
  11411. orders = append(orders, &order)
  11412. }
  11413. }
  11414. }
  11415. //处方医嘱信息
  11416. fed.MatnStas = "0"
  11417. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11418. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11419. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11420. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11421. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11422. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11423. fed.SetlTotlnum = "1"
  11424. fed.Insutype = his.Insutype
  11425. fed.ReimFlag = "0"
  11426. fed.OutSetlFlag = "0"
  11427. var fopd []*models.FsiOperationDtosData
  11428. data := make(map[string]interface{})
  11429. data["fed"] = fed
  11430. data["fdd"] = fdds
  11431. data["fod"] = orders
  11432. data["pd"] = pd
  11433. data["pp"] = pp
  11434. data["fopd"] = fopd
  11435. data["trig_scen"] = trig_scen
  11436. client := &http.Client{}
  11437. bytesData, _ := json.Marshal(data)
  11438. var req *http.Request
  11439. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11440. if miConfig.MdtrtareaAdmvs == "320921" {
  11441. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11442. } else {
  11443. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11444. }
  11445. resp, _ := client.Do(req)
  11446. defer resp.Body.Close()
  11447. body, ioErr := ioutil.ReadAll(resp.Body)
  11448. if ioErr != nil {
  11449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11451. return res
  11452. }
  11453. var respJSON map[string]interface{}
  11454. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11457. return res
  11458. }
  11459. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11460. result, _ := json.Marshal(respJSON)
  11461. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11462. utils.ErrorLog("解析失败:%v", err)
  11463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11464. return res
  11465. }
  11466. return res
  11467. } else {
  11468. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11469. saveLog(output, input, "3102", "事中")
  11470. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11471. utils.ErrorLog("解析失败:%v", err)
  11472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11473. return
  11474. }
  11475. return res
  11476. }
  11477. return res
  11478. }
  11479. 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) {
  11480. var res Resultgd3101
  11481. adminUser := c.GetAdminUserInfo()
  11482. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11483. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11484. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11485. //record_time := c.GetString("record_time")
  11486. //trig_scen := c.GetString("trig_scen")
  11487. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11488. //psn_info, _ := service.GetPatientId(patient_id)
  11489. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11490. timeLayout := "2006-01-02"
  11491. loc, _ := time.LoadLocation("Local")
  11492. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11493. if err != nil {
  11494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11495. return res
  11496. }
  11497. recordDateTime := theTime.Unix()
  11498. var patientPrescription models.HisPrescriptionInfo
  11499. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11500. //if patientPrescription.ID == 0 {
  11501. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11502. //}
  11503. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11504. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11505. //
  11506. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11507. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11508. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11509. var pp models.PublicParams
  11510. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11511. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11512. pp.FixmedinsName = miConfig.OrgName
  11513. pp.FixmedinsCode = miConfig.Code
  11514. pp.RequestUrl = miConfig.Url
  11515. pp.Cainfo = miConfig.Cainfo
  11516. pp.SecretKey = miConfig.SecretKey
  11517. pp.AccessKey = miConfig.AccessKey
  11518. pp.OpterName = roles.UserName
  11519. var config []*models.HisXtDiagnoseConfig
  11520. for _, item := range diagnosis_ids {
  11521. id, _ := strconv.ParseInt(item, 10, 64)
  11522. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11523. config = append(config, &diagnosisConfig)
  11524. }
  11525. var pd models.PatientDtos
  11526. pd.PatnID = his.PsnNo
  11527. pd.PatnName = his.Name
  11528. pd.Gend = his.Gend
  11529. pd.Brdy = str
  11530. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11531. pd.CurrMdtrtID = his.Number
  11532. var fed models.FsiEncounterDtos
  11533. fed.MdtrtID = his.Number
  11534. fed.MedinsID = miConfig.Code
  11535. fed.MedinsName = miConfig.OrgName
  11536. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11537. fed.MedMdtrtType = "1"
  11538. fed.MedinsType = "1"
  11539. fed.MedinsLv = "11"
  11540. tm := time.Unix(his.RecordDate, 0)
  11541. s_tm := tm.Format("2006-01-02 15:04:05")
  11542. fed.AdmDate = s_tm
  11543. fed.DscgDate = s_tm
  11544. fed.DscgMainDiseCodg = config[0].CountryCode
  11545. fed.DscgMainDiseName = config[0].CountryContentName
  11546. //诊断信息
  11547. var fdds []*models.FsiDiagnoseDtos
  11548. for index, item := range config {
  11549. if index == 0 {
  11550. var fdd models.FsiDiagnoseDtos
  11551. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11552. fdd.InoutDiseType = "1"
  11553. fdd.MaindiseFlag = "1"
  11554. fdd.DiseDate = s_tm
  11555. fdd.DiasSrtNo = "1"
  11556. fdd.DiseName = item.CountryContentName
  11557. fdd.DiseCodg = item.CountryCode
  11558. fdds = append(fdds, &fdd)
  11559. } else {
  11560. var fdd models.FsiDiagnoseDtos
  11561. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11562. fdd.InoutDiseType = "1"
  11563. fdd.MaindiseFlag = "1"
  11564. fdd.DiseDate = s_tm
  11565. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11566. fdd.DiseName = item.CountryContentName
  11567. fdd.DiseCodg = item.CountryCode
  11568. fdds = append(fdds, &fdd)
  11569. }
  11570. }
  11571. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11572. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11573. fed.AdmDeptName = de.Name
  11574. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11575. fed.DscgDeptName = de.Name
  11576. fed.MedMdtrtType = "1"
  11577. fed.MedType = "11"
  11578. //if his.Insutype == "390" {
  11579. // fed.MedType = "1402"
  11580. //} else {
  11581. // fed.MedType = "9933"
  11582. //}
  11583. var orders []*models.FsiOrderDtos
  11584. if trig_scen == "2" {
  11585. //处方医嘱信息
  11586. for _, item := range prescriptions {
  11587. for _, subItem := range item.HisDoctorAdviceInfo {
  11588. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11589. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11590. var order models.FsiOrderDtos
  11591. order.RxID = strconv.FormatInt(item.ID, 10)
  11592. order.Rxno = strconv.FormatInt(item.ID, 10)
  11593. order.LongDrordFlag = "0"
  11594. order.HilistType = "1"
  11595. order.ChrgType = "1"
  11596. order.DrordBhvr = "0"
  11597. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11598. order.HosplistName = subItem.BaseDrugLib.DrugName
  11599. order.HilistLv = "1"
  11600. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11601. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11602. order.HosplistName = subItem.BaseDrugLib.DrugName
  11603. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11604. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11605. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11606. order.OwnpayAmt = ""
  11607. order.SelfpayAmt = ""
  11608. order.Spec = spec
  11609. order.SpecUnt = subItem.PrescribingNumberUnit
  11610. order.DrordBegnDate = s_tm
  11611. order.DrordStopDate = ""
  11612. order.DrordDrCodg = doctor_info.DoctorNumber
  11613. order.DrordDeptName = department.Name
  11614. order.DrordDeptCodg = department.Number
  11615. order.DrordDrName = doctor_info.UserName
  11616. order.DrordDrProfttl = "234"
  11617. order.CurrDrordFlag = "1"
  11618. orders = append(orders, &order)
  11619. }
  11620. }
  11621. for _, subItem := range item.HisPrescriptionProject {
  11622. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11623. var order models.FsiOrderDtos
  11624. order.RxID = strconv.FormatInt(item.ID, 10)
  11625. order.Rxno = strconv.FormatInt(item.ID, 10)
  11626. order.LongDrordFlag = "0"
  11627. order.HilistType = "1"
  11628. order.ChrgType = "1"
  11629. order.DrordBhvr = "0"
  11630. order.HilistCode = subItem.HisProject.MedicalCode
  11631. order.HosplistName = subItem.HisProject.ProjectName
  11632. order.HilistLv = "1"
  11633. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11634. order.HosplistCode = subItem.HisProject.MedicalCode
  11635. order.HosplistName = subItem.HisProject.ProjectName
  11636. order.Cnt = subItem.Count
  11637. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11638. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11639. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11640. order.OwnpayAmt = ""
  11641. order.SelfpayAmt = ""
  11642. order.Spec = subItem.Unit
  11643. order.SpecUnt = subItem.Unit
  11644. order.DrordBegnDate = s_tm
  11645. order.DrordStopDate = ""
  11646. order.DrordDrCodg = doctor_info.DoctorNumber
  11647. order.DrordDeptName = department.Name
  11648. order.DrordDeptCodg = department.Number
  11649. order.DrordDrName = doctor_info.UserName
  11650. order.DrordDrProfttl = "234"
  11651. order.CurrDrordFlag = "1"
  11652. orders = append(orders, &order)
  11653. }
  11654. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11655. var order models.FsiOrderDtos
  11656. order.RxID = strconv.FormatInt(item.ID, 10)
  11657. order.Rxno = strconv.FormatInt(item.ID, 10)
  11658. order.LongDrordFlag = "0"
  11659. order.HilistType = "1"
  11660. order.ChrgType = "1"
  11661. order.DrordBhvr = "0"
  11662. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11663. order.HosplistName = subItem.GoodInfo.GoodName
  11664. order.HilistLv = "1"
  11665. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11666. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11667. order.HosplistName = subItem.GoodInfo.GoodName
  11668. order.Cnt = subItem.Count
  11669. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11670. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11671. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11672. order.OwnpayAmt = ""
  11673. order.SelfpayAmt = ""
  11674. order.Spec = subItem.GoodInfo.SpecificationName
  11675. order.SpecUnt = subItem.Unit
  11676. order.DrordBegnDate = s_tm
  11677. order.DrordStopDate = ""
  11678. order.DrordDrCodg = doctor_info.DoctorNumber
  11679. order.DrordDeptName = department.Name
  11680. order.DrordDeptCodg = department.Number
  11681. order.DrordDrName = doctor_info.UserName
  11682. order.DrordDrProfttl = "234"
  11683. order.CurrDrordFlag = "1"
  11684. orders = append(orders, &order)
  11685. }
  11686. }
  11687. }
  11688. //处方医嘱信息
  11689. }
  11690. fed.MatnStas = "0"
  11691. fed.MedfeeSumamt = "0"
  11692. fed.OwnpayAmt = "0"
  11693. fed.SelfpayAmt = "0"
  11694. fed.AcctPayamt = "0"
  11695. fed.MaAmt = "0"
  11696. fed.HifpPayamt = "0"
  11697. fed.SetlTotlnum = "1"
  11698. fed.Insutype = his.Insutype
  11699. fed.ReimFlag = "0"
  11700. fed.OutSetlFlag = "0"
  11701. var fopd []*models.FsiOperationDtosData
  11702. data := make(map[string]interface{})
  11703. data["fed"] = fed
  11704. data["fdd"] = fdds
  11705. data["fod"] = orders
  11706. data["pd"] = pd
  11707. data["pp"] = pp
  11708. data["fopd"] = fopd
  11709. data["trig_scen"] = trig_scen
  11710. fmt.Println(data)
  11711. fmt.Println(fed)
  11712. fmt.Println(fdds)
  11713. fmt.Println(orders)
  11714. fmt.Println(pd)
  11715. fmt.Println(pp)
  11716. fmt.Println(fopd)
  11717. client := &http.Client{}
  11718. bytesData, _ := json.Marshal(data)
  11719. var req *http.Request
  11720. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11721. if miConfig.MdtrtareaAdmvs == "320921" {
  11722. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11723. } else {
  11724. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11725. }
  11726. resp, _ := client.Do(req)
  11727. defer resp.Body.Close()
  11728. body, ioErr := ioutil.ReadAll(resp.Body)
  11729. if ioErr != nil {
  11730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11732. return res
  11733. }
  11734. var respJSON map[string]interface{}
  11735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11738. return res
  11739. }
  11740. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11741. fmt.Println(respJSON)
  11742. result, _ := json.Marshal(respJSON)
  11743. fmt.Println(result)
  11744. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11745. utils.ErrorLog("解析失败:%v", err)
  11746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11747. return res
  11748. }
  11749. return res
  11750. } else {
  11751. //if miConfig.MdtrtareaAdmvs == "441202" {
  11752. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11753. saveLog(output, input, "3101", "事前")
  11754. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11755. utils.ErrorLog("解析失败:%v", err)
  11756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11757. return
  11758. }
  11759. return res
  11760. //}
  11761. }
  11762. }
  11763. 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) {
  11764. adminUser := c.GetAdminUserInfo()
  11765. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11766. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11767. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11768. //record_time := c.GetString("record_time")
  11769. //trig_scen := c.GetString("trig_scen")
  11770. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11771. timeLayout := "2006-01-02"
  11772. loc, _ := time.LoadLocation("Local")
  11773. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11774. if err != nil {
  11775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11776. return res
  11777. }
  11778. recordDateTime := theTime.Unix()
  11779. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11780. var patientPrescription models.HisPrescriptionInfo
  11781. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11782. if patientPrescription.ID == 0 {
  11783. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11784. }
  11785. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11786. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11787. //
  11788. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11789. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11790. var pp models.PublicParams
  11791. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11792. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11793. pp.FixmedinsName = miConfig.OrgName
  11794. pp.FixmedinsCode = miConfig.Code
  11795. pp.RequestUrl = miConfig.Url
  11796. pp.Cainfo = miConfig.Cainfo
  11797. pp.SecretKey = miConfig.SecretKey
  11798. pp.AccessKey = miConfig.AccessKey
  11799. pp.OpterName = roles.UserName
  11800. var config []*models.HisXtDiagnoseConfig
  11801. for _, item := range diagnosis_ids {
  11802. id, _ := strconv.ParseInt(item, 10, 64)
  11803. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11804. config = append(config, &diagnosisConfig)
  11805. }
  11806. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11807. var pd models.PatientDtos
  11808. pd.PatnID = his.PsnNo
  11809. pd.PatnName = his.Name
  11810. pd.Gend = his.Gend
  11811. pd.Brdy = str
  11812. pd.Poolarea = his.InsuplcAdmdvs
  11813. pd.CurrMdtrtID = his.Number
  11814. var fed models.FsiEncounterDtos
  11815. fed.MdtrtID = his.Number
  11816. fed.MedinsID = miConfig.Code
  11817. fed.MedinsName = miConfig.OrgName
  11818. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11819. fed.MedMdtrtType = "1"
  11820. fed.MedinsType = "1"
  11821. fed.MedinsLv = "11"
  11822. tm := time.Unix(his.RecordDate, 0)
  11823. s_tm := tm.Format("2006-01-02 15:04:05")
  11824. fed.AdmDate = s_tm
  11825. fed.DscgDate = s_tm
  11826. fed.DscgMainDiseCodg = config[0].CountryCode
  11827. fed.DscgMainDiseName = config[0].CountryContentName
  11828. //诊断信息
  11829. var fdds []*models.FsiDiagnoseDtos
  11830. for index, item := range config {
  11831. if index == 0 {
  11832. var fdd models.FsiDiagnoseDtos
  11833. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11834. fdd.InoutDiseType = "1"
  11835. fdd.MaindiseFlag = "1"
  11836. fdd.DiseDate = s_tm
  11837. fdd.DiasSrtNo = "1"
  11838. fdd.DiseName = item.CountryContentName
  11839. fdd.DiseCodg = item.CountryCode
  11840. fdds = append(fdds, &fdd)
  11841. } else {
  11842. var fdd models.FsiDiagnoseDtos
  11843. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11844. fdd.InoutDiseType = "1"
  11845. fdd.MaindiseFlag = "1"
  11846. fdd.DiseDate = s_tm
  11847. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11848. fdd.DiseName = item.CountryContentName
  11849. fdd.DiseCodg = item.CountryCode
  11850. fdds = append(fdds, &fdd)
  11851. }
  11852. }
  11853. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11854. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11855. fed.AdmDeptName = department.Name
  11856. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11857. fed.DscgDeptName = department.Name
  11858. fed.MedMdtrtType = "1"
  11859. fed.MedType = "11"
  11860. //if his.Insutype == "390" {
  11861. // fed.MedType = "1402"
  11862. //} else {
  11863. // fed.MedType = "9933"
  11864. //}
  11865. var orders []*models.FsiOrderDtos
  11866. if trig_scen == "2" {
  11867. //处方医嘱信息
  11868. for _, item := range prescriptions {
  11869. for _, subItem := range item.HisDoctorAdviceInfo {
  11870. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11871. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11872. var order models.FsiOrderDtos
  11873. order.RxID = strconv.FormatInt(item.ID, 10)
  11874. order.Rxno = strconv.FormatInt(item.ID, 10)
  11875. order.LongDrordFlag = "0"
  11876. order.HilistType = "1"
  11877. order.ChrgType = "1"
  11878. order.DrordBhvr = "0"
  11879. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11880. order.HosplistName = subItem.BaseDrugLib.DrugName
  11881. order.HilistLv = "1"
  11882. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11883. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11884. order.HosplistName = subItem.BaseDrugLib.DrugName
  11885. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11886. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11887. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11888. order.OwnpayAmt = ""
  11889. order.SelfpayAmt = ""
  11890. order.Spec = spec
  11891. order.SpecUnt = subItem.PrescribingNumberUnit
  11892. order.DrordBegnDate = s_tm
  11893. order.DrordStopDate = ""
  11894. order.DrordDrCodg = doctor_info.DoctorNumber
  11895. order.DrordDeptName = department.Name
  11896. order.DrordDeptCodg = department.Number
  11897. order.DrordDrName = doctor_info.UserName
  11898. order.DrordDrProfttl = "234"
  11899. order.CurrDrordFlag = "1"
  11900. orders = append(orders, &order)
  11901. }
  11902. }
  11903. for _, subItem := range item.HisPrescriptionProject {
  11904. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11905. var order models.FsiOrderDtos
  11906. order.RxID = strconv.FormatInt(item.ID, 10)
  11907. order.Rxno = strconv.FormatInt(item.ID, 10)
  11908. order.LongDrordFlag = "0"
  11909. order.HilistType = "1"
  11910. order.ChrgType = "1"
  11911. order.DrordBhvr = "0"
  11912. order.HilistCode = subItem.HisProject.MedicalCode
  11913. order.HosplistName = subItem.HisProject.ProjectName
  11914. order.HilistLv = "1"
  11915. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11916. order.HosplistCode = subItem.HisProject.MedicalCode
  11917. order.HosplistName = subItem.HisProject.ProjectName
  11918. order.Cnt = subItem.Count
  11919. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11920. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11921. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11922. order.OwnpayAmt = ""
  11923. order.SelfpayAmt = ""
  11924. order.Spec = subItem.Unit
  11925. order.SpecUnt = subItem.Unit
  11926. order.DrordBegnDate = s_tm
  11927. order.DrordStopDate = ""
  11928. order.DrordDrCodg = doctor_info.DoctorNumber
  11929. order.DrordDeptName = department.Name
  11930. order.DrordDeptCodg = department.Number
  11931. order.DrordDrName = doctor_info.UserName
  11932. order.DrordDrProfttl = "234"
  11933. order.CurrDrordFlag = "1"
  11934. orders = append(orders, &order)
  11935. }
  11936. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11937. var order models.FsiOrderDtos
  11938. order.RxID = strconv.FormatInt(item.ID, 10)
  11939. order.Rxno = strconv.FormatInt(item.ID, 10)
  11940. order.LongDrordFlag = "0"
  11941. order.HilistType = "1"
  11942. order.ChrgType = "1"
  11943. order.DrordBhvr = "0"
  11944. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11945. order.HosplistName = subItem.GoodInfo.GoodName
  11946. order.HilistLv = "1"
  11947. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11948. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11949. order.HosplistName = subItem.GoodInfo.GoodName
  11950. order.Cnt = subItem.Count
  11951. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11952. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11953. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11954. order.OwnpayAmt = ""
  11955. order.SelfpayAmt = ""
  11956. order.Spec = subItem.GoodInfo.SpecificationName
  11957. order.SpecUnt = subItem.Unit
  11958. order.DrordBegnDate = s_tm
  11959. order.DrordStopDate = ""
  11960. order.DrordDrCodg = doctor_info.DoctorNumber
  11961. order.DrordDeptName = department.Name
  11962. order.DrordDeptCodg = department.Number
  11963. order.DrordDrName = doctor_info.UserName
  11964. order.DrordDrProfttl = "234"
  11965. order.CurrDrordFlag = "1"
  11966. orders = append(orders, &order)
  11967. }
  11968. }
  11969. }
  11970. //处方医嘱信息
  11971. }
  11972. fed.MatnStas = "0"
  11973. fed.MedfeeSumamt = "0"
  11974. fed.OwnpayAmt = "0"
  11975. fed.SelfpayAmt = "0"
  11976. fed.AcctPayamt = "0"
  11977. fed.MaAmt = "0"
  11978. fed.HifpPayamt = "0"
  11979. fed.SetlTotlnum = "1"
  11980. fed.Insutype = his.Insutype
  11981. fed.ReimFlag = "0"
  11982. fed.OutSetlFlag = "0"
  11983. var fopd []*models.FsiOperationDtosData
  11984. data := make(map[string]interface{})
  11985. data["fed"] = fed
  11986. data["fdd"] = fdds
  11987. data["fod"] = orders
  11988. data["pd"] = pd
  11989. data["pp"] = pp
  11990. data["fopd"] = fopd
  11991. data["trig_scen"] = trig_scen
  11992. fmt.Println(data)
  11993. fmt.Println(fed)
  11994. fmt.Println(fdds)
  11995. fmt.Println(orders)
  11996. fmt.Println(pd)
  11997. fmt.Println(pp)
  11998. fmt.Println(fopd)
  11999. client := &http.Client{}
  12000. bytesData, _ := json.Marshal(data)
  12001. var req *http.Request
  12002. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12003. if miConfig.MdtrtareaAdmvs == "320921" {
  12004. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12005. } else {
  12006. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12007. }
  12008. resp, _ := client.Do(req)
  12009. defer resp.Body.Close()
  12010. body, ioErr := ioutil.ReadAll(resp.Body)
  12011. if ioErr != nil {
  12012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12014. return res
  12015. }
  12016. var respJSON map[string]interface{}
  12017. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12020. return res
  12021. }
  12022. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12023. fmt.Println(respJSON)
  12024. result, _ := json.Marshal(respJSON)
  12025. fmt.Println(result)
  12026. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12027. utils.ErrorLog("解析失败:%v", err)
  12028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12029. return res
  12030. }
  12031. return res
  12032. } else {
  12033. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12034. saveLog(output, input, "3101", "事前")
  12035. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12036. utils.ErrorLog("解析失败:%v", err)
  12037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12038. return
  12039. }
  12040. return res
  12041. }
  12042. return res
  12043. }
  12044. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12045. ////patient_id, _ := c.GetInt64("patient_id")
  12046. //order_id, _ := c.GetInt64("order_id")
  12047. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  12048. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  12049. //trig_scen := c.GetString("trig_scen")
  12050. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12051. //utils.ErrorLog("解析失败:%v", psn_info)
  12052. adminUser := c.GetAdminUserInfo()
  12053. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12054. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12055. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12056. record_time := c.GetString("record_time")
  12057. order, _ := service.GetHisOrderByID(order_id)
  12058. timeLayout := "2006-01-02"
  12059. loc, _ := time.LoadLocation("Local")
  12060. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12061. if err != nil {
  12062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12063. return
  12064. }
  12065. recordDateTime := theTime.Unix()
  12066. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12067. var patientPrescription models.HisPrescriptionInfo
  12068. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12069. if patientPrescription.ID == 0 {
  12070. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12071. }
  12072. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12073. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12074. //
  12075. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12076. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12077. var pp models.PublicParams
  12078. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12079. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12080. pp.FixmedinsName = miConfig.OrgName
  12081. pp.FixmedinsCode = miConfig.Code
  12082. pp.RequestUrl = miConfig.Url
  12083. pp.Cainfo = miConfig.Cainfo
  12084. pp.SecretKey = miConfig.SecretKey
  12085. pp.AccessKey = miConfig.AccessKey
  12086. pp.OpterName = roles.UserName
  12087. var config []*models.HisXtDiagnoseConfig
  12088. for _, item := range diagnosis_ids {
  12089. id, _ := strconv.ParseInt(item, 10, 64)
  12090. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12091. config = append(config, &diagnosisConfig)
  12092. }
  12093. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12094. var pd models.PatientDtos
  12095. pd.PatnID = his.PsnNo
  12096. pd.PatnName = his.Name
  12097. pd.Gend = his.Gend
  12098. pd.Brdy = str
  12099. pd.Poolarea = his.InsuplcAdmdvs
  12100. pd.CurrMdtrtID = his.Number
  12101. var fed models.FsiEncounterDtos
  12102. fed.MdtrtID = his.Number
  12103. fed.MedinsID = miConfig.Code
  12104. fed.MedinsName = miConfig.OrgName
  12105. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12106. fed.MedMdtrtType = "1"
  12107. fed.MedinsType = "1"
  12108. fed.MedinsLv = "11"
  12109. tm := time.Unix(his.RecordDate, 0)
  12110. s_tm := tm.Format("2006-01-02 15:04:05")
  12111. fed.AdmDate = s_tm
  12112. fed.DscgDate = s_tm
  12113. fed.DscgMainDiseCodg = config[0].CountryCode
  12114. fed.DscgMainDiseName = config[0].CountryContentName
  12115. //诊断信息
  12116. var fdds []*models.FsiDiagnoseDtos
  12117. for index, item := range config {
  12118. if index == 0 {
  12119. var fdd models.FsiDiagnoseDtos
  12120. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12121. fdd.InoutDiseType = "1"
  12122. fdd.MaindiseFlag = "1"
  12123. fdd.DiseDate = s_tm
  12124. fdd.DiasSrtNo = "1"
  12125. fdd.DiseName = item.CountryContentName
  12126. fdd.DiseCodg = item.CountryCode
  12127. fdds = append(fdds, &fdd)
  12128. } else {
  12129. var fdd models.FsiDiagnoseDtos
  12130. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12131. fdd.InoutDiseType = "1"
  12132. fdd.MaindiseFlag = "1"
  12133. fdd.DiseDate = s_tm
  12134. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12135. fdd.DiseName = item.CountryContentName
  12136. fdd.DiseCodg = item.CountryCode
  12137. fdds = append(fdds, &fdd)
  12138. }
  12139. }
  12140. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12141. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12142. fed.AdmDeptName = department.Name
  12143. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12144. fed.DscgDeptName = department.Name
  12145. fed.MedType = order.MedType
  12146. //处方医嘱信息
  12147. var orders []*models.FsiOrderDtos
  12148. //for _, item := range prescriptions {
  12149. // for _, subItem := range item.HisDoctorAdviceInfo {
  12150. // var order models.FsiOrderDtos
  12151. // order.RxID = strconv.FormatInt(item.ID, 10)
  12152. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12153. // order.LongDrordFlag = "0"
  12154. // order.HilistType = "1"
  12155. // order.ChrgType = "1"
  12156. // order.DrordBhvr = "-"
  12157. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12158. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12159. // order.HilistLv = "1"
  12160. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12161. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12162. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12163. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12164. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12165. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12166. // order.OwnpayAmt = ""
  12167. // order.SelfpayAmt = ""
  12168. // order.Spec = ""
  12169. // order.SpecUnt = ""
  12170. // order.DrordBegnDate = s_tm
  12171. // order.DrordStopDate = ""
  12172. // order.DrordDrCodg = "1"
  12173. // order.DrordDeptName = department.Name
  12174. // order.DrordDrCodg = "1"
  12175. // order.DrordDrName = doctor_info.UserName
  12176. // order.DrordDrProfttl = ""
  12177. // order.CurrDrordFlag = "1"
  12178. // orders = append(orders, &order)
  12179. // }
  12180. // for _, subItem := range item.HisPrescriptionProject {
  12181. // if subItem.Type == 2 {
  12182. // var order models.FsiOrderDtos
  12183. // order.RxID = strconv.FormatInt(item.ID, 10)
  12184. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12185. // order.LongDrordFlag = "0"
  12186. // order.HilistType = "1"
  12187. // order.ChrgType = "1"
  12188. // order.DrordBhvr = "-"
  12189. // order.HilistCode = subItem.HisProject.MedicalCode
  12190. // order.HosplistName = subItem.HisProject.ProjectName
  12191. // order.HilistLv = "1"
  12192. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12193. // order.HosplistCode = subItem.HisProject.MedicalCode
  12194. // order.HosplistName = subItem.HisProject.ProjectName
  12195. // order.Cnt = subItem.Count
  12196. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12197. //
  12198. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12199. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12200. // order.OwnpayAmt = ""
  12201. // order.SelfpayAmt = ""
  12202. // order.Spec = ""
  12203. // order.SpecUnt = ""
  12204. // order.DrordBegnDate = s_tm
  12205. // order.DrordStopDate = ""
  12206. // order.DrordDrCodg = "1"
  12207. // order.DrordDeptName = department.Name
  12208. // order.DrordDrCodg = "1"
  12209. // order.DrordDrName = doctor_info.UserName
  12210. // order.DrordDrProfttl = ""
  12211. // order.CurrDrordFlag = "1"
  12212. // orders = append(orders, &order)
  12213. //
  12214. // }
  12215. // if subItem.Type == 3 {
  12216. //
  12217. // var order models.FsiOrderDtos
  12218. // order.RxID = strconv.FormatInt(item.ID, 10)
  12219. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12220. // order.LongDrordFlag = "0"
  12221. // order.HilistType = "1"
  12222. // order.ChrgType = "1"
  12223. // order.DrordBhvr = "-"
  12224. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12225. // order.HosplistName = subItem.GoodInfo.GoodName
  12226. // order.HilistLv = "1"
  12227. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12228. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12229. // order.HosplistName = subItem.GoodInfo.GoodName
  12230. // order.Cnt = subItem.Count
  12231. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12232. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12233. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12234. // order.OwnpayAmt = ""
  12235. // order.SelfpayAmt = ""
  12236. // order.Spec = ""
  12237. // order.SpecUnt = ""
  12238. // order.DrordBegnDate = s_tm
  12239. // order.DrordStopDate = ""
  12240. // order.DrordDrCodg = "1"
  12241. // order.DrordDeptName = department.Name
  12242. // order.DrordDrCodg = "1"
  12243. // order.DrordDrName = doctor_info.UserName
  12244. // order.DrordDrProfttl = ""
  12245. // order.CurrDrordFlag = "1"
  12246. // orders = append(orders, &order)
  12247. //
  12248. // }
  12249. // }
  12250. //}
  12251. for _, item := range prescriptions {
  12252. for _, subItem := range item.HisDoctorAdviceInfo {
  12253. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12254. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12255. var order models.FsiOrderDtos
  12256. order.RxID = strconv.FormatInt(item.ID, 10)
  12257. order.Rxno = strconv.FormatInt(item.ID, 10)
  12258. order.LongDrordFlag = "0"
  12259. order.HilistType = "1"
  12260. order.ChrgType = "1"
  12261. order.DrordBhvr = "0"
  12262. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12263. order.HosplistName = subItem.BaseDrugLib.DrugName
  12264. order.HilistLv = "1"
  12265. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12266. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12267. order.HosplistName = subItem.BaseDrugLib.DrugName
  12268. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12269. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12270. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12271. order.OwnpayAmt = ""
  12272. order.SelfpayAmt = ""
  12273. order.Spec = spec
  12274. order.SpecUnt = subItem.PrescribingNumberUnit
  12275. order.DrordBegnDate = s_tm
  12276. order.DrordStopDate = ""
  12277. order.DrordDrCodg = doctor_info.DoctorNumber
  12278. order.DrordDeptName = department.Name
  12279. order.DrordDeptCodg = department.Number
  12280. order.DrordDrName = doctor_info.UserName
  12281. order.DrordDrProfttl = "234"
  12282. order.CurrDrordFlag = "1"
  12283. orders = append(orders, &order)
  12284. }
  12285. }
  12286. for _, subItem := range item.HisPrescriptionProject {
  12287. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12288. var order models.FsiOrderDtos
  12289. order.RxID = strconv.FormatInt(item.ID, 10)
  12290. order.Rxno = strconv.FormatInt(item.ID, 10)
  12291. order.LongDrordFlag = "0"
  12292. order.HilistType = "1"
  12293. order.ChrgType = "1"
  12294. order.DrordBhvr = "0"
  12295. order.HilistCode = subItem.HisProject.MedicalCode
  12296. order.HosplistName = subItem.HisProject.ProjectName
  12297. order.HilistLv = "1"
  12298. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12299. order.HosplistCode = subItem.HisProject.MedicalCode
  12300. order.HosplistName = subItem.HisProject.ProjectName
  12301. order.Cnt = subItem.Count
  12302. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12303. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12304. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12305. order.OwnpayAmt = ""
  12306. order.SelfpayAmt = ""
  12307. order.Spec = subItem.Unit
  12308. order.SpecUnt = subItem.Unit
  12309. order.DrordBegnDate = s_tm
  12310. order.DrordStopDate = ""
  12311. order.DrordDrCodg = doctor_info.DoctorNumber
  12312. order.DrordDeptName = department.Name
  12313. order.DrordDeptCodg = department.Number
  12314. order.DrordDrName = doctor_info.UserName
  12315. order.DrordDrProfttl = "234"
  12316. order.CurrDrordFlag = "1"
  12317. orders = append(orders, &order)
  12318. }
  12319. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12320. var order models.FsiOrderDtos
  12321. order.RxID = strconv.FormatInt(item.ID, 10)
  12322. order.Rxno = strconv.FormatInt(item.ID, 10)
  12323. order.LongDrordFlag = "0"
  12324. order.HilistType = "1"
  12325. order.ChrgType = "1"
  12326. order.DrordBhvr = "0"
  12327. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12328. order.HosplistName = subItem.GoodInfo.GoodName
  12329. order.HilistLv = "1"
  12330. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12331. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12332. order.HosplistName = subItem.GoodInfo.GoodName
  12333. order.Cnt = subItem.Count
  12334. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12335. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12336. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12337. order.OwnpayAmt = ""
  12338. order.SelfpayAmt = ""
  12339. order.Spec = subItem.GoodInfo.SpecificationName
  12340. order.SpecUnt = subItem.Unit
  12341. order.DrordBegnDate = s_tm
  12342. order.DrordStopDate = ""
  12343. order.DrordDrCodg = doctor_info.DoctorNumber
  12344. order.DrordDeptName = department.Name
  12345. order.DrordDeptCodg = department.Number
  12346. order.DrordDrName = doctor_info.UserName
  12347. order.DrordDrProfttl = "234"
  12348. order.CurrDrordFlag = "1"
  12349. orders = append(orders, &order)
  12350. }
  12351. }
  12352. }
  12353. //处方医嘱信息
  12354. fed.MatnStas = "0"
  12355. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12356. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12357. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12358. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12359. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12360. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12361. fed.SetlTotlnum = "1"
  12362. fed.Insutype = his.Insutype
  12363. fed.ReimFlag = "0"
  12364. fed.OutSetlFlag = "0"
  12365. var fopd []*models.FsiOperationDtosData
  12366. data := make(map[string]interface{})
  12367. data["fed"] = fed
  12368. data["fdd"] = fdds
  12369. data["fod"] = orders
  12370. data["pd"] = pd
  12371. data["pp"] = pp
  12372. data["fopd"] = fopd
  12373. data["trig_scen"] = trig_scen
  12374. client := &http.Client{}
  12375. bytesData, _ := json.Marshal(data)
  12376. var req *http.Request
  12377. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12378. if miConfig.MdtrtareaAdmvs == "320921" {
  12379. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12380. } else {
  12381. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12382. }
  12383. resp, _ := client.Do(req)
  12384. defer resp.Body.Close()
  12385. body, ioErr := ioutil.ReadAll(resp.Body)
  12386. if ioErr != nil {
  12387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12389. return res
  12390. }
  12391. var respJSON map[string]interface{}
  12392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12395. return res
  12396. }
  12397. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12398. result, _ := json.Marshal(respJSON)
  12399. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12400. utils.ErrorLog("解析失败:%v", err)
  12401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12402. return res
  12403. }
  12404. return res
  12405. } else {
  12406. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12407. saveLog(output, input, "3102", "事中")
  12408. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12409. utils.ErrorLog("解析失败:%v", err)
  12410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12411. return
  12412. }
  12413. return res
  12414. }
  12415. return res
  12416. }
  12417. func (c *HisApiController) Check() {
  12418. psn_no := c.GetString("psn_no")
  12419. in := c.GetString("in")
  12420. mt := c.GetString("mt")
  12421. baseParams := models.BaseParams{
  12422. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12423. FixmedinsCode: "H15049901371",
  12424. InsuplcAdmdvs: "150499",
  12425. MdtrtareaAdmvs: "150499",
  12426. OrgName: "赤峰费森血液透析中心",
  12427. Doctor: "1111",
  12428. }
  12429. service.Gdyb2001(baseParams, psn_no, in, mt)
  12430. }
  12431. func (c *HisApiController) GetPsnNcdsInfo() {
  12432. admin_user_id, _ := c.GetInt64("admin_user_id")
  12433. patient_id, _ := c.GetInt64("patient_id")
  12434. //id, _ := c.GetInt64("id")
  12435. adminUser := c.GetAdminUserInfo()
  12436. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12437. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12438. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12439. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12440. //psn_record, _ := service.GetP(id)
  12441. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12442. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12443. //
  12444. //if psn_record.ID == 0 {
  12445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12446. // return
  12447. //}
  12448. var res Result5301
  12449. var res10265 Result5301For10265
  12450. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12451. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12452. var api string
  12453. if miConfig.MdtrtareaAdmvs == "320921" {
  12454. 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 +
  12455. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12456. } else {
  12457. 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 +
  12458. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12459. }
  12460. resp, requestErr := http.Get(api)
  12461. if requestErr != nil {
  12462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12463. return
  12464. }
  12465. body, ioErr := ioutil.ReadAll(resp.Body)
  12466. if ioErr != nil {
  12467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12469. return
  12470. }
  12471. var respJSON map[string]interface{}
  12472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12475. return
  12476. }
  12477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12478. result, _ := json.Marshal(respJSON)
  12479. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12480. utils.ErrorLog("解析失败:%v", err)
  12481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12482. return
  12483. }
  12484. res.ErrMsg = res10265.ErrMsg
  12485. res.Output = res10265.Output
  12486. res.InfRefmsgid = res10265.InfRefmsgid
  12487. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12488. res.Infcode = infocode
  12489. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12490. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12491. var api string
  12492. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12493. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12494. resp, requestErr := http.Get(api)
  12495. if requestErr != nil {
  12496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12497. return
  12498. }
  12499. body, ioErr := ioutil.ReadAll(resp.Body)
  12500. if ioErr != nil {
  12501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12503. return
  12504. }
  12505. var respJSON map[string]interface{}
  12506. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12509. return
  12510. }
  12511. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12512. if status == "0" {
  12513. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12514. c.ServeSuccessJSON(map[string]interface{}{
  12515. "failed_code": -10,
  12516. "msg": err_msg,
  12517. })
  12518. return
  12519. }
  12520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12521. result, _ := json.Marshal(respJSON)
  12522. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12523. utils.ErrorLog("解析失败:%v", err)
  12524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12525. return
  12526. }
  12527. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12528. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12529. var api string
  12530. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12531. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12532. resp, requestErr := http.Get(api)
  12533. if requestErr != nil {
  12534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12535. return
  12536. }
  12537. body, ioErr := ioutil.ReadAll(resp.Body)
  12538. if ioErr != nil {
  12539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12541. return
  12542. }
  12543. var respJSON map[string]interface{}
  12544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12547. return
  12548. }
  12549. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12550. if status == "0" {
  12551. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12552. c.ServeSuccessJSON(map[string]interface{}{
  12553. "failed_code": -10,
  12554. "msg": err_msg,
  12555. })
  12556. return
  12557. }
  12558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12559. result, _ := json.Marshal(respJSON)
  12560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12561. utils.ErrorLog("解析失败:%v", err)
  12562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12563. return
  12564. }
  12565. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12566. p, _ := service.GetHisPatientById(patient_id)
  12567. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12568. var dat map[string]interface{}
  12569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12570. fmt.Println(dat)
  12571. } else {
  12572. fmt.Println(err)
  12573. }
  12574. userJSONBytes, _ := json.Marshal(dat)
  12575. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12576. utils.ErrorLog("解析失败:%v", err)
  12577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12578. return
  12579. }
  12580. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12581. p, _ := service.GetHisPatientById(patient_id)
  12582. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12583. var dat map[string]interface{}
  12584. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12585. fmt.Println(dat)
  12586. } else {
  12587. fmt.Println(err)
  12588. }
  12589. userJSONBytes, _ := json.Marshal(dat)
  12590. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12591. utils.ErrorLog("解析失败:%v", err)
  12592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12593. return
  12594. }
  12595. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12596. p, _ := service.GetHisPatientById(patient_id)
  12597. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12598. var dat map[string]interface{}
  12599. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12600. fmt.Println(dat)
  12601. } else {
  12602. fmt.Println(err)
  12603. }
  12604. userJSONBytes, _ := json.Marshal(dat)
  12605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12606. utils.ErrorLog("解析失败:%v", err)
  12607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12608. return
  12609. }
  12610. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12611. p, _ := service.GetHisPatientById(patient_id)
  12612. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12613. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12614. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12615. resp, requestErr := http.Get(api)
  12616. if requestErr != nil {
  12617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12618. return
  12619. }
  12620. body, ioErr := ioutil.ReadAll(resp.Body)
  12621. if ioErr != nil {
  12622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12624. return
  12625. }
  12626. var respJSON map[string]interface{}
  12627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12630. return
  12631. }
  12632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12633. result, _ := json.Marshal(respJSON)
  12634. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12635. utils.ErrorLog("解析失败:%v", err)
  12636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12637. return
  12638. }
  12639. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12640. p, _ := service.GetHisPatientById(patient_id)
  12641. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12642. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12643. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12644. resp, requestErr := http.Get(api)
  12645. if requestErr != nil {
  12646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12647. return
  12648. }
  12649. body, ioErr := ioutil.ReadAll(resp.Body)
  12650. if ioErr != nil {
  12651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12653. return
  12654. }
  12655. var respJSON map[string]interface{}
  12656. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12659. return
  12660. }
  12661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12662. result, _ := json.Marshal(respJSON)
  12663. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12664. utils.ErrorLog("解析失败:%v", err)
  12665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12666. return
  12667. }
  12668. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12669. p, _ := service.GetHisPatientById(patient_id)
  12670. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12671. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12672. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12673. resp, requestErr := http.Get(api)
  12674. if requestErr != nil {
  12675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12676. return
  12677. }
  12678. body, ioErr := ioutil.ReadAll(resp.Body)
  12679. if ioErr != nil {
  12680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12682. return
  12683. }
  12684. var respJSON map[string]interface{}
  12685. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12688. return
  12689. }
  12690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12691. result, _ := json.Marshal(respJSON)
  12692. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12693. utils.ErrorLog("解析失败:%v", err)
  12694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12695. return
  12696. }
  12697. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12698. p, _ := service.GetHisPatientById(patient_id)
  12699. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12700. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12701. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12702. resp, requestErr := http.Get(api)
  12703. if requestErr != nil {
  12704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12705. return
  12706. }
  12707. body, ioErr := ioutil.ReadAll(resp.Body)
  12708. if ioErr != nil {
  12709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12711. return
  12712. }
  12713. var respJSON map[string]interface{}
  12714. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12717. return
  12718. }
  12719. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12720. result, _ := json.Marshal(respJSON)
  12721. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12722. utils.ErrorLog("解析失败:%v", err)
  12723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12724. return
  12725. }
  12726. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12727. p, _ := service.GetHisPatientById(patient_id)
  12728. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12729. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12730. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12731. resp, requestErr := http.Get(api)
  12732. if requestErr != nil {
  12733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12734. return
  12735. }
  12736. body, ioErr := ioutil.ReadAll(resp.Body)
  12737. if ioErr != nil {
  12738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12740. return
  12741. }
  12742. var respJSON map[string]interface{}
  12743. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12746. return
  12747. }
  12748. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12749. result, _ := json.Marshal(respJSON)
  12750. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12751. utils.ErrorLog("解析失败:%v", err)
  12752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12753. return
  12754. }
  12755. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12756. p, _ := service.GetHisPatientById(patient_id)
  12757. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12758. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12759. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12760. resp, requestErr := http.Get(api)
  12761. if requestErr != nil {
  12762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12763. return
  12764. }
  12765. body, ioErr := ioutil.ReadAll(resp.Body)
  12766. if ioErr != nil {
  12767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12769. return
  12770. }
  12771. var respJSON map[string]interface{}
  12772. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12775. return
  12776. }
  12777. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12778. result, _ := json.Marshal(respJSON)
  12779. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12780. utils.ErrorLog("解析失败:%v", err)
  12781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12782. return
  12783. }
  12784. } else {
  12785. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12786. var dat map[string]interface{}
  12787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12788. fmt.Println(dat)
  12789. } else {
  12790. fmt.Println(err)
  12791. }
  12792. userJSONBytes, _ := json.Marshal(dat)
  12793. if miConfig.Code == "H15049901371" {
  12794. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12795. utils.ErrorLog("解析失败:%v", err)
  12796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12797. return
  12798. }
  12799. res.InfRefmsgid = res10265.InfRefmsgid
  12800. res.Output = res10265.Output
  12801. res.ErrMsg = res10265.ErrMsg
  12802. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12803. res.Infcode = infocode
  12804. } else {
  12805. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12806. utils.ErrorLog("解析失败:%v", err)
  12807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12808. return
  12809. }
  12810. }
  12811. }
  12812. if res.Infcode == 0 {
  12813. c.ServeSuccessJSON(map[string]interface{}{
  12814. "result": res.Output.Result,
  12815. })
  12816. }
  12817. }
  12818. func (c *HisApiController) CheckInsutype() {
  12819. his_patient_id, _ := c.GetInt64("his_patient_id")
  12820. admin_user_id, _ := c.GetInt64("admin_user_id")
  12821. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12822. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12823. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12824. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12825. var dat map[string]interface{}
  12826. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12827. fmt.Println(dat)
  12828. } else {
  12829. fmt.Println(err)
  12830. }
  12831. userJSONBytes, _ := json.Marshal(dat)
  12832. var res Result90100
  12833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12834. utils.ErrorLog("解析失败:%v", err)
  12835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12836. return
  12837. }
  12838. if res.Infcode != 0 {
  12839. c.ServeSuccessJSON(map[string]interface{}{
  12840. "failed_code": -10,
  12841. "msg": res.ErrMsg,
  12842. })
  12843. return
  12844. } else {
  12845. fmt.Println(res)
  12846. }
  12847. }
  12848. func (c *HisApiController) CheckCardPWD() {
  12849. card_pwd := c.GetString("card_pwd")
  12850. his_patient_id, _ := c.GetInt64("his_patient_id")
  12851. admin_user_id, _ := c.GetInt64("admin_user_id")
  12852. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12854. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12855. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12856. bas := strings.Split(psn.CardInfo, "|")
  12857. basNumber := bas[2]
  12858. if psn.InsuplcAdmdvs[:4] == "4403" {
  12859. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12860. var dat map[string]interface{}
  12861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12862. fmt.Println(dat)
  12863. } else {
  12864. fmt.Println(err)
  12865. }
  12866. userJSONBytes, _ := json.Marshal(dat)
  12867. var res Result90991
  12868. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12869. utils.ErrorLog("解析失败:%v", err)
  12870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12871. return
  12872. }
  12873. if res.Infcode != 0 {
  12874. c.ServeSuccessJSON(map[string]interface{}{
  12875. "failed_code": -10,
  12876. "msg": res.ErrMsg,
  12877. })
  12878. return
  12879. } else {
  12880. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12881. var msg string
  12882. switch res.Output.Result.CardStat {
  12883. case "00":
  12884. msg = "未激活"
  12885. break
  12886. case "10":
  12887. msg = "激活"
  12888. break
  12889. case "20":
  12890. msg = "窗口挂失"
  12891. break
  12892. case "21":
  12893. msg = "电话挂失"
  12894. break
  12895. case "22":
  12896. msg = "单位网上申报挂失"
  12897. break
  12898. case "23":
  12899. msg = "保健办挂失"
  12900. break
  12901. case "24":
  12902. msg = "个人网上挂失"
  12903. break
  12904. case "25":
  12905. msg = "网上服务大厅挂失"
  12906. break
  12907. case "30":
  12908. msg = "注销"
  12909. break
  12910. case "40":
  12911. msg = "回收"
  12912. break
  12913. case "99":
  12914. msg = "制卡中(无效卡)"
  12915. break
  12916. }
  12917. c.ServeSuccessJSON(map[string]interface{}{
  12918. "failed_code": -10,
  12919. "msg": msg,
  12920. })
  12921. return
  12922. } else {
  12923. c.ServeSuccessJSON(map[string]interface{}{
  12924. "msg": "校验成功",
  12925. })
  12926. return
  12927. }
  12928. }
  12929. } else {
  12930. c.ServeSuccessJSON(map[string]interface{}{
  12931. "msg": "校验成功",
  12932. })
  12933. return
  12934. }
  12935. }
  12936. func (c *HisApiController) CheckCardPWDTwo() {
  12937. //card_pwd := c.GetString("card_pwd")
  12938. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12939. admin_user_id, _ := c.GetInt64("admin_user_id")
  12940. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12941. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12942. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12943. var dat map[string]interface{}
  12944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12945. fmt.Println(dat)
  12946. } else {
  12947. fmt.Println(err)
  12948. }
  12949. userJSONBytes, _ := json.Marshal(dat)
  12950. var res Result90991
  12951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12952. utils.ErrorLog("解析失败:%v", err)
  12953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12954. return
  12955. }
  12956. if res.Infcode != 0 {
  12957. c.ServeSuccessJSON(map[string]interface{}{
  12958. "failed_code": -10,
  12959. "msg": res.ErrMsg,
  12960. })
  12961. return
  12962. } else {
  12963. if res.Output.Result.SscnoCheckStat == "0" {
  12964. var msg string
  12965. switch res.Output.Result.CardStat {
  12966. case "00":
  12967. msg = "未激活"
  12968. break
  12969. case "10":
  12970. msg = "激活"
  12971. break
  12972. case "20":
  12973. msg = "窗口挂失"
  12974. break
  12975. case "21":
  12976. msg = "电话挂失"
  12977. break
  12978. case "22":
  12979. msg = "单位网上申报挂失"
  12980. break
  12981. case "23":
  12982. msg = "保健办挂失"
  12983. break
  12984. case "24":
  12985. msg = "个人网上挂失"
  12986. break
  12987. case "25":
  12988. msg = "网上服务大厅挂失"
  12989. break
  12990. case "30":
  12991. msg = "注销"
  12992. break
  12993. case "40":
  12994. msg = "回收"
  12995. break
  12996. case "99":
  12997. msg = "制卡中(无效卡)"
  12998. break
  12999. }
  13000. c.ServeSuccessJSON(map[string]interface{}{
  13001. "failed_code": -10,
  13002. "msg": msg,
  13003. })
  13004. return
  13005. } else {
  13006. c.ServeSuccessJSON(map[string]interface{}{
  13007. "msg": "校验成功",
  13008. })
  13009. return
  13010. }
  13011. }
  13012. }
  13013. type ELeCertData struct {
  13014. Data struct {
  13015. Extra string `json:"extra"`
  13016. IDNo string `json:"idNo"`
  13017. IDType string `json:"idType"`
  13018. EcToken string `json:"ecToken"`
  13019. InsuOrg string `json:"insuOrg"`
  13020. UserName string `json:"userName"`
  13021. EcIndexNo string `json:"ecIndexNo"`
  13022. Gender string `json:"gender"`
  13023. Birthday string `json:"birthday"`
  13024. Nationality string `json:"nationality"`
  13025. Email string `json:"email"`
  13026. } `json:"OutData"`
  13027. }
  13028. func (c *HisApiController) ReadCard() {
  13029. id_card_type, _ := c.GetInt64("id_card_type")
  13030. admin_user_id, _ := c.GetInt64("admin_user_id")
  13031. certificates, _ := c.GetInt64("certificates")
  13032. //
  13033. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13034. id_card_no := c.GetString("id_card_no")
  13035. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13036. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13037. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13038. switch id_card_type {
  13039. case 1:
  13040. if miConfig.MdtrtareaAdmvs == "421300" {
  13041. var res ResultTwo
  13042. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13043. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13044. "&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)
  13045. resp, requestErr := http.Get(api)
  13046. if requestErr != nil {
  13047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13048. return
  13049. }
  13050. body, ioErr := ioutil.ReadAll(resp.Body)
  13051. if ioErr != nil {
  13052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13054. return
  13055. }
  13056. var respJSON map[string]interface{}
  13057. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13060. return
  13061. }
  13062. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13063. result, _ := json.Marshal(respJSON)
  13064. fmt.Println("log")
  13065. fmt.Println(string(result))
  13066. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13067. utils.ErrorLog("解析失败:%v", err)
  13068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13069. return
  13070. }
  13071. if res.Infcode == 0 {
  13072. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13073. if err == gorm.ErrRecordNotFound {
  13074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13075. return
  13076. } else if err != nil {
  13077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13078. return
  13079. } else {
  13080. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13081. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13082. infoStr := string(Iinfos)
  13083. idetinfoStr := string(Idetinfos)
  13084. var rf []*ResultFive
  13085. json.Unmarshal([]byte(infoStr), &rf)
  13086. var insutypes []*ResultFive
  13087. var insutype string
  13088. var is390 int = 0
  13089. var is310 int = 0
  13090. for _, item := range rf {
  13091. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13092. insutypes = append(insutypes, item)
  13093. }
  13094. }
  13095. if len(insutypes) == 1 {
  13096. insutype = insutypes[0].Insutype
  13097. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13098. } else {
  13099. for _, i := range insutypes {
  13100. if i.Insutype == "390" {
  13101. is390 = 1
  13102. }
  13103. if i.Insutype == "310" {
  13104. is310 = 1
  13105. }
  13106. }
  13107. }
  13108. if is390 == 1 {
  13109. insutype = "390"
  13110. }
  13111. if is310 == 1 {
  13112. insutype = "310"
  13113. }
  13114. if len(insutypes) == 0 {
  13115. insutype = "390"
  13116. }
  13117. var insuplc_admdvs string
  13118. for _, item := range rf {
  13119. if item.Insutype == insutype {
  13120. insuplc_admdvs = item.InsuplcAdmdvs
  13121. }
  13122. }
  13123. if strings.Contains(insuplc_admdvs, "4213") {
  13124. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13125. }
  13126. psn := &models.HisPsn{
  13127. PsnNo: res.Output.Baseinfo.PsnNo,
  13128. PatientId: patient.ID,
  13129. Certno: res.Output.Baseinfo.Certno,
  13130. Gend: res.Output.Baseinfo.Gend,
  13131. Naty: res.Output.Baseinfo.Naty,
  13132. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13133. PsnName: res.Output.Baseinfo.PsnName,
  13134. Idetinfo: idetinfoStr,
  13135. Insuinfo: infoStr,
  13136. InsuplcAdmdvs: insuplc_admdvs,
  13137. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13138. }
  13139. service.CreateHisPsn(psn)
  13140. c.ServeSuccessJSON(map[string]interface{}{
  13141. "patient": patient,
  13142. "number": res.Output.Baseinfo.Certno,
  13143. })
  13144. }
  13145. } else {
  13146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13147. return
  13148. }
  13149. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13150. var res ResultTwo
  13151. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13152. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13153. "&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)
  13154. resp, requestErr := http.Get(api)
  13155. if requestErr != nil {
  13156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13157. return
  13158. }
  13159. body, ioErr := ioutil.ReadAll(resp.Body)
  13160. if ioErr != nil {
  13161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13163. return
  13164. }
  13165. var respJSON map[string]interface{}
  13166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13169. return
  13170. }
  13171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13172. result, _ := json.Marshal(respJSON)
  13173. fmt.Println("log")
  13174. fmt.Println(string(result))
  13175. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13176. utils.ErrorLog("解析失败:%v", err)
  13177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13178. return
  13179. }
  13180. if res.Infcode == 0 {
  13181. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13182. if err == gorm.ErrRecordNotFound {
  13183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13184. return
  13185. } else if err != nil {
  13186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13187. return
  13188. } else {
  13189. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13190. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13191. infoStr := string(Iinfos)
  13192. idetinfoStr := string(Idetinfos)
  13193. psn := &models.HisPsn{
  13194. PsnNo: res.Output.Baseinfo.PsnNo,
  13195. PatientId: patient.ID,
  13196. Certno: res.Output.Baseinfo.Certno,
  13197. Gend: res.Output.Baseinfo.Gend,
  13198. Naty: res.Output.Baseinfo.Naty,
  13199. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13200. PsnName: res.Output.Baseinfo.PsnName,
  13201. Idetinfo: idetinfoStr,
  13202. Insuinfo: infoStr,
  13203. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13204. }
  13205. service.CreateHisPsn(psn)
  13206. var rf []*ResultFive
  13207. json.Unmarshal([]byte(infoStr), &rf)
  13208. var insutypes []*ResultFive
  13209. var insutype string
  13210. var is390 int = 0
  13211. var is310 int = 0
  13212. for _, item := range rf {
  13213. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13214. insutypes = append(insutypes, item)
  13215. }
  13216. }
  13217. if len(insutypes) == 1 {
  13218. insutype = insutypes[0].Insutype
  13219. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13220. } else {
  13221. for _, i := range insutypes {
  13222. if i.Insutype == "390" {
  13223. is390 = 1
  13224. }
  13225. if i.Insutype == "310" {
  13226. is310 = 1
  13227. }
  13228. }
  13229. }
  13230. if is390 == 1 {
  13231. insutype = "390"
  13232. }
  13233. if is310 == 1 {
  13234. insutype = "310"
  13235. }
  13236. if len(insutypes) == 0 {
  13237. insutype = "310"
  13238. }
  13239. c.ServeSuccessJSON(map[string]interface{}{
  13240. "patient": patient,
  13241. "number": res.Output.Baseinfo.Certno,
  13242. "insutype": insutype,
  13243. })
  13244. }
  13245. } else {
  13246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13247. return
  13248. }
  13249. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13250. var res ResultTwo
  13251. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13252. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13253. "&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)
  13254. resp, requestErr := http.Get(api)
  13255. if requestErr != nil {
  13256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13257. return
  13258. }
  13259. body, ioErr := ioutil.ReadAll(resp.Body)
  13260. if ioErr != nil {
  13261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13263. return
  13264. }
  13265. var respJSON map[string]interface{}
  13266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13269. return
  13270. }
  13271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13272. result, _ := json.Marshal(respJSON)
  13273. fmt.Println("log")
  13274. fmt.Println(string(result))
  13275. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13276. utils.ErrorLog("解析失败:%v", err)
  13277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13278. return
  13279. }
  13280. if res.Infcode == 0 {
  13281. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13282. if err == gorm.ErrRecordNotFound {
  13283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13284. return
  13285. } else if err != nil {
  13286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13287. return
  13288. } else {
  13289. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13290. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13291. infoStr := string(Iinfos)
  13292. idetinfoStr := string(Idetinfos)
  13293. var rf []*ResultFive
  13294. json.Unmarshal([]byte(infoStr), &rf)
  13295. var insutypes []*ResultFive
  13296. var insutype string
  13297. var is390 int = 0
  13298. var is310 int = 0
  13299. for _, item := range rf {
  13300. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13301. insutypes = append(insutypes, item)
  13302. }
  13303. }
  13304. if len(insutypes) == 1 {
  13305. insutype = insutypes[0].Insutype
  13306. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13307. } else {
  13308. for _, i := range insutypes {
  13309. if i.Insutype == "390" {
  13310. is390 = 1
  13311. }
  13312. if i.Insutype == "310" {
  13313. is310 = 1
  13314. }
  13315. }
  13316. }
  13317. if is390 == 1 {
  13318. insutype = "390"
  13319. }
  13320. if is310 == 1 {
  13321. insutype = "310"
  13322. }
  13323. if len(insutypes) == 0 {
  13324. insutype = "390"
  13325. }
  13326. var insuplc_admdvs string
  13327. for _, item := range rf {
  13328. if item.Insutype == insutype {
  13329. insuplc_admdvs = item.InsuplcAdmdvs
  13330. }
  13331. }
  13332. psn := &models.HisPsn{
  13333. PsnNo: res.Output.Baseinfo.PsnNo,
  13334. PatientId: patient.ID,
  13335. Certno: res.Output.Baseinfo.Certno,
  13336. Gend: res.Output.Baseinfo.Gend,
  13337. Naty: res.Output.Baseinfo.Naty,
  13338. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13339. PsnName: res.Output.Baseinfo.PsnName,
  13340. Idetinfo: idetinfoStr,
  13341. Insuinfo: infoStr,
  13342. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13343. InsuplcAdmdvs: insuplc_admdvs,
  13344. }
  13345. service.CreateHisPsn(psn)
  13346. for _, item := range rf {
  13347. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13348. insutypes = append(insutypes, item)
  13349. }
  13350. }
  13351. if len(insutypes) == 1 {
  13352. insutype = insutypes[0].Insutype
  13353. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13354. } else {
  13355. for _, i := range insutypes {
  13356. if i.Insutype == "390" {
  13357. is390 = 1
  13358. }
  13359. if i.Insutype == "310" {
  13360. is310 = 1
  13361. }
  13362. }
  13363. }
  13364. if is390 == 1 {
  13365. insutype = "390"
  13366. }
  13367. if is310 == 1 {
  13368. insutype = "310"
  13369. }
  13370. if len(insutypes) == 0 {
  13371. insutype = "310"
  13372. }
  13373. c.ServeSuccessJSON(map[string]interface{}{
  13374. "patient": patient,
  13375. "number": res.Output.Baseinfo.Certno,
  13376. "insutype": insutype,
  13377. })
  13378. }
  13379. } else {
  13380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13381. return
  13382. }
  13383. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13384. var res ResultTwo
  13385. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13386. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13387. "&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)
  13388. resp, requestErr := http.Get(api)
  13389. if requestErr != nil {
  13390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13391. return
  13392. }
  13393. body, ioErr := ioutil.ReadAll(resp.Body)
  13394. if ioErr != nil {
  13395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13397. return
  13398. }
  13399. var respJSON map[string]interface{}
  13400. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13403. return
  13404. }
  13405. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13406. result, _ := json.Marshal(respJSON)
  13407. fmt.Println("log")
  13408. fmt.Println(string(result))
  13409. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13410. utils.ErrorLog("解析失败:%v", err)
  13411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13412. return
  13413. }
  13414. if res.Infcode == 0 {
  13415. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13416. if err == gorm.ErrRecordNotFound {
  13417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13418. return
  13419. } else if err != nil {
  13420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13421. return
  13422. } else {
  13423. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13424. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13425. infoStr := string(Iinfos)
  13426. idetinfoStr := string(Idetinfos)
  13427. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13428. psn := &models.HisPsn{
  13429. PsnNo: res.Output.Baseinfo.PsnNo,
  13430. PatientId: patient.ID,
  13431. Certno: res.Output.Baseinfo.Certno,
  13432. Brdy: b,
  13433. Age: float64(age),
  13434. Gend: res.Output.Baseinfo.Gend,
  13435. Naty: res.Output.Baseinfo.Naty,
  13436. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13437. PsnName: res.Output.Baseinfo.PsnName,
  13438. Idetinfo: idetinfoStr,
  13439. Insuinfo: infoStr,
  13440. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13441. }
  13442. service.CreateHisPsn(psn)
  13443. var rf []*ResultFive
  13444. json.Unmarshal([]byte(infoStr), &rf)
  13445. var insutypes []*ResultFive
  13446. var insutype string
  13447. var is390 int = 0
  13448. var is310 int = 0
  13449. for _, item := range rf {
  13450. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13451. insutypes = append(insutypes, item)
  13452. }
  13453. }
  13454. if len(insutypes) == 1 {
  13455. insutype = insutypes[0].Insutype
  13456. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13457. } else {
  13458. for _, i := range insutypes {
  13459. if i.Insutype == "390" {
  13460. is390 = 1
  13461. }
  13462. if i.Insutype == "310" {
  13463. is310 = 1
  13464. }
  13465. }
  13466. }
  13467. if is390 == 1 {
  13468. insutype = "390"
  13469. }
  13470. if is310 == 1 {
  13471. insutype = "310"
  13472. }
  13473. if len(insutypes) == 0 {
  13474. insutype = "310"
  13475. }
  13476. c.ServeSuccessJSON(map[string]interface{}{
  13477. "patient": patient,
  13478. "number": res.Output.Baseinfo.Certno,
  13479. "insutype": insutype,
  13480. })
  13481. }
  13482. } else {
  13483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13484. return
  13485. }
  13486. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13487. var api string
  13488. if miConfig.MdtrtareaAdmvs == "320921" {
  13489. 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 +
  13490. "&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
  13491. fmt.Println(api)
  13492. } else {
  13493. 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 +
  13494. "&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)
  13495. }
  13496. resp, requestErr := http.Get(api)
  13497. if requestErr != nil {
  13498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13499. return
  13500. }
  13501. body, ioErr := ioutil.ReadAll(resp.Body)
  13502. if ioErr != nil {
  13503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13505. return
  13506. }
  13507. var respJSON map[string]interface{}
  13508. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13511. return
  13512. }
  13513. var status string
  13514. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13515. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13516. //console.log()
  13517. fmt.Println("type===")
  13518. fmt.Println(card_type)
  13519. var token string
  13520. var res ResultTwo //1101结果
  13521. var res10265 ResultTwo10265 //1101结果
  13522. var card_info string //卡信息
  13523. var busi_card_info string
  13524. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13525. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13526. if status == "0" { //读卡成功
  13527. if card_type == "1" {
  13528. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13529. result, _ := json.Marshal(respJSON)
  13530. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13531. utils.ErrorLog("解析失败:%v", err)
  13532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13533. return
  13534. }
  13535. res.ErrMsg = res10265.ErrMsg
  13536. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13537. res.Infcode = infocode
  13538. res.Output = res10265.Output
  13539. res.InfRefmsgid = res10265.InfRefmsgid
  13540. } else {
  13541. //var card_info string //卡信息
  13542. //var busi_card_info string
  13543. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13544. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13545. //fmt.Println(card_info)
  13546. //fmt.Println(busi_card_info)
  13547. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13548. result, _ := json.Marshal(respJSON)
  13549. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13550. utils.ErrorLog("解析失败:%v", err)
  13551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13552. return
  13553. }
  13554. res.ErrMsg = res10265.ErrMsg
  13555. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13556. res.Infcode = infocode
  13557. res.Output = res10265.Output
  13558. res.InfRefmsgid = res10265.InfRefmsgid
  13559. }
  13560. if res.Infcode == 0 {
  13561. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13562. if err == gorm.ErrRecordNotFound {
  13563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13564. return
  13565. } else if err != nil {
  13566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13567. return
  13568. } else {
  13569. if card_type == "1" {
  13570. bas := strings.Split(card_info, "|")
  13571. basNumber := bas[2]
  13572. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13573. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13574. infoStr := string(Iinfos)
  13575. idetinfoStr := string(Idetinfos)
  13576. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13577. psn := &models.HisPsn{
  13578. PsnNo: res.Output.Baseinfo.PsnNo,
  13579. PatientId: patient.ID,
  13580. Certno: res.Output.Baseinfo.Certno,
  13581. Brdy: b,
  13582. Age: float64(age),
  13583. Gend: res.Output.Baseinfo.Gend,
  13584. Naty: res.Output.Baseinfo.Naty,
  13585. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13586. PsnName: res.Output.Baseinfo.PsnName,
  13587. Idetinfo: idetinfoStr,
  13588. Insuinfo: infoStr,
  13589. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13590. CardInfo: card_info,
  13591. VerifyNumber: busi_card_info,
  13592. }
  13593. service.CreateHisPsn(psn)
  13594. var rf []*ResultFive
  13595. json.Unmarshal([]byte(infoStr), &rf)
  13596. var insutypes []*ResultFive
  13597. var insutype string
  13598. var is390 int = 0
  13599. var is310 int = 0
  13600. for _, item := range rf {
  13601. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13602. insutypes = append(insutypes, item)
  13603. }
  13604. }
  13605. if len(insutypes) == 1 {
  13606. insutype = insutypes[0].Insutype
  13607. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13608. } else {
  13609. for _, i := range insutypes {
  13610. if i.Insutype == "390" {
  13611. is390 = 1
  13612. }
  13613. if i.Insutype == "310" {
  13614. is310 = 1
  13615. }
  13616. }
  13617. }
  13618. if is390 == 1 {
  13619. insutype = "390"
  13620. }
  13621. if is310 == 1 {
  13622. insutype = "310"
  13623. }
  13624. if len(insutypes) == 0 {
  13625. insutype = "310"
  13626. }
  13627. c.ServeSuccessJSON(map[string]interface{}{
  13628. "patient": patient,
  13629. "number": basNumber,
  13630. "insutype": insutype,
  13631. })
  13632. } else {
  13633. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13634. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13635. infoStr := string(Iinfos)
  13636. idetinfoStr := string(Idetinfos)
  13637. psn := &models.HisPsn{
  13638. PsnNo: res.Output.Baseinfo.PsnNo,
  13639. PatientId: patient.ID,
  13640. Certno: res.Output.Baseinfo.Certno,
  13641. Gend: res.Output.Baseinfo.Gend,
  13642. Naty: res.Output.Baseinfo.Naty,
  13643. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13644. PsnName: res.Output.Baseinfo.PsnName,
  13645. Idetinfo: idetinfoStr,
  13646. Insuinfo: infoStr,
  13647. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13648. CardInfo: card_info,
  13649. VerifyNumber: token,
  13650. }
  13651. service.CreateHisPsn(psn)
  13652. c.ServeSuccessJSON(map[string]interface{}{
  13653. "patient": patient,
  13654. "number": token,
  13655. })
  13656. }
  13657. }
  13658. } else {
  13659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13660. return
  13661. }
  13662. } else { //读卡失败
  13663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13664. return
  13665. }
  13666. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13667. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13668. cardnum = DeleteExtraSpaceTwo(cardnum)
  13669. cardCode = DeleteExtraSpaceTwo(cardCode)
  13670. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13671. name = DeleteExtraSpaceTwo(name)
  13672. errmsg = DeleteExtraSpaceTwo(errmsg)
  13673. cardnum = Remove0000(cardnum)
  13674. cardCode = Remove0000(cardCode)
  13675. id_card_no = Remove0000(id_card_no)
  13676. name = Remove0000(name)
  13677. errmsg = Remove0000(errmsg)
  13678. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13679. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13680. //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)
  13681. //fmt.Println(result2)
  13682. //fmt.Println(requestLog2)
  13683. //fmt.Println(errMsgLog2)
  13684. 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)
  13685. saveLog(result, requestLog, "1101", "获取人员信息")
  13686. fmt.Println(errMsgLog)
  13687. if len(errMsgLog) > 0 {
  13688. } else {
  13689. var dat map[string]interface{}
  13690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13691. fmt.Println(dat)
  13692. } else {
  13693. fmt.Println(err)
  13694. }
  13695. userJSONBytes, _ := json.Marshal(dat)
  13696. var res ResultTwo
  13697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13698. utils.ErrorLog("解析失败:%v", err)
  13699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13700. return
  13701. }
  13702. res.ErrMsg = errMsgLog
  13703. if res.Infcode == 0 {
  13704. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13705. if err == gorm.ErrRecordNotFound {
  13706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13707. return
  13708. } else if err != nil {
  13709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13710. return
  13711. } else {
  13712. fmt.Println(res)
  13713. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13714. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13715. infoStr := string(Iinfos)
  13716. idetinfoStr := string(Idetinfos)
  13717. var rf []*ResultFive
  13718. json.Unmarshal([]byte(infoStr), &rf)
  13719. var insutypes []*ResultFive
  13720. var insutype string
  13721. var is390 int = 0
  13722. var is310 int = 0
  13723. for _, item := range rf {
  13724. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13725. insutypes = append(insutypes, item)
  13726. }
  13727. }
  13728. if len(insutypes) == 1 {
  13729. insutype = insutypes[0].Insutype
  13730. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13731. } else {
  13732. for _, i := range insutypes {
  13733. if i.Insutype == "390" {
  13734. is390 = 1
  13735. }
  13736. if i.Insutype == "310" {
  13737. is310 = 1
  13738. }
  13739. }
  13740. }
  13741. if is390 == 1 {
  13742. insutype = "390"
  13743. }
  13744. if is310 == 1 {
  13745. insutype = "310"
  13746. }
  13747. if len(insutypes) == 0 {
  13748. insutype = "390"
  13749. }
  13750. var insuplc_admdvs string
  13751. for _, item := range rf {
  13752. if item.Insutype == insutype {
  13753. insuplc_admdvs = item.InsuplcAdmdvs
  13754. }
  13755. }
  13756. psn := &models.HisPsn{
  13757. PsnNo: res.Output.Baseinfo.PsnNo,
  13758. PatientId: patient.ID,
  13759. Certno: res.Output.Baseinfo.Certno,
  13760. Gend: res.Output.Baseinfo.Gend,
  13761. Naty: res.Output.Baseinfo.Naty,
  13762. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13763. PsnName: res.Output.Baseinfo.PsnName,
  13764. Idetinfo: idetinfoStr,
  13765. Insuinfo: infoStr,
  13766. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13767. CardInfo: basStr,
  13768. VerifyNumber: "",
  13769. InsuplcAdmdvs: insuplc_admdvs,
  13770. }
  13771. service.CreateHisPsn(psn)
  13772. c.ServeSuccessJSON(map[string]interface{}{
  13773. "patient": patient,
  13774. "number": cardnum,
  13775. "insutype": insutype,
  13776. })
  13777. }
  13778. } else {
  13779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13780. return
  13781. }
  13782. }
  13783. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13784. fmt.Println(initFlag)
  13785. fmt.Println("initFlag")
  13786. if initFlag == 0 {
  13787. c.TestGetJiangXiBasBaseInit()
  13788. }
  13789. basStr := c.GetBasBaseInfo()
  13790. if len(basStr) == 0 {
  13791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13792. return
  13793. }
  13794. fmt.Println(basStr)
  13795. bas := strings.Split(basStr, "|")
  13796. basNumber := bas[1]
  13797. fmt.Println(basNumber)
  13798. card_sn := bas[3]
  13799. fmt.Println(card_sn)
  13800. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13801. 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)
  13802. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13803. var dat map[string]interface{}
  13804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13805. fmt.Println(dat)
  13806. } else {
  13807. fmt.Println(err)
  13808. }
  13809. userJSONBytes, _ := json.Marshal(dat)
  13810. var res ResultTwo
  13811. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13812. utils.ErrorLog("解析失败:%v", err)
  13813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13814. return
  13815. }
  13816. if res.Infcode == 0 {
  13817. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13818. if err == gorm.ErrRecordNotFound {
  13819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13820. return
  13821. } else if err != nil {
  13822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13823. return
  13824. } else {
  13825. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13826. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13827. infoStr := string(Iinfos)
  13828. idetinfoStr := string(Idetinfos)
  13829. var rf []*ResultFive
  13830. json.Unmarshal([]byte(infoStr), &rf)
  13831. var insutypes []*ResultFive
  13832. var insutype string
  13833. var is390 int = 0
  13834. var is310 int = 0
  13835. var insuplc_admdvs string
  13836. for _, item := range rf {
  13837. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13838. insutypes = append(insutypes, item)
  13839. }
  13840. }
  13841. if len(insutypes) == 1 {
  13842. insutype = insutypes[0].Insutype
  13843. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13844. } else {
  13845. for _, i := range insutypes {
  13846. if i.Insutype == "390" {
  13847. is390 = 1
  13848. }
  13849. if i.Insutype == "310" {
  13850. is310 = 1
  13851. }
  13852. }
  13853. }
  13854. if is390 == 1 {
  13855. insutype = "390"
  13856. }
  13857. if is310 == 1 {
  13858. insutype = "310"
  13859. }
  13860. if len(insutypes) == 0 {
  13861. insutype = "310"
  13862. }
  13863. for _, item := range rf {
  13864. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13865. insuplc_admdvs = item.InsuplcAdmdvs
  13866. }
  13867. }
  13868. psn := &models.HisPsn{
  13869. PsnNo: res.Output.Baseinfo.PsnNo,
  13870. PatientId: patient.ID,
  13871. Certno: res.Output.Baseinfo.Certno,
  13872. Gend: res.Output.Baseinfo.Gend,
  13873. Naty: res.Output.Baseinfo.Naty,
  13874. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13875. PsnName: res.Output.Baseinfo.PsnName,
  13876. Idetinfo: idetinfoStr,
  13877. Insuinfo: infoStr,
  13878. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13879. CardInfo: basStr,
  13880. InsuplcAdmdvs: insuplc_admdvs,
  13881. VerifyNumber: "",
  13882. }
  13883. service.CreateHisPsn(psn)
  13884. c.ServeSuccessJSON(map[string]interface{}{
  13885. "patient": patient,
  13886. "number": basNumber,
  13887. "insutype": insutype,
  13888. })
  13889. }
  13890. } else {
  13891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13892. return
  13893. }
  13894. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13895. basStr := c.GetBasBaseInfo22222()
  13896. fmt.Println(basStr)
  13897. if len(basStr) == 0 {
  13898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13899. return
  13900. }
  13901. fmt.Println(basStr)
  13902. bas := strings.Split(basStr, "|")
  13903. basNumber := bas[2] //卡号
  13904. card_sn := bas[3] //
  13905. id_card_No := bas[1] //卡号
  13906. fmt.Println(basNumber)
  13907. fmt.Println(card_sn)
  13908. fmt.Println(id_card_No)
  13909. var patient service.Patients
  13910. if len(id_card_No) == 0 {
  13911. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13912. } else {
  13913. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13914. }
  13915. 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)
  13916. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13917. var dat map[string]interface{}
  13918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13919. fmt.Println(dat)
  13920. } else {
  13921. fmt.Println(err)
  13922. }
  13923. userJSONBytes, _ := json.Marshal(dat)
  13924. var res ResultTwo
  13925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13926. utils.ErrorLog("解析失败:%v", err)
  13927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13928. return
  13929. }
  13930. if res.Infcode == 0 {
  13931. var pateint2 service.Patients
  13932. var err error
  13933. if len(id_card_No) == 0 {
  13934. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13935. } else {
  13936. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13937. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13938. }
  13939. if err == gorm.ErrRecordNotFound {
  13940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13941. return
  13942. } else if err != nil {
  13943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13944. return
  13945. } else {
  13946. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13947. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13948. infoStr := string(Iinfos)
  13949. idetinfoStr := string(Idetinfos)
  13950. var rf []*ResultFive
  13951. json.Unmarshal([]byte(infoStr), &rf)
  13952. var insutypes []*ResultFive
  13953. var insutype string
  13954. var is390 int = 0
  13955. var is310 int = 0
  13956. var insuplc_admdvs string
  13957. for _, item := range rf {
  13958. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13959. insutypes = append(insutypes, item)
  13960. }
  13961. }
  13962. if len(insutypes) == 1 {
  13963. insutype = insutypes[0].Insutype
  13964. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13965. } else {
  13966. for _, i := range insutypes {
  13967. if i.Insutype == "390" {
  13968. is390 = 1
  13969. }
  13970. if i.Insutype == "310" {
  13971. is310 = 1
  13972. }
  13973. }
  13974. }
  13975. if is390 == 1 {
  13976. insutype = "390"
  13977. }
  13978. if is310 == 1 {
  13979. insutype = "310"
  13980. }
  13981. if len(insutypes) == 0 {
  13982. insutype = "310"
  13983. }
  13984. for _, item := range rf {
  13985. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13986. insuplc_admdvs = item.InsuplcAdmdvs
  13987. }
  13988. }
  13989. psn := &models.HisPsn{
  13990. PsnNo: res.Output.Baseinfo.PsnNo,
  13991. PatientId: pateint2.ID,
  13992. Certno: res.Output.Baseinfo.Certno,
  13993. Gend: res.Output.Baseinfo.Gend,
  13994. Naty: res.Output.Baseinfo.Naty,
  13995. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13996. PsnName: res.Output.Baseinfo.PsnName,
  13997. Idetinfo: idetinfoStr,
  13998. Insuinfo: infoStr,
  13999. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14000. CardInfo: basStr,
  14001. InsuplcAdmdvs: insuplc_admdvs,
  14002. VerifyNumber: "",
  14003. }
  14004. service.CreateHisPsn(psn)
  14005. c.ServeSuccessJSON(map[string]interface{}{
  14006. "patient": patient,
  14007. "number": basNumber,
  14008. "insutype": insutype,
  14009. })
  14010. }
  14011. } else {
  14012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14013. return
  14014. }
  14015. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14016. fmt.Println(initFlag)
  14017. fmt.Println("initFlag")
  14018. if initFlag == 0 {
  14019. c.TestGetHnBasBaseInit()
  14020. }
  14021. basStr := c.GetBasBaseInfo()
  14022. if len(basStr) == 0 {
  14023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14024. return
  14025. }
  14026. fmt.Println(basStr)
  14027. bas := strings.Split(basStr, "|")
  14028. basNumber := bas[1]
  14029. fmt.Println(basNumber)
  14030. card_sn := bas[3]
  14031. card_no := bas[2]
  14032. fmt.Println(card_sn)
  14033. name := bas[4]
  14034. name = ConvertToString(name, "gbk", "utf-8")
  14035. 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)
  14036. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14037. var dat map[string]interface{}
  14038. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14039. fmt.Println(dat)
  14040. } else {
  14041. fmt.Println(err)
  14042. }
  14043. userJSONBytes, _ := json.Marshal(dat)
  14044. var res ResultTwo
  14045. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14046. utils.ErrorLog("解析失败:%v", err)
  14047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14048. return
  14049. }
  14050. if res.Infcode == 0 {
  14051. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14052. if err == gorm.ErrRecordNotFound {
  14053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14054. return
  14055. } else if err != nil {
  14056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14057. return
  14058. } else {
  14059. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14060. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14061. infoStr := string(Iinfos)
  14062. idetinfoStr := string(Idetinfos)
  14063. psn := &models.HisPsn{
  14064. PsnNo: res.Output.Baseinfo.PsnNo,
  14065. PatientId: patient.ID,
  14066. Certno: res.Output.Baseinfo.Certno,
  14067. Gend: res.Output.Baseinfo.Gend,
  14068. Naty: res.Output.Baseinfo.Naty,
  14069. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14070. PsnName: res.Output.Baseinfo.PsnName,
  14071. Idetinfo: idetinfoStr,
  14072. Insuinfo: infoStr,
  14073. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14074. CardInfo: basStr,
  14075. VerifyNumber: "",
  14076. }
  14077. service.CreateHisPsn(psn)
  14078. var rf []*ResultFive
  14079. json.Unmarshal([]byte(infoStr), &rf)
  14080. var insutypes []*ResultFive
  14081. var insutype string
  14082. var is390 int = 0
  14083. var is310 int = 0
  14084. for _, item := range rf {
  14085. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14086. insutypes = append(insutypes, item)
  14087. }
  14088. }
  14089. if len(insutypes) == 1 {
  14090. insutype = insutypes[0].Insutype
  14091. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14092. } else {
  14093. for _, i := range insutypes {
  14094. if i.Insutype == "390" {
  14095. is390 = 1
  14096. }
  14097. if i.Insutype == "310" {
  14098. is310 = 1
  14099. }
  14100. }
  14101. }
  14102. if is390 == 1 {
  14103. insutype = "390"
  14104. }
  14105. if is310 == 1 {
  14106. insutype = "310"
  14107. }
  14108. if len(insutypes) == 0 {
  14109. insutype = "310"
  14110. }
  14111. c.ServeSuccessJSON(map[string]interface{}{
  14112. "patient": patient,
  14113. "number": basNumber,
  14114. "insutype": insutype,
  14115. })
  14116. }
  14117. } else {
  14118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14119. return
  14120. }
  14121. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14122. var api string
  14123. 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 +
  14124. "&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
  14125. fmt.Println(api)
  14126. resp, requestErr := http.Get(api)
  14127. if requestErr != nil {
  14128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14129. return
  14130. }
  14131. body, ioErr := ioutil.ReadAll(resp.Body)
  14132. if ioErr != nil {
  14133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14135. return
  14136. }
  14137. var respJSON map[string]interface{}
  14138. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14141. return
  14142. }
  14143. var res ResultTwo //1101结果
  14144. var res10265 ResultTwo10265 //1101结果
  14145. var card_info string //卡信息
  14146. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14147. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14148. result, _ := json.Marshal(respJSON)
  14149. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14150. utils.ErrorLog("解析失败:%v", err)
  14151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14152. return
  14153. }
  14154. res.ErrMsg = res10265.ErrMsg
  14155. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14156. res.Infcode = infocode
  14157. res.Output = res10265.Output
  14158. res.InfRefmsgid = res10265.InfRefmsgid
  14159. if res.Infcode == 0 {
  14160. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14161. if err == gorm.ErrRecordNotFound {
  14162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14163. return
  14164. } else if err != nil {
  14165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14166. return
  14167. } else {
  14168. bas := strings.Split(card_info, "|")
  14169. basNumber := bas[2]
  14170. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14171. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14172. infoStr := string(Iinfos)
  14173. idetinfoStr := string(Idetinfos)
  14174. psn := &models.HisPsn{
  14175. PsnNo: res.Output.Baseinfo.PsnNo,
  14176. PatientId: patient.ID,
  14177. Certno: res.Output.Baseinfo.Certno,
  14178. Gend: res.Output.Baseinfo.Gend,
  14179. Naty: res.Output.Baseinfo.Naty,
  14180. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14181. PsnName: res.Output.Baseinfo.PsnName,
  14182. Idetinfo: idetinfoStr,
  14183. Insuinfo: infoStr,
  14184. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14185. CardInfo: card_info,
  14186. VerifyNumber: token,
  14187. }
  14188. service.CreateHisPsn(psn)
  14189. var rf []*ResultFive
  14190. json.Unmarshal([]byte(infoStr), &rf)
  14191. var insutypes []*ResultFive
  14192. var insutype string
  14193. var is390 int = 0
  14194. var is310 int = 0
  14195. for _, item := range rf {
  14196. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14197. insutypes = append(insutypes, item)
  14198. }
  14199. }
  14200. if len(insutypes) == 1 {
  14201. insutype = insutypes[0].Insutype
  14202. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14203. } else {
  14204. for _, i := range insutypes {
  14205. if i.Insutype == "390" {
  14206. is390 = 1
  14207. }
  14208. if i.Insutype == "310" {
  14209. is310 = 1
  14210. }
  14211. }
  14212. }
  14213. if is390 == 1 {
  14214. insutype = "390"
  14215. }
  14216. if is310 == 1 {
  14217. insutype = "310"
  14218. }
  14219. if len(insutypes) == 0 {
  14220. insutype = "310"
  14221. }
  14222. c.ServeSuccessJSON(map[string]interface{}{
  14223. "patient": patient,
  14224. "number": basNumber,
  14225. "insutype": insutype,
  14226. })
  14227. }
  14228. } else {
  14229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14230. return
  14231. }
  14232. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14233. res := c.GetoleInfo()
  14234. if res.Infcode == 0 {
  14235. var result string
  14236. if res.Output.MdtrtCertType == "01" {
  14237. 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)
  14238. } else if res.Output.MdtrtCertType == "02" {
  14239. 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)
  14240. } else if res.Output.MdtrtCertType == "03" {
  14241. 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)
  14242. }
  14243. var dat map[string]interface{}
  14244. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14245. fmt.Println(dat)
  14246. } else {
  14247. fmt.Println(err)
  14248. }
  14249. userJSONBytes, _ := json.Marshal(dat)
  14250. var res2 ResultTwo
  14251. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14252. utils.ErrorLog("解析失败:%v", err)
  14253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14254. return
  14255. }
  14256. if res2.Infcode == 0 {
  14257. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14258. if err == gorm.ErrRecordNotFound {
  14259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14260. return
  14261. } else if err != nil {
  14262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14263. return
  14264. } else {
  14265. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14266. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14267. infoStr := string(Iinfos)
  14268. idetinfoStr := string(Idetinfos)
  14269. var rf []*ResultFive
  14270. json.Unmarshal([]byte(infoStr), &rf)
  14271. var insutypes []*ResultFive
  14272. var insutype string
  14273. var is390 int = 0
  14274. var is310 int = 0
  14275. //var insuplc_admdvs string
  14276. for _, item := range rf {
  14277. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14278. insutypes = append(insutypes, item)
  14279. }
  14280. }
  14281. if len(insutypes) == 1 {
  14282. insutype = insutypes[0].Insutype
  14283. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14284. } else {
  14285. for _, i := range insutypes {
  14286. if i.Insutype == "390" {
  14287. is390 = 1
  14288. }
  14289. if i.Insutype == "310" {
  14290. is310 = 1
  14291. }
  14292. }
  14293. }
  14294. if is390 == 1 {
  14295. insutype = "390"
  14296. }
  14297. if is310 == 1 {
  14298. insutype = "310"
  14299. }
  14300. if len(insutypes) == 0 {
  14301. insutype = "310"
  14302. }
  14303. psn := &models.HisPsn{
  14304. PsnNo: res2.Output.Baseinfo.PsnNo,
  14305. PatientId: patient.ID,
  14306. Certno: res2.Output.Baseinfo.Certno,
  14307. Gend: res2.Output.Baseinfo.Gend,
  14308. Naty: res2.Output.Baseinfo.Naty,
  14309. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14310. PsnName: res2.Output.Baseinfo.PsnName,
  14311. Idetinfo: idetinfoStr,
  14312. Insuinfo: infoStr,
  14313. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14314. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14315. VerifyNumber: res.Output.EcToken,
  14316. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14317. }
  14318. if res.Output.MdtrtCertType == "01" {
  14319. psn.VerifyNumber = res.Output.EcToken
  14320. //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)
  14321. } else if res.Output.MdtrtCertType == "02" {
  14322. psn.VerifyNumber = res.Output.MdtrtCertNo
  14323. //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)
  14324. } else if res.Output.MdtrtCertType == "03" {
  14325. psn.VerifyNumber = res.Output.MdtrtCertNo
  14326. //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)
  14327. }
  14328. var balc float64
  14329. for _, item := range rf {
  14330. if item.Insutype == insutype {
  14331. balc = item.Balc
  14332. }
  14333. }
  14334. service.CreateHisPsn(psn)
  14335. c.ServeSuccessJSON(map[string]interface{}{
  14336. "patient": patient,
  14337. "number": res.Output.CardNo,
  14338. "insutype": insutype,
  14339. "blac": balc,
  14340. "desc": idetinfoStr,
  14341. })
  14342. }
  14343. } else {
  14344. c.ServeSuccessJSON(map[string]interface{}{
  14345. "failed_code": -10,
  14346. "msg": res2.ErrMsg,
  14347. })
  14348. }
  14349. } else {
  14350. c.ServeSuccessJSON(map[string]interface{}{
  14351. "failed_code": -10,
  14352. "msg": res.ErrMsg,
  14353. })
  14354. }
  14355. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14356. var api string
  14357. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14358. "&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
  14359. fmt.Println(api)
  14360. resp, requestErr := http.Get(api)
  14361. if requestErr != nil {
  14362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14363. return
  14364. }
  14365. body, ioErr := ioutil.ReadAll(resp.Body)
  14366. if ioErr != nil {
  14367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14369. return
  14370. }
  14371. var respJSON map[string]interface{}
  14372. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14375. return
  14376. }
  14377. var status string
  14378. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14379. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14380. //console.log()
  14381. fmt.Println("type===")
  14382. fmt.Println(card_type)
  14383. var token string
  14384. var res ResultTwo //1101结果
  14385. //var res10265 ResultTwoesultTwo10265 //1101结果
  14386. var card_info string //卡信息
  14387. var busi_card_info string
  14388. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14389. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14390. if status == "0" { //读卡成功
  14391. if card_type == "1" {
  14392. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14393. result, _ := json.Marshal(respJSON)
  14394. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14395. utils.ErrorLog("解析失败:%v", err)
  14396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14397. return
  14398. }
  14399. } else {
  14400. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14401. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14402. result, _ := json.Marshal(respJSON)
  14403. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14404. utils.ErrorLog("解析失败:%v", err)
  14405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14406. return
  14407. }
  14408. }
  14409. if res.Infcode == 0 {
  14410. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14411. if err == gorm.ErrRecordNotFound {
  14412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14413. return
  14414. } else if err != nil {
  14415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14416. return
  14417. } else {
  14418. if card_type == "1" {
  14419. bas := strings.Split(card_info, "|")
  14420. basNumber := bas[2]
  14421. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14422. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14423. infoStr := string(Iinfos)
  14424. idetinfoStr := string(Idetinfos)
  14425. psn := &models.HisPsn{
  14426. PsnNo: res.Output.Baseinfo.PsnNo,
  14427. PatientId: patient.ID,
  14428. Certno: res.Output.Baseinfo.Certno,
  14429. Gend: res.Output.Baseinfo.Gend,
  14430. Naty: res.Output.Baseinfo.Naty,
  14431. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14432. PsnName: res.Output.Baseinfo.PsnName,
  14433. Idetinfo: idetinfoStr,
  14434. Insuinfo: infoStr,
  14435. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14436. CardInfo: card_info,
  14437. VerifyNumber: busi_card_info,
  14438. }
  14439. service.CreateHisPsn(psn)
  14440. var rf []*ResultFive
  14441. json.Unmarshal([]byte(infoStr), &rf)
  14442. var insutypes []*ResultFive
  14443. var insutype string
  14444. var is390 int = 0
  14445. var is310 int = 0
  14446. for _, item := range rf {
  14447. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14448. insutypes = append(insutypes, item)
  14449. }
  14450. }
  14451. if len(insutypes) == 1 {
  14452. insutype = insutypes[0].Insutype
  14453. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14454. } else {
  14455. for _, i := range insutypes {
  14456. if i.Insutype == "390" {
  14457. is390 = 1
  14458. }
  14459. if i.Insutype == "310" {
  14460. is310 = 1
  14461. }
  14462. }
  14463. }
  14464. if is390 == 1 {
  14465. insutype = "390"
  14466. }
  14467. if is310 == 1 {
  14468. insutype = "310"
  14469. }
  14470. if len(insutypes) == 0 {
  14471. insutype = "310"
  14472. }
  14473. c.ServeSuccessJSON(map[string]interface{}{
  14474. "patient": patient,
  14475. "number": basNumber,
  14476. "insutype": insutype,
  14477. })
  14478. } else {
  14479. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14480. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14481. infoStr := string(Iinfos)
  14482. idetinfoStr := string(Idetinfos)
  14483. psn := &models.HisPsn{
  14484. PsnNo: res.Output.Baseinfo.PsnNo,
  14485. PatientId: patient.ID,
  14486. Certno: res.Output.Baseinfo.Certno,
  14487. Gend: res.Output.Baseinfo.Gend,
  14488. Naty: res.Output.Baseinfo.Naty,
  14489. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14490. PsnName: res.Output.Baseinfo.PsnName,
  14491. Idetinfo: idetinfoStr,
  14492. Insuinfo: infoStr,
  14493. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14494. CardInfo: card_info,
  14495. VerifyNumber: token,
  14496. }
  14497. service.CreateHisPsn(psn)
  14498. c.ServeSuccessJSON(map[string]interface{}{
  14499. "patient": patient,
  14500. "number": token,
  14501. })
  14502. }
  14503. }
  14504. } else {
  14505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14506. return
  14507. }
  14508. } else { //读卡失败
  14509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14510. return
  14511. }
  14512. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14513. var api string
  14514. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14515. "&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
  14516. fmt.Println(api)
  14517. resp, requestErr := http.Get(api)
  14518. if requestErr != nil {
  14519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14520. return
  14521. }
  14522. body, ioErr := ioutil.ReadAll(resp.Body)
  14523. if ioErr != nil {
  14524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14526. return
  14527. }
  14528. var respJSON map[string]interface{}
  14529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14532. return
  14533. }
  14534. var status string
  14535. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14536. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14537. //console.log()
  14538. fmt.Println("type===")
  14539. fmt.Println(card_type)
  14540. var token string
  14541. var res ResultTwo //1101结果
  14542. //var res10265 ResultTwoesultTwo10265 //1101结果
  14543. var card_info string //卡信息
  14544. //var busi_card_info string
  14545. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14546. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14547. if status == "0" { //读卡成功
  14548. if card_type == "1" {
  14549. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14550. result, _ := json.Marshal(respJSON)
  14551. fmt.Println(result)
  14552. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14553. utils.ErrorLog("解析失败:%v", err)
  14554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14555. return
  14556. }
  14557. fmt.Println(res)
  14558. } else {
  14559. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14560. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14561. result, _ := json.Marshal(respJSON)
  14562. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14563. utils.ErrorLog("解析失败:%v", err)
  14564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14565. return
  14566. }
  14567. }
  14568. if res.Infcode == 0 {
  14569. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14570. if err == gorm.ErrRecordNotFound {
  14571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14572. return
  14573. } else if err != nil {
  14574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14575. return
  14576. } else {
  14577. if card_type == "1" {
  14578. bas := strings.Split(card_info, "|")
  14579. basNumber := bas[2]
  14580. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14581. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14582. infoStr := string(Iinfos)
  14583. idetinfoStr := string(Idetinfos)
  14584. psn := &models.HisPsn{
  14585. PsnNo: res.Output.Baseinfo.PsnNo,
  14586. PatientId: patient.ID,
  14587. Certno: res.Output.Baseinfo.Certno,
  14588. Gend: res.Output.Baseinfo.Gend,
  14589. Naty: res.Output.Baseinfo.Naty,
  14590. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14591. PsnName: res.Output.Baseinfo.PsnName,
  14592. Idetinfo: idetinfoStr,
  14593. Insuinfo: infoStr,
  14594. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14595. CardInfo: card_info,
  14596. //VerifyNumber: busi_card_info,
  14597. }
  14598. service.CreateHisPsn(psn)
  14599. var rf []*ResultFive
  14600. json.Unmarshal([]byte(infoStr), &rf)
  14601. var insutypes []*ResultFive
  14602. var insutype string
  14603. var is390 int = 0
  14604. var is310 int = 0
  14605. for _, item := range rf {
  14606. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14607. insutypes = append(insutypes, item)
  14608. }
  14609. }
  14610. if len(insutypes) == 1 {
  14611. insutype = insutypes[0].Insutype
  14612. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14613. } else {
  14614. for _, i := range insutypes {
  14615. if i.Insutype == "390" {
  14616. is390 = 1
  14617. }
  14618. if i.Insutype == "310" {
  14619. is310 = 1
  14620. }
  14621. }
  14622. }
  14623. if is390 == 1 {
  14624. insutype = "390"
  14625. }
  14626. if is310 == 1 {
  14627. insutype = "310"
  14628. }
  14629. if len(insutypes) == 0 {
  14630. insutype = "310"
  14631. }
  14632. c.ServeSuccessJSON(map[string]interface{}{
  14633. "patient": patient,
  14634. "number": basNumber,
  14635. "insutype": insutype,
  14636. })
  14637. } else {
  14638. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14639. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14640. infoStr := string(Iinfos)
  14641. idetinfoStr := string(Idetinfos)
  14642. psn := &models.HisPsn{
  14643. PsnNo: res.Output.Baseinfo.PsnNo,
  14644. PatientId: patient.ID,
  14645. Certno: res.Output.Baseinfo.Certno,
  14646. Gend: res.Output.Baseinfo.Gend,
  14647. Naty: res.Output.Baseinfo.Naty,
  14648. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14649. PsnName: res.Output.Baseinfo.PsnName,
  14650. Idetinfo: idetinfoStr,
  14651. Insuinfo: infoStr,
  14652. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14653. CardInfo: card_info,
  14654. VerifyNumber: token,
  14655. }
  14656. service.CreateHisPsn(psn)
  14657. c.ServeSuccessJSON(map[string]interface{}{
  14658. "patient": patient,
  14659. "number": token,
  14660. })
  14661. }
  14662. }
  14663. } else {
  14664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14665. return
  14666. }
  14667. } else { //读卡失败
  14668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14669. return
  14670. }
  14671. } else {
  14672. if initFlag == 0 {
  14673. c.TestGetBasBaseInit()
  14674. }
  14675. basStr := c.GetBasBaseInfo()
  14676. if len(basStr) == 0 {
  14677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14678. return
  14679. }
  14680. fmt.Println(basStr)
  14681. bas := strings.Split(basStr, "|")
  14682. basNumber := bas[1]
  14683. fmt.Println(basNumber)
  14684. card_sn := bas[3]
  14685. fmt.Println(card_sn)
  14686. cardNumber := bas[2]
  14687. fmt.Println(cardNumber)
  14688. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14689. var result string
  14690. if bas[0][:2] == "44" {
  14691. 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)
  14692. } else {
  14693. 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)
  14694. }
  14695. var dat map[string]interface{}
  14696. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14697. fmt.Println(dat)
  14698. } else {
  14699. fmt.Println(err)
  14700. }
  14701. userJSONBytes, _ := json.Marshal(dat)
  14702. var res ResultTwo
  14703. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14704. utils.ErrorLog("解析失败:%v", err)
  14705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14706. return
  14707. }
  14708. if res.Infcode == 0 {
  14709. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14710. if err == gorm.ErrRecordNotFound {
  14711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14712. return
  14713. } else if err != nil {
  14714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14715. return
  14716. } else {
  14717. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14718. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14719. infoStr := string(Iinfos)
  14720. idetinfoStr := string(Idetinfos)
  14721. var rf []*ResultFive
  14722. json.Unmarshal([]byte(infoStr), &rf)
  14723. var insutypes []*ResultFive
  14724. var insutype string
  14725. var is390 int = 0
  14726. var is310 int = 0
  14727. var insuplc_admdvs string
  14728. for _, item := range rf {
  14729. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14730. insutypes = append(insutypes, item)
  14731. }
  14732. }
  14733. if len(insutypes) == 1 {
  14734. insutype = insutypes[0].Insutype
  14735. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14736. } else {
  14737. for _, i := range insutypes {
  14738. if i.Insutype == "390" {
  14739. is390 = 1
  14740. }
  14741. if i.Insutype == "310" {
  14742. is310 = 1
  14743. }
  14744. }
  14745. }
  14746. if is390 == 1 {
  14747. insutype = "390"
  14748. }
  14749. if is310 == 1 {
  14750. insutype = "310"
  14751. }
  14752. if len(insutypes) == 0 {
  14753. insutype = "310"
  14754. }
  14755. for _, item := range rf {
  14756. if item.Insutype == insutype {
  14757. insuplc_admdvs = item.InsuplcAdmdvs
  14758. }
  14759. }
  14760. psn := &models.HisPsn{
  14761. PsnNo: res.Output.Baseinfo.PsnNo,
  14762. PatientId: patient.ID,
  14763. Certno: res.Output.Baseinfo.Certno,
  14764. Gend: res.Output.Baseinfo.Gend,
  14765. Naty: res.Output.Baseinfo.Naty,
  14766. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14767. PsnName: res.Output.Baseinfo.PsnName,
  14768. Idetinfo: idetinfoStr,
  14769. Insuinfo: infoStr,
  14770. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14771. CardInfo: basStr,
  14772. VerifyNumber: "",
  14773. InsuplcAdmdvs: insuplc_admdvs,
  14774. }
  14775. service.CreateHisPsn(psn)
  14776. c.ServeSuccessJSON(map[string]interface{}{
  14777. "patient": patient,
  14778. "number": basNumber,
  14779. })
  14780. }
  14781. } else {
  14782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14783. return
  14784. }
  14785. break
  14786. }
  14787. case 2:
  14788. if miConfig.MdtrtareaAdmvs == "430800" {
  14789. if initFlag == 0 {
  14790. c.TestGetHnBasBaseInit()
  14791. }
  14792. SFZStr := c.GetSFZBaseInfo()
  14793. if len(SFZStr) == 0 {
  14794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14795. return
  14796. }
  14797. fmt.Println(SFZStr)
  14798. id_card_str := strings.Split(SFZStr, "^")
  14799. card_no := id_card_str[0]
  14800. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14801. //name := id_card_str[1]
  14802. //name = ConvertToString(name, "gbk", "utf-8")
  14803. 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)
  14804. var dat map[string]interface{}
  14805. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14806. fmt.Println(dat)
  14807. } else {
  14808. fmt.Println(err)
  14809. }
  14810. userJSONBytes, _ := json.Marshal(dat)
  14811. var res ResultTwo
  14812. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14813. utils.ErrorLog("解析失败:%v", err)
  14814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14815. return
  14816. }
  14817. if res.Infcode == 0 {
  14818. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14819. if err == gorm.ErrRecordNotFound {
  14820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14821. return
  14822. } else if err != nil {
  14823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14824. return
  14825. } else {
  14826. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14827. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14828. infoStr := string(Iinfos)
  14829. idetinfoStr := string(Idetinfos)
  14830. var rf []*ResultFive
  14831. json.Unmarshal([]byte(infoStr), &rf)
  14832. var insutypes []*ResultFive
  14833. var insutype string
  14834. var is390 int = 0
  14835. var is310 int = 0
  14836. for _, item := range rf {
  14837. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14838. insutypes = append(insutypes, item)
  14839. }
  14840. }
  14841. if len(insutypes) == 1 {
  14842. insutype = insutypes[0].Insutype
  14843. } else {
  14844. for _, i := range insutypes {
  14845. if i.Insutype == "390" {
  14846. is390 = 1
  14847. }
  14848. if i.Insutype == "310" {
  14849. is310 = 1
  14850. }
  14851. }
  14852. }
  14853. if is390 == 1 {
  14854. insutype = "390"
  14855. }
  14856. if is310 == 1 {
  14857. insutype = "310"
  14858. }
  14859. if len(insutypes) == 0 {
  14860. insutype = "310"
  14861. }
  14862. var InsuplcAdmdvs string
  14863. for _, item := range rf {
  14864. if item.Insutype == insutype {
  14865. InsuplcAdmdvs = item.InsuplcAdmdvs
  14866. }
  14867. }
  14868. psn := &models.HisPsn{
  14869. PsnNo: res.Output.Baseinfo.PsnNo,
  14870. PatientId: patient.ID,
  14871. Certno: res.Output.Baseinfo.Certno,
  14872. Gend: res.Output.Baseinfo.Gend,
  14873. Naty: res.Output.Baseinfo.Naty,
  14874. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14875. PsnName: res.Output.Baseinfo.PsnName,
  14876. Idetinfo: idetinfoStr,
  14877. Insuinfo: infoStr,
  14878. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14879. CardInfo: SFZStr,
  14880. VerifyNumber: "",
  14881. InsuplcAdmdvs: InsuplcAdmdvs,
  14882. }
  14883. service.CreateHisPsn(psn)
  14884. c.ServeSuccessJSON(map[string]interface{}{
  14885. "patient": patient,
  14886. "number": card_no,
  14887. "insutype": insutype,
  14888. })
  14889. }
  14890. } else {
  14891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14892. return
  14893. }
  14894. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14895. var res ResultTwo
  14896. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14897. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14898. "&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)
  14899. resp, requestErr := http.Get(api)
  14900. if requestErr != nil {
  14901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14902. return
  14903. }
  14904. body, ioErr := ioutil.ReadAll(resp.Body)
  14905. if ioErr != nil {
  14906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14908. return
  14909. }
  14910. var respJSON map[string]interface{}
  14911. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14914. return
  14915. }
  14916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14917. result, _ := json.Marshal(respJSON)
  14918. fmt.Println("log")
  14919. fmt.Println(string(result))
  14920. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14921. utils.ErrorLog("解析失败:%v", err)
  14922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14923. return
  14924. }
  14925. if res.Infcode == 0 {
  14926. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14927. if err == gorm.ErrRecordNotFound {
  14928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14929. return
  14930. } else if err != nil {
  14931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14932. return
  14933. } else {
  14934. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14935. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14936. infoStr := string(Iinfos)
  14937. idetinfoStr := string(Idetinfos)
  14938. psn := &models.HisPsn{
  14939. PsnNo: res.Output.Baseinfo.PsnNo,
  14940. PatientId: patient.ID,
  14941. Certno: res.Output.Baseinfo.Certno,
  14942. Gend: res.Output.Baseinfo.Gend,
  14943. Naty: res.Output.Baseinfo.Naty,
  14944. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14945. PsnName: res.Output.Baseinfo.PsnName,
  14946. Idetinfo: idetinfoStr,
  14947. Insuinfo: infoStr,
  14948. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14949. }
  14950. service.CreateHisPsn(psn)
  14951. c.ServeSuccessJSON(map[string]interface{}{
  14952. "patient": patient,
  14953. "number": res.Output.Baseinfo.Certno,
  14954. })
  14955. }
  14956. } else {
  14957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14958. return
  14959. }
  14960. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14961. var res ResultTwo
  14962. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14963. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14964. "&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)
  14965. resp, requestErr := http.Get(api)
  14966. if requestErr != nil {
  14967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14968. return
  14969. }
  14970. body, ioErr := ioutil.ReadAll(resp.Body)
  14971. if ioErr != nil {
  14972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14974. return
  14975. }
  14976. var respJSON map[string]interface{}
  14977. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14980. return
  14981. }
  14982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14983. result, _ := json.Marshal(respJSON)
  14984. fmt.Println("log")
  14985. fmt.Println(string(result))
  14986. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14987. utils.ErrorLog("解析失败:%v", err)
  14988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14989. return
  14990. }
  14991. if res.Infcode == 0 {
  14992. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14993. if err == gorm.ErrRecordNotFound {
  14994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14995. return
  14996. } else if err != nil {
  14997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14998. return
  14999. } else {
  15000. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15001. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15002. infoStr := string(Iinfos)
  15003. idetinfoStr := string(Idetinfos)
  15004. psn := &models.HisPsn{
  15005. PsnNo: res.Output.Baseinfo.PsnNo,
  15006. PatientId: patient.ID,
  15007. Certno: res.Output.Baseinfo.Certno,
  15008. Gend: res.Output.Baseinfo.Gend,
  15009. Naty: res.Output.Baseinfo.Naty,
  15010. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15011. PsnName: res.Output.Baseinfo.PsnName,
  15012. Idetinfo: idetinfoStr,
  15013. Insuinfo: infoStr,
  15014. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15015. }
  15016. service.CreateHisPsn(psn)
  15017. c.ServeSuccessJSON(map[string]interface{}{
  15018. "patient": patient,
  15019. "number": res.Output.Baseinfo.Certno,
  15020. })
  15021. }
  15022. } else {
  15023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15024. return
  15025. }
  15026. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15027. var res ResultTwo
  15028. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15029. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15030. "&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)
  15031. resp, requestErr := http.Get(api)
  15032. if requestErr != nil {
  15033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15034. return
  15035. }
  15036. body, ioErr := ioutil.ReadAll(resp.Body)
  15037. if ioErr != nil {
  15038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15040. return
  15041. }
  15042. var respJSON map[string]interface{}
  15043. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15046. return
  15047. }
  15048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15049. result, _ := json.Marshal(respJSON)
  15050. fmt.Println("log")
  15051. fmt.Println(string(result))
  15052. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15053. utils.ErrorLog("解析失败:%v", err)
  15054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15055. return
  15056. }
  15057. if res.Infcode == 0 {
  15058. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15059. if err == gorm.ErrRecordNotFound {
  15060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15061. return
  15062. } else if err != nil {
  15063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15064. return
  15065. } else {
  15066. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15067. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15068. infoStr := string(Iinfos)
  15069. idetinfoStr := string(Idetinfos)
  15070. var rf []*ResultFive
  15071. json.Unmarshal([]byte(infoStr), &rf)
  15072. var insutypes []*ResultFive
  15073. var insutype string
  15074. var is390 int = 0
  15075. var is310 int = 0
  15076. for _, item := range rf {
  15077. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15078. insutypes = append(insutypes, item)
  15079. }
  15080. }
  15081. if len(insutypes) == 1 {
  15082. insutype = insutypes[0].Insutype
  15083. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15084. } else {
  15085. for _, i := range insutypes {
  15086. if i.Insutype == "390" {
  15087. is390 = 1
  15088. }
  15089. if i.Insutype == "310" {
  15090. is310 = 1
  15091. }
  15092. }
  15093. }
  15094. if is390 == 1 {
  15095. insutype = "390"
  15096. }
  15097. if is310 == 1 {
  15098. insutype = "310"
  15099. }
  15100. if len(insutypes) == 0 {
  15101. insutype = "390"
  15102. }
  15103. var insuplc_admdvs string
  15104. for _, item := range rf {
  15105. if item.Insutype == insutype {
  15106. insuplc_admdvs = item.InsuplcAdmdvs
  15107. }
  15108. }
  15109. psn := &models.HisPsn{
  15110. PsnNo: res.Output.Baseinfo.PsnNo,
  15111. PatientId: patient.ID,
  15112. Certno: res.Output.Baseinfo.Certno,
  15113. Gend: res.Output.Baseinfo.Gend,
  15114. Naty: res.Output.Baseinfo.Naty,
  15115. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15116. PsnName: res.Output.Baseinfo.PsnName,
  15117. Idetinfo: idetinfoStr,
  15118. Insuinfo: infoStr,
  15119. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15120. InsuplcAdmdvs: insuplc_admdvs,
  15121. }
  15122. service.CreateHisPsn(psn)
  15123. c.ServeSuccessJSON(map[string]interface{}{
  15124. "patient": patient,
  15125. "number": res.Output.Baseinfo.Certno,
  15126. })
  15127. }
  15128. } else {
  15129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15130. return
  15131. }
  15132. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15133. res := c.GetoleInfo()
  15134. if res.Infcode == 0 {
  15135. var result string
  15136. if res.Output.MdtrtCertType == "01" {
  15137. 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)
  15138. } else if res.Output.MdtrtCertType == "02" {
  15139. 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)
  15140. } else if res.Output.MdtrtCertType == "03" {
  15141. 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)
  15142. }
  15143. var dat map[string]interface{}
  15144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15145. fmt.Println(dat)
  15146. } else {
  15147. fmt.Println(err)
  15148. }
  15149. userJSONBytes, _ := json.Marshal(dat)
  15150. var res2 ResultTwo
  15151. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15152. utils.ErrorLog("解析失败:%v", err)
  15153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15154. return
  15155. }
  15156. if res2.Infcode == 0 {
  15157. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15158. if err == gorm.ErrRecordNotFound {
  15159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15160. return
  15161. } else if err != nil {
  15162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15163. return
  15164. } else {
  15165. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15166. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15167. infoStr := string(Iinfos)
  15168. idetinfoStr := string(Idetinfos)
  15169. var rf []*ResultFive
  15170. json.Unmarshal([]byte(infoStr), &rf)
  15171. var insutypes []*ResultFive
  15172. var insutype string
  15173. var is390 int = 0
  15174. var is310 int = 0
  15175. //var insuplc_admdvs string
  15176. for _, item := range rf {
  15177. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15178. insutypes = append(insutypes, item)
  15179. }
  15180. }
  15181. if len(insutypes) == 1 {
  15182. insutype = insutypes[0].Insutype
  15183. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15184. } else {
  15185. for _, i := range insutypes {
  15186. if i.Insutype == "390" {
  15187. is390 = 1
  15188. }
  15189. if i.Insutype == "310" {
  15190. is310 = 1
  15191. }
  15192. }
  15193. }
  15194. if is390 == 1 {
  15195. insutype = "390"
  15196. }
  15197. if is310 == 1 {
  15198. insutype = "310"
  15199. }
  15200. if len(insutypes) == 0 {
  15201. insutype = "310"
  15202. }
  15203. psn := &models.HisPsn{
  15204. PsnNo: res2.Output.Baseinfo.PsnNo,
  15205. PatientId: patient.ID,
  15206. //Brdy: res2.Output.Baseinfo.Brdy,
  15207. Certno: res2.Output.Baseinfo.Certno,
  15208. Gend: res2.Output.Baseinfo.Gend,
  15209. Naty: res2.Output.Baseinfo.Naty,
  15210. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15211. PsnName: res2.Output.Baseinfo.PsnName,
  15212. Idetinfo: idetinfoStr,
  15213. Insuinfo: infoStr,
  15214. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15215. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15216. VerifyNumber: res.Output.EcToken,
  15217. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15218. }
  15219. service.CreateHisPsn(psn)
  15220. var balc float64
  15221. for _, item := range rf {
  15222. if item.Insutype == insutype {
  15223. balc = item.Balc
  15224. }
  15225. }
  15226. c.ServeSuccessJSON(map[string]interface{}{
  15227. "patient": patient,
  15228. "number": res.Output.CardNo,
  15229. "insutype": insutype,
  15230. "blac": balc,
  15231. "desc": idetinfoStr,
  15232. })
  15233. }
  15234. } else {
  15235. c.ServeSuccessJSON(map[string]interface{}{
  15236. "failed_code": -10,
  15237. "msg": res2.ErrMsg,
  15238. })
  15239. }
  15240. } else {
  15241. c.ServeSuccessJSON(map[string]interface{}{
  15242. "failed_code": -10,
  15243. "msg": res.ErrMsg,
  15244. })
  15245. }
  15246. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15247. var insuplc_admdvs string
  15248. if len(patient.InsuplcAdmdvs) > 0 {
  15249. insuplc_admdvs = patient.InsuplcAdmdvs
  15250. } else {
  15251. if len(insuplc_admdvs_str) > 0 {
  15252. insuplc_admdvs = insuplc_admdvs_str
  15253. } else {
  15254. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15255. }
  15256. }
  15257. //请求内网数据
  15258. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15259. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15260. "&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=" + ""
  15261. resp, requestErr := http.Get(api)
  15262. if requestErr != nil {
  15263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15264. return
  15265. }
  15266. body, ioErr := ioutil.ReadAll(resp.Body)
  15267. if ioErr != nil {
  15268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15270. return
  15271. }
  15272. var respJSON map[string]interface{}
  15273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15276. return
  15277. }
  15278. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15279. if status == "0" {
  15280. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15281. c.ServeSuccessJSON(map[string]interface{}{
  15282. "failed_code": -10,
  15283. "msg": err_msg,
  15284. })
  15285. return
  15286. }
  15287. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15288. var res ResultTwo
  15289. result, _ := json.Marshal(respJSON)
  15290. fmt.Println("log")
  15291. fmt.Println(string(result))
  15292. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15293. utils.ErrorLog("解析失败:%v", err)
  15294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15295. return
  15296. }
  15297. if res.Infcode == 0 {
  15298. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15299. if err == gorm.ErrRecordNotFound {
  15300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15301. return
  15302. } else if err != nil {
  15303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15304. return
  15305. } else {
  15306. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15307. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15308. infoStr := string(Iinfos)
  15309. idetinfoStr := string(Idetinfos)
  15310. psn := &models.HisPsn{
  15311. PsnNo: res.Output.Baseinfo.PsnNo,
  15312. PatientId: patient.ID,
  15313. Certno: res.Output.Baseinfo.Certno,
  15314. Gend: res.Output.Baseinfo.Gend,
  15315. Naty: res.Output.Baseinfo.Naty,
  15316. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15317. PsnName: res.Output.Baseinfo.PsnName,
  15318. Idetinfo: idetinfoStr,
  15319. Insuinfo: infoStr,
  15320. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15321. }
  15322. service.CreateHisPsn(psn)
  15323. var rf []*ResultFive
  15324. json.Unmarshal([]byte(infoStr), &rf)
  15325. var insutypes []*ResultFive
  15326. var is390 int = 0
  15327. var is310 int = 0
  15328. var insutype string
  15329. for _, item := range rf {
  15330. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15331. insutypes = append(insutypes, item)
  15332. }
  15333. }
  15334. if len(insutypes) == 1 {
  15335. insutype = insutypes[0].Insutype
  15336. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15337. } else {
  15338. for _, i := range insutypes {
  15339. if i.Insutype == "390" {
  15340. is390 = 1
  15341. }
  15342. if i.Insutype == "310" {
  15343. is310 = 1
  15344. }
  15345. }
  15346. }
  15347. if is390 == 1 {
  15348. insutype = "390"
  15349. }
  15350. if is310 == 1 {
  15351. insutype = "310"
  15352. }
  15353. if len(insutypes) == 0 {
  15354. insutype = "390"
  15355. }
  15356. c.ServeSuccessJSON(map[string]interface{}{
  15357. "patient": patient,
  15358. "insutype": insutype,
  15359. "number": res.Output.Baseinfo.Certno,
  15360. "info": res,
  15361. })
  15362. }
  15363. } else {
  15364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15365. return
  15366. }
  15367. } else {
  15368. SFZStr := c.GetSFZBaseInfo()
  15369. id_card_str := strings.Split(SFZStr, "^")
  15370. id_card_number := id_card_str[0]
  15371. card_sn := ""
  15372. 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)
  15373. var dat map[string]interface{}
  15374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15375. fmt.Println(dat)
  15376. } else {
  15377. fmt.Println(err)
  15378. }
  15379. userJSONBytes, _ := json.Marshal(dat)
  15380. var res ResultTwo
  15381. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15382. utils.ErrorLog("解析失败:%v", err)
  15383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15384. return
  15385. }
  15386. if res.Infcode == 0 {
  15387. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15388. if err == gorm.ErrRecordNotFound {
  15389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15390. return
  15391. } else if err != nil {
  15392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15393. return
  15394. } else {
  15395. c.ServeSuccessJSON(map[string]interface{}{
  15396. "patient": patient,
  15397. "number": id_card_number,
  15398. })
  15399. }
  15400. } else {
  15401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15402. return
  15403. }
  15404. }
  15405. break
  15406. case 3:
  15407. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15408. var api string
  15409. if miConfig.MdtrtareaAdmvs == "320921" {
  15410. 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 +
  15411. "&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
  15412. fmt.Println(api)
  15413. } else {
  15414. 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 +
  15415. "&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)
  15416. }
  15417. resp, requestErr := http.Get(api)
  15418. if requestErr != nil {
  15419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15420. return
  15421. }
  15422. body, ioErr := ioutil.ReadAll(resp.Body)
  15423. if ioErr != nil {
  15424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15426. return
  15427. }
  15428. var respJSON map[string]interface{}
  15429. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15432. return
  15433. }
  15434. var status string
  15435. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15436. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15437. var token string
  15438. var res ResultTwo //1101结果
  15439. var res10265 ResultTwo10265 //1101结果
  15440. var card_info string //卡信息
  15441. var busi_card_info string
  15442. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15443. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15444. if status == "0" { //读卡成功
  15445. if card_type == "1" {
  15446. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15447. result, _ := json.Marshal(respJSON)
  15448. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15449. utils.ErrorLog("解析失败:%v", err)
  15450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15451. return
  15452. }
  15453. res.ErrMsg = res10265.ErrMsg
  15454. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15455. res.Infcode = infocode
  15456. res.Output = res10265.Output
  15457. res.InfRefmsgid = res10265.InfRefmsgid
  15458. } else {
  15459. //var card_info string //卡信息
  15460. //var busi_card_info string
  15461. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15462. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15463. //fmt.Println(card_info)
  15464. //fmt.Println(busi_card_info)
  15465. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15466. result, _ := json.Marshal(respJSON)
  15467. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15468. utils.ErrorLog("解析失败:%v", err)
  15469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15470. return
  15471. }
  15472. res.ErrMsg = res10265.ErrMsg
  15473. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15474. res.Infcode = infocode
  15475. res.Output = res10265.Output
  15476. res.InfRefmsgid = res10265.InfRefmsgid
  15477. }
  15478. if res.Infcode == 0 {
  15479. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15480. if err == gorm.ErrRecordNotFound {
  15481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15482. return
  15483. } else if err != nil {
  15484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15485. return
  15486. } else {
  15487. if card_type == "1" {
  15488. bas := strings.Split(card_info, "|")
  15489. basNumber := bas[2]
  15490. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15491. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15492. infoStr := string(Iinfos)
  15493. idetinfoStr := string(Idetinfos)
  15494. psn := &models.HisPsn{
  15495. PsnNo: res.Output.Baseinfo.PsnNo,
  15496. PatientId: patient.ID,
  15497. Certno: res.Output.Baseinfo.Certno,
  15498. //Brdy: res.Output.Baseinfo.Brdy,
  15499. Gend: res.Output.Baseinfo.Gend,
  15500. Naty: res.Output.Baseinfo.Naty,
  15501. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15502. PsnName: res.Output.Baseinfo.PsnName,
  15503. Idetinfo: idetinfoStr,
  15504. Insuinfo: infoStr,
  15505. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15506. CardInfo: card_info,
  15507. VerifyNumber: busi_card_info,
  15508. }
  15509. service.CreateHisPsn(psn)
  15510. c.ServeSuccessJSON(map[string]interface{}{
  15511. "patient": patient,
  15512. "number": basNumber,
  15513. })
  15514. } else {
  15515. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15516. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15517. infoStr := string(Iinfos)
  15518. idetinfoStr := string(Idetinfos)
  15519. psn := &models.HisPsn{
  15520. PsnNo: res.Output.Baseinfo.PsnNo,
  15521. PatientId: patient.ID,
  15522. Certno: res.Output.Baseinfo.Certno,
  15523. Gend: res.Output.Baseinfo.Gend,
  15524. Naty: res.Output.Baseinfo.Naty,
  15525. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15526. PsnName: res.Output.Baseinfo.PsnName,
  15527. Idetinfo: idetinfoStr,
  15528. Insuinfo: infoStr,
  15529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15530. CardInfo: card_info,
  15531. VerifyNumber: token,
  15532. }
  15533. service.CreateHisPsn(psn)
  15534. var rf []*ResultFive
  15535. json.Unmarshal([]byte(infoStr), &rf)
  15536. var insutypes []*ResultFive
  15537. var insutype string
  15538. var is390 int = 0
  15539. var is310 int = 0
  15540. for _, item := range rf {
  15541. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15542. insutypes = append(insutypes, item)
  15543. }
  15544. }
  15545. if len(insutypes) == 1 {
  15546. insutype = insutypes[0].Insutype
  15547. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15548. } else {
  15549. for _, i := range insutypes {
  15550. if i.Insutype == "390" {
  15551. is390 = 1
  15552. }
  15553. if i.Insutype == "310" {
  15554. is310 = 1
  15555. }
  15556. }
  15557. }
  15558. if is390 == 1 {
  15559. insutype = "390"
  15560. }
  15561. if is310 == 1 {
  15562. insutype = "310"
  15563. }
  15564. if len(insutypes) == 0 {
  15565. insutype = "310"
  15566. }
  15567. c.ServeSuccessJSON(map[string]interface{}{
  15568. "patient": patient,
  15569. "number": token,
  15570. "insutype": insutype,
  15571. })
  15572. }
  15573. }
  15574. } else {
  15575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15576. return
  15577. }
  15578. } else { //读卡失败
  15579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15580. return
  15581. }
  15582. }
  15583. break
  15584. case 4:
  15585. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15586. var api string
  15587. if miConfig.MdtrtareaAdmvs == "320921" {
  15588. 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 +
  15589. "&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
  15590. fmt.Println(api)
  15591. } else {
  15592. 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 +
  15593. "&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)
  15594. }
  15595. resp, requestErr := http.Get(api)
  15596. if requestErr != nil {
  15597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15598. return
  15599. }
  15600. body, ioErr := ioutil.ReadAll(resp.Body)
  15601. if ioErr != nil {
  15602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15604. return
  15605. }
  15606. var respJSON map[string]interface{}
  15607. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15610. return
  15611. }
  15612. var status string
  15613. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15614. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15615. var token string
  15616. var res ResultTwo //1101结果
  15617. var res10265 ResultTwo10265 //1101结果
  15618. if status == "0" { //读卡成功
  15619. var card_info string //卡信息
  15620. var busi_card_info string
  15621. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15622. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15623. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15624. fmt.Println(card_info)
  15625. fmt.Println(busi_card_info)
  15626. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15627. result, _ := json.Marshal(respJSON)
  15628. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15629. utils.ErrorLog("解析失败:%v", err)
  15630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15631. return
  15632. }
  15633. res.ErrMsg = res10265.ErrMsg
  15634. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15635. res.Infcode = infocode
  15636. res.Output = res10265.Output
  15637. res.InfRefmsgid = res10265.InfRefmsgid
  15638. if res.Infcode == 0 {
  15639. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15640. if err == gorm.ErrRecordNotFound {
  15641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15642. return
  15643. } else if err != nil {
  15644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15645. return
  15646. } else {
  15647. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15648. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15649. infoStr := string(Iinfos)
  15650. idetinfoStr := string(Idetinfos)
  15651. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15652. psn := &models.HisPsn{
  15653. PsnNo: res.Output.Baseinfo.PsnNo,
  15654. PatientId: patient.ID,
  15655. Certno: res.Output.Baseinfo.Certno,
  15656. Brdy: b,
  15657. Age: float64(age),
  15658. //Brdy: res.Output.Baseinfo.Brdy,
  15659. Gend: res.Output.Baseinfo.Gend,
  15660. Naty: res.Output.Baseinfo.Naty,
  15661. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15662. PsnName: res.Output.Baseinfo.PsnName,
  15663. Idetinfo: idetinfoStr,
  15664. Insuinfo: infoStr,
  15665. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15666. CardInfo: card_info,
  15667. VerifyNumber: token,
  15668. }
  15669. var rf []*ResultFive
  15670. json.Unmarshal([]byte(infoStr), &rf)
  15671. var insutypes []*ResultFive
  15672. var insutype string
  15673. var is390 int = 0
  15674. var is310 int = 0
  15675. for _, item := range rf {
  15676. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15677. insutypes = append(insutypes, item)
  15678. }
  15679. }
  15680. if len(insutypes) == 1 {
  15681. insutype = insutypes[0].Insutype
  15682. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15683. } else {
  15684. for _, i := range insutypes {
  15685. if i.Insutype == "390" {
  15686. is390 = 1
  15687. }
  15688. if i.Insutype == "310" {
  15689. is310 = 1
  15690. }
  15691. }
  15692. }
  15693. if is390 == 1 {
  15694. insutype = "390"
  15695. }
  15696. if is310 == 1 {
  15697. insutype = "310"
  15698. }
  15699. if len(insutypes) == 0 {
  15700. insutype = "310"
  15701. }
  15702. service.CreateHisPsn(psn)
  15703. c.ServeSuccessJSON(map[string]interface{}{
  15704. "patient": patient,
  15705. "number": token,
  15706. "insutype": insutype,
  15707. })
  15708. }
  15709. } else {
  15710. c.ServeSuccessJSON(map[string]interface{}{
  15711. "failed_code": -10,
  15712. "msg": res.ErrMsg,
  15713. })
  15714. }
  15715. } else { //读卡失败
  15716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15717. return
  15718. }
  15719. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15720. var api string
  15721. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15722. "&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
  15723. resp, requestErr := http.Get(api)
  15724. if requestErr != nil {
  15725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15726. return
  15727. }
  15728. body, ioErr := ioutil.ReadAll(resp.Body)
  15729. if ioErr != nil {
  15730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15732. return
  15733. }
  15734. var respJSON map[string]interface{}
  15735. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15738. return
  15739. }
  15740. var status string
  15741. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15742. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15743. var token string
  15744. var res ResultTwo //1101结果
  15745. if status == "1" { //读卡成功
  15746. var card_info string //卡信息
  15747. var busi_card_info string
  15748. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15749. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15750. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15751. fmt.Println(card_info)
  15752. fmt.Println(busi_card_info)
  15753. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15754. result, _ := json.Marshal(respJSON)
  15755. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15756. utils.ErrorLog("解析失败:%v", err)
  15757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15758. return
  15759. }
  15760. if res.Infcode == 0 {
  15761. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15762. if err == gorm.ErrRecordNotFound {
  15763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15764. return
  15765. } else if err != nil {
  15766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15767. return
  15768. } else {
  15769. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15770. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15771. infoStr := string(Iinfos)
  15772. idetinfoStr := string(Idetinfos)
  15773. psn := &models.HisPsn{
  15774. PsnNo: res.Output.Baseinfo.PsnNo,
  15775. PatientId: patient.ID,
  15776. Certno: res.Output.Baseinfo.Certno,
  15777. Gend: res.Output.Baseinfo.Gend,
  15778. Naty: res.Output.Baseinfo.Naty,
  15779. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15780. PsnName: res.Output.Baseinfo.PsnName,
  15781. Idetinfo: idetinfoStr,
  15782. Insuinfo: infoStr,
  15783. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15784. CardInfo: card_info,
  15785. VerifyNumber: token,
  15786. }
  15787. var rf []*ResultFive
  15788. json.Unmarshal([]byte(infoStr), &rf)
  15789. var insutypes []*ResultFive
  15790. var insutype string
  15791. var is390 int = 0
  15792. var is310 int = 0
  15793. for _, item := range rf {
  15794. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15795. insutypes = append(insutypes, item)
  15796. }
  15797. }
  15798. if len(insutypes) == 1 {
  15799. insutype = insutypes[0].Insutype
  15800. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15801. } else {
  15802. for _, i := range insutypes {
  15803. if i.Insutype == "390" {
  15804. is390 = 1
  15805. }
  15806. if i.Insutype == "310" {
  15807. is310 = 1
  15808. }
  15809. }
  15810. }
  15811. if is390 == 1 {
  15812. insutype = "390"
  15813. }
  15814. if is310 == 1 {
  15815. insutype = "310"
  15816. }
  15817. if len(insutypes) == 0 {
  15818. insutype = "310"
  15819. }
  15820. service.CreateHisPsn(psn)
  15821. c.ServeSuccessJSON(map[string]interface{}{
  15822. "patient": patient,
  15823. "number": token,
  15824. "insutype": insutype,
  15825. })
  15826. }
  15827. } else {
  15828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15829. return
  15830. }
  15831. } else { //读卡失败
  15832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15833. return
  15834. }
  15835. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15836. var api string
  15837. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15838. "&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
  15839. resp, requestErr := http.Get(api)
  15840. if requestErr != nil {
  15841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15842. return
  15843. }
  15844. body, ioErr := ioutil.ReadAll(resp.Body)
  15845. if ioErr != nil {
  15846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15848. return
  15849. }
  15850. var respJSON map[string]interface{}
  15851. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15854. return
  15855. }
  15856. var status string
  15857. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15858. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15859. var token string
  15860. var res ResultTwo //1101结果
  15861. if status == "1" { //读卡成功
  15862. var card_info string //卡信息
  15863. var busi_card_info string
  15864. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15865. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15866. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15867. fmt.Println(card_info)
  15868. fmt.Println(busi_card_info)
  15869. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15870. result, _ := json.Marshal(respJSON)
  15871. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15872. utils.ErrorLog("解析失败:%v", err)
  15873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15874. return
  15875. }
  15876. if res.Infcode == 0 {
  15877. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15878. if err == gorm.ErrRecordNotFound {
  15879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15880. return
  15881. } else if err != nil {
  15882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15883. return
  15884. } else {
  15885. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15886. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15887. infoStr := string(Iinfos)
  15888. idetinfoStr := string(Idetinfos)
  15889. psn := &models.HisPsn{
  15890. PsnNo: res.Output.Baseinfo.PsnNo,
  15891. PatientId: patient.ID,
  15892. Certno: res.Output.Baseinfo.Certno,
  15893. Gend: res.Output.Baseinfo.Gend,
  15894. Naty: res.Output.Baseinfo.Naty,
  15895. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15896. PsnName: res.Output.Baseinfo.PsnName,
  15897. Idetinfo: idetinfoStr,
  15898. Insuinfo: infoStr,
  15899. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15900. CardInfo: card_info,
  15901. VerifyNumber: token,
  15902. }
  15903. var rf []*ResultFive
  15904. json.Unmarshal([]byte(infoStr), &rf)
  15905. var insutypes []*ResultFive
  15906. var insutype string
  15907. var is390 int = 0
  15908. var is310 int = 0
  15909. for _, item := range rf {
  15910. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15911. insutypes = append(insutypes, item)
  15912. }
  15913. }
  15914. if len(insutypes) == 1 {
  15915. insutype = insutypes[0].Insutype
  15916. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15917. } else {
  15918. for _, i := range insutypes {
  15919. if i.Insutype == "390" {
  15920. is390 = 1
  15921. }
  15922. if i.Insutype == "310" {
  15923. is310 = 1
  15924. }
  15925. }
  15926. }
  15927. if is390 == 1 {
  15928. insutype = "390"
  15929. }
  15930. if is310 == 1 {
  15931. insutype = "310"
  15932. }
  15933. if len(insutypes) == 0 {
  15934. insutype = "310"
  15935. }
  15936. service.CreateHisPsn(psn)
  15937. c.ServeSuccessJSON(map[string]interface{}{
  15938. "patient": patient,
  15939. "number": token,
  15940. "insutype": insutype,
  15941. })
  15942. }
  15943. } else {
  15944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15945. return
  15946. }
  15947. } else { //读卡失败
  15948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15949. return
  15950. }
  15951. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15952. //idNo := c.GetString("idNo")
  15953. //userName := c.GetString("userName")
  15954. //ecToken := c.GetString("ecToken")
  15955. //insuOrg := c.GetString("insuOrg")
  15956. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15957. utils.ErrorLog("解析失败:%v", json_result)
  15958. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15959. type ELeData struct {
  15960. Data struct {
  15961. IdNo string `json:"idNo"`
  15962. IdType string `json:"idType"`
  15963. UserName string `json:"userName"`
  15964. EcToken string `json:"ecToken"`
  15965. InsuOrg string `json:"insuOrg"`
  15966. Gender string `json:"gender"`
  15967. Birthday string `json:"birthday"`
  15968. Nationality string `json:"nationality"`
  15969. Email string `json:"email"`
  15970. Extra string `json:"extra"`
  15971. } `json:"data"`
  15972. Code int `json:"code"`
  15973. Message string `json:"message"`
  15974. }
  15975. var ele ELeData
  15976. err := json.Unmarshal([]byte(json_result), &ele)
  15977. if err != nil {
  15978. utils.ErrorLog("解析失败:%v", err)
  15979. }
  15980. token := ele.Data.EcToken
  15981. token = Remove0000(token)
  15982. 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)
  15983. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15984. var res ResultTwo
  15985. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15986. utils.ErrorLog("解析失败:%v", err)
  15987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15988. return
  15989. }
  15990. if res.Infcode == 0 {
  15991. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15992. if err == gorm.ErrRecordNotFound {
  15993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15994. return
  15995. } else if err != nil {
  15996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15997. return
  15998. } else {
  15999. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16000. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16001. infoStr := string(Iinfos)
  16002. idetinfoStr := string(Idetinfos)
  16003. psn := &models.HisPsn{
  16004. PsnNo: res.Output.Baseinfo.PsnNo,
  16005. PatientId: patient.ID,
  16006. Certno: res.Output.Baseinfo.Certno,
  16007. Gend: res.Output.Baseinfo.Gend,
  16008. Naty: res.Output.Baseinfo.Naty,
  16009. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16010. PsnName: res.Output.Baseinfo.PsnName,
  16011. Idetinfo: idetinfoStr,
  16012. Insuinfo: infoStr,
  16013. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16014. CardInfo: "",
  16015. Stage: "1",
  16016. VerifyNumber: token,
  16017. InsuplcAdmdvs: ele.Data.InsuOrg,
  16018. }
  16019. service.CreateHisPsn(psn)
  16020. var rf []*ResultFive
  16021. json.Unmarshal([]byte(infoStr), &rf)
  16022. var insutypes []*ResultFive
  16023. var insutype string
  16024. var is390 int = 0
  16025. var is310 int = 0
  16026. for _, item := range rf {
  16027. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16028. insutypes = append(insutypes, item)
  16029. }
  16030. }
  16031. if len(insutypes) == 1 {
  16032. insutype = insutypes[0].Insutype
  16033. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16034. } else {
  16035. for _, i := range insutypes {
  16036. if i.Insutype == "390" {
  16037. is390 = 1
  16038. }
  16039. if i.Insutype == "310" {
  16040. is310 = 1
  16041. }
  16042. }
  16043. }
  16044. if is390 == 1 {
  16045. insutype = "390"
  16046. }
  16047. if is310 == 1 {
  16048. insutype = "310"
  16049. }
  16050. if len(insutypes) == 0 {
  16051. insutype = "310"
  16052. }
  16053. c.ServeSuccessJSON(map[string]interface{}{
  16054. "patient": patient,
  16055. "number": token,
  16056. "insutype": insutype,
  16057. })
  16058. }
  16059. } else {
  16060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16061. return
  16062. }
  16063. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16064. //if initFlag == 0 {
  16065. //c.TestGetJiangXiBasBaseInit()
  16066. //}
  16067. //if initEleFlag == 0 {
  16068. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16069. //}
  16070. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16071. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16072. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16073. type ELeData struct {
  16074. Data struct {
  16075. IdNo string `json:"idNo"`
  16076. IdType string `json:"idType"`
  16077. UserName string `json:"userName"`
  16078. EcToken string `json:"ecToken"`
  16079. InsuOrg string `json:"insuOrg"`
  16080. Gender string `json:"gender"`
  16081. Birthday string `json:"birthday"`
  16082. Nationality string `json:"nationality"`
  16083. Email string `json:"email"`
  16084. Extra string `json:"extra"`
  16085. } `json:"data"`
  16086. Code int `json:"code"`
  16087. Message string `json:"message"`
  16088. }
  16089. var ele ELeData
  16090. err := json.Unmarshal([]byte(result), &ele)
  16091. if err != nil {
  16092. utils.ErrorLog("解析失败:%v", err)
  16093. }
  16094. token := ele.Data.EcToken
  16095. token = Remove0000(token)
  16096. 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)
  16097. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16098. var res ResultTwo
  16099. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16100. utils.ErrorLog("解析失败:%v", err)
  16101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16102. return
  16103. }
  16104. if res.Infcode == 0 {
  16105. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16106. if err == gorm.ErrRecordNotFound {
  16107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16108. return
  16109. } else if err != nil {
  16110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16111. return
  16112. } else {
  16113. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16114. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16115. infoStr := string(Iinfos)
  16116. idetinfoStr := string(Idetinfos)
  16117. psn := &models.HisPsn{
  16118. PsnNo: res.Output.Baseinfo.PsnNo,
  16119. PatientId: patient.ID,
  16120. Certno: res.Output.Baseinfo.Certno,
  16121. Gend: res.Output.Baseinfo.Gend,
  16122. Naty: res.Output.Baseinfo.Naty,
  16123. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16124. PsnName: res.Output.Baseinfo.PsnName,
  16125. Idetinfo: idetinfoStr,
  16126. Insuinfo: infoStr,
  16127. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16128. CardInfo: "",
  16129. VerifyNumber: token,
  16130. InsuplcAdmdvs: ele.Data.InsuOrg,
  16131. }
  16132. service.CreateHisPsn(psn)
  16133. var rf []*ResultFive
  16134. json.Unmarshal([]byte(infoStr), &rf)
  16135. var insutypes []*ResultFive
  16136. var insutype string
  16137. var is390 int = 0
  16138. var is310 int = 0
  16139. for _, item := range rf {
  16140. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16141. insutypes = append(insutypes, item)
  16142. }
  16143. }
  16144. if len(insutypes) == 1 {
  16145. insutype = insutypes[0].Insutype
  16146. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16147. } else {
  16148. for _, i := range insutypes {
  16149. if i.Insutype == "390" {
  16150. is390 = 1
  16151. }
  16152. if i.Insutype == "310" {
  16153. is310 = 1
  16154. }
  16155. }
  16156. }
  16157. if is390 == 1 {
  16158. insutype = "390"
  16159. }
  16160. if is310 == 1 {
  16161. insutype = "310"
  16162. }
  16163. if len(insutypes) == 0 {
  16164. insutype = "310"
  16165. }
  16166. c.ServeSuccessJSON(map[string]interface{}{
  16167. "patient": patient,
  16168. "number": token,
  16169. "insutype": insutype,
  16170. })
  16171. }
  16172. } else {
  16173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16174. return
  16175. }
  16176. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16177. //if initFlag == 0 {
  16178. //c.TestGetJiangXiBasBaseInit()
  16179. //}
  16180. //if initEleFlag == 0 {
  16181. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16182. //}
  16183. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16184. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16185. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16186. type ELeData struct {
  16187. Data struct {
  16188. IdNo string `json:"idNo"`
  16189. IdType string `json:"idType"`
  16190. UserName string `json:"userName"`
  16191. EcToken string `json:"ecToken"`
  16192. InsuOrg string `json:"insuOrg"`
  16193. Gender string `json:"gender"`
  16194. Birthday string `json:"birthday"`
  16195. Nationality string `json:"nationality"`
  16196. Email string `json:"email"`
  16197. Extra string `json:"extra"`
  16198. } `json:"data"`
  16199. Code int `json:"code"`
  16200. Message string `json:"message"`
  16201. }
  16202. var ele ELeData
  16203. err := json.Unmarshal([]byte(result), &ele)
  16204. if err != nil {
  16205. utils.ErrorLog("解析失败:%v", err)
  16206. }
  16207. token := ele.Data.EcToken
  16208. token = Remove0000(token)
  16209. 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)
  16210. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16211. var res ResultTwo
  16212. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16213. utils.ErrorLog("解析失败:%v", err)
  16214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16215. return
  16216. }
  16217. if res.Infcode == 0 {
  16218. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16219. if err == gorm.ErrRecordNotFound {
  16220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16221. return
  16222. } else if err != nil {
  16223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16224. return
  16225. } else {
  16226. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16227. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16228. infoStr := string(Iinfos)
  16229. idetinfoStr := string(Idetinfos)
  16230. psn := &models.HisPsn{
  16231. PsnNo: res.Output.Baseinfo.PsnNo,
  16232. PatientId: patient.ID,
  16233. Certno: res.Output.Baseinfo.Certno,
  16234. Gend: res.Output.Baseinfo.Gend,
  16235. Naty: res.Output.Baseinfo.Naty,
  16236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16237. PsnName: res.Output.Baseinfo.PsnName,
  16238. Idetinfo: idetinfoStr,
  16239. Insuinfo: infoStr,
  16240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16241. CardInfo: "",
  16242. VerifyNumber: token,
  16243. InsuplcAdmdvs: ele.Data.InsuOrg,
  16244. }
  16245. service.CreateHisPsn(psn)
  16246. var rf []*ResultFive
  16247. json.Unmarshal([]byte(infoStr), &rf)
  16248. var insutypes []*ResultFive
  16249. var insutype string
  16250. var is390 int = 0
  16251. var is310 int = 0
  16252. for _, item := range rf {
  16253. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16254. insutypes = append(insutypes, item)
  16255. }
  16256. }
  16257. if len(insutypes) == 1 {
  16258. insutype = insutypes[0].Insutype
  16259. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16260. } else {
  16261. for _, i := range insutypes {
  16262. if i.Insutype == "390" {
  16263. is390 = 1
  16264. }
  16265. if i.Insutype == "310" {
  16266. is310 = 1
  16267. }
  16268. }
  16269. }
  16270. if is390 == 1 {
  16271. insutype = "390"
  16272. }
  16273. if is310 == 1 {
  16274. insutype = "310"
  16275. }
  16276. if len(insutypes) == 0 {
  16277. insutype = "310"
  16278. }
  16279. c.ServeSuccessJSON(map[string]interface{}{
  16280. "patient": patient,
  16281. "number": token,
  16282. "insutype": insutype,
  16283. })
  16284. }
  16285. } else {
  16286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16287. return
  16288. }
  16289. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16290. //if initFlag == 0 {
  16291. c.TestGetJiangXiBasBaseInit()
  16292. //}
  16293. //if initEleFlag == 0 {
  16294. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16295. //}
  16296. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16297. type ELeData struct {
  16298. Data struct {
  16299. IdNo string `json:"idNo"`
  16300. IdType string `json:"idType"`
  16301. UserName string `json:"userName"`
  16302. EcToken string `json:"ecToken"`
  16303. InsuOrg string `json:"insuOrg"`
  16304. Gender string `json:"gender"`
  16305. Birthday string `json:"birthday"`
  16306. Nationality string `json:"nationality"`
  16307. Email string `json:"email"`
  16308. Extra string `json:"extra"`
  16309. } `json:"data"`
  16310. Code int `json:"code"`
  16311. Message string `json:"message"`
  16312. }
  16313. var ele ELeData
  16314. err := json.Unmarshal([]byte(json_result), &ele)
  16315. if err != nil {
  16316. utils.ErrorLog("解析失败:%v", err)
  16317. }
  16318. token := ele.Data.EcToken
  16319. token = Remove0000(token)
  16320. 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)
  16321. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16322. var res ResultTwo
  16323. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16324. utils.ErrorLog("解析失败:%v", err)
  16325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16326. return
  16327. }
  16328. if res.Infcode == 0 {
  16329. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16330. if err == gorm.ErrRecordNotFound {
  16331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16332. return
  16333. } else if err != nil {
  16334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16335. return
  16336. } else {
  16337. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16338. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16339. infoStr := string(Iinfos)
  16340. idetinfoStr := string(Idetinfos)
  16341. psn := &models.HisPsn{
  16342. PsnNo: res.Output.Baseinfo.PsnNo,
  16343. PatientId: patient.ID,
  16344. Certno: res.Output.Baseinfo.Certno,
  16345. Gend: res.Output.Baseinfo.Gend,
  16346. Naty: res.Output.Baseinfo.Naty,
  16347. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16348. PsnName: res.Output.Baseinfo.PsnName,
  16349. Idetinfo: idetinfoStr,
  16350. Insuinfo: infoStr,
  16351. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16352. CardInfo: "",
  16353. VerifyNumber: token,
  16354. }
  16355. service.CreateHisPsn(psn)
  16356. var rf []*ResultFive
  16357. json.Unmarshal([]byte(infoStr), &rf)
  16358. var insutypes []*ResultFive
  16359. var insutype string
  16360. var is390 int = 0
  16361. var is310 int = 0
  16362. for _, item := range rf {
  16363. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16364. insutypes = append(insutypes, item)
  16365. }
  16366. }
  16367. if len(insutypes) == 1 {
  16368. insutype = insutypes[0].Insutype
  16369. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16370. } else {
  16371. for _, i := range insutypes {
  16372. if i.Insutype == "390" {
  16373. is390 = 1
  16374. }
  16375. if i.Insutype == "310" {
  16376. is310 = 1
  16377. }
  16378. }
  16379. }
  16380. if is390 == 1 {
  16381. insutype = "390"
  16382. }
  16383. if is310 == 1 {
  16384. insutype = "310"
  16385. }
  16386. if len(insutypes) == 0 {
  16387. insutype = "310"
  16388. }
  16389. c.ServeSuccessJSON(map[string]interface{}{
  16390. "patient": patient,
  16391. "number": token,
  16392. "insutype": insutype,
  16393. })
  16394. }
  16395. } else {
  16396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16397. return
  16398. }
  16399. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16400. type ELeData struct {
  16401. Code string `json:"code"`
  16402. Data struct {
  16403. Aac002 string `json:"aac002"`
  16404. Aaz500 string `json:"aaz500"`
  16405. ActCardNo string `json:"actCardNo"`
  16406. Bab520 string `json:"bab520"`
  16407. Bkz543 string `json:"bkz543"`
  16408. BusinessType string `json:"businessType"`
  16409. CertfCodg string `json:"certfCodg"`
  16410. EcIndexNo string `json:"ecIndexNo"`
  16411. EcToken string `json:"ecToken"`
  16412. ID0000 string `json:"id0000"`
  16413. IDNo string `json:"idNo"`
  16414. IDType string `json:"idType"`
  16415. Idcode string `json:"idcode"`
  16416. IdentityToken string `json:"identity_token"`
  16417. InsuOrg string `json:"insuOrg"`
  16418. OfficeID string `json:"officeId"`
  16419. OfficeName string `json:"officeName"`
  16420. OperatorID string `json:"operatorId"`
  16421. OperatorName string `json:"operatorName"`
  16422. OrgID string `json:"orgId"`
  16423. UserName string `json:"userName"`
  16424. } `json:"data"`
  16425. Infno interface{} `json:"infno"`
  16426. Message string `json:"message"`
  16427. OrgID string `json:"orgId"`
  16428. TransType string `json:"transType"`
  16429. }
  16430. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16431. outPutInfo = Remove0000(outPutInfo)
  16432. if len(outPutInfo) > 0 {
  16433. var ele ELeData
  16434. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16435. if err != nil {
  16436. utils.ErrorLog("解析失败:%v", err)
  16437. }
  16438. token := ele.Data.EcToken
  16439. fmt.Println(inputInfo)
  16440. fmt.Println(outPutInfo)
  16441. 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)
  16442. saveLog(result, requestLog, "1101", "获取人员信息")
  16443. var dat map[string]interface{}
  16444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16445. fmt.Println(dat)
  16446. } else {
  16447. fmt.Println(err)
  16448. }
  16449. userJSONBytes, _ := json.Marshal(dat)
  16450. var res ResultTwo
  16451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16452. utils.ErrorLog("解析失败:%v", err)
  16453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16454. return
  16455. }
  16456. res.ErrMsg = errMsgLog
  16457. if res.Infcode == 0 {
  16458. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16459. if err == gorm.ErrRecordNotFound {
  16460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16461. return
  16462. } else if err != nil {
  16463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16464. return
  16465. } else {
  16466. fmt.Println(res)
  16467. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16468. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16469. infoStr := string(Iinfos)
  16470. idetinfoStr := string(Idetinfos)
  16471. psn := &models.HisPsn{
  16472. PsnNo: res.Output.Baseinfo.PsnNo,
  16473. PatientId: patient.ID,
  16474. Certno: res.Output.Baseinfo.Certno,
  16475. Gend: res.Output.Baseinfo.Gend,
  16476. Naty: res.Output.Baseinfo.Naty,
  16477. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16478. PsnName: res.Output.Baseinfo.PsnName,
  16479. Idetinfo: idetinfoStr,
  16480. Insuinfo: infoStr,
  16481. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16482. CardInfo: outPutInfo,
  16483. VerifyNumber: token,
  16484. InsuplcAdmdvs: ele.Data.InsuOrg,
  16485. }
  16486. service.CreateHisPsn(psn)
  16487. var rf []*ResultFive
  16488. json.Unmarshal([]byte(infoStr), &rf)
  16489. var insutypes []*ResultFive
  16490. var insutype string
  16491. var is390 int = 0
  16492. var is310 int = 0
  16493. for _, item := range rf {
  16494. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16495. insutypes = append(insutypes, item)
  16496. }
  16497. }
  16498. if len(insutypes) == 1 {
  16499. insutype = insutypes[0].Insutype
  16500. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16501. } else {
  16502. for _, i := range insutypes {
  16503. if i.Insutype == "390" {
  16504. is390 = 1
  16505. }
  16506. if i.Insutype == "310" {
  16507. is310 = 1
  16508. }
  16509. }
  16510. }
  16511. if is390 == 1 {
  16512. insutype = "390"
  16513. }
  16514. if is310 == 1 {
  16515. insutype = "310"
  16516. }
  16517. if len(insutypes) == 0 {
  16518. insutype = "310"
  16519. }
  16520. c.ServeSuccessJSON(map[string]interface{}{
  16521. "patient": patient,
  16522. "number": token,
  16523. "insutype": insutype,
  16524. })
  16525. }
  16526. } else {
  16527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16528. return
  16529. }
  16530. }
  16531. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16532. var api string
  16533. 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 +
  16534. "&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
  16535. resp, requestErr := http.Get(api)
  16536. if requestErr != nil {
  16537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16538. return
  16539. }
  16540. body, ioErr := ioutil.ReadAll(resp.Body)
  16541. if ioErr != nil {
  16542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16544. return
  16545. }
  16546. var respJSON map[string]interface{}
  16547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16550. return
  16551. }
  16552. var status string
  16553. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16554. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16555. var token string
  16556. var res ResultTwo //1101结果
  16557. var res10265 ResultTwo10265 //1101结果
  16558. if status == "0" { //读卡成功
  16559. var card_info string //卡信息
  16560. var busi_card_info string
  16561. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16562. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16563. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16564. fmt.Println(card_info)
  16565. fmt.Println(busi_card_info)
  16566. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16567. result, _ := json.Marshal(respJSON)
  16568. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16569. utils.ErrorLog("解析失败:%v", err)
  16570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16571. return
  16572. }
  16573. res.ErrMsg = res10265.ErrMsg
  16574. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16575. res.Infcode = infocode
  16576. res.Output = res10265.Output
  16577. res.InfRefmsgid = res10265.InfRefmsgid
  16578. if res.Infcode == 0 {
  16579. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16580. if err == gorm.ErrRecordNotFound {
  16581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16582. return
  16583. } else if err != nil {
  16584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16585. return
  16586. } else {
  16587. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16588. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16589. infoStr := string(Iinfos)
  16590. idetinfoStr := string(Idetinfos)
  16591. psn := &models.HisPsn{
  16592. PsnNo: res.Output.Baseinfo.PsnNo,
  16593. PatientId: patient.ID,
  16594. Certno: res.Output.Baseinfo.Certno,
  16595. Gend: res.Output.Baseinfo.Gend,
  16596. Naty: res.Output.Baseinfo.Naty,
  16597. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16598. PsnName: res.Output.Baseinfo.PsnName,
  16599. Idetinfo: idetinfoStr,
  16600. Insuinfo: infoStr,
  16601. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16602. CardInfo: card_info,
  16603. VerifyNumber: token,
  16604. }
  16605. var rf []*ResultFive
  16606. json.Unmarshal([]byte(infoStr), &rf)
  16607. var insutypes []*ResultFive
  16608. var insutype string
  16609. var is390 int = 0
  16610. var is310 int = 0
  16611. for _, item := range rf {
  16612. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16613. insutypes = append(insutypes, item)
  16614. }
  16615. }
  16616. if len(insutypes) == 1 {
  16617. insutype = insutypes[0].Insutype
  16618. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16619. } else {
  16620. for _, i := range insutypes {
  16621. if i.Insutype == "390" {
  16622. is390 = 1
  16623. }
  16624. if i.Insutype == "310" {
  16625. is310 = 1
  16626. }
  16627. }
  16628. }
  16629. if is390 == 1 {
  16630. insutype = "390"
  16631. }
  16632. if is310 == 1 {
  16633. insutype = "310"
  16634. }
  16635. if len(insutypes) == 0 {
  16636. insutype = "310"
  16637. }
  16638. service.CreateHisPsn(psn)
  16639. c.ServeSuccessJSON(map[string]interface{}{
  16640. "patient": patient,
  16641. "number": token,
  16642. "insutype": insutype,
  16643. })
  16644. }
  16645. } else {
  16646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16647. return
  16648. }
  16649. } else { //读卡失败
  16650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16651. return
  16652. }
  16653. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16654. res := c.GetoleInfo()
  16655. if res.Infcode == 0 {
  16656. var result string
  16657. if res.Output.MdtrtCertType == "01" {
  16658. 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)
  16659. } else if res.Output.MdtrtCertType == "02" {
  16660. 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)
  16661. } else if res.Output.MdtrtCertType == "03" {
  16662. 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)
  16663. }
  16664. var dat map[string]interface{}
  16665. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16666. fmt.Println(dat)
  16667. } else {
  16668. fmt.Println(err)
  16669. }
  16670. userJSONBytes, _ := json.Marshal(dat)
  16671. var res2 ResultTwo
  16672. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16673. utils.ErrorLog("解析失败:%v", err)
  16674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16675. return
  16676. }
  16677. if res2.Infcode == 0 {
  16678. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16679. if err == gorm.ErrRecordNotFound {
  16680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16681. return
  16682. } else if err != nil {
  16683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16684. return
  16685. } else {
  16686. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16687. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16688. infoStr := string(Iinfos)
  16689. idetinfoStr := string(Idetinfos)
  16690. var rf []*ResultFive
  16691. json.Unmarshal([]byte(infoStr), &rf)
  16692. var insutypes []*ResultFive
  16693. var insutype string
  16694. var is390 int = 0
  16695. var is310 int = 0
  16696. //var insuplc_admdvs string
  16697. for _, item := range rf {
  16698. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16699. insutypes = append(insutypes, item)
  16700. }
  16701. }
  16702. if len(insutypes) == 1 {
  16703. insutype = insutypes[0].Insutype
  16704. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16705. } else {
  16706. for _, i := range insutypes {
  16707. if i.Insutype == "390" {
  16708. is390 = 1
  16709. }
  16710. if i.Insutype == "310" {
  16711. is310 = 1
  16712. }
  16713. }
  16714. }
  16715. if is390 == 1 {
  16716. insutype = "390"
  16717. }
  16718. if is310 == 1 {
  16719. insutype = "310"
  16720. }
  16721. if len(insutypes) == 0 {
  16722. insutype = "310"
  16723. }
  16724. psn := &models.HisPsn{
  16725. PsnNo: res2.Output.Baseinfo.PsnNo,
  16726. PatientId: patient.ID,
  16727. Certno: res2.Output.Baseinfo.Certno,
  16728. Gend: res2.Output.Baseinfo.Gend,
  16729. Naty: res2.Output.Baseinfo.Naty,
  16730. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16731. PsnName: res2.Output.Baseinfo.PsnName,
  16732. Idetinfo: idetinfoStr,
  16733. Insuinfo: infoStr,
  16734. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16735. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16736. VerifyNumber: res.Output.EcToken,
  16737. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16738. }
  16739. if res.Output.MdtrtCertType == "01" {
  16740. psn.VerifyNumber = res.Output.EcToken
  16741. //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)
  16742. } else if res.Output.MdtrtCertType == "02" {
  16743. psn.VerifyNumber = res.Output.CardNo
  16744. //result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo,admin_user_id)
  16745. } else if res.Output.MdtrtCertType == "03" {
  16746. psn.VerifyNumber = res.Output.MdtrtCertNo
  16747. //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)
  16748. }
  16749. service.CreateHisPsn(psn)
  16750. var balc float64
  16751. for _, item := range rf {
  16752. if item.Insutype == insutype {
  16753. balc = item.Balc
  16754. }
  16755. }
  16756. c.ServeSuccessJSON(map[string]interface{}{
  16757. "patient": patient,
  16758. "number": res.Output.CardNo,
  16759. "insutype": insutype,
  16760. "blac": balc,
  16761. "desc": idetinfoStr,
  16762. })
  16763. }
  16764. } else {
  16765. c.ServeSuccessJSON(map[string]interface{}{
  16766. "failed_code": -10,
  16767. "msg": res2.ErrMsg,
  16768. })
  16769. }
  16770. } else {
  16771. c.ServeSuccessJSON(map[string]interface{}{
  16772. "failed_code": -10,
  16773. "msg": res.ErrMsg,
  16774. })
  16775. }
  16776. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16777. var res ResultTwo
  16778. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16779. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16780. "&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)
  16781. resp, requestErr := http.Get(api)
  16782. if requestErr != nil {
  16783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16784. return
  16785. }
  16786. body, ioErr := ioutil.ReadAll(resp.Body)
  16787. if ioErr != nil {
  16788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16790. return
  16791. }
  16792. var respJSON map[string]interface{}
  16793. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16796. return
  16797. }
  16798. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16799. result, _ := json.Marshal(respJSON)
  16800. fmt.Println("log")
  16801. fmt.Println(string(result))
  16802. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16803. utils.ErrorLog("解析失败:%v", err)
  16804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16805. return
  16806. }
  16807. if res.Infcode == 0 {
  16808. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16809. if err == gorm.ErrRecordNotFound {
  16810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16811. return
  16812. } else if err != nil {
  16813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16814. return
  16815. } else {
  16816. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16817. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16818. infoStr := string(Iinfos)
  16819. idetinfoStr := string(Idetinfos)
  16820. var rf []*ResultFive
  16821. json.Unmarshal([]byte(infoStr), &rf)
  16822. var insutypes []*ResultFive
  16823. var insutype string
  16824. var is390 int = 0
  16825. var is310 int = 0
  16826. for _, item := range rf {
  16827. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16828. insutypes = append(insutypes, item)
  16829. }
  16830. }
  16831. if len(insutypes) == 1 {
  16832. insutype = insutypes[0].Insutype
  16833. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16834. } else {
  16835. for _, i := range insutypes {
  16836. if i.Insutype == "390" {
  16837. is390 = 1
  16838. }
  16839. if i.Insutype == "310" {
  16840. is310 = 1
  16841. }
  16842. }
  16843. }
  16844. if is390 == 1 {
  16845. insutype = "390"
  16846. }
  16847. if is310 == 1 {
  16848. insutype = "310"
  16849. }
  16850. if len(insutypes) == 0 {
  16851. insutype = "390"
  16852. }
  16853. var insuplc_admdvs string
  16854. for _, item := range rf {
  16855. if item.Insutype == insutype {
  16856. insuplc_admdvs = item.InsuplcAdmdvs
  16857. }
  16858. }
  16859. psn := &models.HisPsn{
  16860. PsnNo: res.Output.Baseinfo.PsnNo,
  16861. PatientId: patient.ID,
  16862. Certno: res.Output.Baseinfo.Certno,
  16863. Gend: res.Output.Baseinfo.Gend,
  16864. Naty: res.Output.Baseinfo.Naty,
  16865. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16866. PsnName: res.Output.Baseinfo.PsnName,
  16867. Idetinfo: idetinfoStr,
  16868. Insuinfo: infoStr,
  16869. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16870. InsuplcAdmdvs: insuplc_admdvs,
  16871. }
  16872. service.CreateHisPsn(psn)
  16873. c.ServeSuccessJSON(map[string]interface{}{
  16874. "patient": patient,
  16875. "number": res.Output.Baseinfo.Certno,
  16876. })
  16877. }
  16878. } else {
  16879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16880. return
  16881. }
  16882. } else {
  16883. type ELeData struct {
  16884. Code string `json:"code"`
  16885. Data struct {
  16886. Aac002 string `json:"aac002"`
  16887. Aaz500 string `json:"aaz500"`
  16888. ActCardNo string `json:"actCardNo"`
  16889. Bab520 string `json:"bab520"`
  16890. Bkz543 string `json:"bkz543"`
  16891. BusinessType string `json:"businessType"`
  16892. CertfCodg string `json:"certfCodg"`
  16893. EcIndexNo string `json:"ecIndexNo"`
  16894. EcToken string `json:"ecToken"`
  16895. ID0000 string `json:"id0000"`
  16896. IDNo string `json:"idNo"`
  16897. IDType string `json:"idType"`
  16898. Idcode string `json:"idcode"`
  16899. IdentityToken string `json:"identity_token"`
  16900. InsuOrg string `json:"insuOrg"`
  16901. OfficeID string `json:"officeId"`
  16902. OfficeName string `json:"officeName"`
  16903. OperatorID string `json:"operatorId"`
  16904. OperatorName string `json:"operatorName"`
  16905. OrgID string `json:"orgId"`
  16906. UserName string `json:"userName"`
  16907. } `json:"data"`
  16908. Infno interface{} `json:"infno"`
  16909. Message string `json:"message"`
  16910. OrgID string `json:"orgId"`
  16911. TransType string `json:"transType"`
  16912. }
  16913. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16914. fmt.Println(result)
  16915. outPutInfo := Remove0000(result)
  16916. fmt.Println(outPutInfo)
  16917. if len(outPutInfo) > 0 {
  16918. var ele ELeData
  16919. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16920. if err != nil {
  16921. utils.ErrorLog("解析失败:%v", err)
  16922. }
  16923. token := ele.Data.EcToken
  16924. fmt.Println(outPutInfo)
  16925. 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)
  16926. saveLog(result, requestLog, "1101", "获取人员信息")
  16927. var dat map[string]interface{}
  16928. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16929. fmt.Println(dat)
  16930. } else {
  16931. fmt.Println(err)
  16932. }
  16933. userJSONBytes, _ := json.Marshal(dat)
  16934. var res ResultTwo
  16935. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16936. utils.ErrorLog("解析失败:%v", err)
  16937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16938. return
  16939. }
  16940. if res.Infcode == 0 {
  16941. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16942. if err == gorm.ErrRecordNotFound {
  16943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16944. return
  16945. } else if err != nil {
  16946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16947. return
  16948. } else {
  16949. fmt.Println(res)
  16950. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16951. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16952. infoStr := string(Iinfos)
  16953. idetinfoStr := string(Idetinfos)
  16954. psn := &models.HisPsn{
  16955. PsnNo: res.Output.Baseinfo.PsnNo,
  16956. PatientId: patient.ID,
  16957. Certno: res.Output.Baseinfo.Certno,
  16958. Gend: res.Output.Baseinfo.Gend,
  16959. Naty: res.Output.Baseinfo.Naty,
  16960. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16961. PsnName: res.Output.Baseinfo.PsnName,
  16962. Idetinfo: idetinfoStr,
  16963. Insuinfo: infoStr,
  16964. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16965. CardInfo: outPutInfo,
  16966. VerifyNumber: token,
  16967. InsuplcAdmdvs: ele.Data.InsuOrg,
  16968. }
  16969. service.CreateHisPsn(psn)
  16970. var rf []*ResultFive
  16971. json.Unmarshal([]byte(infoStr), &rf)
  16972. var insutypes []*ResultFive
  16973. var insutype string
  16974. var is390 int = 0
  16975. var is310 int = 0
  16976. for _, item := range rf {
  16977. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16978. insutypes = append(insutypes, item)
  16979. }
  16980. }
  16981. if len(insutypes) == 1 {
  16982. insutype = insutypes[0].Insutype
  16983. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16984. } else {
  16985. for _, i := range insutypes {
  16986. if i.Insutype == "390" {
  16987. is390 = 1
  16988. }
  16989. if i.Insutype == "310" {
  16990. is310 = 1
  16991. }
  16992. }
  16993. }
  16994. if is390 == 1 {
  16995. insutype = "390"
  16996. }
  16997. if is310 == 1 {
  16998. insutype = "310"
  16999. }
  17000. if len(insutypes) == 0 {
  17001. insutype = "310"
  17002. }
  17003. c.ServeSuccessJSON(map[string]interface{}{
  17004. "patient": patient,
  17005. "number": token,
  17006. "insutype": insutype,
  17007. })
  17008. }
  17009. } else {
  17010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17011. return
  17012. }
  17013. }
  17014. //fmt.Println(result)
  17015. //
  17016. //if initFlag == 0 {
  17017. // c.TestGetBasBaseInit()
  17018. //}
  17019. //token := c.GetEleBaseInfo()
  17020. //
  17021. //token = Remove0000(token)
  17022. //
  17023. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17024. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17025. ////
  17026. //var res ResultTwo
  17027. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17028. // utils.ErrorLog("解析失败:%v", err)
  17029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17030. // return
  17031. //}
  17032. //
  17033. //if res.Infcode == 0 {
  17034. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17035. // if err == gorm.ErrRecordNotFound {
  17036. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17037. // return
  17038. // } else if err != nil {
  17039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17040. // return
  17041. //
  17042. // } else {
  17043. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17044. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17045. // infoStr := string(Iinfos)
  17046. // idetinfoStr := string(Idetinfos)
  17047. //
  17048. //
  17049. //
  17050. //
  17051. // var rf []*ResultFive
  17052. // json.Unmarshal([]byte(infoStr), &rf)
  17053. //
  17054. // var insutypes []*ResultFive
  17055. // var insutype string
  17056. // var is390 int = 0
  17057. // var is310 int = 0
  17058. // var insuplc_admdvs string
  17059. //
  17060. // for _, item := range rf {
  17061. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17062. // insutypes = append(insutypes, item)
  17063. // }
  17064. // }
  17065. //
  17066. // if len(insutypes) == 1 {
  17067. // insutype = insutypes[0].Insutype
  17068. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17069. // } else {
  17070. // for _, i := range insutypes {
  17071. // if i.Insutype == "390" {
  17072. // is390 = 1
  17073. // }
  17074. //
  17075. // if i.Insutype == "310" {
  17076. // is310 = 1
  17077. // }
  17078. // }
  17079. // }
  17080. // if is390 == 1 {
  17081. // insutype = "390"
  17082. // }
  17083. //
  17084. // if is310 == 1 {
  17085. // insutype = "310"
  17086. // }
  17087. // if len(insutypes) == 0 {
  17088. // insutype = "310"
  17089. // }
  17090. // for _, item := range rf {
  17091. // if item.Insutype == insutype {
  17092. // insuplc_admdvs = item.InsuplcAdmdvs
  17093. // }
  17094. // }
  17095. // psn := &models.HisPsn{
  17096. // PsnNo: res.Output.Baseinfo.PsnNo,
  17097. // Age: res.Output.Baseinfo.Age,
  17098. // PatientId: patient.ID,
  17099. // Certno: res.Output.Baseinfo.Certno,
  17100. // Brdy: res.Output.Baseinfo.Brdy,
  17101. // Gend: res.Output.Baseinfo.Gend,
  17102. // Naty: res.Output.Baseinfo.Naty,
  17103. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17104. // PsnName: res.Output.Baseinfo.PsnName,
  17105. // Idetinfo: idetinfoStr,
  17106. // Insuinfo: infoStr,
  17107. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17108. // CardInfo: "",
  17109. // VerifyNumber: token,
  17110. // InsuplcAdmdvs: insuplc_admdvs,
  17111. // }
  17112. // service.CreateHisPsn(psn)
  17113. //
  17114. // c.ServeSuccessJSON(map[string]interface{}{
  17115. // "patient": patient,
  17116. // "number": token,
  17117. // })
  17118. // }
  17119. //} else {
  17120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17121. // return
  17122. //}
  17123. }
  17124. break
  17125. case 5:
  17126. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17127. var api string
  17128. if miConfig.MdtrtareaAdmvs == "320921" {
  17129. 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 +
  17130. "&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
  17131. fmt.Println(api)
  17132. } else {
  17133. 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 +
  17134. "&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)
  17135. }
  17136. resp, requestErr := http.Get(api)
  17137. if requestErr != nil {
  17138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17139. return
  17140. }
  17141. body, ioErr := ioutil.ReadAll(resp.Body)
  17142. if ioErr != nil {
  17143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17145. return
  17146. }
  17147. var respJSON map[string]interface{}
  17148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17151. return
  17152. }
  17153. var status string
  17154. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17155. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17156. var token string
  17157. var res ResultTwo //1101结果
  17158. var res10265 ResultTwo10265 //1101结果
  17159. if status == "0" { //读卡成功
  17160. var card_info string //卡信息
  17161. //var busi_card_info string
  17162. var auth_info string
  17163. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17164. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17165. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17166. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17167. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17168. result, _ := json.Marshal(respJSON)
  17169. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17170. utils.ErrorLog("解析失败:%v", err)
  17171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17172. return
  17173. }
  17174. res.ErrMsg = res10265.ErrMsg
  17175. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17176. res.Infcode = infocode
  17177. res.Output = res10265.Output
  17178. res.InfRefmsgid = res10265.InfRefmsgid
  17179. if res.Infcode == 0 {
  17180. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17181. if err == gorm.ErrRecordNotFound {
  17182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17183. return
  17184. } else if err != nil {
  17185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17186. return
  17187. } else {
  17188. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17189. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17190. infoStr := string(Iinfos)
  17191. idetinfoStr := string(Idetinfos)
  17192. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17193. psn := &models.HisPsn{
  17194. PsnNo: res.Output.Baseinfo.PsnNo,
  17195. PatientId: patient.ID,
  17196. Certno: res.Output.Baseinfo.Certno,
  17197. Gend: res.Output.Baseinfo.Gend,
  17198. Brdy: b,
  17199. Age: float64(age),
  17200. Naty: res.Output.Baseinfo.Naty,
  17201. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17202. PsnName: res.Output.Baseinfo.PsnName,
  17203. Idetinfo: idetinfoStr,
  17204. Insuinfo: infoStr,
  17205. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17206. CardInfo: card_info,
  17207. VerifyNumber: token,
  17208. AuthInfo: auth_info,
  17209. }
  17210. var rf []*ResultFive
  17211. json.Unmarshal([]byte(infoStr), &rf)
  17212. var insutypes []*ResultFive
  17213. var insutype string
  17214. var is390 int = 0
  17215. var is310 int = 0
  17216. for _, item := range rf {
  17217. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17218. insutypes = append(insutypes, item)
  17219. }
  17220. }
  17221. if len(insutypes) == 1 {
  17222. insutype = insutypes[0].Insutype
  17223. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17224. } else {
  17225. for _, i := range insutypes {
  17226. if i.Insutype == "390" {
  17227. is390 = 1
  17228. }
  17229. if i.Insutype == "310" {
  17230. is310 = 1
  17231. }
  17232. }
  17233. }
  17234. if is390 == 1 {
  17235. insutype = "390"
  17236. }
  17237. if is310 == 1 {
  17238. insutype = "310"
  17239. }
  17240. if len(insutypes) == 0 {
  17241. insutype = "310"
  17242. }
  17243. service.CreateHisPsn(psn)
  17244. c.ServeSuccessJSON(map[string]interface{}{
  17245. "patient": patient,
  17246. "number": token,
  17247. "insutype": insutype,
  17248. })
  17249. }
  17250. } else {
  17251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17252. return
  17253. }
  17254. } else { //读卡失败
  17255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17256. return
  17257. }
  17258. }
  17259. break
  17260. }
  17261. }
  17262. var initFlag int64 = 0
  17263. var initEleFlag int64 = 0
  17264. func (c *HisApiController) TestGetBasBaseInit() {
  17265. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17266. Iinit := DllDef.MustFindProc("Init")
  17267. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17268. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  17269. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  17270. if ret != 0 {
  17271. fmt.Println("SSCard的报错原因:", err)
  17272. fmt.Println("SSCard的运算结果为:", ret)
  17273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17274. return
  17275. }
  17276. result := int(ret)
  17277. fmt.Println("SSCard的运算结果为1:", result)
  17278. initFlag = 1
  17279. return
  17280. }
  17281. func (c *HisApiController) HandleJiangXiReadCard() {
  17282. fmt.Println("~~~~~~")
  17283. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17284. admin_user_id, _ := c.GetInt64("admin_user_id")
  17285. id_card_type, _ := c.GetInt64("id_card_type")
  17286. //certificates, _ := c.GetInt64("certificates")
  17287. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17288. if initFlag == 0 {
  17289. c.TestGetJiangXiBasBaseInit()
  17290. }
  17291. basStr := c.GetBasBaseInfo()
  17292. if len(basStr) == 0 {
  17293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17294. return
  17295. }
  17296. fmt.Println(basStr)
  17297. bas := strings.Split(basStr, "|")
  17298. basNumber := bas[1]
  17299. fmt.Println(basNumber)
  17300. card_sn := bas[3]
  17301. fmt.Println(card_sn)
  17302. 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, "")
  17303. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17304. var dat map[string]interface{}
  17305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17306. fmt.Println(dat)
  17307. } else {
  17308. fmt.Println(err)
  17309. }
  17310. userJSONBytes, _ := json.Marshal(dat)
  17311. var res ResultTwo
  17312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17313. utils.ErrorLog("解析失败:%v", err)
  17314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17315. return
  17316. }
  17317. if res.Infcode == 0 {
  17318. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17319. if err == gorm.ErrRecordNotFound {
  17320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17321. return
  17322. } else if err != nil {
  17323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17324. return
  17325. } else {
  17326. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17327. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17328. infoStr := string(Iinfos)
  17329. idetinfoStr := string(Idetinfos)
  17330. psn := &models.HisPsn{
  17331. PsnNo: res.Output.Baseinfo.PsnNo,
  17332. PatientId: patient.ID,
  17333. Certno: res.Output.Baseinfo.Certno,
  17334. Gend: res.Output.Baseinfo.Gend,
  17335. Naty: res.Output.Baseinfo.Naty,
  17336. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17337. PsnName: res.Output.Baseinfo.PsnName,
  17338. Idetinfo: idetinfoStr,
  17339. Insuinfo: infoStr,
  17340. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17341. CardInfo: basStr,
  17342. VerifyNumber: "",
  17343. }
  17344. service.CreateHisPsn(psn)
  17345. c.ServeSuccessJSON(map[string]interface{}{
  17346. "patient": patient,
  17347. "number": basNumber,
  17348. })
  17349. }
  17350. } else {
  17351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17352. return
  17353. }
  17354. }
  17355. func (c *HisApiController) TestGetHnBasBaseInit() {
  17356. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17357. Iinit := DllDef.MustFindProc("Init")
  17358. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17359. //http://10.77.211.236/CSB/hsa-fsi-1303
  17360. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17361. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17362. // 调用 Init 函数
  17363. 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"))))
  17364. //if ret != 0 {
  17365. fmt.Println("SSCard的报错原因:", err)
  17366. fmt.Println("SSCard的运算结果为:", ret)
  17367. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17368. // return
  17369. //}
  17370. result := int(ret)
  17371. fmt.Println("SSCard的运算结果为1:", result)
  17372. initFlag = 1
  17373. return
  17374. }
  17375. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17376. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17377. Iinit := DllDef.MustFindProc("Init")
  17378. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17379. //http://10.77.211.236/CSB/hsa-fsi-1303
  17380. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  17381. if ret != 0 {
  17382. fmt.Println("SSCard的报错原因:", err)
  17383. fmt.Println("SSCard的运算结果为:", ret)
  17384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17385. return
  17386. }
  17387. result := int(ret)
  17388. fmt.Println("SSCard的运算结果为1:", result)
  17389. initFlag = 1
  17390. return
  17391. }
  17392. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17393. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17394. Iinit := DllDef.MustFindProc("Init")
  17395. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17396. //http://10.77.211.236/CSB/hsa-fsi-1303
  17397. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17398. if ret != 0 {
  17399. fmt.Println("SSCard的报错原因:", err)
  17400. fmt.Println("SSCard的运算结果为:", ret)
  17401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17402. return
  17403. }
  17404. result := int(ret)
  17405. fmt.Println("SSCard的运算结果为1:", result)
  17406. initFlag = 1
  17407. return
  17408. }
  17409. func (c *HisApiController) GetSFZBaseInfo() string {
  17410. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17411. readCard := DllDef.MustFindProc("ReadSFZ")
  17412. if readCard == nil {
  17413. fmt.Println("readcard is nil")
  17414. readCard = DllDef.MustFindProc("ReadSFZ")
  17415. }
  17416. str := make([]byte, 8096)
  17417. str1 := make([]byte, 8096)
  17418. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17419. fmt.Println(r)
  17420. return Remove0000(string(str))
  17421. }
  17422. func (c *HisApiController) GetEleBaseInfo() string {
  17423. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17424. readCard := DllDef.MustFindProc("GetQRBase")
  17425. fmt.Println(readCard)
  17426. if readCard == nil {
  17427. fmt.Println("readcard is nil")
  17428. readCard = DllDef.MustFindProc("GetQRBase")
  17429. }
  17430. str := make([]byte, 1024)
  17431. str1 := make([]byte, 1024)
  17432. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17433. fmt.Println(ret2)
  17434. fmt.Println(string(str1))
  17435. fmt.Println(string(str))
  17436. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17437. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17438. if ret2 != 0 {
  17439. return ""
  17440. }
  17441. return string(str)
  17442. }
  17443. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17444. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17445. readCard := DllDef.MustFindProc("NationEcTrans")
  17446. fmt.Println(readCard)
  17447. fmt.Println("!!!!!")
  17448. pBusiCardInfo := make([]byte, 2048)
  17449. input := make(map[string]interface{})
  17450. inputData := make(map[string]interface{})
  17451. inputData["orgId"] = code
  17452. inputData["businessType"] = "01101"
  17453. inputData["operatorId"] = "1"
  17454. inputData["operatorName"] = "admin"
  17455. inputData["officeId"] = "001"
  17456. inputData["officeName"] = "血透室"
  17457. inputData["deviceType"] = ""
  17458. input["data"] = inputData
  17459. input["orgId"] = code
  17460. input["transType"] = "ec.query"
  17461. bytesData, _ := json.Marshal(input)
  17462. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17463. fmt.Println(ret2)
  17464. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17465. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17466. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17467. }
  17468. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17469. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17470. readCard := DllDef.MustFindProc("NationEcTrans")
  17471. fmt.Println(readCard)
  17472. fmt.Println("!!!!!")
  17473. pBusiCardInfo := make([]byte, 2048)
  17474. input := make(map[string]interface{})
  17475. inputData := make(map[string]interface{})
  17476. inputData["orgId"] = code
  17477. inputData["businessType"] = "01101"
  17478. inputData["operatorId"] = "9"
  17479. inputData["operatorName"] = "admin"
  17480. inputData["officeId"] = "001"
  17481. inputData["officeName"] = "血透室"
  17482. inputData["deviceType"] = ""
  17483. input["data"] = inputData
  17484. input["orgId"] = code
  17485. input["transType"] = "ec.query"
  17486. bytesData, _ := json.Marshal(input)
  17487. 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])))
  17488. fmt.Println(ret2)
  17489. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17490. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17491. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17492. }
  17493. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17494. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17495. readCard := DllDef.MustFindProc("NationEcTrans")
  17496. fmt.Println(readCard)
  17497. fmt.Println("!!!!!")
  17498. pBusiCardInfo := make([]byte, 2048)
  17499. input := make(map[string]interface{})
  17500. inputData := make(map[string]interface{})
  17501. inputData["orgId"] = code
  17502. inputData["businessType"] = "01301"
  17503. inputData["operatorId"] = "9"
  17504. inputData["operatorName"] = "admin"
  17505. inputData["officeId"] = "001"
  17506. inputData["officeName"] = "血透室"
  17507. inputData["deviceType"] = ""
  17508. input["data"] = inputData
  17509. input["orgId"] = code
  17510. input["transType"] = "ec.query"
  17511. bytesData, _ := json.Marshal(input)
  17512. 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])))
  17513. fmt.Println(ret2)
  17514. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17515. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17516. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17517. }
  17518. func GetJxEleBaseInfo(org_id int64) string {
  17519. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17520. readCard := DllDef.MustFindProc("NationEcTrans")
  17521. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17522. if readCard == nil {
  17523. fmt.Println("readcard is nil")
  17524. readCard = DllDef.MustFindProc("NationEcTrans")
  17525. }
  17526. str1 := make([]byte, 1024)
  17527. data := make(map[string]interface{})
  17528. inputData := make(map[string]interface{})
  17529. inputData["orgId"] = miConfig.Code
  17530. inputData["businessType"] = "01101"
  17531. inputData["operatorId"] = "test001"
  17532. inputData["operatorName"] = "cn"
  17533. inputData["officeId"] = "32760"
  17534. inputData["officeName"] = "waike"
  17535. inputData["deviceType"] = ""
  17536. data["data"] = inputData
  17537. data["transType"] = "ec.query"
  17538. data["extra "] = ""
  17539. data["orgId"] = miConfig.Code
  17540. bytesData, _ := json.Marshal(data)
  17541. //bytesData, _ := json.Marshal(data)
  17542. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17543. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17544. fmt.Println(ret2)
  17545. fmt.Println(string(str1))
  17546. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17547. if ret2 != 0 {
  17548. return ""
  17549. }
  17550. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17551. }
  17552. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17553. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17554. // readCard := DllDef.MustFindProc("NationEcTrans")
  17555. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17556. //
  17557. // if readCard == nil {
  17558. // fmt.Println("readcard is nil")
  17559. // readCard = DllDef.MustFindProc("NationEcTrans")
  17560. // }
  17561. // str1 := make([]byte, 1024)
  17562. //
  17563. // data := make(map[string]interface{})
  17564. //
  17565. // inputData := make(map[string]interface{})
  17566. // inputData["orgId"] = miConfig.Code
  17567. // inputData["businessType"] = "01101"
  17568. // inputData["operatorId"] = "test001"
  17569. // inputData["operatorName"] = "cn"
  17570. // inputData["officeId"] = "32760"
  17571. // inputData["officeName"] = "waike"
  17572. // inputData["deviceType"] = ""
  17573. //
  17574. // data["data"] = inputData
  17575. // data["transType"] = "ec.query"
  17576. // data["extra "] = ""
  17577. // data["orgId"] = miConfig.Code
  17578. // bytesData, _ := json.Marshal(data)
  17579. // //bytesData, _ := json.Marshal(data)
  17580. //
  17581. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17582. //
  17583. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17584. // fmt.Println(ret2)
  17585. // fmt.Println(string(str1))
  17586. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17587. //
  17588. // if ret2 != 0 {
  17589. // return ""
  17590. // }
  17591. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17592. //}
  17593. func GetJxEleBaseInitInfo(org_id int64) string {
  17594. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17595. readCard := DllDef.MustFindProc("NationEcTrans")
  17596. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17597. if readCard == nil {
  17598. fmt.Println("readcard is nil")
  17599. readCard = DllDef.MustFindProc("NationEcTrans")
  17600. }
  17601. str1 := make([]byte, 2048)
  17602. data := make(map[string]interface{})
  17603. inputData := make(map[string]interface{})
  17604. inputData["orgId"] = miConfig.Code
  17605. inputData["businessType"] = "01101"
  17606. inputData["operatorId"] = "1"
  17607. inputData["operatorName"] = "huangchuang"
  17608. inputData["officeId"] = "101"
  17609. inputData["officeName"] = "xuetou"
  17610. inputData["deviceType"] = ""
  17611. data["data"] = inputData
  17612. data["transType"] = "ec.query"
  17613. data["orgId"] = miConfig.Code
  17614. bytesData, _ := json.Marshal(data)
  17615. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17616. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17617. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17618. fmt.Println(ret2)
  17619. fmt.Println(string(str1))
  17620. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17621. if ret2 != 0 {
  17622. return ""
  17623. }
  17624. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17625. initEleFlag = 1
  17626. }
  17627. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17628. }
  17629. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17630. // // 构建命令
  17631. // cmd := exec.Command("python", "b.py")
  17632. //
  17633. // // 执行命令并等待完成
  17634. // output, err := cmd.CombinedOutput()
  17635. // if err != nil {
  17636. // fmt.Println("Error executing Python script:", err)
  17637. // return
  17638. // }
  17639. //
  17640. // // 打印Python脚本的输出
  17641. // fmt.Println(string(output))
  17642. //}
  17643. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17644. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17645. readCard := DllDef.MustFindProc("gxyb_call")
  17646. if readCard == nil {
  17647. fmt.Println("readcard is nil")
  17648. readCard = DllDef.MustFindProc("gxyb_call")
  17649. }
  17650. str := make([]byte, 1024)
  17651. str1 := make([]byte, 1024)
  17652. //data := make(map[string]interface{})
  17653. currentTime := time.Now()
  17654. // 格式化时间为 "YYYYMMDDHH24MISS"
  17655. formattedTime := currentTime.Format("20060102150405")
  17656. inputData := make(map[string]interface{})
  17657. inputData2 := make(map[string]interface{})
  17658. inputData["transNo"] = "1401"
  17659. inputData["transType"] = "passwordCheck"
  17660. inputData["timestamp"] = formattedTime
  17661. inputData2["fixmedinsCode"] = code
  17662. inputData2["psnNo"] = ""
  17663. inputData["data"] = inputData2
  17664. jsonBytes, err := json.Marshal(inputData)
  17665. if err != nil {
  17666. fmt.Println("Error encoding map to JSON:", err)
  17667. }
  17668. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17669. fmt.Println(string(str1))
  17670. fmt.Println(string(str))
  17671. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17672. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17673. if ret2 != 0 {
  17674. return ""
  17675. }
  17676. return string(str)
  17677. }
  17678. func (c *HisApiController) GetoleInfo() Response {
  17679. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17680. defer ole.CoUninitialize()
  17681. // Replace with the ProgID or CLSID of your COM object
  17682. progID := "YinHai.XJ.Actual.Interface.New"
  17683. // Create COM object
  17684. unknown, err := oleutil.CreateObject(progID)
  17685. if err != nil {
  17686. fmt.Println("Unable to create COM object:", err)
  17687. }
  17688. defer unknown.Release()
  17689. // Query for the IDispatch interface
  17690. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17691. if err != nil {
  17692. fmt.Println("Unable to get IDispatch interface:", err)
  17693. }
  17694. defer dispatch.Release()
  17695. // Prepare parameters
  17696. transNo := "1401"
  17697. transType := "passwordCheck"
  17698. timestamp := time.Now().Unix()
  17699. fixmedinsCode := "H45072101171"
  17700. psnNo := ""
  17701. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17702. result2 := ""
  17703. // Call COM object's method using the IDispatch interface
  17704. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17705. fmt.Println(resulr)
  17706. fmt.Println(result2)
  17707. if err != nil {
  17708. fmt.Println("调用COM对象方法失败:", err)
  17709. }
  17710. var response Response
  17711. err2 := json.Unmarshal([]byte(result2), &response)
  17712. if err2 != nil {
  17713. fmt.Println("解析JSON失败:", err)
  17714. }
  17715. return response
  17716. }
  17717. func (c *HisApiController) GetBasBaseInfo() string {
  17718. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17719. readCard := DllDef.MustFindProc("ReadCardBas")
  17720. if readCard == nil {
  17721. fmt.Println("readcard is nil")
  17722. readCard = DllDef.MustFindProc("ReadCardBas")
  17723. }
  17724. str := make([]byte, 1024)
  17725. str1 := make([]byte, 1024)
  17726. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17727. fmt.Println(string(str1))
  17728. fmt.Println(string(str))
  17729. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17730. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17731. if ret2 != 0 {
  17732. return ""
  17733. }
  17734. return string(str)
  17735. }
  17736. type Program struct {
  17737. FunctionID string `xml:"function_id"`
  17738. CardInfo string `xml:"cardinfo"`
  17739. User string `xml:"user"`
  17740. }
  17741. func (c *HisApiController) GetBasBaseInfo1111() string {
  17742. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17743. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17744. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17745. if readCard == nil {
  17746. fmt.Println("readcard is nil")
  17747. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17748. }
  17749. if readCard2 == nil {
  17750. fmt.Println("readcard is nil")
  17751. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17752. }
  17753. str := make([]byte, 1024)
  17754. str1 := make([]byte, 1024)
  17755. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17756. str3 := make([]byte, 1024)
  17757. str4 := make([]byte, 1024)
  17758. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17759. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17760. //if err != nil {
  17761. // fmt.Println("Error opening file:", err)
  17762. //}
  17763. //defer file.Close()
  17764. //
  17765. //var lastProgram Program
  17766. //scanner := bufio.NewScanner(file)
  17767. //inProgram := false
  17768. //
  17769. //for scanner.Scan() {
  17770. // line := scanner.Text()
  17771. // if strings.Contains(line, "<program>") {
  17772. // inProgram = true
  17773. // programXML := "<program>"
  17774. // for scanner.Scan() {
  17775. // line = scanner.Text()
  17776. // programXML += line
  17777. // if strings.Contains(line, "</program>") {
  17778. // programXML += "</program>"
  17779. // break
  17780. // }
  17781. // }
  17782. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17783. // // 解析成功,更新最后的 Program
  17784. // }
  17785. // inProgram = false
  17786. // }
  17787. //}
  17788. //
  17789. // fmt.Println("Error reading file:", inProgram)
  17790. //
  17791. //if err := scanner.Err(); err != nil {
  17792. // fmt.Println("Error reading file:", err)
  17793. //}
  17794. // 输出最后一次的 Program
  17795. //fmt.Printf("最后一次的 <program>:\n")
  17796. //fmt.Printf("<program>\n")
  17797. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17798. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17799. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17800. //fmt.Printf("</program>\n")
  17801. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17802. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17803. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17804. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17805. return ConvertToString(string(str), "gbk", "utf-8")
  17806. }
  17807. func (c *HisApiController) GetBasBaseInfo22222() string {
  17808. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17809. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17810. if readCard == nil {
  17811. fmt.Println("readcard is nil")
  17812. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17813. }
  17814. str := make([]byte, 1024)
  17815. str1 := make([]byte, 1024)
  17816. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17817. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17818. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17819. //if err != nil {
  17820. // fmt.Println("Error opening file:", err)
  17821. //}
  17822. //defer file.Close()
  17823. //
  17824. //var lastProgram Program
  17825. //scanner := bufio.NewScanner(file)
  17826. //inProgram := false
  17827. //
  17828. //for scanner.Scan() {
  17829. // line := scanner.Text()
  17830. // if strings.Contains(line, "<program>") {
  17831. // inProgram = true
  17832. // programXML := "<program>"
  17833. // for scanner.Scan() {
  17834. // line = scanner.Text()
  17835. // programXML += line
  17836. // if strings.Contains(line, "</program>") {
  17837. // programXML += "</program>"
  17838. // break
  17839. // }
  17840. // }
  17841. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17842. // // 解析成功,更新最后的 Program
  17843. // }
  17844. // inProgram = false
  17845. // }
  17846. //}
  17847. //
  17848. // fmt.Println("Error reading file:", inProgram)
  17849. //
  17850. //if err := scanner.Err(); err != nil {
  17851. // fmt.Println("Error reading file:", err)
  17852. //}
  17853. // 输出最后一次的 Program
  17854. //fmt.Printf("最后一次的 <program>:\n")
  17855. //fmt.Printf("<program>\n")
  17856. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17857. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17858. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17859. //fmt.Printf("</program>\n")
  17860. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17861. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17862. return ConvertToString(string(str1), "gbk", "utf-8")
  17863. }
  17864. func (c *HisApiController) GetahBasBaseInfo() string {
  17865. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17866. readCard := DllDef.MustFindProc("iReadCardBas")
  17867. if readCard == nil {
  17868. fmt.Println("readcard is nil")
  17869. readCard = DllDef.MustFindProc("iReadCardBas")
  17870. }
  17871. //str := make([]byte, 1024)
  17872. str1 := make([]byte, 1024)
  17873. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17874. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17875. //if err != nil {
  17876. // fmt.Println("Error opening file:", err)
  17877. //}
  17878. //defer file.Close()
  17879. //
  17880. //var lastProgram Program
  17881. //scanner := bufio.NewScanner(file)
  17882. //inProgram := false
  17883. //
  17884. //for scanner.Scan() {
  17885. // line := scanner.Text()
  17886. // if strings.Contains(line, "<program>") {
  17887. // inProgram = true
  17888. // programXML := "<program>"
  17889. // for scanner.Scan() {
  17890. // line = scanner.Text()
  17891. // programXML += line
  17892. // if strings.Contains(line, "</program>") {
  17893. // programXML += "</program>"
  17894. // break
  17895. // }
  17896. // }
  17897. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17898. // // 解析成功,更新最后的 Program
  17899. // }
  17900. // inProgram = false
  17901. // }
  17902. //}
  17903. //
  17904. // fmt.Println("Error reading file:", inProgram)
  17905. //
  17906. //if err := scanner.Err(); err != nil {
  17907. // fmt.Println("Error reading file:", err)
  17908. //}
  17909. // 输出最后一次的 Program
  17910. //fmt.Printf("最后一次的 <program>:\n")
  17911. //fmt.Printf("<program>\n")
  17912. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17913. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17914. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17915. //fmt.Printf("</program>\n")
  17916. fmt.Println(string(str1))
  17917. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17918. if ret2 != 0 {
  17919. return ""
  17920. }
  17921. return string(str1)
  17922. }
  17923. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17924. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17925. readCard := DllDef.MustFindProc("read_cardinfo")
  17926. if readCard == nil {
  17927. fmt.Println("readcard is nil")
  17928. readCard = DllDef.MustFindProc("read_cardinfo")
  17929. }
  17930. str := make([]byte, 1024) //卡号
  17931. str1 := make([]byte, 1024) //卡识别码
  17932. str2 := make([]byte, 1024) //身份证号
  17933. str3 := make([]byte, 1024) //姓名
  17934. str4 := make([]byte, 1024) //错误信息
  17935. 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])))
  17936. fmt.Println(string(str1))
  17937. fmt.Println(string(str))
  17938. fmt.Println(string(str2))
  17939. fmt.Println(string(str3))
  17940. fmt.Println(string(str4))
  17941. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17942. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17943. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17944. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17945. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17946. if ret2 != 0 {
  17947. return "", "", "", "", ""
  17948. }
  17949. return string(str), string(str1), string(str2), string(str3), string(str4)
  17950. }
  17951. type CustomFundPay struct {
  17952. FundPayType string `json:"fund_pay_type"`
  17953. FundPayamt float64 `json:"fund_payamt"`
  17954. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17955. }
  17956. //func (c *HisApiController) GetBatchSettleList() {
  17957. // start_time_str := c.GetString("start_time")
  17958. // //end_time_str := c.GetString("end_time")
  17959. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17960. //
  17961. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17962. //
  17963. // for _, item := range orders {
  17964. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17965. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17966. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17967. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17968. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17969. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17970. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17971. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17972. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17973. //
  17974. // if order.ID == 0 {
  17975. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17976. // return
  17977. // }
  17978. //
  17979. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17980. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17981. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17982. // //fmt.Println(count)
  17983. // //var zero string
  17984. // //number := count + 1
  17985. // //if number >= 1000 {
  17986. // // zero = "0000" + strconv.FormatInt(number, 10)
  17987. // //} else if number >= 10000 {
  17988. // // zero = "000" + strconv.FormatInt(number, 10)
  17989. // //} else if number >= 100000 {
  17990. // // zero = "00" + strconv.FormatInt(number, 10)
  17991. // //} else if number >= 1000000 {
  17992. // // zero = "0" + strconv.FormatInt(number, 10)
  17993. // //} else {
  17994. // // zero = strconv.FormatInt(number, 10)
  17995. // //}
  17996. // //fmt.Println(zero)
  17997. //
  17998. // struct4101 := service.Struct4101{
  17999. // PsnNo: order.PsnNo,
  18000. // MdtrtId: order.MdtrtId,
  18001. // SetlId: order.SetlId,
  18002. // PsnName: order.PsnName,
  18003. // Gend: order.Gend,
  18004. // Brdy: his.Brdy,
  18005. // Age: his.Age,
  18006. // Naty: order.Naty,
  18007. // PatnCertType: "01",
  18008. // Certno: order.Certno,
  18009. // Prfs: "90",
  18010. // ConerName: roles[0].UserName,
  18011. // PatnRlts: "99",
  18012. // ConerAddr: miConfig.OrgName,
  18013. // ConerTel: admin.Mobile,
  18014. // HiType: order.Insutype,
  18015. // Insuplc: miConfig.InsuplcAdmdvs,
  18016. // MaindiagFlag: "1",
  18017. // BillCode: order.SetlId,
  18018. // BillNo: order.SetlId,
  18019. // BizSn: order.Number,
  18020. // PsnSelfPay: order.PsnPartAmt,
  18021. // PsnOwnPay: order.PsnPartAmt,
  18022. // AcctPay: order.AcctPay,
  18023. // PsnCashpay: order.PsnCashPay,
  18024. // HiPaymtd: "1",
  18025. // Hsorg: miConfig.InsuplcAdmdvs,
  18026. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18027. // MedinsFillPsn: curRoles.UserName,
  18028. // MedinsFillDept: miConfig.OrgName,
  18029. // IptMedType: "2",
  18030. // }
  18031. // struct4101.SetlBegnDate = order.SetlTime
  18032. // struct4101.SetlEndDate = order.SetlTime
  18033. // time_arr := strings.Split(order.SetlTime, " ")
  18034. // struct4101.AdmTime = time_arr[0]
  18035. // struct4101.AdmEndTime = time_arr[0]
  18036. //
  18037. // var rf []CustomFundPay
  18038. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18039. //
  18040. // var tempFunPays []service.CustomStruct
  18041. // for _, item := range rf {
  18042. // var tempFunPay service.CustomStruct
  18043. // tempFunPay.FundPayamt = item.FundPayamt
  18044. // tempFunPay.FundPayType = item.FundPayType
  18045. // tempFunPays = append(tempFunPays, tempFunPay)
  18046. // }
  18047. // struct4101.CustomStruct = tempFunPays
  18048. //
  18049. // var tempDiaginfos []service.DiaginfoStructTwo
  18050. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18051. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18052. //
  18053. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18054. // var config []*models.HisXtDiagnoseConfig
  18055. // for _, item := range diagnosis_ids {
  18056. // id, _ := strconv.ParseInt(item, 10, 64)
  18057. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18058. // config = append(config, &diagnosisConfig)
  18059. // }
  18060. //
  18061. // for index, item := range config {
  18062. // if index == 0 {
  18063. // var tempDiaginfo service.DiaginfoStructTwo
  18064. // tempDiaginfo.DiagCode = item.CountryCode
  18065. // tempDiaginfo.DiagName = item.CountryContentName
  18066. // tempDiaginfo.DiagType = "1"
  18067. // tempDiaginfo.MaindiagFlag = "1"
  18068. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18069. // } else {
  18070. // var tempDiaginfo service.DiaginfoStructTwo
  18071. // tempDiaginfo.DiagCode = item.CountryCode
  18072. // tempDiaginfo.DiagName = item.CountryContentName
  18073. // tempDiaginfo.DiagType = "1"
  18074. // tempDiaginfo.MaindiagFlag = "0"
  18075. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18076. // }
  18077. // }
  18078. // struct4101.Diseinfo = tempDiaginfos
  18079. //
  18080. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18081. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18082. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18083. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18084. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18085. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18086. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18087. //
  18088. // var iteminfo service.IteminfoStruct
  18089. //
  18090. // var bedCostTotal float64 = 0 //床位总费
  18091. // var bedCostSelfTotal float64 = 0 //床位自费
  18092. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18093. //
  18094. // var operationCostTotal float64 = 0 //手术费
  18095. // var operationCostSelfTotal float64 = 0 //手术费
  18096. // var operationCostPartSelfTotal float64 = 0 //手术费
  18097. //
  18098. // var otherCostTotal float64 = 0 //其他费用
  18099. // var otherCostSelfTotal float64 = 0 //其他费用
  18100. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18101. //
  18102. // var materialCostTotal float64 = 0 //材料费
  18103. // var materialCostSelfTotal float64 = 0 //材料费
  18104. // var materialCostPartSelfTotal float64 = 0 //材料费
  18105. //
  18106. // var westernMedicineCostTotal float64 = 0 //西药费
  18107. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18108. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18109. //
  18110. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18111. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18112. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18113. //
  18114. // var checkCostTotal float64 = 0 //检查费
  18115. // var checkCostSelfTotal float64 = 0 //检查费
  18116. // var checkCostPartSelfTotal float64 = 0 //检查费
  18117. //
  18118. // var laboratoryCostTotal float64 = 0 //化验费
  18119. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18120. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18121. //
  18122. // var treatCostTotal float64 = 0 //治疗费用
  18123. // var treatCostSelfTotal float64 = 0 //治疗费用
  18124. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18125. //
  18126. // decimal.DivisionPrecision = 2
  18127. //
  18128. // var bed_fulamt_ownpay_amt float64 = 0
  18129. // var operation_fulamt_ownpay_amt float64 = 0
  18130. // var other_fulamt_ownpay_amt float64 = 0
  18131. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18132. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18133. // var check_fulamt_ownpay_amt float64 = 0
  18134. // var material_fulamt_ownpay_amt float64 = 0
  18135. // var laboratory_fulamt_ownpay_amt float64 = 0
  18136. // var treat_fulamt_ownpay_amt float64 = 0
  18137. //
  18138. // var bed_claa_sunmfee float64 = 0
  18139. // var bed_clab_amt float64 = 0
  18140. // var bed_other_amt float64 = 0
  18141. //
  18142. // var operation_claa_sunmfee float64 = 0
  18143. // var operation_clab_amt float64 = 0
  18144. // var operation_other_amt float64 = 0
  18145. //
  18146. // var other_claa_sunmfee float64 = 0
  18147. // var other_clab_amt float64 = 0
  18148. // var other_other_amt float64 = 0
  18149. //
  18150. // var westernMedicine_claa_sunmfee float64 = 0
  18151. // var westernMedicine_clab_amt float64 = 0
  18152. // var westernMedicine_other_amt float64 = 0
  18153. //
  18154. // var chineseTraditional_claa_sunmfee float64 = 0
  18155. // var chineseTraditional_clab_amt float64 = 0
  18156. // var chineseTraditional_other_amt float64 = 0
  18157. //
  18158. // var check_claa_sunmfee float64 = 0
  18159. // var check_clab_amt float64 = 0
  18160. // var check_other_amt float64 = 0
  18161. //
  18162. // var material_claa_sunmfee float64 = 0
  18163. // var material_clab_amt float64 = 0
  18164. // var material_other_amt float64 = 0
  18165. //
  18166. // var laboratory_claa_sunmfee float64 = 0
  18167. // var laboratory_clab_amt float64 = 0
  18168. // var laboratory_other_amt float64 = 0
  18169. //
  18170. // var treat_claa_sunmfee float64 = 0
  18171. // var treat_clab_amt float64 = 0
  18172. // var treat_other_amt float64 = 0
  18173. //
  18174. // for _, item := range order.HisOrderInfo {
  18175. // if item.MedChrgitmType == "01" { //床位费
  18176. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18177. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18178. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18179. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18180. // if item.ChrgitmLv == "1" {
  18181. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18182. // }
  18183. // if item.ChrgitmLv == "2" {
  18184. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18185. //
  18186. // }
  18187. // if item.ChrgitmLv == "3" {
  18188. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18189. // }
  18190. //
  18191. // }
  18192. //
  18193. // if item.MedChrgitmType == "03" { //检查费
  18194. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18195. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18196. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18197. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18198. // if item.ChrgitmLv == "1" {
  18199. //
  18200. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18201. //
  18202. // }
  18203. // if item.ChrgitmLv == "2" {
  18204. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18205. //
  18206. // }
  18207. // if item.ChrgitmLv == "3" {
  18208. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18209. // }
  18210. // }
  18211. //
  18212. // if item.MedChrgitmType == "04" { //化验费
  18213. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18214. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18215. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18216. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18217. // if item.ChrgitmLv == "1" {
  18218. //
  18219. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18220. //
  18221. // }
  18222. // if item.ChrgitmLv == "2" {
  18223. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18224. //
  18225. // }
  18226. // if item.ChrgitmLv == "3" {
  18227. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18228. // }
  18229. // }
  18230. //
  18231. // if item.MedChrgitmType == "05" { //治疗费
  18232. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18233. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18234. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18235. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18236. // if item.ChrgitmLv == "1" {
  18237. //
  18238. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18239. //
  18240. // }
  18241. // if item.ChrgitmLv == "2" {
  18242. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18243. //
  18244. // }
  18245. // if item.ChrgitmLv == "3" {
  18246. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18247. // }
  18248. // }
  18249. //
  18250. // if item.MedChrgitmType == "06" { //手术费
  18251. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18252. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18253. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18254. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18255. //
  18256. // if item.ChrgitmLv == "1" {
  18257. //
  18258. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18259. //
  18260. // }
  18261. // if item.ChrgitmLv == "2" {
  18262. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18263. //
  18264. // }
  18265. // if item.ChrgitmLv == "3" {
  18266. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18267. // }
  18268. // }
  18269. //
  18270. // if item.MedChrgitmType == "08" { //材料费
  18271. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18272. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18273. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18274. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18275. // if item.ChrgitmLv == "1" {
  18276. //
  18277. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18278. //
  18279. // }
  18280. // if item.ChrgitmLv == "2" {
  18281. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18282. //
  18283. // }
  18284. // if item.ChrgitmLv == "3" {
  18285. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18286. // }
  18287. // }
  18288. //
  18289. // if item.MedChrgitmType == "09" { //西药费
  18290. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18291. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18292. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18293. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18294. // if item.ChrgitmLv == "1" {
  18295. //
  18296. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18297. //
  18298. // }
  18299. // if item.ChrgitmLv == "2" {
  18300. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18301. //
  18302. // }
  18303. // if item.ChrgitmLv == "3" {
  18304. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18305. // }
  18306. // }
  18307. //
  18308. // if item.MedChrgitmType == "11" { //中成费
  18309. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18310. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18311. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18312. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18313. // if item.ChrgitmLv == "1" {
  18314. //
  18315. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18316. //
  18317. // }
  18318. // if item.ChrgitmLv == "2" {
  18319. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18320. //
  18321. // }
  18322. // if item.ChrgitmLv == "3" {
  18323. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18324. // }
  18325. // }
  18326. //
  18327. // if item.MedChrgitmType == "14" { //其他费
  18328. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18329. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18330. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18331. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18332. // if item.ChrgitmLv == "1" {
  18333. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18334. //
  18335. // }
  18336. // if item.ChrgitmLv == "2" {
  18337. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18338. //
  18339. // }
  18340. // if item.ChrgitmLv == "3" {
  18341. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18342. // }
  18343. // }
  18344. //
  18345. // }
  18346. //
  18347. // var iteminfoStructs []service.IteminfoStruct
  18348. //
  18349. // if bedCostTotal != 0 {
  18350. // iteminfo.MedChrgitm = "01"
  18351. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18352. // iteminfo.Amt = bedCostTotal
  18353. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18354. // iteminfo.ClabAmt = bed_clab_amt
  18355. // iteminfo.OthAmt = bed_other_amt
  18356. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18357. // }
  18358. //
  18359. // if checkCostTotal != 0 {
  18360. // iteminfo.MedChrgitm = "03"
  18361. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18362. // iteminfo.Amt = checkCostTotal
  18363. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18364. // iteminfo.ClabAmt = check_clab_amt
  18365. // iteminfo.OthAmt = check_other_amt
  18366. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18367. //
  18368. // }
  18369. //
  18370. // if laboratoryCostTotal != 0 {
  18371. // iteminfo.MedChrgitm = "04"
  18372. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18373. // iteminfo.Amt = laboratoryCostTotal
  18374. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18375. // iteminfo.ClabAmt = laboratory_clab_amt
  18376. // iteminfo.OthAmt = laboratory_other_amt
  18377. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18378. //
  18379. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18380. //
  18381. // }
  18382. //
  18383. // if treatCostTotal != 0 {
  18384. // iteminfo.MedChrgitm = "05"
  18385. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18386. // iteminfo.Amt = treatCostTotal
  18387. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18388. // iteminfo.ClabAmt = treat_clab_amt
  18389. // iteminfo.OthAmt = treat_other_amt
  18390. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18391. // //(struct4101.IteminfoStruct, iteminfo)
  18392. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18393. // }
  18394. //
  18395. // if operationCostTotal != 0 {
  18396. // iteminfo.MedChrgitm = "06"
  18397. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18398. // iteminfo.Amt = operationCostTotal
  18399. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18400. // iteminfo.ClabAmt = operation_clab_amt
  18401. // iteminfo.OthAmt = operation_other_amt
  18402. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18403. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18404. // }
  18405. //
  18406. // if materialCostTotal != 0 {
  18407. // iteminfo.MedChrgitm = "08"
  18408. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18409. // iteminfo.Amt = materialCostTotal
  18410. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18411. // iteminfo.ClabAmt = material_clab_amt
  18412. // iteminfo.OthAmt = material_other_amt
  18413. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18414. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18415. // }
  18416. //
  18417. // if westernMedicineCostTotal != 0 {
  18418. // iteminfo.MedChrgitm = "09"
  18419. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18420. // iteminfo.Amt = westernMedicineCostTotal
  18421. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18422. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18423. // iteminfo.OthAmt = westernMedicine_other_amt
  18424. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18425. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18426. //
  18427. // }
  18428. // if chineseTraditionalMedicineCostTotal != 0 {
  18429. // iteminfo.MedChrgitm = "11"
  18430. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18431. // iteminfo.Amt = westernMedicineCostTotal
  18432. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18433. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18434. // iteminfo.OthAmt = westernMedicine_other_amt
  18435. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18436. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18437. //
  18438. // }
  18439. // if otherCostTotal != 0 {
  18440. // iteminfo.MedChrgitm = "14"
  18441. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18442. // iteminfo.Amt = otherCostTotal
  18443. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18444. // iteminfo.ClabAmt = other_clab_amt
  18445. // iteminfo.OthAmt = other_other_amt
  18446. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18447. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18448. //
  18449. // }
  18450. // struct4101.IteminfoStruct = iteminfoStructs
  18451. // struct4101.Ntly = "中国"
  18452. // struct4101.AdmCaty = "A03.06"
  18453. //
  18454. // struct4101.DoctorName = doctor.UserName
  18455. // struct4101.DoctorCode = doctor.DoctorNumber
  18456. //
  18457. // var res ResultSeventeen
  18458. //
  18459. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18460. // struct4101.BillCode = order.Number
  18461. // struct4101.BillNo = order.SetlId
  18462. // var resOther ResultSeventeenOther
  18463. // var pp models.PublicParams
  18464. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18465. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18466. // pp.FixmedinsName = miConfig.OrgName
  18467. // pp.FixmedinsCode = miConfig.Code
  18468. // pp.RequestUrl = miConfig.Url
  18469. // pp.Cainfo = miConfig.Cainfo
  18470. // pp.SecretKey = miConfig.SecretKey
  18471. // pp.AccessKey = miConfig.AccessKey
  18472. // pp.OpterName = curRoles.UserName
  18473. //
  18474. // client := &http.Client{}
  18475. // var req *http.Request
  18476. // data := make(map[string]interface{})
  18477. // data["struct4101"] = struct4101
  18478. // data["pp"] = pp
  18479. // bytesData, _ := json.Marshal(data)
  18480. // if miConfig.MdtrtareaAdmvs == "320921" {
  18481. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18482. // } else {
  18483. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18484. // }
  18485. // resp, _ := client.Do(req)
  18486. // defer resp.Body.Close()
  18487. // body, ioErr := ioutil.ReadAll(resp.Body)
  18488. // if ioErr != nil {
  18489. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18490. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18491. // return
  18492. // }
  18493. // var respJSON map[string]interface{}
  18494. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18495. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18497. // return
  18498. // }
  18499. //
  18500. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18501. // userJSONBytes, _ := json.Marshal(respJSON)
  18502. // fmt.Println("log")
  18503. // fmt.Println(string(userJSONBytes))
  18504. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18505. // utils.ErrorLog("解析失败:%v", err)
  18506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18507. // return
  18508. // }
  18509. // res.InfRefmsgid = resOther.InfRefmsgid
  18510. // res.Output = resOther.Output
  18511. // res.ErrMsg = resOther.ErrMsg
  18512. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18513. // res.Infcode = infocode
  18514. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18515. //
  18516. // var pp models.PublicParams
  18517. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18518. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18519. // pp.FixmedinsName = miConfig.OrgName
  18520. // pp.FixmedinsCode = miConfig.Code
  18521. // pp.RequestUrl = miConfig.Url
  18522. // pp.Cainfo = miConfig.Cainfo
  18523. // pp.SecretKey = miConfig.SecretKey
  18524. // pp.AccessKey = miConfig.AccessKey
  18525. // pp.OpterName = curRoles.UserName
  18526. // result, _ := service.Jxyb4101(struct4101, pp)
  18527. // var dat map[string]interface{}
  18528. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18529. // fmt.Println(dat)
  18530. // } else {
  18531. // fmt.Println(err)
  18532. // }
  18533. // userJSONBytes, _ := json.Marshal(dat)
  18534. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18535. // utils.ErrorLog("解析失败:%v", err)
  18536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18537. // return
  18538. // }
  18539. //
  18540. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18541. // var pp models.PublicParams
  18542. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18543. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18544. // pp.FixmedinsName = miConfig.OrgName
  18545. // pp.FixmedinsCode = miConfig.Code
  18546. // pp.RequestUrl = miConfig.Url
  18547. // pp.Cainfo = miConfig.Cainfo
  18548. // pp.SecretKey = miConfig.SecretKey
  18549. // pp.AccessKey = miConfig.AccessKey
  18550. // pp.OpterName = curRoles.UserName
  18551. // result, _ := service.Hnyb4101(struct4101, pp)
  18552. // var dat map[string]interface{}
  18553. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18554. // fmt.Println(dat)
  18555. // } else {
  18556. // fmt.Println(err)
  18557. // }
  18558. // userJSONBytes, _ := json.Marshal(dat)
  18559. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18560. // utils.ErrorLog("解析失败:%v", err)
  18561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18562. // return
  18563. // }
  18564. //
  18565. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18566. // var resOther ResultSeventeenOther
  18567. //
  18568. // var pp models.PublicParams
  18569. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18570. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18571. // pp.FixmedinsName = miConfig.OrgName
  18572. // pp.FixmedinsCode = miConfig.Code
  18573. // pp.RequestUrl = miConfig.Url
  18574. // pp.Cainfo = miConfig.Cainfo
  18575. // pp.SecretKey = miConfig.SecretKey
  18576. // pp.AccessKey = miConfig.AccessKey
  18577. // pp.OpterName = curRoles.UserName
  18578. // client := &http.Client{}
  18579. // var req *http.Request
  18580. // data := make(map[string]interface{})
  18581. // data["struct4101"] = struct4101
  18582. // data["pp"] = pp
  18583. // bytesData, _ := json.Marshal(data)
  18584. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18585. // resp, _ := client.Do(req)
  18586. // defer resp.Body.Close()
  18587. // body, ioErr := ioutil.ReadAll(resp.Body)
  18588. // if ioErr != nil {
  18589. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18591. // return
  18592. // }
  18593. // var respJSON map[string]interface{}
  18594. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18595. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18597. // return
  18598. // }
  18599. //
  18600. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18601. // userJSONBytes, _ := json.Marshal(respJSON)
  18602. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18603. // utils.ErrorLog("解析失败:%v", err)
  18604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18605. // return
  18606. // }
  18607. // res.InfRefmsgid = resOther.InfRefmsgid
  18608. // res.Output = resOther.Output
  18609. // res.ErrMsg = resOther.ErrMsg
  18610. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18611. // res.Infcode = infocode
  18612. //
  18613. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18614. // var pp models.PublicParams
  18615. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18616. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18617. // pp.FixmedinsName = miConfig.OrgName
  18618. // pp.FixmedinsCode = miConfig.Code
  18619. // pp.RequestUrl = miConfig.Url
  18620. // pp.Cainfo = miConfig.Cainfo
  18621. // pp.SecretKey = miConfig.SecretKey
  18622. // pp.AccessKey = miConfig.AccessKey
  18623. // pp.OpterName = curRoles.UserName
  18624. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18625. // fmt.Println(requestLog)
  18626. // fmt.Println(errMsgLog)
  18627. //
  18628. // saveLog(result, requestLog, "4101a", "上传清单")
  18629. //
  18630. // var dat map[string]interface{}
  18631. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18632. // fmt.Println(dat)
  18633. // } else {
  18634. // fmt.Println(err)
  18635. // }
  18636. // userJSONBytes, _ := json.Marshal(dat)
  18637. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18638. // utils.ErrorLog("解析失败:%v", err)
  18639. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18640. // return
  18641. // }
  18642. //
  18643. // } else {
  18644. //
  18645. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18646. // var dat map[string]interface{}
  18647. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18648. // fmt.Println(dat)
  18649. // } else {
  18650. // fmt.Println(err)
  18651. // }
  18652. // userJSONBytes, _ := json.Marshal(dat)
  18653. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18654. // utils.ErrorLog("解析失败:%v", err)
  18655. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18656. // return
  18657. // }
  18658. // }
  18659. //
  18660. // if res.Infcode != 0 {
  18661. // adminUser := c.GetAdminUserInfo()
  18662. // errlog := &models.HisOrderError{
  18663. // UserOrgId: adminUser.CurrentOrgId,
  18664. // Ctime: time.Now().Unix(),
  18665. // Mtime: time.Now().Unix(),
  18666. // ErrMsg: res.ErrMsg,
  18667. // Status: 1,
  18668. // PatientId: order.ID,
  18669. // Stage: 10265,
  18670. // }
  18671. // service.CreateErrMsgLog(errlog)
  18672. // continue
  18673. // } else {
  18674. // //order.FaPiaoNumber = zero
  18675. // //order.FaPiaoCode = last_order.FaPiaoCode
  18676. // //service.UpdateOrder(order)
  18677. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18678. // Number: res.Output.SetlListId,
  18679. // Status: 1,
  18680. // Ctime: time.Now().Unix(),
  18681. // Mtime: time.Now().Unix(),
  18682. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18683. // IsUpload: 1,
  18684. // OrderId: order.ID,
  18685. // }
  18686. // service.CreateUploadRecord(hisFundSettleListResult)
  18687. // c.ServeSuccessJSON(map[string]interface{}{
  18688. // "msg": "上传成功",
  18689. // "result": hisFundSettleListResult,
  18690. // })
  18691. // continue
  18692. // }
  18693. // }
  18694. //}
  18695. func (c *HisApiController) GetbatchSettleList() {
  18696. //order_id, _ := c.GetInt64("order_id")
  18697. admin_user_id, _ := c.GetInt64("admin_user_id")
  18698. orders, _ := service.GetAllHisOrderTwo10485()
  18699. for _, item := range orders {
  18700. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18701. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18702. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18703. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18704. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18705. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18706. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18707. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18708. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18709. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18710. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18711. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18712. //fmt.Println(count)
  18713. //var zero string
  18714. //number := count + 1
  18715. //if number >= 1000 {
  18716. // zero = "0000" + strconv.FormatInt(number, 10)
  18717. //} else if number >= 10000 {
  18718. // zero = "000" + strconv.FormatInt(number, 10)
  18719. //} else if number >= 100000 {
  18720. // zero = "00" + strconv.FormatInt(number, 10)
  18721. //} else if number >= 1000000 {
  18722. // zero = "0" + strconv.FormatInt(number, 10)
  18723. //} else {
  18724. // zero = strconv.FormatInt(number, 10)
  18725. //}
  18726. //fmt.Println(zero)
  18727. struct4101 := service.Struct4101{
  18728. PsnNo: order.PsnNo,
  18729. MdtrtId: order.MdtrtId,
  18730. SetlId: order.SetlId,
  18731. PsnName: order.PsnName,
  18732. Gend: order.Gend,
  18733. Brdy: his.Brdy,
  18734. Age: his.Age,
  18735. Naty: order.Naty,
  18736. PatnCertType: "01",
  18737. Certno: order.Certno,
  18738. Prfs: "90",
  18739. ConerName: roles[0].UserName,
  18740. PatnRlts: "99",
  18741. ConerAddr: miConfig.OrgName,
  18742. ConerTel: admin.Mobile,
  18743. HiType: order.Insutype,
  18744. Insuplc: miConfig.InsuplcAdmdvs,
  18745. MaindiagFlag: "1",
  18746. BillCode: order.SetlId,
  18747. BillNo: order.SetlId,
  18748. BizSn: order.Number,
  18749. PsnSelfPay: order.PsnPartAmt,
  18750. PsnOwnPay: order.PsnPartAmt,
  18751. AcctPay: order.AcctPay,
  18752. PsnCashpay: order.PsnCashPay,
  18753. HiPaymtd: "1",
  18754. Hsorg: miConfig.InsuplcAdmdvs,
  18755. HsorgOpter: miConfig.InsuplcAdmdvs,
  18756. MedinsFillPsn: curRoles.UserName,
  18757. MedinsFillDept: miConfig.OrgName,
  18758. IptMedType: "2",
  18759. }
  18760. struct4101.SetlBegnDate = order.SetlTime
  18761. struct4101.SetlEndDate = order.SetlTime
  18762. time_arr := strings.Split(order.SetlTime, " ")
  18763. struct4101.AdmTime = time_arr[0]
  18764. struct4101.AdmEndTime = time_arr[0]
  18765. //var rf []CustomFundPay
  18766. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18767. //
  18768. //var tempFunPays []service.CustomStruct
  18769. //for _, item := range rf {
  18770. // var tempFunPay service.CustomStruct
  18771. // tempFunPay.FundPayamt = item.FundPayamt
  18772. // tempFunPay.FundPayType = item.FundPayType
  18773. // tempFunPays = append(tempFunPays, tempFunPay)
  18774. //}
  18775. //struct4101.CustomStruct = tempFunPays
  18776. var tempDiaginfos []service.DiaginfoStructTwo
  18777. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18778. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18779. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18780. var config []*models.HisXtDiagnoseConfig
  18781. for _, item := range diagnosis_ids {
  18782. id, _ := strconv.ParseInt(item, 10, 64)
  18783. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18784. config = append(config, &diagnosisConfig)
  18785. }
  18786. for index, item := range config {
  18787. if index == 0 {
  18788. var tempDiaginfo service.DiaginfoStructTwo
  18789. tempDiaginfo.DiagCode = item.CountryCode
  18790. tempDiaginfo.DiagName = item.CountryContentName
  18791. tempDiaginfo.DiagType = "1"
  18792. tempDiaginfo.MaindiagFlag = "1"
  18793. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18794. } else {
  18795. var tempDiaginfo service.DiaginfoStructTwo
  18796. tempDiaginfo.DiagCode = item.CountryCode
  18797. tempDiaginfo.DiagName = item.CountryContentName
  18798. tempDiaginfo.DiagType = "1"
  18799. tempDiaginfo.MaindiagFlag = "0"
  18800. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18801. }
  18802. }
  18803. struct4101.Diseinfo = tempDiaginfos
  18804. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18805. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18806. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18807. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18808. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18809. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18810. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18811. var iteminfo service.IteminfoStruct
  18812. var bedCostTotal float64 = 0 //床位总费
  18813. var bedCostSelfTotal float64 = 0 //床位自费
  18814. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18815. var operationCostTotal float64 = 0 //手术费
  18816. var operationCostSelfTotal float64 = 0 //手术费
  18817. var operationCostPartSelfTotal float64 = 0 //手术费
  18818. var otherCostTotal float64 = 0 //其他费用
  18819. var otherCostSelfTotal float64 = 0 //其他费用
  18820. var otherCostPartSelfTotal float64 = 0 //其他费用
  18821. var materialCostTotal float64 = 0 //材料费
  18822. var materialCostSelfTotal float64 = 0 //材料费
  18823. var materialCostPartSelfTotal float64 = 0 //材料费
  18824. var westernMedicineCostTotal float64 = 0 //西药费
  18825. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18826. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18827. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18828. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18829. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18830. var checkCostTotal float64 = 0 //检查费
  18831. var checkCostSelfTotal float64 = 0 //检查费
  18832. var checkCostPartSelfTotal float64 = 0 //检查费
  18833. var laboratoryCostTotal float64 = 0 //化验费
  18834. var laboratoryCostSelfTotal float64 = 0 //化验费
  18835. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18836. var treatCostTotal float64 = 0 //治疗费用
  18837. var treatCostSelfTotal float64 = 0 //治疗费用
  18838. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18839. decimal.DivisionPrecision = 2
  18840. var bed_fulamt_ownpay_amt float64 = 0
  18841. var operation_fulamt_ownpay_amt float64 = 0
  18842. var other_fulamt_ownpay_amt float64 = 0
  18843. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18844. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18845. var check_fulamt_ownpay_amt float64 = 0
  18846. var material_fulamt_ownpay_amt float64 = 0
  18847. var laboratory_fulamt_ownpay_amt float64 = 0
  18848. var treat_fulamt_ownpay_amt float64 = 0
  18849. var bed_claa_sunmfee float64 = 0
  18850. var bed_clab_amt float64 = 0
  18851. var bed_other_amt float64 = 0
  18852. var operation_claa_sunmfee float64 = 0
  18853. var operation_clab_amt float64 = 0
  18854. var operation_other_amt float64 = 0
  18855. var other_claa_sunmfee float64 = 0
  18856. var other_clab_amt float64 = 0
  18857. var other_other_amt float64 = 0
  18858. var westernMedicine_claa_sunmfee float64 = 0
  18859. var westernMedicine_clab_amt float64 = 0
  18860. var westernMedicine_other_amt float64 = 0
  18861. var chineseTraditional_claa_sunmfee float64 = 0
  18862. var chineseTraditional_clab_amt float64 = 0
  18863. var chineseTraditional_other_amt float64 = 0
  18864. var check_claa_sunmfee float64 = 0
  18865. var check_clab_amt float64 = 0
  18866. var check_other_amt float64 = 0
  18867. var material_claa_sunmfee float64 = 0
  18868. var material_clab_amt float64 = 0
  18869. var material_other_amt float64 = 0
  18870. var laboratory_claa_sunmfee float64 = 0
  18871. var laboratory_clab_amt float64 = 0
  18872. var laboratory_other_amt float64 = 0
  18873. var treat_claa_sunmfee float64 = 0
  18874. var treat_clab_amt float64 = 0
  18875. var treat_other_amt float64 = 0
  18876. for _, item := range order.HisOrderInfo {
  18877. if item.MedChrgitmType == "01" { //床位费
  18878. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18879. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18880. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18881. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18882. if item.ChrgitmLv == "1" {
  18883. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18884. }
  18885. if item.ChrgitmLv == "2" {
  18886. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18887. }
  18888. if item.ChrgitmLv == "3" {
  18889. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18890. }
  18891. }
  18892. if item.MedChrgitmType == "03" { //检查费
  18893. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18894. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18895. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18896. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18897. if item.ChrgitmLv == "1" {
  18898. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18899. }
  18900. if item.ChrgitmLv == "2" {
  18901. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18902. }
  18903. if item.ChrgitmLv == "3" {
  18904. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18905. }
  18906. }
  18907. if item.MedChrgitmType == "04" { //化验费
  18908. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18909. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18910. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18911. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18912. if item.ChrgitmLv == "1" {
  18913. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18914. }
  18915. if item.ChrgitmLv == "2" {
  18916. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18917. }
  18918. if item.ChrgitmLv == "3" {
  18919. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18920. }
  18921. }
  18922. if item.MedChrgitmType == "05" { //治疗费
  18923. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18924. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18925. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18926. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18927. if item.ChrgitmLv == "1" {
  18928. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18929. }
  18930. if item.ChrgitmLv == "2" {
  18931. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18932. }
  18933. if item.ChrgitmLv == "3" {
  18934. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18935. }
  18936. }
  18937. if item.MedChrgitmType == "06" { //手术费
  18938. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18939. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18940. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18941. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18942. if item.ChrgitmLv == "1" {
  18943. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18944. }
  18945. if item.ChrgitmLv == "2" {
  18946. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18947. }
  18948. if item.ChrgitmLv == "3" {
  18949. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18950. }
  18951. }
  18952. if item.MedChrgitmType == "08" { //材料费
  18953. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18954. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18955. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18956. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18957. if item.ChrgitmLv == "1" {
  18958. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18959. }
  18960. if item.ChrgitmLv == "2" {
  18961. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18962. }
  18963. if item.ChrgitmLv == "3" {
  18964. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18965. }
  18966. }
  18967. if item.MedChrgitmType == "09" { //西药费
  18968. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18969. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18970. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18971. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18972. if item.ChrgitmLv == "1" {
  18973. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18974. }
  18975. if item.ChrgitmLv == "2" {
  18976. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18977. }
  18978. if item.ChrgitmLv == "3" {
  18979. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18980. }
  18981. }
  18982. if item.MedChrgitmType == "11" { //中成费
  18983. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18984. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18985. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18986. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18987. if item.ChrgitmLv == "1" {
  18988. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18989. }
  18990. if item.ChrgitmLv == "2" {
  18991. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18992. }
  18993. if item.ChrgitmLv == "3" {
  18994. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18995. }
  18996. }
  18997. if item.MedChrgitmType == "14" { //其他费
  18998. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18999. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19000. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19001. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19002. if item.ChrgitmLv == "1" {
  19003. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19004. }
  19005. if item.ChrgitmLv == "2" {
  19006. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19007. }
  19008. if item.ChrgitmLv == "3" {
  19009. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19010. }
  19011. }
  19012. }
  19013. var iteminfoStructs []service.IteminfoStruct
  19014. if bedCostTotal != 0 {
  19015. iteminfo.MedChrgitm = "01"
  19016. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19017. iteminfo.Amt = bedCostTotal
  19018. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19019. iteminfo.ClabAmt = bed_clab_amt
  19020. iteminfo.OthAmt = bed_other_amt
  19021. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19022. }
  19023. if checkCostTotal != 0 {
  19024. iteminfo.MedChrgitm = "03"
  19025. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19026. iteminfo.Amt = checkCostTotal
  19027. iteminfo.ClaaSumfee = check_claa_sunmfee
  19028. iteminfo.ClabAmt = check_clab_amt
  19029. iteminfo.OthAmt = check_other_amt
  19030. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19031. }
  19032. if laboratoryCostTotal != 0 {
  19033. iteminfo.MedChrgitm = "04"
  19034. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19035. iteminfo.Amt = laboratoryCostTotal
  19036. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19037. iteminfo.ClabAmt = laboratory_clab_amt
  19038. iteminfo.OthAmt = laboratory_other_amt
  19039. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19040. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19041. }
  19042. if treatCostTotal != 0 {
  19043. iteminfo.MedChrgitm = "05"
  19044. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19045. iteminfo.Amt = treatCostTotal
  19046. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19047. iteminfo.ClabAmt = treat_clab_amt
  19048. iteminfo.OthAmt = treat_other_amt
  19049. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19050. //(struct4101.IteminfoStruct, iteminfo)
  19051. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19052. }
  19053. if operationCostTotal != 0 {
  19054. iteminfo.MedChrgitm = "06"
  19055. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19056. iteminfo.Amt = operationCostTotal
  19057. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19058. iteminfo.ClabAmt = operation_clab_amt
  19059. iteminfo.OthAmt = operation_other_amt
  19060. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19061. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19062. }
  19063. if materialCostTotal != 0 {
  19064. iteminfo.MedChrgitm = "08"
  19065. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19066. iteminfo.Amt = materialCostTotal
  19067. iteminfo.ClaaSumfee = material_claa_sunmfee
  19068. iteminfo.ClabAmt = material_clab_amt
  19069. iteminfo.OthAmt = material_other_amt
  19070. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19071. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19072. }
  19073. if westernMedicineCostTotal != 0 {
  19074. iteminfo.MedChrgitm = "09"
  19075. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19076. iteminfo.Amt = westernMedicineCostTotal
  19077. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19078. iteminfo.ClabAmt = westernMedicine_clab_amt
  19079. iteminfo.OthAmt = westernMedicine_other_amt
  19080. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19081. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19082. }
  19083. if chineseTraditionalMedicineCostTotal != 0 {
  19084. iteminfo.MedChrgitm = "11"
  19085. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19086. iteminfo.Amt = westernMedicineCostTotal
  19087. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19088. iteminfo.ClabAmt = westernMedicine_clab_amt
  19089. iteminfo.OthAmt = westernMedicine_other_amt
  19090. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19091. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19092. }
  19093. if otherCostTotal != 0 {
  19094. iteminfo.MedChrgitm = "14"
  19095. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19096. iteminfo.Amt = otherCostTotal
  19097. iteminfo.ClaaSumfee = other_claa_sunmfee
  19098. iteminfo.ClabAmt = other_clab_amt
  19099. iteminfo.OthAmt = other_other_amt
  19100. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19101. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19102. }
  19103. struct4101.IteminfoStruct = iteminfoStructs
  19104. struct4101.Ntly = "中国"
  19105. struct4101.AdmCaty = "A03.06"
  19106. struct4101.DoctorName = doctor.UserName
  19107. struct4101.DoctorCode = doctor.DoctorNumber
  19108. var res ResultSeventeen
  19109. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19110. struct4101.BillCode = order.Number
  19111. struct4101.BillNo = order.SetlId
  19112. var resOther ResultSeventeenOther
  19113. var pp models.PublicParams
  19114. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19115. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19116. pp.FixmedinsName = miConfig.OrgName
  19117. pp.FixmedinsCode = miConfig.Code
  19118. pp.RequestUrl = miConfig.Url
  19119. pp.Cainfo = miConfig.Cainfo
  19120. pp.SecretKey = miConfig.SecretKey
  19121. pp.AccessKey = miConfig.AccessKey
  19122. pp.OpterName = curRoles.UserName
  19123. client := &http.Client{}
  19124. var req *http.Request
  19125. data := make(map[string]interface{})
  19126. data["struct4101"] = struct4101
  19127. data["pp"] = pp
  19128. bytesData, _ := json.Marshal(data)
  19129. if miConfig.MdtrtareaAdmvs == "320921" {
  19130. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19131. } else {
  19132. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19133. }
  19134. resp, _ := client.Do(req)
  19135. defer resp.Body.Close()
  19136. body, ioErr := ioutil.ReadAll(resp.Body)
  19137. if ioErr != nil {
  19138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19140. return
  19141. }
  19142. var respJSON map[string]interface{}
  19143. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19146. return
  19147. }
  19148. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19149. userJSONBytes, _ := json.Marshal(respJSON)
  19150. fmt.Println("log")
  19151. fmt.Println(string(userJSONBytes))
  19152. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19153. utils.ErrorLog("解析失败:%v", err)
  19154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19155. return
  19156. }
  19157. res.InfRefmsgid = resOther.InfRefmsgid
  19158. res.Output = resOther.Output
  19159. res.ErrMsg = resOther.ErrMsg
  19160. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19161. res.Infcode = infocode
  19162. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19163. var pp models.PublicParams
  19164. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19165. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19166. pp.FixmedinsName = miConfig.OrgName
  19167. pp.FixmedinsCode = miConfig.Code
  19168. pp.RequestUrl = miConfig.Url
  19169. pp.Cainfo = miConfig.Cainfo
  19170. pp.SecretKey = miConfig.SecretKey
  19171. pp.AccessKey = miConfig.AccessKey
  19172. pp.OpterName = curRoles.UserName
  19173. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19174. result, _ := service.Jxyb4101(struct4101, pp)
  19175. var dat map[string]interface{}
  19176. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19177. fmt.Println(dat)
  19178. } else {
  19179. fmt.Println(err)
  19180. }
  19181. userJSONBytes, _ := json.Marshal(dat)
  19182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19183. utils.ErrorLog("解析失败:%v", err)
  19184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19185. return
  19186. }
  19187. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19188. var pp models.PublicParams
  19189. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19190. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19191. pp.FixmedinsName = miConfig.OrgName
  19192. pp.FixmedinsCode = miConfig.Code
  19193. pp.RequestUrl = miConfig.Url
  19194. pp.Cainfo = miConfig.Cainfo
  19195. pp.SecretKey = miConfig.SecretKey
  19196. pp.AccessKey = miConfig.AccessKey
  19197. pp.OpterName = curRoles.UserName
  19198. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19199. result, _ := service.Jxyb4101(struct4101, pp)
  19200. var dat map[string]interface{}
  19201. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19202. fmt.Println(dat)
  19203. } else {
  19204. fmt.Println(err)
  19205. }
  19206. userJSONBytes, _ := json.Marshal(dat)
  19207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19208. utils.ErrorLog("解析失败:%v", err)
  19209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19210. return
  19211. }
  19212. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19213. var pp models.PublicParams
  19214. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19215. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19216. pp.FixmedinsName = miConfig.OrgName
  19217. pp.FixmedinsCode = miConfig.Code
  19218. pp.RequestUrl = miConfig.Url
  19219. pp.Cainfo = miConfig.Cainfo
  19220. pp.SecretKey = miConfig.SecretKey
  19221. pp.AccessKey = miConfig.AccessKey
  19222. pp.OpterName = curRoles.UserName
  19223. result, _ := service.Hnyb4101(struct4101, pp)
  19224. var dat map[string]interface{}
  19225. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19226. fmt.Println(dat)
  19227. } else {
  19228. fmt.Println(err)
  19229. }
  19230. userJSONBytes, _ := json.Marshal(dat)
  19231. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19232. utils.ErrorLog("解析失败:%v", err)
  19233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19234. return
  19235. }
  19236. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19237. var resOther ResultSeventeenOther
  19238. var pp models.PublicParams
  19239. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19240. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19241. pp.FixmedinsName = miConfig.OrgName
  19242. pp.FixmedinsCode = miConfig.Code
  19243. pp.RequestUrl = miConfig.Url
  19244. pp.Cainfo = miConfig.Cainfo
  19245. pp.SecretKey = miConfig.SecretKey
  19246. pp.AccessKey = miConfig.AccessKey
  19247. pp.OpterName = curRoles.UserName
  19248. client := &http.Client{}
  19249. var req *http.Request
  19250. data := make(map[string]interface{})
  19251. data["struct4101"] = struct4101
  19252. data["pp"] = pp
  19253. bytesData, _ := json.Marshal(data)
  19254. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19255. resp, _ := client.Do(req)
  19256. defer resp.Body.Close()
  19257. body, ioErr := ioutil.ReadAll(resp.Body)
  19258. if ioErr != nil {
  19259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19261. return
  19262. }
  19263. var respJSON map[string]interface{}
  19264. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19267. return
  19268. }
  19269. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19270. userJSONBytes, _ := json.Marshal(respJSON)
  19271. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19272. utils.ErrorLog("解析失败:%v", err)
  19273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19274. return
  19275. }
  19276. res.InfRefmsgid = resOther.InfRefmsgid
  19277. res.Output = resOther.Output
  19278. res.ErrMsg = resOther.ErrMsg
  19279. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19280. res.Infcode = infocode
  19281. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19282. var pp models.PublicParams
  19283. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19284. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19285. pp.FixmedinsName = miConfig.OrgName
  19286. pp.FixmedinsCode = miConfig.Code
  19287. pp.RequestUrl = miConfig.Url
  19288. pp.Cainfo = miConfig.Cainfo
  19289. pp.SecretKey = miConfig.SecretKey
  19290. pp.AccessKey = miConfig.AccessKey
  19291. pp.OpterName = curRoles.UserName
  19292. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19293. fmt.Println(requestLog)
  19294. fmt.Println(errMsgLog)
  19295. saveLog(result, requestLog, "4101a", "上传清单")
  19296. var dat map[string]interface{}
  19297. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19298. fmt.Println(dat)
  19299. } else {
  19300. fmt.Println(err)
  19301. }
  19302. userJSONBytes, _ := json.Marshal(dat)
  19303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19304. utils.ErrorLog("解析失败:%v", err)
  19305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19306. return
  19307. }
  19308. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19309. var pp models.PublicParams
  19310. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19311. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19312. pp.FixmedinsName = miConfig.OrgName
  19313. pp.FixmedinsCode = miConfig.Code
  19314. pp.RequestUrl = miConfig.Url
  19315. pp.Cainfo = miConfig.Cainfo
  19316. pp.SecretKey = miConfig.SecretKey
  19317. pp.AccessKey = miConfig.AccessKey
  19318. pp.OpterName = curRoles.UserName
  19319. client := &http.Client{}
  19320. var req *http.Request
  19321. data := make(map[string]interface{})
  19322. data["struct4101"] = struct4101
  19323. data["pp"] = pp
  19324. bytesData, _ := json.Marshal(data)
  19325. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19326. resp, _ := client.Do(req)
  19327. defer resp.Body.Close()
  19328. body, ioErr := ioutil.ReadAll(resp.Body)
  19329. if ioErr != nil {
  19330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19332. return
  19333. }
  19334. var respJSON map[string]interface{}
  19335. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19338. return
  19339. }
  19340. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19341. userJSONBytes, _ := json.Marshal(respJSON)
  19342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19343. utils.ErrorLog("解析失败:%v", err)
  19344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19345. return
  19346. }
  19347. } else {
  19348. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19349. var dat map[string]interface{}
  19350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19351. fmt.Println(dat)
  19352. } else {
  19353. fmt.Println(err)
  19354. }
  19355. userJSONBytes, _ := json.Marshal(dat)
  19356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19357. utils.ErrorLog("解析失败:%v", err)
  19358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19359. return
  19360. }
  19361. }
  19362. if res.Infcode != 0 {
  19363. errlog := &models.HisOrderError{
  19364. UserOrgId: order.UserOrgId,
  19365. Ctime: time.Now().Unix(),
  19366. Mtime: time.Now().Unix(),
  19367. ErrMsg: res.ErrMsg + "解析失败",
  19368. Status: 1,
  19369. PatientId: order.ID,
  19370. Stage: 10485,
  19371. }
  19372. service.CreateErrMsgLog(errlog)
  19373. continue
  19374. //c.ServeSuccessJSON(map[string]interface{}{
  19375. // "failed_code": -10,
  19376. // "msg": res.ErrMsg,
  19377. //})
  19378. } else {
  19379. //order.FaPiaoNumber = zero
  19380. //order.FaPiaoCode = last_order.FaPiaoCode
  19381. //service.UpdateOrder(order)
  19382. hisFundSettleListResult := &models.HisFundSettleListResult{
  19383. Number: res.Output.SetlListId,
  19384. Status: 1,
  19385. Ctime: time.Now().Unix(),
  19386. Mtime: time.Now().Unix(),
  19387. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19388. IsUpload: 1,
  19389. OrderId: order.ID,
  19390. }
  19391. service.CreateUploadRecord(hisFundSettleListResult)
  19392. continue
  19393. }
  19394. }
  19395. }
  19396. func (c *HisApiController) GetSettleList() {
  19397. order_id, _ := c.GetInt64("order_id")
  19398. admin_user_id, _ := c.GetInt64("admin_user_id")
  19399. order, _ := service.GetHisOrderByIDTwo(order_id)
  19400. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19401. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19402. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19403. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19404. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19405. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19406. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19407. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19408. if order.ID == 0 {
  19409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19410. return
  19411. }
  19412. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19413. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19414. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19415. //fmt.Println(count)
  19416. //var zero string
  19417. //number := count + 1
  19418. //if number >= 1000 {
  19419. // zero = "0000" + strconv.FormatInt(number, 10)
  19420. //} else if number >= 10000 {
  19421. // zero = "000" + strconv.FormatInt(number, 10)
  19422. //} else if number >= 100000 {
  19423. // zero = "00" + strconv.FormatInt(number, 10)
  19424. //} else if number >= 1000000 {
  19425. // zero = "0" + strconv.FormatInt(number, 10)
  19426. //} else {
  19427. // zero = strconv.FormatInt(number, 10)
  19428. //}
  19429. //fmt.Println(zero)
  19430. struct4101 := service.Struct4101{
  19431. PsnNo: order.PsnNo,
  19432. MdtrtId: order.MdtrtId,
  19433. SetlId: order.SetlId,
  19434. PsnName: order.PsnName,
  19435. Gend: order.Gend,
  19436. Brdy: his.Brdy,
  19437. Age: his.Age,
  19438. Naty: order.Naty,
  19439. PatnCertType: "01",
  19440. Certno: order.Certno,
  19441. Prfs: "90",
  19442. ConerName: roles[0].UserName,
  19443. PatnRlts: "99",
  19444. ConerAddr: miConfig.OrgName,
  19445. ConerTel: admin.Mobile,
  19446. HiType: order.Insutype,
  19447. Insuplc: miConfig.InsuplcAdmdvs,
  19448. MaindiagFlag: "1",
  19449. BillCode: order.SetlId,
  19450. BillNo: order.SetlId,
  19451. BizSn: order.Number,
  19452. PsnSelfPay: order.PsnPartAmt,
  19453. PsnOwnPay: order.PsnPartAmt,
  19454. AcctPay: order.AcctPay,
  19455. PsnCashpay: order.PsnCashPay,
  19456. HiPaymtd: "1",
  19457. Hsorg: miConfig.InsuplcAdmdvs,
  19458. HsorgOpter: miConfig.InsuplcAdmdvs,
  19459. MedinsFillPsn: curRoles.UserName,
  19460. MedinsFillDept: miConfig.OrgName,
  19461. IptMedType: "2",
  19462. }
  19463. struct4101.SetlBegnDate = order.SetlTime
  19464. struct4101.SetlEndDate = order.SetlTime
  19465. time_arr := strings.Split(order.SetlTime, " ")
  19466. struct4101.AdmTime = time_arr[0]
  19467. struct4101.AdmEndTime = time_arr[0]
  19468. //
  19469. //var rf []CustomFundPay
  19470. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19471. //
  19472. //var tempFunPays []service.CustomStruct
  19473. //for _, item := range rf {
  19474. // var tempFunPay service.CustomStruct
  19475. // tempFunPay.FundPayamt = item.FundPayamt
  19476. // tempFunPay.FundPayType = item.FundPayType
  19477. // tempFunPays = append(tempFunPays, tempFunPay)
  19478. //}
  19479. //struct4101.CustomStruct = tempFunPays
  19480. var tempDiaginfos []service.DiaginfoStructTwo
  19481. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19482. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19483. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19484. var config []*models.HisXtDiagnoseConfig
  19485. for _, item := range diagnosis_ids {
  19486. id, _ := strconv.ParseInt(item, 10, 64)
  19487. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19488. config = append(config, &diagnosisConfig)
  19489. }
  19490. if miConfig.Code == "H15049901371" {
  19491. //for _, item := range config {
  19492. // if item.ID == 138 {
  19493. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19494. var tempDiaginfo service.DiaginfoStructTwo
  19495. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19496. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19497. tempDiaginfo.DiagType = "1"
  19498. tempDiaginfo.MaindiagFlag = "1"
  19499. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19500. //}
  19501. //}
  19502. for _, item := range config {
  19503. if item.ID != 138 {
  19504. var tempDiaginfo service.DiaginfoStructTwo
  19505. tempDiaginfo.DiagCode = item.CountryCode
  19506. tempDiaginfo.DiagName = item.CountryContentName
  19507. tempDiaginfo.DiagType = "1"
  19508. tempDiaginfo.MaindiagFlag = "0"
  19509. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19510. }
  19511. }
  19512. } else {
  19513. for index, item := range config {
  19514. if index == 0 {
  19515. var tempDiaginfo service.DiaginfoStructTwo
  19516. tempDiaginfo.DiagCode = item.CountryCode
  19517. tempDiaginfo.DiagName = item.CountryContentName
  19518. tempDiaginfo.DiagType = "1"
  19519. tempDiaginfo.MaindiagFlag = "1"
  19520. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19521. } else {
  19522. var tempDiaginfo service.DiaginfoStructTwo
  19523. tempDiaginfo.DiagCode = item.CountryCode
  19524. tempDiaginfo.DiagName = item.CountryContentName
  19525. tempDiaginfo.DiagType = "1"
  19526. tempDiaginfo.MaindiagFlag = "0"
  19527. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19528. }
  19529. }
  19530. }
  19531. struct4101.Diseinfo = tempDiaginfos
  19532. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19533. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19534. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19535. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19536. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19537. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19538. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19539. var iteminfo service.IteminfoStruct
  19540. var bedCostTotal float64 = 0 //床位总费
  19541. var bedCostSelfTotal float64 = 0 //床位自费
  19542. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19543. var operationCostTotal float64 = 0 //手术费
  19544. var operationCostSelfTotal float64 = 0 //手术费
  19545. var operationCostPartSelfTotal float64 = 0 //手术费
  19546. var otherCostTotal float64 = 0 //其他费用
  19547. var otherCostSelfTotal float64 = 0 //其他费用
  19548. var otherCostPartSelfTotal float64 = 0 //其他费用
  19549. var materialCostTotal float64 = 0 //材料费
  19550. var materialCostSelfTotal float64 = 0 //材料费
  19551. var materialCostPartSelfTotal float64 = 0 //材料费
  19552. var westernMedicineCostTotal float64 = 0 //西药费
  19553. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19554. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19555. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19556. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19557. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19558. var checkCostTotal float64 = 0 //检查费
  19559. var checkCostSelfTotal float64 = 0 //检查费
  19560. var checkCostPartSelfTotal float64 = 0 //检查费
  19561. var laboratoryCostTotal float64 = 0 //化验费
  19562. var laboratoryCostSelfTotal float64 = 0 //化验费
  19563. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19564. var treatCostTotal float64 = 0 //治疗费用
  19565. var treatCostSelfTotal float64 = 0 //治疗费用
  19566. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19567. decimal.DivisionPrecision = 2
  19568. var bed_fulamt_ownpay_amt float64 = 0
  19569. var operation_fulamt_ownpay_amt float64 = 0
  19570. var other_fulamt_ownpay_amt float64 = 0
  19571. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19572. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19573. var check_fulamt_ownpay_amt float64 = 0
  19574. var material_fulamt_ownpay_amt float64 = 0
  19575. var laboratory_fulamt_ownpay_amt float64 = 0
  19576. var treat_fulamt_ownpay_amt float64 = 0
  19577. var bed_claa_sunmfee float64 = 0
  19578. var bed_clab_amt float64 = 0
  19579. var bed_other_amt float64 = 0
  19580. var operation_claa_sunmfee float64 = 0
  19581. var operation_clab_amt float64 = 0
  19582. var operation_other_amt float64 = 0
  19583. var other_claa_sunmfee float64 = 0
  19584. var other_clab_amt float64 = 0
  19585. var other_other_amt float64 = 0
  19586. var westernMedicine_claa_sunmfee float64 = 0
  19587. var westernMedicine_clab_amt float64 = 0
  19588. var westernMedicine_other_amt float64 = 0
  19589. var chineseTraditional_claa_sunmfee float64 = 0
  19590. var chineseTraditional_clab_amt float64 = 0
  19591. var chineseTraditional_other_amt float64 = 0
  19592. var check_claa_sunmfee float64 = 0
  19593. var check_clab_amt float64 = 0
  19594. var check_other_amt float64 = 0
  19595. var material_claa_sunmfee float64 = 0
  19596. var material_clab_amt float64 = 0
  19597. var material_other_amt float64 = 0
  19598. var laboratory_claa_sunmfee float64 = 0
  19599. var laboratory_clab_amt float64 = 0
  19600. var laboratory_other_amt float64 = 0
  19601. var treat_claa_sunmfee float64 = 0
  19602. var treat_clab_amt float64 = 0
  19603. var treat_other_amt float64 = 0
  19604. for _, item := range order.HisOrderInfo {
  19605. if item.MedChrgitmType == "01" { //床位费
  19606. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19607. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19608. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19609. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19610. if item.ChrgitmLv == "1" {
  19611. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19612. }
  19613. if item.ChrgitmLv == "2" {
  19614. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19615. }
  19616. if item.ChrgitmLv == "3" {
  19617. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19618. }
  19619. }
  19620. if item.MedChrgitmType == "03" { //检查费
  19621. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19622. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19623. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19624. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19625. if item.ChrgitmLv == "1" {
  19626. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19627. }
  19628. if item.ChrgitmLv == "2" {
  19629. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19630. }
  19631. if item.ChrgitmLv == "3" {
  19632. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19633. }
  19634. }
  19635. if item.MedChrgitmType == "04" { //化验费
  19636. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19637. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19638. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19639. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19640. if item.ChrgitmLv == "1" {
  19641. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19642. }
  19643. if item.ChrgitmLv == "2" {
  19644. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19645. }
  19646. if item.ChrgitmLv == "3" {
  19647. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19648. }
  19649. }
  19650. if item.MedChrgitmType == "05" { //治疗费
  19651. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19652. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19653. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19654. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19655. if item.ChrgitmLv == "1" {
  19656. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19657. }
  19658. if item.ChrgitmLv == "2" {
  19659. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19660. }
  19661. if item.ChrgitmLv == "3" {
  19662. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19663. }
  19664. }
  19665. if item.MedChrgitmType == "06" { //手术费
  19666. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19667. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19668. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19669. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19670. if item.ChrgitmLv == "1" {
  19671. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19672. }
  19673. if item.ChrgitmLv == "2" {
  19674. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19675. }
  19676. if item.ChrgitmLv == "3" {
  19677. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19678. }
  19679. }
  19680. if item.MedChrgitmType == "08" { //材料费
  19681. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19682. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19683. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19684. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19685. if item.ChrgitmLv == "1" {
  19686. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19687. }
  19688. if item.ChrgitmLv == "2" {
  19689. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19690. }
  19691. if item.ChrgitmLv == "3" {
  19692. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19693. }
  19694. }
  19695. if item.MedChrgitmType == "09" { //西药费
  19696. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19697. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19698. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19699. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19700. if item.ChrgitmLv == "1" {
  19701. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19702. }
  19703. if item.ChrgitmLv == "2" {
  19704. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19705. }
  19706. if item.ChrgitmLv == "3" {
  19707. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19708. }
  19709. }
  19710. if item.MedChrgitmType == "11" { //中成费
  19711. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19712. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19713. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19714. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19715. if item.ChrgitmLv == "1" {
  19716. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19717. }
  19718. if item.ChrgitmLv == "2" {
  19719. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19720. }
  19721. if item.ChrgitmLv == "3" {
  19722. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19723. }
  19724. }
  19725. if item.MedChrgitmType == "14" { //其他费
  19726. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19727. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19728. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19729. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19730. if item.ChrgitmLv == "1" {
  19731. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19732. }
  19733. if item.ChrgitmLv == "2" {
  19734. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19735. }
  19736. if item.ChrgitmLv == "3" {
  19737. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19738. }
  19739. }
  19740. }
  19741. var iteminfoStructs []service.IteminfoStruct
  19742. if bedCostTotal != 0 {
  19743. iteminfo.MedChrgitm = "01"
  19744. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19745. iteminfo.Amt = bedCostTotal
  19746. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19747. iteminfo.ClabAmt = bed_clab_amt
  19748. iteminfo.OthAmt = bed_other_amt
  19749. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19750. }
  19751. if checkCostTotal != 0 {
  19752. iteminfo.MedChrgitm = "03"
  19753. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19754. iteminfo.Amt = checkCostTotal
  19755. iteminfo.ClaaSumfee = check_claa_sunmfee
  19756. iteminfo.ClabAmt = check_clab_amt
  19757. iteminfo.OthAmt = check_other_amt
  19758. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19759. }
  19760. if laboratoryCostTotal != 0 {
  19761. iteminfo.MedChrgitm = "04"
  19762. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19763. iteminfo.Amt = laboratoryCostTotal
  19764. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19765. iteminfo.ClabAmt = laboratory_clab_amt
  19766. iteminfo.OthAmt = laboratory_other_amt
  19767. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19768. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19769. }
  19770. if treatCostTotal != 0 {
  19771. iteminfo.MedChrgitm = "05"
  19772. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19773. iteminfo.Amt = treatCostTotal
  19774. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19775. iteminfo.ClabAmt = treat_clab_amt
  19776. iteminfo.OthAmt = treat_other_amt
  19777. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19778. //(struct4101.IteminfoStruct, iteminfo)
  19779. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19780. }
  19781. if operationCostTotal != 0 {
  19782. iteminfo.MedChrgitm = "06"
  19783. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19784. iteminfo.Amt = operationCostTotal
  19785. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19786. iteminfo.ClabAmt = operation_clab_amt
  19787. iteminfo.OthAmt = operation_other_amt
  19788. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19789. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19790. }
  19791. if materialCostTotal != 0 {
  19792. iteminfo.MedChrgitm = "08"
  19793. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19794. iteminfo.Amt = materialCostTotal
  19795. iteminfo.ClaaSumfee = material_claa_sunmfee
  19796. iteminfo.ClabAmt = material_clab_amt
  19797. iteminfo.OthAmt = material_other_amt
  19798. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19799. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19800. }
  19801. if westernMedicineCostTotal != 0 {
  19802. iteminfo.MedChrgitm = "09"
  19803. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19804. iteminfo.Amt = westernMedicineCostTotal
  19805. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19806. iteminfo.ClabAmt = westernMedicine_clab_amt
  19807. iteminfo.OthAmt = westernMedicine_other_amt
  19808. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19809. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19810. }
  19811. if chineseTraditionalMedicineCostTotal != 0 {
  19812. iteminfo.MedChrgitm = "11"
  19813. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19814. iteminfo.Amt = westernMedicineCostTotal
  19815. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19816. iteminfo.ClabAmt = westernMedicine_clab_amt
  19817. iteminfo.OthAmt = westernMedicine_other_amt
  19818. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19819. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19820. }
  19821. if otherCostTotal != 0 {
  19822. iteminfo.MedChrgitm = "14"
  19823. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19824. iteminfo.Amt = otherCostTotal
  19825. iteminfo.ClaaSumfee = other_claa_sunmfee
  19826. iteminfo.ClabAmt = other_clab_amt
  19827. iteminfo.OthAmt = other_other_amt
  19828. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19829. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19830. }
  19831. struct4101.IteminfoStruct = iteminfoStructs
  19832. struct4101.Ntly = "中国"
  19833. struct4101.AdmCaty = "A03.06"
  19834. struct4101.DoctorName = doctor.UserName
  19835. struct4101.DoctorCode = doctor.DoctorNumber
  19836. var res ResultSeventeen
  19837. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19838. struct4101.BillCode = order.Number
  19839. struct4101.BillNo = order.SetlId
  19840. var resOther ResultSeventeenOther
  19841. var pp models.PublicParams
  19842. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19843. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19844. pp.FixmedinsName = miConfig.OrgName
  19845. pp.FixmedinsCode = miConfig.Code
  19846. pp.RequestUrl = miConfig.Url
  19847. pp.Cainfo = miConfig.Cainfo
  19848. pp.SecretKey = miConfig.SecretKey
  19849. pp.AccessKey = miConfig.AccessKey
  19850. pp.OpterName = curRoles.UserName
  19851. client := &http.Client{}
  19852. var req *http.Request
  19853. data := make(map[string]interface{})
  19854. data["struct4101"] = struct4101
  19855. data["pp"] = pp
  19856. bytesData, _ := json.Marshal(data)
  19857. if miConfig.MdtrtareaAdmvs == "320921" {
  19858. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19859. } else {
  19860. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19861. }
  19862. resp, _ := client.Do(req)
  19863. defer resp.Body.Close()
  19864. body, ioErr := ioutil.ReadAll(resp.Body)
  19865. if ioErr != nil {
  19866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19868. return
  19869. }
  19870. var respJSON map[string]interface{}
  19871. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19874. return
  19875. }
  19876. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19877. userJSONBytes, _ := json.Marshal(respJSON)
  19878. fmt.Println("log")
  19879. fmt.Println(string(userJSONBytes))
  19880. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19881. utils.ErrorLog("解析失败:%v", err)
  19882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19883. return
  19884. }
  19885. res.InfRefmsgid = resOther.InfRefmsgid
  19886. res.Output = resOther.Output
  19887. res.ErrMsg = resOther.ErrMsg
  19888. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19889. res.Infcode = infocode
  19890. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19891. var pp models.PublicParams
  19892. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19893. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19894. pp.FixmedinsName = miConfig.OrgName
  19895. pp.FixmedinsCode = miConfig.Code
  19896. pp.RequestUrl = miConfig.Url
  19897. pp.Cainfo = miConfig.Cainfo
  19898. pp.SecretKey = miConfig.SecretKey
  19899. pp.AccessKey = miConfig.AccessKey
  19900. pp.OpterName = curRoles.UserName
  19901. result, _ := service.Jxyb4101(struct4101, pp)
  19902. var dat map[string]interface{}
  19903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19904. fmt.Println(dat)
  19905. } else {
  19906. fmt.Println(err)
  19907. }
  19908. userJSONBytes, _ := json.Marshal(dat)
  19909. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19910. utils.ErrorLog("解析失败:%v", err)
  19911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19912. return
  19913. }
  19914. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19915. var pp models.PublicParams
  19916. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19917. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19918. pp.FixmedinsName = miConfig.OrgName
  19919. pp.FixmedinsCode = miConfig.Code
  19920. pp.RequestUrl = miConfig.Url
  19921. pp.Cainfo = miConfig.Cainfo
  19922. pp.SecretKey = miConfig.SecretKey
  19923. pp.AccessKey = miConfig.AccessKey
  19924. pp.OpterName = curRoles.UserName
  19925. result, _ := service.Jxyb4101(struct4101, pp)
  19926. var dat map[string]interface{}
  19927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19928. fmt.Println(dat)
  19929. } else {
  19930. fmt.Println(err)
  19931. }
  19932. userJSONBytes, _ := json.Marshal(dat)
  19933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19934. utils.ErrorLog("解析失败:%v", err)
  19935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19936. return
  19937. }
  19938. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19939. var pp models.PublicParams
  19940. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19941. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19942. pp.FixmedinsName = miConfig.OrgName
  19943. pp.FixmedinsCode = miConfig.Code
  19944. pp.RequestUrl = miConfig.Url
  19945. pp.Cainfo = miConfig.Cainfo
  19946. pp.SecretKey = miConfig.SecretKey
  19947. pp.AccessKey = miConfig.AccessKey
  19948. pp.OpterName = curRoles.UserName
  19949. result, _ := service.Hnyb4101(struct4101, pp)
  19950. var dat map[string]interface{}
  19951. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19952. fmt.Println(dat)
  19953. } else {
  19954. fmt.Println(err)
  19955. }
  19956. userJSONBytes, _ := json.Marshal(dat)
  19957. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19958. utils.ErrorLog("解析失败:%v", err)
  19959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19960. return
  19961. }
  19962. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19963. var resOther ResultSeventeenOther
  19964. var pp models.PublicParams
  19965. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19966. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19967. pp.FixmedinsName = miConfig.OrgName
  19968. pp.FixmedinsCode = miConfig.Code
  19969. pp.RequestUrl = miConfig.Url
  19970. pp.Cainfo = miConfig.Cainfo
  19971. pp.SecretKey = miConfig.SecretKey
  19972. pp.AccessKey = miConfig.AccessKey
  19973. pp.OpterName = curRoles.UserName
  19974. client := &http.Client{}
  19975. var req *http.Request
  19976. data := make(map[string]interface{})
  19977. data["struct4101"] = struct4101
  19978. data["pp"] = pp
  19979. bytesData, _ := json.Marshal(data)
  19980. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19981. resp, _ := client.Do(req)
  19982. defer resp.Body.Close()
  19983. body, ioErr := ioutil.ReadAll(resp.Body)
  19984. if ioErr != nil {
  19985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19987. return
  19988. }
  19989. var respJSON map[string]interface{}
  19990. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19993. return
  19994. }
  19995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19996. userJSONBytes, _ := json.Marshal(respJSON)
  19997. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19998. utils.ErrorLog("解析失败:%v", err)
  19999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20000. return
  20001. }
  20002. res.InfRefmsgid = resOther.InfRefmsgid
  20003. res.Output = resOther.Output
  20004. res.ErrMsg = resOther.ErrMsg
  20005. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20006. res.Infcode = infocode
  20007. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20008. var pp models.PublicParams
  20009. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20010. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20011. pp.FixmedinsName = miConfig.OrgName
  20012. pp.FixmedinsCode = miConfig.Code
  20013. pp.RequestUrl = miConfig.Url
  20014. pp.Cainfo = miConfig.Cainfo
  20015. pp.SecretKey = miConfig.SecretKey
  20016. pp.AccessKey = miConfig.AccessKey
  20017. pp.OpterName = curRoles.UserName
  20018. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20019. fmt.Println(requestLog)
  20020. fmt.Println(errMsgLog)
  20021. saveLog(result, requestLog, "4101a", "上传清单")
  20022. var dat map[string]interface{}
  20023. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20024. fmt.Println(dat)
  20025. } else {
  20026. fmt.Println(err)
  20027. }
  20028. userJSONBytes, _ := json.Marshal(dat)
  20029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20030. utils.ErrorLog("解析失败:%v", err)
  20031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20032. return
  20033. }
  20034. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20035. var pp models.PublicParams
  20036. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20037. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20038. pp.FixmedinsName = miConfig.OrgName
  20039. pp.FixmedinsCode = miConfig.Code
  20040. pp.RequestUrl = miConfig.Url
  20041. pp.Cainfo = miConfig.Cainfo
  20042. pp.SecretKey = miConfig.SecretKey
  20043. pp.AccessKey = miConfig.AccessKey
  20044. pp.OpterName = curRoles.UserName
  20045. client := &http.Client{}
  20046. var req *http.Request
  20047. data := make(map[string]interface{})
  20048. data["struct4101"] = struct4101
  20049. data["pp"] = pp
  20050. bytesData, _ := json.Marshal(data)
  20051. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20052. resp, _ := client.Do(req)
  20053. defer resp.Body.Close()
  20054. body, ioErr := ioutil.ReadAll(resp.Body)
  20055. if ioErr != nil {
  20056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20058. return
  20059. }
  20060. var respJSON map[string]interface{}
  20061. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20064. return
  20065. }
  20066. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20067. userJSONBytes, _ := json.Marshal(respJSON)
  20068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20069. utils.ErrorLog("解析失败:%v", err)
  20070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20071. return
  20072. }
  20073. } else {
  20074. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20075. var dat map[string]interface{}
  20076. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20077. fmt.Println(dat)
  20078. } else {
  20079. fmt.Println(err)
  20080. }
  20081. userJSONBytes, _ := json.Marshal(dat)
  20082. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20083. utils.ErrorLog("解析失败:%v", err)
  20084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20085. return
  20086. }
  20087. }
  20088. if res.Infcode != 0 {
  20089. c.ServeSuccessJSON(map[string]interface{}{
  20090. "failed_code": -10,
  20091. "msg": res.ErrMsg,
  20092. })
  20093. return
  20094. } else {
  20095. //order.FaPiaoNumber = zero
  20096. //order.FaPiaoCode = last_order.FaPiaoCode
  20097. //service.UpdateOrder(order)
  20098. hisFundSettleListResult := &models.HisFundSettleListResult{
  20099. Number: res.Output.SetlListId,
  20100. Status: 1,
  20101. Ctime: time.Now().Unix(),
  20102. Mtime: time.Now().Unix(),
  20103. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20104. IsUpload: 1,
  20105. OrderId: order_id,
  20106. }
  20107. service.CreateUploadRecord(hisFundSettleListResult)
  20108. c.ServeSuccessJSON(map[string]interface{}{
  20109. "msg": "上传成功",
  20110. "result": hisFundSettleListResult,
  20111. })
  20112. return
  20113. }
  20114. }
  20115. func (c *HisApiController) GetSettleListHospital() {
  20116. order_id, _ := c.GetInt64("order_id")
  20117. admin_user_id, _ := c.GetInt64("admin_user_id")
  20118. order, _ := service.GetHisOrderByIDTwo(order_id)
  20119. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20120. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20121. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20122. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20123. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20124. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20125. if order.ID == 0 {
  20126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20127. return
  20128. }
  20129. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20130. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20131. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20132. fmt.Println(count)
  20133. var zero string
  20134. number := count + 1
  20135. if number >= 1000 {
  20136. zero = "0000" + strconv.FormatInt(number, 10)
  20137. } else if number >= 10000 {
  20138. zero = "000" + strconv.FormatInt(number, 10)
  20139. } else if number >= 100000 {
  20140. zero = "00" + strconv.FormatInt(number, 10)
  20141. } else if number >= 1000000 {
  20142. zero = "0" + strconv.FormatInt(number, 10)
  20143. } else {
  20144. zero = strconv.FormatInt(number, 10)
  20145. }
  20146. fmt.Println(zero)
  20147. struct4101 := service.Struct4101{
  20148. PsnNo: order.PsnNo,
  20149. MdtrtId: order.MdtrtId,
  20150. SetlId: order.SetlId,
  20151. PsnName: order.PsnName,
  20152. Gend: order.Gend,
  20153. Brdy: his.Brdy,
  20154. Age: int64(order.Age),
  20155. Naty: order.Naty,
  20156. PatnCertType: "01",
  20157. Certno: order.Certno,
  20158. Prfs: "90",
  20159. ConerName: roles[0].UserName,
  20160. PatnRlts: "99",
  20161. ConerAddr: miConfig.OrgName,
  20162. ConerTel: admin.Mobile,
  20163. HiType: order.Insutype,
  20164. Insuplc: miConfig.InsuplcAdmdvs,
  20165. MaindiagFlag: "1",
  20166. BillCode: order.SetlId,
  20167. BillNo: order.SetlId,
  20168. BizSn: order.Number,
  20169. PsnSelfPay: order.PsnPartAmt,
  20170. PsnOwnPay: order.PsnPartAmt,
  20171. AcctPay: order.AcctPay,
  20172. PsnCashpay: order.PsnCashPay,
  20173. HiPaymtd: "1",
  20174. Hsorg: miConfig.InsuplcAdmdvs,
  20175. HsorgOpter: miConfig.InsuplcAdmdvs,
  20176. MedinsFillPsn: curRoles.UserName,
  20177. MedinsFillDept: depart.Name,
  20178. IptMedType: "2",
  20179. AdmTime: his.InHosptialTime,
  20180. AdmEndTime: his.OutHosptialTime,
  20181. }
  20182. struct4101.SetlBegnDate = order.SetlTime
  20183. struct4101.SetlEndDate = order.SetlTime
  20184. //var rf []CustomFundPay
  20185. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20186. //
  20187. //var tempFunPays []service.CustomStruct
  20188. //for _, item := range rf {
  20189. // var tempFunPay service.CustomStruct
  20190. // tempFunPay.FundPayamt = item.FundPayamt
  20191. // tempFunPay.FundPayType = item.FundPayType
  20192. // tempFunPays = append(tempFunPays, tempFunPay)
  20193. //}
  20194. //struct4101.CustomStruct = tempFunPays
  20195. var tempDiaginfos []service.DiaginfoStructTwo
  20196. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20197. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20198. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  20199. //for _, item := range infos {
  20200. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  20201. //}
  20202. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  20203. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  20204. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20205. fmt.Println(diagnosis_ids_arr)
  20206. if order.UserOrgId == 10210 {
  20207. var diagnosis_ids_arr_two []int64
  20208. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  20209. var config []*models.HisXtDiagnoseConfig
  20210. for _, id := range diagnosis_ids_arr_two {
  20211. //id, _ := strconv.ParseInt(item, 10, 64)
  20212. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20213. if diagnosisConfig.ID > 0 {
  20214. config = append(config, &diagnosisConfig)
  20215. }
  20216. }
  20217. for index, item := range config {
  20218. if item.ID > 0 {
  20219. if index == 0 {
  20220. var tempDiaginfo service.DiaginfoStructTwo
  20221. tempDiaginfo.DiagCode = item.CountryCode
  20222. tempDiaginfo.DiagName = item.CountryContentName
  20223. tempDiaginfo.DiagType = "1"
  20224. tempDiaginfo.MaindiagFlag = "1"
  20225. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20226. } else {
  20227. var tempDiaginfo service.DiaginfoStructTwo
  20228. tempDiaginfo.DiagCode = item.CountryCode
  20229. tempDiaginfo.DiagName = item.CountryContentName
  20230. tempDiaginfo.DiagType = "1"
  20231. tempDiaginfo.MaindiagFlag = "0"
  20232. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20233. }
  20234. }
  20235. }
  20236. struct4101.Diseinfo = tempDiaginfos
  20237. } else {
  20238. var config []*models.HisXtDiagnoseConfig
  20239. for _, item := range diagnosis_ids_arr {
  20240. id, _ := strconv.ParseInt(item, 10, 64)
  20241. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20242. if diagnosisConfig.ID > 0 {
  20243. config = append(config, &diagnosisConfig)
  20244. }
  20245. }
  20246. for index, item := range config {
  20247. if item.ID > 0 {
  20248. if index == 0 {
  20249. var tempDiaginfo service.DiaginfoStructTwo
  20250. tempDiaginfo.DiagCode = item.CountryCode
  20251. tempDiaginfo.DiagName = item.CountryContentName
  20252. tempDiaginfo.DiagType = "1"
  20253. tempDiaginfo.MaindiagFlag = "1"
  20254. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20255. } else {
  20256. var tempDiaginfo service.DiaginfoStructTwo
  20257. tempDiaginfo.DiagCode = item.CountryCode
  20258. tempDiaginfo.DiagName = item.CountryContentName
  20259. tempDiaginfo.DiagType = "1"
  20260. tempDiaginfo.MaindiagFlag = "0"
  20261. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20262. }
  20263. }
  20264. }
  20265. struct4101.Diseinfo = tempDiaginfos
  20266. }
  20267. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20268. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20269. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20270. tempOpspdiseinfo2.OprnOprtCode = ""
  20271. tempOpspdiseinfo2.OprnOprtName = ""
  20272. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20273. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20274. var iteminfo service.IteminfoStruct
  20275. var bedCostTotal float64 = 0 //床位总费
  20276. var bedCostSelfTotal float64 = 0 //床位自费
  20277. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20278. var operationCostTotal float64 = 0 //手术费
  20279. var operationCostSelfTotal float64 = 0 //手术费
  20280. var operationCostPartSelfTotal float64 = 0 //手术费
  20281. var otherCostTotal float64 = 0 //其他费用
  20282. var otherCostSelfTotal float64 = 0 //其他费用
  20283. var otherCostPartSelfTotal float64 = 0 //其他费用
  20284. var materialCostTotal float64 = 0 //材料费
  20285. var materialCostSelfTotal float64 = 0 //材料费
  20286. var materialCostPartSelfTotal float64 = 0 //材料费
  20287. var westernMedicineCostTotal float64 = 0 //西药费
  20288. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20289. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20290. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20291. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20292. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20293. var checkCostTotal float64 = 0 //检查费
  20294. var checkCostSelfTotal float64 = 0 //检查费
  20295. var checkCostPartSelfTotal float64 = 0 //检查费
  20296. var laboratoryCostTotal float64 = 0 //化验费
  20297. var laboratoryCostSelfTotal float64 = 0 //化验费
  20298. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20299. var treatCostTotal float64 = 0 //治疗费用
  20300. var treatCostSelfTotal float64 = 0 //治疗费用
  20301. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20302. decimal.DivisionPrecision = 2
  20303. var bed_fulamt_ownpay_amt float64 = 0
  20304. var operation_fulamt_ownpay_amt float64 = 0
  20305. var other_fulamt_ownpay_amt float64 = 0
  20306. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20307. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20308. var check_fulamt_ownpay_amt float64 = 0
  20309. var material_fulamt_ownpay_amt float64 = 0
  20310. var laboratory_fulamt_ownpay_amt float64 = 0
  20311. var treat_fulamt_ownpay_amt float64 = 0
  20312. var bed_claa_sunmfee float64 = 0
  20313. var bed_clab_amt float64 = 0
  20314. var bed_other_amt float64 = 0
  20315. var operation_claa_sunmfee float64 = 0
  20316. var operation_clab_amt float64 = 0
  20317. var operation_other_amt float64 = 0
  20318. var other_claa_sunmfee float64 = 0
  20319. var other_clab_amt float64 = 0
  20320. var other_other_amt float64 = 0
  20321. var westernMedicine_claa_sunmfee float64 = 0
  20322. var westernMedicine_clab_amt float64 = 0
  20323. var westernMedicine_other_amt float64 = 0
  20324. var chineseTraditional_claa_sunmfee float64 = 0
  20325. var chineseTraditional_clab_amt float64 = 0
  20326. var chineseTraditional_other_amt float64 = 0
  20327. var check_claa_sunmfee float64 = 0
  20328. var check_clab_amt float64 = 0
  20329. var check_other_amt float64 = 0
  20330. var material_claa_sunmfee float64 = 0
  20331. var material_clab_amt float64 = 0
  20332. var material_other_amt float64 = 0
  20333. var laboratory_claa_sunmfee float64 = 0
  20334. var laboratory_clab_amt float64 = 0
  20335. var laboratory_other_amt float64 = 0
  20336. var treat_claa_sunmfee float64 = 0
  20337. var treat_clab_amt float64 = 0
  20338. var treat_other_amt float64 = 0
  20339. for _, item := range order.HisOrderInfo {
  20340. if item.MedChrgitmType == "01" { //床位费
  20341. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20342. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20343. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20344. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20345. if item.ChrgitmLv == "1" {
  20346. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20347. }
  20348. if item.ChrgitmLv == "2" {
  20349. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20350. }
  20351. if item.ChrgitmLv == "3" {
  20352. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20353. }
  20354. }
  20355. if item.MedChrgitmType == "03" { //检查费
  20356. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20357. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20358. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20359. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20360. if item.ChrgitmLv == "1" {
  20361. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20362. }
  20363. if item.ChrgitmLv == "2" {
  20364. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20365. }
  20366. if item.ChrgitmLv == "3" {
  20367. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20368. }
  20369. }
  20370. if item.MedChrgitmType == "04" { //化验费
  20371. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20372. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20373. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20374. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20375. if item.ChrgitmLv == "1" {
  20376. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20377. }
  20378. if item.ChrgitmLv == "2" {
  20379. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20380. }
  20381. if item.ChrgitmLv == "3" {
  20382. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20383. }
  20384. }
  20385. if item.MedChrgitmType == "05" { //治疗费
  20386. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20387. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20388. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20389. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20390. if item.ChrgitmLv == "1" {
  20391. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20392. }
  20393. if item.ChrgitmLv == "2" {
  20394. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20395. }
  20396. if item.ChrgitmLv == "3" {
  20397. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20398. }
  20399. }
  20400. if item.MedChrgitmType == "06" { //手术费
  20401. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20402. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20403. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20404. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20405. if item.ChrgitmLv == "1" {
  20406. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20407. }
  20408. if item.ChrgitmLv == "2" {
  20409. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20410. }
  20411. if item.ChrgitmLv == "3" {
  20412. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20413. }
  20414. }
  20415. if item.MedChrgitmType == "08" { //材料费
  20416. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20417. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20418. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20419. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20420. if item.ChrgitmLv == "1" {
  20421. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20422. }
  20423. if item.ChrgitmLv == "2" {
  20424. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20425. }
  20426. if item.ChrgitmLv == "3" {
  20427. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20428. }
  20429. }
  20430. if item.MedChrgitmType == "09" { //西药费
  20431. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20432. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20433. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20434. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20435. if item.ChrgitmLv == "1" {
  20436. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20437. }
  20438. if item.ChrgitmLv == "2" {
  20439. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20440. }
  20441. if item.ChrgitmLv == "3" {
  20442. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20443. }
  20444. }
  20445. if item.MedChrgitmType == "11" { //中成费
  20446. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20447. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20448. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20449. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20450. if item.ChrgitmLv == "1" {
  20451. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20452. }
  20453. if item.ChrgitmLv == "2" {
  20454. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20455. }
  20456. if item.ChrgitmLv == "3" {
  20457. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20458. }
  20459. }
  20460. if item.MedChrgitmType == "14" { //其他费
  20461. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20462. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20463. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20464. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20465. if item.ChrgitmLv == "1" {
  20466. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20467. }
  20468. if item.ChrgitmLv == "2" {
  20469. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20470. }
  20471. if item.ChrgitmLv == "3" {
  20472. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20473. }
  20474. }
  20475. }
  20476. var iteminfoStructs []service.IteminfoStruct
  20477. if bedCostTotal != 0 {
  20478. iteminfo.MedChrgitm = "01"
  20479. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20480. iteminfo.Amt = bedCostTotal
  20481. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20482. iteminfo.ClabAmt = bed_clab_amt
  20483. iteminfo.OthAmt = bed_other_amt
  20484. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20485. }
  20486. if checkCostTotal != 0 {
  20487. iteminfo.MedChrgitm = "03"
  20488. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20489. iteminfo.Amt = checkCostTotal
  20490. iteminfo.ClaaSumfee = check_claa_sunmfee
  20491. iteminfo.ClabAmt = check_clab_amt
  20492. iteminfo.OthAmt = check_other_amt
  20493. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20494. }
  20495. if laboratoryCostTotal != 0 {
  20496. iteminfo.MedChrgitm = "04"
  20497. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20498. iteminfo.Amt = laboratoryCostTotal
  20499. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20500. iteminfo.ClabAmt = laboratory_clab_amt
  20501. iteminfo.OthAmt = laboratory_other_amt
  20502. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20503. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20504. }
  20505. if treatCostTotal != 0 {
  20506. iteminfo.MedChrgitm = "05"
  20507. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20508. iteminfo.Amt = treatCostTotal
  20509. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20510. iteminfo.ClabAmt = treat_clab_amt
  20511. iteminfo.OthAmt = treat_other_amt
  20512. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20513. //(struct4101.IteminfoStruct, iteminfo)
  20514. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20515. }
  20516. if operationCostTotal != 0 {
  20517. iteminfo.MedChrgitm = "06"
  20518. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20519. iteminfo.Amt = operationCostTotal
  20520. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20521. iteminfo.ClabAmt = operation_clab_amt
  20522. iteminfo.OthAmt = operation_other_amt
  20523. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20524. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20525. }
  20526. if materialCostTotal != 0 {
  20527. iteminfo.MedChrgitm = "08"
  20528. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20529. iteminfo.Amt = materialCostTotal
  20530. iteminfo.ClaaSumfee = material_claa_sunmfee
  20531. iteminfo.ClabAmt = material_clab_amt
  20532. iteminfo.OthAmt = material_other_amt
  20533. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20534. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20535. }
  20536. if westernMedicineCostTotal != 0 {
  20537. iteminfo.MedChrgitm = "09"
  20538. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20539. iteminfo.Amt = westernMedicineCostTotal
  20540. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20541. iteminfo.ClabAmt = westernMedicine_clab_amt
  20542. iteminfo.OthAmt = westernMedicine_other_amt
  20543. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20544. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20545. }
  20546. if chineseTraditionalMedicineCostTotal != 0 {
  20547. iteminfo.MedChrgitm = "11"
  20548. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20549. iteminfo.Amt = westernMedicineCostTotal
  20550. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20551. iteminfo.ClabAmt = westernMedicine_clab_amt
  20552. iteminfo.OthAmt = westernMedicine_other_amt
  20553. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20554. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20555. }
  20556. if otherCostTotal != 0 {
  20557. iteminfo.MedChrgitm = "14"
  20558. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20559. iteminfo.Amt = otherCostTotal
  20560. iteminfo.ClaaSumfee = other_claa_sunmfee
  20561. iteminfo.ClabAmt = other_clab_amt
  20562. iteminfo.OthAmt = other_other_amt
  20563. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20564. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20565. }
  20566. struct4101.IteminfoStruct = iteminfoStructs
  20567. struct4101.Ntly = "中国"
  20568. struct4101.AdmCaty = "A03.06"
  20569. var resOther ResultSeventeenOther
  20570. var res ResultSeventeen
  20571. if miConfig.MdtrtareaAdmvs == "150499" {
  20572. var pp models.PublicParams
  20573. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20574. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20575. pp.FixmedinsName = miConfig.OrgName
  20576. pp.FixmedinsCode = miConfig.Code
  20577. pp.RequestUrl = miConfig.Url
  20578. pp.Cainfo = miConfig.Cainfo
  20579. pp.SecretKey = miConfig.SecretKey
  20580. pp.AccessKey = miConfig.AccessKey
  20581. pp.OpterName = curRoles.UserName
  20582. client := &http.Client{}
  20583. var req *http.Request
  20584. data := make(map[string]interface{})
  20585. data["struct4101"] = struct4101
  20586. data["pp"] = pp
  20587. bytesData, _ := json.Marshal(data)
  20588. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20589. resp, _ := client.Do(req)
  20590. defer resp.Body.Close()
  20591. body, ioErr := ioutil.ReadAll(resp.Body)
  20592. if ioErr != nil {
  20593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20595. return
  20596. }
  20597. var respJSON map[string]interface{}
  20598. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20601. return
  20602. }
  20603. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20604. userJSONBytes, _ := json.Marshal(respJSON)
  20605. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20606. utils.ErrorLog("解析失败:%v", err)
  20607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20608. return
  20609. }
  20610. res.InfRefmsgid = resOther.InfRefmsgid
  20611. res.Output = resOther.Output
  20612. res.ErrMsg = resOther.ErrMsg
  20613. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20614. res.Infcode = infocode
  20615. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20616. var pp models.PublicParams
  20617. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20618. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20619. pp.FixmedinsName = miConfig.OrgName
  20620. pp.FixmedinsCode = miConfig.Code
  20621. pp.RequestUrl = miConfig.Url
  20622. pp.Cainfo = miConfig.Cainfo
  20623. pp.SecretKey = miConfig.SecretKey
  20624. pp.AccessKey = miConfig.AccessKey
  20625. pp.OpterName = curRoles.UserName
  20626. result, _ := service.Jxyb4101(struct4101, pp)
  20627. var dat map[string]interface{}
  20628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20629. fmt.Println(dat)
  20630. } else {
  20631. fmt.Println(err)
  20632. }
  20633. userJSONBytes, _ := json.Marshal(dat)
  20634. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20635. utils.ErrorLog("解析失败:%v", err)
  20636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20637. return
  20638. }
  20639. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20640. var pp models.PublicParams
  20641. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20642. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20643. pp.FixmedinsName = miConfig.OrgName
  20644. pp.FixmedinsCode = miConfig.Code
  20645. pp.RequestUrl = miConfig.Url
  20646. pp.Cainfo = miConfig.Cainfo
  20647. pp.SecretKey = miConfig.SecretKey
  20648. pp.AccessKey = miConfig.AccessKey
  20649. pp.OpterName = curRoles.UserName
  20650. result, _ := service.Jxyb4101(struct4101, pp)
  20651. var dat map[string]interface{}
  20652. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20653. fmt.Println(dat)
  20654. } else {
  20655. fmt.Println(err)
  20656. }
  20657. userJSONBytes, _ := json.Marshal(dat)
  20658. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20659. utils.ErrorLog("解析失败:%v", err)
  20660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20661. return
  20662. }
  20663. } else {
  20664. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20665. var dat map[string]interface{}
  20666. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20667. fmt.Println(dat)
  20668. } else {
  20669. fmt.Println(err)
  20670. }
  20671. userJSONBytes, _ := json.Marshal(dat)
  20672. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20673. utils.ErrorLog("解析失败:%v", err)
  20674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20675. return
  20676. }
  20677. }
  20678. if res.Infcode != 0 {
  20679. c.ServeSuccessJSON(map[string]interface{}{
  20680. "failed_code": -10,
  20681. "msg": res.ErrMsg,
  20682. })
  20683. return
  20684. } else {
  20685. if miConfig.MdtrtareaAdmvs != "150499" {
  20686. order.FaPiaoNumber = zero
  20687. order.FaPiaoCode = last_order.FaPiaoCode
  20688. service.UpdateOrder(order)
  20689. }
  20690. hisFundSettleListResult := &models.HisFundSettleListResult{
  20691. Number: res.Output.SetlListId,
  20692. Status: 1,
  20693. Ctime: time.Now().Unix(),
  20694. Mtime: time.Now().Unix(),
  20695. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20696. IsUpload: 1,
  20697. OrderId: order_id,
  20698. }
  20699. service.CreateUploadRecord(hisFundSettleListResult)
  20700. c.ServeSuccessJSON(map[string]interface{}{
  20701. "msg": "上传成功",
  20702. "result": hisFundSettleListResult,
  20703. })
  20704. return
  20705. }
  20706. }
  20707. //func (c *HisApiController) GetBatchSettleList() {
  20708. // orders, _ := service.GetAllHisOrder(10106)
  20709. // for _, item := range orders {
  20710. // order_id := item.ID
  20711. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20712. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20713. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20714. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20715. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20716. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20717. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20718. //
  20719. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20720. //
  20721. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20722. //
  20723. // if order.ID == 0 {
  20724. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20725. // return
  20726. // }
  20727. // if his.BalanceAccountsType == 2 {
  20728. // continue
  20729. // }
  20730. // struct4101 := service.Struct4101{
  20731. // PsnNo: order.PsnNo,
  20732. // MdtrtId: order.MdtrtId,
  20733. // SetlId: order.SetlId,
  20734. // PsnName: order.PsnName,
  20735. // Gend: order.Gend,
  20736. // Brdy: his.Brdy,
  20737. // Age: his.Age,
  20738. // Naty: order.Naty,
  20739. // PatnCertType: "01",
  20740. // Certno: order.Certno,
  20741. // Prfs: "90",
  20742. // ConerName: roles[0].UserName,
  20743. // PatnRlts: "99",
  20744. // ConerAddr: miConfig.OrgName,
  20745. // ConerTel: admin.Mobile,
  20746. // HiType: order.Insutype,
  20747. // Insuplc: his.InsuplcAdmdvs,
  20748. // MaindiagFlag: "1",
  20749. // BillCode: order.SetlId,
  20750. // BillNo: order.SetlId,
  20751. // BizSn: order.Number,
  20752. // PsnSelfPay: order.PsnPartAmt,
  20753. // PsnOwnPay: order.PsnPartAmt,
  20754. // AcctPay: order.AcctPay,
  20755. // PsnCashpay: order.PsnCashPay,
  20756. // HiPaymtd: "1",
  20757. // Hsorg: his.InsuplcAdmdvs,
  20758. // HsorgOpter: his.InsuplcAdmdvs,
  20759. // MedinsFillPsn: curRoles.UserName,
  20760. // MedinsFillDept: depart.Name,
  20761. // IptMedType: "2",
  20762. // }
  20763. // struct4101.SetlBegnDate = order.SetlTime
  20764. // struct4101.SetlEndDate = order.SetlTime
  20765. // //if order.SettleType == 1 {
  20766. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20767. // // dateStr := t.Format("2006-01-02")
  20768. // // struct4101.SetlBegnDate = dateStr
  20769. // // struct4101.SetlEndDate = dateStr
  20770. // //} else {
  20771. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20772. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20773. // // dateStartStr := t.Format("2006-01-02")
  20774. // // dateEndStr := t2.Format("2006-01-02")
  20775. // // struct4101.SetlBegnDate = dateStartStr
  20776. // // struct4101.SetlEndDate = dateEndStr
  20777. // //}
  20778. //
  20779. // var rf []CustomFundPay
  20780. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20781. //
  20782. // var tempFunPays []service.CustomStruct
  20783. // var tempFunPay610100 service.CustomStruct
  20784. //
  20785. // for _, item := range rf {
  20786. // if item.FundPayType == "610100" {
  20787. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20788. // tempFunPay610100.FundPayType = item.FundPayType
  20789. // } else {
  20790. // var tempFunPay service.CustomStruct
  20791. // tempFunPay.FundPayamt = item.FundPayamt
  20792. // tempFunPay.FundPayType = item.FundPayType
  20793. // tempFunPays = append(tempFunPays, tempFunPay)
  20794. // }
  20795. // }
  20796. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20797. // struct4101.CustomStruct = tempFunPays
  20798. //
  20799. // var tempDiaginfos []service.DiaginfoStructTwo
  20800. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20801. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20802. //
  20803. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20804. // var config []*models.HisXtDiagnoseConfig
  20805. // for _, item := range diagnosis_ids {
  20806. // id, _ := strconv.ParseInt(item, 10, 64)
  20807. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20808. // config = append(config, &diagnosisConfig)
  20809. // }
  20810. //
  20811. // for index, item := range config {
  20812. // if index == 0 {
  20813. // var tempDiaginfo service.DiaginfoStructTwo
  20814. // tempDiaginfo.DiagCode = item.CountryCode
  20815. // tempDiaginfo.DiagName = item.CountryContentName
  20816. // tempDiaginfo.DiagType = "1"
  20817. // tempDiaginfo.MaindiagFlag = "1"
  20818. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20819. // } else {
  20820. //
  20821. // var tempDiaginfo service.DiaginfoStructTwo
  20822. // tempDiaginfo.DiagCode = item.CountryCode
  20823. // tempDiaginfo.DiagName = item.CountryContentName
  20824. // tempDiaginfo.DiagType = "2"
  20825. // tempDiaginfo.MaindiagFlag = "0"
  20826. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20827. // }
  20828. // }
  20829. // struct4101.Diseinfo = tempDiaginfos
  20830. //
  20831. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20832. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20833. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20834. // tempOpspdiseinfo2.OprnOprtCode = ""
  20835. // tempOpspdiseinfo2.OprnOprtName = ""
  20836. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20837. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20838. //
  20839. // var iteminfo service.IteminfoStruct
  20840. //
  20841. // var bedCostTotal float64 = 0 //床位总费
  20842. // var bedCostSelfTotal float64 = 0 //床位自费
  20843. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20844. //
  20845. // var examineCostTotal float64 = 0 //诊查总费
  20846. // var examineCostSelfTotal float64 = 0 //诊查自费
  20847. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20848. //
  20849. // var nursingCostTotal float64 = 0 //护理总费
  20850. // var nursingCostSelfTotal float64 = 0 //护理自费
  20851. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20852. //
  20853. // var chineseMedicineCostTotal float64 = 0 //中成药
  20854. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20855. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20856. //
  20857. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20858. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20859. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20860. //
  20861. // var registerCostTotal float64 = 0 //一般诊疗费
  20862. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20863. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20864. //
  20865. // var operationCostTotal float64 = 0 //手术费
  20866. // var operationCostSelfTotal float64 = 0 //手术费
  20867. // var operationCostPartSelfTotal float64 = 0 //手术费
  20868. //
  20869. // var otherCostTotal float64 = 0 //其他费用
  20870. // var otherCostSelfTotal float64 = 0 //其他费用
  20871. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20872. //
  20873. // var materialCostTotal float64 = 0 //材料费
  20874. // var materialCostSelfTotal float64 = 0 //材料费
  20875. // var materialCostPartSelfTotal float64 = 0 //材料费
  20876. //
  20877. // var westernMedicineCostTotal float64 = 0 //西药费
  20878. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20879. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20880. //
  20881. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20882. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20883. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20884. //
  20885. // var checkCostTotal float64 = 0 //检查费
  20886. // var checkCostSelfTotal float64 = 0 //检查费
  20887. // var checkCostPartSelfTotal float64 = 0 //检查费
  20888. //
  20889. // var laboratoryCostTotal float64 = 0 //化验费
  20890. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20891. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20892. //
  20893. // var treatCostTotal float64 = 0 //治疗费用
  20894. // var treatCostSelfTotal float64 = 0 //治疗费用
  20895. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20896. //
  20897. // decimal.DivisionPrecision = 2
  20898. //
  20899. // var bed_fulamt_ownpay_amt float64 = 0
  20900. //
  20901. // var examine_fulamt_ownpay_amt float64 = 0
  20902. //
  20903. // var nursing_fulamt_ownpay_amt float64 = 0
  20904. //
  20905. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20906. //
  20907. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20908. //
  20909. // var register_fulamt_ownpay_amt float64 = 0
  20910. //
  20911. // var operation_fulamt_ownpay_amt float64 = 0
  20912. // var other_fulamt_ownpay_amt float64 = 0
  20913. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20914. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20915. // var check_fulamt_ownpay_amt float64 = 0
  20916. // var material_fulamt_ownpay_amt float64 = 0
  20917. // var laboratory_fulamt_ownpay_amt float64 = 0
  20918. // var treat_fulamt_ownpay_amt float64 = 0
  20919. //
  20920. // var bed_claa_sunmfee float64 = 0
  20921. // var bed_clab_amt float64 = 0
  20922. // var bed_other_amt float64 = 0
  20923. //
  20924. // var examine_claa_sunmfee float64 = 0
  20925. // var examine_clab_amt float64 = 0
  20926. // var examine_other_amt float64 = 0
  20927. //
  20928. // var nursing_claa_sunmfee float64 = 0
  20929. // var nursing_clab_amt float64 = 0
  20930. // var nursing_other_amt float64 = 0
  20931. //
  20932. // var chinese_medicine_claa_sunmfee float64 = 0
  20933. // var chinese_medicine_clab_amt float64 = 0
  20934. // var chinese_medicine_other_amt float64 = 0
  20935. //
  20936. // var commonly_treatment_claa_sunmfee float64 = 0
  20937. // var commonly_treatment_clab_amt float64 = 0
  20938. // var commonly_treatment_other_amt float64 = 0
  20939. //
  20940. // var operation_claa_sunmfee float64 = 0
  20941. // var operation_clab_amt float64 = 0
  20942. // var operation_other_amt float64 = 0
  20943. //
  20944. // var other_claa_sunmfee float64 = 0
  20945. // var other_clab_amt float64 = 0
  20946. // var other_other_amt float64 = 0
  20947. //
  20948. // var westernMedicine_claa_sunmfee float64 = 0
  20949. // var westernMedicine_clab_amt float64 = 0
  20950. // var westernMedicine_other_amt float64 = 0
  20951. //
  20952. // var chineseTraditional_claa_sunmfee float64 = 0
  20953. // var chineseTraditional_clab_amt float64 = 0
  20954. // var chineseTraditional_other_amt float64 = 0
  20955. //
  20956. // var check_claa_sunmfee float64 = 0
  20957. // var check_clab_amt float64 = 0
  20958. // var check_other_amt float64 = 0
  20959. //
  20960. // var material_claa_sunmfee float64 = 0
  20961. // var material_clab_amt float64 = 0
  20962. // var material_other_amt float64 = 0
  20963. //
  20964. // var laboratory_claa_sunmfee float64 = 0
  20965. // var laboratory_clab_amt float64 = 0
  20966. // var laboratory_other_amt float64 = 0
  20967. //
  20968. // var treat_claa_sunmfee float64 = 0
  20969. // var treat_clab_amt float64 = 0
  20970. // var treat_other_amt float64 = 0
  20971. //
  20972. // var register_claa_sunmfee float64 = 0
  20973. // var register_clab_amt float64 = 0
  20974. // var register_other_amt float64 = 0
  20975. //
  20976. // for _, item := range order.HisOrderInfo {
  20977. // if item.MedChrgitmType == "01" { //床位费
  20978. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20979. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20980. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20981. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20982. // if item.ChrgitmLv == "1" {
  20983. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20984. // }
  20985. // if item.ChrgitmLv == "2" {
  20986. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20987. //
  20988. // }
  20989. // if item.ChrgitmLv == "3" {
  20990. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20991. // }
  20992. //
  20993. // }
  20994. //
  20995. // if item.MedChrgitmType == "02" { //诊查
  20996. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20997. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20998. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20999. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21000. // if item.ChrgitmLv == "1" {
  21001. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21002. // }
  21003. // if item.ChrgitmLv == "2" {
  21004. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21005. //
  21006. // }
  21007. // if item.ChrgitmLv == "3" {
  21008. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21009. // }
  21010. //
  21011. // }
  21012. //
  21013. // if item.MedChrgitmType == "03" { //检查费
  21014. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21015. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21016. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21017. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21018. // if item.ChrgitmLv == "1" {
  21019. //
  21020. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21021. //
  21022. // }
  21023. // if item.ChrgitmLv == "2" {
  21024. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21025. //
  21026. // }
  21027. // if item.ChrgitmLv == "3" {
  21028. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21029. // }
  21030. // }
  21031. //
  21032. // if item.MedChrgitmType == "04" { //化验费
  21033. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21034. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21035. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21036. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21037. // if item.ChrgitmLv == "1" {
  21038. //
  21039. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21040. //
  21041. // }
  21042. // if item.ChrgitmLv == "2" {
  21043. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21044. //
  21045. // }
  21046. // if item.ChrgitmLv == "3" {
  21047. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21048. // }
  21049. // }
  21050. //
  21051. // if item.MedChrgitmType == "05" { //治疗费
  21052. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21053. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21054. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21055. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21056. // if item.ChrgitmLv == "1" {
  21057. //
  21058. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21059. //
  21060. // }
  21061. // if item.ChrgitmLv == "2" {
  21062. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21063. //
  21064. // }
  21065. // if item.ChrgitmLv == "3" {
  21066. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21067. // }
  21068. // }
  21069. //
  21070. // if item.MedChrgitmType == "06" { //手术费
  21071. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21072. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21073. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21074. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21075. //
  21076. // if item.ChrgitmLv == "1" {
  21077. //
  21078. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21079. //
  21080. // }
  21081. // if item.ChrgitmLv == "2" {
  21082. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21083. //
  21084. // }
  21085. // if item.ChrgitmLv == "3" {
  21086. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21087. // }
  21088. // }
  21089. //
  21090. // if item.MedChrgitmType == "07" { //手术费
  21091. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21092. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21093. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21094. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21095. //
  21096. // if item.ChrgitmLv == "1" {
  21097. //
  21098. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21099. //
  21100. // }
  21101. // if item.ChrgitmLv == "2" {
  21102. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21103. //
  21104. // }
  21105. // if item.ChrgitmLv == "3" {
  21106. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21107. // }
  21108. // }
  21109. //
  21110. // if item.MedChrgitmType == "08" { //材料费
  21111. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21112. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21113. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21114. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21115. // if item.ChrgitmLv == "1" {
  21116. //
  21117. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21118. //
  21119. // }
  21120. // if item.ChrgitmLv == "2" {
  21121. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21122. //
  21123. // }
  21124. // if item.ChrgitmLv == "3" {
  21125. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21126. // }
  21127. // }
  21128. // if item.MedChrgitmType == "09" { //西药费
  21129. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21130. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21131. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21132. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21133. // if item.ChrgitmLv == "1" {
  21134. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21135. // }
  21136. // if item.ChrgitmLv == "2" {
  21137. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21138. // }
  21139. // if item.ChrgitmLv == "3" {
  21140. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21141. // }
  21142. // }
  21143. // if item.MedChrgitmType == "10" { //中药饮片
  21144. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21145. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21146. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21147. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21148. // if item.ChrgitmLv == "1" {
  21149. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21150. // }
  21151. // if item.ChrgitmLv == "2" {
  21152. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21153. // }
  21154. // if item.ChrgitmLv == "3" {
  21155. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21156. // }
  21157. // }
  21158. //
  21159. // if item.MedChrgitmType == "11" { //中成费
  21160. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21161. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21162. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21163. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21164. // if item.ChrgitmLv == "1" {
  21165. //
  21166. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21167. //
  21168. // }
  21169. // if item.ChrgitmLv == "2" {
  21170. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21171. //
  21172. // }
  21173. // if item.ChrgitmLv == "3" {
  21174. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21175. // }
  21176. // }
  21177. //
  21178. // if item.MedChrgitmType == "12" { //中成费
  21179. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21180. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21181. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21182. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21183. // if item.ChrgitmLv == "1" {
  21184. //
  21185. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21186. //
  21187. // }
  21188. // if item.ChrgitmLv == "2" {
  21189. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21190. //
  21191. // }
  21192. // if item.ChrgitmLv == "3" {
  21193. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21194. // }
  21195. // }
  21196. //
  21197. // if item.MedChrgitmType == "13" { //中成费
  21198. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21199. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21200. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21201. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21202. // if item.ChrgitmLv == "1" {
  21203. //
  21204. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21205. //
  21206. // }
  21207. // if item.ChrgitmLv == "2" {
  21208. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21209. //
  21210. // }
  21211. // if item.ChrgitmLv == "3" {
  21212. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21213. // }
  21214. // }
  21215. //
  21216. // if item.MedChrgitmType == "14" { //其他费
  21217. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21218. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21219. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21220. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21221. // if item.ChrgitmLv == "1" {
  21222. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21223. //
  21224. // }
  21225. // if item.ChrgitmLv == "2" {
  21226. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21227. //
  21228. // }
  21229. // if item.ChrgitmLv == "3" {
  21230. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21231. // }
  21232. // }
  21233. //
  21234. // }
  21235. //
  21236. // var iteminfoStructs []service.IteminfoStruct
  21237. //
  21238. // if bedCostTotal != 0 {
  21239. // iteminfo.MedChrgitm = "01"
  21240. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21241. // iteminfo.Amt = bedCostTotal
  21242. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  21243. // iteminfo.ClabAmt = bed_clab_amt
  21244. // iteminfo.OthAmt = bed_other_amt
  21245. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21246. // }
  21247. //
  21248. // if examineCostTotal != 0 {
  21249. // iteminfo.MedChrgitm = "02"
  21250. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  21251. // iteminfo.Amt = examineCostTotal
  21252. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  21253. // iteminfo.ClabAmt = examine_clab_amt
  21254. // iteminfo.OthAmt = examine_other_amt
  21255. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21256. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21257. // }
  21258. //
  21259. // if checkCostTotal != 0 {
  21260. // iteminfo.MedChrgitm = "03"
  21261. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21262. // iteminfo.Amt = checkCostTotal
  21263. // iteminfo.ClaaSumfee = check_claa_sunmfee
  21264. // iteminfo.ClabAmt = check_clab_amt
  21265. // iteminfo.OthAmt = check_other_amt
  21266. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21267. //
  21268. // }
  21269. //
  21270. // if laboratoryCostTotal != 0 {
  21271. // iteminfo.MedChrgitm = "04"
  21272. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21273. // iteminfo.Amt = laboratoryCostTotal
  21274. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21275. // iteminfo.ClabAmt = laboratory_clab_amt
  21276. // iteminfo.OthAmt = laboratory_other_amt
  21277. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21278. //
  21279. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21280. //
  21281. // }
  21282. //
  21283. // if treatCostTotal != 0 {
  21284. // iteminfo.MedChrgitm = "05"
  21285. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21286. // iteminfo.Amt = treatCostTotal
  21287. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  21288. // iteminfo.ClabAmt = treat_clab_amt
  21289. // iteminfo.OthAmt = treat_other_amt
  21290. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21291. // //(struct4101.IteminfoStruct, iteminfo)
  21292. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21293. // }
  21294. //
  21295. // if operationCostTotal != 0 {
  21296. // iteminfo.MedChrgitm = "06"
  21297. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21298. // iteminfo.Amt = operationCostTotal
  21299. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  21300. // iteminfo.ClabAmt = operation_clab_amt
  21301. // iteminfo.OthAmt = operation_other_amt
  21302. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21303. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21304. // }
  21305. //
  21306. // if nursingCostTotal != 0 {
  21307. // iteminfo.MedChrgitm = "07"
  21308. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  21309. // iteminfo.Amt = nursingCostTotal
  21310. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  21311. // iteminfo.ClabAmt = nursing_clab_amt
  21312. // iteminfo.OthAmt = nursing_other_amt
  21313. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21314. // }
  21315. //
  21316. // if materialCostTotal != 0 {
  21317. // iteminfo.MedChrgitm = "08"
  21318. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21319. // iteminfo.Amt = materialCostTotal
  21320. // iteminfo.ClaaSumfee = material_claa_sunmfee
  21321. // iteminfo.ClabAmt = material_clab_amt
  21322. // iteminfo.OthAmt = material_other_amt
  21323. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21324. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21325. // }
  21326. //
  21327. // if westernMedicineCostTotal != 0 {
  21328. // iteminfo.MedChrgitm = "09"
  21329. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21330. // iteminfo.Amt = westernMedicineCostTotal
  21331. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21332. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21333. // iteminfo.OthAmt = westernMedicine_other_amt
  21334. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21335. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21336. //
  21337. // }
  21338. //
  21339. // if chineseMedicineCostTotal != 0 {
  21340. // iteminfo.MedChrgitm = "10"
  21341. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21342. // iteminfo.Amt = chineseMedicineCostTotal
  21343. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21344. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21345. // iteminfo.OthAmt = chinese_medicine_other_amt
  21346. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21347. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21348. //
  21349. // }
  21350. //
  21351. // if chineseTraditionalMedicineCostTotal != 0 {
  21352. // iteminfo.MedChrgitm = "11"
  21353. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21354. // iteminfo.Amt = westernMedicineCostTotal
  21355. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21356. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21357. // iteminfo.OthAmt = westernMedicine_other_amt
  21358. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21359. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21360. //
  21361. // }
  21362. //
  21363. // if commonlyTreatmentCostTotal != 0 {
  21364. // iteminfo.MedChrgitm = "12"
  21365. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21366. // iteminfo.Amt = commonlyTreatmentCostTotal
  21367. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21368. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21369. // iteminfo.OthAmt = commonly_treatment_other_amt
  21370. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21371. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21372. //
  21373. // }
  21374. //
  21375. // if registerCostTotal != 0 {
  21376. // iteminfo.MedChrgitm = "13"
  21377. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21378. // iteminfo.Amt = registerCostTotal
  21379. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21380. // iteminfo.ClabAmt = register_clab_amt
  21381. // iteminfo.OthAmt = register_other_amt
  21382. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21383. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21384. //
  21385. // }
  21386. //
  21387. // if otherCostTotal != 0 {
  21388. // iteminfo.MedChrgitm = "14"
  21389. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21390. // iteminfo.Amt = otherCostTotal
  21391. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21392. // iteminfo.ClabAmt = other_clab_amt
  21393. // iteminfo.OthAmt = other_other_amt
  21394. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21395. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21396. //
  21397. // }
  21398. // struct4101.IteminfoStruct = iteminfoStructs
  21399. // time_arr := strings.Split(order.SetlTime, " ")
  21400. // struct4101.AdmTime = time_arr[0]
  21401. // struct4101.AdmEndTime = time_arr[0]
  21402. //
  21403. // struct4101.DoctorName = doctor.UserName
  21404. // struct4101.DoctorCode = doctor.DoctorNumber
  21405. //
  21406. // struct4101.Ntly = "中国"
  21407. // struct4101.AdmCaty = "A03.06"
  21408. // var res ResultSeventeen
  21409. // if miConfig.MdtrtareaAdmvs == "421300" {
  21410. // data := make(map[string]interface{})
  21411. // data["struct4101"] = struct4101
  21412. // data["secret_key"] = miConfig.SecretKey
  21413. // data["org_name"] = miConfig.OrgName
  21414. // data["opera"] = curRoles.UserName
  21415. // data["code"] = miConfig.Code
  21416. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21417. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21418. //
  21419. // client := &http.Client{}
  21420. // bytesData, _ := json.Marshal(data)
  21421. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21422. // resp, _ := client.Do(req)
  21423. // defer resp.Body.Close()
  21424. // body, ioErr := ioutil.ReadAll(resp.Body)
  21425. // if ioErr != nil {
  21426. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21427. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21428. // return
  21429. // }
  21430. // var respJSON map[string]interface{}
  21431. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21432. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21433. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21434. // return
  21435. // }
  21436. //
  21437. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21438. // userJSONBytes, _ := json.Marshal(respJSON)
  21439. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21440. // utils.ErrorLog("解析失败:%v", err)
  21441. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21442. // adminUser := c.GetAdminUserInfo()
  21443. // errlog := &models.HisOrderError{
  21444. // UserOrgId: adminUser.CurrentOrgId,
  21445. // Ctime: time.Now().Unix(),
  21446. // Mtime: time.Now().Unix(),
  21447. // ErrMsg: res.ErrMsg + "解析失败",
  21448. // Status: 1,
  21449. // PatientId: order_id,
  21450. // Stage: 10088,
  21451. // }
  21452. // service.CreateErrMsgLog(errlog)
  21453. // continue
  21454. // }
  21455. //
  21456. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21457. // data := make(map[string]interface{})
  21458. // data["struct4101"] = struct4101
  21459. // data["secret_key"] = miConfig.SecretKey
  21460. // data["org_name"] = miConfig.OrgName
  21461. // data["opera"] = curRoles.UserName
  21462. // data["code"] = miConfig.Code
  21463. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21464. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21465. //
  21466. // client := &http.Client{}
  21467. // bytesData, _ := json.Marshal(data)
  21468. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21469. // resp, _ := client.Do(req)
  21470. // defer resp.Body.Close()
  21471. // body, ioErr := ioutil.ReadAll(resp.Body)
  21472. // if ioErr != nil {
  21473. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21475. // return
  21476. // }
  21477. // var respJSON map[string]interface{}
  21478. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21479. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21481. // return
  21482. // }
  21483. //
  21484. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21485. // userJSONBytes, _ := json.Marshal(respJSON)
  21486. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21487. // utils.ErrorLog("解析失败:%v", err)
  21488. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21489. // adminUser := c.GetAdminUserInfo()
  21490. // errlog := &models.HisOrderError{
  21491. // UserOrgId: adminUser.CurrentOrgId,
  21492. // Ctime: time.Now().Unix(),
  21493. // Mtime: time.Now().Unix(),
  21494. // ErrMsg: res.ErrMsg + "解析失败",
  21495. // Status: 1,
  21496. // PatientId: order_id,
  21497. // Stage: 10088,
  21498. // }
  21499. // service.CreateErrMsgLog(errlog)
  21500. // continue
  21501. // }
  21502. //
  21503. // } else {
  21504. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21505. // fmt.Println(result)
  21506. //
  21507. // var dat map[string]interface{}
  21508. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21509. // fmt.Println(dat)
  21510. // } else {
  21511. // fmt.Println(err)
  21512. // }
  21513. // userJSONBytes, _ := json.Marshal(dat)
  21514. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21515. // utils.ErrorLog("解析失败:%v", err)
  21516. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21517. // adminUser := c.GetAdminUserInfo()
  21518. // errlog := &models.HisOrderError{
  21519. // UserOrgId: adminUser.CurrentOrgId,
  21520. // Ctime: time.Now().Unix(),
  21521. // Mtime: time.Now().Unix(),
  21522. // ErrMsg: res.ErrMsg + "解析失败",
  21523. // Status: 1,
  21524. // PatientId: order_id,
  21525. // Stage: 10106,
  21526. // }
  21527. // service.CreateErrMsgLog(errlog)
  21528. // continue
  21529. // }
  21530. // }
  21531. //
  21532. // if res.Infcode != 0 {
  21533. // adminUser := c.GetAdminUserInfo()
  21534. // errlog := &models.HisOrderError{
  21535. // UserOrgId: adminUser.CurrentOrgId,
  21536. // Ctime: time.Now().Unix(),
  21537. // Mtime: time.Now().Unix(),
  21538. // ErrMsg: res.ErrMsg,
  21539. // Status: 1,
  21540. // PatientId: order_id,
  21541. // Stage: 10106,
  21542. // }
  21543. // service.CreateErrMsgLog(errlog)
  21544. // continue
  21545. // } else {
  21546. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21547. // Number: res.Output.SetlListId,
  21548. // Status: 1,
  21549. // Ctime: time.Now().Unix(),
  21550. // Mtime: time.Now().Unix(),
  21551. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21552. // IsUpload: 1,
  21553. // OrderId: order_id,
  21554. // }
  21555. // service.CreateUploadRecord(hisFundSettleListResult)
  21556. // continue
  21557. // }
  21558. // }
  21559. //}
  21560. func (c *HisApiController) GetOrgInfo() {
  21561. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21562. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21563. }
  21564. func (c *HisApiController) GetHisPatientInfo() {
  21565. medical_insurance_card := c.GetString("medical_insurance_card")
  21566. id_card_type, _ := c.GetInt64("id_card_type")
  21567. id_card := c.GetString("id_card")
  21568. adminInfo := c.GetAdminUserInfo()
  21569. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21570. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21571. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21572. IdCardNo := ""
  21573. if id_card_type == 1 {
  21574. IdCardNo = medical_insurance_card
  21575. } else if id_card_type == 2 {
  21576. IdCardNo = id_card
  21577. }
  21578. if config.IsOpen == 1 {
  21579. 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
  21580. resp, requestErr := http.Get(api)
  21581. if requestErr != nil {
  21582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21583. return
  21584. }
  21585. defer resp.Body.Close()
  21586. body, ioErr := ioutil.ReadAll(resp.Body)
  21587. if ioErr != nil {
  21588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21590. return
  21591. }
  21592. var respJSON map[string]interface{}
  21593. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21596. return
  21597. }
  21598. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21599. userJSONBytes, _ := json.Marshal(userJSON)
  21600. var res ResultTwo
  21601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21602. utils.ErrorLog("解析失败:%v", err)
  21603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21604. return
  21605. }
  21606. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21607. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21608. infoStr := string(Iinfos)
  21609. idetinfoStr := string(Idetinfos)
  21610. if res.Infcode == 0 {
  21611. his := models.VMHisPatient{
  21612. Status: 1,
  21613. Ctime: time.Now().Unix(),
  21614. Mtime: time.Now().Unix(),
  21615. PsnNo: res.Output.Baseinfo.PsnNo,
  21616. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21617. Certno: res.Output.Baseinfo.Certno,
  21618. PsnName: res.Output.Baseinfo.PsnName,
  21619. Gend: res.Output.Baseinfo.Gend,
  21620. Naty: res.Output.Baseinfo.Naty,
  21621. Iinfo: infoStr,
  21622. Idetinfo: idetinfoStr,
  21623. UserOrgId: adminInfo.CurrentOrgId,
  21624. IsReturn: 1,
  21625. IdCardType: id_card_type,
  21626. }
  21627. c.ServeSuccessJSON(map[string]interface{}{
  21628. "info": his,
  21629. })
  21630. } else {
  21631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21632. return
  21633. }
  21634. }
  21635. }
  21636. //func GetBasBaseInfo() (jsonStr string, err error) {
  21637. //
  21638. // handle := syscall.NewLazyDLL("SSCard.dll")
  21639. // add := handle.NewProc("ReadCardBas")
  21640. // str := make([]byte, 1024)
  21641. // str1 := make([]byte, 1024)
  21642. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21643. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21644. //
  21645. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21646. //
  21647. // fmt.Println("> Add(4,5)的结果为:", ret)
  21648. // handle.Release()
  21649. //
  21650. // return "", nil
  21651. //
  21652. //}
  21653. //func GetQRBaseInfo() (jsonStr string, err error) {
  21654. // handle := syscall.LoadDLL("SSCard.dll")
  21655. // ReadCardBas := handle.FindProc("GetQRBase")
  21656. //
  21657. // str := make([]byte, 256)
  21658. // str1 := make([]byte, 256)
  21659. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21660. //
  21661. // fmt.Println(string(str))
  21662. // fmt.Println(r)
  21663. // return string(str), nil
  21664. //}
  21665. //func CardInit() int {
  21666. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21667. // add := DllTestDef.MustFindProc("Init")
  21668. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21669. // if err != nil {
  21670. // fmt.Println("SSCard的运算结果为:", ret)
  21671. // }
  21672. // result := int(ret)
  21673. // return result
  21674. //}
  21675. //func CardInit() int {
  21676. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21677. // if err != nil {
  21678. // fmt.Println("SSCard的运算结果为:", ret)
  21679. // }
  21680. // fmt.Println(err)
  21681. // result := int(ret)
  21682. // return result
  21683. //}
  21684. func IntPtr(n int) uintptr {
  21685. return uintptr(n)
  21686. }
  21687. func StrPtr(s string) uintptr {
  21688. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21689. }
  21690. type Result2001 struct {
  21691. Cainfo interface{} `json:"cainfo"`
  21692. ErrMsg string `json:"err_msg"`
  21693. InfRefmsgid string `json:"inf_refmsgid"`
  21694. Infcode int64 `json:"infcode"`
  21695. Output struct {
  21696. Trtinfo struct {
  21697. PsnNo string `json:"psn_no"`
  21698. TrtChkType string `json:"trt_chk_type"`
  21699. FundPayType string `json:"fund_pay_type"`
  21700. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21701. Begndate string `json:"begndate"`
  21702. Enddate string `json:"enddate"`
  21703. TrtChkRslt string `json:"trt_chk_rslt"`
  21704. } `json:"trtinfo"`
  21705. } `json:"output"`
  21706. RefmsgTime string `json:"refmsg_time"`
  21707. RespondTime string `json:"respond_time"`
  21708. Signtype interface{} `json:"signtype"`
  21709. WarnMsg interface{} `json:"warn_msg"`
  21710. }
  21711. type Result2001Org10265 struct {
  21712. Cainfo interface{} `json:"cainfo"`
  21713. ErrMsg string `json:"err_msg"`
  21714. InfRefmsgid string `json:"inf_refmsgid"`
  21715. Infcode string `json:"infcode"`
  21716. Output struct {
  21717. Trtinfo struct {
  21718. PsnNo string `json:"psn_no"`
  21719. TrtChkType string `json:"trt_chk_type"`
  21720. FundPayType string `json:"fund_pay_type"`
  21721. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21722. Begndate string `json:"begndate"`
  21723. Enddate string `json:"enddate"`
  21724. TrtChkRslt string `json:"trt_chk_rslt"`
  21725. } `json:"trtinfo"`
  21726. } `json:"output"`
  21727. RefmsgTime string `json:"refmsg_time"`
  21728. RespondTime string `json:"respond_time"`
  21729. Signtype interface{} `json:"signtype"`
  21730. WarnMsg interface{} `json:"warn_msg"`
  21731. }
  21732. type ResultTwo struct {
  21733. ErrMsg string `json:"err_msg"`
  21734. InfRefmsgid string `json:"inf_refmsgid"`
  21735. Infcode int64 `json:"infcode"`
  21736. Output struct {
  21737. Baseinfo struct {
  21738. //Brdy string `json:"brdy"`
  21739. Certno string `json:"certno"`
  21740. Gend string `json:"gend"`
  21741. Naty string `json:"naty"`
  21742. PsnCertType string `json:"psn_cert_type"`
  21743. PsnName string `json:"psn_name"`
  21744. PsnNo string `json:"psn_no"`
  21745. } `json:"baseinfo"`
  21746. Idetinfo []interface{} `json:"idetinfo"`
  21747. Iinfo []struct {
  21748. Balc float64 `json:"balc"`
  21749. CvlservFlag string `json:"cvlserv_flag"`
  21750. EmpName string `json:"emp_name"`
  21751. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21752. Insutype string `json:"insutype"`
  21753. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21754. //PausInsuDate string `json:"paus_insu_date"`
  21755. //PsnInsuDate string `json:"psn_insu_date"`
  21756. PsnInsuStas string `json:"psn_insu_stas"`
  21757. PsnType string `json:"psn_type"`
  21758. } `json:"insuinfo"`
  21759. } `json:"output"`
  21760. RefmsgTime string `json:"refmsg_time"`
  21761. RespondTime string `json:"respond_time"`
  21762. Signtype interface{} `json:"signtype"`
  21763. WarnInfo interface{} `json:"warn_info"`
  21764. }
  21765. type ResultTwo10265 struct {
  21766. ErrMsg string `json:"err_msg"`
  21767. InfRefmsgid string `json:"inf_refmsgid"`
  21768. Infcode string `json:"infcode"`
  21769. Output struct {
  21770. Baseinfo struct {
  21771. //Brdy string `json:"brdy"`
  21772. Certno string `json:"certno"`
  21773. Gend string `json:"gend"`
  21774. Naty string `json:"naty"`
  21775. PsnCertType string `json:"psn_cert_type"`
  21776. PsnName string `json:"psn_name"`
  21777. PsnNo string `json:"psn_no"`
  21778. } `json:"baseinfo"`
  21779. Idetinfo []interface{} `json:"idetinfo"`
  21780. Iinfo []struct {
  21781. Balc float64 `json:"balc"`
  21782. CvlservFlag string `json:"cvlserv_flag"`
  21783. EmpName string `json:"emp_name"`
  21784. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21785. Insutype string `json:"insutype"`
  21786. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21787. PsnInsuStas string `json:"psn_insu_stas"`
  21788. PsnType string `json:"psn_type"`
  21789. } `json:"insuinfo"`
  21790. } `json:"output"`
  21791. RefmsgTime string `json:"refmsg_time"`
  21792. RespondTime string `json:"respond_time"`
  21793. Signtype interface{} `json:"signtype"`
  21794. WarnInfo interface{} `json:"warn_info"`
  21795. }
  21796. type ResultThree struct {
  21797. Cainfo interface{} `json:"cainfo"`
  21798. ErrMsg string `json:"err_msg"`
  21799. InfRefmsgid string `json:"inf_refmsgid"`
  21800. Infcode int64 `json:"infcode"`
  21801. Output struct {
  21802. Data struct {
  21803. IptOtpNo string `json:"ipt_otp_no"`
  21804. MdtrtID string `json:"mdtrt_id"`
  21805. PsnNo string `json:"psn_no"`
  21806. } `json:"data"`
  21807. } `json:"output"`
  21808. RefmsgTime string `json:"refmsg_time"`
  21809. RespondTime string `json:"respond_time"`
  21810. Signtype interface{} `json:"signtype"`
  21811. WarnMsg interface{} `json:"warn_msg"`
  21812. }
  21813. type ResultThree10265 struct {
  21814. Cainfo interface{} `json:"cainfo"`
  21815. ErrMsg string `json:"err_msg"`
  21816. InfRefmsgid string `json:"inf_refmsgid"`
  21817. Infcode string `json:"infcode"`
  21818. Output struct {
  21819. Data struct {
  21820. IptOtpNo string `json:"ipt_otp_no"`
  21821. MdtrtID string `json:"mdtrt_id"`
  21822. PsnNo string `json:"psn_no"`
  21823. } `json:"data"`
  21824. } `json:"output"`
  21825. RefmsgTime string `json:"refmsg_time"`
  21826. RespondTime string `json:"respond_time"`
  21827. Signtype interface{} `json:"signtype"`
  21828. WarnMsg interface{} `json:"warn_msg"`
  21829. }
  21830. type ResultFour struct {
  21831. Cainfo string `json:"cainfo"`
  21832. ErrMsg string `json:"err_msg"`
  21833. InfRefmsgid string `json:"inf_refmsgid"`
  21834. Infcode int64 `json:"infcode"`
  21835. Output struct {
  21836. Result []struct {
  21837. BasMednFlag string `json:"bas_medn_flag"`
  21838. ChldMedcFlag string `json:"chld_medc_flag"`
  21839. ChrgitmLv string `json:"chrgitm_lv"`
  21840. Cnt float64 `json:"cnt"`
  21841. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21842. DrtReimFlag string `json:"drt_reim_flag"`
  21843. FeedetlSn string `json:"feedetl_sn"`
  21844. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21845. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21846. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21847. ListSpItemFlag string `json:"list_sp_item_flag"`
  21848. LmtUsedFlag string `json:"lmt_used_flag"`
  21849. MedChrgitmType string `json:"med_chrgitm_type"`
  21850. Memo string `json:"memo"`
  21851. OverlmtAmt float64 `json:"overlmt_amt"`
  21852. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21853. Pric float64 `json:"pric"`
  21854. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21855. SelfpayProp float64 `json:"selfpay_prop"`
  21856. } `json:"result"`
  21857. } `json:"output"`
  21858. RefmsgTime string `json:"refmsg_time"`
  21859. RespondTime string `json:"respond_time"`
  21860. Signtype string `json:"signtype"`
  21861. WarnMsg string `json:"warn_msg"`
  21862. }
  21863. type ResultFour10265 struct {
  21864. Cainfo string `json:"cainfo"`
  21865. ErrMsg string `json:"err_msg"`
  21866. InfRefmsgid string `json:"inf_refmsgid"`
  21867. Infcode string `json:"infcode"`
  21868. Output struct {
  21869. Result []struct {
  21870. BasMednFlag string `json:"bas_medn_flag"`
  21871. ChldMedcFlag string `json:"chld_medc_flag"`
  21872. ChrgitmLv string `json:"chrgitm_lv"`
  21873. Cnt float64 `json:"cnt"`
  21874. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21875. DrtReimFlag string `json:"drt_reim_flag"`
  21876. FeedetlSn string `json:"feedetl_sn"`
  21877. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21878. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21879. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21880. ListSpItemFlag string `json:"list_sp_item_flag"`
  21881. LmtUsedFlag string `json:"lmt_used_flag"`
  21882. MedChrgitmType string `json:"med_chrgitm_type"`
  21883. Memo string `json:"memo"`
  21884. OverlmtAmt float64 `json:"overlmt_amt"`
  21885. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21886. Pric float64 `json:"pric"`
  21887. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21888. SelfpayProp float64 `json:"selfpay_prop"`
  21889. } `json:"result"`
  21890. } `json:"output"`
  21891. RefmsgTime string `json:"refmsg_time"`
  21892. RespondTime string `json:"respond_time"`
  21893. Signtype string `json:"signtype"`
  21894. WarnMsg string `json:"warn_msg"`
  21895. }
  21896. type ResultMemo struct {
  21897. InsuAdmdvs string `json:"insuAdmdvs"`
  21898. }
  21899. // [{"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}]
  21900. type ResultIDInfo struct {
  21901. Begntime string `json:"begntime"`
  21902. Endtime string `json:"endtime"`
  21903. Memo string `json:"memo"`
  21904. }
  21905. type ResultFive struct {
  21906. Balc float64 `json:"balc"`
  21907. CvlservFlag string `json:"cvlserv_flag"`
  21908. EmpName string `json:"emp_name"`
  21909. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21910. Insutype string `json:"insutype"`
  21911. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21912. PausInsuDate string `json:"paus_insu_date"`
  21913. PsnInsuDate string `json:"psn_insu_date"`
  21914. PsnInsuStas string `json:"psn_insu_stas"`
  21915. PsnType string `json:"psn_type"`
  21916. }
  21917. type ResultSix struct {
  21918. Cainfo interface{} `json:"cainfo"`
  21919. ErrMsg string `json:"err_msg"`
  21920. InfRefmsgid string `json:"inf_refmsgid"`
  21921. Infcode int64 `json:"infcode"`
  21922. Output struct {
  21923. } `json:"output"`
  21924. RefmsgTime string `json:"refmsg_time"`
  21925. RespondTime string `json:"respond_time"`
  21926. Signtype interface{} `json:"signtype"`
  21927. WarnMsg interface{} `json:"warn_msg"`
  21928. }
  21929. type FJ3507Result struct {
  21930. Cainfo interface{} `json:"cainfo"`
  21931. ErrMsg string `json:"err_msg"`
  21932. InfRefmsgid string `json:"inf_refmsgid"`
  21933. Infcode int64 `json:"infcode"`
  21934. Output struct {
  21935. retRslt string `json:"retRslt"`
  21936. msgRslt string `json:"msgRslt"`
  21937. } `json:"output"`
  21938. RefmsgTime string `json:"refmsg_time"`
  21939. RespondTime string `json:"respond_time"`
  21940. Signtype interface{} `json:"signtype"`
  21941. WarnMsg interface{} `json:"warn_msg"`
  21942. }
  21943. type FJ3507ResultFor10188 struct {
  21944. Cainfo interface{} `json:"cainfo"`
  21945. ErrMsg string `json:"err_msg"`
  21946. InfRefmsgid string `json:"inf_refmsgid"`
  21947. Infcode string `json:"infcode"`
  21948. RefmsgTime string `json:"refmsg_time"`
  21949. RespondTime string `json:"respond_time"`
  21950. Signtype interface{} `json:"signtype"`
  21951. WarnMsg interface{} `json:"warn_msg"`
  21952. }
  21953. type Result2406 struct {
  21954. Cainfo interface{} `json:"cainfo"`
  21955. ErrMsg string `json:"err_msg"`
  21956. InfRefmsgid string `json:"inf_refmsgid"`
  21957. Infcode int64 `json:"infcode"`
  21958. Output struct {
  21959. Result struct {
  21960. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21961. } `json:"result"`
  21962. } `json:"output"`
  21963. RefmsgTime string `json:"refmsg_time"`
  21964. RespondTime string `json:"respond_time"`
  21965. Signtype interface{} `json:"signtype"`
  21966. WarnMsg interface{} `json:"warn_msg"`
  21967. }
  21968. type GZResultSix struct {
  21969. Cainfo interface{} `json:"cainfo"`
  21970. ErrMsg string `json:"err_msg"`
  21971. InfRefmsgid string `json:"inf_refmsgid"`
  21972. Infcode int64 `json:"infcode"`
  21973. Output string `json:"output"`
  21974. RefmsgTime string `json:"refmsg_time"`
  21975. RespondTime string `json:"respond_time"`
  21976. Signtype interface{} `json:"signtype"`
  21977. WarnMsg interface{} `json:"warn_msg"`
  21978. }
  21979. type ResultSix10265 struct {
  21980. Cainfo interface{} `json:"cainfo"`
  21981. ErrMsg string `json:"err_msg"`
  21982. InfRefmsgid string `json:"inf_refmsgid"`
  21983. Infcode string `json:"infcode"`
  21984. Output struct {
  21985. } `json:"output"`
  21986. RefmsgTime string `json:"refmsg_time"`
  21987. RespondTime string `json:"respond_time"`
  21988. Signtype interface{} `json:"signtype"`
  21989. WarnMsg interface{} `json:"warn_msg"`
  21990. }
  21991. type ResultSeven struct {
  21992. Cainfo string `json:"cainfo"`
  21993. ErrMsg string `json:"err_msg"`
  21994. InfRefmsgid string `json:"inf_refmsgid"`
  21995. Infcode int64 `json:"infcode"`
  21996. Output struct {
  21997. Setlinfo struct {
  21998. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21999. AcctPay float64 `json:"acct_pay"`
  22000. ActPayDedc float64 `json:"act_pay_dedc"`
  22001. Age float64 `json:"age"`
  22002. Balc float64 `json:"balc"`
  22003. Certno string `json:"certno"`
  22004. ClrOptins string `json:"clr_optins"`
  22005. ClrType string `json:"clr_type"`
  22006. ClrWay string `json:"clr_way"`
  22007. CvlservFlag string `json:"cvlserv_flag"`
  22008. CvlservPay float64 `json:"cvlserv_pay"`
  22009. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22010. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22011. Gend string `json:"gend"`
  22012. HifesPay float64 `json:"hifes_pay"`
  22013. HifmiPay float64 `json:"hifmi_pay"`
  22014. HifpPay float64 `json:"hifp_pay"`
  22015. HospPartAmt float64 `json:"hosp_part_amt"`
  22016. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22017. Insutype string `json:"insutype"`
  22018. MafPay float64 `json:"maf_pay"`
  22019. MdtrtCertType string `json:"mdtrt_cert_type"`
  22020. HifobPay float64 `json:"hifob_pay"`
  22021. MdtrtID string `json:"mdtrt_id"`
  22022. MedType string `json:"med_type"`
  22023. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22024. MedinsSetlID string `json:"medins_setl_id"`
  22025. Naty string `json:"naty"`
  22026. OthPay float64 `json:"oth_pay"`
  22027. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22028. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22029. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22030. PsnCashPay float64 `json:"psn_cash_pay"`
  22031. PsnCertType string `json:"psn_cert_type"`
  22032. PsnName string `json:"psn_name"`
  22033. PsnNo string `json:"psn_no"`
  22034. PsnPartAmt float64 `json:"psn_part_amt"`
  22035. PsnType string `json:"psn_type"`
  22036. SetlID string `json:"setl_id"`
  22037. SetlTime string `json:"setl_time"`
  22038. } `json:"setlinfo"`
  22039. Setldetail interface{} `json:"setldetail"`
  22040. } `json:"output"`
  22041. RefmsgTime string `json:"refmsg_time"`
  22042. RespondTime string `json:"respond_time"`
  22043. Signtype interface{} `json:"signtype"`
  22044. WarnMsg interface{} `json:"warn_msg"`
  22045. }
  22046. type ResultSevenAH struct {
  22047. Cainfo string `json:"cainfo"`
  22048. ErrMsg string `json:"err_msg"`
  22049. InfRefmsgid string `json:"inf_refmsgid"`
  22050. Infcode int64 `json:"infcode"`
  22051. Output struct {
  22052. Setlinfo struct {
  22053. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22054. AcctPay float64 `json:"acct_pay"`
  22055. ActPayDedc float64 `json:"act_pay_dedc"`
  22056. Age float64 `json:"age"`
  22057. Balc float64 `json:"balc"`
  22058. Certno string `json:"certno"`
  22059. ClrOptins string `json:"clr_optins"`
  22060. ClrType string `json:"clr_type"`
  22061. ClrWay string `json:"clr_way"`
  22062. CvlservFlag string `json:"cvlserv_flag"`
  22063. CvlservPay float64 `json:"cvlserv_pay"`
  22064. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22065. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22066. Gend string `json:"gend"`
  22067. HifesPay float64 `json:"hifes_pay"`
  22068. HifmiPay float64 `json:"hifmi_pay"`
  22069. HifpPay float64 `json:"hifp_pay"`
  22070. HospPartAmt float64 `json:"hosp_part_amt"`
  22071. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22072. Insutype string `json:"insutype"`
  22073. MafPay float64 `json:"maf_pay"`
  22074. MdtrtCertType string `json:"mdtrt_cert_type"`
  22075. HifobPay float64 `json:"hifob_pay"`
  22076. MdtrtID string `json:"mdtrt_id"`
  22077. MedType string `json:"med_type"`
  22078. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22079. MedinsSetlID string `json:"medins_setl_id"`
  22080. Naty string `json:"naty"`
  22081. OthPay float64 `json:"oth_pay"`
  22082. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22083. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22084. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22085. PsnCashPay float64 `json:"psn_cash_pay"`
  22086. PsnCertType string `json:"psn_cert_type"`
  22087. PsnName string `json:"psn_name"`
  22088. PsnNo string `json:"psn_no"`
  22089. PsnPartAmt float64 `json:"psn_part_amt"`
  22090. PsnType string `json:"psn_type"`
  22091. SetlID string `json:"setl_id"`
  22092. SetlTime int64 `json:"setl_time"`
  22093. } `json:"setlinfo"`
  22094. Setldetail interface{} `json:"setldetail"`
  22095. } `json:"output"`
  22096. RefmsgTime string `json:"refmsg_time"`
  22097. RespondTime string `json:"respond_time"`
  22098. Signtype interface{} `json:"signtype"`
  22099. WarnMsg interface{} `json:"warn_msg"`
  22100. }
  22101. type ResultSeven10265 struct {
  22102. Cainfo string `json:"cainfo"`
  22103. ErrMsg string `json:"err_msg"`
  22104. InfRefmsgid string `json:"inf_refmsgid"`
  22105. Infcode string `json:"infcode"`
  22106. Output struct {
  22107. Setlinfo struct {
  22108. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22109. AcctPay float64 `json:"acct_pay"`
  22110. ActPayDedc float64 `json:"act_pay_dedc"`
  22111. Age float64 `json:"age"`
  22112. Balc float64 `json:"balc"`
  22113. Certno string `json:"certno"`
  22114. ClrOptins string `json:"clr_optins"`
  22115. ClrType string `json:"clr_type"`
  22116. ClrWay string `json:"clr_way"`
  22117. CvlservFlag string `json:"cvlserv_flag"`
  22118. CvlservPay float64 `json:"cvlserv_pay"`
  22119. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22120. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22121. Gend string `json:"gend"`
  22122. HifesPay float64 `json:"hifes_pay"`
  22123. HifmiPay float64 `json:"hifmi_pay"`
  22124. HifpPay float64 `json:"hifp_pay"`
  22125. HospPartAmt float64 `json:"hosp_part_amt"`
  22126. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22127. Insutype string `json:"insutype"`
  22128. MafPay float64 `json:"maf_pay"`
  22129. MdtrtCertType string `json:"mdtrt_cert_type"`
  22130. HifobPay float64 `json:"hifob_pay"`
  22131. MdtrtID string `json:"mdtrt_id"`
  22132. MedType string `json:"med_type"`
  22133. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22134. MedinsSetlID string `json:"medins_setl_id"`
  22135. Naty string `json:"naty"`
  22136. OthPay float64 `json:"oth_pay"`
  22137. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22138. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22139. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22140. PsnCashPay float64 `json:"psn_cash_pay"`
  22141. PsnCertType string `json:"psn_cert_type"`
  22142. PsnName string `json:"psn_name"`
  22143. PsnNo string `json:"psn_no"`
  22144. PsnPartAmt float64 `json:"psn_part_amt"`
  22145. PsnType string `json:"psn_type"`
  22146. SetlID string `json:"setl_id"`
  22147. SetlTime string `json:"setl_time"`
  22148. } `json:"setlinfo"`
  22149. Setldetail interface{} `json:"setldetail"`
  22150. } `json:"output"`
  22151. RefmsgTime string `json:"refmsg_time"`
  22152. RespondTime string `json:"respond_time"`
  22153. Signtype interface{} `json:"signtype"`
  22154. WarnMsg interface{} `json:"warn_msg"`
  22155. }
  22156. type ResultSeven10265Two struct {
  22157. Cainfo string `json:"cainfo"`
  22158. ErrMsg string `json:"err_msg"`
  22159. InfRefmsgid string `json:"inf_refmsgid"`
  22160. Infcode string `json:"infcode"`
  22161. Output struct {
  22162. Setlinfo struct {
  22163. AcctMulaidPay string `json:"acct_mulaid_pay"`
  22164. AcctPay float64 `json:"acct_pay"`
  22165. ActPayDedc float64 `json:"act_pay_dedc"`
  22166. Age float64 `json:"age"`
  22167. Balc float64 `json:"balc"`
  22168. Certno string `json:"certno"`
  22169. ClrOptins string `json:"clr_optins"`
  22170. ClrType string `json:"clr_type"`
  22171. ClrWay string `json:"clr_way"`
  22172. CvlservFlag string `json:"cvlserv_flag"`
  22173. CvlservPay float64 `json:"cvlserv_pay"`
  22174. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22175. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22176. Gend string `json:"gend"`
  22177. HifesPay float64 `json:"hifes_pay"`
  22178. HifmiPay float64 `json:"hifmi_pay"`
  22179. HifpPay float64 `json:"hifp_pay"`
  22180. HospPartAmt string `json:"hosp_part_amt"`
  22181. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22182. Insutype string `json:"insutype"`
  22183. MafPay float64 `json:"maf_pay"`
  22184. MdtrtCertType string `json:"mdtrt_cert_type"`
  22185. HifobPay float64 `json:"hifob_pay"`
  22186. MdtrtID string `json:"mdtrt_id"`
  22187. MedType string `json:"med_type"`
  22188. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22189. MedinsSetlID string `json:"medins_setl_id"`
  22190. Naty string `json:"naty"`
  22191. OthPay float64 `json:"oth_pay"`
  22192. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22193. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22194. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22195. PsnCashPay float64 `json:"psn_cash_pay"`
  22196. PsnCertType string `json:"psn_cert_type"`
  22197. PsnName string `json:"psn_name"`
  22198. PsnNo string `json:"psn_no"`
  22199. PsnPartAmt float64 `json:"psn_part_amt"`
  22200. PsnType string `json:"psn_type"`
  22201. SetlID string `json:"setl_id"`
  22202. SetlTime string `json:"setl_time"`
  22203. } `json:"setlinfo"`
  22204. Setldetail interface{} `json:"setldetail"`
  22205. } `json:"output"`
  22206. RefmsgTime string `json:"refmsg_time"`
  22207. RespondTime string `json:"respond_time"`
  22208. Signtype interface{} `json:"signtype"`
  22209. WarnMsg interface{} `json:"warn_msg"`
  22210. }
  22211. type GZResultSeven10265Two struct {
  22212. Cainfo string `json:"cainfo"`
  22213. ErrMsg string `json:"err_msg"`
  22214. InfRefmsgid string `json:"inf_refmsgid"`
  22215. Infcode int64 `json:"infcode"`
  22216. Output struct {
  22217. Setlinfo struct {
  22218. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22219. AcctPay float64 `json:"acct_pay"`
  22220. ActPayDedc float64 `json:"act_pay_dedc"`
  22221. Age float64 `json:"age"`
  22222. Balc float64 `json:"balc"`
  22223. Certno string `json:"certno"`
  22224. ClrOptins string `json:"clr_optins"`
  22225. ClrType string `json:"clr_type"`
  22226. ClrWay string `json:"clr_way"`
  22227. CvlservFlag string `json:"cvlserv_flag"`
  22228. CvlservPay float64 `json:"cvlserv_pay"`
  22229. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22230. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22231. Gend string `json:"gend"`
  22232. HifesPay float64 `json:"hifes_pay"`
  22233. HifmiPay float64 `json:"hifmi_pay"`
  22234. HifpPay float64 `json:"hifp_pay"`
  22235. HospPartAmt float64 `json:"hosp_part_amt"`
  22236. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22237. Insutype string `json:"insutype"`
  22238. MafPay float64 `json:"maf_pay"`
  22239. MdtrtCertType string `json:"mdtrt_cert_type"`
  22240. HifobPay float64 `json:"hifob_pay"`
  22241. MdtrtID string `json:"mdtrt_id"`
  22242. MedType string `json:"med_type"`
  22243. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22244. MedinsSetlID string `json:"medins_setl_id"`
  22245. Naty string `json:"naty"`
  22246. OthPay float64 `json:"oth_pay"`
  22247. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22248. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22249. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22250. PsnCashPay float64 `json:"psn_cash_pay"`
  22251. PsnCertType string `json:"psn_cert_type"`
  22252. PsnName string `json:"psn_name"`
  22253. PsnNo string `json:"psn_no"`
  22254. PsnPartAmt float64 `json:"psn_part_amt"`
  22255. PsnType string `json:"psn_type"`
  22256. SetlID string `json:"setl_id"`
  22257. SetlTime string `json:"setl_time"`
  22258. } `json:"setlinfo"`
  22259. Setldetail interface{} `json:"setldetail"`
  22260. } `json:"output"`
  22261. RefmsgTime string `json:"refmsg_time"`
  22262. RespondTime string `json:"respond_time"`
  22263. Signtype interface{} `json:"signtype"`
  22264. WarnMsg interface{} `json:"warn_msg"`
  22265. }
  22266. type ResultEight struct {
  22267. Cainfo string `json:"cainfo"`
  22268. ErrMsg string `json:"err_msg"`
  22269. InfRefmsgid string `json:"inf_refmsgid"`
  22270. Infcode int64 `json:"infcode"`
  22271. Output struct {
  22272. Stmtinfo struct {
  22273. SetlOptins string `json:"setl_optins"`
  22274. StmtRslt string `json:"stmt_rslt"`
  22275. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22276. } `json:"stmtinfo"`
  22277. } `json:"output"`
  22278. RefmsgTime string `json:"refmsg_time"`
  22279. RespondTime string `json:"respond_time"`
  22280. Signtype interface{} `json:"signtype"`
  22281. WarnMsg interface{} `json:"warn_msg"`
  22282. }
  22283. type ResultEightFor10188 struct {
  22284. Cainfo string `json:"cainfo"`
  22285. ErrMsg string `json:"err_msg"`
  22286. InfRefmsgid string `json:"inf_refmsgid"`
  22287. Infcode string `json:"infcode"`
  22288. Output struct {
  22289. Stmtinfo struct {
  22290. SetlOptins string `json:"setl_optins"`
  22291. StmtRslt string `json:"stmt_rslt"`
  22292. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22293. } `json:"stmtinfo"`
  22294. } `json:"output"`
  22295. RefmsgTime string `json:"refmsg_time"`
  22296. RespondTime string `json:"respond_time"`
  22297. Signtype interface{} `json:"signtype"`
  22298. WarnMsg interface{} `json:"warn_msg"`
  22299. }
  22300. type ResultNine struct {
  22301. Cainfo string `json:"cainfo"`
  22302. ErrMsg string `json:"err_msg"`
  22303. InfRefmsgid string `json:"inf_refmsgid"`
  22304. Infcode int64 `json:"infcode"`
  22305. Output struct {
  22306. FileQuryNo string `json:"file_qury_no"`
  22307. } `json:"output"`
  22308. RefmsgTime string `json:"refmsg_time"`
  22309. RespondTime string `json:"respond_time"`
  22310. Signtype interface{} `json:"signtype"`
  22311. WarnMsg interface{} `json:"warn_msg"`
  22312. }
  22313. type ResultTen struct {
  22314. Cainfo string `json:"cainfo"`
  22315. ErrMsg string `json:"err_msg"`
  22316. InfRefmsgid string `json:"inf_refmsgid"`
  22317. Infcode int64 `json:"infcode"`
  22318. Output struct {
  22319. Fileinfo struct {
  22320. DldEndtime string `json:"dld_endtime"`
  22321. FileQuryNo string `json:"file_qury_no"`
  22322. Filename string `json:"filename"`
  22323. } `json:"fileinfo"`
  22324. } `json:"output"`
  22325. RefmsgTime string `json:"refmsg_time"`
  22326. RespondTime string `json:"respond_time"`
  22327. Signtype interface{} `json:"signtype"`
  22328. WarnMsg interface{} `json:"warn_msg"`
  22329. }
  22330. type Result5262 struct {
  22331. ErrMsg string `json:"err_msg"`
  22332. InfRefmsgid string `json:"inf_refmsgid"`
  22333. Infcode int64 `json:"infcode"`
  22334. Output struct {
  22335. PageInfo struct {
  22336. Size int `json:"size"`
  22337. RecordCounts int `json:"record_counts"`
  22338. } `json:"page_info"`
  22339. Idetinfo []interface{} `json:"idetinfo"`
  22340. Result []struct {
  22341. SetlID string `json:"setl_id"`
  22342. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22343. MdtrtID string `json:"mdtrt_id"`
  22344. InitSetlID string `json:"init_setl_id,omitempty"`
  22345. PsnNo string `json:"psn_no"`
  22346. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22347. PsnName string `json:"psn_name"`
  22348. PsnCertType string `json:"psn_cert_type"`
  22349. Certno string `json:"certno"`
  22350. Gend string `json:"gend,omitempty"`
  22351. Naty string `json:"naty,omitempty"`
  22352. Brdy string `json:"brdy,omitempty"`
  22353. Age float64 `json:"age,omitempty"`
  22354. Insutype string `json:"insutype,omitempty"`
  22355. PsnType string `json:"psn_type"`
  22356. CvlservFlag string `json:"cvlserv_flag"`
  22357. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22358. SpPsnType string `json:"sp_psn_type,omitempty"`
  22359. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22360. ClctGrde string `json:"clct_grde,omitempty"`
  22361. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22362. NwbFlag string `json:"nwb_flag,omitempty"`
  22363. InsuAdmdvs string `json:"insu_admdvs"`
  22364. EmpNo string `json:"emp_no,omitempty"`
  22365. EmpName string `json:"emp_name,omitempty"`
  22366. EmpType string `json:"emp_type,omitempty"`
  22367. EconType string `json:"econ_type,omitempty"`
  22368. AfilIndu string `json:"afil_indu,omitempty"`
  22369. AfilRlts string `json:"afil_rlts,omitempty"`
  22370. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22371. PayLoc string `json:"pay_loc,omitempty"`
  22372. FixmedinsCode string `json:"fixmedins_code"`
  22373. FixmedinsName string `json:"fixmedins_name"`
  22374. HospLv string `json:"hosp_lv,omitempty"`
  22375. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22376. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22377. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22378. Begndate string `json:"begndate"`
  22379. Enddate string `json:"enddate"`
  22380. SetlTime string `json:"setl_time"`
  22381. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22382. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22383. MedType string `json:"med_type"`
  22384. SetlType string `json:"setl_type,omitempty"`
  22385. ClrType string `json:"clr_type,omitempty"`
  22386. ClrWay string `json:"clr_way,omitempty"`
  22387. PsnSetlway string `json:"psn_setlway,omitempty"`
  22388. ClrOptins string `json:"clr_optins,omitempty"`
  22389. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22390. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22391. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22392. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22393. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22394. DedcStd float64 `json:"dedc_std,omitempty"`
  22395. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22396. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22397. HifpPay float64 `json:"hifp_pay,omitempty"`
  22398. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22399. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22400. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22401. HifesPay float64 `json:"hifes_pay,omitempty"`
  22402. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22403. HifobPay float64 `json:"hifob_pay,omitempty"`
  22404. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22405. MafPay float64 `json:"maf_pay,omitempty"`
  22406. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22407. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22408. PsnPay float64 `json:"psn_pay,omitempty"`
  22409. AcctPay float64 `json:"acct_pay,omitempty"`
  22410. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22411. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22412. Balc float64 `json:"balc,omitempty"`
  22413. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22414. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22415. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22416. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22417. Year string `json:"year,omitempty"`
  22418. DiseNo string `json:"dise_no,omitempty"`
  22419. DiseName string `json:"dise_name,omitempty"`
  22420. Invono string `json:"invono,omitempty"`
  22421. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22422. ValiFlag string `json:"vali_flag,omitempty"`
  22423. Memo string `json:"memo,omitempty"`
  22424. Rid string `json:"rid"`
  22425. UpdtTime string `json:"updt_time,omitempty"`
  22426. CrterID string `json:"crter_id,omitempty"`
  22427. CrterName string `json:"crter_name,omitempty"`
  22428. CrteTime string `json:"crte_time,omitempty"`
  22429. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22430. OpterID string `json:"opter_id,omitempty"`
  22431. OpterName string `json:"opter_name,omitempty"`
  22432. OptTime string `json:"opt_time,omitempty"`
  22433. OptinsNo string `json:"optins_no,omitempty"`
  22434. PoolareaNo string `json:"poolarea_no,omitempty"`
  22435. } `json:"result"`
  22436. } `json:"output"`
  22437. RefmsgTime string `json:"refmsg_time"`
  22438. RespondTime string `json:"respond_time"`
  22439. Signtype interface{} `json:"signtype"`
  22440. WarnInfo interface{} `json:"warn_info"`
  22441. }
  22442. type Result5267 struct {
  22443. ErrMsg string `json:"err_msg"`
  22444. InfRefmsgid string `json:"inf_refmsgid"`
  22445. Infcode int64 `json:"infcode"`
  22446. Output struct {
  22447. PageInfo struct {
  22448. Size int `json:"size"`
  22449. RecordCounts int `json:"record_counts"`
  22450. } `json:"pageinfo"`
  22451. Result []struct {
  22452. SetlID string `json:"setl_id"`
  22453. ClrOptins string `json:"clr_optins"`
  22454. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22455. MdtrtID string `json:"mdtrt_id"`
  22456. InitSetlID string `json:"init_setl_id,omitempty"`
  22457. PsnNo string `json:"psn_no"`
  22458. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22459. PsnName string `json:"psn_name"`
  22460. PsnCertType string `json:"psn_cert_type"`
  22461. Certno string `json:"certno"`
  22462. Gend string `json:"gend,omitempty"`
  22463. Naty string `json:"naty,omitempty"`
  22464. Brdy string `json:"brdy,omitempty"`
  22465. Age float64 `json:"age,omitempty"`
  22466. Insutype string `json:"insutype,omitempty"`
  22467. PsnType string `json:"psn_type"`
  22468. CvlservFlag string `json:"cvlserv_flag"`
  22469. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22470. SpPsnType string `json:"sp_psn_type,omitempty"`
  22471. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22472. ClctGrde string `json:"clct_grde,omitempty"`
  22473. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22474. NwbFlag string `json:"nwb_flag,omitempty"`
  22475. InsuAdmdvs string `json:"insu_admdvs"`
  22476. EmpNo string `json:"emp_no,omitempty"`
  22477. EmpName string `json:"emp_name,omitempty"`
  22478. EmpType string `json:"emp_type,omitempty"`
  22479. EconType string `json:"econ_type,omitempty"`
  22480. AfilIndu string `json:"afil_indu,omitempty"`
  22481. AfilRlts string `json:"afil_rlts,omitempty"`
  22482. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22483. PayLoc string `json:"pay_loc,omitempty"`
  22484. FixmedinsCode string `json:"fixmedins_code"`
  22485. FixmedinsName string `json:"fixmedins_name"`
  22486. HospLv string `json:"hosp_lv,omitempty"`
  22487. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22488. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22489. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22490. Begndate string `json:"begndate,omitempty"`
  22491. Enddate string `json:"enddate,omitempty"`
  22492. SetlTime string `json:"setl_time,omitempty"`
  22493. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22494. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22495. MedType string `json:"med_type"`
  22496. SetlType string `json:"setl_type,omitempty"`
  22497. ClrType string `json:"clr_type,omitempty"`
  22498. ClrWay string `json:"clr_way,omitempty"`
  22499. PsnSetlway string `json:"psn_setlway,omitempty"`
  22500. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22501. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22502. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22503. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22504. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22505. DedcStd float64 `json:"dedc_std,omitempty"`
  22506. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22507. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22508. HifpPay float64 `json:"hifp_pay,omitempty"`
  22509. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22510. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22511. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22512. HifesPay float64 `json:"hifes_pay,omitempty"`
  22513. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22514. HifobPay float64 `json:"hifob_pay,omitempty"`
  22515. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22516. MafPay float64 `json:"maf_pay,omitempty"`
  22517. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22518. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22519. PsnPay float64 `json:"psn_pay,omitempty"`
  22520. AcctPay float64 `json:"acct_pay,omitempty"`
  22521. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22522. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22523. Balc float64 `json:"balc,omitempty"`
  22524. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22525. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22526. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22527. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22528. Year string `json:"year,omitempty"`
  22529. DiseNo string `json:"dise_no,omitempty"`
  22530. DiseName string `json:"dise_name,omitempty"`
  22531. Invono string `json:"invono,omitempty"`
  22532. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22533. Memo string `json:"memo,omitempty"`
  22534. UpdtTime string `json:"updt_time,omitempty"`
  22535. OpterID string `json:"opter_id,omitempty"`
  22536. OpterName string `json:"opter_name,omitempty"`
  22537. OptTime string `json:"opt_time,omitempty"`
  22538. OptinsNo string `json:"optins_no,omitempty"`
  22539. PoolareaNo string `json:"poolarea_no,omitempty"`
  22540. } `json:"result"`
  22541. } `json:"output"`
  22542. RefmsgTime string `json:"refmsg_time"`
  22543. RespondTime string `json:"respond_time"`
  22544. Signtype interface{} `json:"signtype"`
  22545. WarnInfo interface{} `json:"warn_info"`
  22546. }
  22547. // type Autogenerated struct {
  22548. // Output struct {
  22549. // Setlinfo struct {
  22550. // SetlTime string `json:"setl_time"`
  22551. // CvlservPay float64 `json:"cvlserv_pay"`
  22552. // Year string `json:"year"`
  22553. // MedType string `json:"med_type"`
  22554. // PsnPay float64 `json:"psn_pay"`
  22555. // OpterID string `json:"opter_id"`
  22556. // Begndate string `json:"begndate"`
  22557. // FlxempeFlag string `json:"flxempe_flag"`
  22558. // HifmiPay float64 `json:"hifmi_pay"`
  22559. // PsnNo string `json:"psn_no"`
  22560. // ActPayDedc float64 `json:"act_pay_dedc"`
  22561. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22562. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22563. // ClrWay string `json:"clr_way"`
  22564. // OthPay float64 `json:"oth_pay"`
  22565. // Gend string `json:"gend"`
  22566. // MdtrtID string `json:"mdtrt_id"`
  22567. // AcctPay float64 `json:"acct_pay"`
  22568. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22569. // Insutype string `json:"insutype"`
  22570. // Invono interface{} `json:"invono"`
  22571. // Enddate string `json:"enddate"`
  22572. // CashPayamt float64 `json:"cash_payamt"`
  22573. // PsnType string `json:"psn_type"`
  22574. // FixmedinsName string `json:"fixmedins_name"`
  22575. // HifpPay float64 `json:"hifp_pay"`
  22576. // NewFlag interface{} `json:"new_flag"`
  22577. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22578. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22579. // PayLoc string `json:"pay_loc"`
  22580. // ClrType string `json:"clr_type"`
  22581. // RefdSetlFlag string `json:"refd_setl_flag"`
  22582. // CvlservFlag string `json:"cvlserv_flag"`
  22583. // EmpName string `json:"emp_name"`
  22584. // Brdy string `json:"brdy"`
  22585. // Naty string `json:"naty"`
  22586. // Certno string `json:"certno"`
  22587. // DiseCode string `json:"dise_code"`
  22588. // FixmedinsCode string `json:"fixmedins_code"`
  22589. // DedcHospLv string `json:"dedc_hosp_lv"`
  22590. // OpterName string `json:"opter_name"`
  22591. // Balc float64 `json:"balc"`
  22592. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22593. // PsnCertType string `json:"psn_cert_type"`
  22594. // HifobPay float64 `json:"hifob_pay"`
  22595. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22596. // HifesPay float64 `json:"hifes_pay"`
  22597. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22598. // OptTime string `json:"opt_time"`
  22599. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22600. // SetlID string `json:"setl_id"`
  22601. // MafPay float64 `json:"maf_pay"`
  22602. // PsnName string `json:"psn_name"`
  22603. // InsuOptins interface{} `json:"insu_optins"`
  22604. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22605. // ClrOptins string `json:"clr_optins"`
  22606. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22607. // DiseName string `json:"dise_name"`
  22608. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22609. // Age float64 `json:"age"`
  22610. // DtrtCertType string `json:"dtrt_cert_type"`
  22611. // HospLv string `json:"hosp_lv"`
  22612. // } `json:"setlinfo"`
  22613. // Setldetail []struct {
  22614. // FundPayType string `json:"fund_pay_type"`
  22615. // FundPayamt float64 `json:"fund_payamt"`
  22616. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22617. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22618. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22619. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22620. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22621. // } `json:"setldetail"`
  22622. // } `json:"output"`
  22623. // Infcode int `json:"infcode"`
  22624. // WarnMsg interface{} `json:"warn_msg"`
  22625. // Cainfo interface{} `json:"cainfo"`
  22626. // ErrMsg interface{} `json:"err_msg"`
  22627. // RefmsgTime string `json:"refmsg_time"`
  22628. // Signtype interface{} `json:"signtype"`
  22629. // RespondTime string `json:"respond_time"`
  22630. // InfRefmsgid string `json:"inf_refmsgid"`
  22631. // }
  22632. type Result002 struct {
  22633. Cainfo interface{} `json:"cainfo"`
  22634. ErrMsg string `json:"err_msg"`
  22635. InfRefmsgid string `json:"inf_refmsgid"`
  22636. Infcode int64 `json:"infcode"`
  22637. Output struct {
  22638. RxFile string `json:"rx_file"`
  22639. SignDigest string `json:"sign_digest"`
  22640. SignCertSn string `json:"sign_cert_sn"`
  22641. SignCertDn string `json:"sign_cert_dn"`
  22642. } `json:"output"`
  22643. RefmsgTime string `json:"refmsg_time"`
  22644. RespondTime string `json:"respond_time"`
  22645. Signtype interface{} `json:"signtype"`
  22646. WarnMsg interface{} `json:"warn_msg"`
  22647. }
  22648. type Result003 struct {
  22649. Cainfo interface{} `json:"cainfo"`
  22650. ErrMsg string `json:"err_msg"`
  22651. InfRefmsgid string `json:"inf_refmsgid"`
  22652. Infcode int64 `json:"infcode"`
  22653. Output struct {
  22654. HiRxno string `json:"hi_rxno"`
  22655. RxStasCodg string `json:"rx_stas_codg"`
  22656. RxStasName string `json:"rx_stas_name"`
  22657. } `json:"output"`
  22658. RefmsgTime string `json:"refmsg_time"`
  22659. RespondTime string `json:"respond_time"`
  22660. Signtype interface{} `json:"signtype"`
  22661. WarnMsg interface{} `json:"warn_msg"`
  22662. }
  22663. type ResultEleven struct {
  22664. Cainfo string `json:"cainfo"`
  22665. ErrMsg string `json:"err_msg"`
  22666. InfRefmsgid string `json:"inf_refmsgid"`
  22667. Infcode int64 `json:"infcode"`
  22668. Output struct {
  22669. Setlinfo struct {
  22670. SetlTime string `json:"setl_time"`
  22671. CvlservPay float64 `json:"cvlserv_pay"`
  22672. Year string `json:"year"`
  22673. MedType string `json:"med_type"`
  22674. PsnPay float64 `json:"psn_pay"`
  22675. OpterID string `json:"opter_id"`
  22676. Begndate string `json:"begndate"`
  22677. FlxempeFlag string `json:"flxempe_flag"`
  22678. HifmiPay float64 `json:"hifmi_pay"`
  22679. PsnNo string `json:"psn_no"`
  22680. ActPayDedc float64 `json:"act_pay_dedc"`
  22681. MedinsSetlID interface{} `json:"medins_setl_id"`
  22682. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22683. ClrWay string `json:"clr_way"`
  22684. OthPay float64 `json:"oth_pay"`
  22685. Gend string `json:"gend"`
  22686. MdtrtID string `json:"mdtrt_id"`
  22687. AcctPay float64 `json:"acct_pay"`
  22688. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22689. Insutype string `json:"insutype"`
  22690. Invono interface{} `json:"invono"`
  22691. Enddate string `json:"enddate"`
  22692. CashPayamt float64 `json:"cash_payamt"`
  22693. PsnType string `json:"psn_type"`
  22694. FixmedinsName string `json:"fixmedins_name"`
  22695. HifpPay float64 `json:"hifp_pay"`
  22696. NewFlag interface{} `json:"new_flag"`
  22697. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22698. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22699. PayLoc string `json:"pay_loc"`
  22700. ClrType string `json:"clr_type"`
  22701. RefdSetlFlag string `json:"refd_setl_flag"`
  22702. CvlservFlag string `json:"cvlserv_flag"`
  22703. EmpName string `json:"emp_name"`
  22704. Brdy string `json:"brdy"`
  22705. Naty string `json:"naty"`
  22706. Certno string `json:"certno"`
  22707. DiseCode string `json:"dise_code"`
  22708. FixmedinsCode string `json:"fixmedins_code"`
  22709. DedcHospLv string `json:"dedc_hosp_lv"`
  22710. OpterName string `json:"opter_name"`
  22711. Balc float64 `json:"balc"`
  22712. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22713. PsnCertType string `json:"psn_cert_type"`
  22714. HifobPay float64 `json:"hifob_pay"`
  22715. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22716. HifesPay float64 `json:"hifes_pay"`
  22717. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22718. OptTime string `json:"opt_time"`
  22719. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22720. SetlID string `json:"setl_id"`
  22721. MafPay float64 `json:"maf_pay"`
  22722. PsnName string `json:"psn_name"`
  22723. InsuOptins interface{} `json:"insu_optins"`
  22724. PrefFundPay interface{} `json:"pref_fund_pay"`
  22725. ClrOptins string `json:"clr_optins"`
  22726. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22727. DiseName string `json:"dise_name"`
  22728. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22729. Age float64 `json:"age"`
  22730. DtrtCertType string `json:"dtrt_cert_type"`
  22731. HospLv string `json:"hosp_lv"`
  22732. PsnCashPay float64 `json:"psn_cash_pay"`
  22733. } `json:"setlinfo"`
  22734. } `json:"output"`
  22735. RefmsgTime string `json:"refmsg_time"`
  22736. RespondTime string `json:"respond_time"`
  22737. Signtype interface{} `json:"signtype"`
  22738. WarnMsg interface{} `json:"warn_msg"`
  22739. }
  22740. type ResultElevenah struct {
  22741. Cainfo string `json:"cainfo"`
  22742. ErrMsg string `json:"err_msg"`
  22743. InfRefmsgid string `json:"inf_refmsgid"`
  22744. Infcode int64 `json:"infcode"`
  22745. Output struct {
  22746. Setlinfo struct {
  22747. SetlTime int64 `json:"setl_time"`
  22748. CvlservPay float64 `json:"cvlserv_pay"`
  22749. Year string `json:"year"`
  22750. MedType string `json:"med_type"`
  22751. PsnPay float64 `json:"psn_pay"`
  22752. OpterID string `json:"opter_id"`
  22753. Begndate int64 `json:"begndate"`
  22754. FlxempeFlag string `json:"flxempe_flag"`
  22755. HifmiPay float64 `json:"hifmi_pay"`
  22756. PsnNo string `json:"psn_no"`
  22757. ActPayDedc float64 `json:"act_pay_dedc"`
  22758. MedinsSetlID interface{} `json:"medins_setl_id"`
  22759. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22760. ClrWay string `json:"clr_way"`
  22761. OthPay float64 `json:"oth_pay"`
  22762. Gend string `json:"gend"`
  22763. MdtrtID string `json:"mdtrt_id"`
  22764. AcctPay float64 `json:"acct_pay"`
  22765. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22766. Insutype string `json:"insutype"`
  22767. Invono interface{} `json:"invono"`
  22768. Enddate int64 `json:"enddate"`
  22769. CashPayamt float64 `json:"cash_payamt"`
  22770. PsnType string `json:"psn_type"`
  22771. FixmedinsName string `json:"fixmedins_name"`
  22772. HifpPay float64 `json:"hifp_pay"`
  22773. NewFlag interface{} `json:"new_flag"`
  22774. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22775. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22776. PayLoc string `json:"pay_loc"`
  22777. ClrType string `json:"clr_type"`
  22778. RefdSetlFlag string `json:"refd_setl_flag"`
  22779. CvlservFlag string `json:"cvlserv_flag"`
  22780. EmpName string `json:"emp_name"`
  22781. Brdy int64 `json:"brdy"`
  22782. Naty string `json:"naty"`
  22783. Certno string `json:"certno"`
  22784. DiseCode string `json:"dise_code"`
  22785. FixmedinsCode string `json:"fixmedins_code"`
  22786. DedcHospLv string `json:"dedc_hosp_lv"`
  22787. OpterName string `json:"opter_name"`
  22788. Balc float64 `json:"balc"`
  22789. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22790. PsnCertType string `json:"psn_cert_type"`
  22791. HifobPay float64 `json:"hifob_pay"`
  22792. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22793. HifesPay float64 `json:"hifes_pay"`
  22794. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22795. OptTime int64 `json:"opt_time"`
  22796. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22797. SetlID string `json:"setl_id"`
  22798. MafPay float64 `json:"maf_pay"`
  22799. PsnName string `json:"psn_name"`
  22800. InsuOptins interface{} `json:"insu_optins"`
  22801. PrefFundPay interface{} `json:"pref_fund_pay"`
  22802. ClrOptins string `json:"clr_optins"`
  22803. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22804. DiseName string `json:"dise_name"`
  22805. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22806. Age float64 `json:"age"`
  22807. DtrtCertType string `json:"dtrt_cert_type"`
  22808. HospLv string `json:"hosp_lv"`
  22809. PsnCashPay float64 `json:"psn_cash_pay"`
  22810. } `json:"setlinfo"`
  22811. } `json:"output"`
  22812. RefmsgTime string `json:"refmsg_time"`
  22813. RespondTime string `json:"respond_time"`
  22814. Signtype interface{} `json:"signtype"`
  22815. WarnMsg interface{} `json:"warn_msg"`
  22816. }
  22817. type ResultEleven10265 struct {
  22818. Cainfo string `json:"cainfo"`
  22819. ErrMsg string `json:"err_msg"`
  22820. InfRefmsgid string `json:"inf_refmsgid"`
  22821. Infcode string `json:"infcode"`
  22822. Output struct {
  22823. Setlinfo struct {
  22824. SetlTime string `json:"setl_time"`
  22825. CvlservPay float64 `json:"cvlserv_pay"`
  22826. Year string `json:"year"`
  22827. MedType string `json:"med_type"`
  22828. PsnPay float64 `json:"psn_pay"`
  22829. OpterID string `json:"opter_id"`
  22830. Begndate string `json:"begndate"`
  22831. FlxempeFlag string `json:"flxempe_flag"`
  22832. HifmiPay float64 `json:"hifmi_pay"`
  22833. PsnNo string `json:"psn_no"`
  22834. ActPayDedc float64 `json:"act_pay_dedc"`
  22835. MedinsSetlID interface{} `json:"medins_setl_id"`
  22836. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22837. ClrWay string `json:"clr_way"`
  22838. OthPay float64 `json:"oth_pay"`
  22839. Gend string `json:"gend"`
  22840. MdtrtID string `json:"mdtrt_id"`
  22841. AcctPay float64 `json:"acct_pay"`
  22842. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22843. Insutype string `json:"insutype"`
  22844. Invono interface{} `json:"invono"`
  22845. Enddate string `json:"enddate"`
  22846. CashPayamt float64 `json:"cash_payamt"`
  22847. PsnType string `json:"psn_type"`
  22848. FixmedinsName string `json:"fixmedins_name"`
  22849. HifpPay float64 `json:"hifp_pay"`
  22850. NewFlag interface{} `json:"new_flag"`
  22851. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22852. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22853. PayLoc string `json:"pay_loc"`
  22854. ClrType string `json:"clr_type"`
  22855. RefdSetlFlag string `json:"refd_setl_flag"`
  22856. CvlservFlag string `json:"cvlserv_flag"`
  22857. EmpName string `json:"emp_name"`
  22858. Brdy string `json:"brdy"`
  22859. Naty string `json:"naty"`
  22860. Certno string `json:"certno"`
  22861. DiseCode string `json:"dise_code"`
  22862. FixmedinsCode string `json:"fixmedins_code"`
  22863. DedcHospLv string `json:"dedc_hosp_lv"`
  22864. OpterName string `json:"opter_name"`
  22865. Balc float64 `json:"balc"`
  22866. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22867. PsnCertType string `json:"psn_cert_type"`
  22868. HifobPay float64 `json:"hifob_pay"`
  22869. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22870. HifesPay float64 `json:"hifes_pay"`
  22871. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22872. OptTime string `json:"opt_time"`
  22873. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22874. SetlID string `json:"setl_id"`
  22875. MafPay float64 `json:"maf_pay"`
  22876. PsnName string `json:"psn_name"`
  22877. InsuOptins interface{} `json:"insu_optins"`
  22878. PrefFundPay interface{} `json:"pref_fund_pay"`
  22879. ClrOptins string `json:"clr_optins"`
  22880. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22881. DiseName string `json:"dise_name"`
  22882. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22883. Age float64 `json:"age"`
  22884. DtrtCertType string `json:"dtrt_cert_type"`
  22885. HospLv string `json:"hosp_lv"`
  22886. PsnCashPay float64 `json:"psn_cash_pay"`
  22887. } `json:"setlinfo"`
  22888. } `json:"output"`
  22889. RefmsgTime string `json:"refmsg_time"`
  22890. RespondTime string `json:"respond_time"`
  22891. Signtype interface{} `json:"signtype"`
  22892. WarnMsg interface{} `json:"warn_msg"`
  22893. }
  22894. type ResultTwelve struct {
  22895. Cainfo string `json:"cainfo"`
  22896. ErrMsg string `json:"err_msg"`
  22897. InfRefmsgid string `json:"inf_refmsgid"`
  22898. Infcode int64 `json:"infcode"`
  22899. Output struct {
  22900. MdtrtId string `json:"mdtrt_id"`
  22901. ChrgBchno string `json:"chrg_bchno"`
  22902. PsnNo string `json:"psn_no"`
  22903. } `json:"output"`
  22904. RefmsgTime string `json:"refmsg_time"`
  22905. RespondTime string `json:"respond_time"`
  22906. Signtype interface{} `json:"signtype"`
  22907. WarnMsg interface{} `json:"warn_msg"`
  22908. }
  22909. type ResultThirteen struct {
  22910. ErrMsg string `json:"err_msg"`
  22911. InfRefmsgid string `json:"inf_refmsgid"`
  22912. Infcode int64 `json:"infcode"`
  22913. Output struct {
  22914. Result struct {
  22915. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22916. } `json:"result"`
  22917. } `json:"output"`
  22918. RefmsgTime string `json:"refmsg_time"`
  22919. RespondTime string `json:"respond_time"`
  22920. Signtype interface{} `json:"signtype"`
  22921. WarnInfo interface{} `json:"warn_info"`
  22922. }
  22923. type ResultThirteen10265 struct {
  22924. ErrMsg string `json:"err_msg"`
  22925. InfRefmsgid string `json:"inf_refmsgid"`
  22926. Infcode string `json:"infcode"`
  22927. Output struct {
  22928. Result struct {
  22929. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22930. } `json:"result"`
  22931. } `json:"output"`
  22932. RefmsgTime string `json:"refmsg_time"`
  22933. RespondTime string `json:"respond_time"`
  22934. Signtype interface{} `json:"signtype"`
  22935. WarnInfo interface{} `json:"warn_info"`
  22936. }
  22937. type ResultFourteen struct {
  22938. ErrMsg string `json:"err_msg"`
  22939. InfRefmsgid string `json:"inf_refmsgid"`
  22940. Infcode int64 `json:"infcode"`
  22941. Output struct {
  22942. } `json:"output"`
  22943. RefmsgTime string `json:"refmsg_time"`
  22944. RespondTime string `json:"respond_time"`
  22945. Signtype interface{} `json:"signtype"`
  22946. WarnInfo interface{} `json:"warn_info"`
  22947. }
  22948. type ResultCFYLJG001 struct {
  22949. ErrMsg string `json:"err_msg"`
  22950. InfRefmsgid string `json:"inf_refmsgid"`
  22951. Infcode int64 `json:"infcode"`
  22952. Output struct {
  22953. RxTraceCode string `json:"rx_trace_code"`
  22954. HiRxno string `json:"hi_rxno"`
  22955. } `json:"output"`
  22956. RefmsgTime string `json:"refmsg_time"`
  22957. RespondTime string `json:"respond_time"`
  22958. Signtype interface{} `json:"signtype"`
  22959. WarnInfo interface{} `json:"warn_info"`
  22960. }
  22961. type ResultCFYLJG007 struct {
  22962. ErrMsg string `json:"err_msg"`
  22963. InfRefmsgid string `json:"inf_refmsgid"`
  22964. Infcode int64 `json:"infcode"`
  22965. Output struct {
  22966. HiRxno string `json:"hi_rxno"`
  22967. RxStasName string `json:"rx_stas_name"`
  22968. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22969. Seltdelts []interface{} `json:"seltdelts"`
  22970. RxUsedStasName string `json:"rx_used_stas_name"`
  22971. RxStasCodg string `json:"rx_stas_codg"`
  22972. } `json:"output"`
  22973. RefmsgTime string `json:"refmsg_time"`
  22974. RespondTime string `json:"respond_time"`
  22975. Signtype interface{} `json:"signtype"`
  22976. WarnInfo interface{} `json:"warn_info"`
  22977. }
  22978. type ResultCFYLJG002 struct {
  22979. ErrMsg string `json:"err_msg"`
  22980. InfRefmsgid string `json:"inf_refmsgid"`
  22981. Infcode int64 `json:"infcode"`
  22982. Output struct {
  22983. RxFile string `json:"rx_file"`
  22984. SignDigest string `json:"sign_digest"`
  22985. SignCertSn string `json:"sign_cert_sn"`
  22986. SignCertDn string `json:"sign_cert_dn"`
  22987. } `json:"output"`
  22988. RefmsgTime string `json:"refmsg_time"`
  22989. RespondTime string `json:"respond_time"`
  22990. Signtype interface{} `json:"signtype"`
  22991. WarnInfo interface{} `json:"warn_info"`
  22992. }
  22993. type ResultCFYLJG003 struct {
  22994. ErrMsg string `json:"err_msg"`
  22995. InfRefmsgid string `json:"inf_refmsgid"`
  22996. Infcode int64 `json:"infcode"`
  22997. Output struct {
  22998. HiRxno string `json:"hi_rxno"`
  22999. RxStasCodg string `json:"rx_stas_codg"`
  23000. RxStasName string `json:"rx_stas_name"`
  23001. } `json:"output"`
  23002. RefmsgTime string `json:"refmsg_time"`
  23003. RespondTime string `json:"respond_time"`
  23004. Signtype interface{} `json:"signtype"`
  23005. WarnInfo interface{} `json:"warn_info"`
  23006. }
  23007. type ResultCFYLJG004 struct {
  23008. ErrMsg string `json:"err_msg"`
  23009. InfRefmsgid string `json:"inf_refmsgid"`
  23010. Infcode int64 `json:"infcode"`
  23011. Output struct {
  23012. HiRxno string `json:"hi_rxno"`
  23013. RxStasCodg string `json:"rx_stas_codg"`
  23014. RxStasName string `json:"rx_stas_name"`
  23015. } `json:"output"`
  23016. RefmsgTime string `json:"refmsg_time"`
  23017. RespondTime string `json:"respond_time"`
  23018. Signtype interface{} `json:"signtype"`
  23019. WarnInfo interface{} `json:"warn_info"`
  23020. }
  23021. type ResultCFYLJG008 struct {
  23022. ErrMsg string `json:"err_msg"`
  23023. InfRefmsgid string `json:"inf_refmsgid"`
  23024. Infcode int64 `json:"infcode"`
  23025. Output struct {
  23026. PoolareaNo string `json:"poolareaNo"`
  23027. AdmdvsName string `json:"admdvsName"`
  23028. Count string `json:"count"`
  23029. } `json:"output"`
  23030. RefmsgTime string `json:"refmsg_time"`
  23031. RespondTime string `json:"respond_time"`
  23032. Signtype interface{} `json:"signtype"`
  23033. WarnInfo interface{} `json:"warn_info"`
  23034. }
  23035. type ResultCFYLJG005 struct {
  23036. ErrMsg string `json:"err_msg"`
  23037. InfRefmsgid string `json:"inf_refmsgid"`
  23038. Infcode int64 `json:"infcode"`
  23039. Output struct {
  23040. HiRxNo string `json:"hi_rxno"`
  23041. FixMedinsCode string `json:"fixmedins_code"`
  23042. FixMedinsName string `json:"fixmedins_name"`
  23043. RxStasCodg string `json:"rx_stas_codg"`
  23044. RxStasName string `json:"rx_stas_name"`
  23045. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  23046. RxUserdStasName string `json:"rx_userd_stas_name"`
  23047. PrscTime string `json:"prsc_time"`
  23048. RxDrugCnt float64 `json:"rx_drug_cnt"`
  23049. RxUsedWayCodg string `json:"rx_used_way_codg"`
  23050. RxUsedWayName string `json:"rx_used_way_name"`
  23051. RxFrquCodg string `json:"rx_frqu_codg"`
  23052. RxFrquName string `json:"rx_frqu_name"`
  23053. RxDosunt string `json:"rx_dosunt"`
  23054. RxDoscnt float64 `json:"rx_doscnt"`
  23055. RxDrordDscr string `json:"rx_drord_dscr"`
  23056. ValiDays int64 `json:"vali_days"`
  23057. ValiEndTime string `json:"vali_end_time"`
  23058. ReptFlag string `json:"rept_flag"`
  23059. MaxReptCnt int64 `json:"max_rept_cnt"`
  23060. ReptdCnt int64 `json:"reptd_cnt"`
  23061. MinInrvDays int64 `json:"min_inrv_days"`
  23062. RxTypeCode string `json:"rx_type_code"`
  23063. RxTypeName string `json:"rx_type_name"`
  23064. LongRxFlag string `json:"long_rx_flag"`
  23065. RxDetlList []struct {
  23066. MedListCodg string `json:"med_list_codg"`
  23067. MedinsListCodg string `json:"medins_list_codg"`
  23068. HospPrepFlag string `json:"hosp_prep_flag"`
  23069. RxItemTypeCode string `json:"rx_item_type_code"`
  23070. RxItemTypeName string `json:"rx_item_type_name"`
  23071. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  23072. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  23073. TcmHerbFoote string `json:"tcmherb_foote"`
  23074. MednTypeCode string `json:"medn_type_code"`
  23075. MednTypeName string `json:"medn_type_name"`
  23076. MainMedcFlag string `json:"main_medc_flag"`
  23077. UrgtFlag string `json:"urgt_flag"`
  23078. BasMednFlag string `json:"bas_medn_flag"`
  23079. ImpDrugFlag string `json:"imp_drug_flag"`
  23080. ProdBarc string `json:"prod_barc"`
  23081. DrugProdname string `json:"drug_prodname"`
  23082. GennameCodg string `json:"genname_codg"`
  23083. DrugGenname string `json:"drug_genname"`
  23084. DrugDosform string `json:"drug_dosform"`
  23085. DrugSpec string `json:"drug_spec"`
  23086. PrdrName string `json:"prdr_name"`
  23087. MedcWayCodg string `json:"medc_way_codg"`
  23088. MedcWayDscr string `json:"medc_way_dscr"`
  23089. MedcBegntime string `json:"medc_begntime"`
  23090. MedcEndtime string `json:"medc_endtime"`
  23091. MedcDays float64 `json:"medc_days"`
  23092. DrugPric float64 `json:"drug_pric"`
  23093. DrugSumamt float64 `json:"drug_sumamt"`
  23094. DrugCnt float64 `json:"drug_cnt"`
  23095. DrugDosunt string `json:"drug_dosunt"`
  23096. SinDoscnt float64 `json:"sin_doscnt"`
  23097. SinDosunt string `json:"sin_dosunt"`
  23098. UsedFrquCodg string `json:"used_frqu_codg"`
  23099. UsedFrquName string `json:"used_frqu_name"`
  23100. DrugTotlcnt string `json:"drug_totlcnt"`
  23101. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  23102. DiseCodg string `json:"dise_codg"`
  23103. HospApprFlag string `json:"hosp_appr_flag"`
  23104. } `json:"rx_detl_list"`
  23105. RxOtpinfo struct {
  23106. MedType string `json:"med_type"`
  23107. IptOtpNo string `json:"ipt_otp_no"`
  23108. OtpIptFlag string `json:"otp_ipt_flag"`
  23109. PatnName string `json:"patn_name"`
  23110. PatnAge float64 `json:"patn_age"`
  23111. PatnHgt float64 `json:"patn_hgt"`
  23112. PatnWt float64 `json:"patn_wt"`
  23113. Gend string `json:"gend"`
  23114. GesoVal float64 `json:"geso_val"`
  23115. NwbFlag string `json:"nwb_flag"`
  23116. NwbAge string `json:"nwb_age"`
  23117. SuckPrdFlag string `json:"suck_prd_flag"`
  23118. AlgsHis string `json:"algs_his"`
  23119. Insutype string `json:"insutype"`
  23120. PrscDeptName string `json:"prsc_dept_name"`
  23121. PrscDrName string `json:"prsc_dr_name"`
  23122. PharName string `json:"phar_name"`
  23123. PharChkTime string `json:"phar_chk_time"`
  23124. MdtrtTime string `json:"mdtrt_time"`
  23125. DiseCodg string `json:"dise_codg"`
  23126. DiseName string `json:"dise_name"`
  23127. SpDiseFlag string `json:"sp_dise_flag"`
  23128. MaindiagCode string `json:"maindiag_code"`
  23129. MaindiagName string `json:"maindiag_name"`
  23130. DiseCondDscr string `json:"dise_cond_dscr"`
  23131. FstdiagFlag string `json:"fstdiag_flag"`
  23132. } `json:"rx_otpinfo"`
  23133. RxDiseList []struct {
  23134. DiagType string `json:"diag_type"`
  23135. MaindiagFlag string `json:"maindiag_flag"`
  23136. DiagSrtNo string `json:"diag_srt_no"`
  23137. DiagCode string `json:"diag_code"`
  23138. DiagName string `json:"diag_name"`
  23139. DiagDept string `json:"diag_dept"`
  23140. DiagDrNo string `json:"diag_dr_no"`
  23141. DiagDrName string `json:"diag_dr_name"`
  23142. DiagTime string `json:"diag_time"`
  23143. TcmDiseCode string `json:"tcm_dise_code"`
  23144. TcmDiseName string `json:"tcm_dise_name"`
  23145. TcmSympCode string `json:"tcmsymp_code"`
  23146. TcmSymp string `json:"tcmsymp"`
  23147. } `json:"rx_dise_list"`
  23148. } `json:"output"`
  23149. RefmsgTime string `json:"refmsg_time"`
  23150. RespondTime string `json:"respond_time"`
  23151. Signtype interface{} `json:"signtype"`
  23152. WarnInfo interface{} `json:"warn_info"`
  23153. }
  23154. type ResultCFYLJG006 struct {
  23155. ErrMsg string `json:"err_msg"`
  23156. InfRefmsgid string `json:"inf_refmsgid"`
  23157. Infcode int64 `json:"infcode"`
  23158. Output struct {
  23159. HiRxNo string `json:"hi_rxno"`
  23160. PharCode string `json:"phar_code"`
  23161. PharName string `json:"phar_name"`
  23162. RxChkOpnn string `json:"rx_chk_opnn"`
  23163. RxChkTime string `json:"rx_chk_time"`
  23164. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  23165. RxChkStasName string `json:"rx_chk_stas_name"`
  23166. RxStasCodg string `json:"rx_stas_codg"`
  23167. RxStasName string `json:"rx_stas_name"`
  23168. } `json:"output"`
  23169. RefmsgTime string `json:"refmsg_time"`
  23170. RespondTime string `json:"respond_time"`
  23171. Signtype interface{} `json:"signtype"`
  23172. WarnInfo interface{} `json:"warn_info"`
  23173. }
  23174. type ResultFourteen10265 struct {
  23175. ErrMsg string `json:"err_msg"`
  23176. InfRefmsgid string `json:"inf_refmsgid"`
  23177. Infcode string `json:"infcode"`
  23178. Output struct {
  23179. } `json:"output"`
  23180. RefmsgTime string `json:"refmsg_time"`
  23181. RespondTime string `json:"respond_time"`
  23182. Signtype interface{} `json:"signtype"`
  23183. WarnInfo interface{} `json:"warn_info"`
  23184. }
  23185. type ResultSixteen struct {
  23186. Cainfo string `json:"cainfo"`
  23187. ErrMsg string `json:"err_msg"`
  23188. InfRefmsgid string `json:"inf_refmsgid"`
  23189. Infcode int64 `json:"infcode"`
  23190. Output struct {
  23191. Setlinfo struct {
  23192. MdtrtID string `json:"mdtrt_id"`
  23193. SetlID string `json:"setl_id"`
  23194. ClrOptins string `json:"clr_optins"`
  23195. SetlTime string `json:"setl_time"`
  23196. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23197. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23198. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23199. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23200. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23201. ActPayDedc float64 `json:"act_pay_dedc"`
  23202. HifpPay float64 `json:"hifp_pay"`
  23203. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23204. Lfpay float64 `json:"selfpay"`
  23205. CvlservPay float64 `json:"cvlserv_pay"`
  23206. HifesPay float64 `json:"hifes_pay"`
  23207. HifmiPay float64 `json:"hifmi_pay"`
  23208. HifobPay float64 `json:"hifob_pay"`
  23209. MafPay float64 `json:"maf_pay"`
  23210. OthPay float64 `json:"oth_pay"`
  23211. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23212. PsnPartAmt float64 `json:"psn_part_amt"`
  23213. AcctPay float64 `json:"acct_pay"`
  23214. Balc float64 `json:"balc"`
  23215. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23216. HospPartAmt float64 `json:"hosp_part_amt"`
  23217. MedinsSetlID string `json:"medins_setl_id"`
  23218. PdnCashPay string `json:"pdn_cash_pay"`
  23219. } `json:"setlinfo"`
  23220. } `json:"output"`
  23221. RefmsgTime string `json:"refmsg_time"`
  23222. RespondTime string `json:"respond_time"`
  23223. Signtype interface{} `json:"signtype"`
  23224. WarnMsg interface{} `json:"warn_msg"`
  23225. }
  23226. type ResultSixteen10265 struct {
  23227. Cainfo string `json:"cainfo"`
  23228. ErrMsg string `json:"err_msg"`
  23229. InfRefmsgid string `json:"inf_refmsgid"`
  23230. Infcode string `json:"infcode"`
  23231. Output struct {
  23232. Setlinfo struct {
  23233. MdtrtID string `json:"mdtrt_id"`
  23234. SetlID string `json:"setl_id"`
  23235. ClrOptins string `json:"clr_optins"`
  23236. SetlTime string `json:"setl_time"`
  23237. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23238. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23239. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23240. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23241. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23242. ActPayDedc float64 `json:"act_pay_dedc"`
  23243. HifpPay float64 `json:"hifp_pay"`
  23244. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23245. Lfpay float64 `json:"selfpay"`
  23246. CvlservPay float64 `json:"cvlserv_pay"`
  23247. HifesPay float64 `json:"hifes_pay"`
  23248. HifmiPay float64 `json:"hifmi_pay"`
  23249. HifobPay float64 `json:"hifob_pay"`
  23250. MafPay float64 `json:"maf_pay"`
  23251. OthPay float64 `json:"oth_pay"`
  23252. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23253. PsnPartAmt float64 `json:"psn_part_amt"`
  23254. AcctPay float64 `json:"acct_pay"`
  23255. Balc float64 `json:"balc"`
  23256. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23257. HospPartAmt float64 `json:"hosp_part_amt"`
  23258. MedinsSetlID string `json:"medins_setl_id"`
  23259. PdnCashPay string `json:"pdn_cash_pay"`
  23260. } `json:"setlinfo"`
  23261. } `json:"output"`
  23262. RefmsgTime string `json:"refmsg_time"`
  23263. RespondTime string `json:"respond_time"`
  23264. Signtype interface{} `json:"signtype"`
  23265. WarnMsg interface{} `json:"warn_msg"`
  23266. }
  23267. type ResultSixteen10265Two struct {
  23268. Cainfo string `json:"cainfo"`
  23269. ErrMsg string `json:"err_msg"`
  23270. InfRefmsgid string `json:"inf_refmsgid"`
  23271. Infcode string `json:"infcode"`
  23272. Output struct {
  23273. Setlinfo interface{} `json:"setlinfo"`
  23274. } `json:"output"`
  23275. RefmsgTime string `json:"refmsg_time"`
  23276. RespondTime string `json:"respond_time"`
  23277. Signtype interface{} `json:"signtype"`
  23278. WarnMsg interface{} `json:"warn_msg"`
  23279. }
  23280. type ResultgzSixteen10265Two struct {
  23281. Cainfo string `json:"cainfo"`
  23282. ErrMsg string `json:"err_msg"`
  23283. InfRefmsgid string `json:"inf_refmsgid"`
  23284. Infcode int64 `json:"infcode"`
  23285. Output struct {
  23286. Setlinfo interface{} `json:"setlinfo"`
  23287. } `json:"output"`
  23288. RefmsgTime string `json:"refmsg_time"`
  23289. RespondTime string `json:"respond_time"`
  23290. Signtype interface{} `json:"signtype"`
  23291. WarnMsg interface{} `json:"warn_msg"`
  23292. }
  23293. type ResultSeventeen struct {
  23294. ErrMsg string `json:"err_msg"`
  23295. InfRefmsgid string `json:"inf_refmsgid"`
  23296. Infcode int64 `json:"infcode"`
  23297. Output struct {
  23298. SetlListId string `json:"setl_list_id"`
  23299. } `json:"output"`
  23300. RefmsgTime string `json:"refmsg_time"`
  23301. RespondTime string `json:"respond_time"`
  23302. Signtype string `json:"signtype"`
  23303. WarnInfo string `json:"warn_info"`
  23304. }
  23305. type ResultSeventeenOther struct {
  23306. ErrMsg string `json:"err_msg"`
  23307. InfRefmsgid string `json:"inf_refmsgid"`
  23308. Infcode string `json:"infcode"`
  23309. Output struct {
  23310. SetlListId string `json:"setl_list_id"`
  23311. } `json:"output"`
  23312. RefmsgTime string `json:"refmsg_time"`
  23313. RespondTime string `json:"respond_time"`
  23314. Signtype string `json:"signtype"`
  23315. WarnInfo string `json:"warn_info"`
  23316. }
  23317. type Result90991 struct {
  23318. ErrMsg string `json:"err_msg"`
  23319. InfRefmsgid string `json:"inf_refmsgid"`
  23320. Infcode int64 `json:"infcode"`
  23321. Output struct {
  23322. Result struct {
  23323. PsnNo string `json:"psn_no"`
  23324. CardStat string `json:"card_stat"`
  23325. Certno string `json:"certno"`
  23326. PsnName string `json:"psn_name"`
  23327. CheckStat string `json:"check_stat"`
  23328. SscnoCheckStat string `json:"sscno_check_stat"`
  23329. } `json:"result"`
  23330. } `json:"output"`
  23331. RefmsgTime string `json:"refmsg_time"`
  23332. RespondTime string `json:"respond_time"`
  23333. Signtype interface{} `json:"signtype"`
  23334. WarnInfo interface{} `json:"warn_info"`
  23335. }
  23336. type Result90100 struct {
  23337. ErrMsg string `json:"err_msg"`
  23338. InfRefmsgid string `json:"inf_refmsgid"`
  23339. Infcode int64 `json:"infcode"`
  23340. Output struct {
  23341. PoolareaNo string `json:"poolarea_no"`
  23342. PoolareaNoName string `json:"poolarea_no_name"`
  23343. Insutype string `json:"insutype"`
  23344. InsutypeName string `json:"insutype_name"`
  23345. ClctType string `json:"clct_type"`
  23346. ClctTypeName string `json:"clct_type_name"`
  23347. ClctFlag string `json:"clct_flag"`
  23348. ClctFlagName string `json:"clct_flag_name"`
  23349. AccrymBegn string `json:"accrym_begn"`
  23350. AccrymEnd string `json:"accrym_end"`
  23351. ClctTime string `json:"clct_time"`
  23352. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23353. } `json:"output"`
  23354. RefmsgTime string `json:"refmsg_time"`
  23355. RespondTime string `json:"respond_time"`
  23356. Signtype interface{} `json:"signtype"`
  23357. WarnInfo interface{} `json:"warn_info"`
  23358. }
  23359. type Custom struct {
  23360. DetItemFeeSumamt string
  23361. Cut string
  23362. FeedetlSn string
  23363. Price string
  23364. MedListCodg string
  23365. Type int64
  23366. AdviceId int64
  23367. ProjectId int64
  23368. ItemId int64
  23369. }
  23370. type Result5301 struct {
  23371. ErrMsg string `json:"err_msg"`
  23372. InfRefmsgid string `json:"inf_refmsgid"`
  23373. Infcode int64 `json:"infcode"`
  23374. Output struct {
  23375. Result []struct {
  23376. OpspDiseCode string `json:"opsp_dise_code"`
  23377. OpspDiseName string `json:"opsp_dise_name"`
  23378. Begndate string `json:"begndate"`
  23379. Enddate string `json:"enddate"`
  23380. } `json:"feedetail"`
  23381. } `json:"output"`
  23382. RefmsgTime string `json:"refmsg_time"`
  23383. RespondTime string `json:"respond_time"`
  23384. Signtype interface{} `json:"signtype"`
  23385. WarnInfo interface{} `json:"warn_info"`
  23386. }
  23387. type Result5301For10265 struct {
  23388. ErrMsg string `json:"err_msg"`
  23389. InfRefmsgid string `json:"inf_refmsgid"`
  23390. Infcode string `json:"infcode"`
  23391. Output struct {
  23392. Result []struct {
  23393. OpspDiseCode string `json:"opsp_dise_code"`
  23394. OpspDiseName string `json:"opsp_dise_name"`
  23395. Begndate string `json:"begndate"`
  23396. Enddate string `json:"enddate"`
  23397. } `json:"feedetail"`
  23398. } `json:"output"`
  23399. RefmsgTime string `json:"refmsg_time"`
  23400. RespondTime string `json:"respond_time"`
  23401. Signtype interface{} `json:"signtype"`
  23402. WarnInfo interface{} `json:"warn_info"`
  23403. }
  23404. //获取个人信息----挂号-----上传就诊信息
  23405. func (c *HisApiController) GetRegisterInfo() {
  23406. id, _ := c.GetInt64("id")
  23407. record_time := c.GetString("record_time")
  23408. settlementValue, _ := c.GetInt64("settlement_value")
  23409. medical_insurance_card := c.GetString("medical_insurance_card")
  23410. name := c.GetString("name")
  23411. id_card_type, _ := c.GetInt64("id_card_type")
  23412. certificates, _ := c.GetInt64("certificates")
  23413. medical_care, _ := c.GetInt64("medical_care")
  23414. birthday := c.GetString("birthday")
  23415. id_card := c.GetString("id_card")
  23416. register_type, _ := c.GetInt64("register")
  23417. doctor, _ := c.GetInt64("doctor")
  23418. department, _ := c.GetInt64("department")
  23419. gender, _ := c.GetInt64("sex")
  23420. registration_fee, _ := c.GetFloat("registration_fee")
  23421. medical_expenses, _ := c.GetFloat("medical_expenses")
  23422. social_type, _ := c.GetInt64("social_type")
  23423. admin_user_id, _ := c.GetInt64("admin_user_id")
  23424. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23425. mdtrt_type := c.GetString("mdtrt_type")
  23426. if id_card_type == 5 {
  23427. id_card_type = 4
  23428. }
  23429. timeLayout := "2006-01-02"
  23430. loc, _ := time.LoadLocation("Local")
  23431. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23432. birthUnix := birthdays.Unix()
  23433. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23434. if err != nil {
  23435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23436. return
  23437. }
  23438. recordDateTime := theTime.Unix()
  23439. adminInfo := c.GetAdminUserInfo()
  23440. var patient service.Patients
  23441. if id == 0 {
  23442. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23443. } else {
  23444. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23445. }
  23446. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23447. if patientPrescription.ID == 0 {
  23448. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23449. }
  23450. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23451. if patient.ID == 0 {
  23452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23453. return
  23454. }
  23455. if len(patient.IdCardNo) == 0 {
  23456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23457. return
  23458. }
  23459. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23460. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23461. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23462. //就诊结算未完成,不能进行二次挂号
  23463. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23464. if len(his) >= 1 {
  23465. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23466. if len(his) >= 1 && order.ID == 0 {
  23467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23468. return
  23469. }
  23470. }
  23471. //var register_log string
  23472. if config.IsOpen == 1 {
  23473. var res ResultTwo
  23474. var res10265 ResultTwo10265
  23475. var PsnNo string
  23476. var PsnCertType string
  23477. var Certno string
  23478. var PsnName string
  23479. var Gend string
  23480. var Naty string
  23481. var Brdy string
  23482. var Age float64
  23483. var infoStr string
  23484. var idetinfoStr string
  23485. var infocode int64
  23486. var verify_number string
  23487. fmt.Println(verify_number)
  23488. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23489. psn_info, _ := service.GetPsnByPatientId(id)
  23490. PsnNo = psn_info.PsnNo
  23491. PsnCertType = psn_info.PsnCertType
  23492. Certno = psn_info.Certno
  23493. PsnName = psn_info.PsnName
  23494. Gend = psn_info.Gend
  23495. Naty = psn_info.Naty
  23496. Brdy = psn_info.Brdy
  23497. Age = psn_info.Age
  23498. infoStr = psn_info.Insuinfo
  23499. idetinfoStr = psn_info.Idetinfo
  23500. infocode = 0
  23501. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23502. psn_info, _ := service.GetPsnByPatientId(id)
  23503. PsnNo = psn_info.PsnNo
  23504. PsnCertType = psn_info.PsnCertType
  23505. Certno = psn_info.Certno
  23506. PsnName = psn_info.PsnName
  23507. Gend = psn_info.Gend
  23508. Naty = psn_info.Naty
  23509. Brdy = psn_info.Brdy
  23510. Age = psn_info.Age
  23511. infoStr = psn_info.Insuinfo
  23512. idetinfoStr = psn_info.Idetinfo
  23513. infocode = 0
  23514. verify_number = psn_info.VerifyNumber
  23515. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23516. if id_card_type == 2 {
  23517. //请求内网数据
  23518. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23519. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23520. "&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
  23521. resp, requestErr := http.Get(api)
  23522. if requestErr != nil {
  23523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23524. return
  23525. }
  23526. body, ioErr := ioutil.ReadAll(resp.Body)
  23527. if ioErr != nil {
  23528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23530. return
  23531. }
  23532. var respJSON map[string]interface{}
  23533. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23536. return
  23537. }
  23538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23539. result_byte, _ := json.Marshal(respJSON)
  23540. result := string(result_byte)
  23541. var dat map[string]interface{}
  23542. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23543. fmt.Println(dat)
  23544. } else {
  23545. fmt.Println(err)
  23546. }
  23547. userJSONBytes, _ := json.Marshal(dat)
  23548. var res ResultTwo
  23549. var resTwo10265 ResultTwo10265
  23550. if miConfig.Code == "H15049901371" {
  23551. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23552. utils.ErrorLog("解析失败:%v", err)
  23553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23554. return
  23555. }
  23556. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23557. res.Infcode = Infcode
  23558. res.ErrMsg = resTwo10265.ErrMsg
  23559. res.Output = resTwo10265.Output
  23560. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23561. res.RespondTime = resTwo10265.RespondTime
  23562. res.WarnInfo = resTwo10265.WarnInfo
  23563. } else {
  23564. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23565. utils.ErrorLog("解析失败:%v", err)
  23566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23567. return
  23568. }
  23569. }
  23570. //var insutypes []string
  23571. //var insutype string
  23572. //var is390 int = 0
  23573. //var is310 int = 0
  23574. //for _, item := range res.Output.Iinfo {
  23575. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23576. // insutypes = append(insutypes, item.Insutype)
  23577. // }
  23578. //}
  23579. //if len(insutypes) == 1 {
  23580. // insutype = insutypes[0]
  23581. //} else {
  23582. // for _, i := range insutypes {
  23583. // if i == "390" {
  23584. // is390 = 1
  23585. // }
  23586. //
  23587. // if i == "310" {
  23588. // is310 = 1
  23589. // }
  23590. // }
  23591. //}
  23592. //if is390 == 1 {
  23593. // insutype = "390"
  23594. //}
  23595. //if is310 == 1 {
  23596. // insutype = "310"
  23597. //}
  23598. //if len(insutypes) == 0 {
  23599. // insutype = "310"
  23600. //}
  23601. PsnNo = res.Output.Baseinfo.PsnNo
  23602. PsnCertType = res.Output.Baseinfo.PsnCertType
  23603. Certno = res.Output.Baseinfo.Certno
  23604. PsnName = res.Output.Baseinfo.PsnName
  23605. Gend = res.Output.Baseinfo.Gend
  23606. Naty = res.Output.Baseinfo.Naty
  23607. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23608. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23609. infoStr = string(Iinfos)
  23610. idetinfoStr = string(Idetinfos)
  23611. infocode = res.Infcode
  23612. //infocode = 0
  23613. //verify_number = psn_info.VerifyNumber
  23614. } else {
  23615. psn_info, _ := service.GetPsnByPatientId(id)
  23616. PsnNo = psn_info.PsnNo
  23617. PsnCertType = psn_info.PsnCertType
  23618. Certno = psn_info.Certno
  23619. PsnName = psn_info.PsnName
  23620. Gend = psn_info.Gend
  23621. Naty = psn_info.Naty
  23622. Brdy = psn_info.Brdy
  23623. Age = psn_info.Age
  23624. infoStr = psn_info.Insuinfo
  23625. idetinfoStr = psn_info.Idetinfo
  23626. infocode = 0
  23627. verify_number = psn_info.VerifyNumber
  23628. }
  23629. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23630. if id_card_type == 1 {
  23631. psn_info, _ := service.GetPsnByPatientId(id)
  23632. PsnNo = psn_info.PsnNo
  23633. PsnCertType = psn_info.PsnCertType
  23634. Certno = psn_info.Certno
  23635. PsnName = psn_info.PsnName
  23636. Gend = psn_info.Gend
  23637. Naty = psn_info.Naty
  23638. Brdy = psn_info.Brdy
  23639. Age = psn_info.Age
  23640. infoStr = psn_info.Insuinfo
  23641. idetinfoStr = psn_info.Idetinfo
  23642. infocode = 0
  23643. verify_number = psn_info.VerifyNumber
  23644. } else if id_card_type == 2 {
  23645. 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)
  23646. fmt.Println(errMsgLog)
  23647. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23648. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23649. utils.ErrorLog("解析失败:%v", err)
  23650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23651. return
  23652. }
  23653. PsnNo = res.Output.Baseinfo.PsnNo
  23654. PsnCertType = res.Output.Baseinfo.PsnCertType
  23655. Certno = res.Output.Baseinfo.Certno
  23656. PsnName = res.Output.Baseinfo.PsnName
  23657. Gend = res.Output.Baseinfo.Gend
  23658. Naty = res.Output.Baseinfo.Naty
  23659. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23660. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23661. infoStr = string(Iinfos)
  23662. idetinfoStr = string(Idetinfos)
  23663. infocode = res.Infcode
  23664. }
  23665. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23666. if id_card_type == 1 {
  23667. psn_info, _ := service.GetPsnByPatientId(id)
  23668. PsnNo = psn_info.PsnNo
  23669. PsnCertType = psn_info.PsnCertType
  23670. Certno = psn_info.Certno
  23671. PsnName = psn_info.PsnName
  23672. Gend = psn_info.Gend
  23673. Naty = psn_info.Naty
  23674. Brdy = psn_info.Brdy
  23675. Age = psn_info.Age
  23676. infoStr = psn_info.Insuinfo
  23677. idetinfoStr = psn_info.Idetinfo
  23678. infocode = 0
  23679. verify_number = psn_info.VerifyNumber
  23680. } else if id_card_type == 2 {
  23681. 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, "")
  23682. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23683. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23684. utils.ErrorLog("解析失败:%v", err)
  23685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23686. return
  23687. }
  23688. PsnNo = res.Output.Baseinfo.PsnNo
  23689. PsnCertType = res.Output.Baseinfo.PsnCertType
  23690. Certno = res.Output.Baseinfo.Certno
  23691. PsnName = res.Output.Baseinfo.PsnName
  23692. Gend = res.Output.Baseinfo.Gend
  23693. Naty = res.Output.Baseinfo.Naty
  23694. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23695. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23696. infoStr = string(Iinfos)
  23697. idetinfoStr = string(Idetinfos)
  23698. infocode = res.Infcode
  23699. } else {
  23700. psn_info, _ := service.GetPsnByPatientId(id)
  23701. PsnNo = psn_info.PsnNo
  23702. PsnCertType = psn_info.PsnCertType
  23703. Certno = psn_info.Certno
  23704. PsnName = psn_info.PsnName
  23705. Gend = psn_info.Gend
  23706. Naty = psn_info.Naty
  23707. Brdy = psn_info.Brdy
  23708. Age = psn_info.Age
  23709. infoStr = psn_info.Insuinfo
  23710. idetinfoStr = psn_info.Idetinfo
  23711. infocode = 0
  23712. verify_number = psn_info.VerifyNumber
  23713. }
  23714. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23715. if id_card_type == 1 {
  23716. psn_info, _ := service.GetPsnByPatientId(id)
  23717. PsnNo = psn_info.PsnNo
  23718. PsnCertType = psn_info.PsnCertType
  23719. Certno = psn_info.Certno
  23720. PsnName = psn_info.PsnName
  23721. Gend = psn_info.Gend
  23722. Naty = psn_info.Naty
  23723. Brdy = psn_info.Brdy
  23724. Age = psn_info.Age
  23725. infoStr = psn_info.Insuinfo
  23726. idetinfoStr = psn_info.Idetinfo
  23727. infocode = 0
  23728. verify_number = psn_info.VerifyNumber
  23729. } else if id_card_type == 2 {
  23730. psn_info, _ := service.GetPsnByPatientId(id)
  23731. PsnNo = psn_info.PsnNo
  23732. PsnCertType = psn_info.PsnCertType
  23733. Certno = psn_info.Certno
  23734. PsnName = psn_info.PsnName
  23735. Gend = psn_info.Gend
  23736. Naty = psn_info.Naty
  23737. Brdy = psn_info.Brdy
  23738. Age = psn_info.Age
  23739. infoStr = psn_info.Insuinfo
  23740. idetinfoStr = psn_info.Idetinfo
  23741. infocode = 0
  23742. verify_number = psn_info.VerifyNumber
  23743. } else {
  23744. psn_info, _ := service.GetPsnByPatientId(id)
  23745. PsnNo = psn_info.PsnNo
  23746. PsnCertType = psn_info.PsnCertType
  23747. Certno = psn_info.Certno
  23748. PsnName = psn_info.PsnName
  23749. Gend = psn_info.Gend
  23750. Naty = psn_info.Naty
  23751. Brdy = psn_info.Brdy
  23752. Age = psn_info.Age
  23753. infoStr = psn_info.Insuinfo
  23754. idetinfoStr = psn_info.Idetinfo
  23755. infocode = 0
  23756. verify_number = psn_info.VerifyNumber
  23757. }
  23758. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23759. psn_info, _ := service.GetPsnByPatientId(id)
  23760. PsnNo = psn_info.PsnNo
  23761. PsnCertType = psn_info.PsnCertType
  23762. Certno = psn_info.Certno
  23763. PsnName = psn_info.PsnName
  23764. Gend = psn_info.Gend
  23765. Naty = psn_info.Naty
  23766. Brdy = psn_info.Brdy
  23767. Age = psn_info.Age
  23768. infoStr = psn_info.Insuinfo
  23769. idetinfoStr = psn_info.Idetinfo
  23770. infocode = 0
  23771. verify_number = psn_info.VerifyNumber
  23772. idetinfoStr = psn_info.Idetinfo
  23773. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23774. if id_card_type == 1 {
  23775. psn_info, _ := service.GetPsnByPatientId(id)
  23776. PsnNo = psn_info.PsnNo
  23777. PsnCertType = psn_info.PsnCertType
  23778. Certno = psn_info.Certno
  23779. PsnName = psn_info.PsnName
  23780. Gend = psn_info.Gend
  23781. Naty = psn_info.Naty
  23782. Brdy = psn_info.Brdy
  23783. Age = psn_info.Age
  23784. infoStr = psn_info.Insuinfo
  23785. idetinfoStr = psn_info.Idetinfo
  23786. infocode = 0
  23787. verify_number = psn_info.VerifyNumber
  23788. } else if id_card_type == 2 {
  23789. 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)
  23790. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23791. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23792. utils.ErrorLog("解析失败:%v", err)
  23793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23794. return
  23795. }
  23796. PsnNo = res.Output.Baseinfo.PsnNo
  23797. PsnCertType = res.Output.Baseinfo.PsnCertType
  23798. Certno = res.Output.Baseinfo.Certno
  23799. PsnName = res.Output.Baseinfo.PsnName
  23800. Gend = res.Output.Baseinfo.Gend
  23801. Naty = res.Output.Baseinfo.Naty
  23802. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23803. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23804. infoStr = string(Iinfos)
  23805. idetinfoStr = string(Idetinfos)
  23806. infocode = res.Infcode
  23807. } else if id_card_type == 4 {
  23808. psn_info, _ := service.GetPsnByPatientId(id)
  23809. PsnNo = psn_info.PsnNo
  23810. PsnCertType = psn_info.PsnCertType
  23811. Certno = psn_info.Certno
  23812. PsnName = psn_info.PsnName
  23813. Gend = psn_info.Gend
  23814. Naty = psn_info.Naty
  23815. Brdy = psn_info.Brdy
  23816. Age = psn_info.Age
  23817. infoStr = psn_info.Insuinfo
  23818. idetinfoStr = psn_info.Idetinfo
  23819. infocode = 0
  23820. verify_number = psn_info.VerifyNumber
  23821. }
  23822. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23823. var result string
  23824. var requestLog string
  23825. 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), "")
  23826. if id_card_type == 4 {
  23827. psn_info, _ := service.GetPsnByPatientId(id)
  23828. PsnNo = psn_info.PsnNo
  23829. PsnCertType = psn_info.PsnCertType
  23830. Certno = psn_info.Certno
  23831. PsnName = psn_info.PsnName
  23832. Gend = psn_info.Gend
  23833. Naty = psn_info.Naty
  23834. Brdy = psn_info.Brdy
  23835. Age = psn_info.Age
  23836. infoStr = psn_info.Insuinfo
  23837. idetinfoStr = psn_info.Idetinfo
  23838. infocode = 0
  23839. verify_number = psn_info.VerifyNumber
  23840. } else {
  23841. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23842. if miConfig.Code == "H15049901371" {
  23843. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23844. utils.ErrorLog("解析失败:%v", err)
  23845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23846. return
  23847. }
  23848. res.ErrMsg = res10265.ErrMsg
  23849. res.Output = res10265.Output
  23850. res.InfRefmsgid = res10265.InfRefmsgid
  23851. } else {
  23852. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23853. utils.ErrorLog("解析失败:%v", err)
  23854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23855. return
  23856. }
  23857. }
  23858. PsnNo = res.Output.Baseinfo.PsnNo
  23859. PsnCertType = res.Output.Baseinfo.PsnCertType
  23860. Certno = res.Output.Baseinfo.Certno
  23861. PsnName = res.Output.Baseinfo.PsnName
  23862. Gend = res.Output.Baseinfo.Gend
  23863. Naty = res.Output.Baseinfo.Naty
  23864. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23865. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23866. infoStr = string(Iinfos)
  23867. idetinfoStr = string(Idetinfos)
  23868. if miConfig.Code == "H15049901371" {
  23869. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23870. } else {
  23871. infocode = res.Infcode
  23872. }
  23873. }
  23874. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23875. psn_info, _ := service.GetPsnByPatientId(id)
  23876. PsnNo = psn_info.PsnNo
  23877. PsnCertType = psn_info.PsnCertType
  23878. Certno = psn_info.Certno
  23879. PsnName = psn_info.PsnName
  23880. Gend = psn_info.Gend
  23881. Naty = psn_info.Naty
  23882. Brdy = psn_info.Brdy
  23883. Age = psn_info.Age
  23884. infoStr = psn_info.Insuinfo
  23885. idetinfoStr = psn_info.Idetinfo
  23886. infocode = 0
  23887. verify_number = psn_info.VerifyNumber
  23888. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23889. psn_info, _ := service.GetPsnByPatientId(id)
  23890. PsnNo = psn_info.PsnNo
  23891. PsnCertType = psn_info.PsnCertType
  23892. Certno = psn_info.Certno
  23893. PsnName = psn_info.PsnName
  23894. Gend = psn_info.Gend
  23895. Naty = psn_info.Naty
  23896. Brdy = psn_info.Brdy
  23897. Age = psn_info.Age
  23898. infoStr = psn_info.Insuinfo
  23899. idetinfoStr = psn_info.Idetinfo
  23900. infocode = 0
  23901. verify_number = psn_info.VerifyNumber
  23902. } else {
  23903. var result string
  23904. var requestLog string
  23905. //if miConfig.UserOrgId == 10138 {
  23906. if id_card_type != 4 || id_card_type != 1 {
  23907. var insa string
  23908. if len(patient.InsuplcAdmdvs) > 0 {
  23909. insa = patient.InsuplcAdmdvs
  23910. } else {
  23911. insa = miConfig.InsuplcAdmdvs
  23912. }
  23913. //psn_info, _ := service.GetPsnByPatientId(id)
  23914. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23915. 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)
  23916. }
  23917. //}
  23918. //else {
  23919. // var insa string
  23920. // if len(patient.InsuplcAdmdvs) > 0 {
  23921. // insa = patient.InsuplcAdmdvs
  23922. // } else {
  23923. // insa = miConfig.InsuplcAdmdvs
  23924. // }
  23925. // 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)
  23926. //}
  23927. if id_card_type == 4 || id_card_type == 1 {
  23928. psn_info, _ := service.GetPsnByPatientId(id)
  23929. PsnNo = psn_info.PsnNo
  23930. PsnCertType = psn_info.PsnCertType
  23931. Certno = psn_info.Certno
  23932. PsnName = psn_info.PsnName
  23933. Gend = psn_info.Gend
  23934. Naty = psn_info.Naty
  23935. Brdy = psn_info.Brdy
  23936. Age = psn_info.Age
  23937. infoStr = psn_info.Insuinfo
  23938. idetinfoStr = psn_info.Idetinfo
  23939. infocode = 0
  23940. verify_number = psn_info.VerifyNumber
  23941. } else {
  23942. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23943. if miConfig.Code == "H15049901371" {
  23944. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23945. utils.ErrorLog("解析失败:%v", err)
  23946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23947. return
  23948. }
  23949. res.ErrMsg = res10265.ErrMsg
  23950. res.Output = res10265.Output
  23951. res.InfRefmsgid = res10265.InfRefmsgid
  23952. } else {
  23953. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23954. utils.ErrorLog("解析失败:%v", err)
  23955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23956. return
  23957. }
  23958. }
  23959. PsnNo = res.Output.Baseinfo.PsnNo
  23960. PsnCertType = res.Output.Baseinfo.PsnCertType
  23961. Certno = res.Output.Baseinfo.Certno
  23962. PsnName = res.Output.Baseinfo.PsnName
  23963. Gend = res.Output.Baseinfo.Gend
  23964. Naty = res.Output.Baseinfo.Naty
  23965. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23966. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23967. infoStr = string(Iinfos)
  23968. idetinfoStr = string(Idetinfos)
  23969. if miConfig.Code == "H15049901371" {
  23970. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23971. } else {
  23972. infocode = res.Infcode
  23973. }
  23974. }
  23975. }
  23976. if infocode == 0 {
  23977. his := models.VMHisPatient{
  23978. Name: name,
  23979. Gender: gender,
  23980. Birthday: birthUnix,
  23981. MedicalTreatmentType: medical_care,
  23982. IdType: certificates,
  23983. IdCardNo: id_card,
  23984. BalanceAccountsType: settlementValue,
  23985. SocialType: social_type,
  23986. MedicalInsuranceNumber: medical_insurance_card,
  23987. RegisterType: register_type,
  23988. RegisterCost: registration_fee,
  23989. TreatmentCost: medical_expenses,
  23990. Status: 1,
  23991. Ctime: time.Now().Unix(),
  23992. Mtime: time.Now().Unix(),
  23993. PsnNo: PsnNo,
  23994. PsnCertType: PsnCertType,
  23995. Certno: Certno,
  23996. PsnName: PsnName,
  23997. Gend: Gend,
  23998. Naty: Naty,
  23999. Brdy: Brdy,
  24000. Age: Age,
  24001. Iinfo: infoStr,
  24002. Idetinfo: idetinfoStr,
  24003. PatientId: patient.ID,
  24004. RecordDate: theTime.Unix(),
  24005. UserOrgId: adminInfo.CurrentOrgId,
  24006. AdminUserId: admin_user_id,
  24007. IsReturn: 1,
  24008. IdCardType: id_card_type,
  24009. Doctor: doctor,
  24010. Departments: department,
  24011. MdtrtGrpType: mdtrt_type,
  24012. }
  24013. timestamp := time.Now().Unix()
  24014. tempTime := time.Unix(timestamp, 0)
  24015. timeFormat := tempTime.Format("20060102150405")
  24016. chrgBchno := rand.Intn(100000) + 10000
  24017. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24018. his.Number = ipt_otp_no
  24019. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  24020. department, _ := service.GetDepartMentDetail(department)
  24021. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  24022. IdCardNo := ""
  24023. if id_card_type == 1 {
  24024. // IdCardNo = medical_insurance_card
  24025. IdCardNo = patient.IdCardNo
  24026. } else {
  24027. IdCardNo = patient.IdCardNo
  24028. }
  24029. var rf []*ResultFive
  24030. json.Unmarshal([]byte(his.Iinfo), &rf)
  24031. var insutypes []*ResultFive
  24032. var insutype string
  24033. var insuplc_admdvs_temp string
  24034. var is390 int = 0
  24035. var is310 int = 0
  24036. for _, item := range rf {
  24037. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24038. insutypes = append(insutypes, item)
  24039. }
  24040. }
  24041. if len(insutypes) == 1 {
  24042. insutype = insutypes[0].Insutype
  24043. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24044. if insutype == "390" {
  24045. is390 = 1
  24046. }
  24047. if insutype == "310" {
  24048. is310 = 1
  24049. }
  24050. } else {
  24051. for _, i := range insutypes {
  24052. if i.Insutype == "390" {
  24053. is390 = 1
  24054. }
  24055. if i.Insutype == "310" {
  24056. is310 = 1
  24057. }
  24058. }
  24059. }
  24060. if is390 == 1 {
  24061. insutype = "390"
  24062. }
  24063. if is310 == 1 {
  24064. insutype = "310"
  24065. }
  24066. fmt.Println(social_type)
  24067. if social_type > 0 {
  24068. insutype = strconv.FormatInt(social_type, 10)
  24069. }
  24070. var infocode int64
  24071. var resThree ResultThree
  24072. var resThree10265 ResultThree10265
  24073. if len(insuplc_admdvs) == 0 {
  24074. psn_info, _ := service.GetPsnByPatientId(id)
  24075. //if len(psn_info.InsuplcAdmdvs) > 0 {
  24076. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24077. //}
  24078. } else {
  24079. insuplc_admdvs_temp = insuplc_admdvs
  24080. }
  24081. if miConfig.MdtrtareaAdmvs == "421300" {
  24082. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24083. psn_info, _ := service.GetPsnByPatientId(id)
  24084. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24085. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24086. "&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
  24087. resp, requestErr := http.Get(api)
  24088. if requestErr != nil {
  24089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24090. return
  24091. }
  24092. body, ioErr := ioutil.ReadAll(resp.Body)
  24093. if ioErr != nil {
  24094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24096. return
  24097. }
  24098. var respJSON map[string]interface{}
  24099. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24102. return
  24103. }
  24104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24105. result, _ := json.Marshal(respJSON)
  24106. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24107. utils.ErrorLog("解析失败:%v", err)
  24108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24109. return
  24110. }
  24111. infocode = resThree.Infcode
  24112. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24113. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24114. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24115. // insuplc_admdvs_temp =
  24116. //}
  24117. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24118. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24119. //}
  24120. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24121. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24122. "&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
  24123. resp, requestErr := http.Get(api)
  24124. if requestErr != nil {
  24125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24126. return
  24127. }
  24128. body, ioErr := ioutil.ReadAll(resp.Body)
  24129. if ioErr != nil {
  24130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24132. return
  24133. }
  24134. var respJSON map[string]interface{}
  24135. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24138. return
  24139. }
  24140. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24141. result, _ := json.Marshal(respJSON)
  24142. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24143. utils.ErrorLog("解析失败:%v", err)
  24144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24145. return
  24146. }
  24147. infocode = resThree.Infcode
  24148. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24149. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24150. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24151. // insuplc_admdvs_temp =
  24152. //}
  24153. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24154. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24155. //}
  24156. utils.ErrorLog("解析失败:%v", insutype)
  24157. utils.ErrorLog("解析失败:%v", PsnNo)
  24158. utils.ErrorLog("解析失败:%v", Certno)
  24159. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  24160. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  24161. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  24162. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  24163. utils.ErrorLog("解析失败:%v", PsnNo)
  24164. utils.ErrorLog("解析失败:%v", department.Number)
  24165. utils.ErrorLog("解析失败:%v", department.Name)
  24166. utils.ErrorLog("解析失败:%v", roles.UserName)
  24167. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24168. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24169. "&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
  24170. resp, requestErr := http.Get(api)
  24171. if requestErr != nil {
  24172. utils.ErrorLog("解析失败:%v", requestErr)
  24173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24174. return
  24175. }
  24176. body, ioErr := ioutil.ReadAll(resp.Body)
  24177. if ioErr != nil {
  24178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24180. return
  24181. }
  24182. var respJSON map[string]interface{}
  24183. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24186. return
  24187. }
  24188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24189. result, _ := json.Marshal(respJSON)
  24190. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24191. utils.ErrorLog("解析失败:%v", err)
  24192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24193. return
  24194. }
  24195. infocode = resThree.Infcode
  24196. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24197. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24198. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24199. // insuplc_admdvs_temp =
  24200. //}
  24201. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24202. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24203. //}
  24204. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24205. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24206. "&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
  24207. resp, requestErr := http.Get(api)
  24208. if requestErr != nil {
  24209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24210. return
  24211. }
  24212. body, ioErr := ioutil.ReadAll(resp.Body)
  24213. if ioErr != nil {
  24214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24216. return
  24217. }
  24218. var respJSON map[string]interface{}
  24219. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24222. return
  24223. }
  24224. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24225. result, _ := json.Marshal(respJSON)
  24226. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24227. utils.ErrorLog("解析失败:%v", err)
  24228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24229. return
  24230. }
  24231. infocode = resThree.Infcode
  24232. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24233. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24234. psn_info, _ := service.GetPsnByPatientId(id)
  24235. var verify_number string
  24236. if id_card_type == 4 {
  24237. verify_number = psn_info.VerifyNumber
  24238. } else if id_card_type == 1 {
  24239. bas := strings.Split(psn_info.CardInfo, "|")
  24240. cardNumber := bas[2]
  24241. verify_number = cardNumber
  24242. }
  24243. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24244. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24245. "&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
  24246. resp, requestErr := http.Get(api)
  24247. if requestErr != nil {
  24248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24249. return
  24250. }
  24251. body, ioErr := ioutil.ReadAll(resp.Body)
  24252. if ioErr != nil {
  24253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24255. return
  24256. }
  24257. var respJSON map[string]interface{}
  24258. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24261. return
  24262. }
  24263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24264. result, _ := json.Marshal(respJSON)
  24265. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24266. // utils.ErrorLog("解析失败:%v", err)
  24267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24268. // return
  24269. //}
  24270. //infocode = resThree.Infcode
  24271. //result, _ := json.Marshal(respJSON)
  24272. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24273. utils.ErrorLog("解析失败:%v", err)
  24274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24275. return
  24276. }
  24277. resThree.ErrMsg = resThree10265.ErrMsg
  24278. resThree.Output = resThree10265.Output
  24279. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24280. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24281. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24282. psn_info, _ := service.GetPsnByPatientId(id)
  24283. his.PsnNo = psn_info.PsnNo
  24284. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24285. var cert_no string
  24286. if id_card_type == 3 {
  24287. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  24288. cert_no = IdCardNo
  24289. } else if id_card_type == 4 {
  24290. cert_no = IdCardNo
  24291. psn_info.VerifyNumber = psn_info.VerifyNumber
  24292. } else {
  24293. bas := strings.Split(psn_info.CardInfo, "|")
  24294. cert_no = bas[2]
  24295. }
  24296. var hisPrescription []*models.HisPrescription
  24297. for _, item := range rf {
  24298. if item.Insutype == insutype {
  24299. //insuplc_admdvs = item.InsuplcAdmdvs
  24300. his.InsuplcAdmdvs = insuplc_admdvs
  24301. }
  24302. }
  24303. his.Insutype = insutype
  24304. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24305. fmt.Println(res3101)
  24306. fmt.Println(res3101.Infcode)
  24307. if res3101.Infcode == "0" {
  24308. fmt.Println("33333333")
  24309. if len(res3101.Output.Result) > 0 {
  24310. fmt.Println("222222")
  24311. for _, item := range res3101.Output.Result {
  24312. if len(res3101.ErrMsg) == 0 {
  24313. res3101.ErrMsg = item.VolaCont
  24314. } else {
  24315. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24316. }
  24317. }
  24318. c.ServeSuccessJSON(map[string]interface{}{
  24319. "failed_code": -10,
  24320. "msg": res3101.ErrMsg,
  24321. })
  24322. return
  24323. } else {
  24324. fmt.Println("11111")
  24325. var api string
  24326. if miConfig.MdtrtareaAdmvs == "320921" {
  24327. ipt_otp_no = timeFormat
  24328. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24329. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24330. "&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
  24331. } else {
  24332. ipt_otp_no = timeFormat
  24333. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24334. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24335. "&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
  24336. }
  24337. resp, requestErr := http.Get(api)
  24338. if requestErr != nil {
  24339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24340. return
  24341. }
  24342. body, ioErr := ioutil.ReadAll(resp.Body)
  24343. if ioErr != nil {
  24344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24346. return
  24347. }
  24348. var respJSON map[string]interface{}
  24349. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24352. return
  24353. }
  24354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24355. result, _ := json.Marshal(respJSON)
  24356. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24357. utils.ErrorLog("解析失败:%v", err)
  24358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24359. return
  24360. }
  24361. resThree.ErrMsg = resThree10265.ErrMsg
  24362. resThree.Output = resThree10265.Output
  24363. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24364. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24365. }
  24366. } else if res3101.Infcode != "0" {
  24367. c.ServeSuccessJSON(map[string]interface{}{
  24368. "failed_code": -10,
  24369. "msg": res3101.ErrMsg,
  24370. })
  24371. return
  24372. }
  24373. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24374. psn_info, _ := service.GetPsnByPatientId(id)
  24375. var cert_no string
  24376. if id_card_type == 1 {
  24377. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24378. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24379. } else if id_card_type == 4 {
  24380. cert_no = psn_info.VerifyNumber
  24381. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24382. } else {
  24383. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24384. cert_no = psn_info.VerifyNumber
  24385. }
  24386. 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)
  24387. saveLog(result, requestLog, "2201", "挂号")
  24388. if miConfig.Code == "H15049901371" {
  24389. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24390. utils.ErrorLog("解析失败:%v", err)
  24391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24392. return
  24393. }
  24394. resThree.ErrMsg = resThree10265.ErrMsg
  24395. resThree.Output = resThree10265.Output
  24396. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24397. } else {
  24398. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24399. utils.ErrorLog("解析失败:%v", err)
  24400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24401. return
  24402. }
  24403. }
  24404. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24405. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24406. psn_info, _ := service.GetPsnByPatientId(id)
  24407. var result string
  24408. var requestLog string
  24409. if id_card_type == 1 {
  24410. bas := strings.Split(psn_info.CardInfo, "|")
  24411. basNumber := bas[2]
  24412. card_sn := bas[3]
  24413. 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)
  24414. saveLog(result, requestLog, "2201A", "挂号")
  24415. } else if id_card_type == 2 {
  24416. 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, "", "", "", "", "", "")
  24417. saveLog(result, requestLog, "2201A", "挂号")
  24418. } else {
  24419. 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)
  24420. saveLog(result, requestLog, "2201A", "挂号")
  24421. }
  24422. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24423. utils.ErrorLog("解析失败:%v", err)
  24424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24425. return
  24426. }
  24427. infocode = resThree.Infcode
  24428. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24429. psn_info, _ := service.GetPsnByPatientId(id)
  24430. var result string
  24431. var requestLog string
  24432. if id_card_type == 1 {
  24433. bas := strings.Split(psn_info.CardInfo, "|")
  24434. basNumber := bas[2]
  24435. card_sn := ""
  24436. 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)
  24437. saveLog(result, requestLog, "2201A", "挂号")
  24438. } else if id_card_type == 2 {
  24439. 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, "", "", "", "", "", "")
  24440. saveLog(result, requestLog, "2201A", "挂号")
  24441. } else {
  24442. 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)
  24443. saveLog(result, requestLog, "2201A", "挂号")
  24444. }
  24445. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24446. utils.ErrorLog("解析失败:%v", err)
  24447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24448. return
  24449. }
  24450. infocode = resThree.Infcode
  24451. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24452. psn_info, _ := service.GetPsnByPatientId(id)
  24453. his.PsnNo = psn_info.PsnNo
  24454. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24455. var cert_no string
  24456. if id_card_type == 1 {
  24457. bas := strings.Split(psn_info.CardInfo, "|")
  24458. cert_no = bas[2]
  24459. } else if id_card_type == 4 {
  24460. cert_no = psn_info.VerifyNumber
  24461. psn_info.VerifyNumber = psn_info.VerifyNumber
  24462. IdCardNo = psn_info.VerifyNumber
  24463. } else {
  24464. cert_no = IdCardNo
  24465. psn_info.VerifyNumber = cert_no
  24466. }
  24467. for _, item := range rf {
  24468. if item.Insutype == insutype {
  24469. his.InsuplcAdmdvs = insuplc_admdvs
  24470. }
  24471. }
  24472. his.Insutype = insutype
  24473. var api string
  24474. ipt_otp_no = timeFormat
  24475. 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 +
  24476. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24477. "&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
  24478. resp, requestErr := http.Get(api)
  24479. if requestErr != nil {
  24480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24481. return
  24482. }
  24483. body, ioErr := ioutil.ReadAll(resp.Body)
  24484. if ioErr != nil {
  24485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24487. return
  24488. }
  24489. var respJSON map[string]interface{}
  24490. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24493. return
  24494. }
  24495. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24496. if status == "0" {
  24497. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24498. c.ServeSuccessJSON(map[string]interface{}{
  24499. "failed_code": -10,
  24500. "msg": err_msg,
  24501. })
  24502. return
  24503. }
  24504. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24505. result, _ := json.Marshal(respJSON)
  24506. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24507. utils.ErrorLog("解析失败:%v", err)
  24508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24509. return
  24510. }
  24511. infocode = resThree.Infcode
  24512. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24513. psn_info, _ := service.GetPsnByPatientId(id)
  24514. his.PsnNo = psn_info.PsnNo
  24515. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24516. var cert_no string
  24517. if id_card_type == 1 {
  24518. bas := strings.Split(psn_info.CardInfo, "|")
  24519. cert_no = bas[2]
  24520. } else if id_card_type == 4 {
  24521. cert_no = psn_info.VerifyNumber
  24522. psn_info.VerifyNumber = psn_info.VerifyNumber
  24523. IdCardNo = psn_info.VerifyNumber
  24524. } else {
  24525. cert_no = IdCardNo
  24526. psn_info.VerifyNumber = cert_no
  24527. }
  24528. for _, item := range rf {
  24529. if item.Insutype == insutype {
  24530. his.InsuplcAdmdvs = insuplc_admdvs
  24531. patient.InsuplcAdmdvs = insuplc_admdvs
  24532. }
  24533. }
  24534. his.Insutype = insutype
  24535. var api string
  24536. ipt_otp_no = timeFormat
  24537. 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 +
  24538. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24539. "&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
  24540. resp, requestErr := http.Get(api)
  24541. if requestErr != nil {
  24542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24543. return
  24544. }
  24545. body, ioErr := ioutil.ReadAll(resp.Body)
  24546. if ioErr != nil {
  24547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24549. return
  24550. }
  24551. var respJSON map[string]interface{}
  24552. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24555. return
  24556. }
  24557. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24558. if status == "0" {
  24559. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24560. c.ServeSuccessJSON(map[string]interface{}{
  24561. "failed_code": -10,
  24562. "msg": err_msg,
  24563. })
  24564. return
  24565. }
  24566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24567. result, _ := json.Marshal(respJSON)
  24568. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24569. utils.ErrorLog("解析失败:%v", err)
  24570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24571. return
  24572. }
  24573. infocode = resThree.Infcode
  24574. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24575. psn_info, _ := service.GetPsnByPatientId(id)
  24576. var result string
  24577. var requestLog string
  24578. if id_card_type == 1 {
  24579. bas := strings.Split(psn_info.CardInfo, "|")
  24580. basNumber := bas[2]
  24581. card_sn := bas[3]
  24582. 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)
  24583. saveLog(result, requestLog, "2201A", "挂号")
  24584. } else if id_card_type == 2 {
  24585. 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, "", "")
  24586. saveLog(result, requestLog, "2201A", "挂号")
  24587. } else {
  24588. 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, "", "")
  24589. saveLog(result, requestLog, "2201A", "挂号")
  24590. }
  24591. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24592. utils.ErrorLog("解析失败:%v", err)
  24593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24594. return
  24595. }
  24596. infocode = resThree.Infcode
  24597. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24598. psn_info, _ := service.GetPsnByPatientId(id)
  24599. 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)
  24600. saveLog(result, requestLog, "2201A", "挂号")
  24601. if miConfig.Code == "H15049901371" {
  24602. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24603. utils.ErrorLog("解析失败:%v", err)
  24604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24605. return
  24606. }
  24607. resThree.ErrMsg = resThree10265.ErrMsg
  24608. resThree.Output = resThree10265.Output
  24609. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24610. } else {
  24611. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24612. utils.ErrorLog("解析失败:%v", err)
  24613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24614. return
  24615. }
  24616. }
  24617. if miConfig.Code == "H15049901371" {
  24618. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24619. } else {
  24620. infocode = resThree.Infcode
  24621. }
  24622. } else {
  24623. psn_info, _ := service.GetPsnByPatientId(id)
  24624. if id_card_type == 4 || id_card_type == 1 {
  24625. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24626. }
  24627. var rf []*ResultFive
  24628. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24629. var insutypes []*ResultFive
  24630. var insutype string
  24631. var is390 int = 0
  24632. var is310 int = 0
  24633. for _, item := range rf {
  24634. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24635. insutypes = append(insutypes, item)
  24636. }
  24637. }
  24638. if len(insutypes) == 1 {
  24639. insutype = insutypes[0].Insutype
  24640. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24641. } else {
  24642. for _, i := range insutypes {
  24643. if i.Insutype == "390" {
  24644. is390 = 1
  24645. }
  24646. if i.Insutype == "310" {
  24647. is310 = 1
  24648. }
  24649. }
  24650. }
  24651. if is390 == 1 {
  24652. insutype = "390"
  24653. }
  24654. if is310 == 1 {
  24655. insutype = "310"
  24656. }
  24657. fmt.Println(len(insutypes))
  24658. if len(insutypes) == 0 {
  24659. for index, item := range rf {
  24660. if index == 0 {
  24661. insutype = item.Insutype
  24662. insuplc_admdvs = item.InsuplcAdmdvs
  24663. }
  24664. }
  24665. fmt.Println(insutype)
  24666. fmt.Println(insuplc_admdvs)
  24667. }
  24668. if social_type > 0 {
  24669. insutype = strconv.FormatInt(social_type, 10)
  24670. }
  24671. fmt.Println("--------")
  24672. fmt.Println(psn_info)
  24673. fmt.Println(psn_info.PsnNo)
  24674. if miConfig.MdtrtareaAdmvs == "441202" {
  24675. var hisPrescription []*models.HisPrescription
  24676. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24677. if res3101.Infcode == 0 {
  24678. fmt.Println("33333333")
  24679. if len(res3101.Output.Result) > 0 {
  24680. fmt.Println("222222")
  24681. for _, item := range res3101.Output.Result {
  24682. if len(res3101.ErrMsg) == 0 {
  24683. res3101.ErrMsg = item.VolaCont
  24684. } else {
  24685. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24686. }
  24687. }
  24688. c.ServeSuccessJSON(map[string]interface{}{
  24689. "failed_code": -10,
  24690. "msg": res3101.ErrMsg,
  24691. })
  24692. return
  24693. } else {
  24694. hour := time.Now().Format("15")
  24695. min := time.Now().Format("04")
  24696. sec := time.Now().Format("05")
  24697. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24698. fmt.Println(record_time_two)
  24699. 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)
  24700. saveLog(result, requestLog, "2201A", "挂号")
  24701. if miConfig.Code == "H15049901371" {
  24702. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24703. utils.ErrorLog("解析失败:%v", err)
  24704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24705. return
  24706. }
  24707. resThree.ErrMsg = resThree10265.ErrMsg
  24708. resThree.Output = resThree10265.Output
  24709. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24710. } else {
  24711. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24712. utils.ErrorLog("解析失败:%v", err)
  24713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24714. return
  24715. }
  24716. }
  24717. if miConfig.Code == "H15049901371" {
  24718. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24719. } else {
  24720. infocode = resThree.Infcode
  24721. }
  24722. }
  24723. } else if res3101.Infcode != 0 {
  24724. c.ServeSuccessJSON(map[string]interface{}{
  24725. "failed_code": -10,
  24726. "msg": res3101.ErrMsg,
  24727. })
  24728. return
  24729. }
  24730. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24731. var hisPrescription []*models.HisPrescription
  24732. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24733. if res3101.Infcode == 0 {
  24734. fmt.Println("33333333")
  24735. if len(res3101.Output.Result) > 0 {
  24736. fmt.Println("222222")
  24737. for _, item := range res3101.Output.Result {
  24738. if len(res3101.ErrMsg) == 0 {
  24739. res3101.ErrMsg = item.VolaCont
  24740. } else {
  24741. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24742. }
  24743. }
  24744. c.ServeSuccessJSON(map[string]interface{}{
  24745. "failed_code": -10,
  24746. "msg": res3101.ErrMsg,
  24747. })
  24748. return
  24749. } else {
  24750. hour := time.Now().Format("15")
  24751. min := time.Now().Format("04")
  24752. sec := time.Now().Format("05")
  24753. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24754. fmt.Println(record_time_two)
  24755. 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)
  24756. saveLog(result, requestLog, "2201A", "挂号")
  24757. if miConfig.Code == "H15049901371" {
  24758. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24759. utils.ErrorLog("解析失败:%v", err)
  24760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24761. return
  24762. }
  24763. resThree.ErrMsg = resThree10265.ErrMsg
  24764. resThree.Output = resThree10265.Output
  24765. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24766. } else {
  24767. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24768. utils.ErrorLog("解析失败:%v", err)
  24769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24770. return
  24771. }
  24772. }
  24773. if miConfig.Code == "H15049901371" {
  24774. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24775. } else {
  24776. infocode = resThree.Infcode
  24777. }
  24778. }
  24779. } else if res3101.Infcode != 0 {
  24780. c.ServeSuccessJSON(map[string]interface{}{
  24781. "failed_code": -10,
  24782. "msg": res3101.ErrMsg,
  24783. })
  24784. return
  24785. }
  24786. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24787. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24788. psn_info, _ := service.GetPsnByPatientId(id)
  24789. var verify_number string
  24790. if id_card_type == 4 {
  24791. verify_number = psn_info.VerifyNumber
  24792. } else if id_card_type == 1 {
  24793. bas := strings.Split(psn_info.CardInfo, "|")
  24794. cardNumber := bas[2]
  24795. verify_number = cardNumber
  24796. } else {
  24797. verify_number = psn_info.Certno
  24798. }
  24799. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24800. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24801. "&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
  24802. resp, requestErr := http.Get(api)
  24803. if requestErr != nil {
  24804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24805. return
  24806. }
  24807. body, ioErr := ioutil.ReadAll(resp.Body)
  24808. if ioErr != nil {
  24809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24811. return
  24812. }
  24813. var respJSON map[string]interface{}
  24814. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24817. return
  24818. }
  24819. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24820. result, _ := json.Marshal(respJSON)
  24821. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24822. utils.ErrorLog("解析失败:%v", err)
  24823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24824. return
  24825. }
  24826. infocode = resThree.Infcode
  24827. } else {
  24828. hour := time.Now().Format("15")
  24829. min := time.Now().Format("04")
  24830. sec := time.Now().Format("05")
  24831. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24832. if id_card_type == 1 {
  24833. for _, item := range rf {
  24834. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24835. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24836. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24837. } else if strconv.FormatInt(social_type, 10) == "390" {
  24838. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24839. } else {
  24840. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24841. }
  24842. }
  24843. }
  24844. }
  24845. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24846. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24847. }
  24848. if id_card_type == 1 {
  24849. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24850. bas := strings.Split(psn_info.CardInfo, "|")
  24851. basNumber := bas[1]
  24852. IdCardNo = basNumber
  24853. }
  24854. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24855. IdCardNo = psn_info.VerifyNumber
  24856. }
  24857. if len(insuplc_admdvs_temp) == 0 {
  24858. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24859. }
  24860. var result string
  24861. var requestLog string
  24862. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  24863. var hisPrescription []*models.HisPrescription
  24864. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24865. if res3101.Infcode == 0 {
  24866. if len(res3101.Output.Result) > 0 {
  24867. for _, item := range res3101.Output.Result {
  24868. if len(res3101.ErrMsg) == 0 {
  24869. res3101.ErrMsg = item.VolaCont
  24870. } else {
  24871. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24872. }
  24873. }
  24874. c.ServeSuccessJSON(map[string]interface{}{
  24875. "failed_code": -10,
  24876. "msg": res3101.ErrMsg,
  24877. })
  24878. return
  24879. } else {
  24880. hour := time.Now().Format("15")
  24881. min := time.Now().Format("04")
  24882. sec := time.Now().Format("05")
  24883. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24884. fmt.Println(record_time_two)
  24885. 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)
  24886. saveLog(result, requestLog, "2201A", "挂号")
  24887. if miConfig.Code == "H15049901371" {
  24888. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24889. utils.ErrorLog("解析失败:%v", err)
  24890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24891. return
  24892. }
  24893. resThree.ErrMsg = resThree10265.ErrMsg
  24894. resThree.Output = resThree10265.Output
  24895. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24896. } else {
  24897. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24898. utils.ErrorLog("解析失败:%v", err)
  24899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24900. return
  24901. }
  24902. }
  24903. if miConfig.Code == "H15049901371" {
  24904. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24905. } else {
  24906. infocode = resThree.Infcode
  24907. }
  24908. }
  24909. } else if res3101.Infcode != 0 {
  24910. c.ServeSuccessJSON(map[string]interface{}{
  24911. "failed_code": -10,
  24912. "msg": res3101.ErrMsg,
  24913. })
  24914. return
  24915. }
  24916. } else {
  24917. 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)
  24918. saveLog(result, requestLog, "2201A", "挂号")
  24919. }
  24920. if miConfig.Code == "H15049901371" {
  24921. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24922. utils.ErrorLog("解析失败:%v", err)
  24923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24924. return
  24925. }
  24926. resThree.ErrMsg = resThree10265.ErrMsg
  24927. resThree.Output = resThree10265.Output
  24928. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24929. } else {
  24930. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24931. utils.ErrorLog("解析失败:%v", err)
  24932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24933. return
  24934. }
  24935. }
  24936. if miConfig.Code == "H15049901371" {
  24937. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24938. } else {
  24939. infocode = resThree.Infcode
  24940. }
  24941. }
  24942. }
  24943. if infocode == -1 {
  24944. adminUser := c.GetAdminUserInfo()
  24945. errlog := &models.HisOrderError{
  24946. UserOrgId: adminUser.CurrentOrgId,
  24947. Ctime: time.Now().Unix(),
  24948. Mtime: time.Now().Unix(),
  24949. ErrMsg: resThree.ErrMsg,
  24950. Status: 1,
  24951. PatientId: id,
  24952. RecordTime: recordDateTime,
  24953. Stage: 2,
  24954. }
  24955. service.CreateErrMsgLog(errlog)
  24956. c.ServeSuccessJSON(map[string]interface{}{
  24957. "failed_code": -10,
  24958. "msg": resThree.ErrMsg,
  24959. })
  24960. return
  24961. }
  24962. his.Number = resThree.Output.Data.MdtrtID
  24963. his.PsnNo = resThree.Output.Data.PsnNo
  24964. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24965. his.IdCardNo = patient.IdCardNo
  24966. his.PhoneNumber = patient.Phone
  24967. his.UserOrgId = adminInfo.CurrentOrgId
  24968. his.Insutype = insutype
  24969. his.Ctime = time.Now().Unix()
  24970. his.Mtime = time.Now().Unix()
  24971. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24972. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24973. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24974. }
  24975. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24976. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24977. }
  24978. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24979. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24980. }
  24981. his.Status = 1
  24982. his.MdtrtGrpType = mdtrt_type
  24983. service.UpdateHisPatientStatus(&his)
  24984. service.UpdateHisPatient123(&patient)
  24985. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24986. c.ServeSuccessJSON(map[string]interface{}{
  24987. "his_info": his,
  24988. })
  24989. } else {
  24990. adminUser := c.GetAdminUserInfo()
  24991. errlog := &models.HisOrderError{
  24992. UserOrgId: adminUser.CurrentOrgId,
  24993. Ctime: time.Now().Unix(),
  24994. Mtime: time.Now().Unix(),
  24995. ErrMsg: res.ErrMsg,
  24996. Status: 1,
  24997. PatientId: id,
  24998. RecordTime: recordDateTime,
  24999. Stage: 1,
  25000. }
  25001. service.CreateErrMsgLog(errlog)
  25002. c.ServeSuccessJSON(map[string]interface{}{
  25003. "failed_code": -10,
  25004. "msg": res.ErrMsg,
  25005. })
  25006. return
  25007. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  25008. }
  25009. }
  25010. }
  25011. func (c *HisApiController) GetUploadInfo() {
  25012. id, _ := c.GetInt64("id")
  25013. record_time := c.GetString("record_time")
  25014. his_patient_id, _ := c.GetInt64("his_patient_id")
  25015. order_id, _ := c.GetInt64("order_id")
  25016. pay_way, _ := c.GetInt64("pay_way")
  25017. pay_ways := c.GetString("pay_ways")
  25018. oth_desc := c.GetString("oth_desc")
  25019. pay_price, _ := c.GetFloat("pay_price")
  25020. pay_card_no := c.GetString("pay_card_no")
  25021. discount_price, _ := c.GetFloat("discount_price")
  25022. preferential_price, _ := c.GetFloat("preferential_price")
  25023. reality_price, _ := c.GetFloat("reality_price")
  25024. found_price, _ := c.GetFloat("found_price")
  25025. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  25026. private_price, _ := c.GetFloat("private_price")
  25027. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  25028. admin_user_id, _ := c.GetInt64("admin_user_id")
  25029. fapiao_code := c.GetString("fapiao_code")
  25030. fapiao_number := c.GetString("fapiao_number")
  25031. diagnosis_id := c.GetString("diagnosis")
  25032. sick_type, _ := c.GetInt64("sick_type")
  25033. reg_type, _ := c.GetInt64("p_type")
  25034. begin_time := c.GetString("begin_time")
  25035. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  25036. cash_pay := c.GetString("cash_pay")
  25037. band_card_pay := c.GetString("band_card_pay")
  25038. wechat_pay := c.GetString("wechat_pay")
  25039. ali_pay := c.GetString("ali_pay")
  25040. jifen_pay := c.GetString("jifen_pay")
  25041. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  25042. fmt.Println(acct_used_flag)
  25043. id_str := c.GetString("ids")
  25044. ids_arr := strings.Split(id_str, ",")
  25045. timeLayout := "2006-01-02"
  25046. loc, _ := time.LoadLocation("Local")
  25047. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25048. if err != nil {
  25049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25050. return
  25051. }
  25052. recordDateTime := theTime.Unix()
  25053. adminUser := c.GetAdminUserInfo()
  25054. var tempOrder models.HisOrder
  25055. tempOrder, _ = service.GetHisOrderByID(order_id)
  25056. var prescriptions []*models.HisPrescription
  25057. var start_time int64
  25058. var end_time int64
  25059. //押金模块
  25060. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  25061. tmp_decimal := c.GetString("tmp_decimal")
  25062. var decimal float64 //本次使用的押金
  25063. var errmsg error
  25064. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  25065. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  25066. return
  25067. }
  25068. if len(tmp_decimal) > 0 {
  25069. if tmp_decimal[0] == 45 {
  25070. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  25071. return
  25072. }
  25073. }
  25074. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  25075. fmt.Println(errs)
  25076. decimal = tt
  25077. //if adminUser.CurrentOrgId == 10106{
  25078. // if len(fapiao_code) == 0{
  25079. // fapiao_code = "144072080589"
  25080. // }
  25081. // if len(fapiao_number) == 0{
  25082. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  25083. // if order.ID == 0{
  25084. // fapiao_number = "00001520"
  25085. // }else{
  25086. // //fapiao_code = "00001520"
  25087. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  25088. // var zero string
  25089. // if fpNumber >= 1000{
  25090. // zero = "0000" + strconv.Itoa(fpNumber)
  25091. // }else if fpNumber >= 10000{
  25092. // zero = "000" + strconv.Itoa(fpNumber)
  25093. // } else if fpNumber >= 100000{
  25094. // zero = "00" + strconv.Itoa(fpNumber)
  25095. // } else if fpNumber >= 1000000{
  25096. // zero = "0" + strconv.Itoa(fpNumber)
  25097. // }else {
  25098. // zero = strconv.Itoa(fpNumber)
  25099. // }
  25100. // fapiao_number = zero
  25101. // }
  25102. // }
  25103. //}
  25104. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25105. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25106. var patientPrescription models.HisPrescriptionInfo
  25107. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25108. if patientPrescription.ID == 0 {
  25109. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  25110. }
  25111. //if patientPrescription.Do
  25112. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25113. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25114. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25115. diagnosis_ids := strings.Split(diagnosis_id, ",")
  25116. var config []*models.HisXtDiagnoseConfig
  25117. for _, item := range diagnosis_ids {
  25118. id, _ := strconv.ParseInt(item, 10, 64)
  25119. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25120. config = append(config, &diagnosisConfig)
  25121. }
  25122. sickConfig, _ := service.FindSickById(sick_type)
  25123. //if tempOrder.ID == 0 {
  25124. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  25125. //}
  25126. if tempOrder.ID == 0 {
  25127. var result string
  25128. var requestLog string
  25129. var res2 ResultSix
  25130. var res3 GZResultSix
  25131. var ressix10265 ResultSix10265
  25132. if miConfig.MdtrtareaAdmvs == "421300" {
  25133. data := make(map[string]interface{})
  25134. client := &http.Client{}
  25135. data["psn_no"] = his.PsnNo
  25136. data["mdtrt_id"] = his.Number
  25137. data["opter"] = roles.UserName
  25138. data["org_name"] = miConfig.OrgName
  25139. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25140. data["doctor_id"] = doctor_info.DoctorNumber
  25141. data["doctor_name"] = doctor_info.UserName
  25142. data["department"] = department.Name
  25143. data["fixmedins_code"] = miConfig.Code
  25144. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25145. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25146. data["secret_key"] = miConfig.SecretKey
  25147. data["sick_code"] = sickConfig.CountryCode
  25148. data["sick_name"] = sickConfig.ClassName
  25149. data["dept"] = strconv.FormatInt(department.ID, 10)
  25150. data["config"] = config
  25151. data["begin_time"] = begin_time
  25152. bytesData, _ := json.Marshal(data)
  25153. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25154. resp, _ := client.Do(req)
  25155. defer resp.Body.Close()
  25156. body, ioErr := ioutil.ReadAll(resp.Body)
  25157. if ioErr != nil {
  25158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25160. return
  25161. }
  25162. var respJSON map[string]interface{}
  25163. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25166. return
  25167. }
  25168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25169. userJSONBytes, _ := json.Marshal(respJSON)
  25170. fmt.Println("log")
  25171. fmt.Println(string(userJSONBytes))
  25172. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25173. utils.ErrorLog("解析失败:%v", err)
  25174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25175. return
  25176. }
  25177. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25178. data := make(map[string]interface{})
  25179. client := &http.Client{}
  25180. data["psn_no"] = his.PsnNo
  25181. data["mdtrt_id"] = his.Number
  25182. data["opter"] = roles.UserName
  25183. data["org_name"] = miConfig.OrgName
  25184. if reg_type == 11 && his.Insutype == "390" {
  25185. data["med_type"] = "110104"
  25186. } else {
  25187. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25188. }
  25189. data["doctor_id"] = doctor_info.DoctorNumber
  25190. data["doctor_name"] = doctor_info.UserName
  25191. data["department"] = department.Name
  25192. data["fixmedins_code"] = miConfig.Code
  25193. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25194. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25195. data["secret_key"] = miConfig.SecretKey
  25196. data["sick_code"] = sickConfig.CountryCode
  25197. data["sick_name"] = sickConfig.ClassName
  25198. data["dept"] = strconv.FormatInt(department.ID, 10)
  25199. data["config"] = config
  25200. data["begin_time"] = begin_time
  25201. bytesData, _ := json.Marshal(data)
  25202. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25203. resp, _ := client.Do(req)
  25204. defer resp.Body.Close()
  25205. body, ioErr := ioutil.ReadAll(resp.Body)
  25206. if ioErr != nil {
  25207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25209. return
  25210. }
  25211. var respJSON map[string]interface{}
  25212. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25215. return
  25216. }
  25217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25218. userJSONBytes, _ := json.Marshal(respJSON)
  25219. fmt.Println("log")
  25220. fmt.Println(string(userJSONBytes))
  25221. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25222. utils.ErrorLog("解析失败:%v", err)
  25223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25224. return
  25225. }
  25226. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25227. data := make(map[string]interface{})
  25228. client := &http.Client{}
  25229. data["psn_no"] = his.PsnNo
  25230. data["mdtrt_id"] = his.Number
  25231. data["opter"] = roles.UserName
  25232. data["org_name"] = miConfig.OrgName
  25233. if reg_type == 11 && his.Insutype == "390" {
  25234. data["med_type"] = "110104"
  25235. } else {
  25236. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25237. }
  25238. data["doctor_id"] = doctor_info.DoctorNumber
  25239. data["doctor_name"] = doctor_info.UserName
  25240. data["department"] = department.Name
  25241. data["fixmedins_code"] = miConfig.Code
  25242. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25243. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25244. data["secret_key"] = miConfig.SecretKey
  25245. data["sick_code"] = sickConfig.CountryCode
  25246. data["sick_name"] = sickConfig.ClassName
  25247. data["dept"] = strconv.FormatInt(department.ID, 10)
  25248. data["config"] = config
  25249. data["begin_time"] = begin_time
  25250. bytesData, _ := json.Marshal(data)
  25251. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25252. resp, _ := client.Do(req)
  25253. defer resp.Body.Close()
  25254. body, ioErr := ioutil.ReadAll(resp.Body)
  25255. if ioErr != nil {
  25256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25258. return
  25259. }
  25260. var respJSON map[string]interface{}
  25261. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25264. return
  25265. }
  25266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25267. userJSONBytes, _ := json.Marshal(respJSON)
  25268. fmt.Println("log")
  25269. fmt.Println(string(userJSONBytes))
  25270. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25271. utils.ErrorLog("解析失败:%v", err)
  25272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25273. return
  25274. }
  25275. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25276. data := make(map[string]interface{})
  25277. client := &http.Client{}
  25278. data["psn_no"] = his.PsnNo
  25279. data["mdtrt_id"] = his.Number
  25280. data["opter"] = roles.UserName
  25281. data["org_name"] = miConfig.OrgName
  25282. if reg_type == 11 && his.Insutype == "390" {
  25283. data["med_type"] = "110104"
  25284. } else {
  25285. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25286. }
  25287. data["doctor_id"] = doctor_info.DoctorNumber
  25288. data["doctor_name"] = doctor_info.UserName
  25289. data["department"] = department.Name
  25290. data["fixmedins_code"] = miConfig.Code
  25291. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25292. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25293. data["secret_key"] = miConfig.SecretKey
  25294. data["sick_code"] = sickConfig.CountryCode
  25295. data["sick_name"] = sickConfig.ClassName
  25296. data["dept"] = strconv.FormatInt(department.ID, 10)
  25297. data["config"] = config
  25298. data["begin_time"] = begin_time
  25299. bytesData, _ := json.Marshal(data)
  25300. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25301. resp, _ := client.Do(req)
  25302. defer resp.Body.Close()
  25303. body, ioErr := ioutil.ReadAll(resp.Body)
  25304. if ioErr != nil {
  25305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25307. return
  25308. }
  25309. var respJSON map[string]interface{}
  25310. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25313. return
  25314. }
  25315. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25316. userJSONBytes, _ := json.Marshal(respJSON)
  25317. fmt.Println("log")
  25318. fmt.Println(string(userJSONBytes))
  25319. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25320. utils.ErrorLog("解析失败:%v", err)
  25321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25322. return
  25323. }
  25324. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25325. data := make(map[string]interface{})
  25326. client := &http.Client{}
  25327. data["psn_no"] = his.PsnNo
  25328. data["mdtrt_id"] = his.Number
  25329. data["doctor"] = roles.UserName
  25330. data["department"] = department.Name
  25331. data["org_name"] = miConfig.OrgName
  25332. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25333. data["doctor_id"] = doctor_info.DoctorNumber
  25334. data["new_doctor_name"] = doctor_info.UserName
  25335. data["fixmedins_code"] = miConfig.Code
  25336. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25337. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25338. data["secret_key"] = miConfig.SecretKey
  25339. data["sick_code"] = sickConfig.CountryCode
  25340. data["sick_name"] = sickConfig.ClassName
  25341. data["url"] = miConfig.Url
  25342. data["ak"] = miConfig.AccessKey
  25343. data["begin_time"] = begin_time
  25344. data["cainfo"] = miConfig.Cainfo
  25345. data["dept"] = strconv.FormatInt(department.ID, 10)
  25346. data["config"] = config
  25347. bytesData, _ := json.Marshal(data)
  25348. var req *http.Request
  25349. if miConfig.MdtrtareaAdmvs == "320921" {
  25350. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25351. //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 +
  25352. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25353. } else {
  25354. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25355. }
  25356. resp, _ := client.Do(req)
  25357. defer resp.Body.Close()
  25358. body, ioErr := ioutil.ReadAll(resp.Body)
  25359. if ioErr != nil {
  25360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25362. return
  25363. }
  25364. var respJSON map[string]interface{}
  25365. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25368. return
  25369. }
  25370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25371. userJSONBytes, _ := json.Marshal(respJSON)
  25372. fmt.Println("log")
  25373. fmt.Println(string(userJSONBytes))
  25374. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25375. utils.ErrorLog("解析失败:%v", err)
  25376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25377. return
  25378. }
  25379. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25380. res2.Output = ressix10265.Output
  25381. res2.ErrMsg = ressix10265.ErrMsg
  25382. res2.Cainfo = ressix10265.Cainfo
  25383. res2.WarnMsg = ressix10265.WarnMsg
  25384. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25385. res2.Infcode = infocode
  25386. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25387. data := make(map[string]interface{})
  25388. client := &http.Client{}
  25389. data["psn_no"] = his.PsnNo
  25390. data["mdtrt_id"] = his.Number
  25391. data["doctor"] = roles.UserName
  25392. data["department"] = department.Name
  25393. data["org_name"] = miConfig.OrgName
  25394. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25395. data["doctor_id"] = doctor_info.DoctorNumber
  25396. data["new_doctor_name"] = doctor_info.UserName
  25397. data["fixmedins_code"] = miConfig.Code
  25398. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25399. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25400. data["secret_key"] = miConfig.SecretKey
  25401. data["sick_code"] = sickConfig.CountryCode
  25402. data["sick_name"] = sickConfig.ClassName
  25403. data["url"] = miConfig.Url
  25404. data["ak"] = miConfig.AccessKey
  25405. data["begin_time"] = begin_time
  25406. data["cainfo"] = miConfig.Cainfo
  25407. data["dept"] = strconv.FormatInt(department.ID, 10)
  25408. data["config"] = config
  25409. bytesData, _ := json.Marshal(data)
  25410. var req *http.Request
  25411. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25412. resp, _ := client.Do(req)
  25413. defer resp.Body.Close()
  25414. body, ioErr := ioutil.ReadAll(resp.Body)
  25415. if ioErr != nil {
  25416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25418. return
  25419. }
  25420. var respJSON map[string]interface{}
  25421. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25424. return
  25425. }
  25426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25427. userJSONBytes, _ := json.Marshal(respJSON)
  25428. fmt.Println("log")
  25429. fmt.Println(string(userJSONBytes))
  25430. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25431. utils.ErrorLog("解析失败:%v", err)
  25432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25433. return
  25434. }
  25435. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25436. res2.Output = ressix10265.Output
  25437. res2.ErrMsg = ressix10265.ErrMsg
  25438. res2.Cainfo = ressix10265.Cainfo
  25439. res2.WarnMsg = ressix10265.WarnMsg
  25440. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25441. res2.Infcode = infocode
  25442. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25443. 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)
  25444. saveLog(result, requestLog, "2203", "上传就诊信息")
  25445. var respJSON2 map[string]interface{}
  25446. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25449. return
  25450. }
  25451. userJSONBytes2, _ := json.Marshal(respJSON2)
  25452. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25453. utils.ErrorLog("解析失败:%v", err)
  25454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25455. return
  25456. }
  25457. 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)
  25458. fmt.Println(result2)
  25459. fmt.Println(src_request)
  25460. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25461. data := make(map[string]interface{})
  25462. client := &http.Client{}
  25463. data["psn_no"] = his.PsnNo
  25464. data["mdtrt_id"] = his.Number
  25465. data["doctor"] = roles.UserName
  25466. data["department"] = department.Name
  25467. data["org_name"] = miConfig.OrgName
  25468. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25469. data["doctor_id"] = doctor_info.DoctorNumber
  25470. data["new_doctor_name"] = doctor_info.UserName
  25471. data["fixmedins_code"] = miConfig.Code
  25472. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25473. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25474. data["secret_key"] = miConfig.SecretKey
  25475. data["sick_code"] = sickConfig.CountryCode
  25476. data["sick_name"] = sickConfig.ClassName
  25477. data["url"] = miConfig.Url
  25478. data["ak"] = miConfig.AccessKey
  25479. data["begin_time"] = begin_time
  25480. data["cainfo"] = miConfig.Cainfo
  25481. data["dept"] = strconv.FormatInt(department.ID, 10)
  25482. data["config"] = config
  25483. bytesData, _ := json.Marshal(data)
  25484. var req *http.Request
  25485. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25486. resp, _ := client.Do(req)
  25487. defer resp.Body.Close()
  25488. body, ioErr := ioutil.ReadAll(resp.Body)
  25489. if ioErr != nil {
  25490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25492. return
  25493. }
  25494. var respJSON map[string]interface{}
  25495. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25498. return
  25499. }
  25500. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25501. userJSONBytes, _ := json.Marshal(respJSON)
  25502. fmt.Println("log")
  25503. fmt.Println(string(userJSONBytes))
  25504. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25505. utils.ErrorLog("解析失败:%v", err)
  25506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25507. return
  25508. }
  25509. } else {
  25510. if miConfig.MdtrtareaAdmvs == "440781" { //
  25511. 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)
  25512. } else {
  25513. if miConfig.Code == "H15049901371" {
  25514. //赤峰地区国家医保医疗类别
  25515. //职工透析:医疗类别选特殊情况门诊990502
  25516. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25517. var med_type string
  25518. if his.Insutype == "390" {
  25519. if reg_type == 14 {
  25520. med_type = "9933"
  25521. } else if reg_type == 11 {
  25522. med_type = "11"
  25523. }
  25524. } else if his.Insutype == "310" {
  25525. if reg_type == 14 {
  25526. med_type = "990502"
  25527. } else if reg_type == 11 {
  25528. med_type = "11"
  25529. }
  25530. }
  25531. 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)
  25532. } else {
  25533. 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)
  25534. }
  25535. }
  25536. saveLog(result, requestLog, "2203", "上传就诊信息")
  25537. var respJSON2 map[string]interface{}
  25538. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25541. return
  25542. }
  25543. userJSONBytes2, _ := json.Marshal(respJSON2)
  25544. if miConfig.Code == "H15049901371" {
  25545. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25546. utils.ErrorLog("解析失败:%v", err)
  25547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25548. return
  25549. }
  25550. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25551. res2.Output = ressix10265.Output
  25552. res2.ErrMsg = ressix10265.ErrMsg
  25553. res2.Cainfo = ressix10265.Cainfo
  25554. res2.WarnMsg = ressix10265.WarnMsg
  25555. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25556. res2.Infcode = infocode
  25557. } else {
  25558. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25559. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25560. utils.ErrorLog("解析失败:%v", err)
  25561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25562. return
  25563. }
  25564. res2.Infcode = res3.Infcode
  25565. } else {
  25566. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25567. utils.ErrorLog("解析失败:%v", err)
  25568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25569. return
  25570. }
  25571. }
  25572. }
  25573. }
  25574. if res2.Infcode == -1 {
  25575. adminUser := c.GetAdminUserInfo()
  25576. errlog := &models.HisOrderError{
  25577. UserOrgId: adminUser.CurrentOrgId,
  25578. Ctime: time.Now().Unix(),
  25579. Mtime: time.Now().Unix(),
  25580. ErrMsg: res2.ErrMsg,
  25581. Status: 1,
  25582. PatientId: id,
  25583. RecordTime: recordDateTime,
  25584. Stage: 3,
  25585. }
  25586. service.CreateErrMsgLog(errlog)
  25587. c.ServeSuccessJSON(map[string]interface{}{
  25588. "failed_code": -10,
  25589. "msg": res2.ErrMsg,
  25590. })
  25591. return
  25592. } else {
  25593. his.Diagnosis = diagnosis_id
  25594. his.SickType = sickConfig.ID
  25595. //var p_type int64
  25596. //if reg_type == 1111 || reg_type == 1112 {
  25597. // p_type = 11
  25598. //
  25599. //}
  25600. his.PType = fmt.Sprintf("%d", reg_type)
  25601. service.UpdateHisPatientThree(&his)
  25602. data := make(map[string]interface{})
  25603. if settle_accounts_type == 1 { //日结
  25604. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25605. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25606. } else {
  25607. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25608. }
  25609. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25610. data["pre"] = prescriptions
  25611. } else { //月结
  25612. start_time_str := c.GetString("start_time")
  25613. end_time_str := c.GetString("end_time")
  25614. timeLayout := "2006-01-02"
  25615. loc, _ := time.LoadLocation("Local")
  25616. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25617. if err != nil {
  25618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25619. return
  25620. }
  25621. recordStartTime := theStartTime.Unix()
  25622. start_time = recordStartTime
  25623. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25624. if err != nil {
  25625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25626. return
  25627. }
  25628. recordEndTime := theEndTime.Unix()
  25629. end_time = recordEndTime
  25630. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25631. data["pre"] = prescriptions
  25632. }
  25633. timestamp := time.Now().Unix()
  25634. tempTime := time.Unix(timestamp, 0)
  25635. timeFormat := tempTime.Format("20060102150405")
  25636. chrgBchno := rand.Intn(100000) + 10000
  25637. new_chrg_bchno := ""
  25638. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25639. new_chrg_bchno = chrg_bchno
  25640. strconv.FormatInt(his.PatientId, 10)
  25641. client := &http.Client{}
  25642. if adminUser.CurrentOrgId == 10265 {
  25643. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25644. new_chrg_bchno = "0000"
  25645. }
  25646. }
  25647. data["psn_no"] = his.PsnNo
  25648. data["mdtrt_id"] = his.Number
  25649. data["chrg_bchno"] = new_chrg_bchno
  25650. data["org_name"] = miConfig.OrgName
  25651. data["doctor"] = doctor_info.UserName
  25652. data["doctor_id"] = doctor_info.DoctorNumber
  25653. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25654. data["fixmedins_code"] = miConfig.Code
  25655. data["dept_code"] = department.Number
  25656. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25657. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25658. data["secret_key"] = miConfig.SecretKey
  25659. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25660. data["url"] = miConfig.Url
  25661. data["ak"] = miConfig.AccessKey
  25662. data["new_doctor_name"] = patientPrescription.Doctor
  25663. data["diag_code"] = sickConfig.CountryCode
  25664. data["cainfo"] = miConfig.Cainfo
  25665. data["opter"] = roles.UserName
  25666. var ids []int64
  25667. for _, item := range prescriptions {
  25668. ids = append(ids, item.ID)
  25669. }
  25670. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25671. if config.IsOpen == 1 { //对接了医保,走医保流程
  25672. var res ResultFour
  25673. var resFour10265 ResultFour10265
  25674. if miConfig.MdtrtareaAdmvs == "421300" {
  25675. bytesData, _ := json.Marshal(data)
  25676. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25677. resp, _ := client.Do(req)
  25678. defer resp.Body.Close()
  25679. body, ioErr := ioutil.ReadAll(resp.Body)
  25680. if ioErr != nil {
  25681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25683. return
  25684. }
  25685. var respJSON map[string]interface{}
  25686. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25689. return
  25690. }
  25691. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25692. userJSONBytes, _ := json.Marshal(respJSON)
  25693. fmt.Println("log")
  25694. fmt.Println(string(userJSONBytes))
  25695. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25696. utils.ErrorLog("解析失败:%v", err)
  25697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25698. return
  25699. }
  25700. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25701. bytesData, _ := json.Marshal(data)
  25702. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25703. resp, _ := client.Do(req)
  25704. defer resp.Body.Close()
  25705. body, ioErr := ioutil.ReadAll(resp.Body)
  25706. if ioErr != nil {
  25707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25709. return
  25710. }
  25711. var respJSON map[string]interface{}
  25712. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25715. return
  25716. }
  25717. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25718. userJSONBytes, _ := json.Marshal(respJSON)
  25719. fmt.Println("log")
  25720. fmt.Println(string(userJSONBytes))
  25721. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25722. utils.ErrorLog("解析失败:%v", err)
  25723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25724. return
  25725. }
  25726. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25727. bytesData, _ := json.Marshal(data)
  25728. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25729. resp, _ := client.Do(req)
  25730. defer resp.Body.Close()
  25731. body, ioErr := ioutil.ReadAll(resp.Body)
  25732. if ioErr != nil {
  25733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25735. return
  25736. }
  25737. var respJSON map[string]interface{}
  25738. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25741. return
  25742. }
  25743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25744. userJSONBytes, _ := json.Marshal(respJSON)
  25745. fmt.Println("log")
  25746. fmt.Println(string(userJSONBytes))
  25747. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25748. utils.ErrorLog("解析失败:%v", err)
  25749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25750. return
  25751. }
  25752. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25753. bytesData, _ := json.Marshal(data)
  25754. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25755. resp, _ := client.Do(req)
  25756. defer resp.Body.Close()
  25757. body, ioErr := ioutil.ReadAll(resp.Body)
  25758. if ioErr != nil {
  25759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25761. return
  25762. }
  25763. var respJSON map[string]interface{}
  25764. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25767. return
  25768. }
  25769. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25770. userJSONBytes, _ := json.Marshal(respJSON)
  25771. fmt.Println("log")
  25772. fmt.Println(string(userJSONBytes))
  25773. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25774. utils.ErrorLog("解析失败:%v", err)
  25775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25776. return
  25777. }
  25778. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25779. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25780. if result3101.Infcode == "0" {
  25781. if len(result3101.Output.Result) > 0 {
  25782. var errMsgs []string
  25783. for _, item := range result3101.Output.Result {
  25784. errMsgs = append(errMsgs, item.VolaCont)
  25785. }
  25786. c.ServeSuccessJSON(map[string]interface{}{
  25787. "failed_code": -10,
  25788. "msg": errMsgs,
  25789. })
  25790. return
  25791. }
  25792. }
  25793. bytesData, _ := json.Marshal(data)
  25794. var req *http.Request
  25795. if miConfig.MdtrtareaAdmvs == "320921" {
  25796. data["diag_code"] = sickConfig.CountryCode
  25797. fmt.Println(data)
  25798. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25799. } else {
  25800. data["diag_code"] = sickConfig.CountryCode
  25801. fmt.Println(data)
  25802. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25803. }
  25804. resp, _ := client.Do(req)
  25805. defer resp.Body.Close()
  25806. body, ioErr := ioutil.ReadAll(resp.Body)
  25807. if ioErr != nil {
  25808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25810. return
  25811. }
  25812. var respJSON map[string]interface{}
  25813. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25816. return
  25817. }
  25818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25819. userJSONBytes, _ := json.Marshal(respJSON)
  25820. fmt.Println("log")
  25821. fmt.Println(string(userJSONBytes))
  25822. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25823. utils.ErrorLog("解析失败:%v", err)
  25824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25825. return
  25826. }
  25827. res.InfRefmsgid = resFour10265.InfRefmsgid
  25828. res.Output = resFour10265.Output
  25829. res.ErrMsg = resFour10265.ErrMsg
  25830. res.Cainfo = resFour10265.Cainfo
  25831. res.WarnMsg = resFour10265.WarnMsg
  25832. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25833. res.Infcode = infocode
  25834. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25835. var pagesize int = 2
  25836. var start int = 1
  25837. var stop int
  25838. var pagecount int
  25839. var curpage int
  25840. var isSuccess bool = true
  25841. data["doctor_id"] = doctor_info.DoctorNumber
  25842. //总页数,向上取整,注意除之前要先转换类型为float64
  25843. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25844. for curpage = 1; curpage <= pagecount; curpage++ {
  25845. if curpage == 1 {
  25846. start = 1
  25847. } else {
  25848. start = (curpage-1)*pagesize + 1
  25849. }
  25850. stop = curpage * pagesize
  25851. if stop > len(prescriptions) {
  25852. stop = len(prescriptions)
  25853. }
  25854. //var requestLog string
  25855. data["pre"] = prescriptions[start-1 : stop]
  25856. fmt.Println(data["pre"])
  25857. bytesData, _ := json.Marshal(data)
  25858. var req *http.Request
  25859. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25860. resp, _ := client.Do(req)
  25861. defer resp.Body.Close()
  25862. body, ioErr := ioutil.ReadAll(resp.Body)
  25863. if ioErr != nil {
  25864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25866. return
  25867. }
  25868. var respJSON map[string]interface{}
  25869. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25872. return
  25873. }
  25874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25875. userJSONBytes, _ := json.Marshal(respJSON)
  25876. fmt.Println("log")
  25877. fmt.Println(string(userJSONBytes))
  25878. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25879. utils.ErrorLog("解析失败:%v", err)
  25880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25881. return
  25882. }
  25883. res.InfRefmsgid = resFour10265.InfRefmsgid
  25884. res.Output = resFour10265.Output
  25885. res.ErrMsg = resFour10265.ErrMsg
  25886. res.Cainfo = resFour10265.Cainfo
  25887. res.WarnMsg = resFour10265.WarnMsg
  25888. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25889. res.Infcode = infocode
  25890. if infocode == 0 {
  25891. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25892. } else {
  25893. isSuccess = false
  25894. errlog := &models.HisOrderError{
  25895. UserOrgId: adminUser.CurrentOrgId,
  25896. Ctime: time.Now().Unix(),
  25897. Mtime: time.Now().Unix(),
  25898. Number: chrg_bchno,
  25899. ErrMsg: "",
  25900. Status: 1,
  25901. PatientId: id,
  25902. RecordTime: recordDateTime,
  25903. Stage: 4,
  25904. }
  25905. service.CreateErrMsgLog(errlog)
  25906. c.ServeSuccessJSON(map[string]interface{}{
  25907. "failed_code": -10,
  25908. "msg": res.ErrMsg,
  25909. })
  25910. return
  25911. }
  25912. }
  25913. if isSuccess {
  25914. res.Infcode = 0
  25915. }
  25916. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25917. 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)
  25918. var dat map[string]interface{}
  25919. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25920. fmt.Println(dat)
  25921. } else {
  25922. fmt.Println(err)
  25923. }
  25924. saveLog(result, request_log, "2204", "上传费用明细")
  25925. userJSONBytes, _ := json.Marshal(dat)
  25926. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25927. utils.ErrorLog("解析失败:%v", err)
  25928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25929. return
  25930. }
  25931. res.InfRefmsgid = resFour10265.InfRefmsgid
  25932. res.Output = resFour10265.Output
  25933. res.ErrMsg = resFour10265.ErrMsg
  25934. res.Cainfo = resFour10265.Cainfo
  25935. res.WarnMsg = resFour10265.WarnMsg
  25936. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25937. res.Infcode = infocode
  25938. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25939. bytesData, _ := json.Marshal(data)
  25940. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25941. resp, _ := client.Do(req)
  25942. defer resp.Body.Close()
  25943. body, ioErr := ioutil.ReadAll(resp.Body)
  25944. if ioErr != nil {
  25945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25947. return
  25948. }
  25949. var respJSON map[string]interface{}
  25950. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25953. return
  25954. }
  25955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25956. userJSONBytes, _ := json.Marshal(respJSON)
  25957. fmt.Println("log")
  25958. fmt.Println(string(userJSONBytes))
  25959. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25960. utils.ErrorLog("解析失败:%v", err)
  25961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25962. return
  25963. }
  25964. } else {
  25965. if miConfig.Code == "H15049901371" {
  25966. 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)
  25967. var dat map[string]interface{}
  25968. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25969. fmt.Println(dat)
  25970. } else {
  25971. fmt.Println(err)
  25972. }
  25973. saveLog(result, request_log, "2204", "上传费用明细")
  25974. userJSONBytes, _ := json.Marshal(dat)
  25975. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25976. utils.ErrorLog("解析失败:%v", err)
  25977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25978. return
  25979. }
  25980. res.InfRefmsgid = resFour10265.InfRefmsgid
  25981. res.Output = resFour10265.Output
  25982. res.ErrMsg = resFour10265.ErrMsg
  25983. res.Cainfo = resFour10265.Cainfo
  25984. res.WarnMsg = resFour10265.WarnMsg
  25985. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25986. res.Infcode = infocode
  25987. } else {
  25988. 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)
  25989. var dat map[string]interface{}
  25990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25991. fmt.Println(dat)
  25992. } else {
  25993. fmt.Println(err)
  25994. }
  25995. saveLog(result, request_log, "2204", "上传费用明细")
  25996. userJSONBytes, _ := json.Marshal(dat)
  25997. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25998. utils.ErrorLog("解析失败:%v", err)
  25999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26000. return
  26001. }
  26002. }
  26003. }
  26004. if res.Infcode == 0 {
  26005. order := &models.HisOrder{
  26006. UserOrgId: adminUser.CurrentOrgId,
  26007. HisPatientId: his.ID,
  26008. PatientId: his.PatientId,
  26009. SettleAccountsDate: recordDateTime,
  26010. MdtrtId: his.Number,
  26011. PsnNo: his.PsnNo,
  26012. MedType: strconv.FormatInt(reg_type, 10),
  26013. Ctime: time.Now().Unix(),
  26014. Mtime: time.Now().Unix(),
  26015. Status: 1,
  26016. Number: chrg_bchno,
  26017. Infcode: res.Infcode,
  26018. WarnMsg: res.WarnMsg,
  26019. Cainfo: res.Cainfo,
  26020. ErrMsg: res.ErrMsg,
  26021. RespondTime: res.RefmsgTime,
  26022. InfRefmsgid: res.InfRefmsgid,
  26023. OrderStatus: 1,
  26024. PayWay: pay_way,
  26025. PayWays: pay_ways,
  26026. OthDesc: oth_desc,
  26027. PayPrice: pay_price,
  26028. PayCardNo: pay_card_no,
  26029. DiscountPrice: discount_price,
  26030. PreferentialPrice: preferential_price,
  26031. RealityPrice: reality_price,
  26032. FoundPrice: found_price,
  26033. MedicalInsurancePrice: medical_insurance_price,
  26034. PrivatePrice: private_price,
  26035. IsMedicineInsurance: 1,
  26036. SettleType: settle_accounts_type,
  26037. SettleStartTime: start_time,
  26038. SettleEndTime: end_time,
  26039. Creator: roles.AdminUserId,
  26040. Modify: roles.AdminUserId,
  26041. FaPiaoNumber: fapiao_number,
  26042. FaPiaoCode: fapiao_code,
  26043. PType: 2,
  26044. Diagnosis: diagnosis_id,
  26045. CashPay: cash_pay,
  26046. WechatPay: wechat_pay,
  26047. AliPay: ali_pay,
  26048. JifenPay: jifen_pay,
  26049. BandCardPay: band_card_pay,
  26050. }
  26051. err = service.CreateOrder(order)
  26052. if err != nil {
  26053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  26054. return
  26055. }
  26056. for _, item := range res.Output.Result {
  26057. temp := strings.Split(item.FeedetlSn, "-")
  26058. var advice_id int64 = 0
  26059. var project_id int64 = 0
  26060. var types int64 = 0
  26061. id, _ := strconv.ParseInt(temp[2], 10, 64)
  26062. types, _ = strconv.ParseInt(temp[1], 10, 64)
  26063. if temp[1] == "1" {
  26064. advice_id = id
  26065. project_id = 0
  26066. } else if temp[1] == "2" {
  26067. advice_id = 0
  26068. project_id = id
  26069. }
  26070. if item.MedChrgitmType == "9" {
  26071. item.MedChrgitmType = "09"
  26072. }
  26073. info := &models.HisOrderInfo{
  26074. OrderNumber: order.Number,
  26075. FeedetlSn: item.FeedetlSn,
  26076. UploadDate: time.Now().Unix(),
  26077. AdviceId: advice_id,
  26078. DetItemFeeSumamt: item.DetItemFeeSumamt,
  26079. Cnt: item.Cnt,
  26080. Pric: float64(item.Pric),
  26081. PatientId: his.PatientId,
  26082. PricUplmtAmt: item.PricUplmtAmt,
  26083. SelfpayProp: item.SelfpayProp,
  26084. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  26085. OverlmtAmt: item.OverlmtAmt,
  26086. PreselfpayAmt: item.PreselfpayAmt,
  26087. BasMednFlag: item.BasMednFlag,
  26088. MedChrgitmType: item.MedChrgitmType,
  26089. HiNegoDrugFlag: item.HiNegoDrugFlag,
  26090. Status: 1,
  26091. Memo: item.Memo,
  26092. Mtime: time.Now().Unix(),
  26093. InscpScpAmt: item.InscpScpAmt,
  26094. DrtReimFlag: item.DrtReimFlag,
  26095. Ctime: time.Now().Unix(),
  26096. ListSpItemFlag: item.ListSpItemFlag,
  26097. ChldMedcFlag: item.ChldMedcFlag,
  26098. LmtUsedFlag: item.LmtUsedFlag,
  26099. ChrgitmLv: item.ChrgitmLv,
  26100. UserOrgId: adminUser.CurrentOrgId,
  26101. HisPatientId: his.ID,
  26102. OrderId: order.ID,
  26103. ProjectId: project_id,
  26104. Type: types,
  26105. }
  26106. service.CreateOrderInfo(info)
  26107. }
  26108. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  26109. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  26110. var total float64
  26111. for _, item := range prescriptions {
  26112. if item.Type == 1 { //药品
  26113. for _, subItem := range item.HisDoctorAdviceInfo {
  26114. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26115. total_one := price * subItem.PrescribingNumber
  26116. total = total + total_one
  26117. }
  26118. }
  26119. if item.Type == 2 { //项目
  26120. for _, subItem := range item.HisPrescriptionProject {
  26121. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  26122. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26123. total_one := price * cnt
  26124. total = total + total_one
  26125. }
  26126. }
  26127. }
  26128. allTotal := fmt.Sprintf("%.2f", total)
  26129. //if adminUser.CurrentOrgId == 9919 {
  26130. //
  26131. // allTotal = fmt.Sprintf("%.2f", total)
  26132. //
  26133. //} else {
  26134. //
  26135. // allTotal = fmt.Sprintf("%.2f", total)
  26136. //
  26137. //}
  26138. if res.Infcode == 0 {
  26139. var rf []*ResultFive
  26140. json.Unmarshal([]byte(his.Iinfo), &rf)
  26141. chrg_bchno := chrg_bchno
  26142. cert_no := his.Certno
  26143. var insutypes []string
  26144. var insutype string
  26145. var is390 int = 0
  26146. var is310 int = 0
  26147. for _, item := range rf {
  26148. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26149. insutypes = append(insutypes, item.Insutype)
  26150. }
  26151. }
  26152. if len(insutypes) == 1 {
  26153. insutype = insutypes[0]
  26154. } else {
  26155. for _, i := range insutypes {
  26156. if i == "390" {
  26157. is390 = 1
  26158. }
  26159. if i == "310" {
  26160. is310 = 1
  26161. }
  26162. }
  26163. }
  26164. if is390 == 1 {
  26165. insutype = "390"
  26166. }
  26167. if is310 == 1 {
  26168. insutype = "310"
  26169. }
  26170. if len(insutypes) == 0 {
  26171. insutype = "310"
  26172. }
  26173. if len(insutypes) == 2 {
  26174. insutype = strconv.FormatInt(his.SocialType, 10)
  26175. }
  26176. insutype = strconv.FormatInt(his.SocialType, 10)
  26177. //insutype = "390"
  26178. if his.IdCardType == 1 {
  26179. // cert_no = his.MedicalInsuranceNumber
  26180. cert_no = his.Certno
  26181. } else {
  26182. cert_no = his.Certno
  26183. }
  26184. var res ResultSeven
  26185. var resSeven10265 ResultSeven10265
  26186. var gzresSeven10265Two GZResultSeven10265Two
  26187. var src_resquest string
  26188. var result2 string
  26189. if miConfig.MdtrtareaAdmvs == "421300" {
  26190. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26191. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26192. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26193. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26194. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26195. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26196. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26197. resp, requestErr := http.Get(api)
  26198. if requestErr != nil {
  26199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26200. return
  26201. }
  26202. body, ioErr := ioutil.ReadAll(resp.Body)
  26203. if ioErr != nil {
  26204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26206. return
  26207. }
  26208. var respJSON map[string]interface{}
  26209. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26212. return
  26213. }
  26214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26215. result, _ := json.Marshal(respJSON)
  26216. if miConfig.Code == "H15049901371" {
  26217. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26218. utils.ErrorLog("解析失败:%v", err)
  26219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26220. return
  26221. }
  26222. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26223. res.Output = resSeven10265.Output
  26224. res.ErrMsg = resSeven10265.ErrMsg
  26225. res.Cainfo = resSeven10265.Cainfo
  26226. res.WarnMsg = resSeven10265.WarnMsg
  26227. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26228. res.Infcode = infocode
  26229. } else {
  26230. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26231. utils.ErrorLog("解析失败:%v", err)
  26232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26233. return
  26234. }
  26235. }
  26236. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26237. if reg_type == 11 && his.Insutype == "390" {
  26238. reg_type = 110104
  26239. }
  26240. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26241. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26242. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26243. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26244. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26245. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26246. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26247. resp, requestErr := http.Get(api)
  26248. if requestErr != nil {
  26249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26250. return
  26251. }
  26252. body, ioErr := ioutil.ReadAll(resp.Body)
  26253. if ioErr != nil {
  26254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26256. return
  26257. }
  26258. var respJSON map[string]interface{}
  26259. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26262. return
  26263. }
  26264. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26265. result, _ := json.Marshal(respJSON)
  26266. if miConfig.Code == "H15049901371" {
  26267. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26268. utils.ErrorLog("解析失败:%v", err)
  26269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26270. return
  26271. }
  26272. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26273. res.Output = resSeven10265.Output
  26274. res.ErrMsg = resSeven10265.ErrMsg
  26275. res.Cainfo = resSeven10265.Cainfo
  26276. res.WarnMsg = resSeven10265.WarnMsg
  26277. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26278. res.Infcode = infocode
  26279. } else {
  26280. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26281. utils.ErrorLog("解析失败:%v", err)
  26282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26283. return
  26284. }
  26285. }
  26286. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26287. if reg_type == 11 && his.Insutype == "390" {
  26288. reg_type = 110104
  26289. }
  26290. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26291. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26292. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26293. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26294. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26295. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26296. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26297. resp, requestErr := http.Get(api)
  26298. if requestErr != nil {
  26299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26300. return
  26301. }
  26302. body, ioErr := ioutil.ReadAll(resp.Body)
  26303. if ioErr != nil {
  26304. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26306. return
  26307. }
  26308. var respJSON map[string]interface{}
  26309. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26312. return
  26313. }
  26314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26315. result, _ := json.Marshal(respJSON)
  26316. if miConfig.Code == "H15049901371" {
  26317. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26318. utils.ErrorLog("解析失败:%v", err)
  26319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26320. return
  26321. }
  26322. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26323. res.Output = resSeven10265.Output
  26324. res.ErrMsg = resSeven10265.ErrMsg
  26325. res.Cainfo = resSeven10265.Cainfo
  26326. res.WarnMsg = resSeven10265.WarnMsg
  26327. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26328. res.Infcode = infocode
  26329. } else {
  26330. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26331. utils.ErrorLog("解析失败:%v", err)
  26332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26333. return
  26334. }
  26335. }
  26336. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26337. if reg_type == 11 && his.Insutype == "390" {
  26338. reg_type = 110104
  26339. }
  26340. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26341. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26342. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26343. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26344. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26345. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26346. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26347. resp, requestErr := http.Get(api)
  26348. if requestErr != nil {
  26349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26350. return
  26351. }
  26352. body, ioErr := ioutil.ReadAll(resp.Body)
  26353. if ioErr != nil {
  26354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26356. return
  26357. }
  26358. var respJSON map[string]interface{}
  26359. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26362. return
  26363. }
  26364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26365. result, _ := json.Marshal(respJSON)
  26366. if miConfig.Code == "H15049901371" {
  26367. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26368. utils.ErrorLog("解析失败:%v", err)
  26369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26370. return
  26371. }
  26372. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26373. res.Output = resSeven10265.Output
  26374. res.ErrMsg = resSeven10265.ErrMsg
  26375. res.Cainfo = resSeven10265.Cainfo
  26376. res.WarnMsg = resSeven10265.WarnMsg
  26377. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26378. res.Infcode = infocode
  26379. } else {
  26380. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26381. utils.ErrorLog("解析失败:%v", err)
  26382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26383. return
  26384. }
  26385. }
  26386. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26387. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26388. if result3101.Infcode == "0" {
  26389. if len(result3101.Output.Result) > 0 {
  26390. var errMsgs []string
  26391. for _, item := range result3101.Output.Result {
  26392. errMsgs = append(errMsgs, item.VolaCont)
  26393. }
  26394. c.ServeSuccessJSON(map[string]interface{}{
  26395. "failed_code": -10,
  26396. "msg": errMsgs,
  26397. })
  26398. return
  26399. } else {
  26400. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26401. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26402. bas := strings.Split(psn_info.CardInfo, "|")
  26403. if his.IdCardType == 1 {
  26404. cert_no = bas[2]
  26405. } else if his.IdCardType == 3 {
  26406. cert_no = his.Certno
  26407. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26408. } else if his.IdCardType == 4 {
  26409. cert_no = his.Certno
  26410. psn_info.VerifyNumber = psn_info.VerifyNumber
  26411. }
  26412. var api string
  26413. if miConfig.MdtrtareaAdmvs == "320921" {
  26414. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26415. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26416. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26417. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26418. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26419. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26420. "&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
  26421. } else {
  26422. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26423. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26424. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26425. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26426. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26427. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26428. "&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
  26429. }
  26430. resp, requestErr := http.Get(api)
  26431. if requestErr != nil {
  26432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26433. return
  26434. }
  26435. body, ioErr := ioutil.ReadAll(resp.Body)
  26436. if ioErr != nil {
  26437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26439. return
  26440. }
  26441. var respJSON map[string]interface{}
  26442. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26445. return
  26446. }
  26447. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26448. result, _ := json.Marshal(respJSON)
  26449. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26450. utils.ErrorLog("解析失败:%v", err)
  26451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26452. return
  26453. }
  26454. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26455. res.Output = resSeven10265.Output
  26456. res.ErrMsg = resSeven10265.ErrMsg
  26457. res.Cainfo = resSeven10265.Cainfo
  26458. res.WarnMsg = resSeven10265.WarnMsg
  26459. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26460. res.Infcode = infocode
  26461. }
  26462. }
  26463. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26464. psn_info, _ := service.GetPsnByPatientId(id)
  26465. var verify_number string
  26466. if psn_info.IdCardType == 4 {
  26467. verify_number = psn_info.VerifyNumber
  26468. } else if psn_info.IdCardType == 1 {
  26469. bas := strings.Split(psn_info.CardInfo, "|")
  26470. cardNumber := bas[2]
  26471. verify_number = cardNumber
  26472. } else {
  26473. psn_info.IdCardType = 2
  26474. verify_number = psn_info.Certno
  26475. }
  26476. var api string
  26477. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26478. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26479. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26480. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26481. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26482. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26483. "&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
  26484. resp, requestErr := http.Get(api)
  26485. if requestErr != nil {
  26486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26487. return
  26488. }
  26489. body, ioErr := ioutil.ReadAll(resp.Body)
  26490. if ioErr != nil {
  26491. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26493. return
  26494. }
  26495. var respJSON map[string]interface{}
  26496. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26499. return
  26500. }
  26501. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26502. result, _ := json.Marshal(respJSON)
  26503. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26504. utils.ErrorLog("解析失败:%v", err)
  26505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26506. return
  26507. }
  26508. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26509. res.Output = resSeven10265.Output
  26510. res.ErrMsg = resSeven10265.ErrMsg
  26511. res.Cainfo = resSeven10265.Cainfo
  26512. res.WarnMsg = resSeven10265.WarnMsg
  26513. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26514. res.Infcode = infocode
  26515. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26516. var cert_no string
  26517. if his.IdCardType == 4 {
  26518. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26519. cert_no = psn_info.VerifyNumber
  26520. 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)
  26521. } else if his.IdCardType == 1 {
  26522. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26523. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26524. 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)
  26525. }
  26526. //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)
  26527. var dat map[string]interface{}
  26528. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26529. fmt.Println(dat)
  26530. } else {
  26531. fmt.Println(err)
  26532. }
  26533. saveLog(result2, src_resquest, "2207", "结算")
  26534. userJSONBytes, _ := json.Marshal(dat)
  26535. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26536. utils.ErrorLog("解析失败:%v", err)
  26537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26538. return
  26539. }
  26540. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26541. res.Output = resSeven10265.Output
  26542. res.ErrMsg = resSeven10265.ErrMsg
  26543. res.Cainfo = resSeven10265.Cainfo
  26544. res.WarnMsg = resSeven10265.WarnMsg
  26545. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26546. res.Infcode = infocode
  26547. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26548. res2 := c.GetoleInfo()
  26549. if res2.Infcode == 0 {
  26550. var result string
  26551. var request_log string
  26552. var result_log string
  26553. if res2.Output.MdtrtCertType == "02" {
  26554. 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)
  26555. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26556. } else if res2.Output.MdtrtCertType == "01" {
  26557. 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)
  26558. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26559. } else {
  26560. 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)
  26561. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26562. }
  26563. var dat map[string]interface{}
  26564. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26565. fmt.Println(dat)
  26566. } else {
  26567. fmt.Println(err)
  26568. }
  26569. userJSONBytes, _ := json.Marshal(dat)
  26570. var res5 ResultTwo
  26571. //var resTwo10265 ResultTwo10265
  26572. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26573. utils.ErrorLog("解析失败:%v", err)
  26574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26575. return
  26576. }
  26577. if res5.Infcode == -1 {
  26578. c.ServeSuccessJSON(map[string]interface{}{
  26579. "failed_code": -10,
  26580. "msg": res5.ErrMsg,
  26581. })
  26582. return
  26583. }
  26584. var insutypes []string
  26585. var insutype string
  26586. var is390 int = 0
  26587. var is310 int = 0
  26588. for _, item := range res5.Output.Iinfo {
  26589. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26590. insutypes = append(insutypes, item.Insutype)
  26591. }
  26592. }
  26593. if len(insutypes) == 1 {
  26594. insutype = insutypes[0]
  26595. } else {
  26596. for _, i := range insutypes {
  26597. if i == "390" {
  26598. is390 = 1
  26599. }
  26600. if i == "310" {
  26601. is310 = 1
  26602. }
  26603. }
  26604. }
  26605. if is390 == 1 {
  26606. insutype = "390"
  26607. }
  26608. if is310 == 1 {
  26609. insutype = "310"
  26610. }
  26611. if len(insutypes) == 0 {
  26612. insutype = "310"
  26613. }
  26614. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26615. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26616. infoStr := string(Iinfos)
  26617. idetinfoStr := string(Idetinfos)
  26618. psn := &models.HisPsn{
  26619. PsnNo: res5.Output.Baseinfo.PsnNo,
  26620. PatientId: id,
  26621. Certno: res5.Output.Baseinfo.Certno,
  26622. Gend: res5.Output.Baseinfo.Gend,
  26623. Naty: res5.Output.Baseinfo.Naty,
  26624. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26625. PsnName: res5.Output.Baseinfo.PsnName,
  26626. Idetinfo: idetinfoStr,
  26627. Insuinfo: infoStr,
  26628. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26629. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26630. VerifyNumber: res2.Output.EcToken,
  26631. }
  26632. if res2.Output.MdtrtCertType == "01" {
  26633. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26634. psn.VerifyNumber = res2.Output.EcToken
  26635. } else if res2.Output.MdtrtCertType == "02" {
  26636. psn.VerifyNumber = res2.Output.CardNo
  26637. } else {
  26638. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26639. }
  26640. service.CreateHisPsn(psn)
  26641. if res2.Output.MdtrtCertType == "01" {
  26642. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26643. token := res2.Output.EcToken
  26644. 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)
  26645. } else if res2.Output.MdtrtCertType == "02" {
  26646. 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)
  26647. } else {
  26648. 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)
  26649. }
  26650. var dat2 map[string]interface{}
  26651. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26652. fmt.Println(dat2)
  26653. } else {
  26654. fmt.Println(err)
  26655. }
  26656. userJSONBytes3, _ := json.Marshal(dat2)
  26657. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26658. utils.ErrorLog("解析失败:%v", err)
  26659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26660. return
  26661. }
  26662. saveLog(result2, src_resquest, "2207", "结算")
  26663. } else {
  26664. c.ServeSuccessJSON(map[string]interface{}{
  26665. "failed_code": -10,
  26666. "msg": res2.ErrMsg,
  26667. })
  26668. return
  26669. }
  26670. } else {
  26671. if miConfig.Code == "H15049901371" {
  26672. //赤峰地区国家医保医疗类别
  26673. //职工透析:医疗类别选特殊情况门诊990502
  26674. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26675. var med_type string
  26676. if his.Insutype == "390" {
  26677. if reg_type == 14 {
  26678. med_type = "9933"
  26679. } else if reg_type == 11 {
  26680. med_type = "11"
  26681. }
  26682. } else if his.Insutype == "310" {
  26683. if reg_type == 14 {
  26684. med_type = "990502"
  26685. } else if reg_type == 11 {
  26686. med_type = "11"
  26687. }
  26688. }
  26689. 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)
  26690. } else {
  26691. if his.IdCardType == 4 {
  26692. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26693. var token string
  26694. token = psn_info.VerifyNumber
  26695. 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)
  26696. } else {
  26697. if his.IdCardType == 1 {
  26698. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26699. bas := strings.Split(psn_info.CardInfo, "|")
  26700. basNumber := bas[2]
  26701. cert_no = basNumber
  26702. }
  26703. 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)
  26704. }
  26705. }
  26706. //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)
  26707. var dat map[string]interface{}
  26708. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26709. fmt.Println(dat)
  26710. } else {
  26711. fmt.Println(err)
  26712. }
  26713. saveLog(result2, src_resquest, "2207", "结算")
  26714. userJSONBytes, _ := json.Marshal(dat)
  26715. if miConfig.Code == "H15049901371" {
  26716. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26717. utils.ErrorLog("解析失败:%v", err)
  26718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26719. return
  26720. }
  26721. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26722. res.Output = resSeven10265.Output
  26723. res.ErrMsg = resSeven10265.ErrMsg
  26724. res.Cainfo = resSeven10265.Cainfo
  26725. res.WarnMsg = resSeven10265.WarnMsg
  26726. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26727. res.Infcode = infocode
  26728. } else {
  26729. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26730. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26731. utils.ErrorLog("解析失败:%v", err)
  26732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26733. return
  26734. }
  26735. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26736. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26737. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26738. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26739. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26740. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26741. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26742. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26743. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26744. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26745. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26746. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26747. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26748. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26749. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26750. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26751. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26752. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26753. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26754. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26755. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26756. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26757. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26758. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26759. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26760. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26761. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26762. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26763. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26764. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26765. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26766. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26767. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26768. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26769. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26770. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26771. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26772. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26773. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26774. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26775. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26776. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26777. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26778. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26779. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26780. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26781. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26782. res.Cainfo = gzresSeven10265Two.Cainfo
  26783. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26784. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26785. //res.Infcode = infocode
  26786. } else {
  26787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26788. utils.ErrorLog("解析失败:%v", err)
  26789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26790. return
  26791. }
  26792. }
  26793. }
  26794. }
  26795. if res.Infcode == -1 {
  26796. errlog := &models.HisOrderError{
  26797. UserOrgId: adminUser.CurrentOrgId,
  26798. Ctime: time.Now().Unix(),
  26799. Mtime: time.Now().Unix(),
  26800. Number: chrg_bchno,
  26801. ErrMsg: res.ErrMsg,
  26802. Status: 1,
  26803. PatientId: id,
  26804. RecordTime: recordDateTime,
  26805. Stage: 6,
  26806. }
  26807. service.CreateErrMsgLog(errlog)
  26808. c.ServeSuccessJSON(map[string]interface{}{
  26809. "failed_code": -10,
  26810. "msg": res.ErrMsg,
  26811. })
  26812. return
  26813. } else {
  26814. sickConfig, _ := service.FindSickById(his.SickType)
  26815. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26816. order.OrderStatus = 2
  26817. order.Status = 1
  26818. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26819. order.SetlId = res.Output.Setlinfo.SetlID
  26820. order.PsnNo = res.Output.Setlinfo.PsnNo
  26821. order.PsnName = res.Output.Setlinfo.PsnName
  26822. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26823. order.Certno = res.Output.Setlinfo.Certno
  26824. order.Gend = res.Output.Setlinfo.Gend
  26825. order.Naty = res.Output.Setlinfo.Naty
  26826. order.Age = res.Output.Setlinfo.Age
  26827. order.Insutype = res.Output.Setlinfo.Insutype
  26828. order.PsnType = res.Output.Setlinfo.PsnType
  26829. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26830. order.SetlTime = res.Output.Setlinfo.SetlTime
  26831. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26832. if res.Output.Setlinfo.MedType == "140101" {
  26833. order.MedType = "14"
  26834. } else {
  26835. if res.Output.Setlinfo.MedType == "110104" {
  26836. order.MedType = "11"
  26837. } else {
  26838. order.MedType = res.Output.Setlinfo.MedType
  26839. }
  26840. }
  26841. if reg_type == 1112 {
  26842. order.MedType = "1112"
  26843. }
  26844. if reg_type == 1111 {
  26845. order.MedType = "1111"
  26846. }
  26847. order.ClrType = res.Output.Setlinfo.ClrType
  26848. if adminUser.CurrentOrgId == 10480 {
  26849. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26850. order.ClrType = "11"
  26851. } else {
  26852. order.ClrType = "9903"
  26853. }
  26854. }
  26855. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26856. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26857. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26858. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26859. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26860. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26861. order.HifpPay = res.Output.Setlinfo.HifpPay
  26862. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26863. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26864. order.HifesPay = res.Output.Setlinfo.HifesPay
  26865. order.HifobPay = res.Output.Setlinfo.HifobPay
  26866. order.MafPay = res.Output.Setlinfo.MafPay
  26867. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26868. order.OthPay = res.Output.Setlinfo.OthPay
  26869. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26870. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26871. order.AcctPay = res.Output.Setlinfo.AcctPay
  26872. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26873. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26874. order.Balc = res.Output.Setlinfo.Balc
  26875. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26876. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26877. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26878. //order.ClrType = res.Output.Setlinfo.ClrType
  26879. order.ClrWay = res.Output.Setlinfo.ClrWay
  26880. order.Creator = order.Creator
  26881. order.Modify = roles.AdminUserId
  26882. order.RequestLog = src_resquest
  26883. order.FaPiaoNumber = fapiao_number
  26884. order.FaPiaoCode = fapiao_code
  26885. order.SickName = sickConfig.ClassName
  26886. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26887. //detailStr := string(setlDetail)
  26888. //order.SetlDetail = detailStr
  26889. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26890. err = service.UpDateOrder(order)
  26891. if err == nil {
  26892. //判断是否使用了押金
  26893. if dec_way == "true" {
  26894. tmpstring := strconv.FormatInt(order.ID, 10)
  26895. order.Decimal = decimal
  26896. service.UpDateOrder(order)
  26897. //扣押金
  26898. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26899. if errmsg != nil {
  26900. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26901. return
  26902. }
  26903. }
  26904. c.ServeSuccessJSON(map[string]interface{}{
  26905. "msg": "结算成功",
  26906. })
  26907. } else {
  26908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26909. return
  26910. }
  26911. }
  26912. } else {
  26913. adminUser := c.GetAdminUserInfo()
  26914. errlog := &models.HisOrderError{
  26915. UserOrgId: adminUser.CurrentOrgId,
  26916. Ctime: time.Now().Unix(),
  26917. Mtime: time.Now().Unix(),
  26918. ErrMsg: res.ErrMsg,
  26919. Status: 1,
  26920. PatientId: id,
  26921. RecordTime: recordDateTime,
  26922. Stage: 4,
  26923. }
  26924. service.CreateErrMsgLog(errlog)
  26925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26926. return
  26927. }
  26928. } else {
  26929. adminUser := c.GetAdminUserInfo()
  26930. errlog := &models.HisOrderError{
  26931. UserOrgId: adminUser.CurrentOrgId,
  26932. Ctime: time.Now().Unix(),
  26933. Mtime: time.Now().Unix(),
  26934. ErrMsg: res.ErrMsg,
  26935. Status: 1,
  26936. PatientId: id,
  26937. RecordTime: recordDateTime,
  26938. Stage: 4,
  26939. }
  26940. service.CreateErrMsgLog(errlog)
  26941. c.ServeSuccessJSON(map[string]interface{}{
  26942. "failed_code": -10,
  26943. "msg": res.ErrMsg,
  26944. })
  26945. return
  26946. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26947. //return
  26948. }
  26949. }
  26950. }
  26951. } else if tempOrder.ID > 0 {
  26952. if tempOrder.IsPre == 1 {
  26953. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26954. var rf []*ResultFive
  26955. json.Unmarshal([]byte(his.Iinfo), &rf)
  26956. chrg_bchno := tempOrder.Number
  26957. cert_no := his.Certno
  26958. var insutypes []string
  26959. var insutype string
  26960. var is390 int = 0
  26961. var is310 int = 0
  26962. for _, item := range rf {
  26963. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26964. insutypes = append(insutypes, item.Insutype)
  26965. }
  26966. }
  26967. if len(insutypes) == 1 {
  26968. insutype = insutypes[0]
  26969. } else {
  26970. for _, i := range insutypes {
  26971. if i == "390" {
  26972. is390 = 1
  26973. }
  26974. if i == "310" {
  26975. is310 = 1
  26976. }
  26977. }
  26978. }
  26979. if is390 == 1 {
  26980. insutype = "390"
  26981. }
  26982. if is310 == 1 {
  26983. insutype = "310"
  26984. }
  26985. if len(insutypes) == 0 {
  26986. insutype = "310"
  26987. }
  26988. if len(insutypes) == 2 {
  26989. insutype = strconv.FormatInt(his.SocialType, 10)
  26990. }
  26991. //insutype = "390"
  26992. if his.IdCardType == 1 {
  26993. // cert_no = his.MedicalInsuranceNumber
  26994. cert_no = his.Certno
  26995. } else {
  26996. cert_no = his.Certno
  26997. }
  26998. var res ResultSeven
  26999. var ahres ResultSevenAH
  27000. var resSeven10265 ResultSeven10265
  27001. var gzresSeven10265Two GZResultSeven10265Two
  27002. var src_resquest string
  27003. var result2 string
  27004. if miConfig.MdtrtareaAdmvs == "450721" {
  27005. res2 := c.GetoleInfo()
  27006. if res2.Infcode == 0 {
  27007. var result string
  27008. var request_log string
  27009. var result_log string
  27010. if res2.Output.MdtrtCertType == "02" {
  27011. 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)
  27012. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27013. } else if res2.Output.MdtrtCertType == "01" {
  27014. 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)
  27015. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27016. } else {
  27017. 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)
  27018. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27019. }
  27020. var dat map[string]interface{}
  27021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27022. fmt.Println(dat)
  27023. } else {
  27024. fmt.Println(err)
  27025. }
  27026. userJSONBytes, _ := json.Marshal(dat)
  27027. var res5 ResultTwo
  27028. //var resTwo10265 ResultTwo10265
  27029. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27030. utils.ErrorLog("解析失败:%v", err)
  27031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27032. return
  27033. }
  27034. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  27035. if res5.Infcode == -1 {
  27036. c.ServeSuccessJSON(map[string]interface{}{
  27037. "failed_code": -10,
  27038. "msg": res5.ErrMsg,
  27039. })
  27040. return
  27041. }
  27042. var insutypes []string
  27043. var insutype string
  27044. var is390 int = 0
  27045. var is310 int = 0
  27046. for _, item := range res5.Output.Iinfo {
  27047. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27048. insutypes = append(insutypes, item.Insutype)
  27049. }
  27050. }
  27051. if len(insutypes) == 1 {
  27052. insutype = insutypes[0]
  27053. } else {
  27054. for _, i := range insutypes {
  27055. if i == "390" {
  27056. is390 = 1
  27057. }
  27058. if i == "310" {
  27059. is310 = 1
  27060. }
  27061. }
  27062. }
  27063. if is390 == 1 {
  27064. insutype = "390"
  27065. }
  27066. if is310 == 1 {
  27067. insutype = "310"
  27068. }
  27069. if len(insutypes) == 0 {
  27070. insutype = "310"
  27071. }
  27072. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27073. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27074. infoStr := string(Iinfos)
  27075. idetinfoStr := string(Idetinfos)
  27076. psn := &models.HisPsn{
  27077. PsnNo: res5.Output.Baseinfo.PsnNo,
  27078. PatientId: id,
  27079. Certno: res5.Output.Baseinfo.Certno,
  27080. Gend: res5.Output.Baseinfo.Gend,
  27081. Naty: res5.Output.Baseinfo.Naty,
  27082. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27083. PsnName: res5.Output.Baseinfo.PsnName,
  27084. Idetinfo: idetinfoStr,
  27085. Insuinfo: infoStr,
  27086. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27087. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27088. VerifyNumber: res2.Output.EcToken,
  27089. }
  27090. service.CreateHisPsn(psn)
  27091. if res2.Output.MdtrtCertType == "01" {
  27092. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27093. token := res2.Output.EcToken
  27094. 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)
  27095. } else if res2.Output.MdtrtCertType == "02" {
  27096. 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)
  27097. } else {
  27098. 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)
  27099. }
  27100. var dat2 map[string]interface{}
  27101. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27102. fmt.Println(dat2)
  27103. } else {
  27104. fmt.Println(err)
  27105. }
  27106. userJSONBytes3, _ := json.Marshal(dat2)
  27107. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27108. utils.ErrorLog("解析失败:%v", err)
  27109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27110. return
  27111. }
  27112. saveLog(result2, src_resquest, "2207", "结算")
  27113. } else {
  27114. c.ServeSuccessJSON(map[string]interface{}{
  27115. "failed_code": -10,
  27116. "msg": res2.ErrMsg,
  27117. })
  27118. return
  27119. }
  27120. } else if miConfig.MdtrtareaAdmvs == "421300" {
  27121. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27122. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27123. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27124. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27125. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27126. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27127. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27128. resp, requestErr := http.Get(api)
  27129. if requestErr != nil {
  27130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27131. return
  27132. }
  27133. body, ioErr := ioutil.ReadAll(resp.Body)
  27134. if ioErr != nil {
  27135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27137. return
  27138. }
  27139. var respJSON map[string]interface{}
  27140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27143. return
  27144. }
  27145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27146. result, _ := json.Marshal(respJSON)
  27147. fmt.Println("log")
  27148. fmt.Println(string(result))
  27149. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27150. utils.ErrorLog("解析失败:%v", err)
  27151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27152. return
  27153. }
  27154. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27155. if reg_type == 11 && his.Insutype == "390" {
  27156. reg_type = 110104
  27157. }
  27158. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27159. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27160. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27161. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27162. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27163. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27164. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27165. resp, requestErr := http.Get(api)
  27166. if requestErr != nil {
  27167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27168. return
  27169. }
  27170. body, ioErr := ioutil.ReadAll(resp.Body)
  27171. if ioErr != nil {
  27172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27174. return
  27175. }
  27176. var respJSON map[string]interface{}
  27177. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27180. return
  27181. }
  27182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27183. result, _ := json.Marshal(respJSON)
  27184. fmt.Println("log")
  27185. fmt.Println(string(result))
  27186. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27187. utils.ErrorLog("解析失败:%v", err)
  27188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27189. return
  27190. }
  27191. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27192. if reg_type == 11 && his.Insutype == "390" {
  27193. reg_type = 110104
  27194. }
  27195. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27196. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27197. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27198. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27199. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27200. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27201. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27202. resp, requestErr := http.Get(api)
  27203. if requestErr != nil {
  27204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27205. return
  27206. }
  27207. body, ioErr := ioutil.ReadAll(resp.Body)
  27208. if ioErr != nil {
  27209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27211. return
  27212. }
  27213. var respJSON map[string]interface{}
  27214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27217. return
  27218. }
  27219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27220. result, _ := json.Marshal(respJSON)
  27221. fmt.Println("log")
  27222. fmt.Println(string(result))
  27223. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27224. utils.ErrorLog("解析失败:%v", err)
  27225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27226. return
  27227. }
  27228. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27229. if reg_type == 11 && his.Insutype == "390" {
  27230. reg_type = 110104
  27231. }
  27232. api := miConfig.Url + "hbyb/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=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27257. result, _ := json.Marshal(respJSON)
  27258. fmt.Println("log")
  27259. fmt.Println(string(result))
  27260. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27261. utils.ErrorLog("解析失败:%v", err)
  27262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27263. return
  27264. }
  27265. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27266. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27267. if result3101.Infcode == "0" {
  27268. if len(result3101.Output.Result) > 0 {
  27269. var errMsgs []string
  27270. for _, item := range result3101.Output.Result {
  27271. errMsgs = append(errMsgs, item.VolaCont)
  27272. }
  27273. c.ServeSuccessJSON(map[string]interface{}{
  27274. "failed_code": -10,
  27275. "msg": errMsgs,
  27276. })
  27277. return
  27278. } else {
  27279. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27280. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27281. bas := strings.Split(psn_info.CardInfo, "|")
  27282. if his.IdCardType == 1 {
  27283. cert_no = bas[2]
  27284. } else if his.IdCardType == 3 {
  27285. cert_no = his.Certno
  27286. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27287. } else if his.IdCardType == 4 {
  27288. cert_no = his.Certno
  27289. psn_info.VerifyNumber = psn_info.VerifyNumber
  27290. }
  27291. //江苏地区国家医保医疗类别
  27292. //职工透析:医疗类别选特殊情况门诊9933
  27293. //居民血透门慢: 医疗类别选门诊慢病1402
  27294. //var med_type string
  27295. //if his.Insutype == "310" {
  27296. // if reg_type == 14 {
  27297. // med_type = "9933"
  27298. // } else if reg_type == 11 {
  27299. // med_type = "11"
  27300. //
  27301. // }
  27302. //} else if his.Insutype == "390" {
  27303. // if reg_type == 14 {
  27304. // med_type = "1402"
  27305. // } else if reg_type == 11 {
  27306. // med_type = "11"
  27307. // }
  27308. //}
  27309. var api string
  27310. if miConfig.MdtrtareaAdmvs == "320921" {
  27311. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27312. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27313. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27314. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27315. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27316. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27317. "&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
  27318. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27319. } else {
  27320. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27321. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27322. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27323. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27324. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27325. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27326. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27327. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + 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
  27328. }
  27329. resp, requestErr := http.Get(api)
  27330. if requestErr != nil {
  27331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27332. return
  27333. }
  27334. body, ioErr := ioutil.ReadAll(resp.Body)
  27335. if ioErr != nil {
  27336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27338. return
  27339. }
  27340. var respJSON map[string]interface{}
  27341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27344. return
  27345. }
  27346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27347. result, _ := json.Marshal(respJSON)
  27348. fmt.Println("log")
  27349. fmt.Println(string(result))
  27350. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27351. utils.ErrorLog("解析失败:%v", err)
  27352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27353. return
  27354. }
  27355. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27356. res.Output = resSeven10265.Output
  27357. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27358. res.ErrMsg = resSeven10265.ErrMsg
  27359. res.Cainfo = resSeven10265.Cainfo
  27360. res.WarnMsg = resSeven10265.WarnMsg
  27361. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27362. res.Infcode = infocode
  27363. }
  27364. }
  27365. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27366. psn_info, _ := service.GetPsnByPatientId(id)
  27367. var verify_number string
  27368. if psn_info.IdCardType == 4 {
  27369. verify_number = psn_info.VerifyNumber
  27370. } else if psn_info.IdCardType == 1 {
  27371. bas := strings.Split(psn_info.CardInfo, "|")
  27372. cardNumber := bas[2]
  27373. verify_number = cardNumber
  27374. } else {
  27375. verify_number = psn_info.Certno
  27376. psn_info.IdCardType = 2
  27377. }
  27378. var api string
  27379. new_chrg_bchno := chrg_bchno
  27380. if adminUser.CurrentOrgId == 10265 {
  27381. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27382. new_chrg_bchno = "0000"
  27383. }
  27384. }
  27385. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27386. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27387. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27388. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27389. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27390. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27391. "&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
  27392. resp, requestErr := http.Get(api)
  27393. if requestErr != nil {
  27394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27395. return
  27396. }
  27397. body, ioErr := ioutil.ReadAll(resp.Body)
  27398. if ioErr != nil {
  27399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27401. return
  27402. }
  27403. var respJSON map[string]interface{}
  27404. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27407. return
  27408. }
  27409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27410. result, _ := json.Marshal(respJSON)
  27411. fmt.Println("log")
  27412. fmt.Println(string(result))
  27413. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27414. utils.ErrorLog("解析失败:%v", err)
  27415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27416. return
  27417. }
  27418. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27419. res.Output = resSeven10265.Output
  27420. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27421. res.ErrMsg = resSeven10265.ErrMsg
  27422. res.Cainfo = resSeven10265.Cainfo
  27423. res.WarnMsg = resSeven10265.WarnMsg
  27424. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27425. res.Infcode = infocode
  27426. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27427. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27428. var cert_no string
  27429. if his.IdCardType == 1 {
  27430. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27431. } else {
  27432. cert_no = psn_info.VerifyNumber
  27433. }
  27434. 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)
  27435. var dat map[string]interface{}
  27436. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27437. fmt.Println(dat)
  27438. } else {
  27439. fmt.Println(err)
  27440. }
  27441. saveLog(result2, src_resquest, "2207", "结算")
  27442. userJSONBytes, _ := json.Marshal(dat)
  27443. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27444. utils.ErrorLog("解析失败:%v", err)
  27445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27446. return
  27447. }
  27448. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27449. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27450. var cert_no string
  27451. var card_sn string
  27452. if his.IdCardType == 1 {
  27453. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27454. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27455. bas := strings.Split(psn_info.CardInfo, "|")
  27456. card_sn = bas[3]
  27457. } else if his.IdCardType == 2 {
  27458. cert_no = his.IdCardNo
  27459. } else {
  27460. cert_no = psn_info.VerifyNumber
  27461. }
  27462. var rf []*ResultFive
  27463. json.Unmarshal([]byte(his.Iinfo), &rf)
  27464. var psn_type string
  27465. for _, item := range rf {
  27466. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27467. psn_type = item.PsnType
  27468. }
  27469. }
  27470. 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)
  27471. var dat map[string]interface{}
  27472. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27473. fmt.Println(dat)
  27474. } else {
  27475. fmt.Println(err)
  27476. }
  27477. saveLog(result2, src_resquest, "2207", "结算")
  27478. userJSONBytes, _ := json.Marshal(dat)
  27479. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27480. utils.ErrorLog("解析失败:%v", err)
  27481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27482. return
  27483. }
  27484. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27485. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27486. var cert_no string
  27487. var card_sn string
  27488. if his.IdCardType == 1 {
  27489. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27490. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27491. //bas := strings.Split(psn_info.CardInfo, "|")
  27492. card_sn = ""
  27493. } else if his.IdCardType == 2 {
  27494. cert_no = his.IdCardNo
  27495. } else {
  27496. cert_no = psn_info.VerifyNumber
  27497. }
  27498. var rf []*ResultFive
  27499. json.Unmarshal([]byte(his.Iinfo), &rf)
  27500. var psn_type string
  27501. for _, item := range rf {
  27502. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27503. psn_type = item.PsnType
  27504. }
  27505. }
  27506. 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)
  27507. var dat map[string]interface{}
  27508. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27509. fmt.Println(dat)
  27510. } else {
  27511. fmt.Println(err)
  27512. }
  27513. saveLog(result2, src_resquest, "2207", "结算")
  27514. userJSONBytes, _ := json.Marshal(dat)
  27515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27516. utils.ErrorLog("解析失败:%v", err)
  27517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27518. return
  27519. }
  27520. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27521. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27522. if his.IdCardType == 1 {
  27523. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27524. bas := strings.Split(psn_info.CardInfo, "|")
  27525. cert_no = bas[2]
  27526. } else if his.IdCardType == 3 {
  27527. cert_no = his.Certno
  27528. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27529. } else if his.IdCardType == 4 {
  27530. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27531. cert_no = psn_info.VerifyNumber
  27532. psn_info.VerifyNumber = psn_info.VerifyNumber
  27533. } else {
  27534. cert_no = his.Certno
  27535. psn_info.VerifyNumber = his.Certno
  27536. }
  27537. var api string
  27538. var med_type string
  27539. if his.Insutype == "390" {
  27540. if reg_type == 992102 {
  27541. med_type = "992102"
  27542. }
  27543. if reg_type == 140104 {
  27544. med_type = "140104"
  27545. }
  27546. if reg_type == 140201 {
  27547. med_type = "140201"
  27548. }
  27549. if reg_type == 14 {
  27550. med_type = "14"
  27551. }
  27552. } else if his.Insutype == "310" {
  27553. if reg_type == 992102 {
  27554. med_type = "992102"
  27555. }
  27556. if reg_type == 140104 {
  27557. med_type = "140104"
  27558. }
  27559. if reg_type == 140201 {
  27560. med_type = "140201"
  27561. }
  27562. if reg_type == 14 {
  27563. med_type = "14"
  27564. }
  27565. }
  27566. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27567. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27568. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27569. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27570. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27571. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27572. "&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
  27573. resp, requestErr := http.Get(api)
  27574. if requestErr != nil {
  27575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27576. return
  27577. }
  27578. body, ioErr := ioutil.ReadAll(resp.Body)
  27579. if ioErr != nil {
  27580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27582. return
  27583. }
  27584. var respJSON map[string]interface{}
  27585. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27588. return
  27589. }
  27590. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27591. if status == "0" {
  27592. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27593. c.ServeSuccessJSON(map[string]interface{}{
  27594. "failed_code": -10,
  27595. "msg": err_msg,
  27596. })
  27597. return
  27598. }
  27599. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27600. result, _ := json.Marshal(respJSON)
  27601. fmt.Println("log")
  27602. fmt.Println(string(result))
  27603. if err := json.Unmarshal(result, &ahres); err != nil {
  27604. utils.ErrorLog("解析失败:%v", err)
  27605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27606. return
  27607. }
  27608. res.InfRefmsgid = ahres.InfRefmsgid
  27609. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27610. // 创建对应的Time类型
  27611. t := time.UnixMilli(timestamp)
  27612. // 格式化成指定的日期字符串
  27613. str := t.Format("2006-01-02 15:04:05")
  27614. res.Output.Setlinfo.SetlTime = str
  27615. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27616. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27617. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27618. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27619. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27620. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27621. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27622. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27623. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27624. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27625. res.Output.Setlinfo.ClrType = "11"
  27626. } else {
  27627. res.Output.Setlinfo.ClrType = "9903"
  27628. }
  27629. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27630. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27631. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27632. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27633. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27634. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27635. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27636. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27637. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27638. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27639. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27640. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27641. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27642. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27643. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27644. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27645. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27646. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27647. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27648. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27649. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27650. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27651. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27652. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27653. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27654. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27655. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27656. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27657. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27658. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27659. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27660. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27661. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27662. res.Output.Setldetail = ahres.Output.Setldetail
  27663. res.ErrMsg = ahres.ErrMsg
  27664. res.Cainfo = ahres.Cainfo
  27665. res.WarnMsg = ahres.WarnMsg
  27666. res.Infcode = ahres.Infcode
  27667. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27668. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27669. if his.IdCardType == 1 {
  27670. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27671. bas := strings.Split(psn_info.CardInfo, "|")
  27672. cert_no = bas[2]
  27673. } else if his.IdCardType == 3 {
  27674. cert_no = his.Certno
  27675. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27676. } else if his.IdCardType == 4 {
  27677. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27678. cert_no = his.Certno
  27679. psn_info.VerifyNumber = psn_info.VerifyNumber
  27680. } else {
  27681. cert_no = his.Certno
  27682. psn_info.VerifyNumber = his.Certno
  27683. }
  27684. var api string
  27685. var med_type string
  27686. if his.Insutype == "390" {
  27687. if reg_type == 992102 {
  27688. med_type = "992102"
  27689. }
  27690. if reg_type == 140104 {
  27691. med_type = "140104"
  27692. }
  27693. if reg_type == 14 {
  27694. med_type = "14"
  27695. }
  27696. if reg_type == 140201 {
  27697. med_type = "140201"
  27698. }
  27699. } else if his.Insutype == "310" {
  27700. if reg_type == 992102 {
  27701. med_type = "992102"
  27702. }
  27703. if reg_type == 14 {
  27704. med_type = "14"
  27705. }
  27706. if reg_type == 140104 {
  27707. med_type = "140104"
  27708. }
  27709. if reg_type == 140201 {
  27710. med_type = "140201"
  27711. }
  27712. }
  27713. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27714. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27715. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27716. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27717. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27718. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27719. "&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
  27720. resp, requestErr := http.Get(api)
  27721. if requestErr != nil {
  27722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27723. return
  27724. }
  27725. body, ioErr := ioutil.ReadAll(resp.Body)
  27726. if ioErr != nil {
  27727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27729. return
  27730. }
  27731. var respJSON map[string]interface{}
  27732. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27735. return
  27736. }
  27737. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27738. if status == "0" {
  27739. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27740. c.ServeSuccessJSON(map[string]interface{}{
  27741. "failed_code": -10,
  27742. "msg": err_msg,
  27743. })
  27744. return
  27745. }
  27746. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27747. result, _ := json.Marshal(respJSON)
  27748. fmt.Println("log")
  27749. fmt.Println(string(result))
  27750. if err := json.Unmarshal(result, &ahres); err != nil {
  27751. utils.ErrorLog("解析失败:%v", err)
  27752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27753. return
  27754. }
  27755. res.InfRefmsgid = ahres.InfRefmsgid
  27756. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27757. // 创建对应的Time类型
  27758. t := time.UnixMilli(timestamp)
  27759. // 格式化成指定的日期字符串
  27760. str := t.Format("2006-01-02 15:04:05")
  27761. res.Output.Setlinfo.SetlTime = str
  27762. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27763. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27764. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27765. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27766. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27767. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27768. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27769. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27770. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27771. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27772. res.Output.Setlinfo.ClrType = "11"
  27773. } else {
  27774. res.Output.Setlinfo.ClrType = "9903"
  27775. }
  27776. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27777. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27778. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27779. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27780. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27781. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27782. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27783. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27784. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27785. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27786. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27787. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27788. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27789. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27790. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27791. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27792. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27793. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27794. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27795. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27796. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27797. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27798. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27799. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27800. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27801. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27802. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27803. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27804. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27805. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27806. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27807. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27808. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27809. res.Output.Setldetail = ahres.Output.Setldetail
  27810. res.ErrMsg = ahres.ErrMsg
  27811. res.Cainfo = ahres.Cainfo
  27812. res.WarnMsg = ahres.WarnMsg
  27813. res.Infcode = ahres.Infcode
  27814. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27815. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27816. var cert_no string
  27817. if his.IdCardType == 1 {
  27818. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27819. } else if his.IdCardType == 2 {
  27820. cert_no = his.IdCardNo
  27821. } else {
  27822. cert_no = psn_info.VerifyNumber
  27823. }
  27824. 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, "")
  27825. var dat map[string]interface{}
  27826. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27827. fmt.Println(dat)
  27828. } else {
  27829. fmt.Println(err)
  27830. }
  27831. saveLog(result2, src_resquest, "2207", "结算")
  27832. userJSONBytes, _ := json.Marshal(dat)
  27833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27834. utils.ErrorLog("解析失败:%v", err)
  27835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27836. return
  27837. }
  27838. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27839. psn_info, _ := service.GetPsnByPatientId(id)
  27840. var verify_number string
  27841. if psn_info.IdCardType == 4 {
  27842. verify_number = psn_info.VerifyNumber
  27843. } else if psn_info.IdCardType == 1 {
  27844. bas := strings.Split(psn_info.CardInfo, "|")
  27845. cardNumber := bas[2]
  27846. verify_number = cardNumber
  27847. } else {
  27848. verify_number = psn_info.Certno
  27849. psn_info.IdCardType = 2
  27850. }
  27851. var api string
  27852. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27853. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27854. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27855. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27856. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27857. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27858. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27859. resp, requestErr := http.Get(api)
  27860. if requestErr != nil {
  27861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27862. return
  27863. }
  27864. body, ioErr := ioutil.ReadAll(resp.Body)
  27865. if ioErr != nil {
  27866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27868. return
  27869. }
  27870. var respJSON map[string]interface{}
  27871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27874. return
  27875. }
  27876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27877. result, _ := json.Marshal(respJSON)
  27878. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27879. utils.ErrorLog("解析失败:%v", err)
  27880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27881. return
  27882. }
  27883. } else {
  27884. var src_resquest string
  27885. if miConfig.Code == "H15049901371" {
  27886. //赤峰地区国家医保医疗类别
  27887. //职工透析:医疗类别选特殊情况门诊990502
  27888. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27889. var med_type string
  27890. if his.Insutype == "390" {
  27891. if reg_type == 14 {
  27892. med_type = "9933"
  27893. } else if reg_type == 11 {
  27894. med_type = "11"
  27895. }
  27896. } else if his.Insutype == "310" {
  27897. if reg_type == 14 {
  27898. med_type = "990502"
  27899. } else if reg_type == 11 {
  27900. med_type = "11"
  27901. }
  27902. }
  27903. 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)
  27904. } else {
  27905. if his.IdCardType == 4 {
  27906. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27907. token := psn_info.VerifyNumber
  27908. 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)
  27909. } else {
  27910. 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)
  27911. }
  27912. }
  27913. var dat map[string]interface{}
  27914. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27915. fmt.Println(dat)
  27916. } else {
  27917. fmt.Println(err)
  27918. }
  27919. saveLog(result2, src_resquest, "2207", "结算")
  27920. userJSONBytes, _ := json.Marshal(dat)
  27921. if miConfig.Code == "H15049901371" {
  27922. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27923. utils.ErrorLog("解析失败:%v", err)
  27924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27925. return
  27926. }
  27927. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27928. res.Output = resSeven10265.Output
  27929. res.ErrMsg = resSeven10265.ErrMsg
  27930. res.Cainfo = resSeven10265.Cainfo
  27931. res.WarnMsg = resSeven10265.WarnMsg
  27932. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27933. res.Infcode = infocode
  27934. } else {
  27935. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27936. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27937. utils.ErrorLog("解析失败:%v", err)
  27938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27939. return
  27940. }
  27941. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27942. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27943. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27944. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27945. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27946. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27947. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27948. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27949. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27950. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27951. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27952. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27953. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27954. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27955. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27956. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27957. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27958. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27959. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27960. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27961. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27962. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27963. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27964. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27965. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27966. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27967. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27968. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27969. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27970. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27971. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27972. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27973. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27974. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27975. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27976. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27977. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27978. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27979. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27980. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27981. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27982. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27983. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27984. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27985. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27986. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27987. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27988. res.Cainfo = gzresSeven10265Two.Cainfo
  27989. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27990. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27991. //res.Infcode = infocode
  27992. } else {
  27993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27994. utils.ErrorLog("解析失败:%v", err)
  27995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27996. return
  27997. }
  27998. }
  27999. }
  28000. }
  28001. if res.Infcode == -1 {
  28002. errlog := &models.HisOrderError{
  28003. UserOrgId: adminUser.CurrentOrgId,
  28004. Ctime: time.Now().Unix(),
  28005. Mtime: time.Now().Unix(),
  28006. Number: chrg_bchno,
  28007. ErrMsg: res.ErrMsg,
  28008. Status: 1,
  28009. PatientId: id,
  28010. RecordTime: recordDateTime,
  28011. Stage: 6,
  28012. }
  28013. service.CreateErrMsgLog(errlog)
  28014. c.ServeSuccessJSON(map[string]interface{}{
  28015. "failed_code": -10,
  28016. "msg": res.ErrMsg,
  28017. })
  28018. return
  28019. } else {
  28020. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  28021. order.OrderStatus = 2
  28022. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  28023. order.SetlId = res.Output.Setlinfo.SetlID
  28024. order.PsnNo = res.Output.Setlinfo.PsnNo
  28025. order.PsnName = res.Output.Setlinfo.PsnName
  28026. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28027. order.Certno = res.Output.Setlinfo.Certno
  28028. order.Gend = res.Output.Setlinfo.Gend
  28029. order.Naty = res.Output.Setlinfo.Naty
  28030. order.Age = res.Output.Setlinfo.Age
  28031. order.Insutype = res.Output.Setlinfo.Insutype
  28032. order.PsnType = res.Output.Setlinfo.PsnType
  28033. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28034. order.SetlTime = res.Output.Setlinfo.SetlTime
  28035. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28036. order.PayWays = pay_ways
  28037. order.AcctUsedFlag = acct_used_flag
  28038. order.WechatPay = wechat_pay
  28039. order.AliPay = ali_pay
  28040. order.JifenPay = jifen_pay
  28041. order.BandCardPay = band_card_pay
  28042. order.CashPay = cash_pay
  28043. order.OthDesc = oth_desc
  28044. //order.MedType = res.Output.Setlinfo.MedType
  28045. if reg_type == 1112 {
  28046. order.MedType = "1112"
  28047. }
  28048. if reg_type == 1111 {
  28049. order.MedType = "1111"
  28050. }
  28051. order.ClrType = res.Output.Setlinfo.ClrType
  28052. if adminUser.CurrentOrgId == 10480 {
  28053. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28054. order.ClrType = "11"
  28055. } else {
  28056. order.ClrType = "9903"
  28057. }
  28058. }
  28059. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28060. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28061. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28062. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28063. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28064. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28065. order.HifpPay = res.Output.Setlinfo.HifpPay
  28066. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28067. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28068. order.HifesPay = res.Output.Setlinfo.HifesPay
  28069. order.HifobPay = res.Output.Setlinfo.HifobPay
  28070. order.MafPay = res.Output.Setlinfo.MafPay
  28071. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28072. order.OthPay = res.Output.Setlinfo.OthPay
  28073. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28074. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28075. order.AcctPay = res.Output.Setlinfo.AcctPay
  28076. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28077. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28078. order.Balc = res.Output.Setlinfo.Balc
  28079. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28080. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28081. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28082. order.ClrWay = res.Output.Setlinfo.ClrWay
  28083. order.Creator = order.Creator
  28084. order.Modify = roles.AdminUserId
  28085. order.RequestLog = src_resquest
  28086. order.Diagnosis = diagnosis_id
  28087. order.FaPiaoNumber = fapiao_number
  28088. order.FaPiaoCode = fapiao_code
  28089. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28090. detailStr := string(setlDetail)
  28091. order.SetlDetail = detailStr
  28092. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28093. err = service.UpDateOrder(order)
  28094. if err == nil {
  28095. //判断是否使用了押金
  28096. if dec_way == "true" {
  28097. tmpstring := strconv.FormatInt(order.ID, 10)
  28098. //扣押金
  28099. order.Decimal = decimal
  28100. service.UpDateOrder(order)
  28101. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28102. if errmsg != nil {
  28103. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28104. return
  28105. }
  28106. }
  28107. c.ServeSuccessJSON(map[string]interface{}{
  28108. "msg": "结算成功",
  28109. })
  28110. } else {
  28111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28112. return
  28113. }
  28114. }
  28115. }
  28116. }
  28117. }
  28118. // 上传明细-预结算-
  28119. func (c *HisApiController) GetPreUploadInfo() {
  28120. id, _ := c.GetInt64("id")
  28121. record_time := c.GetString("record_time")
  28122. his_patient_id, _ := c.GetInt64("his_patient_id")
  28123. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  28124. admin_user_id, _ := c.GetInt64("admin_user_id")
  28125. diagnosis_id := c.GetString("diagnosis")
  28126. sick_type, _ := c.GetInt64("sick_type")
  28127. reg_type, _ := c.GetInt64("p_type")
  28128. begin_time := c.GetString("begin_time")
  28129. acct_used_flag := c.GetString("acct_used_flag")
  28130. id_str := c.GetString("ids")
  28131. ids_arr := strings.Split(id_str, ",")
  28132. timeLayout := "2006-01-02"
  28133. loc, _ := time.LoadLocation("Local")
  28134. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28135. if err != nil {
  28136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28137. return
  28138. }
  28139. recordDateTime := theTime.Unix()
  28140. adminUser := c.GetAdminUserInfo()
  28141. diagnosis_ids := strings.Split(diagnosis_id, ",")
  28142. var config []*models.HisXtDiagnoseConfig
  28143. for _, item := range diagnosis_ids {
  28144. id, _ := strconv.ParseInt(item, 10, 64)
  28145. if id > 0 {
  28146. diagnosisConfig, _ := service.FindDiagnoseById(id)
  28147. config = append(config, &diagnosisConfig)
  28148. }
  28149. }
  28150. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  28151. sickConfig, _ := service.FindSickById(sick_type)
  28152. var prescriptions []*models.HisPrescription
  28153. var start_time int64
  28154. var end_time int64
  28155. var isSuccess bool = true
  28156. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28157. fmt.Println(his_patient_id)
  28158. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28159. timestamp := time.Now().Unix()
  28160. tempTime := time.Unix(timestamp, 0)
  28161. timeFormat := tempTime.Format("20060102150405")
  28162. chrgBchno := rand.Intn(100000) + 10000
  28163. new_chrg_bchno := ""
  28164. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  28165. new_chrg_bchno = chrg_bchno
  28166. if adminUser.CurrentOrgId == 10265 {
  28167. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28168. new_chrg_bchno = "0000"
  28169. }
  28170. }
  28171. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28172. var patientPrescription models.HisPrescriptionInfo
  28173. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28174. if patientPrescription.ID == 0 {
  28175. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  28176. }
  28177. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28178. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28179. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  28180. strconv.FormatInt(his.PatientId, 10)
  28181. var res2406 Result2406
  28182. //安徽单病种处理
  28183. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  28184. data := make(map[string]interface{})
  28185. client := &http.Client{}
  28186. data["psn_no"] = his.PsnNo
  28187. data["mdtrt_id"] = his.Number
  28188. data["operator"] = roles.UserName
  28189. data["cert_no"] = his.IdCardNo
  28190. data["org_name"] = miConfig.OrgName
  28191. data["psn_name"] = his.Name
  28192. data["ipt_otp_no"] = his.IptOtpNo
  28193. data["ipt_psn_sp_flag_type"] = "0901"
  28194. data["ipt_psn_sp_flag"] = "1"
  28195. data["fixmedins_code"] = miConfig.Code
  28196. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28197. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28198. data["url"] = miConfig.Url
  28199. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28200. bytesData, _ := json.Marshal(data)
  28201. var req *http.Request
  28202. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28203. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  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. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28219. if status == "0" {
  28220. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28221. c.ServeSuccessJSON(map[string]interface{}{
  28222. "failed_code": -10,
  28223. "msg": err_msg,
  28224. })
  28225. return
  28226. }
  28227. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28228. userJSONBytes, _ := json.Marshal(respJSON)
  28229. fmt.Println("log")
  28230. fmt.Println(string(userJSONBytes))
  28231. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28232. utils.ErrorLog("解析失败:%v", err)
  28233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28234. return
  28235. }
  28236. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  28237. data := make(map[string]interface{})
  28238. client := &http.Client{}
  28239. data["psn_no"] = his.PsnNo
  28240. data["mdtrt_id"] = his.Number
  28241. data["operator"] = roles.UserName
  28242. data["cert_no"] = his.IdCardNo
  28243. data["org_name"] = miConfig.OrgName
  28244. data["psn_name"] = his.Name
  28245. data["ipt_otp_no"] = his.IptOtpNo
  28246. data["ipt_psn_sp_flag_type"] = "0901"
  28247. data["ipt_psn_sp_flag"] = "1"
  28248. data["fixmedins_code"] = miConfig.Code
  28249. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28250. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28251. data["url"] = miConfig.Url
  28252. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28253. bytesData, _ := json.Marshal(data)
  28254. var req *http.Request
  28255. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28256. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28257. resp, _ := client.Do(req)
  28258. defer resp.Body.Close()
  28259. body, ioErr := ioutil.ReadAll(resp.Body)
  28260. if ioErr != nil {
  28261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28263. return
  28264. }
  28265. var respJSON map[string]interface{}
  28266. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28269. return
  28270. }
  28271. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28272. if status == "0" {
  28273. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28274. c.ServeSuccessJSON(map[string]interface{}{
  28275. "failed_code": -10,
  28276. "msg": err_msg,
  28277. })
  28278. return
  28279. }
  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, &res2406); err != nil {
  28285. utils.ErrorLog("解析失败:%v", err)
  28286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28287. return
  28288. }
  28289. }
  28290. if res2406.Infcode != 0 {
  28291. adminUser := c.GetAdminUserInfo()
  28292. errlog := &models.HisOrderError{
  28293. UserOrgId: adminUser.CurrentOrgId,
  28294. Ctime: time.Now().Unix(),
  28295. Mtime: time.Now().Unix(),
  28296. ErrMsg: res2406.ErrMsg,
  28297. Status: 1,
  28298. PatientId: id,
  28299. RecordTime: recordDateTime,
  28300. Stage: 3,
  28301. }
  28302. service.CreateErrMsgLog(errlog)
  28303. c.ServeSuccessJSON(map[string]interface{}{
  28304. "failed_code": -10,
  28305. "msg": res2406.ErrMsg,
  28306. })
  28307. return
  28308. }
  28309. var res2 ResultSix
  28310. var res3 GZResultSix
  28311. var resSix10265 ResultSix10265
  28312. //var time_stamp string
  28313. if miConfig.MdtrtareaAdmvs == "421300" {
  28314. data := make(map[string]interface{})
  28315. client := &http.Client{}
  28316. data["psn_no"] = his.PsnNo
  28317. data["mdtrt_id"] = his.Number
  28318. data["department"] = department.Name
  28319. data["org_name"] = miConfig.OrgName
  28320. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28321. data["doctor_id"] = doctor_info.DoctorNumber
  28322. data["doctor_name"] = roles.UserName
  28323. data["fixmedins_code"] = miConfig.Code
  28324. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28325. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28326. data["secret_key"] = miConfig.SecretKey
  28327. data["sick_code"] = sickConfig.CountryCode
  28328. data["sick_name"] = sickConfig.ClassName
  28329. data["begin_time"] = begin_time
  28330. data["dept"] = strconv.FormatInt(department.ID, 10)
  28331. data["config"] = config
  28332. data["opter"] = roles.UserName
  28333. fmt.Println(data)
  28334. bytesData, _ := json.Marshal(data)
  28335. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28336. resp, _ := client.Do(req)
  28337. defer resp.Body.Close()
  28338. body, ioErr := ioutil.ReadAll(resp.Body)
  28339. if ioErr != nil {
  28340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28342. return
  28343. }
  28344. var respJSON map[string]interface{}
  28345. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28348. return
  28349. }
  28350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28351. userJSONBytes, _ := json.Marshal(respJSON)
  28352. fmt.Println("log")
  28353. fmt.Println(string(userJSONBytes))
  28354. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28355. utils.ErrorLog("解析失败:%v", err)
  28356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28357. return
  28358. }
  28359. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28360. data := make(map[string]interface{})
  28361. client := &http.Client{}
  28362. data["psn_no"] = his.PsnNo
  28363. data["mdtrt_id"] = his.Number
  28364. data["department"] = department.Name
  28365. data["org_name"] = miConfig.OrgName
  28366. if reg_type == 11 && his.Insutype == "390" {
  28367. data["med_type"] = "110104"
  28368. } else {
  28369. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28370. }
  28371. data["doctor_id"] = doctor_info.DoctorNumber
  28372. data["doctor_name"] = roles.UserName
  28373. data["fixmedins_code"] = miConfig.Code
  28374. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28375. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28376. data["secret_key"] = miConfig.SecretKey
  28377. data["sick_code"] = sickConfig.CountryCode
  28378. data["sick_name"] = sickConfig.ClassName
  28379. data["begin_time"] = begin_time
  28380. data["dept"] = strconv.FormatInt(department.ID, 10)
  28381. data["config"] = config
  28382. data["opter"] = roles.UserName
  28383. fmt.Println(data)
  28384. bytesData, _ := json.Marshal(data)
  28385. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28386. resp, _ := client.Do(req)
  28387. defer resp.Body.Close()
  28388. body, ioErr := ioutil.ReadAll(resp.Body)
  28389. if ioErr != nil {
  28390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28392. return
  28393. }
  28394. var respJSON map[string]interface{}
  28395. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28398. return
  28399. }
  28400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28401. userJSONBytes, _ := json.Marshal(respJSON)
  28402. fmt.Println("log")
  28403. fmt.Println(string(userJSONBytes))
  28404. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28405. utils.ErrorLog("解析失败:%v", err)
  28406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28407. return
  28408. }
  28409. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28410. data := make(map[string]interface{})
  28411. client := &http.Client{}
  28412. data["psn_no"] = his.PsnNo
  28413. data["mdtrt_id"] = his.Number
  28414. data["department"] = department.Name
  28415. data["org_name"] = miConfig.OrgName
  28416. if reg_type == 11 && his.Insutype == "390" {
  28417. data["med_type"] = "110104"
  28418. } else {
  28419. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28420. }
  28421. data["doctor_id"] = doctor_info.DoctorNumber
  28422. data["doctor_name"] = roles.UserName
  28423. data["fixmedins_code"] = miConfig.Code
  28424. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28425. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28426. data["secret_key"] = miConfig.SecretKey
  28427. data["sick_code"] = sickConfig.CountryCode
  28428. data["sick_name"] = sickConfig.ClassName
  28429. data["begin_time"] = begin_time
  28430. data["dept"] = strconv.FormatInt(department.ID, 10)
  28431. data["config"] = config
  28432. data["opter"] = roles.UserName
  28433. fmt.Println(data)
  28434. bytesData, _ := json.Marshal(data)
  28435. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28436. resp, _ := client.Do(req)
  28437. defer resp.Body.Close()
  28438. body, ioErr := ioutil.ReadAll(resp.Body)
  28439. if ioErr != nil {
  28440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28442. return
  28443. }
  28444. var respJSON map[string]interface{}
  28445. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28448. return
  28449. }
  28450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28451. userJSONBytes, _ := json.Marshal(respJSON)
  28452. fmt.Println("log")
  28453. fmt.Println(string(userJSONBytes))
  28454. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28455. utils.ErrorLog("解析失败:%v", err)
  28456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28457. return
  28458. }
  28459. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28460. data := make(map[string]interface{})
  28461. client := &http.Client{}
  28462. data["psn_no"] = his.PsnNo
  28463. data["mdtrt_id"] = his.Number
  28464. data["department"] = department.Name
  28465. data["org_name"] = miConfig.OrgName
  28466. if reg_type == 11 && his.Insutype == "390" {
  28467. data["med_type"] = "110104"
  28468. } else {
  28469. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28470. }
  28471. data["doctor_id"] = doctor_info.DoctorNumber
  28472. data["doctor_name"] = roles.UserName
  28473. data["fixmedins_code"] = miConfig.Code
  28474. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28475. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28476. data["secret_key"] = miConfig.SecretKey
  28477. data["sick_code"] = sickConfig.CountryCode
  28478. data["sick_name"] = sickConfig.ClassName
  28479. data["begin_time"] = begin_time
  28480. data["dept"] = strconv.FormatInt(department.ID, 10)
  28481. data["config"] = config
  28482. data["opter"] = roles.UserName
  28483. fmt.Println(data)
  28484. bytesData, _ := json.Marshal(data)
  28485. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28486. resp, _ := client.Do(req)
  28487. defer resp.Body.Close()
  28488. body, ioErr := ioutil.ReadAll(resp.Body)
  28489. if ioErr != nil {
  28490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28492. return
  28493. }
  28494. var respJSON map[string]interface{}
  28495. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28498. return
  28499. }
  28500. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28501. userJSONBytes, _ := json.Marshal(respJSON)
  28502. fmt.Println("log")
  28503. fmt.Println(string(userJSONBytes))
  28504. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28505. utils.ErrorLog("解析失败:%v", err)
  28506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28507. return
  28508. }
  28509. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28510. data := make(map[string]interface{})
  28511. client := &http.Client{}
  28512. data["psn_no"] = his.PsnNo
  28513. data["mdtrt_id"] = his.Number
  28514. data["doctor"] = roles.UserName
  28515. data["department"] = department.Name
  28516. data["org_name"] = miConfig.OrgName
  28517. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28518. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28519. data["fixmedins_code"] = miConfig.Code
  28520. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28521. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28522. data["secret_key"] = miConfig.SecretKey
  28523. data["sick_code"] = sickConfig.CountryCode
  28524. data["sick_name"] = sickConfig.ClassName
  28525. data["begin_time"] = begin_time
  28526. data["dept"] = strconv.FormatInt(department.ID, 10)
  28527. data["config"] = config
  28528. data["url"] = miConfig.Url
  28529. data["ak"] = miConfig.AccessKey
  28530. data["cainfo"] = miConfig.Cainfo
  28531. bytesData, _ := json.Marshal(data)
  28532. var req *http.Request
  28533. if miConfig.MdtrtareaAdmvs == "320921" {
  28534. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28535. } else {
  28536. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28537. }
  28538. resp, _ := client.Do(req)
  28539. defer resp.Body.Close()
  28540. body, ioErr := ioutil.ReadAll(resp.Body)
  28541. if ioErr != nil {
  28542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28544. return
  28545. }
  28546. var respJSON map[string]interface{}
  28547. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28550. return
  28551. }
  28552. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28553. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28554. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28556. userJSONBytes, _ := json.Marshal(respJSON)
  28557. fmt.Println("log")
  28558. fmt.Println(string(userJSONBytes))
  28559. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28560. utils.ErrorLog("解析失败:%v", err)
  28561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28562. return
  28563. }
  28564. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28565. res2.Output = resSix10265.Output
  28566. res2.ErrMsg = resSix10265.ErrMsg
  28567. res2.Cainfo = resSix10265.Cainfo
  28568. res2.WarnMsg = resSix10265.WarnMsg
  28569. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28570. res2.Infcode = infocode
  28571. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28572. data := make(map[string]interface{})
  28573. client := &http.Client{}
  28574. data["psn_no"] = his.PsnNo
  28575. data["mdtrt_id"] = his.Number
  28576. data["doctor"] = roles.UserName
  28577. data["department"] = department.Name
  28578. data["org_name"] = miConfig.OrgName
  28579. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28580. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28581. data["fixmedins_code"] = miConfig.Code
  28582. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28583. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28584. data["secret_key"] = miConfig.SecretKey
  28585. data["sick_code"] = sickConfig.CountryCode
  28586. data["sick_name"] = sickConfig.ClassName
  28587. data["begin_time"] = begin_time
  28588. data["dept"] = strconv.FormatInt(department.ID, 10)
  28589. data["config"] = config
  28590. //data["url"] = miConfig.Url
  28591. //data["ak"] = miConfig.AccessKey
  28592. data["cainfo"] = miConfig.Cainfo
  28593. fmt.Println(data)
  28594. bytesData, _ := json.Marshal(data)
  28595. var req *http.Request
  28596. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28597. resp, _ := client.Do(req)
  28598. defer resp.Body.Close()
  28599. body, ioErr := ioutil.ReadAll(resp.Body)
  28600. if ioErr != nil {
  28601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28603. return
  28604. }
  28605. var respJSON map[string]interface{}
  28606. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28609. return
  28610. }
  28611. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28612. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28613. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28614. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28615. userJSONBytes, _ := json.Marshal(respJSON)
  28616. fmt.Println("log")
  28617. fmt.Println(string(userJSONBytes))
  28618. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28619. utils.ErrorLog("解析失败:%v", err)
  28620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28621. return
  28622. }
  28623. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28624. res2.Output = resSix10265.Output
  28625. res2.ErrMsg = resSix10265.ErrMsg
  28626. res2.Cainfo = resSix10265.Cainfo
  28627. res2.WarnMsg = resSix10265.WarnMsg
  28628. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28629. res2.Infcode = infocode
  28630. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28631. 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)
  28632. saveLog(result, requestLog, "2203", "上传就诊信息")
  28633. var respJSON2 map[string]interface{}
  28634. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28637. return
  28638. }
  28639. userJSONBytes2, _ := json.Marshal(respJSON2)
  28640. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28641. utils.ErrorLog("解析失败:%v", err)
  28642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28643. return
  28644. }
  28645. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28646. var result string
  28647. var requestLog string
  28648. 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, "")
  28649. saveLog(result, requestLog, "2203", "上传就诊信息")
  28650. var respJSON2 map[string]interface{}
  28651. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28654. return
  28655. }
  28656. userJSONBytes2, _ := json.Marshal(respJSON2)
  28657. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28658. utils.ErrorLog("解析失败:%v", err)
  28659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28660. return
  28661. }
  28662. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28663. var result string
  28664. var requestLog string
  28665. 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, "")
  28666. saveLog(result, requestLog, "2203", "上传就诊信息")
  28667. var respJSON2 map[string]interface{}
  28668. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28671. return
  28672. }
  28673. userJSONBytes2, _ := json.Marshal(respJSON2)
  28674. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28675. utils.ErrorLog("解析失败:%v", err)
  28676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28677. return
  28678. }
  28679. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28680. data := make(map[string]interface{})
  28681. client := &http.Client{}
  28682. data["psn_no"] = his.PsnNo
  28683. data["mdtrt_id"] = his.Number
  28684. data["operator"] = roles.UserName
  28685. data["department"] = department.Name
  28686. data["org_name"] = miConfig.OrgName
  28687. var med_type string
  28688. if his.Insutype == "390" {
  28689. if reg_type == 992102 {
  28690. med_type = "992102"
  28691. data["sick_code"] = "ZDZ940"
  28692. data["sick_name"] = "慢性肾衰竭"
  28693. }
  28694. if reg_type == 140104 {
  28695. med_type = "140104"
  28696. data["sick_code"] = sickConfig.CountryCode
  28697. data["sick_name"] = sickConfig.ClassName
  28698. }
  28699. if reg_type == 14 {
  28700. med_type = "140104"
  28701. data["sick_code"] = sickConfig.CountryCode
  28702. data["sick_name"] = sickConfig.ClassName
  28703. }
  28704. } else if his.Insutype == "310" {
  28705. if reg_type == 992102 {
  28706. med_type = "992102"
  28707. data["sick_code"] = "ZDZ940"
  28708. data["sick_name"] = "慢性肾衰竭"
  28709. }
  28710. if reg_type == 140104 {
  28711. med_type = "140104"
  28712. data["sick_code"] = sickConfig.CountryCode
  28713. data["sick_name"] = sickConfig.ClassName
  28714. }
  28715. if reg_type == 14 {
  28716. med_type = "14"
  28717. data["sick_code"] = sickConfig.CountryCode
  28718. data["sick_name"] = sickConfig.ClassName
  28719. }
  28720. }
  28721. data["med_type"] = med_type
  28722. data["doctor_number"] = doctor_info.DoctorNumber
  28723. data["doctor_name"] = doctor_info.UserName
  28724. data["fixmedins_code"] = miConfig.Code
  28725. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28726. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28727. data["secret_key"] = miConfig.SecretKey
  28728. data["begin_time"] = begin_time
  28729. data["dept"] = strconv.FormatInt(department.ID, 10)
  28730. data["config"] = config
  28731. data["url"] = miConfig.Url
  28732. data["ak"] = miConfig.AccessKey
  28733. data["cainfo"] = miConfig.Cainfo
  28734. bytesData, _ := json.Marshal(data)
  28735. var req *http.Request
  28736. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28737. resp, _ := client.Do(req)
  28738. defer resp.Body.Close()
  28739. body, ioErr := ioutil.ReadAll(resp.Body)
  28740. if ioErr != nil {
  28741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28743. return
  28744. }
  28745. var respJSON map[string]interface{}
  28746. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28749. return
  28750. }
  28751. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28752. if status == "0" {
  28753. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28754. c.ServeSuccessJSON(map[string]interface{}{
  28755. "failed_code": -10,
  28756. "msg": err_msg,
  28757. })
  28758. return
  28759. }
  28760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28761. userJSONBytes, _ := json.Marshal(respJSON)
  28762. fmt.Println("log")
  28763. fmt.Println(string(userJSONBytes))
  28764. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28765. utils.ErrorLog("解析失败:%v", err)
  28766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28767. return
  28768. }
  28769. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28770. data := make(map[string]interface{})
  28771. client := &http.Client{}
  28772. data["psn_no"] = his.PsnNo
  28773. data["mdtrt_id"] = his.Number
  28774. data["operator"] = roles.UserName
  28775. data["department"] = department.Name
  28776. data["org_name"] = miConfig.OrgName
  28777. var med_type string
  28778. if his.Insutype == "390" {
  28779. if reg_type == 992102 {
  28780. med_type = "992102"
  28781. data["sick_code"] = sickConfig.CountryCode
  28782. data["sick_name"] = sickConfig.ClassName
  28783. }
  28784. if reg_type == 140104 {
  28785. med_type = "140104"
  28786. data["sick_code"] = sickConfig.CountryCode
  28787. data["sick_name"] = sickConfig.ClassName
  28788. }
  28789. if reg_type == 140201 {
  28790. med_type = "140201"
  28791. data["sick_code"] = sickConfig.CountryCode
  28792. data["sick_name"] = sickConfig.ClassName
  28793. }
  28794. if reg_type == 14 {
  28795. med_type = "14"
  28796. data["sick_code"] = sickConfig.CountryCode
  28797. data["sick_name"] = sickConfig.ClassName
  28798. }
  28799. } else if his.Insutype == "310" {
  28800. if reg_type == 992102 {
  28801. med_type = "992102"
  28802. data["sick_code"] = sickConfig.CountryCode
  28803. data["sick_name"] = sickConfig.ClassName
  28804. }
  28805. if reg_type == 140104 {
  28806. med_type = "140104"
  28807. data["sick_code"] = sickConfig.CountryCode
  28808. data["sick_name"] = sickConfig.ClassName
  28809. }
  28810. if reg_type == 140201 {
  28811. med_type = "140201"
  28812. data["sick_code"] = sickConfig.CountryCode
  28813. data["sick_name"] = sickConfig.ClassName
  28814. }
  28815. if reg_type == 14 {
  28816. med_type = "14"
  28817. data["sick_code"] = sickConfig.CountryCode
  28818. data["sick_name"] = sickConfig.ClassName
  28819. }
  28820. }
  28821. data["med_type"] = med_type
  28822. data["doctor_number"] = doctor_info.DoctorNumber
  28823. data["doctor_name"] = doctor_info.UserName
  28824. data["fixmedins_code"] = miConfig.Code
  28825. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28826. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28827. data["secret_key"] = miConfig.SecretKey
  28828. data["begin_time"] = begin_time
  28829. data["dept"] = strconv.FormatInt(department.ID, 10)
  28830. data["config"] = config
  28831. data["url"] = miConfig.Url
  28832. data["ak"] = miConfig.AccessKey
  28833. data["cainfo"] = miConfig.Cainfo
  28834. bytesData, _ := json.Marshal(data)
  28835. var req *http.Request
  28836. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28837. resp, _ := client.Do(req)
  28838. defer resp.Body.Close()
  28839. body, ioErr := ioutil.ReadAll(resp.Body)
  28840. if ioErr != nil {
  28841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28843. return
  28844. }
  28845. var respJSON map[string]interface{}
  28846. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28849. return
  28850. }
  28851. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28852. if status == "0" {
  28853. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28854. c.ServeSuccessJSON(map[string]interface{}{
  28855. "failed_code": -10,
  28856. "msg": err_msg,
  28857. })
  28858. return
  28859. }
  28860. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28861. userJSONBytes, _ := json.Marshal(respJSON)
  28862. fmt.Println("log")
  28863. fmt.Println(string(userJSONBytes))
  28864. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28865. utils.ErrorLog("解析失败:%v", err)
  28866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28867. return
  28868. }
  28869. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28870. var result string
  28871. var requestLog string
  28872. 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, "")
  28873. saveLog(result, requestLog, "2203", "上传就诊信息")
  28874. var respJSON2 map[string]interface{}
  28875. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28878. return
  28879. }
  28880. userJSONBytes2, _ := json.Marshal(respJSON2)
  28881. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28882. utils.ErrorLog("解析失败:%v", err)
  28883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28884. return
  28885. }
  28886. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28887. data := make(map[string]interface{})
  28888. client := &http.Client{}
  28889. data["psn_no"] = his.PsnNo
  28890. data["mdtrt_id"] = his.Number
  28891. data["doctor"] = roles.UserName
  28892. data["department"] = department.Name
  28893. data["org_name"] = miConfig.OrgName
  28894. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28895. data["doctor_id"] = doctor_info.DoctorNumber
  28896. data["fixmedins_code"] = miConfig.Code
  28897. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28898. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28899. data["secret_key"] = miConfig.SecretKey
  28900. data["sick_code"] = sickConfig.CountryCode
  28901. data["sick_name"] = sickConfig.ClassName
  28902. data["begin_time"] = begin_time
  28903. data["new_doctor_name"] = doctor_info.UserName
  28904. data["dept"] = strconv.FormatInt(department.ID, 10)
  28905. data["config"] = config
  28906. bytesData, _ := json.Marshal(data)
  28907. var req *http.Request
  28908. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28909. resp, _ := client.Do(req)
  28910. defer resp.Body.Close()
  28911. body, ioErr := ioutil.ReadAll(resp.Body)
  28912. if ioErr != nil {
  28913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28915. return
  28916. }
  28917. var respJSON map[string]interface{}
  28918. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28921. return
  28922. }
  28923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28924. userJSONBytes, _ := json.Marshal(respJSON)
  28925. fmt.Println("log")
  28926. fmt.Println(string(userJSONBytes))
  28927. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28928. utils.ErrorLog("解析失败:%v", err)
  28929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28930. return
  28931. }
  28932. } else {
  28933. var result string
  28934. var requestLog string
  28935. if miConfig.MdtrtareaAdmvs == "440781" { //
  28936. 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)
  28937. } else {
  28938. if miConfig.Code == "H15049901371" {
  28939. //赤峰地区国家医保医疗类别
  28940. //职工透析:医疗类别选特殊情况门诊990502
  28941. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28942. var med_type string
  28943. if his.Insutype == "390" {
  28944. if reg_type == 14 {
  28945. med_type = "9933"
  28946. } else if reg_type == 11 {
  28947. med_type = "11"
  28948. }
  28949. } else if his.Insutype == "310" {
  28950. if reg_type == 14 {
  28951. med_type = "990502"
  28952. } else if reg_type == 11 {
  28953. med_type = "11"
  28954. }
  28955. }
  28956. 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)
  28957. } else {
  28958. 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)
  28959. }
  28960. saveLog(result, requestLog, "2203", "上传就诊信息")
  28961. var respJSON2 map[string]interface{}
  28962. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28965. return
  28966. }
  28967. userJSONBytes2, _ := json.Marshal(respJSON2)
  28968. if miConfig.Code == "H15049901371" {
  28969. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28970. utils.ErrorLog("解析失败:%v", err)
  28971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28972. return
  28973. }
  28974. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28975. res2.Output = resSix10265.Output
  28976. res2.ErrMsg = resSix10265.ErrMsg
  28977. res2.Cainfo = resSix10265.Cainfo
  28978. res2.WarnMsg = resSix10265.WarnMsg
  28979. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28980. res2.Infcode = infocode
  28981. } else {
  28982. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28983. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28984. utils.ErrorLog("解析失败:%v", err)
  28985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28986. return
  28987. }
  28988. res2.Infcode = res3.Infcode
  28989. } else {
  28990. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28991. utils.ErrorLog("解析失败:%v", err)
  28992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28993. return
  28994. }
  28995. }
  28996. }
  28997. }
  28998. }
  28999. if res2.Infcode == -1 {
  29000. adminUser := c.GetAdminUserInfo()
  29001. errlog := &models.HisOrderError{
  29002. UserOrgId: adminUser.CurrentOrgId,
  29003. Ctime: time.Now().Unix(),
  29004. Mtime: time.Now().Unix(),
  29005. ErrMsg: res2.ErrMsg,
  29006. Status: 1,
  29007. PatientId: id,
  29008. RecordTime: recordDateTime,
  29009. Stage: 3,
  29010. }
  29011. service.CreateErrMsgLog(errlog)
  29012. c.ServeSuccessJSON(map[string]interface{}{
  29013. "failed_code": -10,
  29014. "msg": res2.ErrMsg,
  29015. })
  29016. return
  29017. }
  29018. if res2.Infcode != 0 {
  29019. adminUser := c.GetAdminUserInfo()
  29020. errlog := &models.HisOrderError{
  29021. UserOrgId: adminUser.CurrentOrgId,
  29022. Ctime: time.Now().Unix(),
  29023. Mtime: time.Now().Unix(),
  29024. ErrMsg: res2.ErrMsg,
  29025. Status: 1,
  29026. PatientId: id,
  29027. RecordTime: recordDateTime,
  29028. Stage: 3,
  29029. }
  29030. service.CreateErrMsgLog(errlog)
  29031. c.ServeSuccessJSON(map[string]interface{}{
  29032. "failed_code": -10,
  29033. "msg": res2.ErrMsg,
  29034. })
  29035. return
  29036. } else {
  29037. his.Diagnosis = diagnosis_id
  29038. his.SickType = sickConfig.ID
  29039. his.PType = fmt.Sprintf("%d", reg_type)
  29040. service.UpdateHisPatientThree(&his)
  29041. data := make(map[string]interface{})
  29042. if settle_accounts_type == 1 { //日结
  29043. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  29044. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  29045. } else {
  29046. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  29047. }
  29048. data["pre"] = prescriptions
  29049. } else { //月结
  29050. start_time_str := c.GetString("start_time")
  29051. end_time_str := c.GetString("end_time")
  29052. timeLayout := "2006-01-02"
  29053. loc, _ := time.LoadLocation("Local")
  29054. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  29055. if err != nil {
  29056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29057. return
  29058. }
  29059. recordStartTime := theStartTime.Unix()
  29060. start_time = recordStartTime
  29061. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  29062. if err != nil {
  29063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29064. return
  29065. }
  29066. recordEndTime := theEndTime.Unix()
  29067. end_time = recordEndTime
  29068. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  29069. data["pre"] = prescriptions
  29070. }
  29071. client := &http.Client{}
  29072. data["psn_no"] = his.PsnNo
  29073. data["mdtrt_id"] = his.Number
  29074. data["chrg_bchno"] = new_chrg_bchno
  29075. data["org_name"] = miConfig.OrgName
  29076. data["doctor"] = doctor_info.UserName
  29077. data["doctor_id"] = doctor_info.DoctorNumber
  29078. data["dept"] = department.Name
  29079. data["fixmedins_code"] = miConfig.Code
  29080. data["opter"] = roles.UserName
  29081. data["dept_code"] = department.Number
  29082. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29083. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29084. data["secret_key"] = miConfig.SecretKey
  29085. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  29086. data["url"] = miConfig.Url
  29087. data["ak"] = miConfig.AccessKey
  29088. data["new_doctor_name"] = patientPrescription.Doctor
  29089. if his.Insutype == "390" {
  29090. if reg_type == 992102 {
  29091. data["diag_code"] = "ZDZ940"
  29092. }
  29093. if reg_type == 140104 {
  29094. data["diag_code"] = sickConfig.CountryCode
  29095. }
  29096. if reg_type == 140201 {
  29097. data["diag_code"] = sickConfig.CountryCode
  29098. }
  29099. if reg_type == 14 {
  29100. data["diag_code"] = sickConfig.CountryCode
  29101. }
  29102. } else if his.Insutype == "310" {
  29103. if miConfig.MdtrtareaAdmvs == "341203" {
  29104. if reg_type == 992102 {
  29105. data["diag_code"] = "ZDZ940"
  29106. }
  29107. if reg_type != 992102 {
  29108. data["diag_code"] = sickConfig.CountryCode
  29109. }
  29110. } else {
  29111. data["diag_code"] = sickConfig.CountryCode
  29112. }
  29113. }
  29114. data["cainfo"] = miConfig.Cainfo
  29115. data["opter"] = roles.UserName
  29116. var ids []int64
  29117. for _, item := range prescriptions {
  29118. ids = append(ids, item.ID)
  29119. }
  29120. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29121. if config.IsOpen == 1 { //对接了医保,走医保流程
  29122. var res ResultFour
  29123. var resFour10265 ResultFour10265
  29124. if miConfig.MdtrtareaAdmvs == "421300" {
  29125. bytesData, _ := json.Marshal(data)
  29126. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29127. resp, _ := client.Do(req)
  29128. defer resp.Body.Close()
  29129. body, ioErr := ioutil.ReadAll(resp.Body)
  29130. if ioErr != nil {
  29131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29133. return
  29134. }
  29135. var respJSON map[string]interface{}
  29136. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29139. return
  29140. }
  29141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29142. userJSONBytes, _ := json.Marshal(respJSON)
  29143. fmt.Println("log")
  29144. fmt.Println(string(userJSONBytes))
  29145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29146. utils.ErrorLog("解析失败:%v", err)
  29147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29148. return
  29149. }
  29150. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29151. bytesData, _ := json.Marshal(data)
  29152. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29153. resp, _ := client.Do(req)
  29154. defer resp.Body.Close()
  29155. body, ioErr := ioutil.ReadAll(resp.Body)
  29156. if ioErr != nil {
  29157. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29159. return
  29160. }
  29161. var respJSON map[string]interface{}
  29162. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29165. return
  29166. }
  29167. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29168. userJSONBytes, _ := json.Marshal(respJSON)
  29169. fmt.Println("log")
  29170. fmt.Println(string(userJSONBytes))
  29171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29172. utils.ErrorLog("解析失败:%v", err)
  29173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29174. return
  29175. }
  29176. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29177. bytesData, _ := json.Marshal(data)
  29178. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29179. resp, _ := client.Do(req)
  29180. defer resp.Body.Close()
  29181. body, ioErr := ioutil.ReadAll(resp.Body)
  29182. if ioErr != nil {
  29183. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29185. return
  29186. }
  29187. var respJSON map[string]interface{}
  29188. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29191. return
  29192. }
  29193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29194. userJSONBytes, _ := json.Marshal(respJSON)
  29195. fmt.Println("log")
  29196. fmt.Println(string(userJSONBytes))
  29197. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29198. utils.ErrorLog("解析失败:%v", err)
  29199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29200. return
  29201. }
  29202. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29203. bytesData, _ := json.Marshal(data)
  29204. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29205. resp, _ := client.Do(req)
  29206. defer resp.Body.Close()
  29207. body, ioErr := ioutil.ReadAll(resp.Body)
  29208. if ioErr != nil {
  29209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29211. return
  29212. }
  29213. var respJSON map[string]interface{}
  29214. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29217. return
  29218. }
  29219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29220. userJSONBytes, _ := json.Marshal(respJSON)
  29221. fmt.Println("log")
  29222. fmt.Println(string(userJSONBytes))
  29223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29224. utils.ErrorLog("解析失败:%v", err)
  29225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29226. return
  29227. }
  29228. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29229. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29230. if result3101.Infcode == "0" {
  29231. if len(result3101.Output.Result) > 0 {
  29232. var errMsgs []string
  29233. for _, item := range result3101.Output.Result {
  29234. errMsgs = append(errMsgs, item.VolaCont)
  29235. }
  29236. c.ServeSuccessJSON(map[string]interface{}{
  29237. "failed_code": -10,
  29238. "msg": errMsgs,
  29239. })
  29240. return
  29241. } else {
  29242. if miConfig.MdtrtareaAdmvs == "320921" {
  29243. data["doctor_id"] = "D320923012139"
  29244. } else {
  29245. data["doctor_id"] = "D371621008686"
  29246. }
  29247. bytesData, _ := json.Marshal(data)
  29248. var req *http.Request
  29249. if miConfig.MdtrtareaAdmvs == "320921" {
  29250. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29251. } else {
  29252. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29253. }
  29254. resp, _ := client.Do(req)
  29255. defer resp.Body.Close()
  29256. body, ioErr := ioutil.ReadAll(resp.Body)
  29257. if ioErr != nil {
  29258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29260. return
  29261. }
  29262. var respJSON map[string]interface{}
  29263. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29266. return
  29267. }
  29268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29269. userJSONBytes, _ := json.Marshal(respJSON)
  29270. fmt.Println("log")
  29271. fmt.Println(string(userJSONBytes))
  29272. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29273. utils.ErrorLog("解析失败:%v", err)
  29274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29275. return
  29276. }
  29277. res.InfRefmsgid = resFour10265.InfRefmsgid
  29278. res.Output = resFour10265.Output
  29279. res.ErrMsg = resFour10265.ErrMsg
  29280. res.Cainfo = resFour10265.Cainfo
  29281. res.WarnMsg = resFour10265.WarnMsg
  29282. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29283. res.Infcode = infocode
  29284. }
  29285. }
  29286. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29287. var pagesize int = 5
  29288. var start int = 1
  29289. var stop int
  29290. var pagecount int
  29291. var curpage int
  29292. data["doctor_id"] = doctor_info.DoctorNumber
  29293. var res2 ResultFour
  29294. //var result res.
  29295. //总页数,向上取整,注意除之前要先转换类型为float64
  29296. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29297. for curpage = 1; curpage <= pagecount; curpage++ {
  29298. if curpage == 1 {
  29299. start = 1
  29300. } else {
  29301. start = (curpage-1)*pagesize + 1
  29302. }
  29303. stop = curpage * pagesize
  29304. if stop > len(prescriptions) {
  29305. stop = len(prescriptions)
  29306. }
  29307. //var requestLog string
  29308. data["pre"] = prescriptions[start-1 : stop]
  29309. fmt.Println(data["pre"])
  29310. bytesData, _ := json.Marshal(data)
  29311. var req *http.Request
  29312. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29313. resp, _ := client.Do(req)
  29314. defer resp.Body.Close()
  29315. body, ioErr := ioutil.ReadAll(resp.Body)
  29316. if ioErr != nil {
  29317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29319. return
  29320. }
  29321. var respJSON map[string]interface{}
  29322. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29325. return
  29326. }
  29327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29328. userJSONBytes, _ := json.Marshal(respJSON)
  29329. fmt.Println("log")
  29330. fmt.Println(string(userJSONBytes))
  29331. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29332. utils.ErrorLog("解析失败:%v", err)
  29333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29334. return
  29335. }
  29336. res.InfRefmsgid = resFour10265.InfRefmsgid
  29337. res.Output = resFour10265.Output
  29338. res.ErrMsg = resFour10265.ErrMsg
  29339. res.Cainfo = resFour10265.Cainfo
  29340. res.WarnMsg = resFour10265.WarnMsg
  29341. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29342. res.Infcode = infocode
  29343. if infocode == 0 {
  29344. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29345. } else {
  29346. isSuccess = false
  29347. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29348. res.Infcode = -1
  29349. res.ErrMsg = resFour10265.ErrMsg
  29350. errlog := &models.HisOrderError{
  29351. UserOrgId: adminUser.CurrentOrgId,
  29352. Ctime: time.Now().Unix(),
  29353. Mtime: time.Now().Unix(),
  29354. Number: chrg_bchno,
  29355. ErrMsg: "",
  29356. Status: 1,
  29357. PatientId: id,
  29358. RecordTime: recordDateTime,
  29359. Stage: 4,
  29360. }
  29361. service.CreateErrMsgLog(errlog)
  29362. }
  29363. }
  29364. if isSuccess {
  29365. res.Infcode = 0
  29366. res.Output.Result = res2.Output.Result
  29367. } else {
  29368. order := &models.HisOrder{
  29369. UserOrgId: adminUser.CurrentOrgId,
  29370. HisPatientId: his.ID,
  29371. PatientId: his.PatientId,
  29372. SettleAccountsDate: recordDateTime,
  29373. Ctime: time.Now().Unix(),
  29374. Mtime: time.Now().Unix(),
  29375. MdtrtId: his.Number,
  29376. PsnNo: his.PsnNo,
  29377. MedType: strconv.FormatInt(reg_type, 10),
  29378. Status: 1,
  29379. Number: chrg_bchno,
  29380. Infcode: res.Infcode,
  29381. WarnMsg: res.WarnMsg,
  29382. Cainfo: res.Cainfo,
  29383. ErrMsg: res.ErrMsg,
  29384. RespondTime: res.RefmsgTime,
  29385. InfRefmsgid: res.InfRefmsgid,
  29386. OrderStatus: 1,
  29387. IsMedicineInsurance: 1,
  29388. SettleType: settle_accounts_type,
  29389. SettleStartTime: start_time,
  29390. SettleEndTime: end_time,
  29391. Creator: roles.AdminUserId,
  29392. Modify: roles.AdminUserId,
  29393. PType: 2,
  29394. Diagnosis: diagnosis_id,
  29395. }
  29396. err = service.CreateOrder(order)
  29397. if err != nil {
  29398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29399. return
  29400. }
  29401. c.ServeSuccessJSON(map[string]interface{}{
  29402. "failed_code": -10,
  29403. "msg": res2.ErrMsg,
  29404. })
  29405. return
  29406. }
  29407. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29408. 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)
  29409. var dat map[string]interface{}
  29410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29411. fmt.Println(dat)
  29412. } else {
  29413. fmt.Println(err)
  29414. }
  29415. saveLog(result, request_log, "2204", "上传费用明细")
  29416. userJSONBytes, _ := json.Marshal(dat)
  29417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29418. utils.ErrorLog("解析失败:%v", err)
  29419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29420. return
  29421. }
  29422. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29423. 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, "", "")
  29424. var dat map[string]interface{}
  29425. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29426. fmt.Println(dat)
  29427. } else {
  29428. fmt.Println(err)
  29429. }
  29430. saveLog(result, request_log, "2204", "上传费用明细")
  29431. userJSONBytes, _ := json.Marshal(dat)
  29432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29433. utils.ErrorLog("解析失败:%v", err)
  29434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29435. return
  29436. }
  29437. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29438. 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, "", "")
  29439. var dat map[string]interface{}
  29440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29441. fmt.Println(dat)
  29442. } else {
  29443. fmt.Println(err)
  29444. }
  29445. saveLog(result, request_log, "2204", "上传费用明细")
  29446. userJSONBytes, _ := json.Marshal(dat)
  29447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29448. utils.ErrorLog("解析失败:%v", err)
  29449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29450. return
  29451. }
  29452. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29453. bytesData, _ := json.Marshal(data)
  29454. var req *http.Request
  29455. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29456. resp, _ := client.Do(req)
  29457. defer resp.Body.Close()
  29458. body, ioErr := ioutil.ReadAll(resp.Body)
  29459. if ioErr != nil {
  29460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29462. return
  29463. }
  29464. var respJSON map[string]interface{}
  29465. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29468. return
  29469. }
  29470. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29471. if status == "0" {
  29472. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29473. c.ServeSuccessJSON(map[string]interface{}{
  29474. "failed_code": -10,
  29475. "msg": err_msg,
  29476. })
  29477. return
  29478. }
  29479. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29480. userJSONBytes, _ := json.Marshal(respJSON)
  29481. fmt.Println("log")
  29482. fmt.Println(string(userJSONBytes))
  29483. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29484. utils.ErrorLog("解析失败:%v", err)
  29485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29486. return
  29487. }
  29488. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29489. bytesData, _ := json.Marshal(data)
  29490. var req *http.Request
  29491. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29492. resp, _ := client.Do(req)
  29493. defer resp.Body.Close()
  29494. body, ioErr := ioutil.ReadAll(resp.Body)
  29495. if ioErr != nil {
  29496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29498. return
  29499. }
  29500. var respJSON map[string]interface{}
  29501. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29504. return
  29505. }
  29506. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29507. if status == "0" {
  29508. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29509. c.ServeSuccessJSON(map[string]interface{}{
  29510. "failed_code": -10,
  29511. "msg": err_msg,
  29512. })
  29513. return
  29514. }
  29515. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29516. userJSONBytes, _ := json.Marshal(respJSON)
  29517. fmt.Println("log")
  29518. fmt.Println(string(userJSONBytes))
  29519. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29520. utils.ErrorLog("解析失败:%v", err)
  29521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29522. return
  29523. }
  29524. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29525. 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, "", "")
  29526. var dat map[string]interface{}
  29527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29528. fmt.Println(dat)
  29529. } else {
  29530. fmt.Println(err)
  29531. }
  29532. saveLog(result, request_log, "2204", "上传费用明细")
  29533. userJSONBytes, _ := json.Marshal(dat)
  29534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29535. utils.ErrorLog("解析失败:%v", err)
  29536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29537. return
  29538. }
  29539. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29540. bytesData, _ := json.Marshal(data)
  29541. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29542. resp, _ := client.Do(req)
  29543. defer resp.Body.Close()
  29544. body, ioErr := ioutil.ReadAll(resp.Body)
  29545. if ioErr != nil {
  29546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29548. return
  29549. }
  29550. var respJSON map[string]interface{}
  29551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29554. return
  29555. }
  29556. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29557. userJSONBytes, _ := json.Marshal(respJSON)
  29558. fmt.Println("log")
  29559. fmt.Println(string(userJSONBytes))
  29560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29561. utils.ErrorLog("解析失败:%v", err)
  29562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29563. return
  29564. }
  29565. } else {
  29566. if miConfig.MdtrtareaAdmvs == "441202" {
  29567. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29568. if result3101.Infcode == 0 {
  29569. if len(result3101.Output.Result) > 0 {
  29570. var errMsgs []string
  29571. for _, item := range result3101.Output.Result {
  29572. errMsgs = append(errMsgs, item.VolaCont)
  29573. }
  29574. c.ServeSuccessJSON(map[string]interface{}{
  29575. "failed_code": -10,
  29576. "msg": errMsgs,
  29577. })
  29578. return
  29579. } else {
  29580. 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)
  29581. var dat map[string]interface{}
  29582. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29583. fmt.Println(dat)
  29584. } else {
  29585. fmt.Println(err)
  29586. }
  29587. saveLog(result, request_log, "2204", "上传费用明细")
  29588. userJSONBytes, _ := json.Marshal(dat)
  29589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29590. utils.ErrorLog("解析失败:%v", err)
  29591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29592. return
  29593. }
  29594. }
  29595. } else {
  29596. c.ServeSuccessJSON(map[string]interface{}{
  29597. "failed_code": -10,
  29598. "msg": result3101.ErrMsg,
  29599. })
  29600. return
  29601. }
  29602. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29603. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29604. if result3101.Infcode == 0 {
  29605. if len(result3101.Output.Result) > 0 {
  29606. var errMsgs []string
  29607. for _, item := range result3101.Output.Result {
  29608. errMsgs = append(errMsgs, item.VolaCont)
  29609. }
  29610. c.ServeSuccessJSON(map[string]interface{}{
  29611. "failed_code": -10,
  29612. "msg": errMsgs,
  29613. })
  29614. return
  29615. } else {
  29616. 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)
  29617. var dat map[string]interface{}
  29618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29619. fmt.Println(dat)
  29620. } else {
  29621. fmt.Println(err)
  29622. }
  29623. saveLog(result, request_log, "2204", "上传费用明细")
  29624. userJSONBytes, _ := json.Marshal(dat)
  29625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29626. utils.ErrorLog("解析失败:%v", err)
  29627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29628. return
  29629. }
  29630. }
  29631. } else {
  29632. c.ServeSuccessJSON(map[string]interface{}{
  29633. "failed_code": -10,
  29634. "msg": result3101.ErrMsg,
  29635. })
  29636. return
  29637. }
  29638. } else {
  29639. if miConfig.Code == "H15049901371" {
  29640. 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)
  29641. var dat map[string]interface{}
  29642. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29643. fmt.Println(dat)
  29644. } else {
  29645. fmt.Println(err)
  29646. }
  29647. saveLog(result, request_log, "2204", "上传费用明细")
  29648. userJSONBytes, _ := json.Marshal(dat)
  29649. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29650. utils.ErrorLog("解析失败:%v", err)
  29651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29652. return
  29653. }
  29654. res.InfRefmsgid = resFour10265.InfRefmsgid
  29655. res.Output = resFour10265.Output
  29656. res.ErrMsg = resFour10265.ErrMsg
  29657. res.Cainfo = resFour10265.Cainfo
  29658. res.WarnMsg = resFour10265.WarnMsg
  29659. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29660. res.Infcode = infocode
  29661. } else {
  29662. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" {
  29663. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29664. if result3101.Infcode == 0 {
  29665. if len(result3101.Output.Result) > 0 {
  29666. var errMsgs []string
  29667. for _, item := range result3101.Output.Result {
  29668. errMsgs = append(errMsgs, item.VolaCont)
  29669. }
  29670. c.ServeSuccessJSON(map[string]interface{}{
  29671. "failed_code": -10,
  29672. "msg": errMsgs,
  29673. })
  29674. return
  29675. } else {
  29676. 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)
  29677. var dat map[string]interface{}
  29678. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29679. fmt.Println(dat)
  29680. } else {
  29681. fmt.Println(err)
  29682. }
  29683. saveLog(result, request_log, "2204", "上传费用明细")
  29684. userJSONBytes, _ := json.Marshal(dat)
  29685. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29686. utils.ErrorLog("解析失败:%v", err)
  29687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29688. return
  29689. }
  29690. }
  29691. } else {
  29692. c.ServeSuccessJSON(map[string]interface{}{
  29693. "failed_code": -10,
  29694. "msg": result3101.ErrMsg,
  29695. })
  29696. return
  29697. }
  29698. } else {
  29699. 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)
  29700. var dat map[string]interface{}
  29701. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29702. fmt.Println(dat)
  29703. } else {
  29704. fmt.Println(err)
  29705. }
  29706. saveLog(result, request_log, "2204", "上传费用明细")
  29707. userJSONBytes, _ := json.Marshal(dat)
  29708. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29709. utils.ErrorLog("解析失败:%v", err)
  29710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29711. return
  29712. }
  29713. }
  29714. }
  29715. }
  29716. }
  29717. var total_two float64
  29718. if res.Infcode == -1 {
  29719. errlog := &models.HisOrderError{
  29720. UserOrgId: adminUser.CurrentOrgId,
  29721. Ctime: time.Now().Unix(),
  29722. Mtime: time.Now().Unix(),
  29723. Number: chrg_bchno,
  29724. ErrMsg: res.ErrMsg,
  29725. Status: 1,
  29726. PatientId: id,
  29727. RecordTime: recordDateTime,
  29728. Stage: 4,
  29729. }
  29730. service.CreateErrMsgLog(errlog)
  29731. c.ServeSuccessJSON(map[string]interface{}{
  29732. "failed_code": -10,
  29733. "msg": res.ErrMsg,
  29734. })
  29735. return
  29736. }
  29737. if res.Infcode == 0 {
  29738. order := &models.HisOrder{
  29739. UserOrgId: adminUser.CurrentOrgId,
  29740. HisPatientId: his.ID,
  29741. PatientId: his.PatientId,
  29742. SettleAccountsDate: recordDateTime,
  29743. Ctime: time.Now().Unix(),
  29744. Mtime: time.Now().Unix(),
  29745. MdtrtId: his.Number,
  29746. PsnNo: his.PsnNo,
  29747. MedType: strconv.FormatInt(reg_type, 10),
  29748. Status: 1,
  29749. Number: chrg_bchno,
  29750. Infcode: res.Infcode,
  29751. WarnMsg: res.WarnMsg,
  29752. Cainfo: res.Cainfo,
  29753. ErrMsg: res.ErrMsg,
  29754. RespondTime: res.RefmsgTime,
  29755. InfRefmsgid: res.InfRefmsgid,
  29756. OrderStatus: 1,
  29757. IsMedicineInsurance: 1,
  29758. SettleType: settle_accounts_type,
  29759. SettleStartTime: start_time,
  29760. SettleEndTime: end_time,
  29761. Creator: roles.AdminUserId,
  29762. Modify: roles.AdminUserId,
  29763. PType: 2,
  29764. Diagnosis: diagnosis_id,
  29765. }
  29766. err = service.CreateOrder(order)
  29767. if err != nil {
  29768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29769. return
  29770. }
  29771. for _, item := range res.Output.Result {
  29772. temp := strings.Split(item.FeedetlSn, "-")
  29773. var advice_id int64 = 0
  29774. var project_id int64 = 0
  29775. var types int64 = 0
  29776. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29777. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29778. if temp[1] == "1" {
  29779. advice_id = id
  29780. project_id = 0
  29781. } else if temp[1] == "2" {
  29782. advice_id = 0
  29783. project_id = id
  29784. }
  29785. total_two = total_two + item.DetItemFeeSumamt
  29786. info := &models.HisOrderInfo{
  29787. OrderNumber: order.Number,
  29788. FeedetlSn: item.FeedetlSn,
  29789. UploadDate: time.Now().Unix(),
  29790. AdviceId: advice_id,
  29791. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29792. Cnt: item.Cnt,
  29793. Pric: float64(item.Pric),
  29794. PatientId: his.PatientId,
  29795. PricUplmtAmt: item.PricUplmtAmt,
  29796. SelfpayProp: item.SelfpayProp,
  29797. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29798. OverlmtAmt: item.OverlmtAmt,
  29799. PreselfpayAmt: item.PreselfpayAmt,
  29800. BasMednFlag: item.BasMednFlag,
  29801. MedChrgitmType: item.MedChrgitmType,
  29802. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29803. Status: 1,
  29804. Memo: item.Memo,
  29805. Mtime: time.Now().Unix(),
  29806. InscpScpAmt: item.InscpScpAmt,
  29807. DrtReimFlag: item.DrtReimFlag,
  29808. Ctime: time.Now().Unix(),
  29809. ListSpItemFlag: item.ListSpItemFlag,
  29810. ChldMedcFlag: item.ChldMedcFlag,
  29811. LmtUsedFlag: item.LmtUsedFlag,
  29812. ChrgitmLv: item.ChrgitmLv,
  29813. UserOrgId: adminUser.CurrentOrgId,
  29814. HisPatientId: his.ID,
  29815. OrderId: order.ID,
  29816. ProjectId: project_id,
  29817. Type: types,
  29818. }
  29819. service.CreateOrderInfo(info)
  29820. }
  29821. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29822. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29823. var total float64
  29824. for _, item := range prescriptions {
  29825. if item.Type == 1 { //药品
  29826. for _, subItem := range item.HisDoctorAdviceInfo {
  29827. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29828. total_one := price * subItem.PrescribingNumber
  29829. fmt.Println("subItem")
  29830. fmt.Println(subItem.Price)
  29831. fmt.Println("price")
  29832. fmt.Println(price)
  29833. fmt.Println("total_one")
  29834. fmt.Println(total_one)
  29835. total = total + total_one
  29836. fmt.Println(total)
  29837. }
  29838. }
  29839. if item.Type == 2 { //项目
  29840. for _, subItem := range item.HisPrescriptionProject {
  29841. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29842. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29843. total_one := price * cnt
  29844. total = total + total_one
  29845. }
  29846. }
  29847. }
  29848. allTotal := fmt.Sprintf("%.2f", total)
  29849. if res.Infcode == 0 {
  29850. var rf []*ResultFive
  29851. json.Unmarshal([]byte(his.Iinfo), &rf)
  29852. chrg_bchno := chrg_bchno
  29853. cert_no := his.Certno
  29854. var insutypes []string
  29855. var insutype string
  29856. var is390 int = 0
  29857. var is310 int = 0
  29858. for _, item := range rf {
  29859. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29860. insutypes = append(insutypes, item.Insutype)
  29861. }
  29862. }
  29863. if len(insutypes) == 1 {
  29864. insutype = insutypes[0]
  29865. } else {
  29866. for _, i := range insutypes {
  29867. if i == "390" {
  29868. is390 = 1
  29869. }
  29870. if i == "310" {
  29871. is310 = 1
  29872. }
  29873. }
  29874. }
  29875. if is390 == 1 {
  29876. insutype = "390"
  29877. }
  29878. if is310 == 1 {
  29879. insutype = "310"
  29880. }
  29881. if len(insutypes) == 0 {
  29882. insutype = "390"
  29883. }
  29884. if len(insutypes) == 2 {
  29885. insutype = strconv.FormatInt(his.SocialType, 10)
  29886. }
  29887. //insutype = "390"
  29888. if his.IdCardType == 1 {
  29889. cert_no = his.MedicalInsuranceNumber
  29890. } else {
  29891. cert_no = his.Certno
  29892. }
  29893. var res ResultSeven
  29894. var ahres ResultSevenAH
  29895. var resSeven10265 ResultSeven10265
  29896. var resSeven10265Two ResultSeven10265Two
  29897. var gzresSeven10265Two GZResultSeven10265Two
  29898. if miConfig.MdtrtareaAdmvs == "421300" {
  29899. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29900. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29901. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29902. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29903. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29904. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29905. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29906. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29907. resp, requestErr := http.Get(api)
  29908. if requestErr != nil {
  29909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29910. return
  29911. }
  29912. body, ioErr := ioutil.ReadAll(resp.Body)
  29913. if ioErr != nil {
  29914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29916. return
  29917. }
  29918. var respJSON map[string]interface{}
  29919. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29922. return
  29923. }
  29924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29925. result, _ := json.Marshal(respJSON)
  29926. fmt.Println("log")
  29927. fmt.Println(string(result))
  29928. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29929. utils.ErrorLog("解析失败:%v", err)
  29930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29931. return
  29932. }
  29933. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29934. if reg_type == 11 && his.Insutype == "390" {
  29935. reg_type = 110104
  29936. }
  29937. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29938. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29939. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29940. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29941. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29942. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29943. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29944. resp, requestErr := http.Get(api)
  29945. if requestErr != nil {
  29946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29947. return
  29948. }
  29949. body, ioErr := ioutil.ReadAll(resp.Body)
  29950. if ioErr != nil {
  29951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29953. return
  29954. }
  29955. var respJSON map[string]interface{}
  29956. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29959. return
  29960. }
  29961. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29962. result, _ := json.Marshal(respJSON)
  29963. fmt.Println("log")
  29964. fmt.Println(string(result))
  29965. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29966. utils.ErrorLog("解析失败:%v", err)
  29967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29968. return
  29969. }
  29970. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29971. if reg_type == 11 && his.Insutype == "390" {
  29972. reg_type = 110104
  29973. }
  29974. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29975. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29976. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29977. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29978. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29979. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29980. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29981. resp, requestErr := http.Get(api)
  29982. if requestErr != nil {
  29983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29984. return
  29985. }
  29986. body, ioErr := ioutil.ReadAll(resp.Body)
  29987. if ioErr != nil {
  29988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29990. return
  29991. }
  29992. var respJSON map[string]interface{}
  29993. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29996. return
  29997. }
  29998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29999. result, _ := json.Marshal(respJSON)
  30000. fmt.Println("log")
  30001. fmt.Println(string(result))
  30002. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30003. utils.ErrorLog("解析失败:%v", err)
  30004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30005. return
  30006. }
  30007. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30008. if reg_type == 11 && his.Insutype == "390" {
  30009. reg_type = 110104
  30010. }
  30011. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30012. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30013. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30014. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30015. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30016. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30017. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30018. resp, requestErr := http.Get(api)
  30019. if requestErr != nil {
  30020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30021. return
  30022. }
  30023. body, ioErr := ioutil.ReadAll(resp.Body)
  30024. if ioErr != nil {
  30025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30027. return
  30028. }
  30029. var respJSON map[string]interface{}
  30030. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30033. return
  30034. }
  30035. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30036. result, _ := json.Marshal(respJSON)
  30037. fmt.Println("log")
  30038. fmt.Println(string(result))
  30039. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30040. utils.ErrorLog("解析失败:%v", err)
  30041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30042. return
  30043. }
  30044. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30045. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30046. if result3101.Infcode == "0" {
  30047. if len(result3101.Output.Result) > 0 {
  30048. var errMsgs []string
  30049. for _, item := range result3101.Output.Result {
  30050. errMsgs = append(errMsgs, item.VolaCont)
  30051. }
  30052. c.ServeSuccessJSON(map[string]interface{}{
  30053. "failed_code": -10,
  30054. "msg": errMsgs,
  30055. })
  30056. return
  30057. } else {
  30058. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30059. if his.IdCardType != 4 {
  30060. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30061. bas := strings.Split(psn_info.CardInfo, "|")
  30062. if his.IdCardType == 1 {
  30063. cert_no = bas[2]
  30064. } else {
  30065. cert_no = bas[1]
  30066. }
  30067. } else {
  30068. cert_no = his.Certno
  30069. }
  30070. //江苏地区国家医保医疗类别
  30071. //职工透析:医疗类别选特殊情况门诊9933
  30072. //居民血透门慢: 医疗类别选门诊慢病1402
  30073. //var med_type string
  30074. //if his.Insutype == "310" {
  30075. // if reg_type == 14 {
  30076. // med_type = "9933"
  30077. // } else if reg_type == 11 {
  30078. // med_type = "11"
  30079. //
  30080. // }
  30081. //} else if his.Insutype == "390" {
  30082. // if reg_type == 14 {
  30083. // med_type = "1402"
  30084. // } else if reg_type == 11 {
  30085. // med_type = "11"
  30086. // }
  30087. //}
  30088. var api string
  30089. if miConfig.MdtrtareaAdmvs == "320921" {
  30090. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30091. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30092. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30093. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30094. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30095. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30096. "&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
  30097. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30098. } else {
  30099. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30100. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30101. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30102. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30103. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30104. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30105. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30106. "&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
  30107. }
  30108. resp, requestErr := http.Get(api)
  30109. if requestErr != nil {
  30110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30111. return
  30112. }
  30113. body, ioErr := ioutil.ReadAll(resp.Body)
  30114. if ioErr != nil {
  30115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30117. return
  30118. }
  30119. var respJSON map[string]interface{}
  30120. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30123. return
  30124. }
  30125. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30126. result, _ := json.Marshal(respJSON)
  30127. fmt.Println("log")
  30128. fmt.Println(string(result))
  30129. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  30130. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30131. utils.ErrorLog("解析失败:%v", err)
  30132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30133. return
  30134. }
  30135. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30136. res.Output = resSeven10265.Output
  30137. res.ErrMsg = resSeven10265.ErrMsg
  30138. res.Cainfo = resSeven10265.Cainfo
  30139. res.WarnMsg = resSeven10265.WarnMsg
  30140. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30141. res.Infcode = infocode
  30142. } else {
  30143. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  30144. utils.ErrorLog("解析失败:%v", err)
  30145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30146. return
  30147. }
  30148. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  30149. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  30150. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  30151. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  30152. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30153. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  30154. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  30155. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  30156. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  30157. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  30158. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  30159. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30160. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  30161. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  30162. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30163. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30164. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  30165. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  30166. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  30167. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  30168. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  30169. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30170. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  30171. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  30172. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  30173. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  30174. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  30175. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  30176. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  30177. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  30178. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30179. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  30180. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  30181. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  30182. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30183. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30184. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30185. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30186. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  30187. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30188. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  30189. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  30190. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  30191. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  30192. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  30193. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  30194. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  30195. res.ErrMsg = resSeven10265Two.ErrMsg
  30196. res.Cainfo = resSeven10265Two.Cainfo
  30197. res.WarnMsg = resSeven10265Two.WarnMsg
  30198. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30199. res.Infcode = infocode
  30200. }
  30201. }
  30202. }
  30203. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30204. psn_info, _ := service.GetPsnByPatientId(id)
  30205. var verify_number string
  30206. if psn_info.IdCardType == 4 {
  30207. verify_number = psn_info.VerifyNumber
  30208. } else if psn_info.IdCardType == 1 {
  30209. bas := strings.Split(psn_info.CardInfo, "|")
  30210. cardNumber := bas[2]
  30211. verify_number = cardNumber
  30212. } else {
  30213. psn_info.IdCardType = 2
  30214. verify_number = psn_info.Certno
  30215. }
  30216. var api string
  30217. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30218. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  30219. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30220. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30221. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  30222. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30223. "&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
  30224. resp, requestErr := http.Get(api)
  30225. if requestErr != nil {
  30226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30227. return
  30228. }
  30229. body, ioErr := ioutil.ReadAll(resp.Body)
  30230. if ioErr != nil {
  30231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30233. return
  30234. }
  30235. var respJSON map[string]interface{}
  30236. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30239. return
  30240. }
  30241. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30242. result, _ := json.Marshal(respJSON)
  30243. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30244. utils.ErrorLog("解析失败:%v", err)
  30245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30246. return
  30247. }
  30248. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30249. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  30250. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  30251. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30252. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  30253. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  30254. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  30255. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  30256. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  30257. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  30258. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  30259. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  30260. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  30261. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30262. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  30263. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  30264. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  30265. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  30266. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  30267. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30268. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30269. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30270. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30271. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30272. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30273. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30274. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30275. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30276. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30277. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30278. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30279. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30280. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30281. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30282. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30283. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30284. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30285. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30286. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30287. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30288. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30289. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30290. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30291. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30292. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30293. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30294. res.ErrMsg = resSeven10265.ErrMsg
  30295. res.Cainfo = resSeven10265.Cainfo
  30296. res.WarnMsg = resSeven10265.WarnMsg
  30297. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30298. res.Infcode = infocode
  30299. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30300. acct_used_flag := "1"
  30301. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30302. var result string
  30303. var request_log string
  30304. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30305. 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)
  30306. } else {
  30307. 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)
  30308. }
  30309. var dat map[string]interface{}
  30310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30311. fmt.Println(dat)
  30312. } else {
  30313. fmt.Println(err)
  30314. }
  30315. saveLog(result, request_log, "2206", "预结算")
  30316. userJSONBytes, _ := json.Marshal(dat)
  30317. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30318. utils.ErrorLog("解析失败:%v", err)
  30319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30320. return
  30321. }
  30322. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30323. var result string
  30324. var request_log string
  30325. if his.IdCardType == 2 {
  30326. 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, "")
  30327. } else if his.IdCardType == 1 {
  30328. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30329. bas := strings.Split(psn_info.CardInfo, "|")
  30330. basNumber := bas[2]
  30331. card_sn := bas[3]
  30332. var rf []*ResultFive
  30333. json.Unmarshal([]byte(his.Iinfo), &rf)
  30334. var psn_type string
  30335. for _, item := range rf {
  30336. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30337. psn_type = item.PsnType
  30338. }
  30339. }
  30340. 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)
  30341. } else {
  30342. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30343. //bas := strings.Split(psn_info.CardInfo, "|")
  30344. //basNumber := bas[2]
  30345. //card_sn := bas[3]
  30346. var rf []*ResultFive
  30347. json.Unmarshal([]byte(his.Iinfo), &rf)
  30348. var psn_type string
  30349. for _, item := range rf {
  30350. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30351. psn_type = item.PsnType
  30352. }
  30353. }
  30354. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30355. 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)
  30356. }
  30357. var dat map[string]interface{}
  30358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30359. fmt.Println(dat)
  30360. } else {
  30361. fmt.Println(err)
  30362. }
  30363. saveLog(result, request_log, "2206", "预结算")
  30364. userJSONBytes, _ := json.Marshal(dat)
  30365. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30366. utils.ErrorLog("解析失败:%v", err)
  30367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30368. return
  30369. }
  30370. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30371. var result string
  30372. var request_log string
  30373. if his.IdCardType == 2 {
  30374. 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, "")
  30375. } else if his.IdCardType == 1 {
  30376. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30377. bas := strings.Split(psn_info.CardInfo, "|")
  30378. basNumber := bas[0]
  30379. card_sn := ""
  30380. var rf []*ResultFive
  30381. json.Unmarshal([]byte(his.Iinfo), &rf)
  30382. var psn_type string
  30383. for _, item := range rf {
  30384. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30385. psn_type = item.PsnType
  30386. }
  30387. }
  30388. 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)
  30389. } else {
  30390. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30391. //bas := strings.Split(psn_info.CardInfo, "|")
  30392. //basNumber := bas[2]
  30393. //card_sn := bas[3]
  30394. var rf []*ResultFive
  30395. json.Unmarshal([]byte(his.Iinfo), &rf)
  30396. var psn_type string
  30397. for _, item := range rf {
  30398. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30399. psn_type = item.PsnType
  30400. }
  30401. }
  30402. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30403. 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)
  30404. }
  30405. var dat map[string]interface{}
  30406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30407. fmt.Println(dat)
  30408. } else {
  30409. fmt.Println(err)
  30410. }
  30411. saveLog(result, request_log, "2206", "预结算")
  30412. userJSONBytes, _ := json.Marshal(dat)
  30413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30414. utils.ErrorLog("解析失败:%v", err)
  30415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30416. return
  30417. }
  30418. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30419. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30420. if his.IdCardType == 4 {
  30421. psn_info.VerifyNumber = psn_info.VerifyNumber
  30422. cert_no = psn_info.VerifyNumber
  30423. } else if his.IdCardType == 2 {
  30424. cert_no = psn_info.Certno
  30425. psn_info.VerifyNumber = psn_info.Certno
  30426. } else {
  30427. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30428. bas := strings.Split(psn_info.CardInfo, "|")
  30429. if his.IdCardType == 1 {
  30430. cert_no = bas[2]
  30431. } else {
  30432. cert_no = bas[1]
  30433. }
  30434. }
  30435. var api string
  30436. var med_type string
  30437. if his.Insutype == "390" {
  30438. if reg_type == 992102 {
  30439. med_type = "992102"
  30440. }
  30441. if reg_type == 140104 {
  30442. med_type = "140104"
  30443. }
  30444. if reg_type == 140201 {
  30445. med_type = "140201"
  30446. }
  30447. if reg_type == 14 {
  30448. med_type = "140104"
  30449. }
  30450. } else if his.Insutype == "310" {
  30451. if reg_type == 992102 {
  30452. med_type = "992102"
  30453. }
  30454. if reg_type == 140104 {
  30455. med_type = "140104"
  30456. }
  30457. if reg_type == 140201 {
  30458. med_type = "140201"
  30459. }
  30460. if reg_type == 14 {
  30461. med_type = "140104"
  30462. }
  30463. }
  30464. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30465. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30466. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30467. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30468. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30469. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30470. "&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
  30471. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30472. resp, requestErr := http.Get(api)
  30473. if requestErr != nil {
  30474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30475. return
  30476. }
  30477. body, ioErr := ioutil.ReadAll(resp.Body)
  30478. if ioErr != nil {
  30479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30481. return
  30482. }
  30483. var respJSON map[string]interface{}
  30484. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30487. return
  30488. }
  30489. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30490. if status == "0" {
  30491. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30492. c.ServeSuccessJSON(map[string]interface{}{
  30493. "failed_code": -10,
  30494. "msg": err_msg,
  30495. })
  30496. return
  30497. }
  30498. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30499. result, _ := json.Marshal(respJSON)
  30500. fmt.Println("log")
  30501. fmt.Println(string(result))
  30502. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30503. utils.ErrorLog("解析失败:%v", err)
  30504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30505. return
  30506. }
  30507. res.InfRefmsgid = ahres.InfRefmsgid
  30508. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30509. // 创建对应的Time类型
  30510. t := time.UnixMilli(timestamp)
  30511. // 格式化成指定的日期字符串
  30512. str := t.Format("2006-01-02 15:04:05")
  30513. res.Output.Setlinfo.SetlTime = str
  30514. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30515. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30516. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30517. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30518. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30519. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30520. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30521. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30522. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30523. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30524. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30525. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30526. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30527. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30528. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30529. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30530. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30531. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30532. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30533. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30534. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30535. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30536. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30537. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30538. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30539. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30540. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30541. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30542. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30543. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30544. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30545. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30546. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30547. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30548. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30549. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30550. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30551. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30552. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30553. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30554. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30555. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30556. //res.Output.Setldetail = ahres.Output.Setldetail
  30557. res.ErrMsg = ahres.ErrMsg
  30558. res.Cainfo = ahres.Cainfo
  30559. res.WarnMsg = ahres.WarnMsg
  30560. res.Infcode = ahres.Infcode
  30561. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30562. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30563. if his.IdCardType == 4 {
  30564. psn_info.VerifyNumber = psn_info.VerifyNumber
  30565. cert_no = psn_info.Certno
  30566. } else if his.IdCardType == 2 {
  30567. cert_no = psn_info.Certno
  30568. psn_info.VerifyNumber = psn_info.Certno
  30569. } else {
  30570. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30571. bas := strings.Split(psn_info.CardInfo, "|")
  30572. if his.IdCardType == 1 {
  30573. cert_no = bas[2]
  30574. } else {
  30575. cert_no = bas[1]
  30576. }
  30577. }
  30578. var api string
  30579. var med_type string
  30580. if his.Insutype == "390" {
  30581. if reg_type == 992102 {
  30582. med_type = "992102"
  30583. }
  30584. if reg_type == 140104 {
  30585. med_type = "140104"
  30586. }
  30587. if reg_type == 140201 {
  30588. med_type = "140201"
  30589. }
  30590. if reg_type == 14 {
  30591. med_type = "14"
  30592. }
  30593. } else if his.Insutype == "310" {
  30594. if reg_type == 992102 {
  30595. med_type = "992102"
  30596. }
  30597. if reg_type == 140104 {
  30598. med_type = "140104"
  30599. }
  30600. if reg_type == 140201 {
  30601. med_type = "140201"
  30602. }
  30603. if reg_type == 14 {
  30604. med_type = "14"
  30605. }
  30606. }
  30607. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30608. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30609. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30610. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30611. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30612. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30613. "&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
  30614. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30615. resp, requestErr := http.Get(api)
  30616. if requestErr != nil {
  30617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30618. return
  30619. }
  30620. body, ioErr := ioutil.ReadAll(resp.Body)
  30621. if ioErr != nil {
  30622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30624. return
  30625. }
  30626. var respJSON map[string]interface{}
  30627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30630. return
  30631. }
  30632. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30633. if status == "0" {
  30634. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30635. c.ServeSuccessJSON(map[string]interface{}{
  30636. "failed_code": -10,
  30637. "msg": err_msg,
  30638. })
  30639. return
  30640. }
  30641. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30642. result, _ := json.Marshal(respJSON)
  30643. fmt.Println("log")
  30644. fmt.Println(string(result))
  30645. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30646. utils.ErrorLog("解析失败:%v", err)
  30647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30648. return
  30649. }
  30650. res.InfRefmsgid = ahres.InfRefmsgid
  30651. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30652. // 创建对应的Time类型
  30653. t := time.UnixMilli(timestamp)
  30654. // 格式化成指定的日期字符串
  30655. str := t.Format("2006-01-02 15:04:05")
  30656. res.Output.Setlinfo.SetlTime = str
  30657. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30658. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30659. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30660. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30661. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30662. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30663. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30664. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30665. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30666. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30667. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30668. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30669. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30670. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30671. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30672. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30673. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30674. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30675. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30676. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30677. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30678. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30679. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30680. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30681. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30682. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30683. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30684. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30685. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30686. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30687. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30688. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30689. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30690. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30691. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30692. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30693. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30694. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30695. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30696. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30697. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30698. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30699. //res.Output.Setldetail = ahres.Output.Setldetail
  30700. res.ErrMsg = ahres.ErrMsg
  30701. res.Cainfo = ahres.Cainfo
  30702. res.WarnMsg = ahres.WarnMsg
  30703. res.Infcode = ahres.Infcode
  30704. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30705. var result string
  30706. var request_log string
  30707. if his.IdCardType == 2 {
  30708. 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")
  30709. } else if his.IdCardType == 1 {
  30710. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30711. bas := strings.Split(psn_info.CardInfo, "|")
  30712. basNumber := bas[2]
  30713. card_sn := bas[3]
  30714. 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")
  30715. } else {
  30716. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30717. 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")
  30718. }
  30719. var dat map[string]interface{}
  30720. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30721. fmt.Println(dat)
  30722. } else {
  30723. fmt.Println(err)
  30724. }
  30725. saveLog(result, request_log, "2206", "预结算")
  30726. userJSONBytes, _ := json.Marshal(dat)
  30727. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30728. utils.ErrorLog("解析失败:%v", err)
  30729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30730. return
  30731. }
  30732. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30733. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30734. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30735. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30736. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30737. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30738. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30739. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30740. resp, requestErr := http.Get(api)
  30741. if requestErr != nil {
  30742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30743. return
  30744. }
  30745. body, ioErr := ioutil.ReadAll(resp.Body)
  30746. if ioErr != nil {
  30747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30749. return
  30750. }
  30751. var respJSON map[string]interface{}
  30752. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30755. return
  30756. }
  30757. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30758. result, _ := json.Marshal(respJSON)
  30759. fmt.Println("log")
  30760. fmt.Println(string(result))
  30761. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30762. utils.ErrorLog("解析失败:%v", err)
  30763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30764. return
  30765. }
  30766. } else {
  30767. if miConfig.MdtrtareaAdmvs == "441202" {
  30768. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30769. if result3101.Infcode == 0 {
  30770. if len(result3101.Output.Result) > 0 {
  30771. var errMsgs []string
  30772. for _, item := range result3101.Output.Result {
  30773. errMsgs = append(errMsgs, item.VolaCont)
  30774. }
  30775. c.ServeSuccessJSON(map[string]interface{}{
  30776. "failed_code": -10,
  30777. "msg": errMsgs,
  30778. })
  30779. return
  30780. } else {
  30781. var result string
  30782. var request_log string
  30783. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30784. allTotal = fmt.Sprintf("%.2f", total_two)
  30785. if his.IdCardType == 4 {
  30786. 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)
  30787. } else {
  30788. 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)
  30789. }
  30790. var dat map[string]interface{}
  30791. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30792. fmt.Println(dat)
  30793. } else {
  30794. fmt.Println(err)
  30795. }
  30796. saveLog(result, request_log, "2206", "预结算")
  30797. //userJSONBytes, _ := json.Marshal(dat)
  30798. //
  30799. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30800. // utils.ErrorLog("解析失败:%v", err)
  30801. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30802. // return
  30803. //}
  30804. userJSONBytes, _ := json.Marshal(dat)
  30805. if miConfig.Code == "H15049901371" {
  30806. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30807. utils.ErrorLog("解析失败:%v", err)
  30808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30809. return
  30810. }
  30811. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30812. res.Output = resSeven10265.Output
  30813. res.ErrMsg = resSeven10265.ErrMsg
  30814. res.Cainfo = resSeven10265.Cainfo
  30815. res.WarnMsg = resSeven10265.WarnMsg
  30816. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30817. res.Infcode = infocode
  30818. } else {
  30819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30820. utils.ErrorLog("解析失败:%v", err)
  30821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30822. return
  30823. }
  30824. }
  30825. }
  30826. } else {
  30827. c.ServeSuccessJSON(map[string]interface{}{
  30828. "failed_code": -10,
  30829. "msg": result3101.ErrMsg,
  30830. })
  30831. return
  30832. }
  30833. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30834. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30835. if result3101.Infcode == 0 {
  30836. if len(result3101.Output.Result) > 0 {
  30837. var errMsgs []string
  30838. for _, item := range result3101.Output.Result {
  30839. errMsgs = append(errMsgs, item.VolaCont)
  30840. }
  30841. c.ServeSuccessJSON(map[string]interface{}{
  30842. "failed_code": -10,
  30843. "msg": errMsgs,
  30844. })
  30845. return
  30846. } else {
  30847. var result string
  30848. var request_log string
  30849. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30850. allTotal = fmt.Sprintf("%.2f", total_two)
  30851. if his.IdCardType == 4 {
  30852. 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)
  30853. } else {
  30854. 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)
  30855. }
  30856. var dat map[string]interface{}
  30857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30858. fmt.Println(dat)
  30859. } else {
  30860. fmt.Println(err)
  30861. }
  30862. saveLog(result, request_log, "2206", "预结算")
  30863. //userJSONBytes, _ := json.Marshal(dat)
  30864. //
  30865. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30866. // utils.ErrorLog("解析失败:%v", err)
  30867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30868. // return
  30869. //}
  30870. userJSONBytes, _ := json.Marshal(dat)
  30871. if miConfig.Code == "H15049901371" {
  30872. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30873. utils.ErrorLog("解析失败:%v", err)
  30874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30875. return
  30876. }
  30877. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30878. res.Output = resSeven10265.Output
  30879. res.ErrMsg = resSeven10265.ErrMsg
  30880. res.Cainfo = resSeven10265.Cainfo
  30881. res.WarnMsg = resSeven10265.WarnMsg
  30882. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30883. res.Infcode = infocode
  30884. } else {
  30885. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30886. utils.ErrorLog("解析失败:%v", err)
  30887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30888. return
  30889. }
  30890. }
  30891. }
  30892. } else {
  30893. c.ServeSuccessJSON(map[string]interface{}{
  30894. "failed_code": -10,
  30895. "msg": result3101.ErrMsg,
  30896. })
  30897. return
  30898. }
  30899. } else {
  30900. var result string
  30901. var request_log string
  30902. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30903. allTotal = fmt.Sprintf("%.2f", total_two)
  30904. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  30905. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30906. if result3101.Infcode == 0 {
  30907. if len(result3101.Output.Result) > 0 {
  30908. var errMsgs []string
  30909. for _, item := range result3101.Output.Result {
  30910. errMsgs = append(errMsgs, item.VolaCont)
  30911. }
  30912. c.ServeSuccessJSON(map[string]interface{}{
  30913. "failed_code": -10,
  30914. "msg": errMsgs,
  30915. })
  30916. return
  30917. } else {
  30918. var result string
  30919. var request_log string
  30920. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30921. allTotal = fmt.Sprintf("%.2f", total_two)
  30922. if his.IdCardType == 4 {
  30923. 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)
  30924. } else {
  30925. 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)
  30926. }
  30927. var dat map[string]interface{}
  30928. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30929. fmt.Println(dat)
  30930. } else {
  30931. fmt.Println(err)
  30932. }
  30933. saveLog(result, request_log, "2206", "预结算")
  30934. }
  30935. } else {
  30936. c.ServeSuccessJSON(map[string]interface{}{
  30937. "failed_code": -10,
  30938. "msg": result3101.ErrMsg,
  30939. })
  30940. return
  30941. }
  30942. } else {
  30943. if his.IdCardType == 4 {
  30944. 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)
  30945. } else {
  30946. 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)
  30947. }
  30948. }
  30949. var dat map[string]interface{}
  30950. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30951. fmt.Println(dat)
  30952. } else {
  30953. fmt.Println(err)
  30954. }
  30955. saveLog(result, request_log, "2206", "预结算")
  30956. //userJSONBytes, _ := json.Marshal(dat)
  30957. //
  30958. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30959. // utils.ErrorLog("解析失败:%v", err)
  30960. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30961. // return
  30962. //}
  30963. userJSONBytes, _ := json.Marshal(dat)
  30964. if miConfig.Code == "H15049901371" {
  30965. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30966. utils.ErrorLog("解析失败:%v", err)
  30967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30968. return
  30969. }
  30970. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30971. res.Output = resSeven10265.Output
  30972. res.ErrMsg = resSeven10265.ErrMsg
  30973. res.Cainfo = resSeven10265.Cainfo
  30974. res.WarnMsg = resSeven10265.WarnMsg
  30975. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30976. res.Infcode = infocode
  30977. } else {
  30978. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30979. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30980. utils.ErrorLog("解析失败:%v", err)
  30981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30982. return
  30983. }
  30984. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30985. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30986. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30987. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30988. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30989. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30990. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30991. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30992. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30993. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30994. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30995. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30996. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30997. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30998. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30999. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  31000. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  31001. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  31002. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  31003. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  31004. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31005. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  31006. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  31007. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  31008. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  31009. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  31010. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  31011. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  31012. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  31013. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31014. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  31015. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  31016. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  31017. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31018. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31019. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31020. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31021. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  31022. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31023. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  31024. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  31025. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  31026. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  31027. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  31028. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  31029. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  31030. res.ErrMsg = gzresSeven10265Two.ErrMsg
  31031. res.Cainfo = gzresSeven10265Two.Cainfo
  31032. res.WarnMsg = gzresSeven10265Two.WarnMsg
  31033. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31034. //res.Infcode = infocode
  31035. } else {
  31036. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31037. utils.ErrorLog("解析失败:%v", err)
  31038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31039. return
  31040. }
  31041. }
  31042. }
  31043. }
  31044. }
  31045. utils.ErrorLog("解析失败:%v", res.Infcode)
  31046. if res.Infcode == -1 {
  31047. errlog := &models.HisOrderError{
  31048. UserOrgId: adminUser.CurrentOrgId,
  31049. Ctime: time.Now().Unix(),
  31050. Mtime: time.Now().Unix(),
  31051. Number: chrg_bchno,
  31052. ErrMsg: res.ErrMsg,
  31053. Status: 1,
  31054. PatientId: id,
  31055. RecordTime: recordDateTime,
  31056. Stage: 20,
  31057. }
  31058. service.CreateErrMsgLog(errlog)
  31059. c.ServeSuccessJSON(map[string]interface{}{
  31060. "failed_code": -10,
  31061. "msg": res.ErrMsg,
  31062. })
  31063. return
  31064. }
  31065. if res.Infcode != 0 {
  31066. errlog := &models.HisOrderError{
  31067. UserOrgId: adminUser.CurrentOrgId,
  31068. Ctime: time.Now().Unix(),
  31069. Mtime: time.Now().Unix(),
  31070. Number: chrg_bchno,
  31071. ErrMsg: res.ErrMsg,
  31072. Status: 1,
  31073. PatientId: id,
  31074. RecordTime: recordDateTime,
  31075. Stage: 20,
  31076. }
  31077. service.CreateErrMsgLog(errlog)
  31078. c.ServeSuccessJSON(map[string]interface{}{
  31079. "failed_code": -10,
  31080. "msg": res.ErrMsg,
  31081. })
  31082. return
  31083. } else {
  31084. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  31085. order.OrderStatus = 1
  31086. order.IsPre = 1
  31087. order.Status = 1
  31088. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  31089. order.SetlId = res.Output.Setlinfo.SetlID
  31090. order.PsnNo = res.Output.Setlinfo.PsnNo
  31091. order.PsnName = res.Output.Setlinfo.PsnName
  31092. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  31093. order.Certno = res.Output.Setlinfo.Certno
  31094. order.Gend = res.Output.Setlinfo.Gend
  31095. order.Naty = res.Output.Setlinfo.Naty
  31096. order.Age = res.Output.Setlinfo.Age
  31097. order.Insutype = res.Output.Setlinfo.Insutype
  31098. order.PsnType = res.Output.Setlinfo.PsnType
  31099. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  31100. order.SetlTime = res.Output.Setlinfo.SetlTime
  31101. order.AcctUsedFlag = acct_used_flag
  31102. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  31103. if res.Output.Setlinfo.MedType == "140101" {
  31104. order.MedType = "14"
  31105. } else {
  31106. if res.Output.Setlinfo.MedType == "110104" {
  31107. order.MedType = "11"
  31108. } else {
  31109. order.MedType = res.Output.Setlinfo.MedType
  31110. }
  31111. }
  31112. if res.Output.Setlinfo.MedType == "992102" {
  31113. order.MedType = "992102"
  31114. }
  31115. if res.Output.Setlinfo.MedType == "140104" {
  31116. order.MedType = "140104"
  31117. }
  31118. if res.Output.Setlinfo.MedType == "140201" {
  31119. order.MedType = "140201"
  31120. }
  31121. if res.Output.Setlinfo.MedType == "14" {
  31122. order.MedType = "14"
  31123. }
  31124. if reg_type == 1112 {
  31125. order.MedType = "1112"
  31126. }
  31127. if reg_type == 1111 {
  31128. order.MedType = "1111"
  31129. }
  31130. order.ClrType = res.Output.Setlinfo.ClrType
  31131. if adminUser.CurrentOrgId == 10480 {
  31132. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  31133. order.ClrType = "11"
  31134. } else {
  31135. order.ClrType = "9903"
  31136. }
  31137. }
  31138. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  31139. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  31140. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  31141. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  31142. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  31143. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  31144. order.HifpPay = res.Output.Setlinfo.HifpPay
  31145. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  31146. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  31147. order.HifesPay = res.Output.Setlinfo.HifesPay
  31148. order.HifobPay = res.Output.Setlinfo.HifobPay
  31149. order.MafPay = res.Output.Setlinfo.MafPay
  31150. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  31151. order.OthPay = res.Output.Setlinfo.OthPay
  31152. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  31153. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  31154. order.AcctPay = res.Output.Setlinfo.AcctPay
  31155. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  31156. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  31157. order.Balc = res.Output.Setlinfo.Balc
  31158. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  31159. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  31160. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  31161. order.ClrWay = res.Output.Setlinfo.ClrWay
  31162. order.Creator = order.Creator
  31163. order.Modify = roles.AdminUserId
  31164. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  31165. //detailStr := string(setlDetail)
  31166. //order.SetlDetail = detailStr
  31167. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  31168. err = service.UpDateOrder(order)
  31169. if err == nil {
  31170. c.ServeSuccessJSON(map[string]interface{}{
  31171. "msg": "预结算成功",
  31172. })
  31173. } else {
  31174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  31175. return
  31176. }
  31177. }
  31178. } else {
  31179. adminUser := c.GetAdminUserInfo()
  31180. errlog := &models.HisOrderError{
  31181. UserOrgId: adminUser.CurrentOrgId,
  31182. Ctime: time.Now().Unix(),
  31183. Mtime: time.Now().Unix(),
  31184. ErrMsg: res.ErrMsg,
  31185. Status: 1,
  31186. PatientId: id,
  31187. RecordTime: recordDateTime,
  31188. Stage: 4,
  31189. }
  31190. service.CreateErrMsgLog(errlog)
  31191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  31192. return
  31193. }
  31194. } else {
  31195. if miConfig.MdtrtareaAdmvs == "150499" {
  31196. order := &models.HisOrder{
  31197. UserOrgId: adminUser.CurrentOrgId,
  31198. HisPatientId: his.ID,
  31199. PatientId: his.PatientId,
  31200. SettleAccountsDate: recordDateTime,
  31201. Ctime: time.Now().Unix(),
  31202. Mtime: time.Now().Unix(),
  31203. MdtrtId: his.Number,
  31204. PsnNo: his.PsnNo,
  31205. MedType: strconv.FormatInt(reg_type, 10),
  31206. Status: 1,
  31207. Number: chrg_bchno,
  31208. Infcode: res.Infcode,
  31209. WarnMsg: res.WarnMsg,
  31210. Cainfo: res.Cainfo,
  31211. ErrMsg: res.ErrMsg,
  31212. RespondTime: res.RefmsgTime,
  31213. InfRefmsgid: res.InfRefmsgid,
  31214. OrderStatus: 1,
  31215. IsMedicineInsurance: 1,
  31216. SettleType: settle_accounts_type,
  31217. SettleStartTime: start_time,
  31218. SettleEndTime: end_time,
  31219. Creator: roles.AdminUserId,
  31220. Modify: roles.AdminUserId,
  31221. PType: 2,
  31222. Diagnosis: diagnosis_id,
  31223. }
  31224. err = service.CreateOrder(order)
  31225. if err != nil {
  31226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31227. return
  31228. }
  31229. }
  31230. adminUser := c.GetAdminUserInfo()
  31231. errlog := &models.HisOrderError{
  31232. UserOrgId: adminUser.CurrentOrgId,
  31233. Ctime: time.Now().Unix(),
  31234. Mtime: time.Now().Unix(),
  31235. ErrMsg: res.ErrMsg,
  31236. Status: 1,
  31237. PatientId: id,
  31238. RecordTime: recordDateTime,
  31239. Stage: 4,
  31240. }
  31241. service.CreateErrMsgLog(errlog)
  31242. c.ServeSuccessJSON(map[string]interface{}{
  31243. "failed_code": -10,
  31244. "msg": res.ErrMsg,
  31245. })
  31246. return
  31247. }
  31248. }
  31249. }
  31250. }
  31251. // 退款
  31252. func (c *HisApiController) Refund() {
  31253. order_id, _ := c.GetInt64("order_id")
  31254. admin_user_id, _ := c.GetInt64("admin_user_id")
  31255. adminUser := c.GetAdminUserInfo()
  31256. var order models.HisOrder
  31257. order, _ = service.GetHisOrderByID(order_id)
  31258. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31259. if fapiao.ID > 0 {
  31260. c.ServeSuccessJSON(map[string]interface{}{
  31261. "failed_code": -10,
  31262. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31263. })
  31264. return
  31265. }
  31266. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31267. if order.ID == 0 {
  31268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31269. return
  31270. }
  31271. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31272. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31273. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31274. if config.IsOpen == 1 { //对接了医保,走医保流程
  31275. var res ResultSixteen
  31276. var ahres ResultSevenAH
  31277. var resSixteen10265 ResultSixteen10265
  31278. var resSixteen10265Two ResultSixteen10265Two
  31279. var gz ResultgzSixteen10265Two
  31280. var src_resquest string
  31281. var result string
  31282. if miConfig.MdtrtareaAdmvs == "421300" {
  31283. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31284. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31285. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31286. resp3, requestErr3 := http.Get(api3)
  31287. if requestErr3 != nil {
  31288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31289. return
  31290. }
  31291. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31292. if ioErr3 != nil {
  31293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31295. return
  31296. }
  31297. var respJSON3 map[string]interface{}
  31298. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31301. return
  31302. }
  31303. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31304. userJSONBytes3, _ := json.Marshal(respJSON3)
  31305. fmt.Println("log")
  31306. fmt.Println(string(userJSONBytes3))
  31307. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31308. utils.ErrorLog("解析失败:%v", err)
  31309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31310. return
  31311. }
  31312. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31313. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31314. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31315. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31316. resp3, requestErr3 := http.Get(api3)
  31317. if requestErr3 != nil {
  31318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31319. return
  31320. }
  31321. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31322. if ioErr3 != nil {
  31323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31325. return
  31326. }
  31327. var respJSON3 map[string]interface{}
  31328. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31331. return
  31332. }
  31333. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31334. userJSONBytes3, _ := json.Marshal(respJSON3)
  31335. fmt.Println("log")
  31336. fmt.Println(string(userJSONBytes3))
  31337. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31338. utils.ErrorLog("解析失败:%v", err)
  31339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31340. return
  31341. }
  31342. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31343. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31344. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31345. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31346. resp3, requestErr3 := http.Get(api3)
  31347. if requestErr3 != nil {
  31348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31349. return
  31350. }
  31351. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31352. if ioErr3 != nil {
  31353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31355. return
  31356. }
  31357. var respJSON3 map[string]interface{}
  31358. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31361. return
  31362. }
  31363. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31364. userJSONBytes3, _ := json.Marshal(respJSON3)
  31365. fmt.Println("log")
  31366. fmt.Println(string(userJSONBytes3))
  31367. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31368. utils.ErrorLog("解析失败:%v", err)
  31369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31370. return
  31371. }
  31372. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31373. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31374. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31375. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31376. resp3, requestErr3 := http.Get(api3)
  31377. if requestErr3 != nil {
  31378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31379. return
  31380. }
  31381. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31382. if ioErr3 != nil {
  31383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31385. return
  31386. }
  31387. var respJSON3 map[string]interface{}
  31388. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31391. return
  31392. }
  31393. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31394. userJSONBytes3, _ := json.Marshal(respJSON3)
  31395. fmt.Println("log")
  31396. fmt.Println(string(userJSONBytes3))
  31397. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31398. utils.ErrorLog("解析失败:%v", err)
  31399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31400. return
  31401. }
  31402. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31403. var api3 string
  31404. if miConfig.MdtrtareaAdmvs == "320921" {
  31405. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31406. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31407. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31408. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31409. } else {
  31410. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31411. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31412. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31413. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31414. }
  31415. resp3, requestErr3 := http.Get(api3)
  31416. if requestErr3 != nil {
  31417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31418. return
  31419. }
  31420. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31421. if ioErr3 != nil {
  31422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31424. return
  31425. }
  31426. var respJSON3 map[string]interface{}
  31427. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31430. return
  31431. }
  31432. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31433. userJSONBytes3, _ := json.Marshal(respJSON3)
  31434. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31435. utils.ErrorLog("解析失败:%v", err)
  31436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31437. return
  31438. }
  31439. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31440. res.Output = resSixteen10265.Output
  31441. res.ErrMsg = resSixteen10265.ErrMsg
  31442. res.Cainfo = resSixteen10265.Cainfo
  31443. res.WarnMsg = resSixteen10265.WarnMsg
  31444. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31445. res.Infcode = infocode
  31446. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31447. var api3 string
  31448. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31449. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31450. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31451. resp3, requestErr3 := http.Get(api3)
  31452. if requestErr3 != nil {
  31453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31454. return
  31455. }
  31456. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31457. if ioErr3 != nil {
  31458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31460. return
  31461. }
  31462. var respJSON3 map[string]interface{}
  31463. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31466. return
  31467. }
  31468. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31469. userJSONBytes3, _ := json.Marshal(respJSON3)
  31470. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31471. utils.ErrorLog("解析失败:%v", err)
  31472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31473. return
  31474. }
  31475. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31476. res.Output = resSixteen10265.Output
  31477. res.ErrMsg = resSixteen10265.ErrMsg
  31478. res.Cainfo = resSixteen10265.Cainfo
  31479. res.WarnMsg = resSixteen10265.WarnMsg
  31480. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31481. res.Infcode = infocode
  31482. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31483. 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)
  31484. var dat map[string]interface{}
  31485. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31486. fmt.Println(dat)
  31487. } else {
  31488. fmt.Println(err)
  31489. }
  31490. saveLog(result, src_resquest, "2208", "退费")
  31491. userJSONBytes, _ := json.Marshal(dat)
  31492. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31493. utils.ErrorLog("解析失败:%v", err)
  31494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31495. return
  31496. }
  31497. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31498. 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, "")
  31499. var dat map[string]interface{}
  31500. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31501. fmt.Println(dat)
  31502. } else {
  31503. fmt.Println(err)
  31504. }
  31505. saveLog(result, src_resquest, "2208", "退费")
  31506. userJSONBytes, _ := json.Marshal(dat)
  31507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31508. utils.ErrorLog("解析失败:%v", err)
  31509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31510. return
  31511. }
  31512. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31513. 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, "")
  31514. var dat map[string]interface{}
  31515. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31516. fmt.Println(dat)
  31517. } else {
  31518. fmt.Println(err)
  31519. }
  31520. saveLog(result, src_resquest, "2208", "退费")
  31521. userJSONBytes, _ := json.Marshal(dat)
  31522. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31523. utils.ErrorLog("解析失败:%v", err)
  31524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31525. return
  31526. }
  31527. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31528. var api3 string
  31529. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31530. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31531. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31532. resp3, requestErr3 := http.Get(api3)
  31533. if requestErr3 != nil {
  31534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31535. return
  31536. }
  31537. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31538. if ioErr3 != nil {
  31539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31541. return
  31542. }
  31543. var respJSON3 map[string]interface{}
  31544. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31547. return
  31548. }
  31549. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31550. if status == "0" {
  31551. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31552. c.ServeSuccessJSON(map[string]interface{}{
  31553. "failed_code": -10,
  31554. "msg": err_msg,
  31555. })
  31556. return
  31557. }
  31558. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31559. userJSONBytes3, _ := json.Marshal(respJSON3)
  31560. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31561. // utils.ErrorLog("解析失败:%v", err)
  31562. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31563. // return
  31564. //}
  31565. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31566. utils.ErrorLog("解析失败:%v", err)
  31567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31568. return
  31569. }
  31570. res.InfRefmsgid = ahres.InfRefmsgid
  31571. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31572. // 创建对应的Time类型
  31573. t := time.UnixMilli(timestamp)
  31574. // 格式化成指定的日期字符串
  31575. str := t.Format("2006-01-02 15:04:05")
  31576. res.Output.Setlinfo.SetlTime = str
  31577. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31578. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31579. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31580. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31581. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31582. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31583. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31584. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31585. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31586. //
  31587. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31588. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31589. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31590. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31591. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31592. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31593. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31594. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31595. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31596. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31597. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31598. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31599. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31600. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31601. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31602. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31603. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31604. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31605. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31606. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31607. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31608. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31609. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31610. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31611. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31612. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31613. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31614. //res.Output.Setldetail = ahres.Output.Setldetail
  31615. res.ErrMsg = ahres.ErrMsg
  31616. res.Cainfo = ahres.Cainfo
  31617. res.WarnMsg = ahres.WarnMsg
  31618. res.Infcode = ahres.Infcode
  31619. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31620. var api3 string
  31621. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31622. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31623. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31624. resp3, requestErr3 := http.Get(api3)
  31625. if requestErr3 != nil {
  31626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31627. return
  31628. }
  31629. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31630. if ioErr3 != nil {
  31631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31633. return
  31634. }
  31635. var respJSON3 map[string]interface{}
  31636. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31639. return
  31640. }
  31641. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31642. if status == "0" {
  31643. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31644. c.ServeSuccessJSON(map[string]interface{}{
  31645. "failed_code": -10,
  31646. "msg": err_msg,
  31647. })
  31648. return
  31649. }
  31650. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31651. userJSONBytes3, _ := json.Marshal(respJSON3)
  31652. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31653. // utils.ErrorLog("解析失败:%v", err)
  31654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31655. // return
  31656. //}
  31657. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31658. utils.ErrorLog("解析失败:%v", err)
  31659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31660. return
  31661. }
  31662. res.InfRefmsgid = ahres.InfRefmsgid
  31663. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31664. // 创建对应的Time类型
  31665. t := time.UnixMilli(timestamp)
  31666. // 格式化成指定的日期字符串
  31667. str := t.Format("2006-01-02 15:04:05")
  31668. res.Output.Setlinfo.SetlTime = str
  31669. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31670. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31671. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31672. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31673. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31674. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31675. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31676. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31677. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31678. //
  31679. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31680. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31681. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31682. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31683. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31684. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31685. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31686. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31687. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31688. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31689. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31690. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31691. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31692. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31693. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31694. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31695. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31696. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31697. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31698. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31699. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31700. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31701. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31702. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31703. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31704. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31705. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31706. //res.Output.Setldetail = ahres.Output.Setldetail
  31707. res.ErrMsg = ahres.ErrMsg
  31708. res.Cainfo = ahres.Cainfo
  31709. res.WarnMsg = ahres.WarnMsg
  31710. res.Infcode = ahres.Infcode
  31711. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31712. 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, "")
  31713. var dat map[string]interface{}
  31714. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31715. fmt.Println(dat)
  31716. } else {
  31717. fmt.Println(err)
  31718. }
  31719. saveLog(result, src_resquest, "2208", "退费")
  31720. userJSONBytes, _ := json.Marshal(dat)
  31721. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31722. utils.ErrorLog("解析失败:%v", err)
  31723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31724. return
  31725. }
  31726. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31727. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31728. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31729. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31730. resp3, requestErr3 := http.Get(api3)
  31731. if requestErr3 != nil {
  31732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31733. return
  31734. }
  31735. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31736. if ioErr3 != nil {
  31737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31739. return
  31740. }
  31741. var respJSON3 map[string]interface{}
  31742. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31745. return
  31746. }
  31747. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31748. userJSONBytes3, _ := json.Marshal(respJSON3)
  31749. fmt.Println("log")
  31750. fmt.Println(string(userJSONBytes3))
  31751. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31752. utils.ErrorLog("解析失败:%v", err)
  31753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31754. return
  31755. }
  31756. } else {
  31757. if miConfig.Code == "H15049901371" {
  31758. 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)
  31759. var dat map[string]interface{}
  31760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31761. fmt.Println(dat)
  31762. } else {
  31763. fmt.Println(err)
  31764. }
  31765. saveLog(result, src_resquest, "2208", "退费")
  31766. if strings.Contains(result, "Post") {
  31767. res.Infcode = -1
  31768. res.ErrMsg = result
  31769. }
  31770. userJSONBytes, _ := json.Marshal(dat)
  31771. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31772. utils.ErrorLog("解析失败:%v", err)
  31773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31774. return
  31775. }
  31776. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31777. res.Output = resSixteen10265.Output
  31778. res.ErrMsg = resSixteen10265.ErrMsg
  31779. res.Cainfo = resSixteen10265.Cainfo
  31780. res.WarnMsg = resSixteen10265.WarnMsg
  31781. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31782. res.Infcode = infocode
  31783. } else {
  31784. 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)
  31785. var dat map[string]interface{}
  31786. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31787. fmt.Println(dat)
  31788. } else {
  31789. fmt.Println(err)
  31790. }
  31791. saveLog(result, src_resquest, "2208", "退费")
  31792. userJSONBytes, _ := json.Marshal(dat)
  31793. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31794. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31795. utils.ErrorLog("解析失败:%v", err)
  31796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31797. return
  31798. }
  31799. res.Infcode = gz.Infcode
  31800. } else {
  31801. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31802. utils.ErrorLog("解析失败:%v", err)
  31803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31804. return
  31805. }
  31806. }
  31807. if strings.Contains(result, "Post") {
  31808. res.Infcode = -1
  31809. res.ErrMsg = result
  31810. }
  31811. }
  31812. }
  31813. if res.Infcode == -1 {
  31814. c.ServeSuccessJSON(map[string]interface{}{
  31815. "failed_code": -10,
  31816. "msg": res.ErrMsg,
  31817. })
  31818. return
  31819. }
  31820. if res.Infcode != -1 {
  31821. var res2 ResultSix
  31822. var resSix10265 ResultSix10265
  31823. if miConfig.MdtrtareaAdmvs == "421300" {
  31824. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31825. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31826. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31827. resp3, requestErr3 := http.Get(api3)
  31828. if requestErr3 != nil {
  31829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31830. return
  31831. }
  31832. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31833. if ioErr3 != nil {
  31834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31836. return
  31837. }
  31838. var respJSON3 map[string]interface{}
  31839. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31842. return
  31843. }
  31844. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31845. userJSONBytes3, _ := json.Marshal(respJSON3)
  31846. fmt.Println("log")
  31847. fmt.Println(string(userJSONBytes3))
  31848. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31849. utils.ErrorLog("解析失败:%v", err)
  31850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31851. return
  31852. }
  31853. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31854. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31855. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31856. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31857. resp3, requestErr3 := http.Get(api3)
  31858. if requestErr3 != nil {
  31859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31860. return
  31861. }
  31862. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31863. if ioErr3 != nil {
  31864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31866. return
  31867. }
  31868. var respJSON3 map[string]interface{}
  31869. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31872. return
  31873. }
  31874. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31875. userJSONBytes3, _ := json.Marshal(respJSON3)
  31876. fmt.Println("log")
  31877. fmt.Println(string(userJSONBytes3))
  31878. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31879. utils.ErrorLog("解析失败:%v", err)
  31880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31881. return
  31882. }
  31883. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31884. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31885. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31886. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31887. resp3, requestErr3 := http.Get(api3)
  31888. if requestErr3 != nil {
  31889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31890. return
  31891. }
  31892. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31893. if ioErr3 != nil {
  31894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31896. return
  31897. }
  31898. var respJSON3 map[string]interface{}
  31899. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31902. return
  31903. }
  31904. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31905. userJSONBytes3, _ := json.Marshal(respJSON3)
  31906. fmt.Println("log")
  31907. fmt.Println(string(userJSONBytes3))
  31908. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31909. utils.ErrorLog("解析失败:%v", err)
  31910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31911. return
  31912. }
  31913. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31914. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31915. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31916. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31917. resp3, requestErr3 := http.Get(api3)
  31918. if requestErr3 != nil {
  31919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31920. return
  31921. }
  31922. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31923. if ioErr3 != nil {
  31924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31926. return
  31927. }
  31928. var respJSON3 map[string]interface{}
  31929. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31932. return
  31933. }
  31934. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31935. userJSONBytes3, _ := json.Marshal(respJSON3)
  31936. fmt.Println("log")
  31937. fmt.Println(string(userJSONBytes3))
  31938. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31939. utils.ErrorLog("解析失败:%v", err)
  31940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31941. return
  31942. }
  31943. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31944. var api3 string
  31945. if miConfig.MdtrtareaAdmvs == "320921" {
  31946. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31947. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31948. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31949. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31950. } else {
  31951. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31952. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31953. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31954. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31955. }
  31956. resp3, requestErr3 := http.Get(api3)
  31957. if requestErr3 != nil {
  31958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31959. return
  31960. }
  31961. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31962. if ioErr3 != nil {
  31963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31965. return
  31966. }
  31967. var respJSON3 map[string]interface{}
  31968. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31971. return
  31972. }
  31973. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31974. userJSONBytes3, _ := json.Marshal(respJSON3)
  31975. fmt.Println("log")
  31976. fmt.Println(string(userJSONBytes3))
  31977. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31978. utils.ErrorLog("解析失败:%v", err)
  31979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31980. return
  31981. }
  31982. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31983. res2.Output = resSix10265.Output
  31984. res2.ErrMsg = resSix10265.ErrMsg
  31985. res2.Cainfo = resSix10265.Cainfo
  31986. res2.WarnMsg = resSix10265.WarnMsg
  31987. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31988. res2.Infcode = infocode
  31989. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31990. var api3 string
  31991. new_chrg_bchno := order.Number
  31992. if adminUser.CurrentOrgId == 10265 {
  31993. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31994. new_chrg_bchno = "0000"
  31995. }
  31996. }
  31997. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31998. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31999. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32000. resp3, requestErr3 := http.Get(api3)
  32001. if requestErr3 != nil {
  32002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32003. return
  32004. }
  32005. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32006. if ioErr3 != nil {
  32007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32009. return
  32010. }
  32011. var respJSON3 map[string]interface{}
  32012. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32015. return
  32016. }
  32017. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32018. userJSONBytes3, _ := json.Marshal(respJSON3)
  32019. fmt.Println("log")
  32020. fmt.Println(string(userJSONBytes3))
  32021. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32022. utils.ErrorLog("解析失败:%v", err)
  32023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32024. return
  32025. }
  32026. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32027. res2.Output = resSix10265.Output
  32028. res2.ErrMsg = resSix10265.ErrMsg
  32029. res2.Cainfo = resSix10265.Cainfo
  32030. res2.WarnMsg = resSix10265.WarnMsg
  32031. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32032. res2.Infcode = infocode
  32033. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32034. 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)
  32035. var dat map[string]interface{}
  32036. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32037. fmt.Println(dat)
  32038. } else {
  32039. fmt.Println(err)
  32040. }
  32041. saveLog(result2, src_request, "2205", "撤销明细")
  32042. userJSONBytes, _ := json.Marshal(dat)
  32043. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32044. utils.ErrorLog("解析失败:%v", err)
  32045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32046. return
  32047. }
  32048. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32049. 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, "")
  32050. var dat map[string]interface{}
  32051. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32052. fmt.Println(dat)
  32053. } else {
  32054. fmt.Println(err)
  32055. }
  32056. saveLog(result2, src_request, "2205", "撤销明细")
  32057. userJSONBytes, _ := json.Marshal(dat)
  32058. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32059. utils.ErrorLog("解析失败:%v", err)
  32060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32061. return
  32062. }
  32063. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32064. 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, "")
  32065. var dat map[string]interface{}
  32066. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32067. fmt.Println(dat)
  32068. } else {
  32069. fmt.Println(err)
  32070. }
  32071. saveLog(result2, src_request, "2205", "撤销明细")
  32072. userJSONBytes, _ := json.Marshal(dat)
  32073. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32074. utils.ErrorLog("解析失败:%v", err)
  32075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32076. return
  32077. }
  32078. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32079. var api3 string
  32080. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32081. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32082. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32083. resp3, requestErr3 := http.Get(api3)
  32084. if requestErr3 != nil {
  32085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32086. return
  32087. }
  32088. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32089. if ioErr3 != nil {
  32090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32092. return
  32093. }
  32094. var respJSON3 map[string]interface{}
  32095. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32098. return
  32099. }
  32100. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32101. if status == "0" {
  32102. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32103. c.ServeSuccessJSON(map[string]interface{}{
  32104. "failed_code": -10,
  32105. "msg": err_msg,
  32106. })
  32107. return
  32108. }
  32109. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32110. userJSONBytes3, _ := json.Marshal(respJSON3)
  32111. fmt.Println("log")
  32112. fmt.Println(string(userJSONBytes3))
  32113. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32114. utils.ErrorLog("解析失败:%v", err)
  32115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32116. return
  32117. }
  32118. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32119. 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, "")
  32120. var dat map[string]interface{}
  32121. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32122. fmt.Println(dat)
  32123. } else {
  32124. fmt.Println(err)
  32125. }
  32126. saveLog(result2, src_request, "2205", "撤销明细")
  32127. userJSONBytes, _ := json.Marshal(dat)
  32128. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32129. utils.ErrorLog("解析失败:%v", err)
  32130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32131. return
  32132. }
  32133. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32134. 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, "")
  32135. var dat map[string]interface{}
  32136. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32137. fmt.Println(dat)
  32138. } else {
  32139. fmt.Println(err)
  32140. }
  32141. saveLog(result2, src_request, "2205", "撤销明细")
  32142. userJSONBytes, _ := json.Marshal(dat)
  32143. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32144. utils.ErrorLog("解析失败:%v", err)
  32145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32146. return
  32147. }
  32148. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32149. var api3 string
  32150. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32151. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32152. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32153. resp3, requestErr3 := http.Get(api3)
  32154. if requestErr3 != nil {
  32155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32156. return
  32157. }
  32158. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32159. if ioErr3 != nil {
  32160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32162. return
  32163. }
  32164. var respJSON3 map[string]interface{}
  32165. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32168. return
  32169. }
  32170. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32171. if status == "0" {
  32172. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32173. c.ServeSuccessJSON(map[string]interface{}{
  32174. "failed_code": -10,
  32175. "msg": err_msg,
  32176. })
  32177. return
  32178. }
  32179. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32180. userJSONBytes3, _ := json.Marshal(respJSON3)
  32181. fmt.Println("log")
  32182. fmt.Println(string(userJSONBytes3))
  32183. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32184. utils.ErrorLog("解析失败:%v", err)
  32185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32186. return
  32187. }
  32188. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32189. 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, "")
  32190. var dat map[string]interface{}
  32191. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32192. fmt.Println(dat)
  32193. } else {
  32194. fmt.Println(err)
  32195. }
  32196. saveLog(result2, src_request, "2205", "撤销明细")
  32197. userJSONBytes, _ := json.Marshal(dat)
  32198. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32199. utils.ErrorLog("解析失败:%v", err)
  32200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32201. return
  32202. }
  32203. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32204. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  32205. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32206. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32207. resp3, requestErr3 := http.Get(api3)
  32208. if requestErr3 != nil {
  32209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32210. return
  32211. }
  32212. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32213. if ioErr3 != nil {
  32214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32216. return
  32217. }
  32218. var respJSON3 map[string]interface{}
  32219. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32222. return
  32223. }
  32224. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32225. userJSONBytes3, _ := json.Marshal(respJSON3)
  32226. fmt.Println("log")
  32227. fmt.Println(string(userJSONBytes3))
  32228. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32229. utils.ErrorLog("解析失败:%v", err)
  32230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32231. return
  32232. }
  32233. } else {
  32234. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32235. res2.Infcode = 0
  32236. } else {
  32237. 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)
  32238. var dat map[string]interface{}
  32239. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32240. fmt.Println(dat)
  32241. } else {
  32242. fmt.Println(err)
  32243. }
  32244. saveLog(result2, src_request, "2205", "撤销明细")
  32245. userJSONBytes, _ := json.Marshal(dat)
  32246. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32247. utils.ErrorLog("解析失败:%v", err)
  32248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32249. return
  32250. }
  32251. }
  32252. }
  32253. if res2.Infcode == -1 {
  32254. c.ServeSuccessJSON(map[string]interface{}{
  32255. "failed_code": -10,
  32256. "msg": res2.ErrMsg,
  32257. })
  32258. return
  32259. }
  32260. if res2.Infcode == 0 {
  32261. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32262. if err == nil {
  32263. //当押金不为零时产生退费记录
  32264. if order.Decimal != 0 {
  32265. tmp := strconv.FormatInt(order.ID, 10)
  32266. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32267. if err != nil {
  32268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32269. return
  32270. }
  32271. }
  32272. c.ServeSuccessJSON(map[string]interface{}{
  32273. "msg": "退费成功",
  32274. })
  32275. } else {
  32276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32277. return
  32278. }
  32279. } else {
  32280. c.ServeSuccessJSON(map[string]interface{}{
  32281. "failed_code": -10,
  32282. "msg": res2.ErrMsg,
  32283. })
  32284. }
  32285. } else {
  32286. c.ServeSuccessJSON(map[string]interface{}{
  32287. "failed_code": -10,
  32288. "msg": res.ErrMsg,
  32289. })
  32290. }
  32291. }
  32292. }
  32293. func (c *HisApiController) RefundNumber() {
  32294. record_time := c.GetString("record_time")
  32295. //patient_id, _ := c.GetInt64("patient_id")
  32296. admin_user_id, _ := c.GetInt64("admin_user_id")
  32297. his_patient_id, _ := c.GetInt64("id")
  32298. timeLayout := "2006-01-02"
  32299. loc, _ := time.LoadLocation("Local")
  32300. adminUser := c.GetAdminUserInfo()
  32301. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32302. fmt.Println(err)
  32303. if err != nil {
  32304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32305. return
  32306. }
  32307. recordDateTime := theTime.Unix()
  32308. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32309. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32310. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32311. //order, _ := service.GetHisOrderByID(order_id)
  32312. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32313. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32314. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32315. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32316. if count > 0 {
  32317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32318. return
  32319. }
  32320. if config.IsOpen == 1 { //对接了医保,走医保流程
  32321. var res2 ResultSix
  32322. var res3 GZResultSix
  32323. var resSix10265 ResultSix10265
  32324. if miConfig.MdtrtareaAdmvs == "421300" {
  32325. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32326. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32327. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32328. resp3, requestErr3 := http.Get(api3)
  32329. if requestErr3 != nil {
  32330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32331. return
  32332. }
  32333. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32334. if ioErr3 != nil {
  32335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32337. return
  32338. }
  32339. var respJSON3 map[string]interface{}
  32340. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32343. return
  32344. }
  32345. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32346. userJSONBytes3, _ := json.Marshal(respJSON3)
  32347. fmt.Println("log")
  32348. fmt.Println(string(userJSONBytes3))
  32349. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32350. utils.ErrorLog("解析失败:%v", err)
  32351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32352. return
  32353. }
  32354. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32355. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32356. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32357. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32358. resp3, requestErr3 := http.Get(api3)
  32359. if requestErr3 != nil {
  32360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32361. return
  32362. }
  32363. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32364. if ioErr3 != nil {
  32365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32367. return
  32368. }
  32369. var respJSON3 map[string]interface{}
  32370. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32373. return
  32374. }
  32375. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32376. userJSONBytes3, _ := json.Marshal(respJSON3)
  32377. fmt.Println("log")
  32378. fmt.Println(string(userJSONBytes3))
  32379. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32380. utils.ErrorLog("解析失败:%v", err)
  32381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32382. return
  32383. }
  32384. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32385. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32386. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32387. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32388. resp3, requestErr3 := http.Get(api3)
  32389. if requestErr3 != nil {
  32390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32391. return
  32392. }
  32393. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32394. if ioErr3 != nil {
  32395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32397. return
  32398. }
  32399. var respJSON3 map[string]interface{}
  32400. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32403. return
  32404. }
  32405. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32406. userJSONBytes3, _ := json.Marshal(respJSON3)
  32407. fmt.Println("log")
  32408. fmt.Println(string(userJSONBytes3))
  32409. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32410. utils.ErrorLog("解析失败:%v", err)
  32411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32412. return
  32413. }
  32414. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32415. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32416. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32417. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32418. resp3, requestErr3 := http.Get(api3)
  32419. if requestErr3 != nil {
  32420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32421. return
  32422. }
  32423. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32424. if ioErr3 != nil {
  32425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32427. return
  32428. }
  32429. var respJSON3 map[string]interface{}
  32430. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32433. return
  32434. }
  32435. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32436. userJSONBytes3, _ := json.Marshal(respJSON3)
  32437. fmt.Println("log")
  32438. fmt.Println(string(userJSONBytes3))
  32439. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32440. utils.ErrorLog("解析失败:%v", err)
  32441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32442. return
  32443. }
  32444. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32445. var api3 string
  32446. if miConfig.MdtrtareaAdmvs == "320921" {
  32447. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32448. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32449. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32450. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32451. } else {
  32452. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32453. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32454. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32455. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32456. }
  32457. resp3, requestErr3 := http.Get(api3)
  32458. if requestErr3 != nil {
  32459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32460. return
  32461. }
  32462. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32463. if ioErr3 != nil {
  32464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32466. return
  32467. }
  32468. var respJSON3 map[string]interface{}
  32469. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32472. return
  32473. }
  32474. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32475. userJSONBytes3, _ := json.Marshal(respJSON3)
  32476. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32477. utils.ErrorLog("解析失败:%v", err)
  32478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32479. return
  32480. }
  32481. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32482. res2.Output = resSix10265.Output
  32483. res2.ErrMsg = resSix10265.ErrMsg
  32484. res2.Cainfo = resSix10265.Cainfo
  32485. res2.WarnMsg = resSix10265.WarnMsg
  32486. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32487. res2.Infcode = infocode
  32488. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32489. var api3 string
  32490. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32491. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32492. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32493. resp3, requestErr3 := http.Get(api3)
  32494. if requestErr3 != nil {
  32495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32496. return
  32497. }
  32498. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32499. if ioErr3 != nil {
  32500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32502. return
  32503. }
  32504. var respJSON3 map[string]interface{}
  32505. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32508. return
  32509. }
  32510. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32511. userJSONBytes3, _ := json.Marshal(respJSON3)
  32512. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32513. utils.ErrorLog("解析失败:%v", err)
  32514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32515. return
  32516. }
  32517. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32518. res2.Output = resSix10265.Output
  32519. res2.ErrMsg = resSix10265.ErrMsg
  32520. res2.Cainfo = resSix10265.Cainfo
  32521. res2.WarnMsg = resSix10265.WarnMsg
  32522. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32523. res2.Infcode = infocode
  32524. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32525. 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)
  32526. var dat map[string]interface{}
  32527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32528. fmt.Println(dat)
  32529. } else {
  32530. fmt.Println(err)
  32531. }
  32532. saveLog(result, request, "2202", "退号")
  32533. userJSONBytes, _ := json.Marshal(dat)
  32534. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32535. utils.ErrorLog("解析失败:%v", err)
  32536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32537. return
  32538. }
  32539. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32540. 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, "")
  32541. var dat map[string]interface{}
  32542. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32543. fmt.Println(dat)
  32544. } else {
  32545. fmt.Println(err)
  32546. }
  32547. saveLog(result, request, "2202", "退号")
  32548. userJSONBytes, _ := json.Marshal(dat)
  32549. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32550. utils.ErrorLog("解析失败:%v", err)
  32551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32552. return
  32553. }
  32554. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32555. 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, "")
  32556. var dat map[string]interface{}
  32557. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32558. fmt.Println(dat)
  32559. } else {
  32560. fmt.Println(err)
  32561. }
  32562. saveLog(result, request, "2202", "退号")
  32563. userJSONBytes, _ := json.Marshal(dat)
  32564. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32565. utils.ErrorLog("解析失败:%v", err)
  32566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32567. return
  32568. }
  32569. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32570. var api3 string
  32571. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32572. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32573. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32574. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32575. resp3, requestErr3 := http.Get(api3)
  32576. if requestErr3 != nil {
  32577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32578. return
  32579. }
  32580. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32581. if ioErr3 != nil {
  32582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32584. return
  32585. }
  32586. var respJSON3 map[string]interface{}
  32587. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32590. return
  32591. }
  32592. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32593. if status == "0" {
  32594. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32595. c.ServeSuccessJSON(map[string]interface{}{
  32596. "failed_code": -10,
  32597. "msg": err_msg,
  32598. })
  32599. return
  32600. }
  32601. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32602. userJSONBytes3, _ := json.Marshal(respJSON3)
  32603. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32604. utils.ErrorLog("解析失败:%v", err)
  32605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32606. return
  32607. }
  32608. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32609. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32610. var api3 string
  32611. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32612. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32613. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32614. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32615. resp3, requestErr3 := http.Get(api3)
  32616. if requestErr3 != nil {
  32617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32618. return
  32619. }
  32620. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32621. if ioErr3 != nil {
  32622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32624. return
  32625. }
  32626. var respJSON3 map[string]interface{}
  32627. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32630. return
  32631. }
  32632. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32633. if status == "0" {
  32634. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32635. c.ServeSuccessJSON(map[string]interface{}{
  32636. "failed_code": -10,
  32637. "msg": err_msg,
  32638. })
  32639. return
  32640. }
  32641. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32642. userJSONBytes3, _ := json.Marshal(respJSON3)
  32643. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32644. utils.ErrorLog("解析失败:%v", err)
  32645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32646. return
  32647. }
  32648. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32649. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32650. 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, "")
  32651. var dat map[string]interface{}
  32652. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32653. fmt.Println(dat)
  32654. } else {
  32655. fmt.Println(err)
  32656. }
  32657. saveLog(result, request, "2202", "退号")
  32658. userJSONBytes, _ := json.Marshal(dat)
  32659. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32660. utils.ErrorLog("解析失败:%v", err)
  32661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32662. return
  32663. }
  32664. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32665. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32666. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32667. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32668. resp3, requestErr3 := http.Get(api3)
  32669. if requestErr3 != nil {
  32670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32671. return
  32672. }
  32673. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32674. if ioErr3 != nil {
  32675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32677. return
  32678. }
  32679. var respJSON3 map[string]interface{}
  32680. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32683. return
  32684. }
  32685. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32686. userJSONBytes3, _ := json.Marshal(respJSON3)
  32687. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32688. utils.ErrorLog("解析失败:%v", err)
  32689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32690. return
  32691. }
  32692. } else {
  32693. var api3 string
  32694. if miConfig.Code == "H15049901371" {
  32695. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32696. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32697. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32698. } else {
  32699. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32700. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32701. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32702. }
  32703. resp3, requestErr3 := http.Get(api3)
  32704. if requestErr3 != nil {
  32705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32706. return
  32707. }
  32708. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32709. if ioErr3 != nil {
  32710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32712. return
  32713. }
  32714. var respJSON3 map[string]interface{}
  32715. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32718. return
  32719. }
  32720. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32721. userJSONBytes3, _ := json.Marshal(respJSON3)
  32722. if miConfig.Code == "H15049901371" {
  32723. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32724. utils.ErrorLog("解析失败:%v", err)
  32725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32726. return
  32727. }
  32728. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32729. res2.Output = resSix10265.Output
  32730. res2.ErrMsg = resSix10265.ErrMsg
  32731. res2.Cainfo = resSix10265.Cainfo
  32732. res2.WarnMsg = resSix10265.WarnMsg
  32733. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32734. res2.Infcode = infocode
  32735. } else {
  32736. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32737. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32738. utils.ErrorLog("解析失败:%v", err)
  32739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32740. return
  32741. }
  32742. res2.Infcode = res3.Infcode
  32743. } else {
  32744. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32745. utils.ErrorLog("解析失败:%v", err)
  32746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32747. return
  32748. }
  32749. }
  32750. }
  32751. }
  32752. if res2.Infcode == -1 {
  32753. c.ServeSuccessJSON(map[string]interface{}{
  32754. "failed_code": -10,
  32755. "msg": res2.ErrMsg,
  32756. })
  32757. return
  32758. }
  32759. if res2.Infcode == 0 {
  32760. if err == nil {
  32761. c.ServeSuccessJSON(map[string]interface{}{
  32762. "msg": "退号成功",
  32763. })
  32764. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32765. } else {
  32766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32767. return
  32768. }
  32769. }
  32770. } else {
  32771. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32772. //if err == nil {
  32773. // c.ServeSuccessJSON(map[string]interface{}{
  32774. // "msg": "退费成功",
  32775. // })
  32776. //} else {
  32777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32778. // return
  32779. //}
  32780. }
  32781. }
  32782. func (c *HisApiController) RefundDetail() {
  32783. order_id, _ := c.GetInt64("order_id")
  32784. admin_user_id, _ := c.GetInt64("admin_user_id")
  32785. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32786. number := c.GetString("number")
  32787. record_time := c.GetString("record_time")
  32788. patient_id, _ := c.GetInt64("patient_id")
  32789. //med_type, _ := c.GetInt64("med_type")
  32790. timeLayout := "2006-01-02"
  32791. loc, _ := time.LoadLocation("Local")
  32792. adminUser := c.GetAdminUserInfo()
  32793. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32794. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32795. fmt.Println(err)
  32796. if err != nil {
  32797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32798. return
  32799. }
  32800. recordDateTime := theTime.Unix()
  32801. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32802. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32803. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32804. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32805. var order models.HisOrder
  32806. order, _ = service.GetHisOrderByID(order_id)
  32807. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32808. if config.IsOpen == 1 { //对接了医保,走医保流程
  32809. var res2 ResultSix
  32810. if miConfig.MdtrtareaAdmvs == "421300" {
  32811. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32812. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32813. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32814. resp3, requestErr3 := http.Get(api3)
  32815. if requestErr3 != nil {
  32816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32817. return
  32818. }
  32819. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32820. if ioErr3 != nil {
  32821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32823. return
  32824. }
  32825. var respJSON3 map[string]interface{}
  32826. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32829. return
  32830. }
  32831. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32832. userJSONBytes3, _ := json.Marshal(respJSON3)
  32833. fmt.Println("log")
  32834. fmt.Println(string(userJSONBytes3))
  32835. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32836. utils.ErrorLog("解析失败:%v", err)
  32837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32838. return
  32839. }
  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 if miConfig.MdtrtareaAdmvs == "420200" {
  32851. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32852. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32853. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32854. resp3, requestErr3 := http.Get(api3)
  32855. if requestErr3 != nil {
  32856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32857. return
  32858. }
  32859. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32860. if ioErr3 != nil {
  32861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32863. return
  32864. }
  32865. var respJSON3 map[string]interface{}
  32866. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32869. return
  32870. }
  32871. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32872. userJSONBytes3, _ := json.Marshal(respJSON3)
  32873. fmt.Println("log")
  32874. fmt.Println(string(userJSONBytes3))
  32875. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32876. utils.ErrorLog("解析失败:%v", err)
  32877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32878. return
  32879. }
  32880. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32881. if err == nil {
  32882. c.ServeSuccessJSON(map[string]interface{}{
  32883. "msg": "撤销明细成功",
  32884. })
  32885. return
  32886. } else {
  32887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32888. return
  32889. }
  32890. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32891. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32892. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32893. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32894. resp3, requestErr3 := http.Get(api3)
  32895. if requestErr3 != nil {
  32896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32897. return
  32898. }
  32899. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32900. if ioErr3 != nil {
  32901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32903. return
  32904. }
  32905. var respJSON3 map[string]interface{}
  32906. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32909. return
  32910. }
  32911. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32912. userJSONBytes3, _ := json.Marshal(respJSON3)
  32913. fmt.Println("log")
  32914. fmt.Println(string(userJSONBytes3))
  32915. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32916. utils.ErrorLog("解析失败:%v", err)
  32917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32918. return
  32919. }
  32920. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32921. if err == nil {
  32922. c.ServeSuccessJSON(map[string]interface{}{
  32923. "msg": "撤销明细成功",
  32924. })
  32925. return
  32926. } else {
  32927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32928. return
  32929. }
  32930. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32931. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32932. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32933. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32934. resp3, requestErr3 := http.Get(api3)
  32935. if requestErr3 != nil {
  32936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32937. return
  32938. }
  32939. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32940. if ioErr3 != nil {
  32941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32943. return
  32944. }
  32945. var respJSON3 map[string]interface{}
  32946. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32949. return
  32950. }
  32951. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32952. userJSONBytes3, _ := json.Marshal(respJSON3)
  32953. fmt.Println("log")
  32954. fmt.Println(string(userJSONBytes3))
  32955. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32956. utils.ErrorLog("解析失败:%v", err)
  32957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32958. return
  32959. }
  32960. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32961. if err == nil {
  32962. c.ServeSuccessJSON(map[string]interface{}{
  32963. "msg": "撤销明细成功",
  32964. })
  32965. return
  32966. } else {
  32967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32968. return
  32969. }
  32970. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32971. var resSix10265 ResultSix10265
  32972. var api3 string
  32973. if miConfig.MdtrtareaAdmvs == "320921" {
  32974. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32975. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32976. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32977. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32978. } else {
  32979. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32980. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32981. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32982. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32983. }
  32984. resp3, requestErr3 := http.Get(api3)
  32985. utils.ErrorLog("接口: %v", requestErr3)
  32986. if requestErr3 != nil {
  32987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32988. return
  32989. }
  32990. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32991. if ioErr3 != nil {
  32992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32994. return
  32995. }
  32996. var respJSON3 map[string]interface{}
  32997. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33000. return
  33001. }
  33002. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33003. userJSONBytes3, _ := json.Marshal(respJSON3)
  33004. fmt.Println("log")
  33005. fmt.Println(string(userJSONBytes3))
  33006. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33007. utils.ErrorLog("解析失败:%v", err)
  33008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33009. return
  33010. }
  33011. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33012. res2.Output = resSix10265.Output
  33013. res2.ErrMsg = resSix10265.ErrMsg
  33014. res2.Cainfo = resSix10265.Cainfo
  33015. res2.WarnMsg = resSix10265.WarnMsg
  33016. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33017. res2.Infcode = infocode
  33018. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33019. if err == nil {
  33020. c.ServeSuccessJSON(map[string]interface{}{
  33021. "msg": "撤销明细成功",
  33022. })
  33023. return
  33024. } else {
  33025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33026. return
  33027. }
  33028. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33029. var api3 string
  33030. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33031. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33032. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33033. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33034. resp3, requestErr3 := http.Get(api3)
  33035. utils.ErrorLog("接口: %v", requestErr3)
  33036. if requestErr3 != nil {
  33037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33038. return
  33039. }
  33040. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33041. if ioErr3 != nil {
  33042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33044. return
  33045. }
  33046. var respJSON3 map[string]interface{}
  33047. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33050. return
  33051. }
  33052. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33053. if status == "0" {
  33054. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33055. c.ServeSuccessJSON(map[string]interface{}{
  33056. "failed_code": -10,
  33057. "msg": err_msg,
  33058. })
  33059. return
  33060. }
  33061. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33062. userJSONBytes3, _ := json.Marshal(respJSON3)
  33063. fmt.Println("log")
  33064. fmt.Println(string(userJSONBytes3))
  33065. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33066. utils.ErrorLog("解析失败:%v", err)
  33067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33068. return
  33069. }
  33070. fmt.Println(res2.Infcode)
  33071. if res2.Infcode == -1 {
  33072. c.ServeSuccessJSON(map[string]interface{}{
  33073. "failed_code": -10,
  33074. "msg": res2.ErrMsg,
  33075. })
  33076. return
  33077. }
  33078. if res2.Infcode == 0 {
  33079. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33080. if err == nil {
  33081. c.ServeSuccessJSON(map[string]interface{}{
  33082. "msg": "撤销明细成功",
  33083. })
  33084. return
  33085. } else {
  33086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33087. return
  33088. }
  33089. } else {
  33090. c.ServeSuccessJSON(map[string]interface{}{
  33091. "failed_code": -10,
  33092. "msg": res2.ErrMsg,
  33093. })
  33094. }
  33095. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33096. if err == nil {
  33097. c.ServeSuccessJSON(map[string]interface{}{
  33098. "msg": "撤销明细成功",
  33099. })
  33100. return
  33101. } else {
  33102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33103. return
  33104. }
  33105. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33106. var api3 string
  33107. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33108. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33109. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33110. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33111. resp3, requestErr3 := http.Get(api3)
  33112. utils.ErrorLog("接口: %v", requestErr3)
  33113. if requestErr3 != nil {
  33114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33115. return
  33116. }
  33117. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33118. if ioErr3 != nil {
  33119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33121. return
  33122. }
  33123. var respJSON3 map[string]interface{}
  33124. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33127. return
  33128. }
  33129. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33130. if status == "0" {
  33131. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33132. c.ServeSuccessJSON(map[string]interface{}{
  33133. "failed_code": -10,
  33134. "msg": err_msg,
  33135. })
  33136. return
  33137. }
  33138. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33139. userJSONBytes3, _ := json.Marshal(respJSON3)
  33140. fmt.Println("log")
  33141. fmt.Println(string(userJSONBytes3))
  33142. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33143. utils.ErrorLog("解析失败:%v", err)
  33144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33145. return
  33146. }
  33147. fmt.Println(res2.Infcode)
  33148. if res2.Infcode == -1 {
  33149. c.ServeSuccessJSON(map[string]interface{}{
  33150. "failed_code": -10,
  33151. "msg": res2.ErrMsg,
  33152. })
  33153. return
  33154. }
  33155. if res2.Infcode == 0 {
  33156. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33157. if err == nil {
  33158. c.ServeSuccessJSON(map[string]interface{}{
  33159. "msg": "撤销明细成功",
  33160. })
  33161. return
  33162. } else {
  33163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33164. return
  33165. }
  33166. } else {
  33167. c.ServeSuccessJSON(map[string]interface{}{
  33168. "failed_code": -10,
  33169. "msg": res2.ErrMsg,
  33170. })
  33171. }
  33172. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33173. if err == nil {
  33174. c.ServeSuccessJSON(map[string]interface{}{
  33175. "msg": "撤销明细成功",
  33176. })
  33177. return
  33178. } else {
  33179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33180. return
  33181. }
  33182. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33183. var resSix10265 ResultSix10265
  33184. new_chrg_bchno := order.Number
  33185. if adminUser.CurrentOrgId == 10265 {
  33186. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33187. new_chrg_bchno = "0000"
  33188. }
  33189. }
  33190. var api3 string
  33191. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33192. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33193. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33194. resp3, requestErr3 := http.Get(api3)
  33195. if requestErr3 != nil {
  33196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33197. return
  33198. }
  33199. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33200. if ioErr3 != nil {
  33201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33203. return
  33204. }
  33205. var respJSON3 map[string]interface{}
  33206. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33209. return
  33210. }
  33211. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33212. userJSONBytes3, _ := json.Marshal(respJSON3)
  33213. fmt.Println("log")
  33214. fmt.Println(string(userJSONBytes3))
  33215. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33216. utils.ErrorLog("解析失败:%v", err)
  33217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33218. return
  33219. }
  33220. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33221. res2.Output = resSix10265.Output
  33222. res2.ErrMsg = resSix10265.ErrMsg
  33223. res2.Cainfo = resSix10265.Cainfo
  33224. res2.WarnMsg = resSix10265.WarnMsg
  33225. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33226. res2.Infcode = infocode
  33227. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33228. if err == nil {
  33229. c.ServeSuccessJSON(map[string]interface{}{
  33230. "msg": "撤销明细成功",
  33231. })
  33232. return
  33233. } else {
  33234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33235. return
  33236. }
  33237. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33238. 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)
  33239. var dat map[string]interface{}
  33240. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33241. fmt.Println(dat)
  33242. } else {
  33243. fmt.Println(err)
  33244. }
  33245. saveLog(result2, src_request, "2205", "撤销明细")
  33246. userJSONBytes, _ := json.Marshal(dat)
  33247. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33248. utils.ErrorLog("解析失败:%v", err)
  33249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33250. return
  33251. }
  33252. if res2.Infcode == 0 {
  33253. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33254. if err == nil {
  33255. c.ServeSuccessJSON(map[string]interface{}{
  33256. "msg": "撤销明细成功",
  33257. })
  33258. return
  33259. } else {
  33260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33261. return
  33262. }
  33263. } else {
  33264. c.ServeSuccessJSON(map[string]interface{}{
  33265. "failed_code": -10,
  33266. "msg": res2.ErrMsg,
  33267. })
  33268. }
  33269. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33270. 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, "")
  33271. var dat map[string]interface{}
  33272. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33273. fmt.Println(dat)
  33274. } else {
  33275. fmt.Println(err)
  33276. }
  33277. saveLog(result2, src_request, "2205", "撤销明细")
  33278. userJSONBytes, _ := json.Marshal(dat)
  33279. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33280. utils.ErrorLog("解析失败:%v", err)
  33281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33282. return
  33283. }
  33284. if res2.Infcode == 0 {
  33285. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33286. if err == nil {
  33287. c.ServeSuccessJSON(map[string]interface{}{
  33288. "msg": "撤销明细成功",
  33289. })
  33290. return
  33291. } else {
  33292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33293. return
  33294. }
  33295. } else {
  33296. c.ServeSuccessJSON(map[string]interface{}{
  33297. "failed_code": -10,
  33298. "msg": res2.ErrMsg,
  33299. })
  33300. }
  33301. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33302. 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, "")
  33303. var dat map[string]interface{}
  33304. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33305. fmt.Println(dat)
  33306. } else {
  33307. fmt.Println(err)
  33308. }
  33309. saveLog(result2, src_request, "2205", "撤销明细")
  33310. userJSONBytes, _ := json.Marshal(dat)
  33311. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33312. utils.ErrorLog("解析失败:%v", err)
  33313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33314. return
  33315. }
  33316. if res2.Infcode == 0 {
  33317. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33318. if err == nil {
  33319. c.ServeSuccessJSON(map[string]interface{}{
  33320. "msg": "撤销明细成功",
  33321. })
  33322. return
  33323. } else {
  33324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33325. return
  33326. }
  33327. } else {
  33328. c.ServeSuccessJSON(map[string]interface{}{
  33329. "failed_code": -10,
  33330. "msg": res2.ErrMsg,
  33331. })
  33332. }
  33333. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33334. 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, "")
  33335. var dat map[string]interface{}
  33336. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33337. fmt.Println(dat)
  33338. } else {
  33339. fmt.Println(err)
  33340. }
  33341. saveLog(result2, src_request, "2205", "撤销明细")
  33342. userJSONBytes, _ := json.Marshal(dat)
  33343. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33344. utils.ErrorLog("解析失败:%v", err)
  33345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33346. return
  33347. }
  33348. if res2.Infcode == 0 {
  33349. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33350. if err == nil {
  33351. c.ServeSuccessJSON(map[string]interface{}{
  33352. "msg": "撤销明细成功",
  33353. })
  33354. return
  33355. } else {
  33356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33357. return
  33358. }
  33359. } else {
  33360. c.ServeSuccessJSON(map[string]interface{}{
  33361. "failed_code": -10,
  33362. "msg": res2.ErrMsg,
  33363. })
  33364. }
  33365. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33366. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33367. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33368. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33369. resp2, requestErr2 := http.Get(api2)
  33370. if requestErr2 != nil {
  33371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33372. return
  33373. }
  33374. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33375. if ioErr2 != nil {
  33376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33378. return
  33379. }
  33380. var respJSON2 map[string]interface{}
  33381. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33384. return
  33385. }
  33386. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33387. userJSONBytes3, _ := json.Marshal(respJSON2)
  33388. fmt.Println("log")
  33389. fmt.Println(string(userJSONBytes3))
  33390. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33391. utils.ErrorLog("解析失败:%v", err)
  33392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33393. return
  33394. }
  33395. if res2.Infcode == 0 {
  33396. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33397. if err == nil {
  33398. c.ServeSuccessJSON(map[string]interface{}{
  33399. "msg": "撤销明细成功",
  33400. })
  33401. return
  33402. } else {
  33403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33404. return
  33405. }
  33406. } else {
  33407. c.ServeSuccessJSON(map[string]interface{}{
  33408. "failed_code": -10,
  33409. "msg": res2.ErrMsg,
  33410. })
  33411. }
  33412. } else {
  33413. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33414. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33415. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33416. resp2, requestErr2 := http.Get(api2)
  33417. if requestErr2 != nil {
  33418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33419. return
  33420. }
  33421. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33422. if ioErr2 != nil {
  33423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33425. return
  33426. }
  33427. var respJSON2 map[string]interface{}
  33428. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33431. return
  33432. }
  33433. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33434. userJSONBytes3, _ := json.Marshal(respJSON2)
  33435. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33436. utils.ErrorLog("解析失败:%v", err)
  33437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33438. return
  33439. }
  33440. if res2.Infcode == -1 {
  33441. c.ServeSuccessJSON(map[string]interface{}{
  33442. "failed_code": -10,
  33443. "msg": res2.ErrMsg,
  33444. })
  33445. return
  33446. } else {
  33447. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33448. if err == nil {
  33449. c.ServeSuccessJSON(map[string]interface{}{
  33450. "msg": "撤销明细成功",
  33451. })
  33452. return
  33453. } else {
  33454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33455. return
  33456. }
  33457. }
  33458. }
  33459. } else {
  33460. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33461. if err == nil {
  33462. c.ServeSuccessJSON(map[string]interface{}{
  33463. "msg": "退费成功",
  33464. })
  33465. } else {
  33466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33467. return
  33468. }
  33469. }
  33470. }
  33471. // 对账
  33472. func (c *HisApiController) GetCheckAccount() {
  33473. start_time := c.GetString("start_time")
  33474. end_time := c.GetString("end_time")
  33475. insutype := c.GetString("insutype")
  33476. clr_type := c.GetString("clr_type")
  33477. clr_org := c.GetString("clr_optins")
  33478. admin_user_id, _ := c.GetInt64("admin_user_id")
  33479. adminUser := c.GetAdminUserInfo()
  33480. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33481. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33482. if len(clr_org) == 0 {
  33483. clr_org = miConfig.InsuplcAdmdvs
  33484. }
  33485. timeLayout := "2006-01-02"
  33486. loc, _ := time.LoadLocation("Local")
  33487. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33488. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33489. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33490. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33491. fixmedins_setl_cnt := int64(len(orders))
  33492. var medfee_sumamt float64
  33493. var acct_pay float64
  33494. var fund_pay_sumamt float64
  33495. for _, item := range orders {
  33496. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33497. acct_pay = acct_pay + item.AcctPay
  33498. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33499. }
  33500. var user_name string
  33501. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33502. if role.ID == 0 {
  33503. user_name = "xxx"
  33504. } else {
  33505. user_name = role.UserName
  33506. }
  33507. var res ResultEight
  33508. var res10188 ResultEightFor10188
  33509. if config.IsOpen == 1 {
  33510. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33511. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33512. "insutype=" + insutype +
  33513. "&clr_type=" + clr_type +
  33514. "&setl_optins=" + clr_org +
  33515. "&stmt_begndate=" + start_time +
  33516. "&stm_enddate=" + end_time +
  33517. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33518. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33519. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33520. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33521. "&fixmedins_code=" + miConfig.Code +
  33522. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33523. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33524. "&secret_key=" + miConfig.SecretKey +
  33525. "&org_name=" + miConfig.OrgName +
  33526. "&doctor=" + user_name +
  33527. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33528. fmt.Println(api)
  33529. resp, requestErr := http.Get(api)
  33530. if requestErr != nil {
  33531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33532. return
  33533. }
  33534. body, ioErr := ioutil.ReadAll(resp.Body)
  33535. fmt.Println(body)
  33536. if ioErr != nil {
  33537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33539. return
  33540. }
  33541. var respJSON map[string]interface{}
  33542. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33545. return
  33546. }
  33547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33548. userJSONBytes, _ := json.Marshal(respJSON)
  33549. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33550. utils.ErrorLog("解析失败:%v", err)
  33551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33552. return
  33553. }
  33554. res.InfRefmsgid = res10188.InfRefmsgid
  33555. res.Output = res10188.Output
  33556. res.ErrMsg = res10188.ErrMsg
  33557. res.Cainfo = res10188.Cainfo
  33558. res.WarnMsg = res10188.WarnMsg
  33559. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33560. res.Infcode = infocode
  33561. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33562. if clr_type != "9903" {
  33563. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33564. }
  33565. if clr_type == "9903" {
  33566. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33567. }
  33568. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33569. "insutype=" + insutype +
  33570. "&clr_type=" + clr_type +
  33571. "&setl_optins=" + clr_org +
  33572. "&stmt_begndate=" + start_time +
  33573. "&stm_enddate=" + end_time +
  33574. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33575. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33576. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33577. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33578. "&fixmedins_code=" + miConfig.Code +
  33579. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33580. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33581. "&secret_key=" + miConfig.SecretKey +
  33582. "&org_name=" + miConfig.OrgName +
  33583. "&doctor=" + user_name
  33584. resp, requestErr := http.Get(api)
  33585. if requestErr != nil {
  33586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33587. return
  33588. }
  33589. body, ioErr := ioutil.ReadAll(resp.Body)
  33590. if ioErr != nil {
  33591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33593. return
  33594. }
  33595. var respJSON map[string]interface{}
  33596. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33599. return
  33600. }
  33601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33602. result, _ := json.Marshal(respJSON)
  33603. fmt.Println("log")
  33604. fmt.Println(string(result))
  33605. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33606. utils.ErrorLog("解析失败:%v", err)
  33607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33608. return
  33609. }
  33610. res.InfRefmsgid = res10188.InfRefmsgid
  33611. res.Output = res10188.Output
  33612. res.ErrMsg = res10188.ErrMsg
  33613. res.Cainfo = res10188.Cainfo
  33614. res.WarnMsg = res10188.WarnMsg
  33615. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33616. res.Infcode = infocode
  33617. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33618. var baseParams models.BaseParams
  33619. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33620. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33621. baseParams.SecretKey = miConfig.SecretKey
  33622. baseParams.OrgName = miConfig.OrgName
  33623. baseParams.FixmedinsCode = miConfig.Code
  33624. baseParams.EncKey = miConfig.EncKey
  33625. baseParams.AppSecret = miConfig.AppSecret
  33626. baseParams.SignKey = miConfig.SignKey
  33627. baseParams.AppID = miConfig.Code
  33628. baseParams.Doctor = role.UserName
  33629. baseParams.RequestUrl = miConfig.Url
  33630. businessParams := models.BusinessParams{
  33631. Insutype: insutype,
  33632. ClrType: clr_type,
  33633. SetlOptins: clr_org,
  33634. StmtBegndate: start_time,
  33635. StmtEnddate: end_time,
  33636. MedfeeSumamt: medfee_sumamt,
  33637. FundPaySumamt: fund_pay_sumamt,
  33638. AcctPay: acct_pay,
  33639. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33640. }
  33641. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33642. fmt.Println(requestLog)
  33643. fmt.Println(result)
  33644. fmt.Println(err_msg)
  33645. var dat map[string]interface{}
  33646. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33647. fmt.Println(dat)
  33648. } else {
  33649. fmt.Println(err)
  33650. }
  33651. userJSONBytes, _ := json.Marshal(dat)
  33652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33653. utils.ErrorLog("解析失败:%v", err)
  33654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33655. return
  33656. }
  33657. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33658. var baseParams models.BaseParams
  33659. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33660. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33661. baseParams.SecretKey = miConfig.SecretKey
  33662. baseParams.OrgName = miConfig.OrgName
  33663. baseParams.FixmedinsCode = miConfig.Code
  33664. baseParams.EncKey = miConfig.EncKey
  33665. baseParams.AppSecret = miConfig.AppSecret
  33666. baseParams.SignKey = miConfig.SignKey
  33667. baseParams.AppID = miConfig.Code
  33668. baseParams.Doctor = role.UserName
  33669. baseParams.RequestUrl = miConfig.Url
  33670. baseParams.AccessKey = miConfig.AccessKey
  33671. businessParams := models.BusinessParams{
  33672. Insutype: insutype,
  33673. ClrType: clr_type,
  33674. SetlOptins: "430822",
  33675. StmtBegndate: start_time,
  33676. StmtEnddate: end_time,
  33677. MedfeeSumamt: medfee_sumamt,
  33678. FundPaySumamt: fund_pay_sumamt,
  33679. AcctPay: acct_pay,
  33680. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33681. }
  33682. 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)
  33683. fmt.Println(requestLog)
  33684. fmt.Println(result)
  33685. var dat map[string]interface{}
  33686. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33687. fmt.Println(dat)
  33688. } else {
  33689. fmt.Println(err)
  33690. }
  33691. userJSONBytes, _ := json.Marshal(dat)
  33692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33693. utils.ErrorLog("解析失败:%v", err)
  33694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33695. return
  33696. }
  33697. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33698. var baseParams models.BaseParams
  33699. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33700. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33701. baseParams.SecretKey = miConfig.SecretKey
  33702. baseParams.OrgName = miConfig.OrgName
  33703. baseParams.FixmedinsCode = miConfig.Code
  33704. baseParams.EncKey = miConfig.EncKey
  33705. baseParams.AppSecret = miConfig.AppSecret
  33706. baseParams.SignKey = miConfig.SignKey
  33707. baseParams.AppID = miConfig.Code
  33708. baseParams.Doctor = role.UserName
  33709. baseParams.RequestUrl = miConfig.Url
  33710. businessParams := models.BusinessParams{
  33711. Insutype: insutype,
  33712. ClrType: clr_type,
  33713. SetlOptins: clr_org,
  33714. StmtBegndate: start_time,
  33715. StmtEnddate: end_time,
  33716. MedfeeSumamt: medfee_sumamt,
  33717. FundPaySumamt: fund_pay_sumamt,
  33718. AcctPay: acct_pay,
  33719. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33720. }
  33721. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33722. fmt.Println(requestLog)
  33723. fmt.Println(result)
  33724. fmt.Println(err_msg)
  33725. var dat map[string]interface{}
  33726. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33727. fmt.Println(dat)
  33728. } else {
  33729. fmt.Println(err)
  33730. }
  33731. userJSONBytes, _ := json.Marshal(dat)
  33732. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33733. utils.ErrorLog("解析失败:%v", err)
  33734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33735. return
  33736. }
  33737. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33738. if len(clr_type) == 0 {
  33739. clr_type = "11"
  33740. }
  33741. api := miConfig.Url + "gdyb/ten?" +
  33742. "insutype=" + insutype +
  33743. "&clr_type=" + clr_type +
  33744. "&setl_optins=" + clr_org +
  33745. "&stmt_begndate=" + start_time +
  33746. "&stm_enddate=" + end_time +
  33747. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33748. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33749. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33750. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33751. "&fixmedins_code=" + miConfig.Code +
  33752. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33753. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33754. "&secret_key=" + miConfig.SecretKey +
  33755. "&org_name=" + miConfig.OrgName +
  33756. "&doctor=" + user_name
  33757. fmt.Println(api)
  33758. resp, requestErr := http.Get(api)
  33759. if requestErr != nil {
  33760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33761. return
  33762. }
  33763. body, ioErr := ioutil.ReadAll(resp.Body)
  33764. fmt.Println(body)
  33765. if ioErr != nil {
  33766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33768. return
  33769. }
  33770. var respJSON map[string]interface{}
  33771. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33774. return
  33775. }
  33776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33777. userJSONBytes, _ := json.Marshal(respJSON)
  33778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33779. utils.ErrorLog("解析失败:%v", err)
  33780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33781. return
  33782. }
  33783. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33784. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33785. //fixmedins_setl_cnt := int64(len(orders_two))
  33786. //var medfee_sumamt float64
  33787. //var acct_pay float64
  33788. //var fund_pay_sumamt float64
  33789. //for _, item := range orders_two {
  33790. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33791. // acct_pay = acct_pay + item.AcctPay
  33792. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33793. //}
  33794. var baseParams models.BaseParams
  33795. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33796. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33797. baseParams.SecretKey = miConfig.SecretKey
  33798. baseParams.OrgName = miConfig.OrgName
  33799. baseParams.FixmedinsCode = miConfig.Code
  33800. baseParams.EncKey = miConfig.EncKey
  33801. baseParams.AppSecret = miConfig.AppSecret
  33802. baseParams.SignKey = miConfig.SignKey
  33803. baseParams.AppID = miConfig.Code
  33804. baseParams.Doctor = role.UserName
  33805. baseParams.RequestUrl = miConfig.Url
  33806. if clr_type == "9903" {
  33807. clr_type = "9994"
  33808. }
  33809. businessParams := models.BusinessParams{
  33810. Insutype: insutype,
  33811. ClrType: clr_type,
  33812. SetlOptins: "360302",
  33813. StmtBegndate: start_time,
  33814. StmtEnddate: end_time,
  33815. MedfeeSumamt: 0,
  33816. FundPaySumamt: 0,
  33817. AcctPay: 0,
  33818. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33819. }
  33820. 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))
  33821. fmt.Println(requestLog)
  33822. fmt.Println(result)
  33823. var dat map[string]interface{}
  33824. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33825. fmt.Println(dat)
  33826. } else {
  33827. fmt.Println(err)
  33828. }
  33829. userJSONBytes, _ := json.Marshal(dat)
  33830. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33831. utils.ErrorLog("解析失败:%v", err)
  33832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33833. return
  33834. }
  33835. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33836. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33837. fixmedins_setl_cnt := int64(len(orders_two))
  33838. var medfee_sumamt float64
  33839. var acct_pay float64
  33840. var fund_pay_sumamt float64
  33841. for _, item := range orders_two {
  33842. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33843. acct_pay = acct_pay + item.AcctPay
  33844. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33845. }
  33846. var baseParams models.BaseParams
  33847. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33848. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33849. baseParams.SecretKey = miConfig.SecretKey
  33850. baseParams.OrgName = miConfig.OrgName
  33851. baseParams.FixmedinsCode = miConfig.Code
  33852. baseParams.EncKey = miConfig.EncKey
  33853. baseParams.AppSecret = miConfig.AppSecret
  33854. baseParams.SignKey = miConfig.SignKey
  33855. baseParams.AppID = miConfig.Code
  33856. baseParams.Doctor = role.UserName
  33857. baseParams.RequestUrl = miConfig.Url
  33858. if clr_type == "9903" {
  33859. clr_type = "9994"
  33860. }
  33861. businessParams := models.BusinessParams{
  33862. Insutype: insutype,
  33863. ClrType: clr_type,
  33864. SetlOptins: "361025",
  33865. StmtBegndate: start_time,
  33866. StmtEnddate: end_time,
  33867. MedfeeSumamt: 0,
  33868. FundPaySumamt: 0,
  33869. AcctPay: 0,
  33870. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33871. }
  33872. 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))
  33873. fmt.Println(requestLog)
  33874. fmt.Println(result)
  33875. var dat map[string]interface{}
  33876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33877. fmt.Println(dat)
  33878. } else {
  33879. fmt.Println(err)
  33880. }
  33881. userJSONBytes, _ := json.Marshal(dat)
  33882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33883. utils.ErrorLog("解析失败:%v", err)
  33884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33885. return
  33886. }
  33887. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33888. var api string
  33889. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33890. "&clr_type=" + clr_type +
  33891. "&setl_optins=" + clr_org +
  33892. "&stmt_begndate=" + start_time +
  33893. "&stm_enddate=" + end_time +
  33894. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33895. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33896. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33897. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33898. "&fixmedins_code=" + miConfig.Code +
  33899. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33900. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33901. "&secret_key=" + miConfig.SecretKey +
  33902. "&org_name=" + miConfig.OrgName +
  33903. "&doctor=" + user_name + "&url=" + miConfig.Url
  33904. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33905. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33906. resp, requestErr := http.Get(api)
  33907. if requestErr != nil {
  33908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33909. return
  33910. }
  33911. body, ioErr := ioutil.ReadAll(resp.Body)
  33912. if ioErr != nil {
  33913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33915. return
  33916. }
  33917. var respJSON map[string]interface{}
  33918. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33921. return
  33922. }
  33923. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33924. if status == "0" {
  33925. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33926. c.ServeSuccessJSON(map[string]interface{}{
  33927. "failed_code": -10,
  33928. "msg": err_msg,
  33929. })
  33930. return
  33931. }
  33932. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33933. userJSONBytes, _ := json.Marshal(respJSON)
  33934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33935. utils.ErrorLog("解析失败:%v", err)
  33936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33937. return
  33938. }
  33939. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33940. var api string
  33941. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33942. "&clr_type=" + clr_type +
  33943. "&setl_optins=" + clr_org +
  33944. "&stmt_begndate=" + start_time +
  33945. "&stm_enddate=" + end_time +
  33946. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33947. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33948. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33949. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33950. "&fixmedins_code=" + miConfig.Code +
  33951. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33952. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33953. "&secret_key=" + miConfig.SecretKey +
  33954. "&org_name=" + miConfig.OrgName +
  33955. "&doctor=" + user_name + "&url=" + miConfig.Url
  33956. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33957. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33958. resp, requestErr := http.Get(api)
  33959. if requestErr != nil {
  33960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33961. return
  33962. }
  33963. body, ioErr := ioutil.ReadAll(resp.Body)
  33964. if ioErr != nil {
  33965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33967. return
  33968. }
  33969. var respJSON map[string]interface{}
  33970. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33973. return
  33974. }
  33975. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33976. if status == "0" {
  33977. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33978. c.ServeSuccessJSON(map[string]interface{}{
  33979. "failed_code": -10,
  33980. "msg": err_msg,
  33981. })
  33982. return
  33983. }
  33984. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33985. userJSONBytes, _ := json.Marshal(respJSON)
  33986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33987. utils.ErrorLog("解析失败:%v", err)
  33988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33989. return
  33990. }
  33991. } else {
  33992. if len(clr_type) == 0 {
  33993. clr_type = "11"
  33994. }
  33995. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33996. "insutype=" + insutype +
  33997. "&clr_type=" + clr_type +
  33998. "&setl_optins=" + clr_org +
  33999. "&stmt_begndate=" + start_time +
  34000. "&stm_enddate=" + end_time +
  34001. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34002. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34003. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34004. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34005. "&fixmedins_code=" + miConfig.Code +
  34006. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34007. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34008. "&secret_key=" + miConfig.SecretKey +
  34009. "&org_name=" + miConfig.OrgName +
  34010. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34011. fmt.Println(api)
  34012. resp, requestErr := http.Get(api)
  34013. if requestErr != nil {
  34014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34015. return
  34016. }
  34017. body, ioErr := ioutil.ReadAll(resp.Body)
  34018. fmt.Println(body)
  34019. if ioErr != nil {
  34020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34022. return
  34023. }
  34024. var respJSON map[string]interface{}
  34025. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34028. return
  34029. }
  34030. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34031. userJSONBytes, _ := json.Marshal(respJSON)
  34032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34033. utils.ErrorLog("解析失败:%v", err)
  34034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34035. return
  34036. }
  34037. }
  34038. if res.Infcode == 0 {
  34039. if res.Output.Stmtinfo.StmtRslt == "0" {
  34040. micc := &models.MedicalInsuranceCostCompare{
  34041. StartTime: startime.Unix(),
  34042. EndTime: endtime.Unix(),
  34043. Insutype: insutype,
  34044. CheckType: 1,
  34045. Num: fixmedins_setl_cnt,
  34046. Mtime: time.Now().Unix(),
  34047. Status: 1,
  34048. UserOrgId: adminUser.CurrentOrgId,
  34049. CostTotal: medfee_sumamt,
  34050. FuncTotal: fund_pay_sumamt,
  34051. PsnPay: acct_pay,
  34052. Creator: admin_user_id,
  34053. Ctime: time.Now().Unix(),
  34054. ClrType: clr_type,
  34055. }
  34056. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  34057. if err == nil {
  34058. c.ServeSuccessJSON(map[string]interface{}{
  34059. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  34060. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  34061. })
  34062. } else {
  34063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34064. }
  34065. } else {
  34066. c.ServeSuccessJSON(map[string]interface{}{
  34067. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  34068. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  34069. })
  34070. }
  34071. } else {
  34072. c.ServeSuccessJSON(map[string]interface{}{
  34073. "failed_code": -10,
  34074. "msg": res.ErrMsg,
  34075. })
  34076. }
  34077. }
  34078. }
  34079. func (c *HisApiController) Check310() {
  34080. adminUser := c.GetAdminUserInfo()
  34081. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34082. var user_name string
  34083. user_name = "高慧裕"
  34084. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34085. "insutype=" + "310" +
  34086. "&clr_type=" + "" +
  34087. "&setl_optins=" + "441202" +
  34088. "&stmt_begndate=" + "2022-03-01" +
  34089. "&stm_enddate=" + "2022-03-31" +
  34090. "&medfee_sumamt=" + "194930.12" +
  34091. "&fund_pay_sumamt=" + "188741.46" +
  34092. "&acct_pay=" + "0" +
  34093. "&fixmedins_setl_cnt=" + "452" +
  34094. "&fixmedins_code=" + miConfig.Code +
  34095. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34096. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34097. "&secret_key=" + miConfig.SecretKey +
  34098. "&org_name=" + miConfig.OrgName +
  34099. "&doctor=" + user_name
  34100. fmt.Println(api)
  34101. resp, requestErr := http.Get(api)
  34102. if requestErr != nil {
  34103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34104. return
  34105. }
  34106. body, ioErr := ioutil.ReadAll(resp.Body)
  34107. fmt.Println(body)
  34108. if ioErr != nil {
  34109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34111. return
  34112. }
  34113. var respJSON map[string]interface{}
  34114. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34117. return
  34118. }
  34119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34120. userJSONBytes, _ := json.Marshal(respJSON)
  34121. var res ResultEight
  34122. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34123. utils.ErrorLog("解析失败:%v", err)
  34124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34125. return
  34126. }
  34127. }
  34128. func (c *HisApiController) Check390() {
  34129. adminUser := c.GetAdminUserInfo()
  34130. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34131. var user_name string
  34132. user_name = "高慧裕"
  34133. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34134. "insutype=" + "390" +
  34135. "&clr_type=" + "" +
  34136. "&setl_optins=" + "441202" +
  34137. "&stmt_begndate=" + "2022-03-01" +
  34138. "&stm_enddate=" + "2022-03-31" +
  34139. "&medfee_sumamt=" + "1068448.89" +
  34140. "&fund_pay_sumamt=" + "1014677.62" +
  34141. "&acct_pay=" + "0" +
  34142. "&fixmedins_setl_cnt=" + "1950" +
  34143. "&fixmedins_code=" + miConfig.Code +
  34144. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34145. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34146. "&secret_key=" + miConfig.SecretKey +
  34147. "&org_name=" + miConfig.OrgName +
  34148. "&doctor=" + user_name
  34149. fmt.Println(api)
  34150. resp, requestErr := http.Get(api)
  34151. if requestErr != nil {
  34152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34153. return
  34154. }
  34155. body, ioErr := ioutil.ReadAll(resp.Body)
  34156. fmt.Println(body)
  34157. if ioErr != nil {
  34158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34160. return
  34161. }
  34162. var respJSON map[string]interface{}
  34163. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34166. return
  34167. }
  34168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34169. userJSONBytes, _ := json.Marshal(respJSON)
  34170. var res ResultEight
  34171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34172. utils.ErrorLog("解析失败:%v", err)
  34173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34174. return
  34175. }
  34176. }
  34177. // 对账明细
  34178. func (c *HisApiController) GetCheckDetailAccount() {
  34179. start_time := c.GetString("start_time")
  34180. end_time := c.GetString("end_time")
  34181. admin_user_id, _ := c.GetInt64("admin_user_id")
  34182. adminUser := c.GetAdminUserInfo()
  34183. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34184. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34185. timeLayout := "2006-01-02"
  34186. loc, _ := time.LoadLocation("Local")
  34187. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34188. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34189. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34190. rand.Seed(time.Now().UnixNano())
  34191. num := rand.Intn(30000)
  34192. Mkdir(miConfig.OrgName)
  34193. file := strconv.FormatInt(int64(num), 10)
  34194. file_name := file + ".txt"
  34195. zip_name := file + ".zip"
  34196. zip_path := miConfig.OrgName + "/" + zip_name
  34197. file_path := miConfig.OrgName + "/" + file_name
  34198. decimal.DivisionPrecision = 2
  34199. var medfee_sumamt float64
  34200. var psn_cash_pay float64
  34201. var fund_pay_sumamt float64
  34202. fixmedins_setl_cnt := int64(len(orders))
  34203. for _, item := range orders {
  34204. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34205. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  34206. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34207. }
  34208. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  34209. defer f.Close()
  34210. if err != nil {
  34211. fmt.Println(err.Error())
  34212. } else {
  34213. for _, item := range orders {
  34214. var refd_setl_flag string
  34215. if item.OrderStatus == 2 {
  34216. refd_setl_flag = "0"
  34217. var str string
  34218. str = item.SetlId + " " +
  34219. item.MdtrtId + " " +
  34220. item.PsnNo + " " +
  34221. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34222. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34223. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  34224. _, err = f.Write([]byte(str))
  34225. }
  34226. if item.OrderStatus == 3 {
  34227. var str string
  34228. str = item.SetlId + " " +
  34229. item.MdtrtId + " " +
  34230. item.PsnNo + " " +
  34231. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34232. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34233. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  34234. _, err = f.Write([]byte(str))
  34235. var str2 string
  34236. str2 = item.SetlId + " " +
  34237. item.MdtrtId + " " +
  34238. item.PsnNo + " " +
  34239. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  34240. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  34241. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  34242. _, err = f.Write([]byte(str2))
  34243. }
  34244. }
  34245. }
  34246. Zip(file_path, zip_path)
  34247. fmt.Println(ReadFile(zip_path))
  34248. fmt.Println(string(ReadFile(zip_path)))
  34249. if config.IsOpen == 1 {
  34250. var user_name string
  34251. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34252. if role.ID == 0 {
  34253. user_name = "管理员"
  34254. } else {
  34255. user_name = role.UserName
  34256. }
  34257. baseParams := models.BaseParams{
  34258. SecretKey: miConfig.SecretKey,
  34259. FixmedinsCode: miConfig.Code,
  34260. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34261. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34262. OrgName: miConfig.OrgName,
  34263. Doctor: user_name,
  34264. }
  34265. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34266. var dat map[string]interface{}
  34267. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34268. fmt.Println(dat)
  34269. } else {
  34270. fmt.Println(err)
  34271. }
  34272. userJSONBytes, _ := json.Marshal(dat)
  34273. var res ResultNine
  34274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34275. utils.ErrorLog("解析失败:%v", err)
  34276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34277. return
  34278. }
  34279. if res.Infcode == 0 {
  34280. fileNo := res.Output.FileQuryNo
  34281. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34282. "file_qury_no=" + fileNo +
  34283. "&setl_optins=" + "定点医保中心" +
  34284. "&stmt_begndate=" + start_time +
  34285. "&stm_enddate=" + end_time +
  34286. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34287. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34288. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34289. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34290. "&fixmedins_code=" + miConfig.Code +
  34291. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34292. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34293. "&secret_key=" + miConfig.SecretKey +
  34294. "&org_name=" + miConfig.OrgName +
  34295. "&doctor=" + user_name
  34296. resp, requestErr := http.Get(api)
  34297. if requestErr != nil {
  34298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34299. return
  34300. }
  34301. body, ioErr := ioutil.ReadAll(resp.Body)
  34302. if ioErr != nil {
  34303. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34305. return
  34306. }
  34307. var respJSON map[string]interface{}
  34308. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34311. return
  34312. }
  34313. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34314. userJSONBytes, _ := json.Marshal(respJSON)
  34315. var res ResultTen
  34316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34317. utils.ErrorLog("解析失败:%v", err)
  34318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34319. return
  34320. }
  34321. if res.Infcode == 0 {
  34322. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34323. micc := &models.MedicalInsuranceCostCompare{
  34324. StartTime: startime.Unix(),
  34325. EndTime: endtime.Unix(),
  34326. Insutype: "0",
  34327. CheckType: 2,
  34328. Num: fixmedins_setl_cnt,
  34329. Mtime: time.Now().Unix(),
  34330. Status: 1,
  34331. UserOrgId: adminUser.CurrentOrgId,
  34332. CostTotal: medfee_sumamt,
  34333. FuncTotal: fund_pay_sumamt,
  34334. PsnPay: psn_cash_pay,
  34335. Creator: admin_user_id,
  34336. Ctime: time.Now().Unix(),
  34337. }
  34338. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34339. c.ServeSuccessJSON(map[string]interface{}{
  34340. "msg": "明细对账成功",
  34341. })
  34342. }
  34343. } else {
  34344. }
  34345. }
  34346. }
  34347. type CustomOrderInfo struct {
  34348. Name string
  34349. Spec string
  34350. Unit string
  34351. Count float64
  34352. Price float64
  34353. Total float64
  34354. }
  34355. func (c *HisApiController) GetBatchSettleAccounts() {
  34356. admin_user_id, _ := c.GetInt64("admin_user_id")
  34357. order_ids := c.GetString("order_ids")
  34358. order_ids_arr := strings.Split(order_ids, ",")
  34359. data3 := []map[string]interface{}{}
  34360. for _, item := range order_ids_arr {
  34361. id, _ := strconv.ParseInt(item, 10, 64)
  34362. order_id := id
  34363. adminUser := c.GetAdminUserInfo()
  34364. order, _ := service.GetHisOrderByID(order_id)
  34365. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34366. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34367. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34368. orderInfos = append(orderInfos, orderInfos_two...)
  34369. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34370. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34371. var diagnosis_ids []string
  34372. if his.ID > 0 {
  34373. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34374. } else {
  34375. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34376. }
  34377. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34378. var dia_config []*models.HisXtDiagnoseConfig
  34379. var name string
  34380. for _, item := range diagnosis_ids {
  34381. id, _ := strconv.ParseInt(item, 10, 64)
  34382. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34383. dia_config = append(dia_config, &diagnosisConfig)
  34384. if len(name) == 0 {
  34385. name = diagnosisConfig.ClassName
  34386. }
  34387. //} else {
  34388. // name = name + "," + diagnosisConfig.ClassName
  34389. //}
  34390. }
  34391. var bedCostTotal float64 = 0 //床位总费
  34392. var bedCostSelfTotal float64 = 0 //床位自费
  34393. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34394. var bedSelfTotal float64 = 0 //床位部分项目自费
  34395. var bedInscpTotal float64 = 0 //床位部分项目自费
  34396. var operationCostTotal float64 = 0 //手术费
  34397. var operationCostSelfTotal float64 = 0 //手术费
  34398. var operationCostPartSelfTotal float64 = 0 //手术费
  34399. var operationSelfTotal float64 = 0 //床位部分项目自费
  34400. var operationInscpTotal float64 = 0 //床位部分项目自费
  34401. var otherCostTotal float64 = 0 //其他费用
  34402. var otherCostSelfTotal float64 = 0 //其他费用
  34403. var otherCostPartSelfTotal float64 = 0 //其他费用
  34404. var otherSelfTotal float64 = 0 //床位部分项目自费
  34405. var otherInscpTotal float64 = 0 //床位部分项目自费
  34406. var materialCostTotal float64 = 0 //材料费
  34407. var materialCostSelfTotal float64 = 0 //材料费
  34408. var materialCostPartSelfTotal float64 = 0 //材料费
  34409. var materialSelfTotal float64 = 0 //床位部分项目自费
  34410. var materialInscpTotal float64 = 0 //床位部分项目自费
  34411. var westernMedicineCostTotal float64 = 0 //西药费
  34412. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34413. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34414. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34415. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34416. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34417. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34418. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34419. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34420. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34421. var checkCostTotal float64 = 0 //检查费
  34422. var checkCostSelfTotal float64 = 0 //检查费
  34423. var checkCostPartSelfTotal float64 = 0 //检查费
  34424. var checkSelfTotal float64 = 0 //床位部分项目自费
  34425. var checkInscpTotal float64 = 0 //床位部分项目自费
  34426. var laboratoryCostTotal float64 = 0 //化验费
  34427. var laboratoryCostSelfTotal float64 = 0 //化验费
  34428. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34429. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34430. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34431. var treatCostTotal float64 = 0 //治疗费用
  34432. var treatCostSelfTotal float64 = 0 //治疗费用
  34433. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34434. var treatSelfTotal float64 = 0 //床位部分项目自费
  34435. var treatInscpTotal float64 = 0 //床位部分项目自费
  34436. decimal.DivisionPrecision = 2
  34437. for _, item := range orderInfos {
  34438. if item.MedChrgitmType == "01" { //床位费
  34439. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34440. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34441. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34442. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34443. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34444. }
  34445. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34446. if item.MedChrgitmType == "03" { //检查费
  34447. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34448. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34449. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34450. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34451. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34452. }
  34453. } else {
  34454. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34455. fmt.Println("------------")
  34456. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34457. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34458. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34459. }
  34460. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34461. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34462. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34463. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34464. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34465. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34466. }
  34467. }
  34468. if item.MedChrgitmType == "04" { //化验费
  34469. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34470. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34471. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34472. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34473. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34474. }
  34475. if item.MedChrgitmType == "05" { //治疗费
  34476. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34477. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34478. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34479. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34480. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34481. }
  34482. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34483. fmt.Println("------------")
  34484. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34485. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34486. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34487. }
  34488. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34489. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34490. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34491. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34492. }
  34493. //if item.MedChrgitmType == "06" { //手术费
  34494. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34495. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34496. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34497. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34498. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34499. //
  34500. //}
  34501. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34502. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34503. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34504. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34505. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34506. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34507. }
  34508. if item.MedChrgitmType == "09" { //西药费
  34509. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34510. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34511. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34512. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34513. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34514. }
  34515. if item.MedChrgitmType == "11" { //中成费
  34516. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34517. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34518. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34519. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34520. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34521. }
  34522. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34523. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34524. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34525. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34526. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34527. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34528. }
  34529. }
  34530. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34531. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34532. var user_name string
  34533. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34534. if role.ID == 0 {
  34535. user_name = "管理员"
  34536. } else {
  34537. user_name = role.UserName
  34538. }
  34539. baseParams := models.BaseParams{
  34540. SecretKey: miConfig.SecretKey,
  34541. FixmedinsCode: miConfig.Code,
  34542. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34543. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34544. OrgName: miConfig.OrgName,
  34545. Doctor: user_name,
  34546. RequestUrl: miConfig.Url,
  34547. AccessKey: miConfig.AccessKey,
  34548. }
  34549. businessParams := models.BusinessParams{
  34550. PsnNo: order.PsnNo,
  34551. MdtrtId: order.MdtrtId,
  34552. SetlId: order.SetlId,
  34553. }
  34554. var res ResultEleven
  34555. var resEleven10265 ResultEleven10265
  34556. if config.IsOpen == 1 {
  34557. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34558. result := service.Gdyb5203(baseParams, businessParams)
  34559. service.Gdyb5204(baseParams, businessParams)
  34560. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34561. var dat map[string]interface{}
  34562. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34563. fmt.Println(dat)
  34564. } else {
  34565. fmt.Println(err)
  34566. }
  34567. userJSONBytes, _ := json.Marshal(dat)
  34568. if miConfig.Code == "H15049901371" {
  34569. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34570. utils.ErrorLog("解析失败:%v", err)
  34571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34572. return
  34573. }
  34574. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34575. res.Output = resEleven10265.Output
  34576. res.ErrMsg = resEleven10265.ErrMsg
  34577. res.Cainfo = resEleven10265.Cainfo
  34578. res.WarnMsg = resEleven10265.WarnMsg
  34579. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34580. res.Infcode = infocode
  34581. } else {
  34582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34583. utils.ErrorLog("解析失败:%v", err)
  34584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34585. return
  34586. }
  34587. }
  34588. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34589. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34590. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34591. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34592. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34593. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34594. var doctor_name string
  34595. if roles.ID == 0 {
  34596. doctor_name = "管理员"
  34597. } else {
  34598. doctor_name = roles.UserName
  34599. }
  34600. yiliao_leibie := ""
  34601. switch order.MedType {
  34602. case "11":
  34603. yiliao_leibie = "普通门诊"
  34604. break
  34605. case "12":
  34606. yiliao_leibie = "门诊挂号"
  34607. break
  34608. case "13":
  34609. yiliao_leibie = "急诊"
  34610. break
  34611. case "14":
  34612. yiliao_leibie = "门诊特殊病"
  34613. break
  34614. case "15":
  34615. yiliao_leibie = "门诊统筹"
  34616. break
  34617. case "16":
  34618. yiliao_leibie = "门诊慢性病"
  34619. break
  34620. case "21":
  34621. yiliao_leibie = "普通住院"
  34622. break
  34623. }
  34624. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34625. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34626. if res.Infcode == 0 {
  34627. data2 := map[string]interface{}{
  34628. "diagnosis": name,
  34629. "order_infos": orderInfos,
  34630. "number": order.MdtrtId,
  34631. "date": order.SettleAccountsDate,
  34632. "charge_admin": charge_admin,
  34633. "printor_admin": printor_admin,
  34634. "info": res.Output.Setlinfo,
  34635. "order": order,
  34636. "bedCostTotal": bedCostTotal,
  34637. "bedCostSelfTotal": bedCostSelfTotal,
  34638. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34639. "bedSelfTotal": bedSelfTotal,
  34640. "bedInscpTotal": bedInscpTotal,
  34641. "operationCostTotal": operationCostTotal,
  34642. "operationCostSelfTotal": operationCostSelfTotal,
  34643. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34644. "operationSelfTotal": operationSelfTotal,
  34645. "operationInscpTotal": operationInscpTotal,
  34646. "otherCostTotal": otherCostTotal,
  34647. "otherCostSelfTotal": otherCostSelfTotal,
  34648. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34649. "otherSelfTotal": otherSelfTotal,
  34650. "otherInscpTotal": otherInscpTotal,
  34651. "materialCostTotal": materialCostTotal,
  34652. "materialCostSelfTotal": materialCostSelfTotal,
  34653. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34654. "materialSelfTotal": materialSelfTotal,
  34655. "materialInscpTotal": materialInscpTotal,
  34656. "westernMedicineCostTotal": westernMedicineCostTotal,
  34657. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34658. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34659. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34660. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34661. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34662. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34663. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34664. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34665. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34666. "checkCostTotal": checkCostTotal,
  34667. "checkCostSelfTotal": checkCostSelfTotal,
  34668. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34669. "checkSelfTotal": checkSelfTotal,
  34670. "checkInscpTotal": checkInscpTotal,
  34671. "laboratoryCostTotal": laboratoryCostTotal,
  34672. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34673. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34674. "laboratorySelfTotal": laboratorySelfTotal,
  34675. "laboratoryInscpTotal": laboratoryInscpTotal,
  34676. "treatCostTotal": treatCostTotal,
  34677. "treatCostSelfTotal": treatCostSelfTotal,
  34678. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34679. "treatSelfTotal": treatSelfTotal,
  34680. "treatInscpTotal": treatInscpTotal,
  34681. "doctor_info": doctor_info,
  34682. "doctor_code": adminRole_two.DoctorCode,
  34683. "doctor_name": doctor_name,
  34684. "health_card_no": order.PsnNo,
  34685. "department": departments.Name,
  34686. "yiliao_leibie": yiliao_leibie,
  34687. "after_money": order.AccountPrice,
  34688. "patient": patient,
  34689. "org_name": miConfig.OrgName,
  34690. "org_code": miConfig.Code,
  34691. "order_number": order.Number,
  34692. "his_hospital": his_hospital,
  34693. "his": his,
  34694. "dia_config": dia_config,
  34695. "psn_cash_pay": order.PsnCashPay,
  34696. //"check_order_info": cus_slice,
  34697. }
  34698. data3 = append(data3, data2)
  34699. }
  34700. }
  34701. }
  34702. c.ServeSuccessJSON(map[string]interface{}{
  34703. "infos": data3,
  34704. })
  34705. }
  34706. func (c *HisApiController) GetSettleAccounts() {
  34707. //id, _ := c.GetInt64("id")
  34708. //record_time := c.GetString("record_time")
  34709. order_id, _ := c.GetInt64("order_id")
  34710. admin_user_id, _ := c.GetInt64("admin_user_id")
  34711. //timeLayout := "2006-01-02"
  34712. //loc, _ := time.LoadLocation("Local")
  34713. //
  34714. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34715. //if err != nil {
  34716. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34717. // return
  34718. //}Hbyb5203
  34719. //recordDateTime := theTime.Unix()
  34720. adminUser := c.GetAdminUserInfo()
  34721. order, _ := service.GetHisOrderByID(order_id)
  34722. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34723. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34724. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34725. orderInfos = append(orderInfos, orderInfos_two...)
  34726. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34727. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34728. var diagnosis_ids []string
  34729. if his.ID > 0 {
  34730. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34731. } else {
  34732. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34733. }
  34734. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34735. var dia_config []*models.HisXtDiagnoseConfig
  34736. var name string
  34737. for _, item := range diagnosis_ids {
  34738. id, _ := strconv.ParseInt(item, 10, 64)
  34739. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34740. dia_config = append(dia_config, &diagnosisConfig)
  34741. if len(name) == 0 {
  34742. name = diagnosisConfig.ClassName
  34743. } else {
  34744. name = name + "," + diagnosisConfig.ClassName
  34745. }
  34746. }
  34747. if patient.UserOrgId == 10215 {
  34748. name = "慢性肾功能不全(血透治疗)"
  34749. }
  34750. var bedCostTotal float64 = 0 //床位总费
  34751. var bedCostSelfTotal float64 = 0 //床位自费
  34752. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34753. var bedSelfTotal float64 = 0 //床位部分项目自费
  34754. var bedInscpTotal float64 = 0 //床位部分项目自费
  34755. var operationCostTotal float64 = 0 //手术费
  34756. var operationCostSelfTotal float64 = 0 //手术费
  34757. var operationCostPartSelfTotal float64 = 0 //手术费
  34758. var operationSelfTotal float64 = 0 //床位部分项目自费
  34759. var operationInscpTotal float64 = 0 //床位部分项目自费
  34760. var otherCostTotal float64 = 0 //其他费用
  34761. var otherCostSelfTotal float64 = 0 //其他费用
  34762. var otherCostPartSelfTotal float64 = 0 //其他费用
  34763. var otherSelfTotal float64 = 0 //床位部分项目自费
  34764. var otherInscpTotal float64 = 0 //床位部分项目自费
  34765. var materialCostTotal float64 = 0 //材料费
  34766. var materialCostSelfTotal float64 = 0 //材料费
  34767. var materialCostPartSelfTotal float64 = 0 //材料费
  34768. var materialSelfTotal float64 = 0 //床位部分项目自费
  34769. var materialInscpTotal float64 = 0 //床位部分项目自费
  34770. var westernMedicineCostTotal float64 = 0 //西药费
  34771. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34772. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34773. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34774. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34775. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34776. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34777. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34778. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34779. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34780. var checkCostTotal float64 = 0 //检查费
  34781. var checkCostSelfTotal float64 = 0 //检查费
  34782. var checkCostPartSelfTotal float64 = 0 //检查费
  34783. var checkSelfTotal float64 = 0 //床位部分项目自费
  34784. var checkInscpTotal float64 = 0 //床位部分项目自费
  34785. var laboratoryCostTotal float64 = 0 //化验费
  34786. var laboratoryCostSelfTotal float64 = 0 //化验费
  34787. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34788. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34789. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34790. var treatCostTotal float64 = 0 //治疗费用
  34791. var treatCostSelfTotal float64 = 0 //治疗费用
  34792. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34793. var treatSelfTotal float64 = 0 //床位部分项目自费
  34794. var treatInscpTotal float64 = 0 //床位部分项目自费
  34795. var zcCostTotal float64 = 0 //治疗费用
  34796. var zcCostSelfTotal float64 = 0 //治疗费用
  34797. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34798. var zcSelfTotal float64 = 0 //床位部分项目自费
  34799. var zcInscpTotal float64 = 0 //床位部分项目自费
  34800. var huliCostTotal float64 = 0 //治疗费用
  34801. var huliCostSelfTotal float64 = 0 //治疗费用
  34802. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34803. var huliSelfTotal float64 = 0 //床位部分项目自费
  34804. var huliInscpTotal float64 = 0 //床位部分项目自费
  34805. decimal.DivisionPrecision = 2
  34806. for _, item := range orderInfos {
  34807. if item.MedChrgitmType == "01" { //床位费
  34808. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34809. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34810. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34811. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34812. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34813. }
  34814. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34815. if item.MedChrgitmType == "03" { //检查费
  34816. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34817. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34818. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34819. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34820. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34821. }
  34822. } else {
  34823. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34824. fmt.Println("------------")
  34825. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34826. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34827. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34828. }
  34829. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34830. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34831. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34832. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34833. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34834. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34835. }
  34836. }
  34837. if item.MedChrgitmType == "04" { //化验费
  34838. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34839. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34840. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34841. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34842. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34843. }
  34844. if item.MedChrgitmType == "05" { //治疗费
  34845. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34846. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34847. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34848. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34849. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34850. }
  34851. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34852. fmt.Println("------------")
  34853. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34854. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34855. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34856. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34857. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34858. }
  34859. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34860. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34861. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34862. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34863. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34864. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34865. }
  34866. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34867. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34868. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34869. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34870. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34871. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34872. }
  34873. if item.MedChrgitmType == "09" { //西药费
  34874. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34875. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34876. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34877. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34878. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34879. }
  34880. if item.MedChrgitmType == "11" { //中成费
  34881. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34882. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34883. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34884. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34885. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34886. }
  34887. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34888. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34889. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34890. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34891. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34892. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34893. }
  34894. if item.MedChrgitmType == "02" { //其他费
  34895. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34896. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34897. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34898. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34899. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34900. }
  34901. if item.MedChrgitmType == "07" { //其他费
  34902. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34903. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34904. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34905. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34906. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34907. }
  34908. }
  34909. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34910. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34911. var user_name string
  34912. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34913. if role.ID == 0 {
  34914. user_name = "管理员"
  34915. } else {
  34916. user_name = role.UserName
  34917. }
  34918. baseParams := models.BaseParams{
  34919. SecretKey: miConfig.SecretKey,
  34920. FixmedinsCode: miConfig.Code,
  34921. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34922. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34923. OrgName: miConfig.OrgName,
  34924. Doctor: user_name,
  34925. RequestUrl: miConfig.Url,
  34926. AccessKey: miConfig.AccessKey,
  34927. }
  34928. businessParams := models.BusinessParams{
  34929. PsnNo: order.PsnNo,
  34930. MdtrtId: order.MdtrtId,
  34931. SetlId: order.SetlId,
  34932. }
  34933. var res ResultEleven
  34934. var resah ResultElevenah
  34935. var resEleven10265 ResultEleven10265
  34936. if config.IsOpen == 1 {
  34937. if miConfig.MdtrtareaAdmvs == "421300" {
  34938. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34939. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34940. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34941. resp, requestErr := http.Get(api)
  34942. if requestErr != nil {
  34943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34944. return
  34945. }
  34946. body, ioErr := ioutil.ReadAll(resp.Body)
  34947. if ioErr != nil {
  34948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34950. return
  34951. }
  34952. var respJSON map[string]interface{}
  34953. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34956. return
  34957. }
  34958. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34959. result, _ := json.Marshal(respJSON)
  34960. fmt.Println("log")
  34961. fmt.Println(string(result))
  34962. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34963. utils.ErrorLog("解析失败:%v", err)
  34964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34965. return
  34966. }
  34967. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34968. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34969. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34970. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34971. resp, requestErr := http.Get(api)
  34972. if requestErr != nil {
  34973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34974. return
  34975. }
  34976. body, ioErr := ioutil.ReadAll(resp.Body)
  34977. if ioErr != nil {
  34978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34980. return
  34981. }
  34982. var respJSON map[string]interface{}
  34983. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34986. return
  34987. }
  34988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34989. result, _ := json.Marshal(respJSON)
  34990. fmt.Println("log")
  34991. fmt.Println(string(result))
  34992. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34993. utils.ErrorLog("解析失败:%v", err)
  34994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34995. return
  34996. }
  34997. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34998. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34999. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35000. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35001. resp, requestErr := http.Get(api)
  35002. if requestErr != nil {
  35003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35004. return
  35005. }
  35006. body, ioErr := ioutil.ReadAll(resp.Body)
  35007. if ioErr != nil {
  35008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35010. return
  35011. }
  35012. var respJSON map[string]interface{}
  35013. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35016. return
  35017. }
  35018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35019. result, _ := json.Marshal(respJSON)
  35020. fmt.Println("log")
  35021. fmt.Println(string(result))
  35022. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35023. utils.ErrorLog("解析失败:%v", err)
  35024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35025. return
  35026. }
  35027. } else if miConfig.MdtrtareaAdmvs == "421182" {
  35028. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35029. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35030. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  35031. resp, requestErr := http.Get(api)
  35032. if requestErr != nil {
  35033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35034. return
  35035. }
  35036. body, ioErr := ioutil.ReadAll(resp.Body)
  35037. if ioErr != nil {
  35038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35040. return
  35041. }
  35042. var respJSON map[string]interface{}
  35043. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35046. return
  35047. }
  35048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35049. result, _ := json.Marshal(respJSON)
  35050. fmt.Println("log")
  35051. fmt.Println(string(result))
  35052. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35053. utils.ErrorLog("解析失败:%v", err)
  35054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35055. return
  35056. }
  35057. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  35058. var api string
  35059. if miConfig.MdtrtareaAdmvs == "320921" {
  35060. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35061. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35062. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35063. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35064. } else {
  35065. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35066. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35067. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35068. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35069. }
  35070. resp, requestErr := http.Get(api)
  35071. if requestErr != nil {
  35072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35073. return
  35074. }
  35075. body, ioErr := ioutil.ReadAll(resp.Body)
  35076. if ioErr != nil {
  35077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35079. return
  35080. }
  35081. var respJSON map[string]interface{}
  35082. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35085. return
  35086. }
  35087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35088. result, _ := json.Marshal(respJSON)
  35089. fmt.Println("log")
  35090. fmt.Println(string(result))
  35091. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35092. utils.ErrorLog("解析失败:%v", err)
  35093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35094. return
  35095. }
  35096. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35097. res.Output = resEleven10265.Output
  35098. res.ErrMsg = resEleven10265.ErrMsg
  35099. res.Cainfo = resEleven10265.Cainfo
  35100. res.WarnMsg = resEleven10265.WarnMsg
  35101. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35102. res.Infcode = infocode
  35103. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35104. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  35105. saveLog(result, requestLog, "5203", "结算单")
  35106. var dat map[string]interface{}
  35107. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35108. fmt.Println(dat)
  35109. } else {
  35110. fmt.Println(err)
  35111. }
  35112. userJSONBytes, _ := json.Marshal(dat)
  35113. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35114. utils.ErrorLog("解析失败:%v", err)
  35115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35116. return
  35117. }
  35118. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35119. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35120. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35121. saveLog(result, requestLog, "5203", "结算单")
  35122. var dat map[string]interface{}
  35123. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35124. fmt.Println(dat)
  35125. } else {
  35126. fmt.Println(err)
  35127. }
  35128. userJSONBytes, _ := json.Marshal(dat)
  35129. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35130. utils.ErrorLog("解析失败:%v", err)
  35131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35132. return
  35133. }
  35134. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35135. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35136. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35137. saveLog(result, requestLog, "5203", "结算单")
  35138. var dat map[string]interface{}
  35139. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35140. fmt.Println(dat)
  35141. } else {
  35142. fmt.Println(err)
  35143. }
  35144. userJSONBytes, _ := json.Marshal(dat)
  35145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35146. utils.ErrorLog("解析失败:%v", err)
  35147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35148. return
  35149. }
  35150. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35151. var api string
  35152. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35153. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35154. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35155. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35156. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35157. resp, requestErr := http.Get(api)
  35158. if requestErr != nil {
  35159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35160. return
  35161. }
  35162. body, ioErr := ioutil.ReadAll(resp.Body)
  35163. if ioErr != nil {
  35164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35166. return
  35167. }
  35168. var respJSON map[string]interface{}
  35169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35172. return
  35173. }
  35174. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35175. if status == "0" {
  35176. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35177. c.ServeSuccessJSON(map[string]interface{}{
  35178. "failed_code": -10,
  35179. "msg": err_msg,
  35180. })
  35181. return
  35182. }
  35183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35184. result, _ := json.Marshal(respJSON)
  35185. fmt.Println("log")
  35186. fmt.Println(string(result))
  35187. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35188. utils.ErrorLog("解析失败:%v", err)
  35189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35190. return
  35191. }
  35192. res.InfRefmsgid = resah.InfRefmsgid
  35193. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35194. // 创建对应的Time类型
  35195. t := time.UnixMilli(timestamp)
  35196. // 格式化成指定的日期字符串
  35197. str := t.Format("2006-01-02 15:04:05")
  35198. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35199. // 创建对应的Time类型
  35200. t3 := time.UnixMilli(timestamp2)
  35201. // 格式化成指定的日期字符串
  35202. str2 := t3.Format("2006-01-02 15:04:05")
  35203. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35204. // 创建对应的Time类型
  35205. t4 := time.UnixMilli(timestamp3)
  35206. // 格式化成指定的日期字符串
  35207. str3 := t4.Format("2006-01-02 15:04:05")
  35208. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35209. // 创建对应的Time类型
  35210. t5 := time.UnixMilli(timestamp4)
  35211. // 格式化成指定的日期字符串
  35212. str5 := t5.Format("2006-01-02 15:04:05")
  35213. res.Output.Setlinfo.Brdy = str2
  35214. res.Output.Setlinfo.SetlTime = str
  35215. res.Output.Setlinfo.Begndate = str3
  35216. res.Output.Setlinfo.Enddate = str5
  35217. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35218. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35219. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35220. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35221. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35222. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35223. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35224. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35225. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35226. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35227. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35228. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35229. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35230. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35231. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35232. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35233. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35234. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35235. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35236. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35237. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35238. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35239. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35240. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35241. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35242. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35243. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35244. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35245. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35246. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35247. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35248. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35249. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35250. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35251. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35252. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35253. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35254. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35255. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35256. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35257. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35258. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35259. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35260. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35261. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35262. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35263. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35264. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35265. //res.Output.Setldetail = resah.Output.Setldetail
  35266. res.ErrMsg = resah.ErrMsg
  35267. res.Cainfo = resah.Cainfo
  35268. res.WarnMsg = resah.WarnMsg
  35269. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35270. var api string
  35271. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35272. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35273. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35274. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35275. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35276. resp, requestErr := http.Get(api)
  35277. if requestErr != nil {
  35278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35279. return
  35280. }
  35281. body, ioErr := ioutil.ReadAll(resp.Body)
  35282. if ioErr != nil {
  35283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35285. return
  35286. }
  35287. var respJSON map[string]interface{}
  35288. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35291. return
  35292. }
  35293. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35294. if status == "0" {
  35295. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35296. c.ServeSuccessJSON(map[string]interface{}{
  35297. "failed_code": -10,
  35298. "msg": err_msg,
  35299. })
  35300. return
  35301. }
  35302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35303. result, _ := json.Marshal(respJSON)
  35304. fmt.Println("log")
  35305. fmt.Println(string(result))
  35306. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35307. utils.ErrorLog("解析失败:%v", err)
  35308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35309. return
  35310. }
  35311. res.InfRefmsgid = resah.InfRefmsgid
  35312. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35313. // 创建对应的Time类型
  35314. t := time.UnixMilli(timestamp)
  35315. // 格式化成指定的日期字符串
  35316. str := t.Format("2006-01-02 15:04:05")
  35317. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35318. // 创建对应的Time类型
  35319. t3 := time.UnixMilli(timestamp2)
  35320. // 格式化成指定的日期字符串
  35321. str2 := t3.Format("2006-01-02 15:04:05")
  35322. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35323. // 创建对应的Time类型
  35324. t4 := time.UnixMilli(timestamp3)
  35325. // 格式化成指定的日期字符串
  35326. str3 := t4.Format("2006-01-02 15:04:05")
  35327. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35328. // 创建对应的Time类型
  35329. t5 := time.UnixMilli(timestamp4)
  35330. // 格式化成指定的日期字符串
  35331. str5 := t5.Format("2006-01-02 15:04:05")
  35332. res.Output.Setlinfo.Brdy = str2
  35333. res.Output.Setlinfo.SetlTime = str
  35334. res.Output.Setlinfo.Begndate = str3
  35335. res.Output.Setlinfo.Enddate = str5
  35336. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35337. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35338. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35339. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35340. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35341. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35342. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35343. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35344. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35345. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35346. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35347. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35348. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35349. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35350. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35351. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35352. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35353. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35354. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35355. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35356. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35357. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35358. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35359. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35360. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35361. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35362. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35363. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35364. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35365. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35366. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35367. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35368. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35369. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35370. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35371. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35372. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35373. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35374. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35375. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35376. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35377. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35378. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35379. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35380. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35381. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35382. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35383. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35384. //res.Output.Setldetail = resah.Output.Setldetail
  35385. res.ErrMsg = resah.ErrMsg
  35386. res.Cainfo = resah.Cainfo
  35387. res.WarnMsg = resah.WarnMsg
  35388. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35389. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35390. saveLog(result, requestLog, "5203", "结算单")
  35391. var dat map[string]interface{}
  35392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35393. fmt.Println(dat)
  35394. } else {
  35395. fmt.Println(err)
  35396. }
  35397. userJSONBytes, _ := json.Marshal(dat)
  35398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35399. utils.ErrorLog("解析失败:%v", err)
  35400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35401. return
  35402. }
  35403. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35404. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35405. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35406. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35407. resp, requestErr := http.Get(api)
  35408. if requestErr != nil {
  35409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35410. return
  35411. }
  35412. body, ioErr := ioutil.ReadAll(resp.Body)
  35413. if ioErr != nil {
  35414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35416. return
  35417. }
  35418. var respJSON map[string]interface{}
  35419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35422. return
  35423. }
  35424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35425. result, _ := json.Marshal(respJSON)
  35426. fmt.Println("log")
  35427. fmt.Println(string(result))
  35428. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35429. utils.ErrorLog("解析失败:%v", err)
  35430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35431. return
  35432. }
  35433. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35434. res.Output = resEleven10265.Output
  35435. res.ErrMsg = resEleven10265.ErrMsg
  35436. res.Cainfo = resEleven10265.Cainfo
  35437. res.WarnMsg = resEleven10265.WarnMsg
  35438. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35439. res.Infcode = infocode
  35440. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35441. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35442. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35443. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35444. resp, requestErr := http.Get(api)
  35445. if requestErr != nil {
  35446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35447. return
  35448. }
  35449. body, ioErr := ioutil.ReadAll(resp.Body)
  35450. if ioErr != nil {
  35451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35453. return
  35454. }
  35455. var respJSON map[string]interface{}
  35456. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35459. return
  35460. }
  35461. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35462. result, _ := json.Marshal(respJSON)
  35463. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35464. utils.ErrorLog("解析失败:%v", err)
  35465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35466. return
  35467. }
  35468. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35469. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35470. //return
  35471. } else {
  35472. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35473. if len(his.InsuplcAdmdvs) == 0 {
  35474. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35475. } else {
  35476. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35477. }
  35478. result := service.Gdyb5203(baseParams, businessParams)
  35479. //service.Gdyb5204(baseParams, businessParams)
  35480. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35481. var dat map[string]interface{}
  35482. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35483. fmt.Println(dat)
  35484. } else {
  35485. fmt.Println(err)
  35486. }
  35487. userJSONBytes, _ := json.Marshal(dat)
  35488. if miConfig.Code == "H15049901371" {
  35489. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35490. utils.ErrorLog("解析失败:%v", err)
  35491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35492. return
  35493. }
  35494. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35495. res.Output = resEleven10265.Output
  35496. res.ErrMsg = resEleven10265.ErrMsg
  35497. res.Cainfo = resEleven10265.Cainfo
  35498. res.WarnMsg = resEleven10265.WarnMsg
  35499. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35500. res.Infcode = infocode
  35501. } else {
  35502. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35503. utils.ErrorLog("解析失败:%v", err)
  35504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35505. return
  35506. }
  35507. }
  35508. }
  35509. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35510. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35511. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35512. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35513. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35514. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35515. var doctor_name string
  35516. if roles.ID == 0 {
  35517. doctor_name = "管理员"
  35518. } else {
  35519. doctor_name = roles.UserName
  35520. }
  35521. yiliao_leibie := ""
  35522. switch order.MedType {
  35523. case "11":
  35524. yiliao_leibie = "普通门诊"
  35525. break
  35526. case "12":
  35527. yiliao_leibie = "门诊挂号"
  35528. break
  35529. case "13":
  35530. yiliao_leibie = "急诊"
  35531. break
  35532. case "14":
  35533. yiliao_leibie = "门诊特殊病"
  35534. break
  35535. case "15":
  35536. yiliao_leibie = "门诊统筹"
  35537. break
  35538. case "16":
  35539. yiliao_leibie = "门诊慢性病"
  35540. break
  35541. case "21":
  35542. yiliao_leibie = "普通住院"
  35543. break
  35544. }
  35545. //var rf []CustomFundPay
  35546. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35547. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35548. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35549. if res.Infcode == 0 {
  35550. 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 {
  35551. c.ServeSuccessJSON(map[string]interface{}{
  35552. "diagnosis": name,
  35553. "order_infos": orderInfos,
  35554. "number": order.MdtrtId,
  35555. "date": order.SettleAccountsDate,
  35556. "charge_admin": charge_admin,
  35557. "printor_admin": printor_admin,
  35558. "info": res.Output.Setlinfo,
  35559. "order": order,
  35560. "bedCostTotal": bedCostTotal,
  35561. "bedCostSelfTotal": bedCostSelfTotal,
  35562. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35563. "bedSelfTotal": bedSelfTotal,
  35564. "bedInscpTotal": bedInscpTotal,
  35565. "operationCostTotal": operationCostTotal,
  35566. "operationCostSelfTotal": operationCostSelfTotal,
  35567. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35568. "operationSelfTotal": operationSelfTotal,
  35569. "operationInscpTotal": operationInscpTotal,
  35570. "otherCostTotal": otherCostTotal,
  35571. "otherCostSelfTotal": otherCostSelfTotal,
  35572. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35573. "otherSelfTotal": otherSelfTotal,
  35574. "otherInscpTotal": otherInscpTotal,
  35575. "materialCostTotal": materialCostTotal,
  35576. "materialCostSelfTotal": materialCostSelfTotal,
  35577. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35578. "materialSelfTotal": materialSelfTotal,
  35579. "materialInscpTotal": materialInscpTotal,
  35580. "westernMedicineCostTotal": westernMedicineCostTotal,
  35581. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35582. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35583. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35584. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35585. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35586. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35587. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35588. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35589. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35590. "checkCostTotal": checkCostTotal,
  35591. "checkCostSelfTotal": checkCostSelfTotal,
  35592. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35593. "checkSelfTotal": checkSelfTotal,
  35594. "checkInscpTotal": checkInscpTotal,
  35595. "laboratoryCostTotal": laboratoryCostTotal,
  35596. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35597. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35598. "laboratorySelfTotal": laboratorySelfTotal,
  35599. "laboratoryInscpTotal": laboratoryInscpTotal,
  35600. "treatCostTotal": treatCostTotal,
  35601. "treatCostSelfTotal": treatCostSelfTotal,
  35602. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35603. "treatSelfTotal": treatSelfTotal,
  35604. "treatInscpTotal": treatInscpTotal,
  35605. "doctor_info": doctor_info,
  35606. "doctor_code": adminRole_two.DoctorCode,
  35607. "doctor_name": doctor_name,
  35608. "health_card_no": order.PsnNo,
  35609. "department": departments.Name,
  35610. "yiliao_leibie": yiliao_leibie,
  35611. "after_money": order.AccountPrice,
  35612. "patient": patient,
  35613. "org_name": miConfig.OrgName,
  35614. "org_code": miConfig.Code,
  35615. "order_number": order.Number,
  35616. "his_hospital": his_hospital,
  35617. "his": his,
  35618. "dia_config": dia_config,
  35619. "psn_cash_pay": order.PsnCashPay,
  35620. "zcCostTotal": zcCostTotal,
  35621. "zcCostSelfTotal": zcCostSelfTotal,
  35622. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35623. "zcSelfTotal": zcSelfTotal,
  35624. "zcInscpTotal": zcInscpTotal,
  35625. "huliCostTotal": huliCostTotal,
  35626. "huliCostSelfTotal": huliCostSelfTotal,
  35627. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35628. "huliSelfTotal": huliSelfTotal,
  35629. "huliInscpTotal": huliInscpTotal,
  35630. //"funds": rf,
  35631. //"check_order_info": cus_slice,
  35632. })
  35633. } else {
  35634. c.ServeSuccessJSON(map[string]interface{}{
  35635. "diagnosis": name,
  35636. "order_infos": orderInfos,
  35637. "number": order.MdtrtId,
  35638. "date": order.SettleAccountsDate,
  35639. "charge_admin": charge_admin,
  35640. "printor_admin": printor_admin,
  35641. "info": order,
  35642. "order": order,
  35643. "bedCostTotal": bedCostTotal,
  35644. "bedCostSelfTotal": bedCostSelfTotal,
  35645. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35646. "bedSelfTotal": bedSelfTotal,
  35647. "bedInscpTotal": bedInscpTotal,
  35648. "operationCostTotal": operationCostTotal,
  35649. "operationCostSelfTotal": operationCostSelfTotal,
  35650. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35651. "operationSelfTotal": operationSelfTotal,
  35652. "operationInscpTotal": operationInscpTotal,
  35653. "otherCostTotal": otherCostTotal,
  35654. "otherCostSelfTotal": otherCostSelfTotal,
  35655. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35656. "otherSelfTotal": otherSelfTotal,
  35657. "otherInscpTotal": otherInscpTotal,
  35658. "materialCostTotal": materialCostTotal,
  35659. "materialCostSelfTotal": materialCostSelfTotal,
  35660. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35661. "materialSelfTotal": materialSelfTotal,
  35662. "materialInscpTotal": materialInscpTotal,
  35663. "westernMedicineCostTotal": westernMedicineCostTotal,
  35664. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35665. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35666. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35667. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35668. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35669. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35670. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35671. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35672. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35673. "checkCostTotal": checkCostTotal,
  35674. "checkCostSelfTotal": checkCostSelfTotal,
  35675. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35676. "checkSelfTotal": checkSelfTotal,
  35677. "checkInscpTotal": checkInscpTotal,
  35678. "laboratoryCostTotal": laboratoryCostTotal,
  35679. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35680. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35681. "laboratorySelfTotal": laboratorySelfTotal,
  35682. "laboratoryInscpTotal": laboratoryInscpTotal,
  35683. "treatCostTotal": treatCostTotal,
  35684. "treatCostSelfTotal": treatCostSelfTotal,
  35685. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35686. "treatSelfTotal": treatSelfTotal,
  35687. "treatInscpTotal": treatInscpTotal,
  35688. "doctor_info": doctor_info,
  35689. "doctor_code": adminRole_two.DoctorCode,
  35690. "doctor_name": doctor_name,
  35691. "health_card_no": order.PsnNo,
  35692. "department": departments.Name,
  35693. "yiliao_leibie": yiliao_leibie,
  35694. "after_money": order.AccountPrice,
  35695. "patient": patient,
  35696. "org_name": miConfig.OrgName,
  35697. "org_code": miConfig.Code,
  35698. "order_number": order.Number,
  35699. "his_hospital": his_hospital,
  35700. "his": his,
  35701. "dia_config": dia_config,
  35702. "psn_cash_pay": order.PsnCashPay,
  35703. "zcCostTotal": zcCostTotal,
  35704. "zcCostSelfTotal": zcCostSelfTotal,
  35705. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35706. "zcSelfTotal": zcSelfTotal,
  35707. "zcInscpTotal": zcInscpTotal,
  35708. "huliCostTotal": huliCostTotal,
  35709. "huliCostSelfTotal": huliCostSelfTotal,
  35710. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35711. "huliSelfTotal": huliSelfTotal,
  35712. "huliInscpTotal": huliInscpTotal,
  35713. //"funds": rf,
  35714. //"check_order_info": cus_slice,
  35715. })
  35716. }
  35717. }
  35718. }
  35719. }
  35720. //func (c *HisApiController) CheckTreatment() {
  35721. // patient_id, _ := c.GetInt64("patient_id")
  35722. // id_card_no := c.GetString("id_card_no")
  35723. // insutype := c.GetString("insutype")
  35724. // med_type := c.GetString("med_type")
  35725. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35726. //
  35727. // adminUser := c.GetAdminUserInfo()
  35728. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35729. //
  35730. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35731. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35732. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35733. //
  35734. // if miConfig.MdtrtareaAdmvs == "421300" {
  35735. // var res ResultTwo
  35736. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35737. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35738. // "&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)
  35739. // resp, requestErr := http.Get(api)
  35740. // if requestErr != nil {
  35741. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35742. // return
  35743. // }
  35744. //
  35745. // body, ioErr := ioutil.ReadAll(resp.Body)
  35746. // if ioErr != nil {
  35747. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35748. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35749. // return
  35750. // }
  35751. // var respJSON map[string]interface{}
  35752. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35753. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35755. // return
  35756. // }
  35757. //
  35758. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35759. // result, _ := json.Marshal(respJSON)
  35760. //
  35761. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35762. // utils.ErrorLog("解析失败:%v", err)
  35763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35764. // return
  35765. // }
  35766. //
  35767. // if res.Infcode == 0 {
  35768. //
  35769. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35770. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35771. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35772. // resp, requestErr := http.Get(api)
  35773. // if requestErr != nil {
  35774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35775. // return
  35776. // }
  35777. //
  35778. // body, ioErr := ioutil.ReadAll(resp.Body)
  35779. // if ioErr != nil {
  35780. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35782. // return
  35783. // }
  35784. // var respJSON map[string]interface{}
  35785. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35786. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35788. // return
  35789. // }
  35790. // var res Result2001
  35791. //
  35792. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35793. // result2, _ := json.Marshal(respJSON)
  35794. //
  35795. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35796. // utils.ErrorLog("解析失败:%v", err)
  35797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35798. // return
  35799. // }
  35800. //
  35801. // if res.Infcode == 0 {
  35802. // c.ServeSuccessJSON(map[string]interface{}{
  35803. // "msg": res.Output.Trtinfo,
  35804. // })
  35805. // }
  35806. //
  35807. // } else {
  35808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35809. // return
  35810. // }
  35811. //
  35812. // } else {
  35813. //
  35814. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35815. // var dat map[string]interface{}
  35816. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35817. // fmt.Println(dat)
  35818. // } else {
  35819. // fmt.Println(err)
  35820. // }
  35821. // userJSONBytes, _ := json.Marshal(dat)
  35822. // var res ResultTwo
  35823. // var res10265 ResultTwo10265
  35824. // if miConfig.Code == "H15049901371" {
  35825. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35826. // utils.ErrorLog("解析失败:%v", err)
  35827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35828. // return
  35829. // }
  35830. // res.ErrMsg = res10265.ErrMsg
  35831. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35832. // res.Infcode = infocode
  35833. // res.Output = res10265.Output
  35834. // res.InfRefmsgid = res10265.InfRefmsgid
  35835. // } else {
  35836. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35837. // utils.ErrorLog("解析失败:%v", err)
  35838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35839. // return
  35840. // }
  35841. // }
  35842. //
  35843. // var user_name string
  35844. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35845. // if role.ID == 0 {
  35846. // user_name = "xxx"
  35847. // } else {
  35848. // user_name = role.UserName
  35849. // }
  35850. //
  35851. // baseParams := models.BaseParams{
  35852. // SecretKey: miConfig.SecretKey,
  35853. // FixmedinsCode: miConfig.Code,
  35854. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35855. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35856. // OrgName: miConfig.OrgName,
  35857. // Doctor: user_name,
  35858. // }
  35859. //
  35860. // if config.IsOpen == 1 {
  35861. // if miConfig.Code == "H15049901371" {
  35862. // if med_type == "14" {
  35863. // if insutype == "390" {
  35864. // med_type = "9933"
  35865. // } else if insutype == "310" {
  35866. // med_type = "990502"
  35867. // }
  35868. // } else if med_type == "11" {
  35869. // med_type = "11"
  35870. // }
  35871. // }
  35872. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35873. // var dat map[string]interface{}
  35874. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35875. // fmt.Println(dat)
  35876. // } else {
  35877. // fmt.Println(err)
  35878. // }
  35879. // var res Result2001
  35880. // var res10265 Result2001Org10265
  35881. // if miConfig.Code == "H15049901371" {
  35882. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35883. // utils.ErrorLog("解析失败:%v", err)
  35884. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35885. // return
  35886. // }
  35887. // res.ErrMsg = res10265.ErrMsg
  35888. // res.Output = res10265.Output
  35889. // res.InfRefmsgid = res10265.InfRefmsgid
  35890. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35891. // res.Infcode = infocode
  35892. // } else {
  35893. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35894. // utils.ErrorLog("解析失败:%v", err)
  35895. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35896. // return
  35897. // }
  35898. // }
  35899. // if res.Infcode == 0 {
  35900. // c.ServeSuccessJSON(map[string]interface{}{
  35901. // "msg": res.Output.Trtinfo,
  35902. // })
  35903. // }
  35904. // }
  35905. // }
  35906. //}
  35907. //func (c *HisApiController) PutRecord() {
  35908. // id, _ := c.GetInt64("id")
  35909. // record_time := c.GetString("record_time")
  35910. // timeLayout := "2006-01-02"
  35911. // loc, _ := time.LoadLocation("Local")
  35912. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35913. // if err != nil {
  35914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35915. // return
  35916. // }
  35917. // recordDateTime := theTime.Unix()
  35918. //
  35919. // adminInfo := c.GetAdminUserInfo()
  35920. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35921. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35922. //
  35923. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35924. //
  35925. // fmt.Println(miConfig.SecretKey)
  35926. //
  35927. // if patient == nil {
  35928. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35929. // return
  35930. // }
  35931. // if len(patient.IdCardNo) == 0 {
  35932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35933. // return
  35934. // }
  35935. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35936. // if config.IsOpen == 1 {
  35937. // 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
  35938. // resp, requestErr := http.Get(api)
  35939. // if requestErr != nil {
  35940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35941. // return
  35942. // }
  35943. // defer resp.Body.Close()
  35944. // body, ioErr := ioutil.ReadAll(resp.Body)
  35945. // if ioErr != nil {
  35946. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35948. // return
  35949. // }
  35950. // var respJSON map[string]interface{}
  35951. //
  35952. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35953. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35954. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35955. // return
  35956. // }
  35957. //
  35958. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35959. // userJSONBytes, _ := json.Marshal(userJSON)
  35960. // var res ResultTwo
  35961. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35962. // utils.ErrorLog("解析失败:%v", err)
  35963. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35964. // return
  35965. // }
  35966. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35967. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35968. // infoStr := string(Iinfos)
  35969. // idetinfoStr := string(Idetinfos)
  35970. //
  35971. // if res.Infcode == 0 {
  35972. // his := models.VMHisPatient{
  35973. // Status: 1,
  35974. // Ctime: time.Now().Unix(),
  35975. // Mtime: time.Now().Unix(),
  35976. // PsnNo: res.Output.Baseinfo.PsnNo,
  35977. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35978. // Certno: res.Output.Baseinfo.Certno,
  35979. // PsnName: res.Output.Baseinfo.PsnName,
  35980. // Gend: res.Output.Baseinfo.Gend,
  35981. // Naty: res.Output.Baseinfo.Naty,
  35982. // Brdy: res.Output.Baseinfo.Brdy,
  35983. // Age: res.Output.Baseinfo.Age,
  35984. // Iinfo: infoStr,
  35985. // Idetinfo: idetinfoStr,
  35986. // PatientId: patient.ID,
  35987. // RecordDate: theTime.Unix(),
  35988. // UserOrgId: adminInfo.CurrentOrgId,
  35989. // AdminUserId: adminInfo.AdminUser.Id,
  35990. // IsReturn: 1,
  35991. // }
  35992. //
  35993. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35994. // //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")
  35995. // //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")
  35996. //
  35997. // //var dat map[string]interface{}
  35998. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35999. // // fmt.Println(dat)
  36000. // //} else {
  36001. // // fmt.Println(err)
  36002. // //}
  36003. //
  36004. // var dat2 map[string]interface{}
  36005. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36006. // fmt.Println(dat2)
  36007. // } else {
  36008. // fmt.Println(err)
  36009. // }
  36010. //
  36011. // } else {
  36012. // adminUser := c.GetAdminUserInfo()
  36013. // errlog := &models.HisOrderError{
  36014. // UserOrgId: adminUser.CurrentOrgId,
  36015. // Ctime: time.Now().Unix(),
  36016. // Mtime: time.Now().Unix(),
  36017. // ErrMsg: res.ErrMsg,
  36018. // Status: 1,
  36019. // PatientId: id,
  36020. // RecordTime: recordDateTime,
  36021. // Stage: 1,
  36022. // }
  36023. // service.CreateErrMsgLog(errlog)
  36024. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  36025. // return
  36026. // }
  36027. // }
  36028. //
  36029. //}
  36030. //func (c *HisApiController) GetUploadDiag() {
  36031. // id, _ := c.GetInt64("id")
  36032. // record_time := c.GetString("record_time")
  36033. //
  36034. // diagnosis_id, _ := c.GetInt64("diagnosis")
  36035. // sick_type, _ := c.GetInt64("sick_type")
  36036. // reg_type, _ := c.GetInt64("reg_type")
  36037. //
  36038. // timeLayout := "2006-01-02"
  36039. // loc, _ := time.LoadLocation("Local")
  36040. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36041. // if err != nil {
  36042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36043. // return
  36044. // }
  36045. //
  36046. // var patientPrescription models.HisPrescriptionInfo
  36047. // recordDateTime := theTime.Unix()
  36048. // adminInfo := c.GetAdminUserInfo()
  36049. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36050. //
  36051. // if patientPrescription.ID == 0 {
  36052. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36053. // }
  36054. //
  36055. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  36056. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  36057. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36058. // sickConfig, _ := service.FindSickById(sick_type)
  36059. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36060. //
  36061. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  36062. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  36063. // "&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 +
  36064. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  36065. // resp2, requestErr2 := http.Get(api2)
  36066. // if requestErr2 != nil {
  36067. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36068. // return
  36069. // }
  36070. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  36071. // if ioErr2 != nil {
  36072. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  36073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36074. // return
  36075. // }
  36076. // var respJSON2 map[string]interface{}
  36077. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  36078. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36080. // return
  36081. // }
  36082. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36083. // userJSONBytes2, _ := json.Marshal(respJSON2)
  36084. //
  36085. // var res2 ResultSix
  36086. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36087. // utils.ErrorLog("解析失败:%v", err)
  36088. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36089. // return
  36090. // }
  36091. // if res2.Infcode != 0 {
  36092. // adminUser := c.GetAdminUserInfo()
  36093. // errlog := &models.HisOrderError{
  36094. // UserOrgId: adminUser.CurrentOrgId,
  36095. // Ctime: time.Now().Unix(),
  36096. // Mtime: time.Now().Unix(),
  36097. // ErrMsg: res2.ErrMsg,
  36098. // Status: 1,
  36099. // PatientId: id,
  36100. // RecordTime: recordDateTime,
  36101. // Stage: 3,
  36102. // }
  36103. // service.CreateErrMsgLog(errlog)
  36104. //
  36105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  36106. // return
  36107. // }
  36108. //
  36109. // c.ServeSuccessJSON(map[string]interface{}{
  36110. // "msg": "上传成功",
  36111. // })
  36112. //
  36113. //}
  36114. type QueryResult struct {
  36115. ID int64
  36116. Name string
  36117. Code string
  36118. List_type_code string
  36119. }
  36120. func (c *HisApiController) GetCheckCode() {
  36121. ids_str := c.GetString("ids")
  36122. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36123. ids_arr := strings.Split(ids_str, ",")
  36124. var queryResult []QueryResult
  36125. ids := make([]int64, 0)
  36126. for _, item := range ids_arr {
  36127. id, _ := strconv.ParseInt(item, 10, 64)
  36128. ids = append(ids, id)
  36129. }
  36130. if record_type == 1 {
  36131. drugs, _ := service.GetBatchDrugList(ids)
  36132. for _, item := range drugs {
  36133. result := QueryResult{
  36134. ID: item.ID,
  36135. Name: item.DrugName,
  36136. Code: item.MedicalInsuranceNumber,
  36137. List_type_code: "101",
  36138. }
  36139. queryResult = append(queryResult, result)
  36140. }
  36141. } else if record_type == 2 {
  36142. goods, _ := service.GetBatchGoodInformationList(ids)
  36143. fmt.Println(goods)
  36144. for _, item := range goods {
  36145. result := QueryResult{
  36146. ID: item.ID,
  36147. Name: item.GoodName,
  36148. Code: item.SocialSecurityDirectoryCode,
  36149. List_type_code: "301",
  36150. }
  36151. queryResult = append(queryResult, result)
  36152. }
  36153. } else if record_type == 3 {
  36154. projects, _ := service.GetBathchMyPorjecgList(ids)
  36155. for _, item := range projects {
  36156. result := QueryResult{
  36157. ID: item.ID,
  36158. Name: item.ProjectName,
  36159. Code: item.MedicalCode,
  36160. List_type_code: "201",
  36161. }
  36162. queryResult = append(queryResult, result)
  36163. }
  36164. }
  36165. admin_user_id, _ := c.GetInt64("admin_user_id")
  36166. adminUser := c.GetAdminUserInfo()
  36167. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36168. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36169. var user_name string
  36170. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36171. if role.ID == 0 {
  36172. user_name = "管理员"
  36173. } else {
  36174. user_name = role.UserName
  36175. }
  36176. baseParams := models.BaseParams{
  36177. SecretKey: miConfig.SecretKey,
  36178. FixmedinsCode: miConfig.Code,
  36179. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36180. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36181. OrgName: miConfig.OrgName,
  36182. Doctor: user_name,
  36183. }
  36184. var result string
  36185. if miConfig.MdtrtareaAdmvs == "430800" {
  36186. for _, item := range queryResult {
  36187. if record_type == 1 {
  36188. 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)
  36189. } else if record_type == 2 {
  36190. fmt.Println(item.Code)
  36191. 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)
  36192. } else if record_type == 3 {
  36193. 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)
  36194. }
  36195. var dat map[string]interface{}
  36196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36197. fmt.Println(dat)
  36198. } else {
  36199. fmt.Println(err)
  36200. }
  36201. userJSONBytes, _ := json.Marshal(dat)
  36202. var res ResultSix
  36203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36204. utils.ErrorLog("解析失败:%v", err)
  36205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36206. return
  36207. }
  36208. if res.Infcode == 0 {
  36209. if record_type == 1 {
  36210. service.UpdateBaseDrugById(item.ID)
  36211. } else if record_type == 2 {
  36212. service.UpdateGoodInformaitonByDetail(item.ID)
  36213. } else if record_type == 3 {
  36214. service.UpdateProjectById(item.ID)
  36215. }
  36216. c.ServeSuccessJSON(map[string]interface{}{
  36217. "failed_code": 0,
  36218. "msg": "目录对照成功",
  36219. })
  36220. } else {
  36221. c.ServeSuccessJSON(map[string]interface{}{
  36222. "failed_code": -10,
  36223. "msg": res.ErrMsg,
  36224. })
  36225. }
  36226. }
  36227. } else {
  36228. for _, item := range queryResult {
  36229. var result string
  36230. if record_type == 1 {
  36231. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36232. } else if record_type == 2 {
  36233. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36234. } else if record_type == 3 {
  36235. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36236. }
  36237. var dat map[string]interface{}
  36238. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36239. fmt.Println(dat)
  36240. } else {
  36241. fmt.Println(err)
  36242. }
  36243. userJSONBytes, _ := json.Marshal(dat)
  36244. var res ResultSix
  36245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36246. utils.ErrorLog("解析失败:%v", err)
  36247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36248. return
  36249. }
  36250. if res.Infcode == 0 {
  36251. if record_type == 1 {
  36252. service.UpdateBaseDrugById(item.ID)
  36253. } else if record_type == 2 {
  36254. service.UpdateGoodInformaitonByDetail(item.ID)
  36255. } else if record_type == 3 {
  36256. service.UpdateProjectById(item.ID)
  36257. }
  36258. c.ServeSuccessJSON(map[string]interface{}{
  36259. "failed_code": 0,
  36260. "msg": "目录对照成功",
  36261. })
  36262. } else {
  36263. c.ServeSuccessJSON(map[string]interface{}{
  36264. "failed_code": -10,
  36265. "msg": res.ErrMsg,
  36266. })
  36267. }
  36268. }
  36269. }
  36270. }
  36271. func (c *HisApiController) UnCheckCode() {
  36272. ids_str := c.GetString("ids")
  36273. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36274. admin_user_id, _ := c.GetInt64("admin_user_id")
  36275. ids_arr := strings.Split(ids_str, ",")
  36276. var queryResult []QueryResult
  36277. ids := make([]int64, 0)
  36278. for _, item := range ids_arr {
  36279. id, _ := strconv.ParseInt(item, 10, 64)
  36280. ids = append(ids, id)
  36281. }
  36282. if record_type == 1 {
  36283. drugs, _ := service.GetBatchDrugList(ids)
  36284. for _, item := range drugs {
  36285. result := QueryResult{
  36286. ID: item.ID,
  36287. Name: item.DrugName,
  36288. Code: item.MedicalInsuranceNumber,
  36289. List_type_code: "101",
  36290. }
  36291. queryResult = append(queryResult, result)
  36292. }
  36293. } else if record_type == 2 {
  36294. goods, _ := service.GetBatchGoodInformationList(ids)
  36295. for _, item := range goods {
  36296. result := QueryResult{
  36297. ID: item.ID,
  36298. Name: item.GoodName,
  36299. Code: item.SocialSecurityDirectoryCode,
  36300. List_type_code: "301",
  36301. }
  36302. queryResult = append(queryResult, result)
  36303. }
  36304. } else if record_type == 3 {
  36305. projects, _ := service.GetBathchMyPorjecgList(ids)
  36306. for _, item := range projects {
  36307. result := QueryResult{
  36308. ID: item.ID,
  36309. Name: item.ProjectName,
  36310. Code: item.MedicalCode,
  36311. List_type_code: "201",
  36312. }
  36313. queryResult = append(queryResult, result)
  36314. }
  36315. }
  36316. adminUser := c.GetAdminUserInfo()
  36317. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36318. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36319. var user_name string
  36320. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36321. if role.ID == 0 {
  36322. user_name = "xxx"
  36323. } else {
  36324. user_name = role.UserName
  36325. }
  36326. baseParams := &models.BaseParams{
  36327. SecretKey: miConfig.SecretKey,
  36328. FixmedinsCode: miConfig.Code,
  36329. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36330. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36331. OrgName: miConfig.OrgName,
  36332. Doctor: user_name,
  36333. }
  36334. if config.IsOpen == 1 {
  36335. if miConfig.MdtrtareaAdmvs == "430800" {
  36336. for _, item := range queryResult {
  36337. var result string
  36338. if record_type == 1 {
  36339. 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)
  36340. } else if record_type == 2 {
  36341. fmt.Println(item.Code)
  36342. 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)
  36343. } else if record_type == 3 {
  36344. 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)
  36345. }
  36346. var dat map[string]interface{}
  36347. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36348. fmt.Println(dat)
  36349. } else {
  36350. fmt.Println(err)
  36351. }
  36352. userJSONBytes, _ := json.Marshal(dat)
  36353. var res ResultSix
  36354. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36355. utils.ErrorLog("解析失败:%v", err)
  36356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36357. return
  36358. }
  36359. if res.Infcode == 0 {
  36360. if record_type == 1 {
  36361. service.UpdateBaseDrugById(item.ID)
  36362. } else if record_type == 2 {
  36363. service.UpdateGoodInformaitonByDetail(item.ID)
  36364. } else if record_type == 3 {
  36365. service.UpdateProjectById(item.ID)
  36366. }
  36367. c.ServeSuccessJSON(map[string]interface{}{
  36368. "failed_code": 0,
  36369. "msg": "目录对照成功",
  36370. })
  36371. } else {
  36372. c.ServeSuccessJSON(map[string]interface{}{
  36373. "failed_code": -10,
  36374. "msg": res.ErrMsg,
  36375. })
  36376. }
  36377. }
  36378. } else {
  36379. for _, item := range queryResult {
  36380. var result string
  36381. if record_type == 1 {
  36382. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36383. } else if record_type == 2 {
  36384. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36385. } else if record_type == 3 {
  36386. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36387. }
  36388. var dat2 map[string]interface{}
  36389. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36390. fmt.Println(dat2)
  36391. } else {
  36392. fmt.Println(err)
  36393. }
  36394. userJSONBytes, _ := json.Marshal(dat2)
  36395. var res ResultSix
  36396. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36397. utils.ErrorLog("解析失败:%v", err)
  36398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36399. return
  36400. }
  36401. if res.Infcode == 0 {
  36402. if record_type == 1 {
  36403. service.UpdateDrugByIdDetail(item.ID)
  36404. } else if record_type == 2 {
  36405. service.UpdateGoodInfoById(item.ID)
  36406. } else if record_type == 3 {
  36407. service.UpdateMyProjectById(item.ID)
  36408. }
  36409. c.ServeSuccessJSON(map[string]interface{}{
  36410. "failed_code": 0,
  36411. "msg": "撤销目录对照成功",
  36412. })
  36413. } else {
  36414. c.ServeSuccessJSON(map[string]interface{}{
  36415. "failed_code": -10,
  36416. "msg": res.ErrMsg,
  36417. })
  36418. }
  36419. }
  36420. }
  36421. }
  36422. }
  36423. func (c *HisApiController) GetPatientInfo() {
  36424. id_card_no := c.GetString("id_card_no")
  36425. admin_user_id, _ := c.GetInt64("admin_user_id")
  36426. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36427. if patient.ID == 0 {
  36428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36429. return
  36430. }
  36431. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36432. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36433. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36434. var res ResultTwo
  36435. var res10265 ResultTwo10265
  36436. if config.IsOpen == 1 {
  36437. if miConfig.MdtrtareaAdmvs == "150499" {
  36438. //请求内网数据
  36439. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36440. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36441. "&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
  36442. resp, requestErr := http.Get(api)
  36443. if requestErr != nil {
  36444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36445. return
  36446. }
  36447. body, ioErr := ioutil.ReadAll(resp.Body)
  36448. if ioErr != nil {
  36449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36451. return
  36452. }
  36453. var respJSON map[string]interface{}
  36454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36457. return
  36458. }
  36459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36460. result_byte, _ := json.Marshal(respJSON)
  36461. result := string(result_byte)
  36462. var dat map[string]interface{}
  36463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36464. fmt.Println(dat)
  36465. } else {
  36466. fmt.Println(err)
  36467. }
  36468. userJSONBytes, _ := json.Marshal(dat)
  36469. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36470. utils.ErrorLog("解析失败:%v", err)
  36471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36472. return
  36473. }
  36474. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36475. res.Infcode = Infcode
  36476. res.ErrMsg = res10265.ErrMsg
  36477. res.Output = res10265.Output
  36478. res.InfRefmsgid = res10265.InfRefmsgid
  36479. res.RespondTime = res10265.RespondTime
  36480. res.WarnInfo = res10265.WarnInfo
  36481. } else {
  36482. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36483. var dat map[string]interface{}
  36484. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36485. fmt.Println(dat)
  36486. } else {
  36487. fmt.Println(err)
  36488. }
  36489. userJSONBytes, _ := json.Marshal(dat)
  36490. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36491. utils.ErrorLog("解析失败:%v", err)
  36492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36493. return
  36494. }
  36495. }
  36496. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36497. // utils.ErrorLog("解析失败:%v", err)
  36498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36499. // return
  36500. //}
  36501. for index, item := range res.Output.Iinfo {
  36502. if item.PsnInsuStas == "2" {
  36503. fmt.Println("--------")
  36504. res.Output.Iinfo[index].Insutype = "300"
  36505. res.Output.Iinfo[index].PsnInsuStas = "1"
  36506. }
  36507. }
  36508. fmt.Println(res.Output.Iinfo)
  36509. if res.Infcode != 0 {
  36510. c.ServeSuccessJSON(map[string]interface{}{
  36511. "failed_code": -10,
  36512. "msg": res.ErrMsg,
  36513. })
  36514. } else {
  36515. c.ServeSuccessJSON(map[string]interface{}{
  36516. "failed_code": 0,
  36517. "info": res,
  36518. })
  36519. }
  36520. }
  36521. }
  36522. func (c *HisApiController) PsnPutOnRecord() {
  36523. record_type, _ := c.GetInt64("type")
  36524. patient_id, _ := c.GetInt64("patient_id")
  36525. admin_user_id, _ := c.GetInt64("admin_user_id")
  36526. start_time := c.GetString("start_time")
  36527. end_time := c.GetString("end_time")
  36528. adminUser := c.GetAdminUserInfo()
  36529. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36530. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36531. var patients []*models.Patients
  36532. if record_type == 1 { //全部备案
  36533. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36534. patients = append(patients, patient...)
  36535. } else { //单个备案
  36536. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36537. patients = append(patients, patient)
  36538. }
  36539. var user_name string
  36540. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36541. if role.ID == 0 {
  36542. user_name = "xxx"
  36543. } else {
  36544. user_name = role.UserName
  36545. }
  36546. if config.IsOpen == 1 {
  36547. for _, item := range patients {
  36548. 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
  36549. resp, requestErr := http.Get(api)
  36550. if requestErr != nil {
  36551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36552. return
  36553. }
  36554. defer resp.Body.Close()
  36555. body, ioErr := ioutil.ReadAll(resp.Body)
  36556. if ioErr != nil {
  36557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36559. return
  36560. }
  36561. var respJSON map[string]interface{}
  36562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36565. return
  36566. }
  36567. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36568. userJSONBytes, _ := json.Marshal(userJSON)
  36569. var res ResultTwo
  36570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36571. utils.ErrorLog("解析失败:%v", err)
  36572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36573. return
  36574. }
  36575. if res.Infcode == 0 {
  36576. 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)
  36577. var dat map[string]interface{}
  36578. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36579. fmt.Println(dat)
  36580. } else {
  36581. fmt.Println(err)
  36582. }
  36583. userJSONBytes, _ := json.Marshal(dat)
  36584. var res2 ResultThirteen
  36585. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36586. utils.ErrorLog("解析失败:%v", err)
  36587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36588. return
  36589. }
  36590. if res2.Infcode == 0 {
  36591. psnResult := &models.GdybPsnRecord{
  36592. UserOrgId: adminUser.CurrentOrgId,
  36593. PatientId: item.ID,
  36594. PsnNo: res.Output.Baseinfo.PsnNo,
  36595. Ctime: time.Now().Unix(),
  36596. Mtime: time.Now().Unix(),
  36597. Status: 1,
  36598. IsCancel: 1,
  36599. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36600. }
  36601. service.CreatePsnRecord(psnResult)
  36602. } else {
  36603. c.ServeSuccessJSON(map[string]interface{}{
  36604. "failed_code": -10,
  36605. "msg": res2.ErrMsg,
  36606. })
  36607. return
  36608. }
  36609. }
  36610. }
  36611. }
  36612. }
  36613. func (c *HisApiController) PsnUnPutOnRecord() {
  36614. id, _ := c.GetInt64("id")
  36615. //record_type, _ := c.GetInt64("type")
  36616. admin_user_id, _ := c.GetInt64("admin_user_id")
  36617. adminUser := c.GetAdminUserInfo()
  36618. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36619. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36620. var user_name string
  36621. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36622. if role.ID == 0 {
  36623. user_name = "xxx"
  36624. } else {
  36625. user_name = role.UserName
  36626. }
  36627. psn_record, _ := service.GetPsnRecordById(id)
  36628. if psn_record.ID == 0 {
  36629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36630. return
  36631. }
  36632. if config.IsOpen == 1 {
  36633. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36634. var dat map[string]interface{}
  36635. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36636. fmt.Println(dat)
  36637. } else {
  36638. fmt.Println(err)
  36639. }
  36640. userJSONBytes, _ := json.Marshal(dat)
  36641. var res ResultFourteen
  36642. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36643. utils.ErrorLog("解析失败:%v", err)
  36644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36645. return
  36646. }
  36647. if res.Infcode == 0 {
  36648. psn_record.IsCancel = 2
  36649. service.CreatePsnRecord(&psn_record)
  36650. } else {
  36651. c.ServeSuccessJSON(map[string]interface{}{
  36652. "failed_code": -10,
  36653. "msg": res.ErrMsg,
  36654. })
  36655. return
  36656. }
  36657. }
  36658. }
  36659. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36660. patient_id, _ := c.GetInt64("patient_id")
  36661. insutype_two := c.GetString("insutype")
  36662. psn_no := c.GetString("psn_no")
  36663. doctor_id, _ := c.GetInt64("doctor_id")
  36664. sick_id, _ := c.GetInt64("sick_id")
  36665. department_id, _ := c.GetInt64("department_id")
  36666. start_time := c.GetString("start_time")
  36667. end_time := c.GetString("end_time")
  36668. check_time := c.GetString("check_time")
  36669. hospital_code := c.GetString("hospital_code")
  36670. hospital_name := c.GetString("hospital_name")
  36671. adminUser := c.GetAdminUserInfo()
  36672. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36673. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36674. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36675. sick, _ := service.FindSickById(sick_id)
  36676. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36677. if len(hospital_code) == 0 {
  36678. hospital_code = miConfig.Code
  36679. }
  36680. if len(hospital_name) == 0 {
  36681. hospital_name = miConfig.OrgName
  36682. }
  36683. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36684. var res ResultTwo
  36685. var res10265 ResultTwo10265
  36686. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36687. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36688. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36689. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36690. "&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
  36691. resp, requestErr := http.Get(api)
  36692. if requestErr != nil {
  36693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36694. return
  36695. }
  36696. body, ioErr := ioutil.ReadAll(resp.Body)
  36697. if ioErr != nil {
  36698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36700. return
  36701. }
  36702. var respJSON map[string]interface{}
  36703. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36706. return
  36707. }
  36708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36709. result, _ := json.Marshal(respJSON)
  36710. fmt.Println("log")
  36711. fmt.Println(string(result))
  36712. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36713. utils.ErrorLog("解析失败:%v", err)
  36714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36715. return
  36716. }
  36717. res.ErrMsg = res10265.ErrMsg
  36718. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36719. res.Infcode = infocode
  36720. res.Output = res10265.Output
  36721. res.InfRefmsgid = res10265.InfRefmsgid
  36722. } else {
  36723. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36724. if miConfig.Code == "H15049901371" {
  36725. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36726. utils.ErrorLog("解析失败:%v", err)
  36727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36728. return
  36729. }
  36730. res.ErrMsg = res10265.ErrMsg
  36731. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36732. res.Infcode = infocode
  36733. res.Output = res10265.Output
  36734. res.InfRefmsgid = res10265.InfRefmsgid
  36735. } else {
  36736. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36737. utils.ErrorLog("解析失败:%v", err)
  36738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36739. return
  36740. }
  36741. }
  36742. }
  36743. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36744. infoStr := string(Iinfos)
  36745. var rf []*ResultFive
  36746. json.Unmarshal([]byte(infoStr), &rf)
  36747. var insuplc_admdvs string
  36748. var insutype string
  36749. var is390 int = 0
  36750. var is310 int = 0
  36751. var insutypes []*ResultFive
  36752. for _, item := range rf {
  36753. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36754. insutypes = append(insutypes, item)
  36755. }
  36756. }
  36757. if len(insutypes) == 1 {
  36758. insutype = insutypes[0].Insutype
  36759. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36760. } else {
  36761. for _, i := range insutypes {
  36762. if i.Insutype == "390" {
  36763. is390 = 1
  36764. }
  36765. if i.Insutype == "310" {
  36766. is310 = 1
  36767. }
  36768. }
  36769. }
  36770. if is390 == 1 {
  36771. insutype = "390"
  36772. }
  36773. if is310 == 1 {
  36774. insutype = "310"
  36775. }
  36776. if len(insutypes) == 2 {
  36777. insutype = insutype_two
  36778. }
  36779. if len(insutypes) == 0 {
  36780. insutype = "310"
  36781. }
  36782. insutype = insutype_two
  36783. fmt.Println(insutype)
  36784. for _, item := range rf {
  36785. fmt.Println(item.Insutype)
  36786. fmt.Println(insutype)
  36787. if item.Insutype == insutype {
  36788. fmt.Println(item.Insutype)
  36789. fmt.Println(insutype)
  36790. insuplc_admdvs = item.InsuplcAdmdvs
  36791. }
  36792. }
  36793. fmt.Println(insuplc_admdvs)
  36794. var res2 ResultThirteen
  36795. var res10265_2 ResultThirteen10265
  36796. if config.IsOpen == 1 {
  36797. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36798. } else {
  36799. if miConfig.MdtrtareaAdmvs == "150499" {
  36800. //
  36801. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36802. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36803. // "&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
  36804. //resp, requestErr := http.Get(api)
  36805. //if requestErr != nil {
  36806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36807. // return
  36808. //}
  36809. //
  36810. //body, ioErr := ioutil.ReadAll(resp.Body)
  36811. //if ioErr != nil {
  36812. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36814. // return
  36815. //}
  36816. //var respJSON map[string]interface{}
  36817. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36818. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36820. // return
  36821. //}
  36822. //
  36823. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36824. //result, _ := json.Marshal(respJSON)
  36825. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36826. // utils.ErrorLog("解析失败:%v", err)
  36827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36828. // return
  36829. //}
  36830. //infocode = resThree.Infcode
  36831. //result, _ := json.Marshal(respJSON)
  36832. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36833. // utils.ErrorLog("解析失败:%v", err)
  36834. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36835. // return
  36836. //}
  36837. //
  36838. //resThree.ErrMsg = resThree10265.ErrMsg
  36839. //
  36840. //resThree.Output = resThree10265.Output
  36841. //
  36842. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36843. //
  36844. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36845. //
  36846. } else {
  36847. 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)
  36848. var dat map[string]interface{}
  36849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36850. fmt.Println(dat)
  36851. } else {
  36852. fmt.Println(err)
  36853. }
  36854. userJSONBytes, _ := json.Marshal(dat)
  36855. if miConfig.Code == "H15049901371" {
  36856. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36857. utils.ErrorLog("解析失败:%v", err)
  36858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36859. return
  36860. }
  36861. res2.ErrMsg = res10265_2.ErrMsg
  36862. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36863. res2.Infcode = infocode
  36864. res2.Output = res10265_2.Output
  36865. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36866. } else {
  36867. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36868. utils.ErrorLog("解析失败:%v", err)
  36869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36870. return
  36871. }
  36872. }
  36873. }
  36874. }
  36875. if res2.Infcode == 0 {
  36876. psnResult := &models.GdybPsnNcdsRecord{
  36877. UserOrgId: adminUser.CurrentOrgId,
  36878. PatientId: patient.ID,
  36879. PsnNo: psn_no,
  36880. DoctorId: doctor.AdminUserId,
  36881. DepartmentId: department_id,
  36882. SickType: sick_id,
  36883. Insutype: insutype,
  36884. Ctime: time.Now().Unix(),
  36885. Mtime: time.Now().Unix(),
  36886. Status: 1,
  36887. IsCancel: 1,
  36888. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36889. }
  36890. service.CreatePsnNCDSRecord(psnResult)
  36891. c.ServeSuccessJSON(map[string]interface{}{
  36892. "failed_code": 0,
  36893. "msg": "备案成功",
  36894. "result": psnResult,
  36895. })
  36896. } else {
  36897. c.ServeSuccessJSON(map[string]interface{}{
  36898. "failed_code": -10,
  36899. "msg": res2.ErrMsg,
  36900. })
  36901. return
  36902. }
  36903. }
  36904. }
  36905. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36906. id, _ := c.GetInt64("id")
  36907. admin_user_id, _ := c.GetInt64("admin_user_id")
  36908. adminUser := c.GetAdminUserInfo()
  36909. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36910. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36911. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36912. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36913. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36914. //var user_name string
  36915. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36916. //if role.ID == 0 {
  36917. // user_name = "xxx"
  36918. //} else {
  36919. // user_name = role.UserName
  36920. //}
  36921. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36922. if psn_record.ID == 0 {
  36923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36924. return
  36925. }
  36926. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36927. var res ResultTwo
  36928. var res10265 ResultTwo10265
  36929. if miConfig.Code == "H15049901371" {
  36930. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36931. utils.ErrorLog("解析失败:%v", err)
  36932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36933. return
  36934. }
  36935. res.ErrMsg = res10265.ErrMsg
  36936. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36937. res.Infcode = infocode
  36938. res.Output = res10265.Output
  36939. res.InfRefmsgid = res10265.InfRefmsgid
  36940. } else {
  36941. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36942. utils.ErrorLog("解析失败:%v", err)
  36943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36944. return
  36945. }
  36946. }
  36947. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36948. infoStr := string(Iinfos)
  36949. var rf []*ResultFive
  36950. json.Unmarshal([]byte(infoStr), &rf)
  36951. var insuplc_admdvs string
  36952. var insutype string
  36953. var is390 int = 0
  36954. var is310 int = 0
  36955. var insutypes []*ResultFive
  36956. for _, item := range rf {
  36957. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36958. insutypes = append(insutypes, item)
  36959. }
  36960. }
  36961. if len(insutypes) == 1 {
  36962. insutype = insutypes[0].Insutype
  36963. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36964. } else {
  36965. for _, i := range insutypes {
  36966. if i.Insutype == "390" {
  36967. is390 = 1
  36968. }
  36969. if i.Insutype == "310" {
  36970. is310 = 1
  36971. }
  36972. }
  36973. }
  36974. if is390 == 1 {
  36975. insutype = "390"
  36976. }
  36977. if is310 == 1 {
  36978. insutype = "310"
  36979. }
  36980. if len(insutypes) == 0 {
  36981. insutype = "310"
  36982. }
  36983. insutype = psn_record.Insutype
  36984. for _, item := range rf {
  36985. if item.Insutype == insutype {
  36986. insuplc_admdvs = item.InsuplcAdmdvs
  36987. }
  36988. }
  36989. if config.IsOpen == 1 {
  36990. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36991. var dat map[string]interface{}
  36992. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36993. fmt.Println(dat)
  36994. } else {
  36995. fmt.Println(err)
  36996. }
  36997. userJSONBytes, _ := json.Marshal(dat)
  36998. var res ResultFourteen
  36999. var res10265 ResultFourteen10265
  37000. if miConfig.Code == "H15049901371" {
  37001. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37002. utils.ErrorLog("解析失败:%v", err)
  37003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37004. return
  37005. }
  37006. res.ErrMsg = res10265.ErrMsg
  37007. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37008. res.Infcode = infocode
  37009. res.Output = res10265.Output
  37010. res.InfRefmsgid = res10265.InfRefmsgid
  37011. } else {
  37012. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37013. utils.ErrorLog("解析失败:%v", err)
  37014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37015. return
  37016. }
  37017. }
  37018. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37019. // utils.ErrorLog("解析失败:%v", err)
  37020. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37021. // return
  37022. //}
  37023. if res.Infcode == 0 {
  37024. psn_record.IsCancel = 2
  37025. service.CreatePsnNCDSRecord(&psn_record)
  37026. c.ServeSuccessJSON(map[string]interface{}{
  37027. "failed_code": 0,
  37028. "msg": "撤销备案成功",
  37029. })
  37030. } else {
  37031. c.ServeSuccessJSON(map[string]interface{}{
  37032. "failed_code": -10,
  37033. "msg": res.ErrMsg,
  37034. })
  37035. return
  37036. }
  37037. }
  37038. }
  37039. func (c *HisApiController) TestTest() {
  37040. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  37041. fmt.Println(patient.Iinfo)
  37042. }
  37043. type CustomData struct {
  37044. MsgId string
  37045. PsnNo string
  37046. Info string
  37047. }
  37048. func (c *HisApiController) ReversalData() {
  37049. var customData []*CustomData
  37050. custom := &CustomData{
  37051. MsgId: "H44022900158202103301714472004",
  37052. PsnNo: "44020000001101329945",
  37053. Info: "2207",
  37054. }
  37055. customData = append(customData, custom)
  37056. custom1 := &CustomData{
  37057. MsgId: "H4402290015820210330172057803",
  37058. PsnNo: "44020000001101161813",
  37059. Info: "2207",
  37060. }
  37061. customData = append(customData, custom1)
  37062. custom2 := &CustomData{
  37063. MsgId: "H44022900158202103301705198813",
  37064. PsnNo: "44190000133097375417",
  37065. Info: "2207",
  37066. }
  37067. customData = append(customData, custom2)
  37068. custom3 := &CustomData{
  37069. MsgId: "H44022900158202103301715524756",
  37070. PsnNo: "44020000001100187221",
  37071. Info: "2207",
  37072. }
  37073. customData = append(customData, custom3)
  37074. custom4 := &CustomData{
  37075. MsgId: "H44022900158202103301730376224",
  37076. PsnNo: "44020000001101959155",
  37077. Info: "2207",
  37078. }
  37079. customData = append(customData, custom4)
  37080. custom5 := &CustomData{
  37081. MsgId: "H44022900158202103301748008725",
  37082. PsnNo: "44020000001104246641",
  37083. Info: "2207",
  37084. }
  37085. customData = append(customData, custom5)
  37086. custom6 := &CustomData{
  37087. MsgId: "H44022900158202103301718096755",
  37088. PsnNo: "44020000001102211860",
  37089. Info: "2207",
  37090. }
  37091. customData = append(customData, custom6)
  37092. custom7 := &CustomData{
  37093. MsgId: "H44022900158202103301736551640",
  37094. PsnNo: "44020000001102687718",
  37095. Info: "2207",
  37096. }
  37097. customData = append(customData, custom7)
  37098. custom8 := &CustomData{
  37099. MsgId: "H44022900158202103301743097676",
  37100. PsnNo: "44020000001102127785",
  37101. Info: "2207",
  37102. }
  37103. customData = append(customData, custom8)
  37104. custom9 := &CustomData{
  37105. MsgId: "H44022900158202103301712304203",
  37106. PsnNo: "44020000001101518097",
  37107. Info: "2207",
  37108. }
  37109. customData = append(customData, custom9)
  37110. custom10 := &CustomData{
  37111. MsgId: "H44022900158202103301738448785",
  37112. PsnNo: "44020000001100500813",
  37113. Info: "2207",
  37114. }
  37115. customData = append(customData, custom10)
  37116. custom11 := &CustomData{
  37117. MsgId: "H44022900158202103301732455843",
  37118. PsnNo: "44020000001102690557",
  37119. Info: "2207",
  37120. }
  37121. customData = append(customData, custom11)
  37122. custom12 := &CustomData{
  37123. MsgId: "H44022900158202103301745421708",
  37124. PsnNo: "44020000001102211928",
  37125. Info: "2207",
  37126. }
  37127. customData = append(customData, custom12)
  37128. custom1212 := &CustomData{
  37129. MsgId: "H440229001582021033017351627",
  37130. PsnNo: "44020000001102481733",
  37131. Info: "2207",
  37132. }
  37133. customData = append(customData, custom1212)
  37134. custom13 := &CustomData{
  37135. MsgId: "H44022900158202103301740327951",
  37136. PsnNo: "44020000001103174866",
  37137. Info: "2207",
  37138. }
  37139. customData = append(customData, custom13)
  37140. custom14 := &CustomData{
  37141. MsgId: "H4402290015820210330174922668",
  37142. PsnNo: "44020000001102927272",
  37143. Info: "2207",
  37144. }
  37145. customData = append(customData, custom14)
  37146. custom15 := &CustomData{
  37147. MsgId: "H44022900158202103301752362273",
  37148. PsnNo: "44020000001102942890",
  37149. Info: "2207",
  37150. }
  37151. customData = append(customData, custom15)
  37152. custom16 := &CustomData{
  37153. MsgId: "H44022900158202103301751082917",
  37154. PsnNo: "44020000001101662162",
  37155. Info: "2207",
  37156. }
  37157. customData = append(customData, custom16)
  37158. custom17 := &CustomData{
  37159. MsgId: "H44022900158202103301754147728",
  37160. PsnNo: "44020000000229014511",
  37161. Info: "2207",
  37162. }
  37163. customData = append(customData, custom17)
  37164. adminUser := c.GetAdminUserInfo()
  37165. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37166. for _, item := range customData {
  37167. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37168. fmt.Println(result)
  37169. }
  37170. }
  37171. func (c *HisApiController) GetAllopatry() {
  37172. year := c.GetString("year")
  37173. month := c.GetString("month")
  37174. admin_user_id, _ := c.GetInt64("admin_user_id")
  37175. adminUser := c.GetAdminUserInfo()
  37176. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37177. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37178. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37179. var dat map[string]interface{}
  37180. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37181. fmt.Println(dat)
  37182. } else {
  37183. fmt.Println(err)
  37184. }
  37185. userJSONBytes, _ := json.Marshal(dat)
  37186. var res models.Result9001
  37187. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37188. utils.ErrorLog("解析失败:%v", err)
  37189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37190. return
  37191. }
  37192. fmt.Println(res.Output.Signinoutb)
  37193. fmt.Println(res.Output.Signinoutb.SignNo)
  37194. fmt.Println(string(userJSONBytes))
  37195. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37196. var dat3 map[string]interface{}
  37197. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  37198. fmt.Println(dat3)
  37199. } else {
  37200. fmt.Println(err)
  37201. }
  37202. userJSONBytes3, _ := json.Marshal(dat3)
  37203. var res3 models.Result3260
  37204. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  37205. utils.ErrorLog("解析失败:%v", err)
  37206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37207. return
  37208. }
  37209. var curpage int
  37210. var pagesize int = 100
  37211. var start int = 1
  37212. //var stop int
  37213. //pagecount := 10
  37214. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  37215. var res22 []models.Result3260
  37216. for curpage = 1; curpage <= pagecount; curpage++ {
  37217. if curpage == 1 {
  37218. start = 0
  37219. } else {
  37220. start = (curpage-1)*pagesize + 1
  37221. }
  37222. fmt.Println(start)
  37223. //stop = curpage * pagesize
  37224. //if stop > int(res3.Output.Totalrow) {
  37225. // stop =int(res3.Output.Totalrow)
  37226. //}
  37227. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  37228. var dat2 map[string]interface{}
  37229. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37230. fmt.Println(dat)
  37231. } else {
  37232. fmt.Println(err)
  37233. }
  37234. userJSONBytes2, _ := json.Marshal(dat2)
  37235. var res2 models.Result3260
  37236. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37237. utils.ErrorLog("解析失败:%v", err)
  37238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37239. return
  37240. }
  37241. if res2.Infcode == 0 {
  37242. res22 = append(res22, res2)
  37243. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37244. //var dat2 map[string]interface{}
  37245. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37246. // fmt.Println(dat)
  37247. //} else {
  37248. // fmt.Println(err)
  37249. //}
  37250. //c.ServeSuccessJSON(map[string]interface{}{
  37251. // "list": res2.Output.Data,
  37252. //})
  37253. //continue
  37254. }
  37255. }
  37256. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37257. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37258. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37259. //var dat2 map[string]interface{}
  37260. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37261. // fmt.Println(dat)
  37262. //} else {
  37263. // fmt.Println(err)
  37264. //}
  37265. //userJSONBytes2, _ := json.Marshal(dat2)
  37266. //var res2 models.Result3260
  37267. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37268. // utils.ErrorLog("解析失败:%v", err)
  37269. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37270. // return
  37271. //}
  37272. //if res2.Infcode == 0 {
  37273. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37274. // var dat2 map[string]interface{}
  37275. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37276. // fmt.Println(dat)
  37277. // } else {
  37278. // fmt.Println(err)
  37279. // }
  37280. // c.ServeSuccessJSON(map[string]interface{}{
  37281. // "list": res2.Output.Data,
  37282. // })
  37283. //}
  37284. }
  37285. func (c *HisApiController) ComfirmAllopatry() {
  37286. year := c.GetString("year")
  37287. month := c.GetString("month")
  37288. admin_user_id, _ := c.GetInt64("admin_user_id")
  37289. adminUser := c.GetAdminUserInfo()
  37290. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37291. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37292. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37293. var dat map[string]interface{}
  37294. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37295. fmt.Println(dat)
  37296. } else {
  37297. fmt.Println(err)
  37298. }
  37299. userJSONBytes, _ := json.Marshal(dat)
  37300. var res models.Result9001
  37301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37302. utils.ErrorLog("解析失败:%v", err)
  37303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37304. return
  37305. }
  37306. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37307. var dat2 map[string]interface{}
  37308. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37309. fmt.Println(dat)
  37310. } else {
  37311. fmt.Println(err)
  37312. }
  37313. userJSONBytes2, _ := json.Marshal(dat2)
  37314. var res2 models.Result3260
  37315. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37316. utils.ErrorLog("解析失败:%v", err)
  37317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37318. return
  37319. }
  37320. //if res2.Infcode == 0 {
  37321. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37322. // var dat map[string]interface{}
  37323. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37324. // fmt.Println(dat)
  37325. // } else {
  37326. // fmt.Println(err)
  37327. // }
  37328. // userJSONBytes, _ := json.Marshal(dat)
  37329. // var res3 models.Result3261
  37330. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37331. // utils.ErrorLog("解析失败:%v", err)
  37332. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37333. // return
  37334. // }
  37335. //
  37336. // if res3.Infcode == 0 {
  37337. // record := &models.HisYidiClearRecord{
  37338. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37339. // Ctime: time.Now().Unix(),
  37340. // Mtime: time.Now().Unix(),
  37341. // Status: 1,
  37342. // MsgId: msgId,
  37343. // }
  37344. // service.SaveClearRecord(record)
  37345. // c.ServeSuccessJSON(map[string]interface{}{
  37346. // "msg": "提取成功",
  37347. // })
  37348. // }
  37349. //}
  37350. }
  37351. func (c *HisApiController) RefundAllopatry() {
  37352. year := c.GetString("year")
  37353. month := c.GetString("month")
  37354. //id, _ := c.GetInt64("id")
  37355. admin_user_id, _ := c.GetInt64("admin_user_id")
  37356. adminUser := c.GetAdminUserInfo()
  37357. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37358. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37359. //record, _ := service.GetClearRecordById(id)
  37360. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37361. var dat map[string]interface{}
  37362. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37363. fmt.Println(dat)
  37364. } else {
  37365. fmt.Println(err)
  37366. }
  37367. userJSONBytes, _ := json.Marshal(dat)
  37368. var res models.Result9001
  37369. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37370. utils.ErrorLog("解析失败:%v", err)
  37371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37372. return
  37373. }
  37374. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37375. var dat2 map[string]interface{}
  37376. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37377. fmt.Println(dat)
  37378. } else {
  37379. fmt.Println(err)
  37380. }
  37381. userJSONBytes2, _ := json.Marshal(dat2)
  37382. var empty ResultFourteen
  37383. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37384. utils.ErrorLog("解析失败:%v", err)
  37385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37386. return
  37387. }
  37388. if empty.Infcode == 0 {
  37389. c.ServeSuccessJSON(map[string]interface{}{
  37390. "msg": "撤销成功",
  37391. })
  37392. return
  37393. }
  37394. }
  37395. func (c *HisApiController) ReversalOtherData() {
  37396. var customData []*CustomData
  37397. custom := &CustomData{
  37398. MsgId: "H44022900158202103301714472004",
  37399. PsnNo: "44020000001101329945",
  37400. Info: "2208",
  37401. }
  37402. customData = append(customData, custom)
  37403. custom1 := &CustomData{
  37404. MsgId: "H4402290015820210330172057803",
  37405. PsnNo: "44020000001101161813",
  37406. Info: "2208",
  37407. }
  37408. customData = append(customData, custom1)
  37409. custom2 := &CustomData{
  37410. MsgId: "H44022900158202103301705198813",
  37411. PsnNo: "44190000133097375417",
  37412. Info: "2208",
  37413. }
  37414. customData = append(customData, custom2)
  37415. custom3 := &CustomData{
  37416. MsgId: "H44022900158202103301715524756",
  37417. PsnNo: "44020000001100187221",
  37418. Info: "2208",
  37419. }
  37420. customData = append(customData, custom3)
  37421. custom4 := &CustomData{
  37422. MsgId: "H44022900158202103301730376224",
  37423. PsnNo: "44020000001101959155",
  37424. Info: "2208",
  37425. }
  37426. customData = append(customData, custom4)
  37427. custom5 := &CustomData{
  37428. MsgId: "H44022900158202103301748008725",
  37429. PsnNo: "44020000001104246641",
  37430. Info: "2208",
  37431. }
  37432. customData = append(customData, custom5)
  37433. custom6 := &CustomData{
  37434. MsgId: "H44022900158202103301718096755",
  37435. PsnNo: "44020000001102211860",
  37436. Info: "2208",
  37437. }
  37438. customData = append(customData, custom6)
  37439. custom7 := &CustomData{
  37440. MsgId: "H44022900158202103301736551640",
  37441. PsnNo: "44020000001102687718",
  37442. Info: "2208",
  37443. }
  37444. customData = append(customData, custom7)
  37445. custom8 := &CustomData{
  37446. MsgId: "H44022900158202103301743097676",
  37447. PsnNo: "44020000001102127785",
  37448. Info: "2208",
  37449. }
  37450. customData = append(customData, custom8)
  37451. custom9 := &CustomData{
  37452. MsgId: "H44022900158202103301712304203",
  37453. PsnNo: "44020000001101518097",
  37454. Info: "2208",
  37455. }
  37456. customData = append(customData, custom9)
  37457. custom10 := &CustomData{
  37458. MsgId: "H44022900158202103301738448785",
  37459. PsnNo: "44020000001100500813",
  37460. Info: "2208",
  37461. }
  37462. customData = append(customData, custom10)
  37463. custom11 := &CustomData{
  37464. MsgId: "H44022900158202103301732455843",
  37465. PsnNo: "44020000001102690557",
  37466. Info: "2208",
  37467. }
  37468. customData = append(customData, custom11)
  37469. custom12 := &CustomData{
  37470. MsgId: "H44022900158202103301745421708",
  37471. PsnNo: "44020000001102211928",
  37472. Info: "2208",
  37473. }
  37474. customData = append(customData, custom12)
  37475. custom1212 := &CustomData{
  37476. MsgId: "H440229001582021033017351627",
  37477. PsnNo: "44020000001102481733",
  37478. Info: "2208",
  37479. }
  37480. customData = append(customData, custom1212)
  37481. custom13 := &CustomData{
  37482. MsgId: "H44022900158202103301740327951",
  37483. PsnNo: "44020000001103174866",
  37484. Info: "2208",
  37485. }
  37486. customData = append(customData, custom13)
  37487. custom14 := &CustomData{
  37488. MsgId: "H4402290015820210330174922668",
  37489. PsnNo: "44020000001102927272",
  37490. Info: "2208",
  37491. }
  37492. customData = append(customData, custom14)
  37493. custom15 := &CustomData{
  37494. MsgId: "H44022900158202103301752362273",
  37495. PsnNo: "44020000001102942890",
  37496. Info: "2208",
  37497. }
  37498. customData = append(customData, custom15)
  37499. custom16 := &CustomData{
  37500. MsgId: "H44022900158202103301751082917",
  37501. PsnNo: "44020000001101662162",
  37502. Info: "2208",
  37503. }
  37504. customData = append(customData, custom16)
  37505. custom17 := &CustomData{
  37506. MsgId: "H44022900158202103301754147728",
  37507. PsnNo: "44020000000229014511",
  37508. Info: "2208",
  37509. }
  37510. customData = append(customData, custom17)
  37511. adminUser := c.GetAdminUserInfo()
  37512. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37513. for _, item := range customData {
  37514. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37515. fmt.Println(result)
  37516. }
  37517. }
  37518. func PathExists(path string) (bool, error) {
  37519. _, err := os.Stat(path)
  37520. if err == nil {
  37521. return true, nil
  37522. }
  37523. if os.IsNotExist(err) {
  37524. return false, nil
  37525. }
  37526. return false, err
  37527. }
  37528. // 创建文件夹
  37529. func Mkdir(dir string) {
  37530. // 创建文件夹
  37531. exist, err := PathExists(dir)
  37532. if err != nil {
  37533. fmt.Println(err.Error())
  37534. } else {
  37535. if exist {
  37536. fmt.Println(dir + "文件夹已存在!")
  37537. } else {
  37538. // 文件夹名称,权限
  37539. err := os.Mkdir(dir, os.ModePerm)
  37540. if err != nil {
  37541. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37542. } else {
  37543. fmt.Println(dir + "文件夹创建成功!")
  37544. }
  37545. }
  37546. }
  37547. }
  37548. // 压缩文件
  37549. func Zip(srcFile string, destZip string) error {
  37550. zipfile, err := os.Create(destZip)
  37551. if err != nil {
  37552. return err
  37553. }
  37554. defer zipfile.Close()
  37555. archive := zip.NewWriter(zipfile)
  37556. defer archive.Close()
  37557. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37558. if err != nil {
  37559. return err
  37560. }
  37561. header, err := zip.FileInfoHeader(info)
  37562. if err != nil {
  37563. return err
  37564. }
  37565. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37566. // header.Name = path
  37567. if info.IsDir() {
  37568. header.Name += "/"
  37569. } else {
  37570. header.Method = zip.Deflate
  37571. }
  37572. writer, err := archive.CreateHeader(header)
  37573. if err != nil {
  37574. return err
  37575. }
  37576. if !info.IsDir() {
  37577. file, err := os.Open(path)
  37578. if err != nil {
  37579. return err
  37580. }
  37581. defer file.Close()
  37582. _, err = io.Copy(writer, file)
  37583. }
  37584. return err
  37585. })
  37586. return err
  37587. }
  37588. func ReadFile(filePath string) []byte {
  37589. f, err := os.Open(filePath)
  37590. if err != nil {
  37591. fmt.Println("read file fail", err)
  37592. return nil
  37593. }
  37594. defer f.Close()
  37595. fd, err := ioutil.ReadAll(f)
  37596. if err != nil {
  37597. fmt.Println("read to fd fail", err)
  37598. return nil
  37599. }
  37600. return fd
  37601. }
  37602. func saveLogq(result string, request string, infno string, desc string) {
  37603. dir := "日志"
  37604. utils.Mkdir(dir)
  37605. month := time.Unix(1557042972, 0).Format("1")
  37606. year := time.Now().Format("2006")
  37607. month = time.Now().Format("01")
  37608. day := time.Now().Format("02")
  37609. hour := time.Now().Format("15")
  37610. min := time.Now().Format("04")
  37611. sec := time.Now().Format("05")
  37612. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37613. file := year + month + day + "_log"
  37614. file_name := file + ".txt"
  37615. file_path := "日志" + "/" + file_name
  37616. exist, _ := utils.PathExists(file_path)
  37617. if exist { //存在
  37618. fmt.Println("存在")
  37619. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37620. if err != nil {
  37621. fmt.Println("read fail")
  37622. }
  37623. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37624. n, _ := f.Seek(0, 2)
  37625. _, err = f.WriteAt([]byte(content), n)
  37626. } else { //不存在
  37627. fmt.Println("文件不存在,创建文件")
  37628. f, err := os.Create("日志" + "/" + file_name)
  37629. defer f.Close()
  37630. if err != nil {
  37631. } else {
  37632. _, err = f.Write([]byte("记录日志"))
  37633. }
  37634. }
  37635. }
  37636. func saveLog(result string, request string, infno string, desc string) {
  37637. org_id, _ := beego.AppConfig.Int64("org_id")
  37638. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37639. dir := miConfig.OrgName + "日志"
  37640. utils.Mkdir(dir)
  37641. month := time.Unix(1557042972, 0).Format("1")
  37642. year := time.Now().Format("2006")
  37643. month = time.Now().Format("01")
  37644. day := time.Now().Format("02")
  37645. hour := time.Now().Format("15")
  37646. min := time.Now().Format("04")
  37647. sec := time.Now().Format("05")
  37648. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37649. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37650. file_name := file + ".txt"
  37651. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37652. exist, _ := utils.PathExists(file_path)
  37653. if exist { //存在
  37654. fmt.Println("存在")
  37655. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37656. if err != nil {
  37657. fmt.Println("read fail")
  37658. }
  37659. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37660. n, _ := f.Seek(0, 2)
  37661. _, err = f.WriteAt([]byte(content), n)
  37662. } else { //不存在
  37663. fmt.Println("文件不存在,创建文件")
  37664. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37665. defer f.Close()
  37666. if err != nil {
  37667. } else {
  37668. _, err = f.Write([]byte("记录日志"))
  37669. }
  37670. }
  37671. }
  37672. type Charset string
  37673. const (
  37674. UTF8 = Charset("UTF-8")
  37675. GB18030 = Charset("GB18030")
  37676. )
  37677. func ConvertToString(src string, srcCode string, tagCode string) string {
  37678. srcCoder := mahonia.NewDecoder(srcCode)
  37679. srcResult := srcCoder.ConvertString(src)
  37680. tagCoder := mahonia.NewDecoder(tagCode)
  37681. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37682. result := string(cdata)
  37683. return result
  37684. }
  37685. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37686. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37687. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37688. var token string
  37689. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37690. var api string
  37691. if miConfig.MdtrtareaAdmvs == "320921" {
  37692. 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 +
  37693. "&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
  37694. fmt.Println(api)
  37695. } else {
  37696. 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 +
  37697. "&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
  37698. }
  37699. resp, requestErr := http.Get(api)
  37700. if requestErr != nil {
  37701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37702. return ""
  37703. }
  37704. body, ioErr := ioutil.ReadAll(resp.Body)
  37705. if ioErr != nil {
  37706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37708. return ""
  37709. }
  37710. var respJSON map[string]interface{}
  37711. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37714. return ""
  37715. }
  37716. var status string
  37717. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37718. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37719. var res ResultTwo //1101结果
  37720. var res10265 ResultTwo10265 //1101结果
  37721. if status == "0" { //读卡成功
  37722. var card_info string //卡信息
  37723. var busi_card_info string
  37724. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37725. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37726. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37727. fmt.Println(card_info)
  37728. fmt.Println(busi_card_info)
  37729. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37730. result, _ := json.Marshal(respJSON)
  37731. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37732. utils.ErrorLog("解析失败:%v", err)
  37733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37734. return ""
  37735. }
  37736. res.ErrMsg = res10265.ErrMsg
  37737. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37738. res.Infcode = infocode
  37739. res.Output = res10265.Output
  37740. res.InfRefmsgid = res10265.InfRefmsgid
  37741. if res.Infcode == 0 {
  37742. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37743. if err == gorm.ErrRecordNotFound {
  37744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37745. return ""
  37746. } else if err != nil {
  37747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37748. return ""
  37749. } else {
  37750. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37751. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37752. infoStr := string(Iinfos)
  37753. idetinfoStr := string(Idetinfos)
  37754. psn := &models.HisPsn{
  37755. PsnNo: res.Output.Baseinfo.PsnNo,
  37756. PatientId: patient.ID,
  37757. Certno: res.Output.Baseinfo.Certno,
  37758. Gend: res.Output.Baseinfo.Gend,
  37759. Naty: res.Output.Baseinfo.Naty,
  37760. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37761. PsnName: res.Output.Baseinfo.PsnName,
  37762. Idetinfo: idetinfoStr,
  37763. Insuinfo: infoStr,
  37764. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37765. CardInfo: card_info,
  37766. VerifyNumber: token,
  37767. }
  37768. service.CreateHisPsn(psn)
  37769. return token
  37770. }
  37771. }
  37772. } else {
  37773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37774. return ""
  37775. }
  37776. } else { //读卡失败
  37777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37778. return ""
  37779. }
  37780. return token
  37781. }
  37782. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37783. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37784. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37785. var token string
  37786. var api string
  37787. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37788. "&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
  37789. fmt.Println(api)
  37790. resp, requestErr := http.Get(api)
  37791. if requestErr != nil {
  37792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37793. return ""
  37794. }
  37795. body, ioErr := ioutil.ReadAll(resp.Body)
  37796. if ioErr != nil {
  37797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37799. return ""
  37800. }
  37801. var respJSON map[string]interface{}
  37802. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37805. return ""
  37806. }
  37807. var status string
  37808. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37809. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37810. var res ResultTwo //1101结果
  37811. if status == "1" { //读卡成功
  37812. var card_info string //卡信息
  37813. var busi_card_info string
  37814. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37815. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37816. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37817. fmt.Println(card_info)
  37818. fmt.Println(busi_card_info)
  37819. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37820. result, _ := json.Marshal(respJSON)
  37821. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37822. utils.ErrorLog("解析失败:%v", err)
  37823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37824. return ""
  37825. }
  37826. if res.Infcode == 0 {
  37827. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37828. if err == gorm.ErrRecordNotFound {
  37829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37830. return ""
  37831. } else if err != nil {
  37832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37833. return ""
  37834. } else {
  37835. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37836. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37837. infoStr := string(Iinfos)
  37838. idetinfoStr := string(Idetinfos)
  37839. psn := &models.HisPsn{
  37840. PsnNo: res.Output.Baseinfo.PsnNo,
  37841. PatientId: patient.ID,
  37842. Certno: res.Output.Baseinfo.Certno,
  37843. Gend: res.Output.Baseinfo.Gend,
  37844. Naty: res.Output.Baseinfo.Naty,
  37845. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37846. PsnName: res.Output.Baseinfo.PsnName,
  37847. Idetinfo: idetinfoStr,
  37848. Insuinfo: infoStr,
  37849. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37850. CardInfo: card_info,
  37851. VerifyNumber: token,
  37852. }
  37853. service.CreateHisPsn(psn)
  37854. return token
  37855. }
  37856. }
  37857. } else {
  37858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37859. return ""
  37860. }
  37861. return token
  37862. }
  37863. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37864. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37865. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37866. var token string
  37867. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37868. var api string
  37869. if miConfig.MdtrtareaAdmvs == "320921" {
  37870. 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 +
  37871. "&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
  37872. fmt.Println(api)
  37873. } else {
  37874. 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 +
  37875. "&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
  37876. }
  37877. resp, requestErr := http.Get(api)
  37878. if requestErr != nil {
  37879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37880. return ""
  37881. }
  37882. body, ioErr := ioutil.ReadAll(resp.Body)
  37883. if ioErr != nil {
  37884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37886. return ""
  37887. }
  37888. var respJSON map[string]interface{}
  37889. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37892. return ""
  37893. }
  37894. var status string
  37895. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37896. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37897. var res ResultTwo //1101结果
  37898. var res10265 ResultTwo10265 //1101结果
  37899. if status == "0" { //读卡成功
  37900. var card_info string //卡信息
  37901. var busi_card_info string
  37902. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37903. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37904. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37905. fmt.Println(card_info)
  37906. fmt.Println(busi_card_info)
  37907. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37908. result, _ := json.Marshal(respJSON)
  37909. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37910. utils.ErrorLog("解析失败:%v", err)
  37911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37912. return ""
  37913. }
  37914. res.ErrMsg = res10265.ErrMsg
  37915. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37916. res.Infcode = infocode
  37917. res.Output = res10265.Output
  37918. res.InfRefmsgid = res10265.InfRefmsgid
  37919. if res.Infcode == 0 {
  37920. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37921. if err == gorm.ErrRecordNotFound {
  37922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37923. return ""
  37924. } else if err != nil {
  37925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37926. return ""
  37927. } else {
  37928. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37929. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37930. infoStr := string(Iinfos)
  37931. idetinfoStr := string(Idetinfos)
  37932. psn := &models.HisPsn{
  37933. PsnNo: res.Output.Baseinfo.PsnNo,
  37934. PatientId: patient.ID,
  37935. Certno: res.Output.Baseinfo.Certno,
  37936. Gend: res.Output.Baseinfo.Gend,
  37937. Naty: res.Output.Baseinfo.Naty,
  37938. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37939. PsnName: res.Output.Baseinfo.PsnName,
  37940. Idetinfo: idetinfoStr,
  37941. Insuinfo: infoStr,
  37942. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37943. CardInfo: card_info,
  37944. VerifyNumber: token,
  37945. }
  37946. service.CreateHisPsn(psn)
  37947. return token
  37948. }
  37949. }
  37950. } else {
  37951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37952. return ""
  37953. }
  37954. } else { //读卡失败
  37955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37956. return ""
  37957. }
  37958. return token
  37959. }
  37960. func DeleteExtraSpaceTwo(s string) string {
  37961. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37962. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37963. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37964. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37965. s2 := make([]byte, len(s1)) //定义字符数组切片
  37966. copy(s2, s1) //将字符串复制到切片
  37967. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37968. for len(spc_index) > 0 { //找到适配项
  37969. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37970. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37971. }
  37972. return string(s2)
  37973. }
  37974. func Remove0000(s string) string {
  37975. str := make([]rune, 0, len(s))
  37976. for _, v := range []rune(s) {
  37977. if v == 0 {
  37978. continue
  37979. }
  37980. str = append(str, v)
  37981. }
  37982. return string(str)
  37983. }
  37984. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37985. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37986. readCard := DllDef.MustFindProc("EcQuery")
  37987. pCardInfo := make([]byte, 8192)
  37988. pBusiCardInfo := make([]byte, 8192)
  37989. data := make(map[string]interface{})
  37990. //pData := make(map[string]interface{})
  37991. inputData := make(map[string]interface{})
  37992. inputData["orgId"] = code
  37993. inputData["businessType"] = "01101"
  37994. inputData["operatorId"] = operator_id
  37995. inputData["operatorName"] = operator_name
  37996. inputData["officeId"] = "001"
  37997. inputData["officeName"] = "血透室"
  37998. //
  37999. data["data"] = inputData
  38000. data["transType"] = "ec.query"
  38001. data["orgId"] = code
  38002. bytesData, _ := json.Marshal(data)
  38003. pCardInfo = bytesData
  38004. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  38005. fmt.Println(ret2)
  38006. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  38007. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  38008. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  38009. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  38010. if ret2 != 0 {
  38011. return "", ""
  38012. }
  38013. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  38014. }
  38015. func DeleteExtraSpace(s string) string {
  38016. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  38017. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  38018. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  38019. reg, _ := regexp.Compile(regstr) //编译正则表达式
  38020. s2 := make([]byte, len(s1)) //定义字符数组切片
  38021. copy(s2, s1) //将字符串复制到切片
  38022. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  38023. for len(spc_index) > 0 { //找到适配项
  38024. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  38025. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  38026. }
  38027. return string(s2)
  38028. }
  38029. // 对账
  38030. func (c *HisApiController) Post3202() {
  38031. start_time := c.GetString("start_time")
  38032. end_time := c.GetString("end_time")
  38033. //insutype := c.GetString("insutype")
  38034. clr_type := c.GetString("clr_type")
  38035. clr_org := c.GetString("clr_optins")
  38036. admin_user_id, _ := c.GetInt64("admin_user_id")
  38037. adminUser := c.GetAdminUserInfo()
  38038. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38039. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38040. if len(clr_org) == 0 {
  38041. clr_org = miConfig.MdtrtareaAdmvs
  38042. }
  38043. timeLayout := "2006-01-02"
  38044. loc, _ := time.LoadLocation("Local")
  38045. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38046. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38047. var orders []*models.HisOrder
  38048. if clr_org == "421300" {
  38049. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38050. } else if clr_org == "420902" {
  38051. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38052. } else {
  38053. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38054. }
  38055. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38056. //fixmedins_setl_cnt := int64(len(orders))
  38057. var medfee_sumamt float64
  38058. var acct_pay float64
  38059. var fund_pay_sumamt float64
  38060. for _, item := range orders {
  38061. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38062. acct_pay = acct_pay + item.AcctPay
  38063. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38064. }
  38065. //var medfee_sumamt_two float64
  38066. //var acct_pay_two float64
  38067. //var fund_pay_sumamt_two float64
  38068. //for _, item := range orders_two {
  38069. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38070. // acct_pay_two = acct_pay_two + item.AcctPay
  38071. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38072. //}
  38073. //var user_name string
  38074. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38075. //if role.ID == 0 {
  38076. // user_name = "xxx"
  38077. //} else {
  38078. // user_name = role.UserName
  38079. //}
  38080. var res ResultSix
  38081. if config.IsOpen == 1 {
  38082. var bps []*models.BusinessParamsTwo
  38083. var bp models.BusinessParamsTwo
  38084. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38085. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38086. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38087. bp.MedfeeSumamt = medfee_sumamt_str
  38088. bp.AcctPay = acct_pay_str
  38089. bp.FundPaySumamt = fund_pay_sumamt_str
  38090. bp.Insutype = ""
  38091. bp.StmtBegndate = start_time
  38092. bp.ClrType = clr_type
  38093. bp.SetlOptins = clr_org
  38094. bp.StmtEnddate = end_time
  38095. bps = append(bps, &bp)
  38096. data := make(map[string]interface{})
  38097. data["bps"] = bps
  38098. data["org_name"] = miConfig.OrgName
  38099. data["doctor"] = role.UserName
  38100. data["fixmedins_code"] = miConfig.Code
  38101. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38102. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38103. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38104. if miConfig.MdtrtareaAdmvs == "421300" {
  38105. client := &http.Client{}
  38106. bytesData, _ := json.Marshal(data)
  38107. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  38108. resp, _ := client.Do(req)
  38109. defer resp.Body.Close()
  38110. body, ioErr := ioutil.ReadAll(resp.Body)
  38111. if ioErr != nil {
  38112. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38114. return
  38115. }
  38116. var respJSON map[string]interface{}
  38117. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38120. return
  38121. }
  38122. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38123. userJSONBytes, _ := json.Marshal(respJSON)
  38124. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38125. utils.ErrorLog("解析失败:%v", err)
  38126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38127. return
  38128. }
  38129. }
  38130. if miConfig.MdtrtareaAdmvs == "420200" {
  38131. client := &http.Client{}
  38132. bytesData, _ := json.Marshal(data)
  38133. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  38134. resp, _ := client.Do(req)
  38135. defer resp.Body.Close()
  38136. body, ioErr := ioutil.ReadAll(resp.Body)
  38137. if ioErr != nil {
  38138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38140. return
  38141. }
  38142. var respJSON map[string]interface{}
  38143. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38146. return
  38147. }
  38148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38149. userJSONBytes, _ := json.Marshal(respJSON)
  38150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38151. utils.ErrorLog("解析失败:%v", err)
  38152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38153. return
  38154. }
  38155. }
  38156. if miConfig.MdtrtareaAdmvs == "421182" {
  38157. client := &http.Client{}
  38158. bytesData, _ := json.Marshal(data)
  38159. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38160. resp, _ := client.Do(req)
  38161. defer resp.Body.Close()
  38162. body, ioErr := ioutil.ReadAll(resp.Body)
  38163. if ioErr != nil {
  38164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38166. return
  38167. }
  38168. var respJSON map[string]interface{}
  38169. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38172. return
  38173. }
  38174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38175. userJSONBytes, _ := json.Marshal(respJSON)
  38176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38177. utils.ErrorLog("解析失败:%v", err)
  38178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38179. return
  38180. }
  38181. }
  38182. if miConfig.MdtrtareaAdmvs == "420902" {
  38183. client := &http.Client{}
  38184. bytesData, _ := json.Marshal(data)
  38185. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38186. resp, _ := client.Do(req)
  38187. defer resp.Body.Close()
  38188. body, ioErr := ioutil.ReadAll(resp.Body)
  38189. if ioErr != nil {
  38190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38192. return
  38193. }
  38194. var respJSON map[string]interface{}
  38195. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38198. return
  38199. }
  38200. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38201. userJSONBytes, _ := json.Marshal(respJSON)
  38202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38203. utils.ErrorLog("解析失败:%v", err)
  38204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38205. return
  38206. }
  38207. }
  38208. if res.Infcode == 0 {
  38209. c.ServeSuccessJSON(map[string]interface{}{
  38210. "msg": "发起成功",
  38211. })
  38212. } else {
  38213. c.ServeSuccessJSON(map[string]interface{}{
  38214. "failed_code": -10,
  38215. "msg": res.ErrMsg,
  38216. })
  38217. }
  38218. }
  38219. }
  38220. func (c *HisApiController) Post3204a() {
  38221. start_time := c.GetString("start_time")
  38222. end_time := c.GetString("end_time")
  38223. //insutype := c.GetString("insutype")
  38224. clr_type := c.GetString("clr_type")
  38225. clr_org := c.GetString("clr_optins")
  38226. admin_user_id, _ := c.GetInt64("admin_user_id")
  38227. adminUser := c.GetAdminUserInfo()
  38228. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38229. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38230. if len(clr_org) == 0 {
  38231. clr_org = miConfig.MdtrtareaAdmvs
  38232. }
  38233. timeLayout := "2006-01-02"
  38234. loc, _ := time.LoadLocation("Local")
  38235. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38236. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38237. var orders []*models.HisOrder
  38238. if clr_org == "421300" {
  38239. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38240. } else if clr_org == "420902" {
  38241. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38242. } else {
  38243. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38244. }
  38245. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38246. //fixmedins_setl_cnt := int64(len(orders))
  38247. var medfee_sumamt float64
  38248. var acct_pay float64
  38249. var fund_pay_sumamt float64
  38250. for _, item := range orders {
  38251. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38252. acct_pay = acct_pay + item.AcctPay
  38253. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38254. }
  38255. //var medfee_sumamt_two float64
  38256. //var acct_pay_two float64
  38257. //var fund_pay_sumamt_two float64
  38258. //for _, item := range orders_two {
  38259. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38260. // acct_pay_two = acct_pay_two + item.AcctPay
  38261. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38262. //}
  38263. //var user_name string
  38264. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38265. //if role.ID == 0 {
  38266. // user_name = "xxx"
  38267. //} else {
  38268. // user_name = role.UserName
  38269. //}
  38270. var res ResultSix
  38271. if config.IsOpen == 1 {
  38272. var bps []*models.BusinessParamsTwo
  38273. var bp models.BusinessParamsTwo
  38274. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38275. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38276. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38277. bp.MedfeeSumamt = medfee_sumamt_str
  38278. bp.AcctPay = acct_pay_str
  38279. bp.FundPaySumamt = fund_pay_sumamt_str
  38280. bp.Insutype = ""
  38281. bp.StmtBegndate = start_time
  38282. bp.ClrType = clr_type
  38283. bp.SetlOptins = clr_org
  38284. bp.StmtEnddate = end_time
  38285. bps = append(bps, &bp)
  38286. data := make(map[string]interface{})
  38287. data["bps"] = bps
  38288. data["org_name"] = miConfig.OrgName
  38289. data["doctor"] = role.UserName
  38290. data["fixmedins_code"] = miConfig.Code
  38291. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38292. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38293. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38294. if miConfig.MdtrtareaAdmvs == "421300" {
  38295. client := &http.Client{}
  38296. bytesData, _ := json.Marshal(data)
  38297. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38298. resp, _ := client.Do(req)
  38299. defer resp.Body.Close()
  38300. body, ioErr := ioutil.ReadAll(resp.Body)
  38301. if ioErr != nil {
  38302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38304. return
  38305. }
  38306. var respJSON map[string]interface{}
  38307. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38310. return
  38311. }
  38312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38313. userJSONBytes, _ := json.Marshal(respJSON)
  38314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38315. utils.ErrorLog("解析失败:%v", err)
  38316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38317. return
  38318. }
  38319. }
  38320. if miConfig.MdtrtareaAdmvs == "420200" {
  38321. client := &http.Client{}
  38322. bytesData, _ := json.Marshal(data)
  38323. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38324. resp, _ := client.Do(req)
  38325. defer resp.Body.Close()
  38326. body, ioErr := ioutil.ReadAll(resp.Body)
  38327. if ioErr != nil {
  38328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38330. return
  38331. }
  38332. var respJSON map[string]interface{}
  38333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38336. return
  38337. }
  38338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38339. userJSONBytes, _ := json.Marshal(respJSON)
  38340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38341. utils.ErrorLog("解析失败:%v", err)
  38342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38343. return
  38344. }
  38345. }
  38346. if miConfig.MdtrtareaAdmvs == "421182" {
  38347. client := &http.Client{}
  38348. bytesData, _ := json.Marshal(data)
  38349. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38350. resp, _ := client.Do(req)
  38351. defer resp.Body.Close()
  38352. body, ioErr := ioutil.ReadAll(resp.Body)
  38353. if ioErr != nil {
  38354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38356. return
  38357. }
  38358. var respJSON map[string]interface{}
  38359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38362. return
  38363. }
  38364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38365. userJSONBytes, _ := json.Marshal(respJSON)
  38366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38367. utils.ErrorLog("解析失败:%v", err)
  38368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38369. return
  38370. }
  38371. }
  38372. if miConfig.MdtrtareaAdmvs == "420902" {
  38373. client := &http.Client{}
  38374. bytesData, _ := json.Marshal(data)
  38375. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38376. resp, _ := client.Do(req)
  38377. defer resp.Body.Close()
  38378. body, ioErr := ioutil.ReadAll(resp.Body)
  38379. if ioErr != nil {
  38380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38382. return
  38383. }
  38384. var respJSON map[string]interface{}
  38385. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38388. return
  38389. }
  38390. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38391. userJSONBytes, _ := json.Marshal(respJSON)
  38392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38393. utils.ErrorLog("解析失败:%v", err)
  38394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38395. return
  38396. }
  38397. }
  38398. if res.Infcode == 0 {
  38399. c.ServeSuccessJSON(map[string]interface{}{
  38400. "msg": "撤销成功",
  38401. })
  38402. } else {
  38403. c.ServeSuccessJSON(map[string]interface{}{
  38404. "failed_code": -10,
  38405. "msg": res.ErrMsg,
  38406. })
  38407. }
  38408. }
  38409. }
  38410. func (c *HisApiController) Post3204() {
  38411. admin_user_id, _ := c.GetInt64("admin_user_id")
  38412. id := c.GetString("id")
  38413. adminUser := c.GetAdminUserInfo()
  38414. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38415. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38416. //clr_org := miConfig.MdtrtareaAdmvs
  38417. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38418. var res ResultSix
  38419. if config.IsOpen == 1 {
  38420. data := make(map[string]interface{})
  38421. data["id"] = id
  38422. data["org_name"] = miConfig.OrgName
  38423. data["doctor"] = role.UserName
  38424. data["fixmedins_code"] = miConfig.Code
  38425. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38426. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38427. client := &http.Client{}
  38428. bytesData, _ := json.Marshal(data)
  38429. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38430. resp, _ := client.Do(req)
  38431. defer resp.Body.Close()
  38432. body, ioErr := ioutil.ReadAll(resp.Body)
  38433. if ioErr != nil {
  38434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38436. return
  38437. }
  38438. var respJSON map[string]interface{}
  38439. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38442. return
  38443. }
  38444. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38445. userJSONBytes, _ := json.Marshal(respJSON)
  38446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38447. utils.ErrorLog("解析失败:%v", err)
  38448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38449. return
  38450. }
  38451. if res.Infcode == 0 {
  38452. c.ServeSuccessJSON(map[string]interface{}{
  38453. "msg": "发起成功",
  38454. })
  38455. } else {
  38456. c.ServeSuccessJSON(map[string]interface{}{
  38457. "failed_code": -10,
  38458. "msg": res.ErrMsg,
  38459. })
  38460. }
  38461. }
  38462. }
  38463. func (c *HisApiController) Post8404() {
  38464. admin_user_id, _ := c.GetInt64("admin_user_id")
  38465. month := c.GetString("month")
  38466. adminUser := c.GetAdminUserInfo()
  38467. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38468. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38469. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38470. var res ResultSix
  38471. if config.IsOpen == 1 {
  38472. data := make(map[string]interface{})
  38473. data["month"] = month
  38474. data["org_name"] = miConfig.OrgName
  38475. data["doctor"] = role.UserName
  38476. data["fixmedins_code"] = miConfig.Code
  38477. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38478. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38479. client := &http.Client{}
  38480. bytesData, _ := json.Marshal(data)
  38481. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38482. resp, _ := client.Do(req)
  38483. defer resp.Body.Close()
  38484. body, ioErr := ioutil.ReadAll(resp.Body)
  38485. if ioErr != nil {
  38486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38488. return
  38489. }
  38490. var respJSON map[string]interface{}
  38491. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38494. return
  38495. }
  38496. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38497. userJSONBytes, _ := json.Marshal(respJSON)
  38498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38499. utils.ErrorLog("解析失败:%v", err)
  38500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38501. return
  38502. }
  38503. if res.Infcode == 0 {
  38504. c.ServeSuccessJSON(map[string]interface{}{
  38505. "msg": "查询成功",
  38506. })
  38507. } else {
  38508. c.ServeSuccessJSON(map[string]interface{}{
  38509. "failed_code": -10,
  38510. "msg": res.ErrMsg,
  38511. })
  38512. }
  38513. }
  38514. }
  38515. func (c *HisApiController) Post3202b() {
  38516. start_time := c.GetString("start_time")
  38517. end_time := c.GetString("end_time")
  38518. //insutype := c.GetString("insutype")
  38519. clr_type := c.GetString("clr_type")
  38520. clr_org := c.GetString("clr_optins")
  38521. admin_user_id, _ := c.GetInt64("admin_user_id")
  38522. adminUser := c.GetAdminUserInfo()
  38523. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38524. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38525. if len(clr_org) == 0 {
  38526. clr_org = miConfig.MdtrtareaAdmvs
  38527. }
  38528. timeLayout := "2006-01-02"
  38529. loc, _ := time.LoadLocation("Local")
  38530. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38531. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38532. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38533. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38534. //fixmedins_setl_cnt := int64(len(orders))
  38535. var medfee_sumamt float64
  38536. var acct_pay float64
  38537. var fund_pay_sumamt float64
  38538. for _, item := range orders {
  38539. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38540. acct_pay = acct_pay + item.AcctPay
  38541. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38542. }
  38543. //var medfee_sumamt_two float64
  38544. //var acct_pay_two float64
  38545. //var fund_pay_sumamt_two float64
  38546. //for _, item := range orders_two {
  38547. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38548. // acct_pay_two = acct_pay_two + item.AcctPay
  38549. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38550. //}
  38551. //var user_name string
  38552. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38553. //if role.ID == 0 {
  38554. // user_name = "xxx"
  38555. //} else {
  38556. // user_name = role.UserName
  38557. //}
  38558. var res ResultSix
  38559. if config.IsOpen == 1 {
  38560. var bps []*models.BusinessParamsTwo
  38561. var bp models.BusinessParamsTwo
  38562. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38563. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38564. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38565. bp.MedfeeSumamt = medfee_sumamt_str
  38566. bp.AcctPay = acct_pay_str
  38567. bp.FundPaySumamt = fund_pay_sumamt_str
  38568. bp.Insutype = "390"
  38569. bp.StmtBegndate = start_time
  38570. bp.ClrType = clr_type
  38571. bp.SetlOptins = clr_org
  38572. bp.StmtEnddate = end_time
  38573. bps = append(bps, &bp)
  38574. data := make(map[string]interface{})
  38575. data["bps"] = bps
  38576. data["org_name"] = miConfig.OrgName
  38577. data["doctor"] = role.UserName
  38578. data["fixmedins_code"] = miConfig.Code
  38579. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38580. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38581. if miConfig.MdtrtareaAdmvs == "421300" {
  38582. client := &http.Client{}
  38583. bytesData, _ := json.Marshal(data)
  38584. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38585. resp, _ := client.Do(req)
  38586. defer resp.Body.Close()
  38587. body, ioErr := ioutil.ReadAll(resp.Body)
  38588. if ioErr != nil {
  38589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38591. return
  38592. }
  38593. var respJSON map[string]interface{}
  38594. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38597. return
  38598. }
  38599. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38600. userJSONBytes, _ := json.Marshal(respJSON)
  38601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38602. utils.ErrorLog("解析失败:%v", err)
  38603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38604. return
  38605. }
  38606. }
  38607. if miConfig.MdtrtareaAdmvs == "420200" {
  38608. client := &http.Client{}
  38609. bytesData, _ := json.Marshal(data)
  38610. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38611. resp, _ := client.Do(req)
  38612. defer resp.Body.Close()
  38613. body, ioErr := ioutil.ReadAll(resp.Body)
  38614. if ioErr != nil {
  38615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38617. return
  38618. }
  38619. var respJSON map[string]interface{}
  38620. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38623. return
  38624. }
  38625. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38626. userJSONBytes, _ := json.Marshal(respJSON)
  38627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38628. utils.ErrorLog("解析失败:%v", err)
  38629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38630. return
  38631. }
  38632. }
  38633. if miConfig.MdtrtareaAdmvs == "421182" {
  38634. client := &http.Client{}
  38635. bytesData, _ := json.Marshal(data)
  38636. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38637. resp, _ := client.Do(req)
  38638. defer resp.Body.Close()
  38639. body, ioErr := ioutil.ReadAll(resp.Body)
  38640. if ioErr != nil {
  38641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38643. return
  38644. }
  38645. var respJSON map[string]interface{}
  38646. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38649. return
  38650. }
  38651. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38652. userJSONBytes, _ := json.Marshal(respJSON)
  38653. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38654. utils.ErrorLog("解析失败:%v", err)
  38655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38656. return
  38657. }
  38658. }
  38659. if res.Infcode == 0 {
  38660. c.ServeSuccessJSON(map[string]interface{}{
  38661. "msg": "发起成功",
  38662. })
  38663. } else {
  38664. c.ServeSuccessJSON(map[string]interface{}{
  38665. "failed_code": -10,
  38666. "msg": res.ErrMsg,
  38667. })
  38668. }
  38669. }
  38670. }
  38671. func (c *HisApiController) Post1608() {
  38672. start_time := c.GetString("start_time")
  38673. end_time := c.GetString("end_time")
  38674. admin_user_id, _ := c.GetInt64("admin_user_id")
  38675. adminUser := c.GetAdminUserInfo()
  38676. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38677. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38678. timeLayout := "2006-01-02"
  38679. loc, _ := time.LoadLocation("Local")
  38680. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38681. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38682. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38683. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38684. fixmedins_setl_cnt := int64(len(orders))
  38685. var medfee_sumamt float64
  38686. var func_smamt float64
  38687. for _, item := range orders {
  38688. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38689. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38690. }
  38691. times := strings.Split(start_time, "-")
  38692. time_tows := strings.Split(end_time, "-")
  38693. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38694. var res ResultSix
  38695. if config.IsOpen == 1 {
  38696. //var bps []*models.BusinessParamsTwo
  38697. //var bp models.BusinessParamsTwo
  38698. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38699. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38700. data := make(map[string]interface{})
  38701. data["org_name"] = miConfig.OrgName
  38702. data["doctor"] = role.UserName
  38703. data["func_smamt"] = func_smamt_str
  38704. data["fixmedins_code"] = miConfig.Code
  38705. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38706. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38707. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38708. data["medfee_sumamt"] = medfee_sumamt_str
  38709. data["start_time"] = times[0] + times[1] + times[2]
  38710. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38711. if miConfig.MdtrtareaAdmvs == "421300" {
  38712. client := &http.Client{}
  38713. bytesData, _ := json.Marshal(data)
  38714. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38715. resp, _ := client.Do(req)
  38716. defer resp.Body.Close()
  38717. body, ioErr := ioutil.ReadAll(resp.Body)
  38718. if ioErr != nil {
  38719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38721. return
  38722. }
  38723. var respJSON map[string]interface{}
  38724. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38727. return
  38728. }
  38729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38730. userJSONBytes, _ := json.Marshal(respJSON)
  38731. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38732. utils.ErrorLog("解析失败:%v", err)
  38733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38734. return
  38735. }
  38736. }
  38737. if miConfig.MdtrtareaAdmvs == "420200" {
  38738. client := &http.Client{}
  38739. bytesData, _ := json.Marshal(data)
  38740. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38741. resp, _ := client.Do(req)
  38742. defer resp.Body.Close()
  38743. body, ioErr := ioutil.ReadAll(resp.Body)
  38744. if ioErr != nil {
  38745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38747. return
  38748. }
  38749. var respJSON map[string]interface{}
  38750. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38753. return
  38754. }
  38755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38756. userJSONBytes, _ := json.Marshal(respJSON)
  38757. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38758. utils.ErrorLog("解析失败:%v", err)
  38759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38760. return
  38761. }
  38762. }
  38763. if miConfig.MdtrtareaAdmvs == "421182" {
  38764. client := &http.Client{}
  38765. bytesData, _ := json.Marshal(data)
  38766. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38767. resp, _ := client.Do(req)
  38768. defer resp.Body.Close()
  38769. body, ioErr := ioutil.ReadAll(resp.Body)
  38770. if ioErr != nil {
  38771. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38773. return
  38774. }
  38775. var respJSON map[string]interface{}
  38776. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38779. return
  38780. }
  38781. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38782. userJSONBytes, _ := json.Marshal(respJSON)
  38783. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38784. utils.ErrorLog("解析失败:%v", err)
  38785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38786. return
  38787. }
  38788. }
  38789. if res.Infcode == 0 {
  38790. c.ServeSuccessJSON(map[string]interface{}{
  38791. "msg": "发起成功",
  38792. })
  38793. } else {
  38794. c.ServeSuccessJSON(map[string]interface{}{
  38795. "failed_code": -10,
  38796. "msg": res.ErrMsg,
  38797. })
  38798. }
  38799. }
  38800. }
  38801. // 5.11.1.1【5262】结算信息按时间段查询
  38802. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38803. admin_user_id, _ := c.GetInt64("admin_user_id")
  38804. adminUser := c.GetAdminUserInfo()
  38805. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38806. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38807. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38808. var res Result5262
  38809. if config.IsOpen == 1 {
  38810. if miConfig.MdtrtareaAdmvs == "421300" {
  38811. data := make(map[string]interface{})
  38812. data["bps"] = bp
  38813. data["org_name"] = miConfig.OrgName
  38814. data["doctor"] = role.UserName
  38815. data["fixmedins_code"] = miConfig.Code
  38816. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38817. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38818. data["page"] = strconv.FormatInt(page, 10)
  38819. data["limit"] = strconv.FormatInt(limit, 10)
  38820. fmt.Println(data)
  38821. client := &http.Client{}
  38822. bytesData, _ := json.Marshal(data)
  38823. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38824. resp, _ := client.Do(req)
  38825. defer resp.Body.Close()
  38826. body, ioErr := ioutil.ReadAll(resp.Body)
  38827. if ioErr != nil {
  38828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38830. return
  38831. }
  38832. var respJSON map[string]interface{}
  38833. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38836. return
  38837. }
  38838. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38839. userJSONBytes, _ := json.Marshal(respJSON)
  38840. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38841. utils.ErrorLog("解析失败:%v", err)
  38842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38843. return
  38844. }
  38845. }
  38846. if miConfig.MdtrtareaAdmvs == "420200" {
  38847. data := make(map[string]interface{})
  38848. data["bps"] = bp
  38849. data["org_name"] = miConfig.OrgName
  38850. data["doctor"] = role.UserName
  38851. data["fixmedins_code"] = miConfig.Code
  38852. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38853. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38854. data["page"] = strconv.FormatInt(page, 10)
  38855. data["limit"] = strconv.FormatInt(limit, 10)
  38856. fmt.Println(data)
  38857. client := &http.Client{}
  38858. bytesData, _ := json.Marshal(data)
  38859. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38860. resp, _ := client.Do(req)
  38861. defer resp.Body.Close()
  38862. body, ioErr := ioutil.ReadAll(resp.Body)
  38863. if ioErr != nil {
  38864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38866. return
  38867. }
  38868. var respJSON map[string]interface{}
  38869. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38872. return
  38873. }
  38874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38875. userJSONBytes, _ := json.Marshal(respJSON)
  38876. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38877. utils.ErrorLog("解析失败:%v", err)
  38878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38879. return
  38880. }
  38881. }
  38882. if miConfig.MdtrtareaAdmvs == "421182" {
  38883. data := make(map[string]interface{})
  38884. data["bps"] = bp
  38885. data["org_name"] = miConfig.OrgName
  38886. data["doctor"] = role.UserName
  38887. data["fixmedins_code"] = miConfig.Code
  38888. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38889. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38890. data["page"] = strconv.FormatInt(page, 10)
  38891. data["limit"] = strconv.FormatInt(limit, 10)
  38892. fmt.Println(data)
  38893. client := &http.Client{}
  38894. bytesData, _ := json.Marshal(data)
  38895. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38896. resp, _ := client.Do(req)
  38897. defer resp.Body.Close()
  38898. body, ioErr := ioutil.ReadAll(resp.Body)
  38899. if ioErr != nil {
  38900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38902. return
  38903. }
  38904. var respJSON map[string]interface{}
  38905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38908. return
  38909. }
  38910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38911. userJSONBytes, _ := json.Marshal(respJSON)
  38912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38913. utils.ErrorLog("解析失败:%v", err)
  38914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38915. return
  38916. }
  38917. }
  38918. if miConfig.MdtrtareaAdmvs == "420902" {
  38919. data := make(map[string]interface{})
  38920. data["bps"] = bp
  38921. data["org_name"] = miConfig.OrgName
  38922. data["doctor"] = role.UserName
  38923. data["fixmedins_code"] = miConfig.Code
  38924. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38925. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38926. data["page"] = strconv.FormatInt(page, 10)
  38927. data["limit"] = strconv.FormatInt(limit, 10)
  38928. fmt.Println(data)
  38929. client := &http.Client{}
  38930. bytesData, _ := json.Marshal(data)
  38931. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38932. resp, _ := client.Do(req)
  38933. defer resp.Body.Close()
  38934. body, ioErr := ioutil.ReadAll(resp.Body)
  38935. if ioErr != nil {
  38936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38938. return
  38939. }
  38940. var respJSON map[string]interface{}
  38941. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38944. return
  38945. }
  38946. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38947. userJSONBytes, _ := json.Marshal(respJSON)
  38948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38949. utils.ErrorLog("解析失败:%v", err)
  38950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38951. return
  38952. }
  38953. }
  38954. if res.Infcode == 0 {
  38955. c.ServeSuccessJSON(map[string]interface{}{
  38956. "order": res.Output.Result,
  38957. "total": res.Output.PageInfo.RecordCounts,
  38958. })
  38959. } else {
  38960. c.ServeSuccessJSON(map[string]interface{}{
  38961. "failed_code": -10,
  38962. "msg": res.ErrMsg,
  38963. })
  38964. }
  38965. }
  38966. }
  38967. // 5.11.1.2【5267】异地结算信息时间段查询
  38968. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38969. admin_user_id, _ := c.GetInt64("admin_user_id")
  38970. adminUser := c.GetAdminUserInfo()
  38971. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38972. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38973. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38974. var res Result5267
  38975. if config.IsOpen == 1 {
  38976. if miConfig.MdtrtareaAdmvs == "421300" {
  38977. data := make(map[string]interface{})
  38978. data["bps"] = bp
  38979. data["org_name"] = miConfig.OrgName
  38980. data["doctor"] = role.UserName
  38981. data["fixmedins_code"] = miConfig.Code
  38982. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38983. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38984. data["page"] = page
  38985. data["limit"] = limit
  38986. fmt.Println(data)
  38987. client := &http.Client{}
  38988. bytesData, _ := json.Marshal(data)
  38989. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38990. resp, _ := client.Do(req)
  38991. defer resp.Body.Close()
  38992. body, ioErr := ioutil.ReadAll(resp.Body)
  38993. if ioErr != nil {
  38994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38996. return
  38997. }
  38998. var respJSON map[string]interface{}
  38999. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39002. return
  39003. }
  39004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39005. userJSONBytes, _ := json.Marshal(respJSON)
  39006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39007. utils.ErrorLog("解析失败:%v", err)
  39008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39009. return
  39010. }
  39011. }
  39012. if miConfig.MdtrtareaAdmvs == "420200" {
  39013. data := make(map[string]interface{})
  39014. data["bps"] = bp
  39015. data["org_name"] = miConfig.OrgName
  39016. data["doctor"] = role.UserName
  39017. data["fixmedins_code"] = miConfig.Code
  39018. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39019. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39020. data["page"] = page
  39021. data["limit"] = limit
  39022. fmt.Println(data)
  39023. client := &http.Client{}
  39024. bytesData, _ := json.Marshal(data)
  39025. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  39026. resp, _ := client.Do(req)
  39027. defer resp.Body.Close()
  39028. body, ioErr := ioutil.ReadAll(resp.Body)
  39029. if ioErr != nil {
  39030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39032. return
  39033. }
  39034. var respJSON map[string]interface{}
  39035. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39038. return
  39039. }
  39040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39041. userJSONBytes, _ := json.Marshal(respJSON)
  39042. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39043. utils.ErrorLog("解析失败:%v", err)
  39044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39045. return
  39046. }
  39047. }
  39048. if miConfig.MdtrtareaAdmvs == "421182" {
  39049. data := make(map[string]interface{})
  39050. data["bps"] = bp
  39051. data["org_name"] = miConfig.OrgName
  39052. data["doctor"] = role.UserName
  39053. data["fixmedins_code"] = miConfig.Code
  39054. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39055. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39056. data["page"] = page
  39057. data["limit"] = limit
  39058. fmt.Println(data)
  39059. client := &http.Client{}
  39060. bytesData, _ := json.Marshal(data)
  39061. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  39062. resp, _ := client.Do(req)
  39063. defer resp.Body.Close()
  39064. body, ioErr := ioutil.ReadAll(resp.Body)
  39065. if ioErr != nil {
  39066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39068. return
  39069. }
  39070. var respJSON map[string]interface{}
  39071. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39074. return
  39075. }
  39076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39077. userJSONBytes, _ := json.Marshal(respJSON)
  39078. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39079. utils.ErrorLog("解析失败:%v", err)
  39080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39081. return
  39082. }
  39083. }
  39084. if res.Infcode == 0 {
  39085. c.ServeSuccessJSON(map[string]interface{}{
  39086. "order": res.Output.Result,
  39087. "total": res.Output.PageInfo.RecordCounts,
  39088. })
  39089. } else {
  39090. c.ServeSuccessJSON(map[string]interface{}{
  39091. "failed_code": -10,
  39092. "msg": res.ErrMsg,
  39093. })
  39094. }
  39095. }
  39096. }
  39097. func (c *HisApiController) Post3501() {
  39098. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39099. data := make(map[string]interface{})
  39100. var struct3501s []models.Struct3501
  39101. var struct3501 models.Struct3501
  39102. struct3501.OrgName = miConfig.OrgName
  39103. struct3501.AccessKey = miConfig.AccessKey
  39104. struct3501.RequestUrl = miConfig.Url
  39105. struct3501.SecretKey = miConfig.SecretKey
  39106. struct3501.ManuDate = "2022-08-17"
  39107. struct3501.FixmedinsBchno = ""
  39108. struct3501.ManuLotnum = ""
  39109. struct3501.RxFlag = "0"
  39110. struct3501.ExpyEnd = "2022-08-17"
  39111. struct3501.Invdate = "2022-08-17"
  39112. struct3501.InvCnt = "20.25"
  39113. struct3501.Memo = ""
  39114. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39115. struct3501.FixmedinsHilistId = miConfig.Code
  39116. struct3501.FixmedinsHilistName = miConfig.OrgName
  39117. struct3501s = append(struct3501s, struct3501)
  39118. data["struct_3501s"] = struct3501s
  39119. client := &http.Client{}
  39120. bytesData, _ := json.Marshal(data)
  39121. var req *http.Request
  39122. if miConfig.MdtrtareaAdmvs == "320921" {
  39123. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39124. } else {
  39125. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39126. }
  39127. resp, _ := client.Do(req)
  39128. defer resp.Body.Close()
  39129. body, ioErr := ioutil.ReadAll(resp.Body)
  39130. if ioErr != nil {
  39131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39133. return
  39134. }
  39135. var respJSON map[string]interface{}
  39136. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39139. return
  39140. }
  39141. var res ResultSix
  39142. var resSix10265 ResultSix10265 //1101结果
  39143. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39144. result, _ := json.Marshal(respJSON)
  39145. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39146. utils.ErrorLog("解析失败:%v", err)
  39147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39148. return
  39149. }
  39150. res.InfRefmsgid = resSix10265.InfRefmsgid
  39151. res.Output = resSix10265.Output
  39152. res.ErrMsg = resSix10265.ErrMsg
  39153. res.Cainfo = resSix10265.Cainfo
  39154. res.WarnMsg = resSix10265.WarnMsg
  39155. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39156. res.Infcode = infocode
  39157. if infocode == 0 {
  39158. c.ServeSuccessJSON(map[string]interface{}{
  39159. "msg": "上传成功",
  39160. })
  39161. return
  39162. } else {
  39163. c.ServeSuccessJSON(map[string]interface{}{
  39164. "failed_code": -10,
  39165. "msg": res.ErrMsg,
  39166. })
  39167. return
  39168. }
  39169. }
  39170. func (c *HisApiController) Post3502() {
  39171. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39172. data := make(map[string]interface{})
  39173. var struct3502s []models.Struct3502
  39174. var struct3502 models.Struct3502
  39175. struct3502.OrgName = miConfig.OrgName
  39176. struct3502.AccessKey = miConfig.AccessKey
  39177. struct3502.RequestUrl = miConfig.Url
  39178. struct3502.SecretKey = miConfig.SecretKey
  39179. struct3502.ManuDate = "2022-08-15"
  39180. struct3502.FixmedinsBchno = ""
  39181. struct3502.ManuLotnum = ""
  39182. struct3502.RxFlag = "0"
  39183. struct3502.ExpyEnd = "2022-08-15"
  39184. struct3502.Invdate = "2022-08-15"
  39185. struct3502.InvCnt = "20.25"
  39186. struct3502.Memo = ""
  39187. struct3502.MedListCodg = "XB01ABD056B002020200517"
  39188. struct3502.FixmedinsHilistId = miConfig.Code
  39189. struct3502.FixmedinsHilistName = miConfig.OrgName
  39190. struct3502s = append(struct3502s, struct3502)
  39191. data["struct_3502s"] = struct3502s
  39192. client := &http.Client{}
  39193. bytesData, _ := json.Marshal(data)
  39194. var req *http.Request
  39195. if miConfig.MdtrtareaAdmvs == "320921" {
  39196. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39197. } else {
  39198. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39199. }
  39200. resp, _ := client.Do(req)
  39201. defer resp.Body.Close()
  39202. body, ioErr := ioutil.ReadAll(resp.Body)
  39203. if ioErr != nil {
  39204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39206. return
  39207. }
  39208. var respJSON map[string]interface{}
  39209. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39212. return
  39213. }
  39214. var res ResultSix
  39215. var resSix10265 ResultSix10265 //1101结果
  39216. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39217. result, _ := json.Marshal(respJSON)
  39218. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39219. utils.ErrorLog("解析失败:%v", err)
  39220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39221. return
  39222. }
  39223. res.InfRefmsgid = resSix10265.InfRefmsgid
  39224. res.Output = resSix10265.Output
  39225. res.ErrMsg = resSix10265.ErrMsg
  39226. res.Cainfo = resSix10265.Cainfo
  39227. res.WarnMsg = resSix10265.WarnMsg
  39228. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39229. res.Infcode = infocode
  39230. if infocode == 0 {
  39231. c.ServeSuccessJSON(map[string]interface{}{
  39232. "msg": "上传成功",
  39233. })
  39234. return
  39235. } else {
  39236. c.ServeSuccessJSON(map[string]interface{}{
  39237. "failed_code": -10,
  39238. "msg": res.ErrMsg,
  39239. })
  39240. return
  39241. }
  39242. }
  39243. func (c *HisApiController) Post3503() {
  39244. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39245. data := make(map[string]interface{})
  39246. var struct3501s []models.Struct3501
  39247. var struct3501 models.Struct3501
  39248. struct3501.OrgName = miConfig.OrgName
  39249. struct3501.AccessKey = miConfig.AccessKey
  39250. struct3501.RequestUrl = miConfig.Url
  39251. struct3501.SecretKey = miConfig.SecretKey
  39252. struct3501.ManuDate = "2022-08-15"
  39253. struct3501.FixmedinsBchno = ""
  39254. struct3501.ManuLotnum = ""
  39255. struct3501.RxFlag = "0"
  39256. struct3501.ExpyEnd = "2022-08-15"
  39257. struct3501.Invdate = "2022-08-15"
  39258. struct3501.InvCnt = "20.25"
  39259. struct3501.Memo = ""
  39260. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39261. struct3501.FixmedinsHilistId = miConfig.Code
  39262. struct3501.FixmedinsHilistName = miConfig.OrgName
  39263. struct3501s = append(struct3501s, struct3501)
  39264. data["struct_3501s"] = struct3501s
  39265. client := &http.Client{}
  39266. bytesData, _ := json.Marshal(data)
  39267. var req *http.Request
  39268. if miConfig.MdtrtareaAdmvs == "320921" {
  39269. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39270. } else {
  39271. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39272. }
  39273. resp, _ := client.Do(req)
  39274. defer resp.Body.Close()
  39275. body, ioErr := ioutil.ReadAll(resp.Body)
  39276. if ioErr != nil {
  39277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39279. return
  39280. }
  39281. var respJSON map[string]interface{}
  39282. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39285. return
  39286. }
  39287. var res ResultSix
  39288. var resSix10265 ResultSix10265 //1101结果
  39289. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39290. result, _ := json.Marshal(respJSON)
  39291. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39292. utils.ErrorLog("解析失败:%v", err)
  39293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39294. return
  39295. }
  39296. res.InfRefmsgid = resSix10265.InfRefmsgid
  39297. res.Output = resSix10265.Output
  39298. res.ErrMsg = resSix10265.ErrMsg
  39299. res.Cainfo = resSix10265.Cainfo
  39300. res.WarnMsg = resSix10265.WarnMsg
  39301. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39302. res.Infcode = infocode
  39303. if infocode == 0 {
  39304. c.ServeSuccessJSON(map[string]interface{}{
  39305. "msg": "上传成功",
  39306. })
  39307. return
  39308. } else {
  39309. c.ServeSuccessJSON(map[string]interface{}{
  39310. "failed_code": -10,
  39311. "msg": res.ErrMsg,
  39312. })
  39313. return
  39314. }
  39315. }
  39316. func (c *HisApiController) Post3504() {
  39317. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39318. data := make(map[string]interface{})
  39319. var struct3501s []models.Struct3501
  39320. var struct3501 models.Struct3501
  39321. struct3501.OrgName = miConfig.OrgName
  39322. struct3501.AccessKey = miConfig.AccessKey
  39323. struct3501.RequestUrl = miConfig.Url
  39324. struct3501.SecretKey = miConfig.SecretKey
  39325. struct3501.ManuDate = "2022-08-15"
  39326. struct3501.FixmedinsBchno = ""
  39327. struct3501.ManuLotnum = ""
  39328. struct3501.RxFlag = "0"
  39329. struct3501.ExpyEnd = "2022-08-15"
  39330. struct3501.Invdate = "2022-08-15"
  39331. struct3501.InvCnt = "20.25"
  39332. struct3501.Memo = ""
  39333. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39334. struct3501.FixmedinsHilistId = miConfig.Code
  39335. struct3501.FixmedinsHilistName = miConfig.OrgName
  39336. struct3501s = append(struct3501s, struct3501)
  39337. data["struct_3501s"] = struct3501s
  39338. client := &http.Client{}
  39339. bytesData, _ := json.Marshal(data)
  39340. var req *http.Request
  39341. if miConfig.MdtrtareaAdmvs == "320921" {
  39342. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39343. } else {
  39344. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39345. }
  39346. resp, _ := client.Do(req)
  39347. defer resp.Body.Close()
  39348. body, ioErr := ioutil.ReadAll(resp.Body)
  39349. if ioErr != nil {
  39350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39352. return
  39353. }
  39354. var respJSON map[string]interface{}
  39355. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39358. return
  39359. }
  39360. var res ResultSix
  39361. var resSix10265 ResultSix10265 //1101结果
  39362. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39363. result, _ := json.Marshal(respJSON)
  39364. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39365. utils.ErrorLog("解析失败:%v", err)
  39366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39367. return
  39368. }
  39369. res.InfRefmsgid = resSix10265.InfRefmsgid
  39370. res.Output = resSix10265.Output
  39371. res.ErrMsg = resSix10265.ErrMsg
  39372. res.Cainfo = resSix10265.Cainfo
  39373. res.WarnMsg = resSix10265.WarnMsg
  39374. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39375. res.Infcode = infocode
  39376. if infocode == 0 {
  39377. c.ServeSuccessJSON(map[string]interface{}{
  39378. "msg": "上传成功",
  39379. })
  39380. return
  39381. } else {
  39382. c.ServeSuccessJSON(map[string]interface{}{
  39383. "failed_code": -10,
  39384. "msg": res.ErrMsg,
  39385. })
  39386. return
  39387. }
  39388. }
  39389. func (c *HisApiController) Post3505() {
  39390. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39391. data := make(map[string]interface{})
  39392. var struct3501s []models.Struct3501
  39393. var struct3501 models.Struct3501
  39394. struct3501.OrgName = miConfig.OrgName
  39395. struct3501.AccessKey = miConfig.AccessKey
  39396. struct3501.RequestUrl = miConfig.Url
  39397. struct3501.SecretKey = miConfig.SecretKey
  39398. struct3501.ManuDate = "2022-08-15"
  39399. struct3501.FixmedinsBchno = ""
  39400. struct3501.ManuLotnum = ""
  39401. struct3501.RxFlag = "0"
  39402. struct3501.ExpyEnd = "2022-08-15"
  39403. struct3501.Invdate = "2022-08-15"
  39404. struct3501.InvCnt = "20.25"
  39405. struct3501.Memo = ""
  39406. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39407. struct3501.FixmedinsHilistId = miConfig.Code
  39408. struct3501.FixmedinsHilistName = miConfig.OrgName
  39409. struct3501s = append(struct3501s, struct3501)
  39410. data["struct_3501s"] = struct3501s
  39411. client := &http.Client{}
  39412. bytesData, _ := json.Marshal(data)
  39413. var req *http.Request
  39414. if miConfig.MdtrtareaAdmvs == "320921" {
  39415. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39416. } else {
  39417. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39418. }
  39419. resp, _ := client.Do(req)
  39420. defer resp.Body.Close()
  39421. body, ioErr := ioutil.ReadAll(resp.Body)
  39422. if ioErr != nil {
  39423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39425. return
  39426. }
  39427. var respJSON map[string]interface{}
  39428. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39431. return
  39432. }
  39433. var res ResultSix
  39434. var resSix10265 ResultSix10265 //1101结果
  39435. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39436. result, _ := json.Marshal(respJSON)
  39437. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39438. utils.ErrorLog("解析失败:%v", err)
  39439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39440. return
  39441. }
  39442. res.InfRefmsgid = resSix10265.InfRefmsgid
  39443. res.Output = resSix10265.Output
  39444. res.ErrMsg = resSix10265.ErrMsg
  39445. res.Cainfo = resSix10265.Cainfo
  39446. res.WarnMsg = resSix10265.WarnMsg
  39447. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39448. res.Infcode = infocode
  39449. if infocode == 0 {
  39450. c.ServeSuccessJSON(map[string]interface{}{
  39451. "msg": "上传成功",
  39452. })
  39453. return
  39454. } else {
  39455. c.ServeSuccessJSON(map[string]interface{}{
  39456. "failed_code": -10,
  39457. "msg": res.ErrMsg,
  39458. })
  39459. return
  39460. }
  39461. }
  39462. func (c *HisApiController) Post3506() {
  39463. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39464. data := make(map[string]interface{})
  39465. var struct3501s []models.Struct3501
  39466. var struct3501 models.Struct3501
  39467. struct3501.OrgName = miConfig.OrgName
  39468. struct3501.AccessKey = miConfig.AccessKey
  39469. struct3501.RequestUrl = miConfig.Url
  39470. struct3501.SecretKey = miConfig.SecretKey
  39471. struct3501.ManuDate = "2022-08-15"
  39472. struct3501.FixmedinsBchno = ""
  39473. struct3501.ManuLotnum = ""
  39474. struct3501.RxFlag = "0"
  39475. struct3501.ExpyEnd = "2022-08-15"
  39476. struct3501.Invdate = "2022-08-15"
  39477. struct3501.InvCnt = "20.25"
  39478. struct3501.Memo = ""
  39479. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39480. struct3501.FixmedinsHilistId = miConfig.Code
  39481. struct3501.FixmedinsHilistName = miConfig.OrgName
  39482. struct3501s = append(struct3501s, struct3501)
  39483. data["struct_3501s"] = struct3501s
  39484. client := &http.Client{}
  39485. bytesData, _ := json.Marshal(data)
  39486. var req *http.Request
  39487. if miConfig.MdtrtareaAdmvs == "320921" {
  39488. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39489. } else {
  39490. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39491. }
  39492. resp, _ := client.Do(req)
  39493. defer resp.Body.Close()
  39494. body, ioErr := ioutil.ReadAll(resp.Body)
  39495. if ioErr != nil {
  39496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39498. return
  39499. }
  39500. var respJSON map[string]interface{}
  39501. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39504. return
  39505. }
  39506. var res ResultSix
  39507. var resSix10265 ResultSix10265 //1101结果
  39508. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39509. result, _ := json.Marshal(respJSON)
  39510. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39511. utils.ErrorLog("解析失败:%v", err)
  39512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39513. return
  39514. }
  39515. res.InfRefmsgid = resSix10265.InfRefmsgid
  39516. res.Output = resSix10265.Output
  39517. res.ErrMsg = resSix10265.ErrMsg
  39518. res.Cainfo = resSix10265.Cainfo
  39519. res.WarnMsg = resSix10265.WarnMsg
  39520. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39521. res.Infcode = infocode
  39522. if infocode == 0 {
  39523. c.ServeSuccessJSON(map[string]interface{}{
  39524. "msg": "上传成功",
  39525. })
  39526. return
  39527. } else {
  39528. c.ServeSuccessJSON(map[string]interface{}{
  39529. "failed_code": -10,
  39530. "msg": res.ErrMsg,
  39531. })
  39532. return
  39533. }
  39534. }
  39535. func (c *HisApiController) Post3507() {
  39536. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39537. data := make(map[string]interface{})
  39538. var struct3501s []models.Struct3501
  39539. var struct3501 models.Struct3501
  39540. struct3501.OrgName = miConfig.OrgName
  39541. struct3501.AccessKey = miConfig.AccessKey
  39542. struct3501.RequestUrl = miConfig.Url
  39543. struct3501.SecretKey = miConfig.SecretKey
  39544. struct3501.ManuDate = "2022-08-15"
  39545. struct3501.FixmedinsBchno = ""
  39546. struct3501.ManuLotnum = ""
  39547. struct3501.RxFlag = "0"
  39548. struct3501.ExpyEnd = "2022-08-15"
  39549. struct3501.Invdate = "2022-08-15"
  39550. struct3501.InvCnt = "20.25"
  39551. struct3501.Memo = ""
  39552. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39553. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39554. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39555. struct3501s = append(struct3501s, struct3501)
  39556. data["struct_3501s"] = struct3501s
  39557. client := &http.Client{}
  39558. bytesData, _ := json.Marshal(data)
  39559. var req *http.Request
  39560. if miConfig.MdtrtareaAdmvs == "320921" {
  39561. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39562. } else {
  39563. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39564. }
  39565. resp, _ := client.Do(req)
  39566. defer resp.Body.Close()
  39567. body, ioErr := ioutil.ReadAll(resp.Body)
  39568. if ioErr != nil {
  39569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39571. return
  39572. }
  39573. var respJSON map[string]interface{}
  39574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39577. return
  39578. }
  39579. var res ResultSix
  39580. var resSix10265 ResultSix10265 //1101结果
  39581. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39582. result, _ := json.Marshal(respJSON)
  39583. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39584. utils.ErrorLog("解析失败:%v", err)
  39585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39586. return
  39587. }
  39588. res.InfRefmsgid = resSix10265.InfRefmsgid
  39589. res.Output = resSix10265.Output
  39590. res.ErrMsg = resSix10265.ErrMsg
  39591. res.Cainfo = resSix10265.Cainfo
  39592. res.WarnMsg = resSix10265.WarnMsg
  39593. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39594. res.Infcode = infocode
  39595. if infocode == 0 {
  39596. c.ServeSuccessJSON(map[string]interface{}{
  39597. "msg": "上传成功",
  39598. })
  39599. return
  39600. } else {
  39601. c.ServeSuccessJSON(map[string]interface{}{
  39602. "failed_code": -10,
  39603. "msg": res.ErrMsg,
  39604. })
  39605. return
  39606. }
  39607. }
  39608. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39609. // WebSocket服务器地址
  39610. serverURL := "ws://127.0.0.1:8899"
  39611. // 解析WebSocket服务器地址
  39612. u, err := url.Parse(serverURL)
  39613. if err != nil {
  39614. }
  39615. // 建立WebSocket连接
  39616. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39617. if err != nil {
  39618. }
  39619. defer conn.Close()
  39620. input2 := make(map[string]interface{})
  39621. input := make(map[string]interface{})
  39622. inputData := make(map[string]interface{})
  39623. inputData["orgId"] = code
  39624. inputData["businessType"] = "01101"
  39625. inputData["operatorId"] = operator_id
  39626. inputData["operatorName"] = operator_name
  39627. inputData["officeId"] = "001"
  39628. inputData["officeName"] = "血透室"
  39629. inputData["deviceType"] = ""
  39630. input["data"] = inputData
  39631. input["orgId"] = code
  39632. input["transType"] = "ec.query"
  39633. //if md == ""
  39634. if md[:4] == "4403" {
  39635. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39636. } else if md[:4] == "4401" {
  39637. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39638. } else {
  39639. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39640. }
  39641. input2["indata"] = input
  39642. fmt.Println(input2)
  39643. bytesData, _ := json.Marshal(input2)
  39644. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39645. if err != nil {
  39646. fmt.Println(err)
  39647. }
  39648. // 接收消息
  39649. _, receivedMessage, err := conn.ReadMessage()
  39650. if err != nil {
  39651. fmt.Println(err)
  39652. }
  39653. return "", string(receivedMessage)
  39654. }
  39655. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39656. // WebSocket服务器地址
  39657. serverURL := "ws://127.0.0.1:8899"
  39658. // 解析WebSocket服务器地址
  39659. u, err := url.Parse(serverURL)
  39660. if err != nil {
  39661. }
  39662. // 建立WebSocket连接
  39663. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39664. if err != nil {
  39665. }
  39666. defer conn.Close()
  39667. input2 := make(map[string]interface{})
  39668. input := make(map[string]interface{})
  39669. inputData := make(map[string]interface{})
  39670. inputData["orgId"] = code
  39671. inputData["businessType"] = "01101"
  39672. inputData["operatorId"] = operator_id
  39673. inputData["operatorName"] = operator_name
  39674. inputData["officeId"] = "001"
  39675. inputData["officeName"] = "血透室"
  39676. inputData["deviceType"] = ""
  39677. input["data"] = inputData
  39678. input["orgId"] = code
  39679. input["transType"] = "ec.query"
  39680. //if md == ""
  39681. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39682. input2["indata"] = input
  39683. fmt.Println(input2)
  39684. bytesData, _ := json.Marshal(input2)
  39685. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39686. if err != nil {
  39687. fmt.Println(err)
  39688. }
  39689. // 接收消息
  39690. _, receivedMessage, err := conn.ReadMessage()
  39691. if err != nil {
  39692. fmt.Println(err)
  39693. }
  39694. return "", string(receivedMessage)
  39695. }
  39696. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39697. // WebSocket服务器地址
  39698. serverURL := "ws://127.0.0.1:8899"
  39699. // 解析WebSocket服务器地址
  39700. u, err := url.Parse(serverURL)
  39701. if err != nil {
  39702. }
  39703. // 建立WebSocket连接
  39704. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39705. if err != nil {
  39706. }
  39707. defer conn.Close()
  39708. input2 := make(map[string]interface{})
  39709. input := make(map[string]interface{})
  39710. inputData := make(map[string]interface{})
  39711. inputData["orgId"] = code
  39712. inputData["businessType"] = "01301"
  39713. inputData["operatorId"] = operator_id
  39714. inputData["operatorName"] = operator_name
  39715. inputData["officeId"] = "001"
  39716. inputData["officeName"] = "血透室"
  39717. inputData["deviceType"] = ""
  39718. input["data"] = inputData
  39719. input["orgId"] = code
  39720. input["transType"] = "ec.query"
  39721. //if md == ""
  39722. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39723. input2["indata"] = input
  39724. fmt.Println(input2)
  39725. bytesData, _ := json.Marshal(input2)
  39726. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39727. if err != nil {
  39728. fmt.Println(err)
  39729. }
  39730. // 接收消息
  39731. _, receivedMessage, err := conn.ReadMessage()
  39732. if err != nil {
  39733. fmt.Println(err)
  39734. }
  39735. return "", string(receivedMessage)
  39736. }
  39737. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39738. // WebSocket服务器地址
  39739. serverURL := "ws://127.0.0.1:8899"
  39740. // 解析WebSocket服务器地址
  39741. u, err := url.Parse(serverURL)
  39742. if err != nil {
  39743. }
  39744. // 建立WebSocket连接
  39745. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39746. if err != nil {
  39747. }
  39748. defer conn.Close()
  39749. input2 := make(map[string]interface{})
  39750. input := make(map[string]interface{})
  39751. inputData := make(map[string]interface{})
  39752. inputData["orgId"] = code
  39753. inputData["businessType"] = "01103"
  39754. inputData["operatorId"] = operator_id
  39755. inputData["operatorName"] = operator_name
  39756. inputData["officeId"] = "001"
  39757. inputData["officeName"] = "血透室"
  39758. inputData["deviceType"] = ""
  39759. input["data"] = inputData
  39760. input["orgId"] = code
  39761. input["transType"] = "ec.query"
  39762. //if md ==
  39763. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39764. input2["indata"] = input
  39765. fmt.Println(input2)
  39766. bytesData, _ := json.Marshal(input2)
  39767. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39768. if err != nil {
  39769. fmt.Println(err)
  39770. }
  39771. // 接收消息
  39772. _, receivedMessage, err := conn.ReadMessage()
  39773. if err != nil {
  39774. fmt.Println(err)
  39775. }
  39776. return "", string(receivedMessage)
  39777. }
  39778. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39779. // WebSocket服务器地址
  39780. serverURL := "ws://127.0.0.1:8899"
  39781. // 解析WebSocket服务器地址
  39782. u, err := url.Parse(serverURL)
  39783. if err != nil {
  39784. }
  39785. // 建立WebSocket连接
  39786. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39787. if err != nil {
  39788. }
  39789. defer conn.Close()
  39790. input2 := make(map[string]interface{})
  39791. input := make(map[string]interface{})
  39792. inputData := make(map[string]interface{})
  39793. inputData["orgId"] = code
  39794. inputData["businessType"] = "01101"
  39795. inputData["operatorId"] = operator_id
  39796. inputData["operatorName"] = operator_name
  39797. inputData["officeId"] = "001"
  39798. inputData["officeName"] = "血透室"
  39799. inputData["deviceType"] = ""
  39800. input["data"] = inputData
  39801. input["orgId"] = code
  39802. input["transType"] = "ec.query"
  39803. //if md == ""
  39804. if md[:4] == "4403" {
  39805. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39806. } else if md[:4] == "4401" {
  39807. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39808. } else {
  39809. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39810. }
  39811. input2["indata"] = input
  39812. fmt.Println(input2)
  39813. bytesData, _ := json.Marshal(input2)
  39814. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39815. if err != nil {
  39816. fmt.Println(err)
  39817. }
  39818. // 接收消息
  39819. _, receivedMessage, err := conn.ReadMessage()
  39820. if err != nil {
  39821. fmt.Println(err)
  39822. }
  39823. return "", string(receivedMessage)
  39824. }
  39825. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39826. // WebSocket服务器地址
  39827. serverURL := "ws://127.0.0.1:8899"
  39828. // 解析WebSocket服务器地址
  39829. u, err := url.Parse(serverURL)
  39830. if err != nil {
  39831. }
  39832. // 建立WebSocket连接
  39833. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39834. if err != nil {
  39835. }
  39836. defer conn.Close()
  39837. input2 := make(map[string]interface{})
  39838. input := make(map[string]interface{})
  39839. inputData := make(map[string]interface{})
  39840. inputData["orgId"] = code
  39841. inputData["businessType"] = "01301"
  39842. inputData["operatorId"] = operator_id
  39843. inputData["operatorName"] = operator_name
  39844. inputData["officeId"] = "001"
  39845. inputData["officeName"] = "血透室"
  39846. inputData["deviceType"] = ""
  39847. input["data"] = inputData
  39848. input["orgId"] = code
  39849. input["transType"] = "ec.query"
  39850. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39851. input2["indata"] = input
  39852. bytesData, _ := json.Marshal(input2)
  39853. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39854. if err != nil {
  39855. fmt.Println(err)
  39856. }
  39857. // 接收消息
  39858. _, receivedMessage, err := conn.ReadMessage()
  39859. if err != nil {
  39860. fmt.Println(err)
  39861. }
  39862. return "", string(receivedMessage)
  39863. }
  39864. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39865. newArr = make([]string, 0)
  39866. for i := 0; i < len(arr); i++ {
  39867. repeat := false
  39868. for j := i + 1; j < len(arr); j++ {
  39869. if arr[i] == arr[j] {
  39870. repeat = true
  39871. break
  39872. }
  39873. }
  39874. if !repeat {
  39875. newArr = append(newArr, arr[i])
  39876. }
  39877. }
  39878. return
  39879. }
  39880. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39881. if len(idNumber) != 18 {
  39882. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39883. }
  39884. // 提取出生日期
  39885. year, err := strconv.Atoi(idNumber[6:10])
  39886. if err != nil {
  39887. return "", 0, err
  39888. }
  39889. month, err := strconv.Atoi(idNumber[10:12])
  39890. if err != nil {
  39891. return "", 0, err
  39892. }
  39893. day, err := strconv.Atoi(idNumber[12:14])
  39894. if err != nil {
  39895. return "", 0, err
  39896. }
  39897. // 格式化生日字符串
  39898. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39899. birthdateFormatted := birthdate.Format("2006-01-02")
  39900. // 计算年龄
  39901. today := time.Now()
  39902. age := today.Year() - birthdate.Year()
  39903. if today.YearDay() < birthdate.YearDay() {
  39904. age--
  39905. }
  39906. return birthdateFormatted, age, nil
  39907. }
  39908. // 从身份证号码中提取出生年月日
  39909. func getBirthDateFromIDCard(idCard string) (string, error) {
  39910. // 身份证号码长度应为18位
  39911. if len(idCard) != 18 {
  39912. return "", fmt.Errorf("身份证号码长度应为18位")
  39913. }
  39914. // 提取出生日期部分 (YYYYMMDD)
  39915. birthDateStr := idCard[6:14]
  39916. // 解析出生日期
  39917. birthDate, err := time.Parse("20060102", birthDateStr)
  39918. if err != nil {
  39919. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39920. }
  39921. // 格式化出生日期为 YYYY-MM-DD
  39922. formattedDate := birthDate.Format("2006-01-02")
  39923. return formattedDate, nil
  39924. }