his_api_controller.go 1.6MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. "github.com/go-ole/go-ole"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  42. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  43. //上传就诊信息-上传明细-结算
  44. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  45. //查询
  46. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  47. //对总账
  48. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  49. //对明细
  50. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  51. //退费,退明细
  52. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  53. //退号
  54. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  55. //退明细
  56. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  57. //上传就诊信息-上传明细-预结算
  58. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  59. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  60. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  61. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  62. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  63. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  64. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  65. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  66. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  67. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  68. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  69. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  70. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  71. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  72. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  73. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  74. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  75. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  76. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  81. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  82. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  83. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  84. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  85. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  86. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  87. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  88. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  89. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  90. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  91. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  92. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  93. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  94. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  95. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  96. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  97. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  98. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  99. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  100. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  101. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  102. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  103. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  107. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  108. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  109. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  110. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  111. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  112. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  113. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  114. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  115. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  116. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  117. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  118. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  119. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  120. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  121. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  122. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  123. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  124. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  125. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  126. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  127. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  128. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  129. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  130. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  131. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  132. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  133. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  134. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  135. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  136. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  137. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  138. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  139. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  140. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  141. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  142. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  143. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  144. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  145. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  146. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  147. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  148. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  149. //库盘和变更
  150. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  151. //删除库盘和变更
  152. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  153. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  154. //药品变更
  155. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  156. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  157. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  158. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  159. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  160. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  161. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  162. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  163. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  164. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  165. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  166. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  167. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  168. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  169. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  170. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  171. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  172. }
  173. func (c *HisApiController) Get3201() {
  174. adminUser := c.GetAdminUserInfo()
  175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  176. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  177. var response Response
  178. if err := json.Unmarshal([]byte(result), &response); err != nil {
  179. fmt.Println("Error decoding JSON:", err)
  180. return
  181. }
  182. }
  183. func (c *HisApiController) TestNet() {
  184. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  185. //return
  186. c.ServeSuccessJSON(map[string]interface{}{
  187. "msg": "成功",
  188. })
  189. }
  190. func (c *HisApiController) Get3508() {
  191. admin_user_id, _ := c.GetInt64("admin_user_id")
  192. drug_id, _ := c.GetInt64("id")
  193. start_time := c.GetString("start_time")
  194. end_time := c.GetString("end_time")
  195. adminUser := c.GetAdminUserInfo()
  196. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  197. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  198. drug, _ := service.GetDrugByID(drug_id)
  199. var struct3508 models.Struct3508
  200. struct3508.OrgName = miConfig.OrgName
  201. struct3508.FixmedinsCode = miConfig.Code
  202. struct3508.AccessKey = miConfig.AccessKey
  203. struct3508.Opter = curRoles.UserName
  204. struct3508.RequestUrl = miConfig.Url
  205. struct3508.Url = miConfig.Url
  206. struct3508.AppId = miConfig.Cainfo
  207. struct3508.AppSecret = miConfig.AppSecret
  208. struct3508.Enckey = miConfig.EncKey
  209. struct3508.SignKey = miConfig.SignKey
  210. struct3508.SecretKey = miConfig.SecretKey
  211. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  212. struct3508.Begndate = start_time
  213. struct3508.Enddate = end_time
  214. result1, result2, _ := service.FJyb3508(struct3508)
  215. saveLog(result1, result2, "3508", "3508")
  216. var res models.Result3508
  217. var respJSON2 map[string]interface{}
  218. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. userJSONBytes2, _ := json.Marshal(respJSON2)
  224. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  227. return
  228. }
  229. if res.Infcode == -1 {
  230. c.ServeSuccessJSON(map[string]interface{}{
  231. "failed_code": -10,
  232. "msg": res.ErrMsg,
  233. })
  234. } else {
  235. c.ServeSuccessJSON(map[string]interface{}{
  236. "info": res.Output,
  237. })
  238. }
  239. }
  240. func (c *HisApiController) Get3509() {
  241. admin_user_id, _ := c.GetInt64("admin_user_id")
  242. drug_id, _ := c.GetInt64("id")
  243. start_time := c.GetString("start_time")
  244. end_time := c.GetString("end_time")
  245. adminUser := c.GetAdminUserInfo()
  246. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  248. drug, _ := service.GetDrugByID(drug_id)
  249. var struct3508 models.Struct3509
  250. struct3508.OrgName = miConfig.OrgName
  251. struct3508.FixmedinsCode = miConfig.Code
  252. struct3508.AccessKey = miConfig.AccessKey
  253. struct3508.Opter = curRoles.UserName
  254. struct3508.RequestUrl = miConfig.Url
  255. struct3508.Url = miConfig.Url
  256. struct3508.AppId = miConfig.Cainfo
  257. struct3508.AppSecret = miConfig.AppSecret
  258. struct3508.Enckey = miConfig.EncKey
  259. struct3508.SignKey = miConfig.SignKey
  260. struct3508.SecretKey = miConfig.SecretKey
  261. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  262. struct3508.Begndate = start_time
  263. struct3508.Enddate = end_time
  264. result1, result2, _ := service.FJyb3509(struct3508)
  265. saveLog(result1, result2, "3509", "3509")
  266. var res models.Result3509
  267. var respJSON2 map[string]interface{}
  268. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  271. return
  272. }
  273. userJSONBytes2, _ := json.Marshal(respJSON2)
  274. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  275. utils.ErrorLog("解析失败:%v", err)
  276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  277. return
  278. }
  279. if res.Infcode == -1 {
  280. c.ServeSuccessJSON(map[string]interface{}{
  281. "failed_code": -10,
  282. "msg": res.ErrMsg,
  283. })
  284. } else {
  285. c.ServeSuccessJSON(map[string]interface{}{
  286. "info": res.Output,
  287. })
  288. }
  289. }
  290. func (c *HisApiController) Get3510() {
  291. admin_user_id, _ := c.GetInt64("admin_user_id")
  292. drug_id, _ := c.GetInt64("id")
  293. start_time := c.GetString("start_time")
  294. end_time := c.GetString("end_time")
  295. adminUser := c.GetAdminUserInfo()
  296. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  297. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  298. drug, _ := service.GetDrugByID(drug_id)
  299. var struct3508 models.Struct3510
  300. struct3508.FixmedinsCode = miConfig.Code
  301. struct3508.OrgName = miConfig.OrgName
  302. struct3508.AccessKey = miConfig.AccessKey
  303. struct3508.Opter = curRoles.UserName
  304. struct3508.RequestUrl = miConfig.Url
  305. struct3508.Url = miConfig.Url
  306. struct3508.AppId = miConfig.Cainfo
  307. struct3508.AppSecret = miConfig.AppSecret
  308. struct3508.Enckey = miConfig.EncKey
  309. struct3508.SignKey = miConfig.SignKey
  310. struct3508.SecretKey = miConfig.SecretKey
  311. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  312. struct3508.Begndate = start_time
  313. struct3508.Enddate = end_time
  314. result1, result2, _ := service.FJyb3510(struct3508)
  315. saveLog(result1, result2, "3510", "3510")
  316. var res models.Result3510
  317. var respJSON2 map[string]interface{}
  318. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  321. return
  322. }
  323. userJSONBytes2, _ := json.Marshal(respJSON2)
  324. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  325. utils.ErrorLog("解析失败:%v", err)
  326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  327. return
  328. }
  329. if res.Infcode == -1 {
  330. c.ServeSuccessJSON(map[string]interface{}{
  331. "failed_code": -10,
  332. "msg": res.ErrMsg,
  333. })
  334. } else {
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "info": res.Output,
  337. })
  338. }
  339. }
  340. func (c *HisApiController) Get3511() {
  341. admin_user_id, _ := c.GetInt64("admin_user_id")
  342. drug_id, _ := c.GetInt64("id")
  343. start_time := c.GetString("start_time")
  344. end_time := c.GetString("end_time")
  345. adminUser := c.GetAdminUserInfo()
  346. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  348. drug, _ := service.GetDrugByID(drug_id)
  349. var struct3508 models.Struct3511
  350. struct3508.FixmedinsCode = miConfig.Code
  351. struct3508.OrgName = miConfig.OrgName
  352. struct3508.AccessKey = miConfig.AccessKey
  353. struct3508.Opter = curRoles.UserName
  354. struct3508.RequestUrl = miConfig.Url
  355. struct3508.Url = miConfig.Url
  356. struct3508.AppId = miConfig.Cainfo
  357. struct3508.AppSecret = miConfig.AppSecret
  358. struct3508.Enckey = miConfig.EncKey
  359. struct3508.SignKey = miConfig.SignKey
  360. struct3508.SecretKey = miConfig.SecretKey
  361. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  362. struct3508.Begndate = start_time
  363. struct3508.Enddate = end_time
  364. result1, result2, _ := service.FJyb3511(struct3508)
  365. saveLog(result1, result2, "3511", "3511")
  366. var res models.Result3511
  367. var respJSON2 map[string]interface{}
  368. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  371. return
  372. }
  373. userJSONBytes2, _ := json.Marshal(respJSON2)
  374. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  375. utils.ErrorLog("解析失败:%v", err)
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  377. return
  378. }
  379. if res.Infcode == -1 {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. } else {
  385. c.ServeSuccessJSON(map[string]interface{}{
  386. "info": res.Output,
  387. })
  388. }
  389. }
  390. func (c *HisApiController) Get3512() {
  391. admin_user_id, _ := c.GetInt64("admin_user_id")
  392. drug_id, _ := c.GetInt64("id")
  393. start_time := c.GetString("start_time")
  394. end_time := c.GetString("end_time")
  395. adminUser := c.GetAdminUserInfo()
  396. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  397. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  398. drug, _ := service.GetDrugByID(drug_id)
  399. var struct3508 models.Struct3512
  400. struct3508.FixmedinsCode = miConfig.Code
  401. struct3508.OrgName = miConfig.OrgName
  402. struct3508.AccessKey = miConfig.AccessKey
  403. struct3508.Opter = curRoles.UserName
  404. struct3508.RequestUrl = miConfig.Url
  405. struct3508.Url = miConfig.Url
  406. struct3508.AppId = miConfig.Cainfo
  407. struct3508.AppSecret = miConfig.AppSecret
  408. struct3508.Enckey = miConfig.EncKey
  409. struct3508.SignKey = miConfig.SignKey
  410. struct3508.SecretKey = miConfig.SecretKey
  411. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  412. struct3508.Begndate = start_time
  413. struct3508.Enddate = end_time
  414. result1, result2, _ := service.FJyb3512(struct3508)
  415. saveLog(result1, result2, "3512", "3512")
  416. var res models.Result3512
  417. var respJSON2 map[string]interface{}
  418. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  421. return
  422. }
  423. userJSONBytes2, _ := json.Marshal(respJSON2)
  424. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == -1 {
  430. c.ServeSuccessJSON(map[string]interface{}{
  431. "failed_code": -10,
  432. "msg": res.ErrMsg,
  433. })
  434. } else {
  435. c.ServeSuccessJSON(map[string]interface{}{
  436. "info": res.Output,
  437. })
  438. }
  439. }
  440. func (c *HisApiController) Get3513() {
  441. admin_user_id, _ := c.GetInt64("admin_user_id")
  442. drug_id, _ := c.GetInt64("id")
  443. start_time := c.GetString("start_time")
  444. end_time := c.GetString("end_time")
  445. adminUser := c.GetAdminUserInfo()
  446. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  447. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  448. drug, _ := service.GetDrugByID(drug_id)
  449. var struct3508 models.Struct3513
  450. struct3508.FixmedinsCode = miConfig.Code
  451. struct3508.OrgName = miConfig.OrgName
  452. struct3508.AccessKey = miConfig.AccessKey
  453. struct3508.Opter = curRoles.UserName
  454. struct3508.RequestUrl = miConfig.Url
  455. struct3508.Url = miConfig.Url
  456. struct3508.AppId = miConfig.Cainfo
  457. struct3508.AppSecret = miConfig.AppSecret
  458. struct3508.Enckey = miConfig.EncKey
  459. struct3508.SignKey = miConfig.SignKey
  460. struct3508.SecretKey = miConfig.SecretKey
  461. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  462. struct3508.Begndate = start_time
  463. struct3508.Enddate = end_time
  464. result1, result2, _ := service.FJyb3513(struct3508)
  465. saveLog(result1, result2, "3513", "3513")
  466. var res models.Result3513
  467. var respJSON2 map[string]interface{}
  468. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  471. return
  472. }
  473. userJSONBytes2, _ := json.Marshal(respJSON2)
  474. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  475. utils.ErrorLog("解析失败:%v", err)
  476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  477. return
  478. }
  479. if res.Infcode == -1 {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "failed_code": -10,
  482. "msg": res.ErrMsg,
  483. })
  484. } else {
  485. c.ServeSuccessJSON(map[string]interface{}{
  486. "info": res.Output,
  487. })
  488. }
  489. }
  490. func (c *HisApiController) Get35081() {
  491. admin_user_id, _ := c.GetInt64("admin_user_id")
  492. drug_id, _ := c.GetInt64("id")
  493. //start_time := c.GetString("start_time")
  494. //end_time := c.GetString("end_time")
  495. page, _ := c.GetInt("page")
  496. adminUser := c.GetAdminUserInfo()
  497. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  498. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  499. drug, _ := service.GetDrugByID(drug_id)
  500. var struct3508 models.Struct35081
  501. struct3508.FixmedinsCode = miConfig.Code
  502. struct3508.OrgName = miConfig.OrgName
  503. struct3508.AccessKey = miConfig.AccessKey
  504. struct3508.Opter = curRoles.UserName
  505. struct3508.RequestUrl = miConfig.Url
  506. struct3508.Url = miConfig.Url
  507. struct3508.AppId = miConfig.Cainfo
  508. struct3508.AppSecret = miConfig.AppSecret
  509. struct3508.Enckey = miConfig.EncKey
  510. struct3508.SignKey = miConfig.SignKey
  511. struct3508.SecretKey = miConfig.SecretKey
  512. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  513. struct3508.PageNum = page
  514. struct3508.PageSize = 10
  515. result1, result2, _ := service.FJyb35081(struct3508)
  516. saveLog(result1, result2, "35081", "35081")
  517. var res models.Result35081
  518. var respJSON2 map[string]interface{}
  519. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  522. return
  523. }
  524. userJSONBytes2, _ := json.Marshal(respJSON2)
  525. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  526. utils.ErrorLog("解析失败:%v", err)
  527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  528. return
  529. }
  530. if res.Infcode == -1 {
  531. c.ServeSuccessJSON(map[string]interface{}{
  532. "failed_code": -10,
  533. "msg": res.ErrMsg,
  534. })
  535. } else {
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "info": res.Output,
  538. })
  539. }
  540. }
  541. func (c *HisApiController) Get35082() {
  542. admin_user_id, _ := c.GetInt64("admin_user_id")
  543. drug_id, _ := c.GetInt64("id")
  544. //start_time := c.GetString("start_time")
  545. //end_time := c.GetString("end_time")
  546. page, _ := c.GetInt("page")
  547. adminUser := c.GetAdminUserInfo()
  548. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  550. drug, _ := service.GetDrugByID(drug_id)
  551. var struct3508 models.Struct35082
  552. struct3508.FixmedinsCode = miConfig.Code
  553. struct3508.OrgName = miConfig.OrgName
  554. struct3508.AccessKey = miConfig.AccessKey
  555. struct3508.Opter = curRoles.UserName
  556. struct3508.RequestUrl = miConfig.Url
  557. struct3508.Url = miConfig.Url
  558. struct3508.AppId = miConfig.Cainfo
  559. struct3508.AppSecret = miConfig.AppSecret
  560. struct3508.Enckey = miConfig.EncKey
  561. struct3508.SignKey = miConfig.SignKey
  562. struct3508.SecretKey = miConfig.SecretKey
  563. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  564. struct3508.PageNum = page
  565. struct3508.PageSize = 10
  566. result1, result2, _ := service.FJyb35082(struct3508)
  567. saveLog(result1, result2, "35082", "35082")
  568. var res models.Result35082
  569. var respJSON2 map[string]interface{}
  570. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  573. return
  574. }
  575. userJSONBytes2, _ := json.Marshal(respJSON2)
  576. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  577. utils.ErrorLog("解析失败:%v", err)
  578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  579. return
  580. }
  581. if res.Infcode == -1 {
  582. c.ServeSuccessJSON(map[string]interface{}{
  583. "failed_code": -10,
  584. "msg": res.ErrMsg,
  585. })
  586. } else {
  587. c.ServeSuccessJSON(map[string]interface{}{
  588. "info": res.Output,
  589. })
  590. }
  591. }
  592. func (c *HisApiController) FJ3501AND3502() {
  593. ids := c.GetString("ids")
  594. admin_user_id, _ := c.GetInt64("admin_user_id")
  595. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  596. id_arr := strings.Split(ids, ",")
  597. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  598. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  599. //库盘
  600. var errs []string
  601. for _, drug := range drugs {
  602. if drug.IsPc == 0 {
  603. var res2 ResultSix
  604. var res3 ResultSix
  605. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  606. var struct3501 models.Struct3501
  607. struct3501.Code = miConfig.Code
  608. struct3501.OrgName = miConfig.OrgName
  609. struct3501.AccessKey = miConfig.AccessKey
  610. struct3501.Opter = roles.UserName
  611. struct3501.RequestUrl = miConfig.Url
  612. struct3501.Url = miConfig.Url
  613. struct3501.AppId = miConfig.Cainfo
  614. struct3501.AppSecret = miConfig.AppSecret
  615. struct3501.Enckey = miConfig.EncKey
  616. struct3501.SignKey = miConfig.SignKey
  617. struct3501.SecretKey = miConfig.SecretKey
  618. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  620. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  621. struct3501.RxFlag = "1"
  622. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  623. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  624. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  625. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  626. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  627. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  628. struct3501.FixmedinsBchno = number
  629. struct3501.DrugTracCodg = drug.DrugCode
  630. memo := make(map[string]interface{})
  631. memo["pric"] = drug.Price
  632. bytesData, _ := json.Marshal(memo)
  633. struct3501.Memo = string(bytesData)
  634. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  635. result1, result2, _ := service.FJyb3501(struct3501)
  636. saveLog(result1, result2, "3501", "3501")
  637. //saveLog(result, requestLog, "2201", "挂号")
  638. var respJSON2 map[string]interface{}
  639. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  642. return
  643. }
  644. userJSONBytes2, _ := json.Marshal(respJSON2)
  645. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  646. utils.ErrorLog("解析失败:%v", err)
  647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  648. return
  649. }
  650. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  651. data := make(map[string]interface{})
  652. data["struct_3501s"] = struct3501
  653. client := &http.Client{}
  654. bytesData, _ := json.Marshal(data)
  655. var req *http.Request
  656. if miConfig.MdtrtareaAdmvs == "320921" {
  657. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  658. } else {
  659. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  660. }
  661. resp, _ := client.Do(req)
  662. defer resp.Body.Close()
  663. body, ioErr := ioutil.ReadAll(resp.Body)
  664. if ioErr != nil {
  665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  666. }
  667. var respJSON map[string]interface{}
  668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. var resSix10265 ResultSix10265 //1101结果
  674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  675. result, _ := json.Marshal(respJSON)
  676. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  677. utils.ErrorLog("解析失败:%v", err)
  678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  679. return
  680. }
  681. res2.InfRefmsgid = resSix10265.InfRefmsgid
  682. res2.Output = resSix10265.Output
  683. res2.ErrMsg = resSix10265.ErrMsg
  684. res2.Cainfo = resSix10265.Cainfo
  685. res2.WarnMsg = resSix10265.WarnMsg
  686. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  687. res2.Infcode = infocode
  688. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  689. data := make(map[string]interface{})
  690. data["struct_3501s"] = struct3501
  691. client := &http.Client{}
  692. bytesData, _ := json.Marshal(data)
  693. var req *http.Request
  694. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  695. resp, _ := client.Do(req)
  696. defer resp.Body.Close()
  697. body, ioErr := ioutil.ReadAll(resp.Body)
  698. if ioErr != nil {
  699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  700. }
  701. var respJSON map[string]interface{}
  702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  705. return
  706. }
  707. var resSix10265 ResultSix10265 //1101结果
  708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  709. result, _ := json.Marshal(respJSON)
  710. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  711. utils.ErrorLog("解析失败:%v", err)
  712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  713. return
  714. }
  715. res2.InfRefmsgid = resSix10265.InfRefmsgid
  716. res2.Output = resSix10265.Output
  717. res2.ErrMsg = resSix10265.ErrMsg
  718. res2.Cainfo = resSix10265.Cainfo
  719. res2.WarnMsg = resSix10265.WarnMsg
  720. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  721. res2.Infcode = infocode
  722. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  723. data := make(map[string]interface{})
  724. data["struct_3501s"] = struct3501
  725. client := &http.Client{}
  726. bytesData, _ := json.Marshal(data)
  727. var req *http.Request
  728. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  729. resp, _ := client.Do(req)
  730. defer resp.Body.Close()
  731. body, ioErr := ioutil.ReadAll(resp.Body)
  732. if ioErr != nil {
  733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  734. }
  735. var respJSON map[string]interface{}
  736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  739. return
  740. }
  741. var resSix10265 ResultSix10265 //1101结果
  742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  743. result, _ := json.Marshal(respJSON)
  744. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  745. utils.ErrorLog("解析失败:%v", err)
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. res2.InfRefmsgid = resSix10265.InfRefmsgid
  750. res2.Output = resSix10265.Output
  751. res2.ErrMsg = resSix10265.ErrMsg
  752. res2.Cainfo = resSix10265.Cainfo
  753. res2.WarnMsg = resSix10265.WarnMsg
  754. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  755. res2.Infcode = infocode
  756. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  757. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  758. saveLog(result1, result2, "3501", "3501")
  759. //saveLog(result, requestLog, "2201", "挂号")
  760. var respJSON2 map[string]interface{}
  761. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. userJSONBytes2, _ := json.Marshal(respJSON2)
  767. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  768. utils.ErrorLog("解析失败:%v", err)
  769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  770. return
  771. }
  772. }
  773. if res2.Infcode != -1 {
  774. drug.IsPc = 1
  775. drug.Bchno = number
  776. drug.PcDate = time.Now().Unix()
  777. err := service.SaveW(drug)
  778. if err == nil {
  779. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  780. var struct3502 models.Struct3502
  781. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  783. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  784. struct3502.FixmedinsCode = miConfig.Code
  785. struct3502.Code = miConfig.Code
  786. struct3502.RxFlag = "0"
  787. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  788. struct3502.OrgName = miConfig.OrgName
  789. struct3502.Opter = roles.UserName
  790. struct3502.AccessKey = miConfig.AccessKey
  791. struct3502.RequestUrl = miConfig.Url
  792. struct3502.SecretKey = miConfig.SecretKey
  793. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  794. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  795. struct3502.Url = miConfig.Url
  796. struct3502.AppId = miConfig.Cainfo
  797. struct3502.AppSecret = miConfig.AppSecret
  798. struct3502.Enckey = miConfig.EncKey
  799. struct3502.SignKey = miConfig.SignKey
  800. struct3502.SecretKey = miConfig.SecretKey
  801. struct3502.DrugTracCodg = drug.DrugCode
  802. struct3502.Memo = ""
  803. struct3502.InvChgType = "108"
  804. struct3502.FixmedinsBchno = bg_number
  805. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  806. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  807. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  808. result11, result22, _ := service.FJyb3502(struct3502)
  809. saveLog(result11, result22, "3502", "3502")
  810. var respJSON3 map[string]interface{}
  811. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. userJSONBytes3, _ := json.Marshal(respJSON3)
  817. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  818. utils.ErrorLog("解析失败:%v", err)
  819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  820. return
  821. }
  822. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  823. data := make(map[string]interface{})
  824. data["struct_3502s"] = struct3502
  825. client := &http.Client{}
  826. bytesData, _ := json.Marshal(data)
  827. var req *http.Request
  828. if miConfig.MdtrtareaAdmvs == "320921" {
  829. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  830. } else {
  831. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  832. }
  833. resp, _ := client.Do(req)
  834. defer resp.Body.Close()
  835. body, ioErr := ioutil.ReadAll(resp.Body)
  836. if ioErr != nil {
  837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  838. }
  839. var respJSON map[string]interface{}
  840. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  843. return
  844. }
  845. var resSix10265 ResultSix10265 //1101结果
  846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  847. result, _ := json.Marshal(respJSON)
  848. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  849. utils.ErrorLog("解析失败:%v", err)
  850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  851. return
  852. }
  853. res3.InfRefmsgid = resSix10265.InfRefmsgid
  854. res3.Output = resSix10265.Output
  855. res3.ErrMsg = resSix10265.ErrMsg
  856. res3.Cainfo = resSix10265.Cainfo
  857. res3.WarnMsg = resSix10265.WarnMsg
  858. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  859. res3.Infcode = infocode
  860. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  861. data := make(map[string]interface{})
  862. data["struct_3502s"] = struct3502
  863. client := &http.Client{}
  864. bytesData, _ := json.Marshal(data)
  865. var req *http.Request
  866. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  867. resp, _ := client.Do(req)
  868. defer resp.Body.Close()
  869. body, ioErr := ioutil.ReadAll(resp.Body)
  870. if ioErr != nil {
  871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  872. }
  873. var respJSON map[string]interface{}
  874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  877. return
  878. }
  879. var resSix10265 ResultSix10265 //1101结果
  880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  881. result, _ := json.Marshal(respJSON)
  882. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  883. utils.ErrorLog("解析失败:%v", err)
  884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  885. return
  886. }
  887. res3.InfRefmsgid = resSix10265.InfRefmsgid
  888. res3.Output = resSix10265.Output
  889. res3.ErrMsg = resSix10265.ErrMsg
  890. res3.Cainfo = resSix10265.Cainfo
  891. res3.WarnMsg = resSix10265.WarnMsg
  892. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  893. res3.Infcode = infocode
  894. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  895. data := make(map[string]interface{})
  896. data["struct_3501s"] = struct3501
  897. client := &http.Client{}
  898. bytesData, _ := json.Marshal(data)
  899. var req *http.Request
  900. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  901. resp, _ := client.Do(req)
  902. defer resp.Body.Close()
  903. body, ioErr := ioutil.ReadAll(resp.Body)
  904. if ioErr != nil {
  905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  906. }
  907. var respJSON map[string]interface{}
  908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. return
  912. }
  913. var resSix10265 ResultSix10265 //1101结果
  914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  915. result, _ := json.Marshal(respJSON)
  916. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  917. utils.ErrorLog("解析失败:%v", err)
  918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  919. return
  920. }
  921. res2.InfRefmsgid = resSix10265.InfRefmsgid
  922. res2.Output = resSix10265.Output
  923. res2.ErrMsg = resSix10265.ErrMsg
  924. res2.Cainfo = resSix10265.Cainfo
  925. res2.WarnMsg = resSix10265.WarnMsg
  926. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  927. res2.Infcode = infocode
  928. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  929. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  930. saveLog(result11, result22, "3502", "3502")
  931. var respJSON3 map[string]interface{}
  932. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. return
  936. }
  937. userJSONBytes3, _ := json.Marshal(respJSON3)
  938. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  939. utils.ErrorLog("解析失败:%v", err)
  940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  941. return
  942. }
  943. }
  944. if res3.Infcode == -1 {
  945. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  946. c.ServeSuccessJSON(map[string]interface{}{
  947. "failed_code": -10,
  948. "msg": res3.ErrMsg,
  949. })
  950. } else {
  951. drug.IsBg = 1
  952. drug.BgBchno = bg_number
  953. service.SaveW(drug)
  954. }
  955. }
  956. } else {
  957. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  958. }
  959. }
  960. //变更
  961. }
  962. if len(errs) == 0 {
  963. c.ServeSuccessJSON(map[string]interface{}{
  964. "msg": "盘存变更成功",
  965. })
  966. } else {
  967. c.ServeSuccessJSON(map[string]interface{}{
  968. "failed_code": -10,
  969. "msg": errs,
  970. })
  971. }
  972. }
  973. func (c *HisApiController) DeletePCandBG() {
  974. ids := c.GetString("ids")
  975. id_arr := strings.Split(ids, ",")
  976. admin_user_id, _ := c.GetInt64("admin_user_id")
  977. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  978. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  979. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  980. var err []string
  981. for _, item := range drugs {
  982. if item.IsPc == 1 && item.IsBg == 1 {
  983. var res FJ3507Result
  984. var res2 FJ3507Result
  985. var struct3507 models.Struct3507
  986. struct3507.FixmedinsBchno = item.Bchno
  987. struct3507.InvDataType = "1"
  988. struct3507.Opter = roles.UserName
  989. struct3507.OrgName = miConfig.OrgName
  990. struct3507.AccessKey = miConfig.AccessKey
  991. struct3507.RequestUrl = miConfig.Url
  992. struct3507.FixmedinsCode = miConfig.Code
  993. struct3507.Code = miConfig.Code
  994. struct3507.SecretKey = miConfig.SecretKey
  995. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  996. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  997. struct3507.Url = miConfig.Url
  998. struct3507.AppId = miConfig.Cainfo
  999. struct3507.AppSecret = miConfig.AppSecret
  1000. struct3507.Enckey = miConfig.EncKey
  1001. struct3507.SignKey = miConfig.SignKey
  1002. struct3507.SecretKey = miConfig.SecretKey
  1003. if miConfig.MdtrtareaAdmvs == "350500" {
  1004. result, result1, _ := service.FJyb3507(struct3507)
  1005. saveLog(result, result1, "3507", "3507")
  1006. var respJSON2 map[string]interface{}
  1007. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. return
  1011. }
  1012. userJSONBytes2, _ := json.Marshal(respJSON2)
  1013. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1014. utils.ErrorLog("解析失败:%v", err)
  1015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1016. return
  1017. }
  1018. } else {
  1019. data := make(map[string]interface{})
  1020. data["struct_3507s"] = struct3507
  1021. client := &http.Client{}
  1022. bytesData, _ := json.Marshal(data)
  1023. var req *http.Request
  1024. if miConfig.MdtrtareaAdmvs == "320921" {
  1025. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1026. } else {
  1027. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1028. }
  1029. resp, _ := client.Do(req)
  1030. defer resp.Body.Close()
  1031. body, ioErr := ioutil.ReadAll(resp.Body)
  1032. if ioErr != nil {
  1033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1034. }
  1035. var respJSON map[string]interface{}
  1036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. var resSix10265 ResultSix10265 //1101结果
  1042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1043. result, _ := json.Marshal(respJSON)
  1044. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1045. utils.ErrorLog("解析失败:%v", err)
  1046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1047. return
  1048. }
  1049. res.InfRefmsgid = resSix10265.InfRefmsgid
  1050. //res.Output = resSix10265.Output
  1051. res.ErrMsg = resSix10265.ErrMsg
  1052. res.Cainfo = resSix10265.Cainfo
  1053. res.WarnMsg = resSix10265.WarnMsg
  1054. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1055. res.Infcode = infocode
  1056. }
  1057. if res.Infcode == 0 {
  1058. item.IsPc = 0
  1059. err2 := service.SaveW(item)
  1060. if err2 == nil {
  1061. var struct3507_2 models.Struct3507
  1062. struct3507_2.OrgName = miConfig.OrgName
  1063. struct3507_2.AccessKey = miConfig.AccessKey
  1064. struct3507_2.RequestUrl = miConfig.Url
  1065. struct3507_2.Opter = roles.UserName
  1066. struct3507_2.FixmedinsCode = miConfig.Code
  1067. struct3507_2.Code = miConfig.Code
  1068. struct3507_2.SecretKey = miConfig.SecretKey
  1069. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1070. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1071. struct3507_2.Url = miConfig.Url
  1072. struct3507_2.AppId = miConfig.Cainfo
  1073. struct3507_2.AppSecret = miConfig.AppSecret
  1074. struct3507_2.Enckey = miConfig.EncKey
  1075. struct3507_2.SignKey = miConfig.SignKey
  1076. struct3507_2.SecretKey = miConfig.SecretKey
  1077. struct3507_2.FixmedinsBchno = item.BgBchno
  1078. struct3507_2.InvDataType = "2"
  1079. if miConfig.MdtrtareaAdmvs == "350500" {
  1080. result11, result22, _ := service.FJyb3507(struct3507_2)
  1081. saveLog(result11, result22, "3507", "3507")
  1082. var respJSON3 map[string]interface{}
  1083. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1086. return
  1087. }
  1088. userJSONBytes3, _ := json.Marshal(respJSON3)
  1089. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1090. utils.ErrorLog("解析失败:%v", err)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. } else {
  1095. data := make(map[string]interface{})
  1096. data["struct_3507s"] = struct3507_2
  1097. client := &http.Client{}
  1098. bytesData, _ := json.Marshal(data)
  1099. var req *http.Request
  1100. if miConfig.MdtrtareaAdmvs == "320921" {
  1101. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1102. } else {
  1103. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1104. }
  1105. resp, _ := client.Do(req)
  1106. defer resp.Body.Close()
  1107. body, ioErr := ioutil.ReadAll(resp.Body)
  1108. if ioErr != nil {
  1109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1110. }
  1111. var respJSON map[string]interface{}
  1112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1115. return
  1116. }
  1117. var resSix10265 ResultSix10265 //1101结果
  1118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1119. result, _ := json.Marshal(respJSON)
  1120. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1121. utils.ErrorLog("解析失败:%v", err)
  1122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1123. return
  1124. }
  1125. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1126. //res2.Output = resSix10265.Output
  1127. res2.ErrMsg = resSix10265.ErrMsg
  1128. res2.Cainfo = resSix10265.Cainfo
  1129. res2.WarnMsg = resSix10265.WarnMsg
  1130. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1131. res2.Infcode = infocode
  1132. }
  1133. if res2.Infcode != -1 {
  1134. item.IsBg = 0
  1135. item.Bchno = ""
  1136. item.BgBchno = ""
  1137. item.PcDate = 0
  1138. service.SaveW(item)
  1139. } else {
  1140. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1141. }
  1142. }
  1143. } else {
  1144. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1145. }
  1146. }
  1147. if item.IsPc == 1 && item.IsBg == 0 {
  1148. var res FJ3507Result
  1149. var struct3507 models.Struct3507
  1150. struct3507.FixmedinsBchno = item.Bchno
  1151. struct3507.InvDataType = "1"
  1152. struct3507.Opter = roles.UserName
  1153. struct3507.FixmedinsCode = miConfig.Code
  1154. struct3507.Code = miConfig.Code
  1155. struct3507.OrgName = miConfig.OrgName
  1156. struct3507.AccessKey = miConfig.AccessKey
  1157. struct3507.RequestUrl = miConfig.Url
  1158. struct3507.SecretKey = miConfig.SecretKey
  1159. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1160. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1161. struct3507.Url = miConfig.Url
  1162. struct3507.AppId = miConfig.Cainfo
  1163. struct3507.AppSecret = miConfig.AppSecret
  1164. struct3507.Enckey = miConfig.EncKey
  1165. struct3507.SignKey = miConfig.SignKey
  1166. struct3507.SecretKey = miConfig.SecretKey
  1167. //result, result1, _ := service.FJyb3507(struct3507)
  1168. //saveLog(result, result1, "3507", "3507")
  1169. if miConfig.MdtrtareaAdmvs == "350500" {
  1170. result, result1, _ := service.FJyb3507(struct3507)
  1171. saveLog(result, result1, "3507", "3507")
  1172. var respJSON2 map[string]interface{}
  1173. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1176. return
  1177. }
  1178. userJSONBytes2, _ := json.Marshal(respJSON2)
  1179. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1180. utils.ErrorLog("解析失败:%v", err)
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. return
  1183. }
  1184. } else {
  1185. data := make(map[string]interface{})
  1186. data["struct_3507s"] = struct3507
  1187. client := &http.Client{}
  1188. bytesData, _ := json.Marshal(data)
  1189. var req *http.Request
  1190. if miConfig.MdtrtareaAdmvs == "320921" {
  1191. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1192. } else {
  1193. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1194. }
  1195. resp, _ := client.Do(req)
  1196. defer resp.Body.Close()
  1197. body, ioErr := ioutil.ReadAll(resp.Body)
  1198. if ioErr != nil {
  1199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1200. }
  1201. var respJSON map[string]interface{}
  1202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. var resSix10265 ResultSix10265 //1101结果
  1208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1209. result, _ := json.Marshal(respJSON)
  1210. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1211. utils.ErrorLog("解析失败:%v", err)
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1213. return
  1214. }
  1215. res.InfRefmsgid = resSix10265.InfRefmsgid
  1216. //res.Output = resSix10265.Output
  1217. res.ErrMsg = resSix10265.ErrMsg
  1218. res.Cainfo = resSix10265.Cainfo
  1219. res.WarnMsg = resSix10265.WarnMsg
  1220. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1221. res.Infcode = infocode
  1222. }
  1223. if res.Infcode == 0 {
  1224. item.IsPc = 0
  1225. item.Bchno = ""
  1226. item.BgBchno = ""
  1227. item.PcDate = 0
  1228. service.SaveW(item)
  1229. } else {
  1230. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1231. }
  1232. }
  1233. if item.IsPc == 0 && item.IsBg == 1 {
  1234. var res FJ3507Result
  1235. var struct3507 models.Struct3507
  1236. struct3507.FixmedinsBchno = item.BgBchno
  1237. struct3507.InvDataType = "2"
  1238. struct3507.Opter = roles.UserName
  1239. struct3507.FixmedinsCode = miConfig.Code
  1240. struct3507.OrgName = miConfig.OrgName
  1241. struct3507.AccessKey = miConfig.AccessKey
  1242. struct3507.RequestUrl = miConfig.Url
  1243. struct3507.SecretKey = miConfig.SecretKey
  1244. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1245. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1246. struct3507.Url = miConfig.Url
  1247. struct3507.AppId = miConfig.Cainfo
  1248. struct3507.AppSecret = miConfig.AppSecret
  1249. struct3507.Enckey = miConfig.EncKey
  1250. struct3507.SignKey = miConfig.SignKey
  1251. struct3507.SecretKey = miConfig.SecretKey
  1252. //result, result1, _ := service.FJyb3507(struct3507)
  1253. //saveLog(result, result1, "3507", "3507")
  1254. if miConfig.MdtrtareaAdmvs == "350500" {
  1255. result, result1, _ := service.FJyb3507(struct3507)
  1256. saveLog(result, result1, "3507", "3507")
  1257. var respJSON2 map[string]interface{}
  1258. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1261. return
  1262. }
  1263. userJSONBytes2, _ := json.Marshal(respJSON2)
  1264. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1265. utils.ErrorLog("解析失败:%v", err)
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1267. return
  1268. }
  1269. } else {
  1270. data := make(map[string]interface{})
  1271. data["struct_3507s"] = struct3507
  1272. client := &http.Client{}
  1273. bytesData, _ := json.Marshal(data)
  1274. var req *http.Request
  1275. if miConfig.MdtrtareaAdmvs == "320921" {
  1276. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1277. } else {
  1278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1279. }
  1280. resp, _ := client.Do(req)
  1281. defer resp.Body.Close()
  1282. body, ioErr := ioutil.ReadAll(resp.Body)
  1283. if ioErr != nil {
  1284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1285. }
  1286. var respJSON map[string]interface{}
  1287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1290. return
  1291. }
  1292. var resSix10265 ResultSix10265 //1101结果
  1293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1294. result, _ := json.Marshal(respJSON)
  1295. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1296. utils.ErrorLog("解析失败:%v", err)
  1297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. return
  1299. }
  1300. res.InfRefmsgid = resSix10265.InfRefmsgid
  1301. //res.Output = resSix10265.Output
  1302. res.ErrMsg = resSix10265.ErrMsg
  1303. res.Cainfo = resSix10265.Cainfo
  1304. res.WarnMsg = resSix10265.WarnMsg
  1305. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1306. res.Infcode = infocode
  1307. }
  1308. if res.Infcode == 0 {
  1309. item.IsBg = 0
  1310. item.Bchno = ""
  1311. item.BgBchno = ""
  1312. item.PcDate = 0
  1313. service.SaveW(item)
  1314. } else {
  1315. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1316. }
  1317. }
  1318. }
  1319. if len(err) == 0 {
  1320. c.ServeSuccessJSON(map[string]interface{}{
  1321. "msg": "删除盘存变更成功",
  1322. })
  1323. } else {
  1324. c.ServeSuccessJSON(map[string]interface{}{
  1325. "failed_code": -10,
  1326. "msg": err,
  1327. })
  1328. }
  1329. }
  1330. func (c *HisApiController) DeleteXSandBG() {
  1331. ids := c.GetString("ids")
  1332. id_arr := strings.Split(ids, ",")
  1333. admin_user_id, _ := c.GetInt64("admin_user_id")
  1334. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1335. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1337. var err []string
  1338. for _, item := range flows {
  1339. if item.IsSale == 1 && item.IsChange == 1 {
  1340. var res FJ3507Result
  1341. var res2 FJ3507Result
  1342. var struct3507 models.Struct3507
  1343. struct3507.FixmedinsBchno = item.Bchno
  1344. struct3507.InvDataType = "4"
  1345. struct3507.Opter = roles.UserName
  1346. struct3507.OrgName = miConfig.OrgName
  1347. struct3507.AccessKey = miConfig.AccessKey
  1348. struct3507.RequestUrl = miConfig.Url
  1349. struct3507.FixmedinsCode = miConfig.Code
  1350. struct3507.SecretKey = miConfig.SecretKey
  1351. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1352. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1353. struct3507.Url = miConfig.Url
  1354. struct3507.AppId = miConfig.Cainfo
  1355. struct3507.AppSecret = miConfig.AppSecret
  1356. struct3507.Enckey = miConfig.EncKey
  1357. struct3507.SignKey = miConfig.SignKey
  1358. struct3507.SecretKey = miConfig.SecretKey
  1359. //result, result1, _ := service.FJyb3507(struct3507)
  1360. //saveLog(result, result1, "3507", "3507")
  1361. if miConfig.MdtrtareaAdmvs == "350500" {
  1362. result, result1, _ := service.FJyb3507(struct3507)
  1363. saveLog(result, result1, "3507", "3507")
  1364. var respJSON2 map[string]interface{}
  1365. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1368. return
  1369. }
  1370. userJSONBytes2, _ := json.Marshal(respJSON2)
  1371. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1372. utils.ErrorLog("解析失败:%v", err)
  1373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1374. return
  1375. }
  1376. } else {
  1377. data := make(map[string]interface{})
  1378. data["struct_3507s"] = struct3507
  1379. client := &http.Client{}
  1380. bytesData, _ := json.Marshal(data)
  1381. var req *http.Request
  1382. if miConfig.MdtrtareaAdmvs == "320921" {
  1383. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1384. } else {
  1385. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1386. }
  1387. resp, _ := client.Do(req)
  1388. defer resp.Body.Close()
  1389. body, ioErr := ioutil.ReadAll(resp.Body)
  1390. if ioErr != nil {
  1391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1392. }
  1393. var respJSON map[string]interface{}
  1394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1397. return
  1398. }
  1399. var resSix10265 ResultSix10265 //1101结果
  1400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1401. result, _ := json.Marshal(respJSON)
  1402. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1403. utils.ErrorLog("解析失败:%v", err)
  1404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1405. return
  1406. }
  1407. res.InfRefmsgid = resSix10265.InfRefmsgid
  1408. //res.Output = resSix10265.Output
  1409. res.ErrMsg = resSix10265.ErrMsg
  1410. res.Cainfo = resSix10265.Cainfo
  1411. res.WarnMsg = resSix10265.WarnMsg
  1412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1413. res.Infcode = infocode
  1414. }
  1415. if res.Infcode == 0 {
  1416. item.IsSale = 0
  1417. item.SaleDate = ""
  1418. item.Bchno = ""
  1419. err2 := service.SaveDF(item)
  1420. if err2 == nil {
  1421. var struct3507_2 models.Struct3507
  1422. struct3507_2.OrgName = miConfig.OrgName
  1423. struct3507_2.AccessKey = miConfig.AccessKey
  1424. struct3507_2.RequestUrl = miConfig.Url
  1425. struct3507_2.Opter = roles.UserName
  1426. struct3507_2.FixmedinsCode = miConfig.Code
  1427. struct3507_2.Code = miConfig.Code
  1428. struct3507_2.SecretKey = miConfig.SecretKey
  1429. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1430. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1431. struct3507_2.Url = miConfig.Url
  1432. struct3507_2.AppId = miConfig.Cainfo
  1433. struct3507_2.AppSecret = miConfig.AppSecret
  1434. struct3507_2.Enckey = miConfig.EncKey
  1435. struct3507_2.SignKey = miConfig.SignKey
  1436. struct3507_2.SecretKey = miConfig.SecretKey
  1437. struct3507_2.FixmedinsBchno = item.BgBchno
  1438. struct3507_2.InvDataType = "2"
  1439. if miConfig.MdtrtareaAdmvs == "350500" {
  1440. result11, result22, _ := service.FJyb3507(struct3507_2)
  1441. saveLog(result11, result22, "3507", "3507")
  1442. var respJSON3 map[string]interface{}
  1443. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1446. return
  1447. }
  1448. userJSONBytes3, _ := json.Marshal(respJSON3)
  1449. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1450. utils.ErrorLog("解析失败:%v", err)
  1451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1452. return
  1453. }
  1454. } else {
  1455. data := make(map[string]interface{})
  1456. data["struct_3507s"] = struct3507_2
  1457. client := &http.Client{}
  1458. bytesData, _ := json.Marshal(data)
  1459. var req *http.Request
  1460. if miConfig.MdtrtareaAdmvs == "320921" {
  1461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1462. } else {
  1463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1464. }
  1465. resp, _ := client.Do(req)
  1466. defer resp.Body.Close()
  1467. body, ioErr := ioutil.ReadAll(resp.Body)
  1468. if ioErr != nil {
  1469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1470. }
  1471. var respJSON map[string]interface{}
  1472. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1475. return
  1476. }
  1477. var resSix10265 ResultSix10265 //1101结果
  1478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1479. result, _ := json.Marshal(respJSON)
  1480. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1481. utils.ErrorLog("解析失败:%v", err)
  1482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1483. return
  1484. }
  1485. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1486. //res.Output = resSix10265.Output
  1487. res2.ErrMsg = resSix10265.ErrMsg
  1488. res2.Cainfo = resSix10265.Cainfo
  1489. res2.WarnMsg = resSix10265.WarnMsg
  1490. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1491. res2.Infcode = infocode
  1492. }
  1493. if res2.Infcode == 0 {
  1494. item.IsChange = 0
  1495. item.BgBchno = ""
  1496. service.SaveDF2(item)
  1497. } else {
  1498. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1499. }
  1500. }
  1501. } else {
  1502. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1503. }
  1504. }
  1505. if item.IsSale == 2 && item.IsChange == 1 {
  1506. var res FJ3507Result
  1507. var res2 FJ3507Result
  1508. var struct3507 models.Struct3507
  1509. struct3507.FixmedinsBchno = item.Bchno
  1510. struct3507.InvDataType = "4"
  1511. struct3507.Opter = roles.UserName
  1512. struct3507.OrgName = miConfig.OrgName
  1513. struct3507.AccessKey = miConfig.AccessKey
  1514. struct3507.RequestUrl = miConfig.Url
  1515. struct3507.FixmedinsCode = miConfig.Code
  1516. struct3507.Code = miConfig.Code
  1517. struct3507.SecretKey = miConfig.SecretKey
  1518. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1519. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1520. struct3507.Url = miConfig.Url
  1521. struct3507.AppId = miConfig.Cainfo
  1522. struct3507.AppSecret = miConfig.AppSecret
  1523. struct3507.Enckey = miConfig.EncKey
  1524. struct3507.SignKey = miConfig.SignKey
  1525. struct3507.SecretKey = miConfig.SecretKey
  1526. //result, result1, _ := service.FJyb3507(struct3507)
  1527. //saveLog(result, result1, "3507", "3507")
  1528. //
  1529. //var respJSON2 map[string]interface{}
  1530. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1531. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. // return
  1534. //}
  1535. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1536. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1537. // utils.ErrorLog("解析失败:%v", err)
  1538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. // return
  1540. //}
  1541. if miConfig.MdtrtareaAdmvs == "350500" {
  1542. result, result1, _ := service.FJyb3507(struct3507)
  1543. saveLog(result, result1, "3507", "3507")
  1544. var respJSON2 map[string]interface{}
  1545. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1548. return
  1549. }
  1550. userJSONBytes2, _ := json.Marshal(respJSON2)
  1551. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1552. utils.ErrorLog("解析失败:%v", err)
  1553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1554. return
  1555. }
  1556. } else {
  1557. data := make(map[string]interface{})
  1558. data["struct_3507s"] = struct3507
  1559. client := &http.Client{}
  1560. bytesData, _ := json.Marshal(data)
  1561. var req *http.Request
  1562. if miConfig.MdtrtareaAdmvs == "320921" {
  1563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1564. } else {
  1565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1566. }
  1567. resp, _ := client.Do(req)
  1568. defer resp.Body.Close()
  1569. body, ioErr := ioutil.ReadAll(resp.Body)
  1570. if ioErr != nil {
  1571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1572. }
  1573. var respJSON map[string]interface{}
  1574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1577. return
  1578. }
  1579. var resSix10265 ResultSix10265 //1101结果
  1580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1581. result, _ := json.Marshal(respJSON)
  1582. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1583. utils.ErrorLog("解析失败:%v", err)
  1584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. return
  1586. }
  1587. res.InfRefmsgid = resSix10265.InfRefmsgid
  1588. //res.Output = resSix10265.Output
  1589. res.ErrMsg = resSix10265.ErrMsg
  1590. res.Cainfo = resSix10265.Cainfo
  1591. res.WarnMsg = resSix10265.WarnMsg
  1592. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1593. res.Infcode = infocode
  1594. }
  1595. if res.Infcode == 0 {
  1596. item.IsSale = 0
  1597. item.SaleDate = ""
  1598. item.Bchno = ""
  1599. err2 := service.SaveDF(item)
  1600. if err2 == nil {
  1601. var struct3507_2 models.Struct3507
  1602. struct3507_2.OrgName = miConfig.OrgName
  1603. struct3507_2.AccessKey = miConfig.AccessKey
  1604. struct3507_2.RequestUrl = miConfig.Url
  1605. struct3507_2.Opter = roles.UserName
  1606. struct3507_2.FixmedinsCode = miConfig.Code
  1607. struct3507_2.Code = miConfig.Code
  1608. struct3507_2.SecretKey = miConfig.SecretKey
  1609. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1610. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1611. struct3507_2.Url = miConfig.Url
  1612. struct3507_2.AppId = miConfig.Cainfo
  1613. struct3507_2.AppSecret = miConfig.AppSecret
  1614. struct3507_2.Enckey = miConfig.EncKey
  1615. struct3507_2.SignKey = miConfig.SignKey
  1616. struct3507_2.SecretKey = miConfig.SecretKey
  1617. struct3507_2.FixmedinsBchno = item.BgBchno
  1618. struct3507_2.InvDataType = "2"
  1619. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1620. //saveLog(result11, result22, "3507", "3507")
  1621. //var respJSON3 map[string]interface{}
  1622. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1623. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1625. // return
  1626. //}
  1627. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1628. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1629. // utils.ErrorLog("解析失败:%v", err)
  1630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. // return
  1632. //}
  1633. if miConfig.MdtrtareaAdmvs == "350500" {
  1634. result11, result22, _ := service.FJyb3507(struct3507_2)
  1635. saveLog(result11, result22, "3507", "3507")
  1636. var respJSON3 map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. userJSONBytes3, _ := json.Marshal(respJSON3)
  1643. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1644. utils.ErrorLog("解析失败:%v", err)
  1645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1646. return
  1647. }
  1648. } else {
  1649. data := make(map[string]interface{})
  1650. data["struct_3507s"] = struct3507_2
  1651. client := &http.Client{}
  1652. bytesData, _ := json.Marshal(data)
  1653. var req *http.Request
  1654. if miConfig.MdtrtareaAdmvs == "320921" {
  1655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. } else {
  1657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1658. }
  1659. resp, _ := client.Do(req)
  1660. defer resp.Body.Close()
  1661. body, ioErr := ioutil.ReadAll(resp.Body)
  1662. if ioErr != nil {
  1663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1664. }
  1665. var respJSON map[string]interface{}
  1666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1669. return
  1670. }
  1671. var resSix10265 ResultSix10265 //1101结果
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1675. utils.ErrorLog("解析失败:%v", err)
  1676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1677. return
  1678. }
  1679. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1680. //res.Output = resSix10265.Output
  1681. res2.ErrMsg = resSix10265.ErrMsg
  1682. res2.Cainfo = resSix10265.Cainfo
  1683. res2.WarnMsg = resSix10265.WarnMsg
  1684. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1685. res2.Infcode = infocode
  1686. }
  1687. if res2.Infcode == 0 {
  1688. item.IsChange = 0
  1689. item.BgBchno = ""
  1690. service.SaveDF2(item)
  1691. } else {
  1692. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1693. }
  1694. }
  1695. } else {
  1696. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1697. }
  1698. }
  1699. if item.IsSale == 1 && item.IsChange == 0 {
  1700. var res FJ3507Result
  1701. var struct3507 models.Struct3507
  1702. struct3507.FixmedinsBchno = item.Bchno
  1703. struct3507.InvDataType = "4"
  1704. struct3507.Opter = roles.UserName
  1705. struct3507.FixmedinsCode = miConfig.Code
  1706. struct3507.Code = miConfig.Code
  1707. struct3507.OrgName = miConfig.OrgName
  1708. struct3507.AccessKey = miConfig.AccessKey
  1709. struct3507.RequestUrl = miConfig.Url
  1710. struct3507.SecretKey = miConfig.SecretKey
  1711. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1712. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1713. struct3507.Url = miConfig.Url
  1714. struct3507.AppId = miConfig.Cainfo
  1715. struct3507.AppSecret = miConfig.AppSecret
  1716. struct3507.Enckey = miConfig.EncKey
  1717. struct3507.SignKey = miConfig.SignKey
  1718. struct3507.SecretKey = miConfig.SecretKey
  1719. //result, result1, _ := service.FJyb3507(struct3507)
  1720. //saveLog(result, result1, "3507", "3507")
  1721. //
  1722. //var respJSON3 map[string]interface{}
  1723. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1724. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. // return
  1727. //}
  1728. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1729. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1730. // utils.ErrorLog("解析失败:%v", err)
  1731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. // return
  1733. //}
  1734. if miConfig.MdtrtareaAdmvs == "350500" {
  1735. result, result1, _ := service.FJyb3507(struct3507)
  1736. saveLog(result, result1, "3507", "3507")
  1737. var respJSON2 map[string]interface{}
  1738. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1741. return
  1742. }
  1743. userJSONBytes2, _ := json.Marshal(respJSON2)
  1744. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1745. utils.ErrorLog("解析失败:%v", err)
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1747. return
  1748. }
  1749. } else {
  1750. data := make(map[string]interface{})
  1751. data["struct_3507s"] = struct3507
  1752. client := &http.Client{}
  1753. bytesData, _ := json.Marshal(data)
  1754. var req *http.Request
  1755. if miConfig.MdtrtareaAdmvs == "320921" {
  1756. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1757. } else {
  1758. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1759. }
  1760. resp, _ := client.Do(req)
  1761. defer resp.Body.Close()
  1762. body, ioErr := ioutil.ReadAll(resp.Body)
  1763. if ioErr != nil {
  1764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1765. }
  1766. var respJSON map[string]interface{}
  1767. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1770. return
  1771. }
  1772. var resSix10265 ResultSix10265 //1101结果
  1773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1774. result, _ := json.Marshal(respJSON)
  1775. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1776. utils.ErrorLog("解析失败:%v", err)
  1777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1778. return
  1779. }
  1780. res.InfRefmsgid = resSix10265.InfRefmsgid
  1781. //res.Output = resSix10265.Output
  1782. res.ErrMsg = resSix10265.ErrMsg
  1783. res.Cainfo = resSix10265.Cainfo
  1784. res.WarnMsg = resSix10265.WarnMsg
  1785. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1786. res.Infcode = infocode
  1787. }
  1788. if res.Infcode == 0 {
  1789. item.IsSale = 0
  1790. item.SaleDate = ""
  1791. service.SaveDF(item)
  1792. } else {
  1793. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1794. }
  1795. }
  1796. if item.IsSale == 2 && item.IsChange == 0 {
  1797. var res FJ3507Result
  1798. var struct3507 models.Struct3507
  1799. struct3507.FixmedinsBchno = item.Bchno
  1800. struct3507.InvDataType = "4"
  1801. struct3507.Opter = roles.UserName
  1802. struct3507.FixmedinsCode = miConfig.Code
  1803. struct3507.Code = miConfig.Code
  1804. struct3507.OrgName = miConfig.OrgName
  1805. struct3507.AccessKey = miConfig.AccessKey
  1806. struct3507.RequestUrl = miConfig.Url
  1807. struct3507.SecretKey = miConfig.SecretKey
  1808. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1809. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1810. struct3507.Url = miConfig.Url
  1811. struct3507.AppId = miConfig.Cainfo
  1812. struct3507.AppSecret = miConfig.AppSecret
  1813. struct3507.Enckey = miConfig.EncKey
  1814. struct3507.SignKey = miConfig.SignKey
  1815. struct3507.SecretKey = miConfig.SecretKey
  1816. //result, result1, _ := service.FJyb3507(struct3507)
  1817. //saveLog(result, result1, "3507", "3507")
  1818. //
  1819. //var respJSON3 map[string]interface{}
  1820. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1821. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. // return
  1824. //}
  1825. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1826. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1827. // utils.ErrorLog("解析失败:%v", err)
  1828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1829. // return
  1830. //}
  1831. if miConfig.MdtrtareaAdmvs == "350500" {
  1832. result, result1, _ := service.FJyb3507(struct3507)
  1833. saveLog(result, result1, "3507", "3507")
  1834. var respJSON2 map[string]interface{}
  1835. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. return
  1839. }
  1840. userJSONBytes2, _ := json.Marshal(respJSON2)
  1841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1842. utils.ErrorLog("解析失败:%v", err)
  1843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1844. return
  1845. }
  1846. } else {
  1847. data := make(map[string]interface{})
  1848. data["struct_3507s"] = struct3507
  1849. client := &http.Client{}
  1850. bytesData, _ := json.Marshal(data)
  1851. var req *http.Request
  1852. if miConfig.MdtrtareaAdmvs == "320921" {
  1853. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1854. } else {
  1855. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1856. }
  1857. resp, _ := client.Do(req)
  1858. defer resp.Body.Close()
  1859. body, ioErr := ioutil.ReadAll(resp.Body)
  1860. if ioErr != nil {
  1861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1862. }
  1863. var respJSON map[string]interface{}
  1864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1867. return
  1868. }
  1869. var resSix10265 ResultSix10265 //1101结果
  1870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1871. result, _ := json.Marshal(respJSON)
  1872. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1873. utils.ErrorLog("解析失败:%v", err)
  1874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1875. return
  1876. }
  1877. res.InfRefmsgid = resSix10265.InfRefmsgid
  1878. //res.Output = resSix10265.Output
  1879. res.ErrMsg = resSix10265.ErrMsg
  1880. res.Cainfo = resSix10265.Cainfo
  1881. res.WarnMsg = resSix10265.WarnMsg
  1882. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1883. res.Infcode = infocode
  1884. }
  1885. if res.Infcode == 0 {
  1886. item.IsSale = 0
  1887. item.SaleDate = ""
  1888. item.Bchno = ""
  1889. service.SaveDF(item)
  1890. } else {
  1891. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1892. }
  1893. }
  1894. if item.IsSale == 0 && item.IsChange == 1 {
  1895. var res FJ3507Result
  1896. var struct3507 models.Struct3507
  1897. struct3507.FixmedinsBchno = item.BgBchno
  1898. struct3507.InvDataType = "2"
  1899. struct3507.Opter = roles.UserName
  1900. struct3507.FixmedinsCode = miConfig.Code
  1901. struct3507.Code = miConfig.Code
  1902. struct3507.OrgName = miConfig.OrgName
  1903. struct3507.AccessKey = miConfig.AccessKey
  1904. struct3507.RequestUrl = miConfig.Url
  1905. struct3507.SecretKey = miConfig.SecretKey
  1906. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1907. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1908. struct3507.Url = miConfig.Url
  1909. struct3507.AppId = miConfig.Cainfo
  1910. struct3507.AppSecret = miConfig.AppSecret
  1911. struct3507.Enckey = miConfig.EncKey
  1912. struct3507.SignKey = miConfig.SignKey
  1913. struct3507.SecretKey = miConfig.SecretKey
  1914. //result, result1, _ := service.FJyb3507(struct3507)
  1915. //saveLog(result, result1, "3507", "3507")
  1916. //
  1917. //var respJSON3 map[string]interface{}
  1918. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1919. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. // return
  1922. //}
  1923. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1924. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1925. // utils.ErrorLog("解析失败:%v", err)
  1926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1927. // return
  1928. //}
  1929. if miConfig.MdtrtareaAdmvs == "350500" {
  1930. result, result1, _ := service.FJyb3507(struct3507)
  1931. saveLog(result, result1, "3507", "3507")
  1932. var respJSON2 map[string]interface{}
  1933. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1936. return
  1937. }
  1938. userJSONBytes2, _ := json.Marshal(respJSON2)
  1939. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1940. utils.ErrorLog("解析失败:%v", err)
  1941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1942. return
  1943. }
  1944. } else {
  1945. data := make(map[string]interface{})
  1946. data["struct_3507s"] = struct3507
  1947. client := &http.Client{}
  1948. bytesData, _ := json.Marshal(data)
  1949. var req *http.Request
  1950. if miConfig.MdtrtareaAdmvs == "320921" {
  1951. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1952. } else {
  1953. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1954. }
  1955. resp, _ := client.Do(req)
  1956. defer resp.Body.Close()
  1957. body, ioErr := ioutil.ReadAll(resp.Body)
  1958. if ioErr != nil {
  1959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1960. }
  1961. var respJSON map[string]interface{}
  1962. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1965. return
  1966. }
  1967. var resSix10265 ResultSix10265 //1101结果
  1968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1969. result, _ := json.Marshal(respJSON)
  1970. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1971. utils.ErrorLog("解析失败:%v", err)
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1973. return
  1974. }
  1975. res.InfRefmsgid = resSix10265.InfRefmsgid
  1976. //res.Output = resSix10265.Output
  1977. res.ErrMsg = resSix10265.ErrMsg
  1978. res.Cainfo = resSix10265.Cainfo
  1979. res.WarnMsg = resSix10265.WarnMsg
  1980. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1981. res.Infcode = infocode
  1982. }
  1983. if res.Infcode == 0 {
  1984. item.IsChange = 0
  1985. item.BgBchno = ""
  1986. service.SaveDF2(item)
  1987. } else {
  1988. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1989. }
  1990. }
  1991. }
  1992. if len(err) == 0 {
  1993. c.ServeSuccessJSON(map[string]interface{}{
  1994. "msg": "删除销售变更成功",
  1995. })
  1996. } else {
  1997. c.ServeSuccessJSON(map[string]interface{}{
  1998. "failed_code": -10,
  1999. "msg": err,
  2000. })
  2001. }
  2002. }
  2003. //func (c *HisApiController) BatchFJ3501AND3502() {
  2004. // //ids := c.GetString("ids")
  2005. // start_time := c.GetString("start_time")
  2006. // end_time := c.GetString("end_time")
  2007. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2008. //
  2009. //
  2010. // timeLayout := "2006-01-02"
  2011. // loc, _ := time.LoadLocation("Local")
  2012. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2013. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2014. //
  2015. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2016. // //id_arr := strings.Split(ids, ",")
  2017. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2018. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2019. // //库盘
  2020. // var errs []string
  2021. // for _, drug := range drugs {
  2022. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2023. // var res2 ResultSix
  2024. // var res3 ResultSix
  2025. //
  2026. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2027. // var struct3501 models.Struct3501
  2028. // struct3501.Code = miConfig.Code
  2029. // struct3501.OrgName = miConfig.OrgName
  2030. // struct3501.AccessKey = miConfig.AccessKey
  2031. // struct3501.Opter = roles.UserName
  2032. // struct3501.RequestUrl = miConfig.Url
  2033. // struct3501.Url = miConfig.Url
  2034. // struct3501.AppId = miConfig.Cainfo
  2035. // struct3501.AppSecret = miConfig.AppSecret
  2036. // struct3501.Enckey = miConfig.EncKey
  2037. // struct3501.SignKey = miConfig.SignKey
  2038. // struct3501.SecretKey = miConfig.SecretKey
  2039. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2041. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2042. // struct3501.RxFlag = "1"
  2043. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2044. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2045. //
  2046. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2047. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2048. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2049. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2050. // struct3501.FixmedinsBchno = number
  2051. // struct3501.DrugTracCodg = drug.DrugCode
  2052. // memo := make(map[string]interface{})
  2053. // memo["pric"] = drug.Price
  2054. // bytesData, _ := json.Marshal(memo)
  2055. // struct3501.Memo = string(bytesData)
  2056. //
  2057. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2058. //
  2059. // result1, result2, _ := service.FJyb3501(struct3501)
  2060. // saveLog(result1, result2, "3501", "3501")
  2061. // //saveLog(result, requestLog, "2201", "挂号")
  2062. //
  2063. // var respJSON2 map[string]interface{}
  2064. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2065. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2067. // return
  2068. // }
  2069. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2070. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2071. // utils.ErrorLog("解析失败:%v", err)
  2072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. // return
  2074. // }
  2075. //
  2076. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2077. // data := make(map[string]interface{})
  2078. // data["struct_3501s"] = struct3501
  2079. // client := &http.Client{}
  2080. // bytesData, _ := json.Marshal(data)
  2081. // var req *http.Request
  2082. // if miConfig.MdtrtareaAdmvs == "320921" {
  2083. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2084. // } else {
  2085. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2086. // }
  2087. //
  2088. // resp, _ := client.Do(req)
  2089. // defer resp.Body.Close()
  2090. // body, ioErr := ioutil.ReadAll(resp.Body)
  2091. // if ioErr != nil {
  2092. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2093. // }
  2094. // var respJSON map[string]interface{}
  2095. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2096. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2098. // return
  2099. // }
  2100. // var resSix10265 ResultSix10265 //1101结果
  2101. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2102. // result, _ := json.Marshal(respJSON)
  2103. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2104. // utils.ErrorLog("解析失败:%v", err)
  2105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2106. // return
  2107. // }
  2108. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2109. // res2.Output = resSix10265.Output
  2110. // res2.ErrMsg = resSix10265.ErrMsg
  2111. // res2.Cainfo = resSix10265.Cainfo
  2112. // res2.WarnMsg = resSix10265.WarnMsg
  2113. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2114. // res2.Infcode = infocode
  2115. //
  2116. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2117. // data := make(map[string]interface{})
  2118. // data["struct_3501s"] = struct3501
  2119. // client := &http.Client{}
  2120. // bytesData, _ := json.Marshal(data)
  2121. // var req *http.Request
  2122. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2123. // resp, _ := client.Do(req)
  2124. // defer resp.Body.Close()
  2125. // body, ioErr := ioutil.ReadAll(resp.Body)
  2126. // if ioErr != nil {
  2127. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2128. // }
  2129. // var respJSON map[string]interface{}
  2130. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2131. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2133. // return
  2134. // }
  2135. // var resSix10265 ResultSix10265 //1101结果
  2136. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2137. // result, _ := json.Marshal(respJSON)
  2138. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2139. // utils.ErrorLog("解析失败:%v", err)
  2140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2141. // return
  2142. // }
  2143. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2144. // res2.Output = resSix10265.Output
  2145. // res2.ErrMsg = resSix10265.ErrMsg
  2146. // res2.Cainfo = resSix10265.Cainfo
  2147. // res2.WarnMsg = resSix10265.WarnMsg
  2148. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2149. // res2.Infcode = infocode
  2150. //
  2151. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2152. // data := make(map[string]interface{})
  2153. // data["struct_3501s"] = struct3501
  2154. // client := &http.Client{}
  2155. // bytesData, _ := json.Marshal(data)
  2156. // var req *http.Request
  2157. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2158. // resp, _ := client.Do(req)
  2159. // defer resp.Body.Close()
  2160. // body, ioErr := ioutil.ReadAll(resp.Body)
  2161. // if ioErr != nil {
  2162. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2163. // }
  2164. // var respJSON map[string]interface{}
  2165. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2166. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2168. // return
  2169. // }
  2170. // var resSix10265 ResultSix10265 //1101结果
  2171. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2172. // result, _ := json.Marshal(respJSON)
  2173. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2174. // utils.ErrorLog("解析失败:%v", err)
  2175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2176. // return
  2177. // }
  2178. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2179. // res2.Output = resSix10265.Output
  2180. // res2.ErrMsg = resSix10265.ErrMsg
  2181. // res2.Cainfo = resSix10265.Cainfo
  2182. // res2.WarnMsg = resSix10265.WarnMsg
  2183. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2184. // res2.Infcode = infocode
  2185. //
  2186. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2187. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2188. // saveLog(result1, result2, "3501", "3501")
  2189. // //saveLog(result, requestLog, "2201", "挂号")
  2190. //
  2191. // var respJSON2 map[string]interface{}
  2192. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2195. // return
  2196. // }
  2197. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2198. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2199. // utils.ErrorLog("解析失败:%v", err)
  2200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. // return
  2202. // }
  2203. //
  2204. // }
  2205. //
  2206. // if res2.Infcode != -1 {
  2207. // drug.IsPc = 1
  2208. // drug.Bchno = number
  2209. // drug.PcDate = time.Now().Unix()
  2210. // err := service.SaveW(drug)
  2211. // if err == nil {
  2212. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2213. // var struct3502 models.Struct3502
  2214. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2216. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2217. // struct3502.FixmedinsCode = miConfig.Code
  2218. // struct3502.Code = miConfig.Code
  2219. //
  2220. // struct3502.RxFlag = "0"
  2221. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2222. // struct3502.OrgName = miConfig.OrgName
  2223. // struct3502.Opter = roles.UserName
  2224. // struct3502.AccessKey = miConfig.AccessKey
  2225. // struct3502.RequestUrl = miConfig.Url
  2226. // struct3502.SecretKey = miConfig.SecretKey
  2227. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2228. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2229. // struct3502.Url = miConfig.Url
  2230. // struct3502.AppId = miConfig.Cainfo
  2231. // struct3502.AppSecret = miConfig.AppSecret
  2232. // struct3502.Enckey = miConfig.EncKey
  2233. // struct3502.SignKey = miConfig.SignKey
  2234. // struct3502.SecretKey = miConfig.SecretKey
  2235. // struct3502.DrugTracCodg = drug.DrugCode
  2236. //
  2237. // struct3502.Memo = ""
  2238. // struct3502.InvChgType = "108"
  2239. // struct3502.FixmedinsBchno = bg_number
  2240. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2241. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2242. //
  2243. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2244. // result11, result22, _ := service.FJyb3502(struct3502)
  2245. // saveLog(result11, result22, "3502", "3502")
  2246. //
  2247. // var respJSON3 map[string]interface{}
  2248. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2249. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2251. // return
  2252. // }
  2253. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2254. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2255. // utils.ErrorLog("解析失败:%v", err)
  2256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2257. // return
  2258. // }
  2259. //
  2260. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2261. // data := make(map[string]interface{})
  2262. // data["struct_3502s"] = struct3502
  2263. // client := &http.Client{}
  2264. // bytesData, _ := json.Marshal(data)
  2265. // var req *http.Request
  2266. // if miConfig.MdtrtareaAdmvs == "320921" {
  2267. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2268. // } else {
  2269. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2270. // }
  2271. //
  2272. // resp, _ := client.Do(req)
  2273. // defer resp.Body.Close()
  2274. // body, ioErr := ioutil.ReadAll(resp.Body)
  2275. // if ioErr != nil {
  2276. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2277. // }
  2278. // var respJSON map[string]interface{}
  2279. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2280. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2282. // return
  2283. // }
  2284. // var resSix10265 ResultSix10265 //1101结果
  2285. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2286. // result, _ := json.Marshal(respJSON)
  2287. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2288. // utils.ErrorLog("解析失败:%v", err)
  2289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2290. // return
  2291. // }
  2292. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2293. // res3.Output = resSix10265.Output
  2294. // res3.ErrMsg = resSix10265.ErrMsg
  2295. // res3.Cainfo = resSix10265.Cainfo
  2296. // res3.WarnMsg = resSix10265.WarnMsg
  2297. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2298. // res3.Infcode = infocode
  2299. //
  2300. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2301. //
  2302. // data := make(map[string]interface{})
  2303. // data["struct_3502s"] = struct3502
  2304. // client := &http.Client{}
  2305. // bytesData, _ := json.Marshal(data)
  2306. // var req *http.Request
  2307. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2308. // resp, _ := client.Do(req)
  2309. // defer resp.Body.Close()
  2310. // body, ioErr := ioutil.ReadAll(resp.Body)
  2311. // if ioErr != nil {
  2312. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2313. // }
  2314. // var respJSON map[string]interface{}
  2315. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2316. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2318. // return
  2319. // }
  2320. // var resSix10265 ResultSix10265 //1101结果
  2321. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2322. // result, _ := json.Marshal(respJSON)
  2323. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2324. // utils.ErrorLog("解析失败:%v", err)
  2325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2326. // return
  2327. // }
  2328. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2329. // res3.Output = resSix10265.Output
  2330. // res3.ErrMsg = resSix10265.ErrMsg
  2331. // res3.Cainfo = resSix10265.Cainfo
  2332. // res3.WarnMsg = resSix10265.WarnMsg
  2333. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2334. // res3.Infcode = infocode
  2335. //
  2336. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2337. //
  2338. // data := make(map[string]interface{})
  2339. // data["struct_3501s"] = struct3501
  2340. // client := &http.Client{}
  2341. // bytesData, _ := json.Marshal(data)
  2342. // var req *http.Request
  2343. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2344. // resp, _ := client.Do(req)
  2345. // defer resp.Body.Close()
  2346. // body, ioErr := ioutil.ReadAll(resp.Body)
  2347. // if ioErr != nil {
  2348. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2349. // }
  2350. // var respJSON map[string]interface{}
  2351. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2352. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2354. // return
  2355. // }
  2356. // var resSix10265 ResultSix10265 //1101结果
  2357. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2358. // result, _ := json.Marshal(respJSON)
  2359. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2360. // utils.ErrorLog("解析失败:%v", err)
  2361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2362. // return
  2363. // }
  2364. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2365. // res2.Output = resSix10265.Output
  2366. // res2.ErrMsg = resSix10265.ErrMsg
  2367. // res2.Cainfo = resSix10265.Cainfo
  2368. // res2.WarnMsg = resSix10265.WarnMsg
  2369. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2370. // res2.Infcode = infocode
  2371. //
  2372. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2373. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2374. // saveLog(result11, result22, "3502", "3502")
  2375. //
  2376. // var respJSON3 map[string]interface{}
  2377. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. // return
  2381. // }
  2382. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2383. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2384. // utils.ErrorLog("解析失败:%v", err)
  2385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2386. // return
  2387. // }
  2388. // }
  2389. // if res3.Infcode == -1 {
  2390. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2391. // c.ServeSuccessJSON(map[string]interface{}{
  2392. // "failed_code": -10,
  2393. // "msg": res3.ErrMsg,
  2394. // })
  2395. // } else {
  2396. // drug.IsBg = 1
  2397. // drug.BgBchno = bg_number
  2398. // service.SaveW(drug)
  2399. // }
  2400. // }
  2401. // } else {
  2402. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2403. // }
  2404. // }
  2405. // //变更
  2406. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2407. // var res3 ResultSix
  2408. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2409. //
  2410. // var struct3502 models.Struct3502
  2411. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2413. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2414. // struct3502.FixmedinsCode = miConfig.Code
  2415. // struct3502.Code = miConfig.Code
  2416. //
  2417. // struct3502.Opter = roles.UserName
  2418. // struct3502.RxFlag = "0"
  2419. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2420. // struct3502.OrgName = miConfig.OrgName
  2421. // struct3502.AccessKey = miConfig.AccessKey
  2422. // struct3502.RequestUrl = miConfig.Url
  2423. // struct3502.SecretKey = miConfig.SecretKey
  2424. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2425. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2426. // struct3502.InvChgType = "108"
  2427. // struct3502.DrugTracCodg = drug.DrugCode
  2428. //
  2429. // struct3502.Url = miConfig.Url
  2430. // struct3502.AppId = miConfig.Cainfo
  2431. // struct3502.AppSecret = miConfig.AppSecret
  2432. // struct3502.Enckey = miConfig.EncKey
  2433. // struct3502.SignKey = miConfig.SignKey
  2434. // struct3502.SecretKey = miConfig.SecretKey
  2435. //
  2436. // struct3502.FixmedinsBchno = bg_number
  2437. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2438. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2439. //
  2440. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2441. // result1, result2, _ := service.FJyb3502(struct3502)
  2442. // saveLog(result1, result2, "3502", "3502")
  2443. // var respJSON3 map[string]interface{}
  2444. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2445. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2447. // return
  2448. // }
  2449. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2450. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2451. // utils.ErrorLog("解析失败:%v", err)
  2452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2453. // return
  2454. // }
  2455. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2456. // data := make(map[string]interface{})
  2457. // data["struct_3502s"] = struct3502
  2458. // client := &http.Client{}
  2459. // bytesData, _ := json.Marshal(data)
  2460. // var req *http.Request
  2461. // if miConfig.MdtrtareaAdmvs == "320921" {
  2462. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2463. // } else {
  2464. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2465. // }
  2466. // resp, _ := client.Do(req)
  2467. // defer resp.Body.Close()
  2468. // body, ioErr := ioutil.ReadAll(resp.Body)
  2469. // if ioErr != nil {
  2470. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2471. // }
  2472. // var respJSON map[string]interface{}
  2473. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2476. // return
  2477. // }
  2478. // var resSix10265 ResultSix10265 //1101结果
  2479. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2480. // result, _ := json.Marshal(respJSON)
  2481. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2482. // utils.ErrorLog("解析失败:%v", err)
  2483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2484. // return
  2485. // }
  2486. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2487. // res3.Output = resSix10265.Output
  2488. // res3.ErrMsg = resSix10265.ErrMsg
  2489. // res3.Cainfo = resSix10265.Cainfo
  2490. // res3.WarnMsg = resSix10265.WarnMsg
  2491. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2492. // res3.Infcode = infocode
  2493. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2494. //
  2495. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2496. //
  2497. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2498. //
  2499. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2500. //
  2501. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2502. // saveLog(result1, result2, "3501", "3501")
  2503. // //saveLog(result, requestLog, "2201", "挂号")
  2504. //
  2505. // var respJSON2 map[string]interface{}
  2506. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2507. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. // return
  2510. // }
  2511. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2512. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2513. // utils.ErrorLog("解析失败:%v", err)
  2514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2515. // return
  2516. // }
  2517. //
  2518. // }
  2519. // if res3.Infcode == -1 {
  2520. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2521. // } else {
  2522. // drug.IsBg = 1
  2523. // drug.BgBchno = bg_number
  2524. // service.SaveW(drug)
  2525. // }
  2526. // }
  2527. // }
  2528. //
  2529. // if len(errs) == 0 {
  2530. // c.ServeSuccessJSON(map[string]interface{}{
  2531. // "msg": "盘存变更成功",
  2532. // })
  2533. // } else {
  2534. // c.ServeSuccessJSON(map[string]interface{}{
  2535. // "failed_code": -10,
  2536. // "msg": errs,
  2537. // })
  2538. // }
  2539. //}
  2540. func (c *HisApiController) DeleteXSandBGTwo() {
  2541. patient_id, _ := c.GetInt64("patient_id")
  2542. admin_user_id, _ := c.GetInt64("admin_user_id")
  2543. times := c.GetString("time", "")
  2544. timeLayout := "2006-01-02"
  2545. loc, _ := time.LoadLocation("Local")
  2546. var stime, etime int64
  2547. if times == "" {
  2548. stime, etime = GetNowTime()
  2549. } else {
  2550. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2551. stime = stmp.Unix()
  2552. etime = stime + 86399
  2553. }
  2554. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2555. var flows []*models.DrugFlow
  2556. for _, item := range advicelist {
  2557. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2558. flows = append(flows, flow...)
  2559. }
  2560. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2561. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2562. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2563. var err []string
  2564. for _, item := range flows {
  2565. if item.IsSale == 1 {
  2566. var res FJ3507Result
  2567. var struct3507 models.Struct3507
  2568. struct3507.FixmedinsBchno = item.Bchno
  2569. struct3507.InvDataType = "4"
  2570. struct3507.Opter = roles.UserName
  2571. struct3507.OrgName = miConfig.OrgName
  2572. struct3507.AccessKey = miConfig.AccessKey
  2573. struct3507.RequestUrl = miConfig.Url
  2574. struct3507.FixmedinsCode = miConfig.Code
  2575. struct3507.SecretKey = miConfig.SecretKey
  2576. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2577. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2578. struct3507.Url = miConfig.Url
  2579. struct3507.AppId = miConfig.Cainfo
  2580. struct3507.AppSecret = miConfig.AppSecret
  2581. struct3507.Enckey = miConfig.EncKey
  2582. struct3507.SignKey = miConfig.SignKey
  2583. struct3507.SecretKey = miConfig.SecretKey
  2584. if miConfig.MdtrtareaAdmvs == "350500" {
  2585. result, result1, _ := service.FJyb3507(struct3507)
  2586. saveLog(result, result1, "3507", "3507")
  2587. var respJSON2 map[string]interface{}
  2588. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2591. return
  2592. }
  2593. userJSONBytes2, _ := json.Marshal(respJSON2)
  2594. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2595. utils.ErrorLog("解析失败:%v", err)
  2596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2597. return
  2598. }
  2599. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2600. data := make(map[string]interface{})
  2601. data["struct_3507s"] = struct3507
  2602. client := &http.Client{}
  2603. bytesData, _ := json.Marshal(data)
  2604. var req *http.Request
  2605. if miConfig.MdtrtareaAdmvs == "320921" {
  2606. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2607. } else {
  2608. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2609. }
  2610. resp, _ := client.Do(req)
  2611. defer resp.Body.Close()
  2612. body, ioErr := ioutil.ReadAll(resp.Body)
  2613. if ioErr != nil {
  2614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2615. }
  2616. var respJSON map[string]interface{}
  2617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2620. return
  2621. }
  2622. var resSix10265 ResultSix10265 //1101结果
  2623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2624. result, _ := json.Marshal(respJSON)
  2625. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2626. utils.ErrorLog("解析失败:%v", err)
  2627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. return
  2629. }
  2630. res.InfRefmsgid = resSix10265.InfRefmsgid
  2631. //res.Output = resSix10265.Output
  2632. res.ErrMsg = resSix10265.ErrMsg
  2633. res.Cainfo = resSix10265.Cainfo
  2634. res.WarnMsg = resSix10265.WarnMsg
  2635. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2636. res.Infcode = infocode
  2637. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2638. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2639. saveLog(result2, result1, "3507", "3507")
  2640. var respJSON2 map[string]interface{}
  2641. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. return
  2645. }
  2646. userJSONBytes2, _ := json.Marshal(respJSON2)
  2647. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2648. utils.ErrorLog("解析失败:%v", err)
  2649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2650. return
  2651. }
  2652. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2653. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2654. saveLog(result2, result1, "3507", "3507")
  2655. var respJSON2 map[string]interface{}
  2656. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. return
  2660. }
  2661. userJSONBytes2, _ := json.Marshal(respJSON2)
  2662. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2663. utils.ErrorLog("解析失败:%v", err)
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2668. result1, result2 := service.Jxyb3507(struct3507)
  2669. saveLog(result2, result1, "3507", "3507")
  2670. var respJSON2 map[string]interface{}
  2671. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2674. return
  2675. }
  2676. userJSONBytes2, _ := json.Marshal(respJSON2)
  2677. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2678. utils.ErrorLog("解析失败:%v", err)
  2679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2680. return
  2681. }
  2682. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2683. result1, result2 := service.AHyb3507(struct3507)
  2684. saveLog(result2, result1, "3507", "3507")
  2685. var respJSON2 map[string]interface{}
  2686. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2689. return
  2690. }
  2691. userJSONBytes2, _ := json.Marshal(respJSON2)
  2692. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2693. utils.ErrorLog("解析失败:%v", err)
  2694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2695. return
  2696. }
  2697. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2698. data := make(map[string]interface{})
  2699. data["struct_3507s"] = struct3507
  2700. client := &http.Client{}
  2701. bytesData, _ := json.Marshal(data)
  2702. var req *http.Request
  2703. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2704. resp, _ := client.Do(req)
  2705. defer resp.Body.Close()
  2706. body, ioErr := ioutil.ReadAll(resp.Body)
  2707. if ioErr != nil {
  2708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2709. }
  2710. var respJSON map[string]interface{}
  2711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2713. }
  2714. var resSix10265 ResultSix10265 //1101结果
  2715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2716. result, _ := json.Marshal(respJSON)
  2717. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2718. utils.ErrorLog("解析失败:%v", err)
  2719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2720. return
  2721. }
  2722. res.InfRefmsgid = resSix10265.InfRefmsgid
  2723. res.ErrMsg = resSix10265.ErrMsg
  2724. res.Cainfo = resSix10265.Cainfo
  2725. res.WarnMsg = resSix10265.WarnMsg
  2726. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2727. res.Infcode = infocode
  2728. }
  2729. if res.Infcode == 0 {
  2730. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2731. item.IsSale = 0
  2732. item.SaleDate = ""
  2733. item.Bchno = ""
  2734. service.SaveDF(item)
  2735. } else {
  2736. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2737. }
  2738. }
  2739. }
  2740. c.ServeSuccessJSON(map[string]interface{}{
  2741. "msg": "删除销售数据成功",
  2742. })
  2743. }
  2744. // 删除
  2745. func (c *HisApiController) DeleteXSandBGThree() {
  2746. id, _ := c.GetInt64("id")
  2747. admin_user_id, _ := c.GetInt64("admin_user_id")
  2748. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2749. var flows []*models.DrugFlow
  2750. for _, item := range advicelist {
  2751. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2752. flows = append(flows, flow...)
  2753. }
  2754. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2755. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2756. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2757. var err []string
  2758. for _, item := range flows {
  2759. if item.IsSale == 1 {
  2760. var res FJ3507Result
  2761. var struct3507 models.Struct3507
  2762. struct3507.FixmedinsBchno = item.Bchno
  2763. struct3507.InvDataType = "4"
  2764. struct3507.Opter = roles.UserName
  2765. struct3507.OrgName = miConfig.OrgName
  2766. struct3507.AccessKey = miConfig.AccessKey
  2767. struct3507.RequestUrl = miConfig.Url
  2768. struct3507.FixmedinsCode = miConfig.Code
  2769. struct3507.SecretKey = miConfig.SecretKey
  2770. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2771. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2772. struct3507.Url = miConfig.Url
  2773. struct3507.AppId = miConfig.Cainfo
  2774. struct3507.AppSecret = miConfig.AppSecret
  2775. struct3507.Enckey = miConfig.EncKey
  2776. struct3507.SignKey = miConfig.SignKey
  2777. struct3507.SecretKey = miConfig.SecretKey
  2778. if miConfig.MdtrtareaAdmvs == "350500" {
  2779. result, result1, _ := service.FJyb3507(struct3507)
  2780. saveLog(result, result1, "3507", "3507")
  2781. var respJSON2 map[string]interface{}
  2782. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2785. return
  2786. }
  2787. userJSONBytes2, _ := json.Marshal(respJSON2)
  2788. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2789. utils.ErrorLog("解析失败:%v", err)
  2790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2791. return
  2792. }
  2793. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2794. data := make(map[string]interface{})
  2795. data["struct_3507s"] = struct3507
  2796. client := &http.Client{}
  2797. bytesData, _ := json.Marshal(data)
  2798. var req *http.Request
  2799. if miConfig.MdtrtareaAdmvs == "320921" {
  2800. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2801. } else {
  2802. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2803. }
  2804. resp, _ := client.Do(req)
  2805. defer resp.Body.Close()
  2806. body, ioErr := ioutil.ReadAll(resp.Body)
  2807. if ioErr != nil {
  2808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2809. }
  2810. var respJSON map[string]interface{}
  2811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2814. return
  2815. }
  2816. var resSix10265 ResultSix10265 //1101结果
  2817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2818. result, _ := json.Marshal(respJSON)
  2819. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2820. utils.ErrorLog("解析失败:%v", err)
  2821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2822. return
  2823. }
  2824. res.InfRefmsgid = resSix10265.InfRefmsgid
  2825. //res.Output = resSix10265.Output
  2826. res.ErrMsg = resSix10265.ErrMsg
  2827. res.Cainfo = resSix10265.Cainfo
  2828. res.WarnMsg = resSix10265.WarnMsg
  2829. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2830. res.Infcode = infocode
  2831. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2832. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2833. saveLog(result2, result1, "3507", "3507")
  2834. var respJSON2 map[string]interface{}
  2835. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2838. return
  2839. }
  2840. userJSONBytes2, _ := json.Marshal(respJSON2)
  2841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2842. utils.ErrorLog("解析失败:%v", err)
  2843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2844. return
  2845. }
  2846. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2847. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2848. saveLog(result2, result1, "3507", "3507")
  2849. var respJSON2 map[string]interface{}
  2850. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2853. return
  2854. }
  2855. userJSONBytes2, _ := json.Marshal(respJSON2)
  2856. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2857. utils.ErrorLog("解析失败:%v", err)
  2858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2859. return
  2860. }
  2861. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2862. result1, result2 := service.Jxyb3507(struct3507)
  2863. saveLog(result2, result1, "3507", "3507")
  2864. var respJSON2 map[string]interface{}
  2865. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2868. return
  2869. }
  2870. userJSONBytes2, _ := json.Marshal(respJSON2)
  2871. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2872. utils.ErrorLog("解析失败:%v", err)
  2873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. return
  2875. }
  2876. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2877. result1, result2 := service.AHyb3507(struct3507)
  2878. saveLog(result2, result1, "3507", "3507")
  2879. var respJSON2 map[string]interface{}
  2880. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2883. return
  2884. }
  2885. userJSONBytes2, _ := json.Marshal(respJSON2)
  2886. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2887. utils.ErrorLog("解析失败:%v", err)
  2888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2889. return
  2890. }
  2891. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2892. data := make(map[string]interface{})
  2893. data["struct_3507s"] = struct3507
  2894. client := &http.Client{}
  2895. bytesData, _ := json.Marshal(data)
  2896. var req *http.Request
  2897. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2898. resp, _ := client.Do(req)
  2899. defer resp.Body.Close()
  2900. body, ioErr := ioutil.ReadAll(resp.Body)
  2901. if ioErr != nil {
  2902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2903. }
  2904. var respJSON map[string]interface{}
  2905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2907. }
  2908. var resSix10265 ResultSix10265 //1101结果
  2909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2910. result, _ := json.Marshal(respJSON)
  2911. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2912. utils.ErrorLog("解析失败:%v", err)
  2913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2914. return
  2915. }
  2916. res.InfRefmsgid = resSix10265.InfRefmsgid
  2917. res.ErrMsg = resSix10265.ErrMsg
  2918. res.Cainfo = resSix10265.Cainfo
  2919. res.WarnMsg = resSix10265.WarnMsg
  2920. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2921. res.Infcode = infocode
  2922. }
  2923. if res.Infcode == 0 {
  2924. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2925. item.IsSale = 0
  2926. item.SaleDate = ""
  2927. item.Bchno = ""
  2928. service.SaveDF(item)
  2929. } else {
  2930. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2931. }
  2932. }
  2933. }
  2934. c.ServeSuccessJSON(map[string]interface{}{
  2935. "msg": "删除销售数据成功",
  2936. })
  2937. }
  2938. // 获取当天起止时间戳
  2939. func GetNowTime() (int64, int64) {
  2940. t := time.Now()
  2941. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2942. timesamp := addTime.Unix()
  2943. return timesamp, timesamp + 86399
  2944. }
  2945. func (c *HisApiController) ChangeDrugfour() {
  2946. patient_id, _ := c.GetInt64("patient_id")
  2947. admin_user_id, _ := c.GetInt64("admin_user_id")
  2948. times := c.GetString("time", "")
  2949. timeLayout := "2006-01-02"
  2950. loc, _ := time.LoadLocation("Local")
  2951. var stime, etime int64
  2952. if times == "" {
  2953. stime, etime = GetNowTime()
  2954. } else {
  2955. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2956. stime = stmp.Unix()
  2957. etime = stime + 86399
  2958. }
  2959. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2960. var flows []*models.DrugFlow
  2961. for _, item := range advicelist {
  2962. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2963. flows = append(flows, flow...)
  2964. }
  2965. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2966. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2967. var err []string
  2968. for _, item := range flows {
  2969. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2970. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2971. if prescription.OrderStatus == 2 {
  2972. if item.IsSale == 0 {
  2973. var res FJ3507Result
  2974. var res3507for10188 FJ3507ResultFor10188
  2975. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2976. //进行商品销售接口
  2977. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2978. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2979. var respJSON3 map[string]interface{}
  2980. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2983. return
  2984. }
  2985. userJSONBytes3, _ := json.Marshal(respJSON3)
  2986. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2987. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2988. utils.ErrorLog("解析失败:%v", err)
  2989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2990. return
  2991. }
  2992. //if res3507for10188.Infcode
  2993. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2994. //res.Output = resSix10265.Output
  2995. res.ErrMsg = res3507for10188.ErrMsg
  2996. res.Cainfo = res3507for10188.Cainfo
  2997. res.WarnMsg = res3507for10188.WarnMsg
  2998. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2999. res.Infcode = infocode
  3000. } else {
  3001. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3002. utils.ErrorLog("解析失败:%v", err)
  3003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3004. return
  3005. }
  3006. }
  3007. if res.Infcode == 0 {
  3008. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3009. item.IsSale = 1
  3010. item.Bchno = number
  3011. item.SaleDate = time.Now().Format("2006-01-02")
  3012. service.SaveDF(item)
  3013. } else {
  3014. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3015. }
  3016. }
  3017. } else { //还没结,提示用户去结算,并药品追溯上传
  3018. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3019. }
  3020. }
  3021. }
  3022. str := strings.Join(err, " ")
  3023. saveLog(str, str, "3505", "3505自动上传日志")
  3024. c.ServeSuccessJSON(map[string]interface{}{
  3025. "status": "1",
  3026. "msg": err,
  3027. })
  3028. }
  3029. func (c *HisApiController) ChangeDrugFive() {
  3030. id, _ := c.GetInt64("id")
  3031. admin_user_id, _ := c.GetInt64("admin_user_id")
  3032. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3033. var flows []*models.DrugFlow
  3034. for _, item := range advicelist {
  3035. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3036. flows = append(flows, flow...)
  3037. }
  3038. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3039. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3040. var err []string
  3041. for _, item := range flows {
  3042. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3043. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3044. if prescription.OrderStatus == 2 {
  3045. if item.IsSale == 0 {
  3046. var res FJ3507Result
  3047. var res3507for10188 FJ3507ResultFor10188
  3048. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3049. //进行商品销售接口
  3050. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3051. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3052. var respJSON3 map[string]interface{}
  3053. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3056. return
  3057. }
  3058. userJSONBytes3, _ := json.Marshal(respJSON3)
  3059. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3060. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3061. utils.ErrorLog("解析失败:%v", err)
  3062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3063. return
  3064. }
  3065. //if res3507for10188.Infcode
  3066. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3067. //res.Output = resSix10265.Output
  3068. res.ErrMsg = res3507for10188.ErrMsg
  3069. res.Cainfo = res3507for10188.Cainfo
  3070. res.WarnMsg = res3507for10188.WarnMsg
  3071. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3072. res.Infcode = infocode
  3073. } else {
  3074. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3075. utils.ErrorLog("解析失败:%v", err)
  3076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3077. return
  3078. }
  3079. }
  3080. if res.Infcode == 0 {
  3081. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3082. item.IsSale = 1
  3083. item.Bchno = number
  3084. item.SaleDate = time.Now().Format("2006-01-02")
  3085. service.SaveDF(item)
  3086. } else {
  3087. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3088. }
  3089. }
  3090. } else { //还没结,提示用户去结算,并药品追溯上传
  3091. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3092. }
  3093. }
  3094. }
  3095. str := strings.Join(err, " ")
  3096. saveLog(str, str, "3505", "3505自动上传日志")
  3097. c.ServeSuccessJSON(map[string]interface{}{
  3098. "status": "1",
  3099. "msg": err,
  3100. })
  3101. }
  3102. //func (c *HisApiController) ChangeDrugfour() {
  3103. // patient_id, _ := c.GetInt64("patient_id")
  3104. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3105. // //id_arr := strings.Split(ids, ",")
  3106. // times := c.GetString("time", "")
  3107. // timeLayout := "2006-01-02"
  3108. // loc, _ := time.LoadLocation("Local")
  3109. // var stime, etime int64
  3110. // if times == "" {
  3111. // stime, etime = GetNowTime()
  3112. // } else {
  3113. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3114. // stime = stmp.Unix()
  3115. // etime = stime + 86399
  3116. // }
  3117. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3118. // var flows []*models.DrugFlow
  3119. // for _, item := range advicelist {
  3120. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3121. // flows = append(flows, flow...)
  3122. // }
  3123. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3124. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3125. // var err []string
  3126. //
  3127. // for _, item := range flows {
  3128. // var res3 ResultSix
  3129. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3130. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3131. // if prescription.OrderStatus == 2 {
  3132. // //已经结算
  3133. // //判断是否已经销售
  3134. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3135. // //是否已经变更 1是 0否
  3136. // if item.IsChange == 0 { //没变更,进行变更操作
  3137. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3138. //
  3139. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3140. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3141. // var respJSON3 map[string]interface{}
  3142. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3143. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3145. // return
  3146. // }
  3147. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3148. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3149. // utils.ErrorLog("解析失败:%v", err)
  3150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3151. // return
  3152. // }
  3153. // if res3.Infcode == 0 {
  3154. // item.IsChange = 1
  3155. // item.BgBchno = bg_number
  3156. // service.SaveDF2(item)
  3157. // } else {
  3158. //
  3159. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3160. // }
  3161. // }
  3162. // } else { //没销售,
  3163. // var res FJ3507Result
  3164. // var res3507for10188 FJ3507ResultFor10188
  3165. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3166. //
  3167. // //进行商品销售接口
  3168. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3169. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3170. // var respJSON3 map[string]interface{}
  3171. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3172. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3174. // return
  3175. // }
  3176. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3177. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3178. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3179. // utils.ErrorLog("解析失败:%v", err)
  3180. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3181. // return
  3182. // }
  3183. // //if res3507for10188.Infcode
  3184. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3185. // //res.Output = resSix10265.Output
  3186. // res.ErrMsg = res3507for10188.ErrMsg
  3187. // res.Cainfo = res3507for10188.Cainfo
  3188. // res.WarnMsg = res3507for10188.WarnMsg
  3189. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3190. // res.Infcode = infocode
  3191. // } else {
  3192. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3193. // utils.ErrorLog("解析失败:%v", err)
  3194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3195. // return
  3196. // }
  3197. //
  3198. // }
  3199. // if res.Infcode == 0 {
  3200. // item.IsSale = 1
  3201. // item.Bchno = number
  3202. // item.SaleDate = time.Now().Format("2006-01-02")
  3203. //
  3204. // err5 := service.SaveDF(item)
  3205. // if err5 == nil {
  3206. // if item.IsChange == 0 { //没变更,进行变更操作
  3207. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3208. //
  3209. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3210. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3211. //
  3212. // var respJSON3 map[string]interface{}
  3213. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3214. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3216. // return
  3217. // }
  3218. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3219. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3220. // utils.ErrorLog("解析失败:%v", err)
  3221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3222. // return
  3223. // }
  3224. // //if res3507for10188.Infcode
  3225. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3226. // //res.Output = resSix10265.Output
  3227. // res3.ErrMsg = res3507for10188.ErrMsg
  3228. // res3.Cainfo = res3507for10188.Cainfo
  3229. // res3.WarnMsg = res3507for10188.WarnMsg
  3230. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3231. // res3.Infcode = infocode
  3232. // } else {
  3233. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3234. // utils.ErrorLog("解析失败:%v", err)
  3235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3236. // return
  3237. // }
  3238. // }
  3239. // if res3.Infcode == 0 {
  3240. // item.IsChange = 1
  3241. // item.BgBchno = bg_number
  3242. // service.SaveDF2(item)
  3243. // } else {
  3244. //
  3245. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3246. // }
  3247. // }
  3248. // }
  3249. // } else {
  3250. //
  3251. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3252. // }
  3253. // }
  3254. //
  3255. // } else { //还没结,提示用户去结算,并药品追溯上传
  3256. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3257. // }
  3258. // }
  3259. // }
  3260. // if len(err) == 0 {
  3261. // c.ServeSuccessJSON(map[string]interface{}{
  3262. // "msg": "销售变更成功",
  3263. // })
  3264. // } else {
  3265. // c.ServeSuccessJSON(map[string]interface{}{
  3266. // "failed_code": -10,
  3267. // "msg": err,
  3268. // })
  3269. // }
  3270. //}
  3271. func (c *HisApiController) ChangeDrug() {
  3272. ids := c.GetString("ids")
  3273. id_arr := strings.Split(ids, ",")
  3274. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3275. admin_user_id, _ := c.GetInt64("admin_user_id")
  3276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3278. var err []string
  3279. for _, item := range flows {
  3280. var res3 ResultSix
  3281. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3282. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3283. if prescription.OrderStatus == 2 {
  3284. //已经结算
  3285. //判断是否已经销售
  3286. if item.IsSale == 1 { //是否已经销售,1是 0否
  3287. //是否已经变更 1是 0否
  3288. if item.IsChange == 0 { //没变更,进行变更操作
  3289. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3290. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3291. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3292. var respJSON3 map[string]interface{}
  3293. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3296. return
  3297. }
  3298. userJSONBytes3, _ := json.Marshal(respJSON3)
  3299. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3300. utils.ErrorLog("解析失败:%v", err)
  3301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3302. return
  3303. }
  3304. if res3.Infcode == 0 {
  3305. item.IsChange = 1
  3306. item.BgBchno = bg_number
  3307. service.SaveDF2(item)
  3308. } else {
  3309. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3310. }
  3311. }
  3312. } else { //没销售,
  3313. var res FJ3507Result
  3314. var res3507for10188 FJ3507ResultFor10188
  3315. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3316. //进行商品销售接口
  3317. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3318. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3319. var respJSON3 map[string]interface{}
  3320. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3323. return
  3324. }
  3325. userJSONBytes3, _ := json.Marshal(respJSON3)
  3326. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3327. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3328. utils.ErrorLog("解析失败:%v", err)
  3329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3330. return
  3331. }
  3332. //if res3507for10188.Infcode
  3333. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3334. //res.Output = resSix10265.Output
  3335. res.ErrMsg = res3507for10188.ErrMsg
  3336. res.Cainfo = res3507for10188.Cainfo
  3337. res.WarnMsg = res3507for10188.WarnMsg
  3338. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3339. res.Infcode = infocode
  3340. } else {
  3341. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3342. utils.ErrorLog("解析失败:%v", err)
  3343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3344. return
  3345. }
  3346. }
  3347. if res.Infcode == 0 {
  3348. item.IsSale = 1
  3349. item.Bchno = number
  3350. item.SaleDate = time.Now().Format("2006-01-02")
  3351. err5 := service.SaveDF(item)
  3352. if err5 == nil {
  3353. if item.IsChange == 0 { //没变更,进行变更操作
  3354. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3355. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3356. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3357. var respJSON3 map[string]interface{}
  3358. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3361. return
  3362. }
  3363. userJSONBytes3, _ := json.Marshal(respJSON3)
  3364. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3365. utils.ErrorLog("解析失败:%v", err)
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3367. return
  3368. }
  3369. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3370. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3371. utils.ErrorLog("解析失败:%v", err)
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3373. return
  3374. }
  3375. //if res3507for10188.Infcode
  3376. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3377. //res.Output = resSix10265.Output
  3378. res3.ErrMsg = res3507for10188.ErrMsg
  3379. res3.Cainfo = res3507for10188.Cainfo
  3380. res3.WarnMsg = res3507for10188.WarnMsg
  3381. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3382. res3.Infcode = infocode
  3383. } else {
  3384. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3385. utils.ErrorLog("解析失败:%v", err)
  3386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3387. return
  3388. }
  3389. }
  3390. if res3.Infcode == 0 {
  3391. item.IsChange = 1
  3392. item.BgBchno = bg_number
  3393. service.SaveDF2(item)
  3394. } else {
  3395. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3396. }
  3397. }
  3398. }
  3399. } else {
  3400. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3401. }
  3402. }
  3403. } else { //还没结算
  3404. var res3507for10188 FJ3507ResultFor10188
  3405. if item.IsChange == 0 { //没变更,进行变更操作
  3406. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3407. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3408. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3409. var respJSON3 map[string]interface{}
  3410. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3413. return
  3414. }
  3415. userJSONBytes3, _ := json.Marshal(respJSON3)
  3416. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3417. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3418. utils.ErrorLog("解析失败:%v", err)
  3419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3420. return
  3421. }
  3422. //if res3507for10188.Infcode
  3423. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3424. //res.Output = resSix10265.Output
  3425. res3.ErrMsg = res3507for10188.ErrMsg
  3426. res3.Cainfo = res3507for10188.Cainfo
  3427. res3.WarnMsg = res3507for10188.WarnMsg
  3428. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3429. res3.Infcode = infocode
  3430. } else {
  3431. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3432. utils.ErrorLog("解析失败:%v", err)
  3433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3434. return
  3435. }
  3436. }
  3437. if res3.Infcode == 0 {
  3438. item.IsChange = 1
  3439. item.BgBchno = bg_number
  3440. service.SaveDF2(item)
  3441. } else {
  3442. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3443. }
  3444. }
  3445. }
  3446. } else if item.ConsumableType == 7 {
  3447. var res3507for10188 FJ3507ResultFor10188
  3448. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3449. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3450. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3451. //判断是否已经销售
  3452. if item.IsSale == 2 { //是否已经销售,1是 0否
  3453. //是否已经变更 1是 0否
  3454. if item.IsChange == 0 { //没变更,进行变更操作
  3455. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3456. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3457. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3458. var respJSON3 map[string]interface{}
  3459. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3462. return
  3463. }
  3464. userJSONBytes3, _ := json.Marshal(respJSON3)
  3465. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3466. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3467. utils.ErrorLog("解析失败:%v", err)
  3468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3469. return
  3470. }
  3471. //if res3507for10188.Infcode
  3472. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3473. //res.Output = resSix10265.Output
  3474. res3.ErrMsg = res3507for10188.ErrMsg
  3475. res3.Cainfo = res3507for10188.Cainfo
  3476. res3.WarnMsg = res3507for10188.WarnMsg
  3477. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3478. res3.Infcode = infocode
  3479. } else {
  3480. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3481. utils.ErrorLog("解析失败:%v", err)
  3482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3483. return
  3484. }
  3485. }
  3486. if res3.Infcode == 0 {
  3487. item.IsChange = 1
  3488. item.BgBchno = bg_number
  3489. service.SaveDF2(item)
  3490. } else {
  3491. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3492. }
  3493. }
  3494. } else { //没销售,
  3495. //进行商品销售退货接口
  3496. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3497. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3498. saveLog(result111, result222, "3506", "销售退货")
  3499. var res7 FJ3507Result
  3500. //进行商品销售接口
  3501. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3502. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3503. var respJSON3 map[string]interface{}
  3504. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3507. return
  3508. }
  3509. userJSONBytes3, _ := json.Marshal(respJSON3)
  3510. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3511. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3512. utils.ErrorLog("解析失败:%v", err)
  3513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3514. return
  3515. }
  3516. //if res3507for10188.Infcode
  3517. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3518. //res.Output = resSix10265.Output
  3519. res7.ErrMsg = res3507for10188.ErrMsg
  3520. res7.Cainfo = res3507for10188.Cainfo
  3521. res7.WarnMsg = res3507for10188.WarnMsg
  3522. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3523. res7.Infcode = infocode
  3524. } else {
  3525. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3526. utils.ErrorLog("解析失败:%v", err)
  3527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3528. return
  3529. }
  3530. }
  3531. if res7.Infcode == 0 {
  3532. item.IsSale = 2
  3533. item.SaleDate = item.SaleDate
  3534. item.Bchno = number
  3535. service.SaveDF(item)
  3536. if item.IsChange == 0 { //没变更,进行变更操作
  3537. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3538. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3539. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3540. var respJSON3 map[string]interface{}
  3541. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3544. return
  3545. }
  3546. userJSONBytes3, _ := json.Marshal(respJSON3)
  3547. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3548. // utils.ErrorLog("解析失败:%v", err)
  3549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3550. // return
  3551. //}
  3552. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3553. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3554. utils.ErrorLog("解析失败:%v", err)
  3555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3556. return
  3557. }
  3558. //if res3507for10188.Infcode
  3559. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3560. //res.Output = resSix10265.Output
  3561. res3.ErrMsg = res3507for10188.ErrMsg
  3562. res3.Cainfo = res3507for10188.Cainfo
  3563. res3.WarnMsg = res3507for10188.WarnMsg
  3564. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3565. res3.Infcode = infocode
  3566. } else {
  3567. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3568. utils.ErrorLog("解析失败:%v", err)
  3569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3570. return
  3571. }
  3572. }
  3573. if res3.Infcode == 0 {
  3574. item.IsChange = 1
  3575. item.BgBchno = bg_number
  3576. service.SaveDF2(item)
  3577. } else {
  3578. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3579. }
  3580. }
  3581. } else {
  3582. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3583. }
  3584. }
  3585. } else { //还没结算
  3586. if item.IsChange == 0 { //没变更,进行变更操作
  3587. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3588. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3589. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3590. var respJSON3 map[string]interface{}
  3591. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3594. return
  3595. }
  3596. userJSONBytes3, _ := json.Marshal(respJSON3)
  3597. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3598. // utils.ErrorLog("解析失败:%v", err)
  3599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3600. // return
  3601. //}
  3602. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3603. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3604. utils.ErrorLog("解析失败:%v", err)
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. //if res3507for10188.Infcode
  3609. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3610. //res.Output = resSix10265.Output
  3611. res3.ErrMsg = res3507for10188.ErrMsg
  3612. res3.Cainfo = res3507for10188.Cainfo
  3613. res3.WarnMsg = res3507for10188.WarnMsg
  3614. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3615. res3.Infcode = infocode
  3616. } else {
  3617. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3618. utils.ErrorLog("解析失败:%v", err)
  3619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3620. return
  3621. }
  3622. }
  3623. if res3.Infcode == 0 {
  3624. item.IsChange = 1
  3625. item.BgBchno = bg_number
  3626. service.SaveDF2(item)
  3627. } else {
  3628. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3629. }
  3630. }
  3631. }
  3632. }
  3633. }
  3634. if len(err) == 0 {
  3635. c.ServeSuccessJSON(map[string]interface{}{
  3636. "msg": "销售变更成功",
  3637. })
  3638. } else {
  3639. c.ServeSuccessJSON(map[string]interface{}{
  3640. "failed_code": -10,
  3641. "msg": err,
  3642. })
  3643. }
  3644. }
  3645. func (c *HisApiController) ChangeDrugtwo() {
  3646. //ids := c.GetString("ids")
  3647. //id_arr := strings.Split(ids, ",")
  3648. flows, _ := service.GetNewDrugFlowInfothree123()
  3649. admin_user_id, _ := c.GetInt64("admin_user_id")
  3650. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3651. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3652. var err []string
  3653. for _, item := range flows {
  3654. var res3 ResultSix
  3655. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3656. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3657. if prescription.OrderStatus == 2 {
  3658. //已经结算
  3659. //判断是否已经销售
  3660. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3661. // //是否已经变更 1是 0否
  3662. // if item.IsChange == 0 { //没变更,进行变更操作
  3663. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3664. //
  3665. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3666. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3667. // var respJSON3 map[string]interface{}
  3668. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3669. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3671. // return
  3672. // }
  3673. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3674. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3675. // utils.ErrorLog("解析失败:%v", err)
  3676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3677. // return
  3678. // }
  3679. // if res3.Infcode == 0 {
  3680. // item.IsChange = 1
  3681. // item.BgBchno = bg_number
  3682. // service.SaveDF2(item)
  3683. // } else {
  3684. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3685. // }
  3686. // }
  3687. //}
  3688. //else
  3689. { //没销售,
  3690. var res FJ3507Result
  3691. var res3507for10188 FJ3507ResultFor10188
  3692. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3693. //进行商品销售接口
  3694. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3695. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3696. var respJSON3 map[string]interface{}
  3697. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3700. return
  3701. }
  3702. userJSONBytes3, _ := json.Marshal(respJSON3)
  3703. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3704. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3705. utils.ErrorLog("解析失败:%v", err)
  3706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3707. return
  3708. }
  3709. //if res3507for10188.Infcode
  3710. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3711. //res.Output = resSix10265.Output
  3712. res.ErrMsg = res3507for10188.ErrMsg
  3713. res.Cainfo = res3507for10188.Cainfo
  3714. res.WarnMsg = res3507for10188.WarnMsg
  3715. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3716. res.Infcode = infocode
  3717. } else {
  3718. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3719. utils.ErrorLog("解析失败:%v", err)
  3720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3721. return
  3722. }
  3723. }
  3724. if res.Infcode == 0 {
  3725. item.IsSale = 1
  3726. item.Bchno = number
  3727. item.SaleDate = time.Now().Format("2006-01-02")
  3728. service.SaveDF(item)
  3729. //if err5 == nil {
  3730. // if item.IsChange == 0 { //没变更,进行变更操作
  3731. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3732. //
  3733. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3734. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3735. //
  3736. // var respJSON3 map[string]interface{}
  3737. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3738. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3740. // return
  3741. // }
  3742. //
  3743. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3744. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3745. // utils.ErrorLog("解析失败:%v", err)
  3746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3747. // return
  3748. // }
  3749. // //if res3507for10188.Infcode
  3750. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3751. // //res.Output = resSix10265.Output
  3752. // res3.ErrMsg = res3507for10188.ErrMsg
  3753. // res3.Cainfo = res3507for10188.Cainfo
  3754. // res3.WarnMsg = res3507for10188.WarnMsg
  3755. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3756. // res3.Infcode = infocode
  3757. // } else {
  3758. //
  3759. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3760. // utils.ErrorLog("解析失败:%v", err)
  3761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3762. // return
  3763. // }
  3764. //
  3765. // }
  3766. //
  3767. // if res3.Infcode == 0 {
  3768. // item.IsChange = 1
  3769. // item.BgBchno = bg_number
  3770. // service.SaveDF2(item)
  3771. // } else {
  3772. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3773. // }
  3774. // }
  3775. //}
  3776. } else {
  3777. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3778. }
  3779. }
  3780. } else { //还没结算
  3781. var res3507for10188 FJ3507ResultFor10188
  3782. if item.IsChange == 0 { //没变更,进行变更操作
  3783. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3784. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3785. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3786. var respJSON3 map[string]interface{}
  3787. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3790. return
  3791. }
  3792. userJSONBytes3, _ := json.Marshal(respJSON3)
  3793. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3794. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3795. utils.ErrorLog("解析失败:%v", err)
  3796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3797. return
  3798. }
  3799. //if res3507for10188.Infcode
  3800. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3801. //res.Output = resSix10265.Output
  3802. res3.ErrMsg = res3507for10188.ErrMsg
  3803. res3.Cainfo = res3507for10188.Cainfo
  3804. res3.WarnMsg = res3507for10188.WarnMsg
  3805. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3806. res3.Infcode = infocode
  3807. } else {
  3808. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3809. utils.ErrorLog("解析失败:%v", err)
  3810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3811. return
  3812. }
  3813. }
  3814. if res3.Infcode == 0 {
  3815. item.IsChange = 1
  3816. item.BgBchno = bg_number
  3817. service.SaveDF2(item)
  3818. } else {
  3819. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3820. }
  3821. }
  3822. }
  3823. }
  3824. //if item.ConsumableType == 7 {
  3825. // var res3507for10188 FJ3507ResultFor10188
  3826. //
  3827. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3828. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3829. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3830. // //判断是否已经销售
  3831. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3832. // //是否已经变更 1是 0否
  3833. // if item.IsChange == 0 { //没变更,进行变更操作
  3834. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3835. //
  3836. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3837. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3838. //
  3839. // var respJSON3 map[string]interface{}
  3840. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3841. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. // return
  3844. // }
  3845. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3846. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3847. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3848. // utils.ErrorLog("解析失败:%v", err)
  3849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3850. // return
  3851. // }
  3852. // //if res3507for10188.Infcode
  3853. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3854. // //res.Output = resSix10265.Output
  3855. // res3.ErrMsg = res3507for10188.ErrMsg
  3856. // res3.Cainfo = res3507for10188.Cainfo
  3857. // res3.WarnMsg = res3507for10188.WarnMsg
  3858. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3859. // res3.Infcode = infocode
  3860. // } else {
  3861. //
  3862. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3863. // utils.ErrorLog("解析失败:%v", err)
  3864. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3865. // return
  3866. // }
  3867. //
  3868. // }
  3869. // if res3.Infcode == 0 {
  3870. // item.IsChange = 1
  3871. // item.BgBchno = bg_number
  3872. // service.SaveDF2(item)
  3873. // } else {
  3874. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3875. // }
  3876. // }
  3877. // } else { //没销售,
  3878. // //进行商品销售退货接口
  3879. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3880. //
  3881. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3882. // saveLog(result111, result222, "3506", "销售退货")
  3883. // var res7 FJ3507Result
  3884. //
  3885. // //进行商品销售接口
  3886. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3887. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3888. // var respJSON3 map[string]interface{}
  3889. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3890. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3892. // return
  3893. // }
  3894. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3895. //
  3896. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3897. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3898. // utils.ErrorLog("解析失败:%v", err)
  3899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3900. // return
  3901. // }
  3902. // //if res3507for10188.Infcode
  3903. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3904. // //res.Output = resSix10265.Output
  3905. // res7.ErrMsg = res3507for10188.ErrMsg
  3906. // res7.Cainfo = res3507for10188.Cainfo
  3907. // res7.WarnMsg = res3507for10188.WarnMsg
  3908. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3909. // res7.Infcode = infocode
  3910. // } else {
  3911. //
  3912. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3913. // utils.ErrorLog("解析失败:%v", err)
  3914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3915. // return
  3916. // }
  3917. //
  3918. // }
  3919. // if res7.Infcode == 0 {
  3920. // item.IsSale = 2
  3921. // item.SaleDate = item.SaleDate
  3922. // item.Bchno = number
  3923. // service.SaveDF(item)
  3924. // if item.IsChange == 0 { //没变更,进行变更操作
  3925. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3926. //
  3927. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3928. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3929. //
  3930. // var respJSON3 map[string]interface{}
  3931. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3932. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3934. // return
  3935. // }
  3936. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3937. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3938. // // utils.ErrorLog("解析失败:%v", err)
  3939. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3940. // // return
  3941. // //}
  3942. //
  3943. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3944. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3945. // utils.ErrorLog("解析失败:%v", err)
  3946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3947. // return
  3948. // }
  3949. // //if res3507for10188.Infcode
  3950. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3951. // //res.Output = resSix10265.Output
  3952. // res3.ErrMsg = res3507for10188.ErrMsg
  3953. // res3.Cainfo = res3507for10188.Cainfo
  3954. // res3.WarnMsg = res3507for10188.WarnMsg
  3955. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3956. // res3.Infcode = infocode
  3957. // } else {
  3958. //
  3959. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3960. // utils.ErrorLog("解析失败:%v", err)
  3961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. // return
  3963. // }
  3964. //
  3965. // }
  3966. // if res3.Infcode == 0 {
  3967. // item.IsChange = 1
  3968. // item.BgBchno = bg_number
  3969. // service.SaveDF2(item)
  3970. // } else {
  3971. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3972. // }
  3973. // }
  3974. // } else {
  3975. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3976. // }
  3977. // }
  3978. // } else { //还没结算
  3979. // if item.IsChange == 0 { //没变更,进行变更操作
  3980. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3981. //
  3982. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3983. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3984. //
  3985. // var respJSON3 map[string]interface{}
  3986. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3987. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3989. // return
  3990. // }
  3991. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3992. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3993. // // utils.ErrorLog("解析失败:%v", err)
  3994. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. // // return
  3996. // //}
  3997. //
  3998. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3999. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4000. // utils.ErrorLog("解析失败:%v", err)
  4001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4002. // return
  4003. // }
  4004. // //if res3507for10188.Infcode
  4005. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4006. // //res.Output = resSix10265.Output
  4007. // res3.ErrMsg = res3507for10188.ErrMsg
  4008. // res3.Cainfo = res3507for10188.Cainfo
  4009. // res3.WarnMsg = res3507for10188.WarnMsg
  4010. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4011. // res3.Infcode = infocode
  4012. // } else {
  4013. //
  4014. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4015. // utils.ErrorLog("解析失败:%v", err)
  4016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4017. // return
  4018. // }
  4019. //
  4020. // }
  4021. // if res3.Infcode == 0 {
  4022. // item.IsChange = 1
  4023. // item.BgBchno = bg_number
  4024. // service.SaveDF2(item)
  4025. // } else {
  4026. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4027. // }
  4028. // }
  4029. // }
  4030. //}
  4031. }
  4032. if len(err) == 0 {
  4033. c.ServeSuccessJSON(map[string]interface{}{
  4034. "msg": "销售变更成功",
  4035. })
  4036. } else {
  4037. c.ServeSuccessJSON(map[string]interface{}{
  4038. "failed_code": -10,
  4039. "msg": err,
  4040. })
  4041. }
  4042. }
  4043. func (c *HisApiController) ChangeDrugthree() {
  4044. //ids := c.GetString("ids")
  4045. //id_arr := strings.Split(ids, ",")
  4046. flows, _ := service.GetNewDrugFlowInfothree()
  4047. admin_user_id, _ := c.GetInt64("admin_user_id")
  4048. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4049. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4050. var err []string
  4051. for _, item := range flows {
  4052. var res3 ResultSix
  4053. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4054. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4055. if prescription.OrderStatus == 2 {
  4056. //已经结算
  4057. //判断是否已经销售
  4058. if item.IsSale == 1 { //是否已经销售,1是 0否
  4059. //是否已经变更 1是 0否
  4060. if item.IsChange == 0 { //没变更,进行变更操作
  4061. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4062. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4063. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4064. var respJSON3 map[string]interface{}
  4065. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4068. return
  4069. }
  4070. userJSONBytes3, _ := json.Marshal(respJSON3)
  4071. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4072. utils.ErrorLog("解析失败:%v", err)
  4073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4074. return
  4075. }
  4076. if res3.Infcode == 0 {
  4077. item.IsChange = 1
  4078. item.BgBchno = bg_number
  4079. service.SaveDF2(item)
  4080. } else {
  4081. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4082. }
  4083. }
  4084. } else { //没销售,
  4085. var res FJ3507Result
  4086. var res3507for10188 FJ3507ResultFor10188
  4087. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4088. //进行商品销售接口
  4089. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4090. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4091. var respJSON3 map[string]interface{}
  4092. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4095. return
  4096. }
  4097. userJSONBytes3, _ := json.Marshal(respJSON3)
  4098. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4099. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4100. utils.ErrorLog("解析失败:%v", err)
  4101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4102. return
  4103. }
  4104. //if res3507for10188.Infcode
  4105. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4106. //res.Output = resSix10265.Output
  4107. res.ErrMsg = res3507for10188.ErrMsg
  4108. res.Cainfo = res3507for10188.Cainfo
  4109. res.WarnMsg = res3507for10188.WarnMsg
  4110. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4111. res.Infcode = infocode
  4112. } else {
  4113. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4114. utils.ErrorLog("解析失败:%v", err)
  4115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4116. return
  4117. }
  4118. }
  4119. if res.Infcode == 0 {
  4120. item.IsSale = 1
  4121. item.Bchno = number
  4122. item.SaleDate = time.Now().Format("2006-01-02")
  4123. err5 := service.SaveDF(item)
  4124. if err5 == nil {
  4125. if item.IsChange == 0 { //没变更,进行变更操作
  4126. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4127. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4128. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4129. var respJSON3 map[string]interface{}
  4130. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4133. return
  4134. }
  4135. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4136. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4137. utils.ErrorLog("解析失败:%v", err)
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4139. return
  4140. }
  4141. //if res3507for10188.Infcode
  4142. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4143. //res.Output = resSix10265.Output
  4144. res3.ErrMsg = res3507for10188.ErrMsg
  4145. res3.Cainfo = res3507for10188.Cainfo
  4146. res3.WarnMsg = res3507for10188.WarnMsg
  4147. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4148. res3.Infcode = infocode
  4149. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4150. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4151. utils.ErrorLog("解析失败:%v", err)
  4152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4153. return
  4154. }
  4155. //if res3507for10188.Infcode
  4156. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4157. //res.Output = resSix10265.Output
  4158. res3.ErrMsg = res3507for10188.ErrMsg
  4159. res3.Cainfo = res3507for10188.Cainfo
  4160. res3.WarnMsg = res3507for10188.WarnMsg
  4161. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4162. res3.Infcode = infocode
  4163. } else {
  4164. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4165. utils.ErrorLog("解析失败:%v", err)
  4166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4167. return
  4168. }
  4169. }
  4170. if res3.Infcode == 0 {
  4171. item.IsChange = 1
  4172. item.BgBchno = bg_number
  4173. service.SaveDF2(item)
  4174. } else {
  4175. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4176. }
  4177. }
  4178. }
  4179. } else {
  4180. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4181. }
  4182. }
  4183. } else { //还没结算
  4184. var res3507for10188 FJ3507ResultFor10188
  4185. if item.IsChange == 0 { //没变更,进行变更操作
  4186. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4187. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4188. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4189. var respJSON3 map[string]interface{}
  4190. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4193. return
  4194. }
  4195. userJSONBytes3, _ := json.Marshal(respJSON3)
  4196. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4197. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4198. utils.ErrorLog("解析失败:%v", err)
  4199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4200. return
  4201. }
  4202. //if res3507for10188.Infcode
  4203. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4204. //res.Output = resSix10265.Output
  4205. res3.ErrMsg = res3507for10188.ErrMsg
  4206. res3.Cainfo = res3507for10188.Cainfo
  4207. res3.WarnMsg = res3507for10188.WarnMsg
  4208. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4209. res3.Infcode = infocode
  4210. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4211. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4212. utils.ErrorLog("解析失败:%v", err)
  4213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4214. return
  4215. }
  4216. //if res3507for10188.Infcode
  4217. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4218. //res.Output = resSix10265.Output
  4219. res3.ErrMsg = res3507for10188.ErrMsg
  4220. res3.Cainfo = res3507for10188.Cainfo
  4221. res3.WarnMsg = res3507for10188.WarnMsg
  4222. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4223. res3.Infcode = infocode
  4224. } else {
  4225. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4226. utils.ErrorLog("解析失败:%v", err)
  4227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4228. return
  4229. }
  4230. }
  4231. if res3.Infcode == 0 {
  4232. item.IsChange = 1
  4233. item.BgBchno = bg_number
  4234. service.SaveDF2(item)
  4235. } else {
  4236. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4237. }
  4238. }
  4239. }
  4240. } else if item.ConsumableType == 7 {
  4241. var res3507for10188 FJ3507ResultFor10188
  4242. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4243. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4244. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4245. //判断是否已经销售
  4246. if item.IsSale == 2 { //是否已经销售,1是 0否
  4247. //是否已经变更 1是 0否
  4248. if item.IsChange == 0 { //没变更,进行变更操作
  4249. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4250. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4251. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4252. var respJSON3 map[string]interface{}
  4253. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4256. return
  4257. }
  4258. userJSONBytes3, _ := json.Marshal(respJSON3)
  4259. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4260. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4261. utils.ErrorLog("解析失败:%v", err)
  4262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4263. return
  4264. }
  4265. //if res3507for10188.Infcode
  4266. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4267. //res.Output = resSix10265.Output
  4268. res3.ErrMsg = res3507for10188.ErrMsg
  4269. res3.Cainfo = res3507for10188.Cainfo
  4270. res3.WarnMsg = res3507for10188.WarnMsg
  4271. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4272. res3.Infcode = infocode
  4273. } else {
  4274. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4275. utils.ErrorLog("解析失败:%v", err)
  4276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4277. return
  4278. }
  4279. }
  4280. if res3.Infcode == 0 {
  4281. item.IsChange = 1
  4282. item.BgBchno = bg_number
  4283. service.SaveDF2(item)
  4284. } else {
  4285. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4286. }
  4287. }
  4288. } else { //没销售,
  4289. //进行商品销售退货接口
  4290. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4291. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4292. saveLog(result111, result222, "3506", "销售退货")
  4293. var res7 FJ3507Result
  4294. //进行商品销售接口
  4295. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4296. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4297. var respJSON3 map[string]interface{}
  4298. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. return
  4302. }
  4303. userJSONBytes3, _ := json.Marshal(respJSON3)
  4304. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4305. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4306. utils.ErrorLog("解析失败:%v", err)
  4307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4308. return
  4309. }
  4310. //if res3507for10188.Infcode
  4311. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4312. //res.Output = resSix10265.Output
  4313. res7.ErrMsg = res3507for10188.ErrMsg
  4314. res7.Cainfo = res3507for10188.Cainfo
  4315. res7.WarnMsg = res3507for10188.WarnMsg
  4316. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4317. res7.Infcode = infocode
  4318. } else {
  4319. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4320. utils.ErrorLog("解析失败:%v", err)
  4321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4322. return
  4323. }
  4324. }
  4325. if res7.Infcode == 0 {
  4326. item.IsSale = 2
  4327. item.SaleDate = item.SaleDate
  4328. item.Bchno = number
  4329. service.SaveDF(item)
  4330. if item.IsChange == 0 { //没变更,进行变更操作
  4331. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4332. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4333. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4334. var respJSON3 map[string]interface{}
  4335. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4338. return
  4339. }
  4340. userJSONBytes3, _ := json.Marshal(respJSON3)
  4341. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4342. // utils.ErrorLog("解析失败:%v", err)
  4343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. // return
  4345. //}
  4346. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4347. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4348. utils.ErrorLog("解析失败:%v", err)
  4349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. return
  4351. }
  4352. //if res3507for10188.Infcode
  4353. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4354. //res.Output = resSix10265.Output
  4355. res3.ErrMsg = res3507for10188.ErrMsg
  4356. res3.Cainfo = res3507for10188.Cainfo
  4357. res3.WarnMsg = res3507for10188.WarnMsg
  4358. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4359. res3.Infcode = infocode
  4360. } else {
  4361. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4362. utils.ErrorLog("解析失败:%v", err)
  4363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4364. return
  4365. }
  4366. }
  4367. if res3.Infcode == 0 {
  4368. item.IsChange = 1
  4369. item.BgBchno = bg_number
  4370. service.SaveDF2(item)
  4371. } else {
  4372. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4373. }
  4374. }
  4375. } else {
  4376. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4377. }
  4378. }
  4379. } else { //还没结算
  4380. if item.IsChange == 0 { //没变更,进行变更操作
  4381. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4382. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4383. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4384. var respJSON3 map[string]interface{}
  4385. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4388. return
  4389. }
  4390. userJSONBytes3, _ := json.Marshal(respJSON3)
  4391. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4392. // utils.ErrorLog("解析失败:%v", err)
  4393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. // return
  4395. //}
  4396. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4397. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4398. utils.ErrorLog("解析失败:%v", err)
  4399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4400. return
  4401. }
  4402. //if res3507for10188.Infcode
  4403. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4404. //res.Output = resSix10265.Output
  4405. res3.ErrMsg = res3507for10188.ErrMsg
  4406. res3.Cainfo = res3507for10188.Cainfo
  4407. res3.WarnMsg = res3507for10188.WarnMsg
  4408. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4409. res3.Infcode = infocode
  4410. } else {
  4411. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4412. utils.ErrorLog("解析失败:%v", err)
  4413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4414. return
  4415. }
  4416. }
  4417. if res3.Infcode == 0 {
  4418. item.IsChange = 1
  4419. item.BgBchno = bg_number
  4420. service.SaveDF2(item)
  4421. } else {
  4422. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4423. }
  4424. }
  4425. }
  4426. }
  4427. }
  4428. if len(err) == 0 {
  4429. c.ServeSuccessJSON(map[string]interface{}{
  4430. "msg": "销售变更成功",
  4431. })
  4432. } else {
  4433. c.ServeSuccessJSON(map[string]interface{}{
  4434. "failed_code": -10,
  4435. "msg": err,
  4436. })
  4437. }
  4438. }
  4439. func (c *HisApiController) ChangeDrugTen() {
  4440. start_time_str := c.GetString("start_time")
  4441. end_time_str := c.GetString("end_time")
  4442. //ids := c.GetString("ids")
  4443. //id_arr := strings.Split(ids, ",")
  4444. timeLayout := "2006-01-02"
  4445. loc, _ := time.LoadLocation("Local")
  4446. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4447. recordStartTime := theStartTime.Unix()
  4448. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4449. recordEndTime := theEndTime.Unix()
  4450. //timestamp := int64(1729612800)
  4451. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4452. admin_user_id, _ := c.GetInt64("admin_user_id")
  4453. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4454. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4455. var err []string
  4456. for _, item := range flows {
  4457. var res3 ResultSix
  4458. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4459. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4460. continue
  4461. }
  4462. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4463. continue
  4464. }
  4465. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4466. if prescription.OrderStatus == 2 {
  4467. //已经结算
  4468. //判断 是否已经销售
  4469. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4470. ////是否已经变更 1是 0否
  4471. //if item.IsChange == 0 { //没变更,进行变更操作
  4472. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4473. //
  4474. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4475. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4476. // var respJSON3 map[string]interface{}
  4477. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4478. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4480. // return
  4481. // }
  4482. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4483. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4484. // utils.ErrorLog("解析失败:%v", err)
  4485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4486. // return
  4487. // }
  4488. // if res3.Infcode == 0 {
  4489. // item.IsChange = 1
  4490. // item.BgBchno = bg_number
  4491. // service.SaveDF2(item)
  4492. // } else {
  4493. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4494. // }
  4495. //}
  4496. //} else
  4497. if item.IsSale == 0 { //没销售,
  4498. var res FJ3507Result
  4499. var res3507for10188 FJ3507ResultFor10188
  4500. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4501. //进行商品销售接口
  4502. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4503. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4504. var respJSON3 map[string]interface{}
  4505. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4508. return
  4509. }
  4510. userJSONBytes3, _ := json.Marshal(respJSON3)
  4511. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4512. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4513. utils.ErrorLog("解析失败:%v", err)
  4514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4515. return
  4516. }
  4517. //if res3507for10188.Infcode
  4518. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4519. //res.Output = resSix10265.Output
  4520. res.ErrMsg = res3507for10188.ErrMsg
  4521. res.Cainfo = res3507for10188.Cainfo
  4522. res.WarnMsg = res3507for10188.WarnMsg
  4523. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4524. res.Infcode = infocode
  4525. } else {
  4526. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4527. utils.ErrorLog("解析失败:%v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. }
  4532. if res.Infcode == 0 {
  4533. item.IsSale = 1
  4534. item.Bchno = number
  4535. item.SaleDate = time.Now().Format("2006-01-02")
  4536. err5 := service.SaveDF(item)
  4537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4538. //if err5 == nil {
  4539. //
  4540. // if item.IsChange == 1 { //没变更,进行变更操作
  4541. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4542. //
  4543. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4544. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4545. //
  4546. // var respJSON3 map[string]interface{}
  4547. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4548. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4550. // return
  4551. // }
  4552. //
  4553. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4554. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4555. // utils.ErrorLog("解析失败:%v", err)
  4556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4557. // return
  4558. // }
  4559. // //if res3507for10188.Infcode
  4560. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4561. // //res.Output = resSix10265.Output
  4562. // res3.ErrMsg = res3507for10188.ErrMsg
  4563. // res3.Cainfo = res3507for10188.Cainfo
  4564. // res3.WarnMsg = res3507for10188.WarnMsg
  4565. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4566. // res3.Infcode = infocode
  4567. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4568. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4569. // utils.ErrorLog("解析失败:%v", err)
  4570. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. // return
  4572. // }
  4573. // //if res3507for10188.Infcode
  4574. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4575. // //res.Output = resSix10265.Output
  4576. // res3.ErrMsg = res3507for10188.ErrMsg
  4577. // res3.Cainfo = res3507for10188.Cainfo
  4578. // res3.WarnMsg = res3507for10188.WarnMsg
  4579. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4580. // res3.Infcode = infocode
  4581. //
  4582. // } else {
  4583. //
  4584. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4585. // utils.ErrorLog("解析失败:%v", err)
  4586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4587. // return
  4588. // }
  4589. //
  4590. // }
  4591. //
  4592. // if res3.Infcode == 0 {
  4593. // item.IsChange = 1
  4594. // item.BgBchno = bg_number
  4595. // service.SaveDF2(item)
  4596. // return
  4597. // } else {
  4598. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4599. // }
  4600. // }
  4601. //}
  4602. } else {
  4603. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4604. }
  4605. }
  4606. }
  4607. } else if item.ConsumableType == 7 {
  4608. var res3507for10188 FJ3507ResultFor10188
  4609. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4610. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4611. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4612. //判断是否已经销售
  4613. if item.IsSale == 2 { //是否已经销售,1是 0否
  4614. //是否已经变更 1是 0否
  4615. if item.IsChange == 0 { //没变更,进行变更操作
  4616. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4617. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4618. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4619. var respJSON3 map[string]interface{}
  4620. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4623. return
  4624. }
  4625. userJSONBytes3, _ := json.Marshal(respJSON3)
  4626. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4627. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4628. utils.ErrorLog("解析失败:%v", err)
  4629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4630. return
  4631. }
  4632. //if res3507for10188.Infcode
  4633. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4634. //res.Output = resSix10265.Output
  4635. res3.ErrMsg = res3507for10188.ErrMsg
  4636. res3.Cainfo = res3507for10188.Cainfo
  4637. res3.WarnMsg = res3507for10188.WarnMsg
  4638. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4639. res3.Infcode = infocode
  4640. } else {
  4641. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. }
  4647. if res3.Infcode == 0 {
  4648. item.IsChange = 1
  4649. item.BgBchno = bg_number
  4650. service.SaveDF2(item)
  4651. } else {
  4652. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4653. }
  4654. }
  4655. } else { //没销售,
  4656. //进行商品销售退货接口
  4657. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4658. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4659. saveLog(result111, result222, "3506", "销售退货")
  4660. var res7 FJ3507Result
  4661. //进行商品销售接口
  4662. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4663. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4664. var respJSON3 map[string]interface{}
  4665. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4668. return
  4669. }
  4670. userJSONBytes3, _ := json.Marshal(respJSON3)
  4671. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4672. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4673. utils.ErrorLog("解析失败:%v", err)
  4674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4675. return
  4676. }
  4677. //if res3507for10188.Infcode
  4678. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4679. //res.Output = resSix10265.Output
  4680. res7.ErrMsg = res3507for10188.ErrMsg
  4681. res7.Cainfo = res3507for10188.Cainfo
  4682. res7.WarnMsg = res3507for10188.WarnMsg
  4683. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4684. res7.Infcode = infocode
  4685. } else {
  4686. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4687. utils.ErrorLog("解析失败:%v", err)
  4688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4689. return
  4690. }
  4691. }
  4692. if res7.Infcode == 0 {
  4693. item.IsSale = 2
  4694. item.SaleDate = item.SaleDate
  4695. item.Bchno = number
  4696. service.SaveDF(item)
  4697. if item.IsChange == 0 { //没变更,进行变更操作
  4698. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4699. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4700. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4701. var respJSON3 map[string]interface{}
  4702. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4705. return
  4706. }
  4707. userJSONBytes3, _ := json.Marshal(respJSON3)
  4708. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4709. // utils.ErrorLog("解析失败:%v", err)
  4710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4711. // return
  4712. //}
  4713. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4714. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4715. utils.ErrorLog("解析失败:%v", err)
  4716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4717. return
  4718. }
  4719. //if res3507for10188.Infcode
  4720. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4721. //res.Output = resSix10265.Output
  4722. res3.ErrMsg = res3507for10188.ErrMsg
  4723. res3.Cainfo = res3507for10188.Cainfo
  4724. res3.WarnMsg = res3507for10188.WarnMsg
  4725. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4726. res3.Infcode = infocode
  4727. } else {
  4728. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4729. utils.ErrorLog("解析失败:%v", err)
  4730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4731. return
  4732. }
  4733. }
  4734. if res3.Infcode == 0 {
  4735. item.IsChange = 1
  4736. item.BgBchno = bg_number
  4737. service.SaveDF2(item)
  4738. } else {
  4739. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4740. }
  4741. }
  4742. } else {
  4743. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4744. }
  4745. }
  4746. } else { //还没结算
  4747. if item.IsChange == 0 { //没变更,进行变更操作
  4748. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4749. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4750. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4751. var respJSON3 map[string]interface{}
  4752. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. userJSONBytes3, _ := json.Marshal(respJSON3)
  4758. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4759. // utils.ErrorLog("解析失败:%v", err)
  4760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4761. // return
  4762. //}
  4763. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4764. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4765. utils.ErrorLog("解析失败:%v", err)
  4766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4767. return
  4768. }
  4769. //if res3507for10188.Infcode
  4770. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4771. //res.Output = resSix10265.Output
  4772. res3.ErrMsg = res3507for10188.ErrMsg
  4773. res3.Cainfo = res3507for10188.Cainfo
  4774. res3.WarnMsg = res3507for10188.WarnMsg
  4775. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4776. res3.Infcode = infocode
  4777. } else {
  4778. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4779. utils.ErrorLog("解析失败:%v", err)
  4780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4781. return
  4782. }
  4783. }
  4784. if res3.Infcode == 0 {
  4785. item.IsChange = 1
  4786. item.BgBchno = bg_number
  4787. service.SaveDF2(item)
  4788. } else {
  4789. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4790. }
  4791. }
  4792. }
  4793. }
  4794. }
  4795. if len(err) == 0 {
  4796. c.ServeSuccessJSON(map[string]interface{}{
  4797. "msg": "销售变更成功",
  4798. })
  4799. } else {
  4800. c.ServeSuccessJSON(map[string]interface{}{
  4801. "failed_code": -10,
  4802. "msg": err,
  4803. })
  4804. }
  4805. }
  4806. func ChangeDrugTenone() {
  4807. //ids := c.GetString("ids")
  4808. //id_arr := strings.Split(ids, ",")
  4809. now := time.Now()
  4810. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4811. //timestamp := int64(1729612800)
  4812. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4813. admin_user_id := int64(2463)
  4814. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4815. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4816. var err []string
  4817. for _, item := range flows {
  4818. var res3 ResultSix
  4819. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4820. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4821. continue
  4822. }
  4823. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4824. continue
  4825. }
  4826. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4827. if prescription.OrderStatus == 2 {
  4828. //已经结算
  4829. //判断是否已经销售
  4830. if item.IsSale == 1 { //是否已经销售,1是 0否
  4831. //是否已经变更 1是 0否
  4832. if item.IsChange == 0 { //没变更,进行变更操作
  4833. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4834. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4835. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4836. var respJSON3 map[string]interface{}
  4837. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4839. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4840. return
  4841. }
  4842. userJSONBytes3, _ := json.Marshal(respJSON3)
  4843. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4844. utils.ErrorLog("解析失败:%v", err)
  4845. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4846. return
  4847. }
  4848. if res3.Infcode == 0 {
  4849. item.IsChange = 1
  4850. item.BgBchno = bg_number
  4851. service.SaveDF2(item)
  4852. } else {
  4853. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4854. }
  4855. }
  4856. } else { //没销售,
  4857. var res FJ3507Result
  4858. var res3507for10188 FJ3507ResultFor10188
  4859. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4860. //进行商品销售接口
  4861. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4862. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4863. var respJSON3 map[string]interface{}
  4864. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4866. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. userJSONBytes3, _ := json.Marshal(respJSON3)
  4870. {
  4871. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4872. utils.ErrorLog("解析失败:%v", err)
  4873. return
  4874. }
  4875. //if res3507for10188.Infcode
  4876. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4877. //res.Output = resSix10265.Output
  4878. res.ErrMsg = res3507for10188.ErrMsg
  4879. res.Cainfo = res3507for10188.Cainfo
  4880. res.WarnMsg = res3507for10188.WarnMsg
  4881. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4882. res.Infcode = infocode
  4883. }
  4884. if res.Infcode == 0 {
  4885. item.IsSale = 1
  4886. item.Bchno = number
  4887. item.SaleDate = time.Now().Format("2006-01-02")
  4888. err5 := service.SaveDF(item)
  4889. if err5 == nil {
  4890. if item.IsChange == 1 { //没变更,进行变更操作
  4891. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4892. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4893. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4894. var respJSON3 map[string]interface{}
  4895. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4897. return
  4898. }
  4899. {
  4900. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4901. utils.ErrorLog("解析失败:%v", err)
  4902. return
  4903. }
  4904. //if res3507for10188.Infcode
  4905. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4906. //res.Output = resSix10265.Output
  4907. res3.ErrMsg = res3507for10188.ErrMsg
  4908. res3.Cainfo = res3507for10188.Cainfo
  4909. res3.WarnMsg = res3507for10188.WarnMsg
  4910. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4911. res3.Infcode = infocode
  4912. }
  4913. if res3.Infcode == 0 {
  4914. item.IsChange = 1
  4915. item.BgBchno = bg_number
  4916. service.SaveDF2(item)
  4917. } else {
  4918. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4919. }
  4920. }
  4921. }
  4922. } else {
  4923. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4924. }
  4925. }
  4926. }
  4927. }
  4928. }
  4929. }
  4930. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4931. var struct3502 models.Struct3502
  4932. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4933. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4934. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4935. struct3502.FixmedinsCode = miConfig.Code
  4936. struct3502.Code = miConfig.Code
  4937. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4938. struct3502.Opter = role.UserName
  4939. struct3502.RxFlag = "1"
  4940. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4941. struct3502.OrgName = miConfig.OrgName
  4942. struct3502.AccessKey = miConfig.AccessKey
  4943. struct3502.RequestUrl = miConfig.Url
  4944. struct3502.SecretKey = miConfig.SecretKey
  4945. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4946. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4947. struct3502.Url = miConfig.Url
  4948. struct3502.AppId = miConfig.Cainfo
  4949. struct3502.AppSecret = miConfig.AppSecret
  4950. struct3502.Enckey = miConfig.EncKey
  4951. struct3502.SignKey = miConfig.SignKey
  4952. struct3502.SecretKey = miConfig.SecretKey
  4953. struct3502.InvChgType = chgType
  4954. struct3502.FixmedinsBchno = number
  4955. struct3502.Cnt = strconv.FormatInt(count, 10)
  4956. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4957. //result1, result2, _ := service.FJyb3502(struct3502)
  4958. if miConfig.MdtrtareaAdmvs == "350500" {
  4959. result1, result2, _ := service.FJyb3502(struct3502)
  4960. //saveLog(result1, result2, "3502", "3502")
  4961. return result1, result2
  4962. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4963. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4964. return result1, result2
  4965. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4966. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4967. return result1, result2
  4968. } else {
  4969. data := make(map[string]interface{})
  4970. data["struct_3502s"] = struct3502
  4971. client := &http.Client{}
  4972. bytesData, _ := json.Marshal(data)
  4973. var req *http.Request
  4974. if miConfig.MdtrtareaAdmvs == "320921" {
  4975. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4976. } else {
  4977. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4978. }
  4979. resp, _ := client.Do(req)
  4980. defer resp.Body.Close()
  4981. body, ioErr := ioutil.ReadAll(resp.Body)
  4982. if ioErr != nil {
  4983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4984. }
  4985. var respJSON map[string]interface{}
  4986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4988. }
  4989. //var resSix10265 ResultSix10265 //1101结果
  4990. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4991. result, _ := json.Marshal(respJSON)
  4992. return string(result), ""
  4993. }
  4994. }
  4995. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4996. var struct3505 models.Struct3505
  4997. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4998. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4999. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5000. struct3505.FixmedinsBchno = number
  5001. struct3505.Opter = role.UserName
  5002. struct3505.Bchno = "---"
  5003. struct3505.FixmedinsCode = miConfig.Code
  5004. struct3505.Code = miConfig.Code
  5005. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5006. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5007. struct3505.PrscDrName = roles.UserName
  5008. if org_id == 10191 {
  5009. struct3505.PharName = "刘水山"
  5010. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5011. }
  5012. if org_id == 10188 {
  5013. struct3505.PharName = "李汉清"
  5014. struct3505.PharPracCertNo = "30220200932022010034"
  5015. }
  5016. if org_id == 10217 {
  5017. struct3505.PharName = "张敏"
  5018. struct3505.PharPracCertNo = "30220230432090100108"
  5019. }
  5020. if org_id == 10318 {
  5021. struct3505.PharName = "邹刘阳"
  5022. struct3505.PharPracCertNo = "210441200001378"
  5023. }
  5024. if org_id == 10402 {
  5025. struct3505.PharName = "刘韶健"
  5026. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5027. }
  5028. if org_id == 9919 {
  5029. struct3505.PharName = "周君权"
  5030. struct3505.PharPracCertNo = "089644396094401375"
  5031. }
  5032. if org_id == 10644 {
  5033. struct3505.PharName = "陈金娣"
  5034. struct3505.PharPracCertNo = "20181441500320100066"
  5035. }
  5036. if org_id == 10567 {
  5037. struct3505.PharName = "范小兰"
  5038. struct3505.PharPracCertNo = "0200102079485"
  5039. }
  5040. if org_id == 10721 {
  5041. struct3505.PharName = "孙莉侠"
  5042. struct3505.PharPracCertNo = "060399"
  5043. }
  5044. if org_id == 10726 {
  5045. struct3505.PharName = "彭建福"
  5046. struct3505.PharPracCertNo = "D445281006261"
  5047. }
  5048. if org_id == 10265 {
  5049. struct3505.PharName = "李彩星"
  5050. struct3505.PharPracCertNo = "20171110600110100019"
  5051. }
  5052. if org_id == 10028 {
  5053. struct3505.PharName = "曾细平"
  5054. struct3505.PharPracCertNo = "D440307022134"
  5055. }
  5056. if org_id == 10138 {
  5057. struct3505.PharName = "彭斯遥"
  5058. struct3505.PharPracCertNo = "30220200943042010052"
  5059. }
  5060. if org_id == 10278 {
  5061. struct3505.PharName = "彭斯遥"
  5062. struct3505.PharPracCertNo = "30220200943042010052"
  5063. }
  5064. if org_id == 10610 {
  5065. struct3505.PharName = "彭斯遥"
  5066. struct3505.PharPracCertNo = "30220200943042010052"
  5067. }
  5068. if org_id == 10537 {
  5069. struct3505.PharName = "彭斯遥"
  5070. struct3505.PharPracCertNo = "30220200943042010052"
  5071. }
  5072. if org_id == 9504 {
  5073. struct3505.PharName = "资美红"
  5074. struct3505.PharPracCertNo = "D440904006635"
  5075. }
  5076. if org_id == 10480 {
  5077. struct3505.PharName = "陈思"
  5078. struct3505.PharPracCertNo = "30220240434110010470"
  5079. }
  5080. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5081. struct3505.SetlId = order.SetlId
  5082. struct3505.MdtrtSn = order.MdtrtId
  5083. struct3505.ManuLotnum = drug.BatchNumber
  5084. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5085. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5086. struct3505.RxFlag = "1"
  5087. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5088. struct3505.TrdnFlag = "0"
  5089. } else {
  5090. struct3505.TrdnFlag = "1"
  5091. }
  5092. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5093. struct3505.TrdnFlag = "1"
  5094. }
  5095. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5096. struct3505.TrdnFlag = "0"
  5097. }
  5098. struct3505.RtalDocno = order.Number
  5099. struct3505.PsnCertType = "01"
  5100. struct3505.CertNo = order.Certno
  5101. struct3505.PsnNo = order.PsnNo
  5102. struct3505.PsnName = order.PsnName
  5103. struct3505.Url = miConfig.Url
  5104. struct3505.AppId = miConfig.Cainfo
  5105. struct3505.AppSecret = miConfig.AppSecret
  5106. struct3505.Enckey = miConfig.EncKey
  5107. struct3505.SignKey = miConfig.SignKey
  5108. struct3505.SecretKey = miConfig.SecretKey
  5109. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5110. struct3505.SelRetnCnt = strValue
  5111. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5112. struct3505.SelRetnOpterName = role.UserName
  5113. if order.IsMedicineInsurance == 1 {
  5114. struct3505.MdtrtSetlType = "1"
  5115. } else {
  5116. struct3505.MdtrtSetlType = "2"
  5117. }
  5118. struct3505.OrgName = miConfig.OrgName
  5119. struct3505.AccessKey = miConfig.AccessKey
  5120. struct3505.RequestUrl = miConfig.Url
  5121. struct3505.SecretKey = miConfig.SecretKey
  5122. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5123. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5124. struct3505.Cainfo = miConfig.Cainfo
  5125. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5126. if miConfig.MdtrtareaAdmvs == "350500" {
  5127. result1, result2, _ := service.FJyb3505(struct3505)
  5128. return result1, result2
  5129. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5130. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5131. return result1, result2
  5132. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5133. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5134. return result1, result2
  5135. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5136. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5137. return result1, result2
  5138. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5139. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5140. return result1, result2
  5141. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5142. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5143. return result1, result2
  5144. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5145. data := make(map[string]interface{})
  5146. data["struct_3505s"] = struct3505
  5147. client := &http.Client{}
  5148. bytesData, _ := json.Marshal(data)
  5149. var req *http.Request
  5150. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5151. resp, _ := client.Do(req)
  5152. defer resp.Body.Close()
  5153. body, ioErr := ioutil.ReadAll(resp.Body)
  5154. if ioErr != nil {
  5155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5156. }
  5157. var respJSON map[string]interface{}
  5158. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5160. }
  5161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5162. result, _ := json.Marshal(respJSON)
  5163. return string(result), ""
  5164. } else {
  5165. data := make(map[string]interface{})
  5166. data["struct_3505s"] = struct3505
  5167. client := &http.Client{}
  5168. bytesData, _ := json.Marshal(data)
  5169. var req *http.Request
  5170. if miConfig.MdtrtareaAdmvs == "320921" {
  5171. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5172. } else {
  5173. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5174. }
  5175. resp, _ := client.Do(req)
  5176. defer resp.Body.Close()
  5177. body, ioErr := ioutil.ReadAll(resp.Body)
  5178. if ioErr != nil {
  5179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5180. }
  5181. var respJSON map[string]interface{}
  5182. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5184. }
  5185. //var resSix10265 ResultSix10265 //1101结果
  5186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5187. result, _ := json.Marshal(respJSON)
  5188. return string(result), ""
  5189. }
  5190. }
  5191. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5192. var struct3505 models.Struct3505
  5193. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5194. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5195. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5196. struct3505.FixmedinsBchno = number
  5197. struct3505.Opter = role.UserName
  5198. struct3505.FixmedinsCode = miConfig.Code
  5199. struct3505.Code = miConfig.Code
  5200. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5201. struct3505.PrscDrName = roles.UserName
  5202. if org_id == 10191 {
  5203. struct3505.PharName = "刘水山"
  5204. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5205. }
  5206. if org_id == 10188 {
  5207. struct3505.PharName = "李汉清"
  5208. struct3505.PharPracCertNo = "30220200932022010034"
  5209. }
  5210. if org_id == 10217 {
  5211. struct3505.PharName = "张敏"
  5212. struct3505.PharPracCertNo = "30220230432090100108"
  5213. }
  5214. if org_id == 10318 {
  5215. struct3505.PharName = "邹刘阳"
  5216. struct3505.PharPracCertNo = "210441200001378"
  5217. }
  5218. if org_id == 10402 {
  5219. struct3505.PharName = "刘韶健"
  5220. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5221. }
  5222. if org_id == 9919 {
  5223. struct3505.PharName = "周君权"
  5224. struct3505.PharPracCertNo = "089644396094401375"
  5225. }
  5226. if org_id == 10644 {
  5227. struct3505.PharName = "陈金娣"
  5228. struct3505.PharPracCertNo = "20181441500320100066"
  5229. }
  5230. if org_id == 10567 {
  5231. struct3505.PharName = "范小兰"
  5232. struct3505.PharPracCertNo = "0200102079485"
  5233. }
  5234. if org_id == 10721 {
  5235. struct3505.PharName = "孙莉侠"
  5236. struct3505.PharPracCertNo = "060399"
  5237. }
  5238. if org_id == 10726 {
  5239. struct3505.PharName = "彭建福"
  5240. struct3505.PharPracCertNo = "D445281006261"
  5241. }
  5242. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5243. struct3505.SetlId = order.SetlId
  5244. struct3505.MdtrtSn = order.MdtrtId
  5245. struct3505.ManuLotnum = drug.Number
  5246. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5247. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5248. struct3505.RxFlag = "1"
  5249. struct3505.TrdnFlag = "0"
  5250. struct3505.RtalDocno = order.Number
  5251. struct3505.PsnCertType = "01"
  5252. struct3505.CertNo = order.Certno
  5253. struct3505.PsnNo = order.PsnNo
  5254. struct3505.PsnName = order.PsnName
  5255. struct3505.Url = miConfig.Url
  5256. struct3505.AppId = miConfig.Cainfo
  5257. struct3505.AppSecret = miConfig.AppSecret
  5258. struct3505.Enckey = miConfig.EncKey
  5259. struct3505.SignKey = miConfig.SignKey
  5260. struct3505.SecretKey = miConfig.SecretKey
  5261. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5262. struct3505.SelRetnCnt = strValue
  5263. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5264. struct3505.SelRetnOpterName = role.UserName
  5265. if order.IsMedicineInsurance == 1 {
  5266. struct3505.MdtrtSetlType = "1"
  5267. } else {
  5268. struct3505.MdtrtSetlType = "2"
  5269. }
  5270. struct3505.OrgName = miConfig.OrgName
  5271. struct3505.AccessKey = miConfig.AccessKey
  5272. struct3505.RequestUrl = miConfig.Url
  5273. struct3505.SecretKey = miConfig.SecretKey
  5274. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5275. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5276. struct3505.Cainfo = miConfig.Cainfo
  5277. struct3505.DrugTracCodg = drug.DrugCode
  5278. if miConfig.MdtrtareaAdmvs == "350500" {
  5279. result1, result2, _ := service.FJyb3505(struct3505)
  5280. return result1, result2
  5281. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5282. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5283. return result1, result2
  5284. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5285. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5286. return result1, result2
  5287. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5288. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5289. return result1, result2
  5290. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5291. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5292. return result1, result2
  5293. } else {
  5294. data := make(map[string]interface{})
  5295. data["struct_3505s"] = struct3505
  5296. client := &http.Client{}
  5297. bytesData, _ := json.Marshal(data)
  5298. var req *http.Request
  5299. if miConfig.MdtrtareaAdmvs == "320921" {
  5300. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5301. } else {
  5302. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5303. }
  5304. resp, _ := client.Do(req)
  5305. defer resp.Body.Close()
  5306. body, ioErr := ioutil.ReadAll(resp.Body)
  5307. if ioErr != nil {
  5308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5309. }
  5310. var respJSON map[string]interface{}
  5311. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5313. }
  5314. //var resSix10265 ResultSix10265 //1101结果
  5315. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5316. result, _ := json.Marshal(respJSON)
  5317. return string(result), ""
  5318. }
  5319. }
  5320. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5321. var struct3506 models.Struct3506
  5322. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5323. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5324. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5325. struct3506.FixmedinsCode = miConfig.Code
  5326. struct3506.Code = miConfig.Code
  5327. struct3506.FixmedinsBchno = number
  5328. struct3506.Opter = role.UserName
  5329. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5330. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5331. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5332. struct3506.MdtrtSn = order.MdtrtId
  5333. struct3506.ExpyEnd = ""
  5334. struct3506.RxFlag = "0"
  5335. struct3506.TrdnFlag = "1"
  5336. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5337. struct3506.SelRetnCnt = strValue
  5338. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5339. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5340. struct3506.SelRetnOpterName = role.UserName
  5341. struct3506.OrgName = miConfig.OrgName
  5342. struct3506.AccessKey = miConfig.AccessKey
  5343. struct3506.RequestUrl = miConfig.Url
  5344. struct3506.SecretKey = miConfig.SecretKey
  5345. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5346. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5347. struct3506.Url = miConfig.Url
  5348. struct3506.AppId = miConfig.Cainfo
  5349. struct3506.AppSecret = miConfig.AppSecret
  5350. struct3506.Enckey = miConfig.EncKey
  5351. struct3506.SignKey = miConfig.SignKey
  5352. struct3506.SecretKey = miConfig.SecretKey
  5353. struct3506.DrugTracCodg = drug.DrugCode
  5354. if miConfig.MdtrtareaAdmvs == "350500" {
  5355. result1, result2, _ := service.FJyb3506(struct3506)
  5356. return result1, result2
  5357. } else {
  5358. data := make(map[string]interface{})
  5359. data["struct_3506s"] = struct3506
  5360. client := &http.Client{}
  5361. bytesData, _ := json.Marshal(data)
  5362. var req *http.Request
  5363. if miConfig.MdtrtareaAdmvs == "320921" {
  5364. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5365. } else {
  5366. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5367. }
  5368. resp, _ := client.Do(req)
  5369. defer resp.Body.Close()
  5370. body, ioErr := ioutil.ReadAll(resp.Body)
  5371. if ioErr != nil {
  5372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5373. }
  5374. var respJSON map[string]interface{}
  5375. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5377. }
  5378. //var resSix10265 ResultSix10265 //1101结果
  5379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5380. result, _ := json.Marshal(respJSON)
  5381. return string(result), ""
  5382. }
  5383. }
  5384. func (c *HisApiController) Get1318() {
  5385. adminUser := c.GetAdminUserInfo()
  5386. admin_user_id, _ := c.GetInt64("admin_user_id")
  5387. code := c.GetString("code")
  5388. code = ""
  5389. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5390. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5391. api := ""
  5392. if miConfig.MdtrtareaAdmvs == "320921" {
  5393. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5394. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5395. } else {
  5396. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5397. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5398. }
  5399. resp, requestErr := http.Get(api)
  5400. if requestErr != nil {
  5401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5402. return
  5403. }
  5404. body, ioErr := ioutil.ReadAll(resp.Body)
  5405. if ioErr != nil {
  5406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5408. return
  5409. }
  5410. var respJSON map[string]interface{}
  5411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5414. return
  5415. }
  5416. //var res Result2406
  5417. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5418. result, _ := json.Marshal(respJSON)
  5419. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5420. utils.ErrorLog("解析失败:%v", err)
  5421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5422. return
  5423. }
  5424. if res.Infcode == "0" {
  5425. c.ServeSuccessJSON(map[string]interface{}{
  5426. "result": "",
  5427. })
  5428. } else {
  5429. c.ServeSuccessJSON(map[string]interface{}{
  5430. "failed_code": -10,
  5431. "msg": res.ErrMsg,
  5432. })
  5433. */return
  5434. //}
  5435. }
  5436. func (c *HisApiController) Get2503() {
  5437. adminUser := c.GetAdminUserInfo()
  5438. admin_user_id, _ := c.GetInt64("admin_user_id")
  5439. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5440. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5441. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5442. }
  5443. func (c *HisApiController) Get2406() {
  5444. id, _ := c.GetInt64("id")
  5445. record_time := c.GetString("record_time")
  5446. his_patient_id, _ := c.GetInt64("his_patient_id")
  5447. admin_user_id, _ := c.GetInt64("admin_user_id")
  5448. diagnosis_id := c.GetString("diagnosis")
  5449. timeLayout := "2006-01-02"
  5450. loc, _ := time.LoadLocation("Local")
  5451. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5452. if err != nil {
  5453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5454. return
  5455. }
  5456. recordDateTime := theTime.Unix()
  5457. adminUser := c.GetAdminUserInfo()
  5458. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5459. var config []*models.HisXtDiagnoseConfig
  5460. for _, item := range diagnosis_ids {
  5461. id, _ := strconv.ParseInt(item, 10, 64)
  5462. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5463. config = append(config, &diagnosisConfig)
  5464. }
  5465. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5466. fmt.Println(his_patient_id)
  5467. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5468. //timestamp := time.Now().Unix()
  5469. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5470. var patientPrescription models.HisPrescriptionInfo
  5471. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5472. if patientPrescription.ID == 0 {
  5473. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5474. }
  5475. var res2 Result2406
  5476. if miConfig.MdtrtareaAdmvs == "341203" {
  5477. data := make(map[string]interface{})
  5478. client := &http.Client{}
  5479. data["psn_no"] = his.PsnNo
  5480. data["mdtrt_id"] = his.Number
  5481. data["operator"] = roles.UserName
  5482. data["cert_no"] = his.IdCardNo
  5483. data["org_name"] = miConfig.OrgName
  5484. data["psn_name"] = his.Name
  5485. data["ipt_otp_no"] = his.IptOtpNo
  5486. data["ipt_psn_sp_flag_type"] = "0901"
  5487. data["ipt_psn_sp_flag"] = "1"
  5488. data["fixmedins_code"] = miConfig.Code
  5489. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5490. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5491. data["url"] = miConfig.Url
  5492. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5493. bytesData, _ := json.Marshal(data)
  5494. var req *http.Request
  5495. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5496. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5497. resp, _ := client.Do(req)
  5498. defer resp.Body.Close()
  5499. body, ioErr := ioutil.ReadAll(resp.Body)
  5500. if ioErr != nil {
  5501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5503. return
  5504. }
  5505. var respJSON map[string]interface{}
  5506. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5509. return
  5510. }
  5511. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5512. if status == "0" {
  5513. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5514. c.ServeSuccessJSON(map[string]interface{}{
  5515. "failed_code": -10,
  5516. "msg": err_msg,
  5517. })
  5518. return
  5519. }
  5520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5521. userJSONBytes, _ := json.Marshal(respJSON)
  5522. fmt.Println("log")
  5523. fmt.Println(string(userJSONBytes))
  5524. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5525. utils.ErrorLog("解析失败:%v", err)
  5526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5527. return
  5528. }
  5529. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5530. data := make(map[string]interface{})
  5531. client := &http.Client{}
  5532. data["psn_no"] = his.PsnNo
  5533. data["mdtrt_id"] = his.Number
  5534. data["operator"] = roles.UserName
  5535. data["cert_no"] = his.IdCardNo
  5536. data["org_name"] = miConfig.OrgName
  5537. data["psn_name"] = his.Name
  5538. data["ipt_otp_no"] = his.IptOtpNo
  5539. data["ipt_psn_sp_flag_type"] = "0901"
  5540. data["ipt_psn_sp_flag"] = "1"
  5541. data["fixmedins_code"] = miConfig.Code
  5542. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5543. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5544. data["url"] = miConfig.Url
  5545. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5546. bytesData, _ := json.Marshal(data)
  5547. var req *http.Request
  5548. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5549. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5550. resp, _ := client.Do(req)
  5551. defer resp.Body.Close()
  5552. body, ioErr := ioutil.ReadAll(resp.Body)
  5553. if ioErr != nil {
  5554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5556. return
  5557. }
  5558. var respJSON map[string]interface{}
  5559. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5562. return
  5563. }
  5564. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5565. if status == "0" {
  5566. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5567. c.ServeSuccessJSON(map[string]interface{}{
  5568. "failed_code": -10,
  5569. "msg": err_msg,
  5570. })
  5571. return
  5572. }
  5573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5574. userJSONBytes, _ := json.Marshal(respJSON)
  5575. fmt.Println("log")
  5576. fmt.Println(string(userJSONBytes))
  5577. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5578. utils.ErrorLog("解析失败:%v", err)
  5579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5580. return
  5581. }
  5582. }
  5583. if res2.Infcode != 0 {
  5584. adminUser := c.GetAdminUserInfo()
  5585. errlog := &models.HisOrderError{
  5586. UserOrgId: adminUser.CurrentOrgId,
  5587. Ctime: time.Now().Unix(),
  5588. Mtime: time.Now().Unix(),
  5589. ErrMsg: res2.ErrMsg,
  5590. Status: 1,
  5591. PatientId: id,
  5592. RecordTime: recordDateTime,
  5593. Stage: 3,
  5594. }
  5595. service.CreateErrMsgLog(errlog)
  5596. c.ServeSuccessJSON(map[string]interface{}{
  5597. "failed_code": -10,
  5598. "msg": res2.ErrMsg,
  5599. })
  5600. return
  5601. } else {
  5602. c.ServeSuccessJSON(map[string]interface{}{
  5603. "msg": "上传成功",
  5604. })
  5605. return
  5606. }
  5607. }
  5608. func (c *HisApiController) Get4105() {
  5609. }
  5610. func (c *HisApiController) Post5302() {
  5611. patient_id, _ := c.GetInt64("id")
  5612. admin_user_id, _ := c.GetInt64("admin_user_id")
  5613. p, _ := service.GetHisPatientById(patient_id)
  5614. adminUser := c.GetAdminUserInfo()
  5615. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5616. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5617. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5618. }
  5619. func (c *HisApiController) Get4104() {
  5620. }
  5621. type Output struct {
  5622. CertNo string `json:"certno"`
  5623. PsnName string `json:"psn_name"`
  5624. CardNo string `json:"card_no"`
  5625. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5626. CardSN string `json:"card_sn"`
  5627. PsnCertType string `json:"psn_cert_type"`
  5628. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5629. MdtrtCertType string `json:"mdtrt_cert_type"`
  5630. QRCode string `json:"qrCode"`
  5631. EcToken string `json:"ecToken"`
  5632. }
  5633. type AHResponse struct {
  5634. Body AHBody `json:"body"`
  5635. Code int `json:"code"`
  5636. CSBCode int `json:"csbCode"`
  5637. Message string `json:"message"`
  5638. RequestID string `json:"requestId"`
  5639. State struct{} `json:"state"`
  5640. }
  5641. type AHBody struct {
  5642. ErrMsg string `json:"err_msg"`
  5643. InfRefMsgID string `json:"inf_refmsgid"`
  5644. InfCode int `json:"infcode"`
  5645. Output struct {
  5646. Result []struct {
  5647. BasMednFlag string `json:"bas_medn_flag"`
  5648. ChldMedcFlag string `json:"chld_medc_flag"`
  5649. ChrgitmLv string `json:"chrgitm_lv"`
  5650. Cnt float64 `json:"cnt"`
  5651. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5652. DrtReimFlag string `json:"drt_reim_flag"`
  5653. FeedetlSn string `json:"feedetl_sn"`
  5654. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5655. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5656. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5657. ListSpItemFlag string `json:"list_sp_item_flag"`
  5658. LmtUsedFlag string `json:"lmt_used_flag"`
  5659. MedChrgitmType string `json:"med_chrgitm_type"`
  5660. Memo string `json:"memo"`
  5661. OverlmtAmt float64 `json:"overlmt_amt"`
  5662. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5663. Pric float64 `json:"pric"`
  5664. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5665. SelfpayProp float64 `json:"selfpay_prop"`
  5666. } `json:"result"`
  5667. } `json:"output"`
  5668. }
  5669. type Response struct {
  5670. Output Output `json:"output"`
  5671. Infcode int `json:"infcode"`
  5672. InfRefMsgID string `json:"inf_refmsgid"`
  5673. RefMsgTime string `json:"refmsg_time"`
  5674. RespondTime string `json:"respond_time"`
  5675. ErrMsg string `json:"err_msg"`
  5676. WarnMsg string `json:"warn_msg"`
  5677. SignType string `json:"signtype"`
  5678. CAInfo string `json:"cainfo"`
  5679. }
  5680. func (c *HisApiController) Getquerydata() {
  5681. query_type, _ := c.GetInt64("type")
  5682. refd_setl_flag := c.GetString("refd_setl_flag")
  5683. med_type := c.GetString("med_type")
  5684. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5685. cert_no := c.GetString("cert_no")
  5686. psn_no := c.GetString("psn_no")
  5687. start_time := c.GetString("start_time")
  5688. end_time := c.GetString("end_time")
  5689. page, _ := c.GetInt64("page")
  5690. limit, _ := c.GetInt64("limit")
  5691. var bp models.BusinessParams5262
  5692. bp.RefdSetlFlag = refd_setl_flag
  5693. bp.MedType = med_type
  5694. bp.Certno = cert_no
  5695. bp.Psnno = psn_no
  5696. bp.QBegntime = start_time
  5697. bp.QEndtime = end_time
  5698. if query_type == 1 { //本地
  5699. Post5262(c, bp, page, limit)
  5700. } else { //异地
  5701. Post5267(c, bp, page, limit)
  5702. }
  5703. }
  5704. func (c *HisApiController) Drugscheck() {
  5705. admin_user_id, _ := c.GetInt64("admin_user_id")
  5706. adminUser := c.GetAdminUserInfo()
  5707. var queryResult []QueryResult
  5708. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5709. for _, item := range drugs {
  5710. result := QueryResult{
  5711. ID: item.ID,
  5712. Name: item.DrugName,
  5713. Code: item.MedicalInsuranceNumber,
  5714. List_type_code: "101",
  5715. }
  5716. queryResult = append(queryResult, result)
  5717. }
  5718. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5719. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5720. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5721. for _, item := range queryResult {
  5722. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  5723. }
  5724. }
  5725. func (c *HisApiController) Goodcheck() {
  5726. admin_user_id, _ := c.GetInt64("admin_user_id")
  5727. adminUser := c.GetAdminUserInfo()
  5728. var queryResult []QueryResult
  5729. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5730. for _, item := range goods {
  5731. result := QueryResult{
  5732. ID: item.ID,
  5733. Name: item.GoodName,
  5734. Code: item.SocialSecurityDirectoryCode,
  5735. List_type_code: "301",
  5736. }
  5737. queryResult = append(queryResult, result)
  5738. }
  5739. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5740. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5741. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5742. for _, item := range queryResult {
  5743. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  5744. //service.Hnyb3302(miConfig.OrgName,role.UserName,miConfig.Code,miConfig.InsuplcAdmdvs,miConfig.MdtrtareaAdmvs,miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url,miConfig.AccessKey,miConfig.SecretKey)
  5745. }
  5746. }
  5747. func (c *HisApiController) Projectcheck() {
  5748. admin_user_id, _ := c.GetInt64("admin_user_id")
  5749. adminUser := c.GetAdminUserInfo()
  5750. var queryResult []QueryResult
  5751. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5752. for _, item := range projects {
  5753. result := QueryResult{
  5754. ID: item.ID,
  5755. Name: item.ProjectName,
  5756. Code: item.MedicalCode,
  5757. List_type_code: "201",
  5758. }
  5759. queryResult = append(queryResult, result)
  5760. }
  5761. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5762. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5763. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5764. for _, item := range queryResult {
  5765. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  5766. }
  5767. }
  5768. //func (c *HisApiController)CancleDia(){
  5769. //
  5770. // id, _ := c.GetInt64("id")
  5771. // record_time := c.GetString("record_time")
  5772. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5773. //
  5774. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5775. //
  5776. // diagnosis_id := c.GetString("diagnosis")
  5777. // sick_type, _ := c.GetInt64("sick_type")
  5778. // reg_type, _ := c.GetInt64("p_type")
  5779. // begin_time := c.GetString("begin_time")
  5780. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5781. //
  5782. //
  5783. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5784. //
  5785. // fmt.Println(acct_used_flag)
  5786. //
  5787. //
  5788. // timeLayout := "2006-01-02"
  5789. // loc, _ := time.LoadLocation("Local")
  5790. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5791. // if err != nil {
  5792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5793. // return
  5794. // }
  5795. // recordDateTime := theTime.Unix()
  5796. // adminUser := c.GetAdminUserInfo()
  5797. //
  5798. //
  5799. //
  5800. //
  5801. //
  5802. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5803. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5804. // var patientPrescription models.HisPrescriptionInfo
  5805. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5806. // if patientPrescription.ID == 0 {
  5807. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5808. // }
  5809. // //if patientPrescription.Do
  5810. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5811. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5812. //
  5813. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5814. //
  5815. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5816. //
  5817. // var config []*models.HisXtDiagnoseConfig
  5818. // for _, item := range diagnosis_ids {
  5819. // id, _ := strconv.ParseInt(item, 10, 64)
  5820. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5821. // config = append(config, &diagnosisConfig)
  5822. // }
  5823. //
  5824. // sickConfig, _ := service.FindSickById(sick_type)
  5825. //
  5826. //
  5827. // data := make(map[string]interface{})
  5828. // client := &http.Client{}
  5829. // data["psn_no"] = his.PsnNo
  5830. // data["mdtrt_id"] = his.Number
  5831. // data["doctor"] = roles.UserName
  5832. // data["department"] = department.Name
  5833. // data["org_name"] = miConfig.OrgName
  5834. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5835. // data["doctor_id"] = doctor_info.DoctorNumber
  5836. // data["new_doctor_name"] = doctor_info.UserName
  5837. // data["fixmedins_code"] = miConfig.Code
  5838. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5839. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5840. // data["secret_key"] = miConfig.SecretKey
  5841. // data["sick_code"] = sickConfig.CountryCode
  5842. // data["sick_name"] = sickConfig.ClassName
  5843. // data["url"] = miConfig.Url
  5844. // data["ak"] = miConfig.AccessKey
  5845. // data["begin_time"] = begin_time
  5846. // data["cainfo"] = miConfig.Cainfo
  5847. // data["is_vaild"] = "0"
  5848. //
  5849. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5850. // data["config"] = config
  5851. // bytesData, _ := json.Marshal(data)
  5852. //
  5853. // var req *http.Request
  5854. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5855. // resp, _ := client.Do(req)
  5856. // defer resp.Body.Close()
  5857. // body, ioErr := ioutil.ReadAll(resp.Body)
  5858. // if ioErr != nil {
  5859. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5860. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5861. // return
  5862. // }
  5863. // var respJSON map[string]interface{}
  5864. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5865. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5867. // return
  5868. // }
  5869. //
  5870. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5871. // userJSONBytes, _ := json.Marshal(respJSON)
  5872. // fmt.Println("log")
  5873. // fmt.Println(string(userJSONBytes))
  5874. //
  5875. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5876. // utils.ErrorLog("解析失败:%v", err)
  5877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5878. // return
  5879. // }
  5880. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5881. // res2.Output = ressix10265.Output
  5882. // res2.ErrMsg = ressix10265.ErrMsg
  5883. // res2.Cainfo = ressix10265.Cainfo
  5884. // res2.WarnMsg = ressix10265.WarnMsg
  5885. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5886. // res2.Infcode = infocode
  5887. //
  5888. //}
  5889. func (c *HisApiController) Get4102() {
  5890. order_id, _ := c.GetInt64("order_id")
  5891. admin_user_id, _ := c.GetInt64("admin_user_id")
  5892. stas_type := c.GetString("stas_type")
  5893. order, _ := service.GetHisOrderByIDTwo(order_id)
  5894. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5895. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5896. var pp models.PublicParams
  5897. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5898. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5899. pp.FixmedinsName = miConfig.OrgName
  5900. pp.FixmedinsCode = miConfig.Code
  5901. pp.RequestUrl = miConfig.Url
  5902. pp.Cainfo = miConfig.Cainfo
  5903. pp.SecretKey = miConfig.SecretKey
  5904. pp.AccessKey = miConfig.AccessKey
  5905. pp.OpterName = curRoles.UserName
  5906. if miConfig.MdtrtareaAdmvs == "350500" {
  5907. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5908. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5909. saveLog(result, request, "4102", "清单确认")
  5910. var dat map[string]interface{}
  5911. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5912. fmt.Println(dat)
  5913. } else {
  5914. fmt.Println(err)
  5915. }
  5916. var empty ResultFourteen
  5917. userJSONBytes, _ := json.Marshal(dat)
  5918. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5919. utils.ErrorLog("解析失败:%v", err)
  5920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5921. return
  5922. }
  5923. if empty.Infcode == 0 {
  5924. c.ServeSuccessJSON(map[string]interface{}{
  5925. "msg": "确认成功",
  5926. })
  5927. return
  5928. }
  5929. } else {
  5930. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5931. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5932. result3, request3 := service.Jxyb4105(pp)
  5933. saveLog(result, request, "4102", "清单确认")
  5934. saveLog(result2, request2, "4103", "清单确认")
  5935. saveLog(result3, request3, "4105", "清单统计")
  5936. var dat map[string]interface{}
  5937. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5938. fmt.Println(dat)
  5939. } else {
  5940. fmt.Println(err)
  5941. }
  5942. var empty ResultFourteen
  5943. userJSONBytes, _ := json.Marshal(dat)
  5944. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5945. utils.ErrorLog("解析失败:%v", err)
  5946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5947. return
  5948. }
  5949. if empty.Infcode == 0 {
  5950. c.ServeSuccessJSON(map[string]interface{}{
  5951. "msg": "确认成功",
  5952. })
  5953. return
  5954. }
  5955. }
  5956. }
  5957. // 对账权限查询
  5958. func (c *HisApiController) Get3260() {
  5959. admin_user_id, _ := c.GetInt64("admin_user_id")
  5960. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5961. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5962. var api string
  5963. var res models.JSResult3260
  5964. if miConfig.MdtrtareaAdmvs == "320921" {
  5965. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5966. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5967. } else {
  5968. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5969. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5970. }
  5971. resp, requestErr := http.Get(api)
  5972. if requestErr != nil {
  5973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5974. return
  5975. }
  5976. body, ioErr := ioutil.ReadAll(resp.Body)
  5977. if ioErr != nil {
  5978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5980. return
  5981. }
  5982. var respJSON map[string]interface{}
  5983. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5986. return
  5987. }
  5988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5989. result, _ := json.Marshal(respJSON)
  5990. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5991. utils.ErrorLog("解析失败:%v", err)
  5992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5993. return
  5994. }
  5995. if res.Infcode == "0" {
  5996. c.ServeSuccessJSON(map[string]interface{}{
  5997. "result": res.Output.Data,
  5998. })
  5999. } else {
  6000. c.ServeSuccessJSON(map[string]interface{}{
  6001. "failed_code": -10,
  6002. "msg": res.ErrMsg,
  6003. })
  6004. return
  6005. }
  6006. }
  6007. func (c *HisApiController) Get3261() {
  6008. admin_user_id, _ := c.GetInt64("admin_user_id")
  6009. //month := c.GetString("month")
  6010. startTime := c.GetString("start_time")
  6011. //endTime, _ := c.GetString("end_time")
  6012. times := strings.Split(startTime, "-")
  6013. stmt_mon := times[0] + times[1]
  6014. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6015. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6016. var api string
  6017. var res models.JSResult3261
  6018. //var res10265 Result5301For10265
  6019. if miConfig.MdtrtareaAdmvs == "320921" {
  6020. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6021. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6022. } else {
  6023. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6024. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6025. }
  6026. resp, requestErr := http.Get(api)
  6027. if requestErr != nil {
  6028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6029. return
  6030. }
  6031. body, ioErr := ioutil.ReadAll(resp.Body)
  6032. if ioErr != nil {
  6033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6035. return
  6036. }
  6037. var respJSON map[string]interface{}
  6038. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6041. return
  6042. }
  6043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6044. result, _ := json.Marshal(respJSON)
  6045. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6046. utils.ErrorLog("解析失败:%v", err)
  6047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6048. return
  6049. }
  6050. if res.Infcode == "0" {
  6051. c.ServeSuccessJSON(map[string]interface{}{
  6052. "result": res.Output,
  6053. })
  6054. } else {
  6055. c.ServeSuccessJSON(map[string]interface{}{
  6056. "failed_code": -10,
  6057. "msg": res.ErrMsg,
  6058. })
  6059. return
  6060. }
  6061. }
  6062. type TempFun struct {
  6063. FundKey string
  6064. FundCode string
  6065. }
  6066. func (c *HisApiController) Get3262() {
  6067. admin_user_id, _ := c.GetInt64("admin_user_id")
  6068. startTime := c.GetString("start_time")
  6069. endTime := c.GetString("end_time")
  6070. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6071. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6072. //timeLayout := "2006-01-02"
  6073. //loc, _ := time.LoadLocation("Local")
  6074. //var theStartTIme int64
  6075. //if len(startTime) > 0 {
  6076. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6077. // if err != nil {
  6078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6079. // return
  6080. // }
  6081. // theStartTIme = theTime.Unix()
  6082. //}
  6083. //var theEndtTIme int64
  6084. //if len(endTime) > 0 {
  6085. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6086. // if err != nil {
  6087. // utils.ErrorLog(err.Error())
  6088. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6089. // return
  6090. // }
  6091. // theEndtTIme = theTime.Unix()
  6092. //}
  6093. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6094. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6095. for _, team := range datas {
  6096. fmt.Println(team.PsnTime)
  6097. for _, team_two := range datas_two {
  6098. fmt.Println(team_two.PsnTime)
  6099. if team.FundKey == team_two.FundKey {
  6100. fmt.Println(team_two.PsnTime)
  6101. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6102. fmt.Println(team.PsnTime)
  6103. }
  6104. }
  6105. }
  6106. fmt.Println("1111")
  6107. fmt.Println(datas)
  6108. fmt.Println("1111")
  6109. var twos []models.FixMonRecDetailFileInTwo
  6110. for _, team := range datas {
  6111. var two models.FixMonRecDetailFileInTwo
  6112. two.MedType = team.MedType
  6113. two.Insutype = team.Insutype
  6114. two.PsnType = team.PsnType
  6115. two.MedType = team.MedType
  6116. two.FixBlngAdmdvs = "999999"
  6117. two.InsuAdmdvs = "555555"
  6118. two.PsnTime = team.PsnTime
  6119. two.PsnCnt = team.PsnCnt
  6120. two.FundKey = team.FundKey
  6121. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6122. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6123. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6124. two.MedfeeSumAmt = ms
  6125. two.InscpAmt = ia
  6126. two.FundPaySumAmt = fps
  6127. twos = append(twos, two)
  6128. }
  6129. //startTime := c.GetString("start_time")
  6130. //endTime, _ := c.GetString("end_time")
  6131. times := strings.Split(startTime, "-")
  6132. stmt_mon := times[0] + times[1]
  6133. var funs []models.FundDetail
  6134. for _, item := range datas {
  6135. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6136. funs = append(funs, fun...)
  6137. }
  6138. var funInfos []models.Fund
  6139. //for _, item := range funs {
  6140. // var rf []models.FundInfo
  6141. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6142. // for _, subitem := range rf {
  6143. // var fund models.Fund
  6144. // fund.FundCode = subitem.FundPayType
  6145. // fund.FundName = subitem.FundPayTypeName
  6146. // fund.FundAmt = subitem.FundPayAmt
  6147. // fund.FundKey = item.FundKey
  6148. // fund.InsuAdmdvs = "555555"
  6149. // fund.FixBlngAdmdvs = "999999"
  6150. // funInfos = append(funInfos, fund)
  6151. // }
  6152. //}
  6153. var tempFuns []TempFun
  6154. for _, funInfo := range funInfos {
  6155. var tempFun TempFun
  6156. tempFun.FundKey = funInfo.FundKey
  6157. tempFun.FundCode = funInfo.FundCode
  6158. tempFuns = append(tempFuns, tempFun)
  6159. }
  6160. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6161. fmt.Println(tempFuns)
  6162. var funInfosTwo []models.Fund
  6163. decimal.DivisionPrecision = 2
  6164. for _, item := range tempFuns {
  6165. var fund models.Fund
  6166. for _, subItem := range funInfos {
  6167. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6168. fund.FundKey = subItem.FundKey
  6169. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6170. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6171. fund.FundName = subItem.FundName
  6172. fund.FundCode = subItem.FundCode
  6173. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6174. }
  6175. }
  6176. funInfosTwo = append(funInfosTwo, fund)
  6177. }
  6178. fmt.Println("funInfosTwo")
  6179. fmt.Println(funInfosTwo)
  6180. var upld_btch string
  6181. var empty models.JSResultEmpty
  6182. data := make(map[string]interface{})
  6183. data["org_name"] = miConfig.OrgName
  6184. data["doctor"] = curRoles.UserName
  6185. data["doctor_name"] = curRoles.UserName
  6186. data["fixmedins_code"] = miConfig.Code
  6187. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6188. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6189. data["secret_key"] = miConfig.SecretKey
  6190. data["url"] = miConfig.Url
  6191. data["ak"] = miConfig.AccessKey
  6192. data["cainfo"] = miConfig.Cainfo
  6193. data["datas"] = twos
  6194. data["fund"] = funInfosTwo
  6195. fmt.Println(twos)
  6196. month := time.Unix(1557042972, 0).Format("1")
  6197. year := time.Now().Format("2006")
  6198. month = time.Now().Format("01")
  6199. day := time.Now().Format("02")
  6200. hour := time.Now().Format("15")
  6201. min := time.Now().Format("04")
  6202. sec := time.Now().Format("05")
  6203. fix_fill_date := year + month + day + hour + min + sec
  6204. data["fix_fill_dept"] = miConfig.OrgName
  6205. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6206. data["fix_fill_psn"] = curRoles.UserName
  6207. data["fix_fill_date"] = fix_fill_date
  6208. data["stmt_loc"] = "2"
  6209. data["setl_mon"] = stmt_mon
  6210. upld_btch = "0"
  6211. data["upld_btch"] = upld_btch
  6212. //fmt.Println(data)
  6213. client := &http.Client{}
  6214. bytesData, _ := json.Marshal(data)
  6215. var req *http.Request
  6216. if miConfig.MdtrtareaAdmvs == "320921" {
  6217. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6218. } else {
  6219. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6220. }
  6221. resp, _ := client.Do(req)
  6222. defer resp.Body.Close()
  6223. body, ioErr := ioutil.ReadAll(resp.Body)
  6224. if ioErr != nil {
  6225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6227. }
  6228. var respJSON map[string]interface{}
  6229. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6232. }
  6233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6234. //fmt.Println(respJSON)
  6235. result, _ := json.Marshal(respJSON)
  6236. //fmt.Println(result)
  6237. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6238. utils.ErrorLog("解析失败:%v", err)
  6239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6240. }
  6241. if empty.Infcode != "0" {
  6242. c.ServeSuccessJSON(map[string]interface{}{
  6243. "failed_code": -10,
  6244. "msg": empty.ErrMsg,
  6245. })
  6246. return
  6247. } else {
  6248. c.ServeSuccessJSON(map[string]interface{}{
  6249. "msg": "上传成功",
  6250. })
  6251. return
  6252. }
  6253. }
  6254. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6255. newArr = make([]TempFun, 0)
  6256. for i := 0; i < len(arr); i++ {
  6257. repeat := false
  6258. for j := i + 1; j < len(arr); j++ {
  6259. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6260. repeat = true
  6261. break
  6262. }
  6263. }
  6264. if !repeat {
  6265. newArr = append(newArr, arr[i])
  6266. }
  6267. }
  6268. return
  6269. }
  6270. func (c *HisApiController) Get3263() {
  6271. admin_user_id, _ := c.GetInt64("admin_user_id")
  6272. startTime := c.GetString("start_time")
  6273. //endTime, _ := c.GetString("end_time")
  6274. times := strings.Split(startTime, "-")
  6275. setl_mon := times[0] + times[1]
  6276. upld_btch := "0"
  6277. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6278. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6279. var result3263 models.JSResult3263
  6280. data := make(map[string]interface{})
  6281. data["org_name"] = miConfig.OrgName
  6282. data["doctor"] = curRoles.UserName
  6283. data["doctor_name"] = curRoles.UserName
  6284. data["fixmedins_code"] = miConfig.Code
  6285. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6286. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6287. data["secret_key"] = miConfig.SecretKey
  6288. data["url"] = miConfig.Url
  6289. data["ak"] = miConfig.AccessKey
  6290. data["cainfo"] = miConfig.Cainfo
  6291. data["setl_mon"] = setl_mon
  6292. data["stmt_loc"] = "2"
  6293. data["upld_btch"] = upld_btch
  6294. client := &http.Client{}
  6295. bytesData, _ := json.Marshal(data)
  6296. var req *http.Request
  6297. if miConfig.MdtrtareaAdmvs == "320921" {
  6298. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6299. } else {
  6300. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6301. }
  6302. resp, _ := client.Do(req)
  6303. defer resp.Body.Close()
  6304. body, ioErr := ioutil.ReadAll(resp.Body)
  6305. if ioErr != nil {
  6306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6308. }
  6309. var respJSON map[string]interface{}
  6310. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6313. }
  6314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6315. fmt.Println(respJSON)
  6316. result, _ := json.Marshal(respJSON)
  6317. fmt.Println(result)
  6318. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6319. utils.ErrorLog("解析失败:%v", err)
  6320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6321. }
  6322. if result3263.Infcode != "0" {
  6323. c.ServeSuccessJSON(map[string]interface{}{
  6324. "failed_code": -10,
  6325. "msg": result3263.ErrMsg,
  6326. })
  6327. return
  6328. } else {
  6329. c.ServeSuccessJSON(map[string]interface{}{
  6330. "list": result3263.Output,
  6331. })
  6332. return
  6333. }
  6334. }
  6335. func (c *HisApiController) Get3264() {
  6336. admin_user_id, _ := c.GetInt64("admin_user_id")
  6337. startTime := c.GetString("start_time")
  6338. //endTime, _ := c.GetString("end_time")
  6339. times := strings.Split(startTime, "-")
  6340. setl_mon := times[0] + times[1]
  6341. upld_btch := "0"
  6342. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6343. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6344. //solidify_id := []
  6345. var result3263 models.JSResult3263
  6346. data := make(map[string]interface{})
  6347. data["org_name"] = miConfig.OrgName
  6348. data["doctor"] = curRoles.UserName
  6349. data["doctor_name"] = curRoles.UserName
  6350. data["fixmedins_code"] = miConfig.Code
  6351. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6352. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6353. data["secret_key"] = miConfig.SecretKey
  6354. data["url"] = miConfig.Url
  6355. data["ak"] = miConfig.AccessKey
  6356. data["cainfo"] = miConfig.Cainfo
  6357. data["setl_mon"] = setl_mon
  6358. data["stmt_loc"] = "2"
  6359. data["upld_btch"] = upld_btch
  6360. client := &http.Client{}
  6361. bytesData, _ := json.Marshal(data)
  6362. var req3263 *http.Request
  6363. if miConfig.MdtrtareaAdmvs == "320921" {
  6364. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6365. } else {
  6366. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6367. }
  6368. resp, _ := client.Do(req3263)
  6369. defer resp.Body.Close()
  6370. body, ioErr := ioutil.ReadAll(resp.Body)
  6371. if ioErr != nil {
  6372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6374. }
  6375. var respJSON3263 map[string]interface{}
  6376. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6379. }
  6380. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6381. fmt.Println(respJSON3263)
  6382. result, _ := json.Marshal(respJSON3263)
  6383. fmt.Println(result)
  6384. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6385. utils.ErrorLog("解析失败:%v", err)
  6386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6387. }
  6388. var ids []string
  6389. for _, item := range result3263.Output {
  6390. ids = append(ids, item.SolidifyID)
  6391. }
  6392. var empty models.JSResultEmpty
  6393. data2 := make(map[string]interface{})
  6394. data2["org_name"] = miConfig.OrgName
  6395. data2["doctor"] = curRoles.UserName
  6396. data2["doctor_name"] = curRoles.UserName
  6397. data2["fixmedins_code"] = miConfig.Code
  6398. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6399. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6400. data2["secret_key"] = miConfig.SecretKey
  6401. data2["url"] = miConfig.Url
  6402. data2["ak"] = miConfig.AccessKey
  6403. data2["cainfo"] = miConfig.Cainfo
  6404. data2["setl_mon"] = setl_mon
  6405. data2["stmt_loc"] = "2"
  6406. data2["upld_btch"] = upld_btch
  6407. data2["solidify_id"] = ids
  6408. client2 := &http.Client{}
  6409. bytesData2, _ := json.Marshal(data2)
  6410. var req *http.Request
  6411. if miConfig.MdtrtareaAdmvs == "320921" {
  6412. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6413. } else {
  6414. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6415. }
  6416. resp2, _ := client2.Do(req)
  6417. defer resp.Body.Close()
  6418. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6419. if ioErr2 != nil {
  6420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6422. }
  6423. var respJSON map[string]interface{}
  6424. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6427. }
  6428. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6429. fmt.Println(respJSON)
  6430. result2, _ := json.Marshal(respJSON)
  6431. fmt.Println(result2)
  6432. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6433. utils.ErrorLog("解析失败:%v", err)
  6434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6435. }
  6436. if empty.Infcode != "0" {
  6437. c.ServeSuccessJSON(map[string]interface{}{
  6438. "failed_code": -10,
  6439. "msg": empty.ErrMsg,
  6440. })
  6441. return
  6442. } else {
  6443. c.ServeSuccessJSON(map[string]interface{}{
  6444. "msg": "",
  6445. })
  6446. return
  6447. }
  6448. }
  6449. func (c *HisApiController) Get3265() {
  6450. admin_user_id, _ := c.GetInt64("admin_user_id")
  6451. startTime := c.GetString("start_time")
  6452. //endTime, _ := c.GetString("end_time")
  6453. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6454. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6455. times := strings.Split(startTime, "-")
  6456. setl_mon := times[0] + times[1]
  6457. var upld_btch string
  6458. upld_btch = "0"
  6459. //var empty models.JSResultEmpty
  6460. var result3265 models.JSResult3264
  6461. var result3263 models.JSResult3263
  6462. data2 := make(map[string]interface{})
  6463. data2["org_name"] = miConfig.OrgName
  6464. data2["doctor"] = curRoles.UserName
  6465. data2["doctor_name"] = curRoles.UserName
  6466. data2["fixmedins_code"] = miConfig.Code
  6467. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6468. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6469. data2["secret_key"] = miConfig.SecretKey
  6470. data2["url"] = miConfig.Url
  6471. data2["ak"] = miConfig.AccessKey
  6472. data2["cainfo"] = miConfig.Cainfo
  6473. data2["setl_mon"] = setl_mon
  6474. data2["stmt_loc"] = "2"
  6475. data2["upld_btch"] = upld_btch
  6476. client2 := &http.Client{}
  6477. bytesData2, _ := json.Marshal(data2)
  6478. var req3263 *http.Request
  6479. if miConfig.MdtrtareaAdmvs == "320921" {
  6480. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6481. } else {
  6482. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6483. }
  6484. resp2, _ := client2.Do(req3263)
  6485. defer resp2.Body.Close()
  6486. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6487. if ioErr2 != nil {
  6488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6490. }
  6491. var respJSON3263 map[string]interface{}
  6492. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6495. }
  6496. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6497. fmt.Println(respJSON3263)
  6498. result2, _ := json.Marshal(respJSON3263)
  6499. fmt.Println(result2)
  6500. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6501. utils.ErrorLog("解析失败:%v", err)
  6502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6503. }
  6504. var ids []string
  6505. for _, item := range result3263.Output {
  6506. ids = append(ids, item.SolidifyID)
  6507. }
  6508. data := make(map[string]interface{})
  6509. data["org_name"] = miConfig.OrgName
  6510. data["doctor"] = curRoles.UserName
  6511. data["doctor_name"] = curRoles.UserName
  6512. data["fixmedins_code"] = miConfig.Code
  6513. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6514. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6515. data["secret_key"] = miConfig.SecretKey
  6516. data["url"] = miConfig.Url
  6517. data["ak"] = miConfig.AccessKey
  6518. data["cainfo"] = miConfig.Cainfo
  6519. data["setl_mon"] = setl_mon
  6520. data["solidify_id"] = ids
  6521. month := time.Unix(1557042972, 0).Format("1")
  6522. year := time.Now().Format("2006")
  6523. month = time.Now().Format("01")
  6524. day := time.Now().Format("02")
  6525. hour := time.Now().Format("15")
  6526. min := time.Now().Format("04")
  6527. sec := time.Now().Format("05")
  6528. fix_fill_date := year + month + day + hour + min + sec
  6529. data["fix_fill_dept"] = miConfig.OrgName
  6530. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6531. data["fix_fill_psn"] = curRoles.UserName
  6532. data["fix_fill_date"] = fix_fill_date
  6533. data["stmt_loc"] = "2"
  6534. data["upld_btch"] = upld_btch
  6535. client := &http.Client{}
  6536. bytesData, _ := json.Marshal(data)
  6537. var req *http.Request
  6538. if miConfig.MdtrtareaAdmvs == "320921" {
  6539. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6540. } else {
  6541. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6542. }
  6543. resp, _ := client.Do(req)
  6544. defer resp.Body.Close()
  6545. body, ioErr := ioutil.ReadAll(resp.Body)
  6546. if ioErr != nil {
  6547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6549. }
  6550. var respJSON map[string]interface{}
  6551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6554. }
  6555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6556. fmt.Println(respJSON)
  6557. result, _ := json.Marshal(respJSON)
  6558. fmt.Println(result)
  6559. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6560. utils.ErrorLog("解析失败:%v", err)
  6561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6562. }
  6563. if result3265.Infcode != "0" {
  6564. c.ServeSuccessJSON(map[string]interface{}{
  6565. "failed_code": -10,
  6566. "msg": result3265.ErrMsg,
  6567. })
  6568. return
  6569. } else {
  6570. c.ServeSuccessJSON(map[string]interface{}{
  6571. "info": result3265.Output,
  6572. })
  6573. return
  6574. }
  6575. }
  6576. func (c *HisApiController) Get3266() {
  6577. admin_user_id, _ := c.GetInt64("admin_user_id")
  6578. startTime := c.GetString("start_time")
  6579. //endTime, _ := c.GetString("end_time")
  6580. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6581. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6582. times := strings.Split(startTime, "-")
  6583. stmt_mon := times[0] + times[1]
  6584. var upld_btch string
  6585. //var empty models.JSResultEmpty
  6586. var result3265 models.JSResult3264
  6587. data := make(map[string]interface{})
  6588. data["org_name"] = miConfig.OrgName
  6589. data["doctor"] = curRoles.UserName
  6590. data["doctor_name"] = curRoles.UserName
  6591. data["fixmedins_code"] = miConfig.Code
  6592. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6593. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6594. data["secret_key"] = miConfig.SecretKey
  6595. data["url"] = miConfig.Url
  6596. data["ak"] = miConfig.AccessKey
  6597. data["cainfo"] = miConfig.Cainfo
  6598. data["setl_mon"] = stmt_mon
  6599. month := time.Unix(1557042972, 0).Format("1")
  6600. year := time.Now().Format("2006")
  6601. month = time.Now().Format("01")
  6602. day := time.Now().Format("02")
  6603. hour := time.Now().Format("15")
  6604. min := time.Now().Format("04")
  6605. sec := time.Now().Format("05")
  6606. fix_fill_date := year + month + day + hour + min + sec
  6607. data["fix_fill_dept"] = miConfig.OrgName
  6608. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6609. data["fix_fill_psn"] = curRoles.UserName
  6610. data["fix_fill_date"] = fix_fill_date
  6611. data["stmt_loc"] = "2"
  6612. upld_btch = "0"
  6613. data["upld_btch"] = upld_btch
  6614. client := &http.Client{}
  6615. bytesData, _ := json.Marshal(data)
  6616. var req *http.Request
  6617. if miConfig.MdtrtareaAdmvs == "320921" {
  6618. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6619. } else {
  6620. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6621. }
  6622. resp, _ := client.Do(req)
  6623. defer resp.Body.Close()
  6624. body, ioErr := ioutil.ReadAll(resp.Body)
  6625. if ioErr != nil {
  6626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6628. }
  6629. var respJSON map[string]interface{}
  6630. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6633. }
  6634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6635. fmt.Println(respJSON)
  6636. result, _ := json.Marshal(respJSON)
  6637. fmt.Println(result)
  6638. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6639. utils.ErrorLog("解析失败:%v", err)
  6640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6641. }
  6642. if result3265.Infcode != "0" {
  6643. c.ServeSuccessJSON(map[string]interface{}{
  6644. "failed_code": -10,
  6645. "msg": result3265.ErrMsg,
  6646. })
  6647. return
  6648. } else {
  6649. c.ServeSuccessJSON(map[string]interface{}{
  6650. "info": result3265.Output,
  6651. })
  6652. return
  6653. }
  6654. }
  6655. func (c *HisApiController) Get3267() {
  6656. admin_user_id, _ := c.GetInt64("admin_user_id")
  6657. startTime := c.GetString("start_time")
  6658. //endTime, _ := c.GetString("end_time")
  6659. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6660. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6661. times := strings.Split(startTime, "-")
  6662. setl_mon := times[0] + times[1]
  6663. var upld_btch string
  6664. //var empty models.JSResultEmpty
  6665. var result3265 models.JSResult3264
  6666. upld_btch = "0"
  6667. data := make(map[string]interface{})
  6668. data["org_name"] = miConfig.OrgName
  6669. data["doctor"] = curRoles.UserName
  6670. data["doctor_name"] = curRoles.UserName
  6671. data["fixmedins_code"] = miConfig.Code
  6672. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6673. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6674. data["secret_key"] = miConfig.SecretKey
  6675. data["url"] = miConfig.Url
  6676. data["ak"] = miConfig.AccessKey
  6677. data["cainfo"] = miConfig.Cainfo
  6678. data["setl_mon"] = setl_mon
  6679. data["stmt_loc"] = "2"
  6680. data["upld_btch"] = upld_btch
  6681. client := &http.Client{}
  6682. bytesData, _ := json.Marshal(data)
  6683. var req *http.Request
  6684. if miConfig.MdtrtareaAdmvs == "320921" {
  6685. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6686. } else {
  6687. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6688. }
  6689. resp, _ := client.Do(req)
  6690. defer resp.Body.Close()
  6691. body, ioErr := ioutil.ReadAll(resp.Body)
  6692. if ioErr != nil {
  6693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6695. }
  6696. var respJSON map[string]interface{}
  6697. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6700. }
  6701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6702. fmt.Println(respJSON)
  6703. result, _ := json.Marshal(respJSON)
  6704. fmt.Println(result)
  6705. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6706. utils.ErrorLog("解析失败:%v", err)
  6707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6708. }
  6709. if result3265.Infcode != "0" {
  6710. c.ServeSuccessJSON(map[string]interface{}{
  6711. "failed_code": -10,
  6712. "msg": result3265.ErrMsg,
  6713. })
  6714. return
  6715. } else {
  6716. c.ServeSuccessJSON(map[string]interface{}{
  6717. "info": result3265.Output.Data,
  6718. })
  6719. return
  6720. }
  6721. }
  6722. func (c *HisApiController) Get3268() {
  6723. admin_user_id, _ := c.GetInt64("admin_user_id")
  6724. startTime := c.GetString("start_time")
  6725. endTime := c.GetString("end_time")
  6726. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6727. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6728. times := strings.Split(startTime, "-")
  6729. setl_mon := times[0] + times[1]
  6730. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6731. var twos []models.FixMonRecDetailFileInTwo
  6732. var funs []models.FundDetail
  6733. for _, item := range datas {
  6734. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6735. funs = append(funs, fun...)
  6736. }
  6737. var funInfos []models.Fund
  6738. //for _, item := range funs {
  6739. // var rf []models.FundInfo
  6740. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6741. // for _, subitem := range rf {
  6742. // var fund models.Fund
  6743. // fund.FundCode = subitem.FundPayType
  6744. // fund.FundName = subitem.FundPayTypeName
  6745. // fund.FundAmt = subitem.FundPayAmt
  6746. // fund.FundKey = item.FundKey
  6747. // fund.InsuAdmdvs = "555555"
  6748. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6749. // funInfos = append(funInfos, fund)
  6750. // }
  6751. //}
  6752. for _, team := range datas {
  6753. var two models.FixMonRecDetailFileInTwo
  6754. two.SetlDate = time.Now().Format("2006-01-02")
  6755. two.MedType = team.MedType
  6756. two.Insutype = team.Insutype
  6757. two.PsnType = team.PsnType
  6758. two.MedType = team.MedType
  6759. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6760. two.InsuAdmdvs = team.InsuAdmdvs
  6761. two.PsnTime = team.PsnTime
  6762. two.PsnCnt = team.PsnCnt
  6763. two.FundKey = team.FundKey
  6764. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6765. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6766. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6767. two.MedfeeSumAmt = ms
  6768. two.InscpAmt = ia
  6769. two.FundPaySumAmt = fps
  6770. twos = append(twos, two)
  6771. }
  6772. var upld_btch string
  6773. upld_btch = "0"
  6774. var empty models.JSResultEmpty
  6775. data := make(map[string]interface{})
  6776. data["org_name"] = miConfig.OrgName
  6777. data["doctor"] = curRoles.UserName
  6778. data["doctor_name"] = curRoles.UserName
  6779. data["fixmedins_code"] = miConfig.Code
  6780. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6782. data["secret_key"] = miConfig.SecretKey
  6783. data["url"] = miConfig.Url
  6784. data["ak"] = miConfig.AccessKey
  6785. data["cainfo"] = miConfig.Cainfo
  6786. data["datas"] = twos
  6787. data["fund"] = funInfos
  6788. data["setl_mon"] = setl_mon
  6789. month := time.Unix(1557042972, 0).Format("1")
  6790. year := time.Now().Format("2006")
  6791. month = time.Now().Format("01")
  6792. day := time.Now().Format("02")
  6793. hour := time.Now().Format("15")
  6794. min := time.Now().Format("04")
  6795. sec := time.Now().Format("05")
  6796. fix_fill_date := year + month + day + hour + min + sec
  6797. data["fix_fill_dept"] = miConfig.OrgName
  6798. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6799. data["fix_fill_psn"] = curRoles.UserName
  6800. data["fix_fill_date"] = fix_fill_date
  6801. data["stmt_loc"] = "2"
  6802. data["upld_btch"] = upld_btch
  6803. client := &http.Client{}
  6804. bytesData, _ := json.Marshal(data)
  6805. var req *http.Request
  6806. if miConfig.MdtrtareaAdmvs == "320921" {
  6807. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6808. } else {
  6809. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6810. }
  6811. resp, _ := client.Do(req)
  6812. defer resp.Body.Close()
  6813. body, ioErr := ioutil.ReadAll(resp.Body)
  6814. if ioErr != nil {
  6815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6817. }
  6818. var respJSON map[string]interface{}
  6819. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6822. }
  6823. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6824. fmt.Println(respJSON)
  6825. result, _ := json.Marshal(respJSON)
  6826. fmt.Println(result)
  6827. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6828. utils.ErrorLog("解析失败:%v", err)
  6829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6830. }
  6831. if empty.Infcode != "0" {
  6832. c.ServeSuccessJSON(map[string]interface{}{
  6833. "failed_code": -10,
  6834. "msg": empty.ErrMsg,
  6835. })
  6836. return
  6837. } else {
  6838. c.ServeSuccessJSON(map[string]interface{}{
  6839. "msg": "上传成功",
  6840. })
  6841. return
  6842. }
  6843. }
  6844. func (c *HisApiController) Get3269() {
  6845. admin_user_id, _ := c.GetInt64("admin_user_id")
  6846. startTime := c.GetString("start_time")
  6847. //endTime, _ := c.GetString("end_time")
  6848. times := strings.Split(startTime, "-")
  6849. setl_mon := times[0] + times[1]
  6850. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6851. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6852. var result3263 models.JSResult3263
  6853. data := make(map[string]interface{})
  6854. data["org_name"] = miConfig.OrgName
  6855. data["doctor"] = curRoles.UserName
  6856. data["doctor_name"] = curRoles.UserName
  6857. data["fixmedins_code"] = miConfig.Code
  6858. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6859. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6860. data["secret_key"] = miConfig.SecretKey
  6861. data["url"] = miConfig.Url
  6862. data["ak"] = miConfig.AccessKey
  6863. data["cainfo"] = miConfig.Cainfo
  6864. data["setl_mon"] = setl_mon
  6865. data["stmt_loc"] = "2"
  6866. client := &http.Client{}
  6867. bytesData, _ := json.Marshal(data)
  6868. var req *http.Request
  6869. if miConfig.MdtrtareaAdmvs == "320921" {
  6870. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6871. } else {
  6872. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6873. }
  6874. resp, _ := client.Do(req)
  6875. defer resp.Body.Close()
  6876. body, ioErr := ioutil.ReadAll(resp.Body)
  6877. if ioErr != nil {
  6878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6880. }
  6881. var respJSON map[string]interface{}
  6882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6885. }
  6886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6887. fmt.Println(respJSON)
  6888. result, _ := json.Marshal(respJSON)
  6889. fmt.Println(result)
  6890. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6891. utils.ErrorLog("解析失败:%v", err)
  6892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6893. }
  6894. if result3263.Infcode != "0" {
  6895. c.ServeSuccessJSON(map[string]interface{}{
  6896. "failed_code": -10,
  6897. "msg": result3263.ErrMsg,
  6898. })
  6899. return
  6900. } else {
  6901. c.ServeSuccessJSON(map[string]interface{}{
  6902. "msg": "上传成功",
  6903. })
  6904. return
  6905. }
  6906. }
  6907. func (c *HisApiController) Get3270() {
  6908. admin_user_id, _ := c.GetInt64("admin_user_id")
  6909. startTime := c.GetString("start_time")
  6910. //endTime, _ := c.GetString("end_time")
  6911. times := strings.Split(startTime, "-")
  6912. setl_mon := times[0] + times[1]
  6913. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6914. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6915. var result3263 models.JSResult3263
  6916. data2 := make(map[string]interface{})
  6917. data2["org_name"] = miConfig.OrgName
  6918. data2["doctor"] = curRoles.UserName
  6919. data2["doctor_name"] = curRoles.UserName
  6920. data2["fixmedins_code"] = miConfig.Code
  6921. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6922. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6923. data2["secret_key"] = miConfig.SecretKey
  6924. data2["url"] = miConfig.Url
  6925. data2["ak"] = miConfig.AccessKey
  6926. data2["cainfo"] = miConfig.Cainfo
  6927. data2["setl_mon"] = setl_mon
  6928. data2["stmt_loc"] = "2"
  6929. client2 := &http.Client{}
  6930. bytesData2, _ := json.Marshal(data2)
  6931. var req3263 *http.Request
  6932. if miConfig.MdtrtareaAdmvs == "320921" {
  6933. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6934. } else {
  6935. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6936. }
  6937. resp2, _ := client2.Do(req3263)
  6938. defer resp2.Body.Close()
  6939. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6940. if ioErr2 != nil {
  6941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6943. }
  6944. var respJSON3263 map[string]interface{}
  6945. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6948. }
  6949. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6950. fmt.Println(respJSON3263)
  6951. result2, _ := json.Marshal(respJSON3263)
  6952. fmt.Println(result2)
  6953. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6954. utils.ErrorLog("解析失败:%v", err)
  6955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6956. }
  6957. var ids []string
  6958. for _, item := range result3263.Output {
  6959. ids = append(ids, item.SolidifyID)
  6960. }
  6961. var result3264 models.JSResult3264
  6962. data := make(map[string]interface{})
  6963. data["org_name"] = miConfig.OrgName
  6964. data["doctor"] = curRoles.UserName
  6965. data["doctor_name"] = curRoles.UserName
  6966. data["fixmedins_code"] = miConfig.Code
  6967. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6968. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6969. data["secret_key"] = miConfig.SecretKey
  6970. data["url"] = miConfig.Url
  6971. data["ak"] = miConfig.AccessKey
  6972. data["cainfo"] = miConfig.Cainfo
  6973. data["setl_mon"] = setl_mon
  6974. data["stmt_loc"] = "2"
  6975. data["solidify_id"] = ids
  6976. client := &http.Client{}
  6977. bytesData, _ := json.Marshal(data)
  6978. var req *http.Request
  6979. if miConfig.MdtrtareaAdmvs == "320921" {
  6980. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6981. } else {
  6982. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6983. }
  6984. resp, _ := client.Do(req)
  6985. defer resp.Body.Close()
  6986. body, ioErr := ioutil.ReadAll(resp.Body)
  6987. if ioErr != nil {
  6988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6990. }
  6991. var respJSON map[string]interface{}
  6992. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6995. }
  6996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6997. fmt.Println(respJSON)
  6998. result, _ := json.Marshal(respJSON)
  6999. fmt.Println(result)
  7000. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7001. utils.ErrorLog("解析失败:%v", err)
  7002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7003. }
  7004. if result3264.Infcode != "0" {
  7005. c.ServeSuccessJSON(map[string]interface{}{
  7006. "failed_code": -10,
  7007. "msg": result3264.ErrMsg,
  7008. })
  7009. return
  7010. } else {
  7011. c.ServeSuccessJSON(map[string]interface{}{
  7012. "info": result3264.Output,
  7013. })
  7014. return
  7015. }
  7016. }
  7017. func (c *HisApiController) Get3271() {
  7018. admin_user_id, _ := c.GetInt64("admin_user_id")
  7019. startTime := c.GetString("start_time")
  7020. //endTime, _ := c.GetString("end_time")
  7021. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7022. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7023. times := strings.Split(startTime, "-")
  7024. setl_mon := times[0] + times[1]
  7025. //var empty models.JSResultEmpty
  7026. var result3265 models.JSResult3264
  7027. var result3263 models.JSResult3263
  7028. data2 := make(map[string]interface{})
  7029. data2["org_name"] = miConfig.OrgName
  7030. data2["doctor"] = curRoles.UserName
  7031. data2["doctor_name"] = curRoles.UserName
  7032. data2["fixmedins_code"] = miConfig.Code
  7033. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7034. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7035. data2["secret_key"] = miConfig.SecretKey
  7036. data2["url"] = miConfig.Url
  7037. data2["ak"] = miConfig.AccessKey
  7038. data2["cainfo"] = miConfig.Cainfo
  7039. data2["setl_mon"] = setl_mon
  7040. data2["stmt_loc"] = "2"
  7041. client2 := &http.Client{}
  7042. bytesData2, _ := json.Marshal(data2)
  7043. var req3263 *http.Request
  7044. if miConfig.MdtrtareaAdmvs == "320921" {
  7045. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7046. } else {
  7047. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7048. }
  7049. resp2, _ := client2.Do(req3263)
  7050. defer resp2.Body.Close()
  7051. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7052. if ioErr2 != nil {
  7053. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. }
  7056. var respJSON3263 map[string]interface{}
  7057. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7060. }
  7061. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7062. fmt.Println(respJSON3263)
  7063. result2, _ := json.Marshal(respJSON3263)
  7064. fmt.Println(result2)
  7065. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7066. utils.ErrorLog("解析失败:%v", err)
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. }
  7069. var ids []string
  7070. for _, item := range result3263.Output {
  7071. ids = append(ids, item.SolidifyID)
  7072. }
  7073. data := make(map[string]interface{})
  7074. data["org_name"] = miConfig.OrgName
  7075. data["doctor"] = curRoles.UserName
  7076. data["doctor_name"] = curRoles.UserName
  7077. data["fixmedins_code"] = miConfig.Code
  7078. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7079. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7080. data["secret_key"] = miConfig.SecretKey
  7081. data["url"] = miConfig.Url
  7082. data["ak"] = miConfig.AccessKey
  7083. data["cainfo"] = miConfig.Cainfo
  7084. data["setl_mon"] = setl_mon
  7085. data["solidify_id"] = ids
  7086. month := time.Unix(1557042972, 0).Format("1")
  7087. year := time.Now().Format("2006")
  7088. month = time.Now().Format("01")
  7089. day := time.Now().Format("02")
  7090. hour := time.Now().Format("15")
  7091. min := time.Now().Format("04")
  7092. sec := time.Now().Format("05")
  7093. fix_fill_date := year + month + day + hour + min + sec
  7094. data["fix_fill_dept"] = miConfig.OrgName
  7095. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7096. data["fix_fill_psn"] = curRoles.UserName
  7097. data["fix_fill_date"] = fix_fill_date
  7098. data["stmt_loc"] = "2"
  7099. client := &http.Client{}
  7100. bytesData, _ := json.Marshal(data)
  7101. var req *http.Request
  7102. if miConfig.MdtrtareaAdmvs == "320921" {
  7103. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7104. } else {
  7105. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7106. }
  7107. resp, _ := client.Do(req)
  7108. defer resp.Body.Close()
  7109. body, ioErr := ioutil.ReadAll(resp.Body)
  7110. if ioErr != nil {
  7111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7113. }
  7114. var respJSON map[string]interface{}
  7115. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7118. }
  7119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7120. fmt.Println(respJSON)
  7121. result, _ := json.Marshal(respJSON)
  7122. fmt.Println(result)
  7123. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7124. utils.ErrorLog("解析失败:%v", err)
  7125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7126. }
  7127. if result3265.Infcode != "0" {
  7128. c.ServeSuccessJSON(map[string]interface{}{
  7129. "failed_code": -10,
  7130. "msg": result3265.ErrMsg,
  7131. })
  7132. return
  7133. } else {
  7134. c.ServeSuccessJSON(map[string]interface{}{
  7135. "info": result3265.Output.Data,
  7136. })
  7137. return
  7138. }
  7139. }
  7140. func (c *HisApiController) Get3272() {
  7141. admin_user_id, _ := c.GetInt64("admin_user_id")
  7142. startTime := c.GetString("start_time")
  7143. //endTime, _ := c.GetString("end_time")
  7144. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7145. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7146. times := strings.Split(startTime, "-")
  7147. setl_mon := times[0] + times[1]
  7148. var upld_btch string
  7149. //var empty models.JSResultEmpty
  7150. var result3265 models.JSResult3264
  7151. data := make(map[string]interface{})
  7152. data["org_name"] = miConfig.OrgName
  7153. data["doctor"] = curRoles.UserName
  7154. data["doctor_name"] = curRoles.UserName
  7155. data["fixmedins_code"] = miConfig.Code
  7156. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7157. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7158. data["secret_key"] = miConfig.SecretKey
  7159. data["url"] = miConfig.Url
  7160. data["ak"] = miConfig.AccessKey
  7161. data["cainfo"] = miConfig.Cainfo
  7162. data["setl_mon"] = setl_mon
  7163. month := time.Unix(1557042972, 0).Format("1")
  7164. year := time.Now().Format("2006")
  7165. month = time.Now().Format("01")
  7166. day := time.Now().Format("02")
  7167. hour := time.Now().Format("15")
  7168. min := time.Now().Format("04")
  7169. sec := time.Now().Format("05")
  7170. fix_fill_date := year + month + day + hour + min + sec
  7171. data["fix_fill_dept"] = miConfig.OrgName
  7172. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7173. data["fix_fill_psn"] = curRoles.UserName
  7174. data["fix_fill_date"] = fix_fill_date
  7175. data["stmt_loc"] = "2"
  7176. data["upld_btch"] = upld_btch
  7177. client := &http.Client{}
  7178. bytesData, _ := json.Marshal(data)
  7179. var req *http.Request
  7180. if miConfig.MdtrtareaAdmvs == "320921" {
  7181. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7182. } else {
  7183. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7184. }
  7185. resp, _ := client.Do(req)
  7186. defer resp.Body.Close()
  7187. body, ioErr := ioutil.ReadAll(resp.Body)
  7188. if ioErr != nil {
  7189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7191. }
  7192. var respJSON map[string]interface{}
  7193. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7196. }
  7197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7198. fmt.Println(respJSON)
  7199. result, _ := json.Marshal(respJSON)
  7200. fmt.Println(result)
  7201. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7202. utils.ErrorLog("解析失败:%v", err)
  7203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7204. }
  7205. if result3265.Infcode != "0" {
  7206. c.ServeSuccessJSON(map[string]interface{}{
  7207. "failed_code": -10,
  7208. "msg": result3265.ErrMsg,
  7209. })
  7210. return
  7211. } else {
  7212. c.ServeSuccessJSON(map[string]interface{}{
  7213. "info": result3265.Output,
  7214. })
  7215. return
  7216. }
  7217. }
  7218. func (c *HisApiController) Get3273() {
  7219. admin_user_id, _ := c.GetInt64("admin_user_id")
  7220. startTime := c.GetString("start_time")
  7221. //endTime, _ := c.GetString("end_time")
  7222. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7223. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7224. times := strings.Split(startTime, "-")
  7225. setl_mon := times[0] + times[1]
  7226. var result3265 models.JSResult3264
  7227. data := make(map[string]interface{})
  7228. data["org_name"] = miConfig.OrgName
  7229. data["doctor"] = curRoles.UserName
  7230. data["doctor_name"] = curRoles.UserName
  7231. data["fixmedins_code"] = miConfig.Code
  7232. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7233. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7234. data["secret_key"] = miConfig.SecretKey
  7235. data["url"] = miConfig.Url
  7236. data["ak"] = miConfig.AccessKey
  7237. data["cainfo"] = miConfig.Cainfo
  7238. data["setl_mon"] = setl_mon
  7239. data["stmt_loc"] = "2"
  7240. client := &http.Client{}
  7241. bytesData, _ := json.Marshal(data)
  7242. var req *http.Request
  7243. if miConfig.MdtrtareaAdmvs == "320921" {
  7244. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7245. } else {
  7246. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7247. }
  7248. resp, _ := client.Do(req)
  7249. defer resp.Body.Close()
  7250. body, ioErr := ioutil.ReadAll(resp.Body)
  7251. if ioErr != nil {
  7252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7254. }
  7255. var respJSON map[string]interface{}
  7256. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7259. }
  7260. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7261. fmt.Println(respJSON)
  7262. result, _ := json.Marshal(respJSON)
  7263. fmt.Println(result)
  7264. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7265. utils.ErrorLog("解析失败:%v", err)
  7266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7267. }
  7268. if result3265.Infcode != "0" {
  7269. c.ServeSuccessJSON(map[string]interface{}{
  7270. "failed_code": -10,
  7271. "msg": result3265.ErrMsg,
  7272. })
  7273. return
  7274. } else {
  7275. c.ServeSuccessJSON(map[string]interface{}{
  7276. "info": result3265.Output.Data,
  7277. })
  7278. return
  7279. }
  7280. }
  7281. func (c *HisApiController) Get3274() {
  7282. //if miConfig.MdtrtareaAdmvs == "320921" {
  7283. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7284. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7285. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7286. //
  7287. //} else {
  7288. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7289. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7290. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7291. //
  7292. //}
  7293. }
  7294. func (c *HisApiController) Get3275() {
  7295. //if miConfig.MdtrtareaAdmvs == "320921" {
  7296. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7297. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7298. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7299. //
  7300. //} else {
  7301. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7302. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7303. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  7304. //
  7305. //}
  7306. }
  7307. func (c *HisApiController) Get3276() {
  7308. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7309. //month := c.GetString("month")
  7310. //
  7311. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7312. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7313. //var api string
  7314. //var res Result5301
  7315. //
  7316. //if miConfig.MdtrtareaAdmvs == "320921" {
  7317. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7318. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7319. //} else {
  7320. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7321. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7322. //}
  7323. //
  7324. //resp, requestErr := http.Get(api)
  7325. //if requestErr != nil {
  7326. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7327. // return
  7328. //}
  7329. //
  7330. //body, ioErr := ioutil.ReadAll(resp.Body)
  7331. //if ioErr != nil {
  7332. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7334. // return
  7335. //}
  7336. //var respJSON map[string]interface{}
  7337. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7338. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7339. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7340. // return
  7341. //}
  7342. //
  7343. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7344. //result, _ := json.Marshal(respJSON)
  7345. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7346. // utils.ErrorLog("解析失败:%v", err)
  7347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7348. // return
  7349. //}
  7350. }
  7351. func (c *HisApiController) Get3277() {
  7352. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7353. //month := c.GetString("month")
  7354. //
  7355. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7356. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7357. //var api string
  7358. //var res Result5301
  7359. //
  7360. //if miConfig.MdtrtareaAdmvs == "320921" {
  7361. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7362. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7363. //} else {
  7364. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7365. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7366. //}
  7367. //
  7368. //resp, requestErr := http.Get(api)
  7369. //if requestErr != nil {
  7370. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7371. // return
  7372. //}
  7373. //
  7374. //body, ioErr := ioutil.ReadAll(resp.Body)
  7375. //if ioErr != nil {
  7376. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7378. // return
  7379. //}
  7380. //var respJSON map[string]interface{}
  7381. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7382. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7384. // return
  7385. //}
  7386. //
  7387. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7388. //result, _ := json.Marshal(respJSON)
  7389. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7390. // utils.ErrorLog("解析失败:%v", err)
  7391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7392. // return
  7393. //}
  7394. }
  7395. func (c *HisApiController) GetCFYLJG001() {
  7396. admin_user_id, _ := c.GetInt64("admin_user_id")
  7397. patient_id, _ := c.GetInt64("patient_id")
  7398. his_patient_id, _ := c.GetInt64("his_patient_id")
  7399. record_time := c.GetString("record_time")
  7400. admin_user_id = 3626
  7401. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7402. psn, _ := service.GetPsnByPatientId(patient_id)
  7403. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7404. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7405. var cFYLJG001 models.CFYLJG001
  7406. timeLayout := "2006-01-02"
  7407. loc, _ := time.LoadLocation("Local")
  7408. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7409. if err != nil {
  7410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7411. return
  7412. }
  7413. recordDateTime := theTime.Unix()
  7414. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7415. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7416. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7417. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7418. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7419. for _, item := range prescriptions {
  7420. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7421. if his.IdCardType == 1 {
  7422. bas := strings.Split(psn.CardInfo, "|")
  7423. basNumber := bas[1]
  7424. fmt.Println(basNumber)
  7425. card_sn := bas[3]
  7426. card_no := bas[2]
  7427. cFYLJG001.MdtrtCertType = "03"
  7428. cFYLJG001.CardSn = card_sn
  7429. cFYLJG001.MdtrtCertNo = card_no
  7430. cFYLJG001.EcToken = ""
  7431. cFYLJG001.AuthNo = ""
  7432. } else if his.IdCardType == 2 {
  7433. cFYLJG001.MdtrtCertType = "02"
  7434. cFYLJG001.CardSn = ""
  7435. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7436. cFYLJG001.EcToken = ""
  7437. cFYLJG001.AuthNo = ""
  7438. } else if his.IdCardType == 4 {
  7439. cFYLJG001.MdtrtCertType = "01"
  7440. cFYLJG001.CardSn = ""
  7441. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7442. cFYLJG001.EcToken = psn.VerifyNumber
  7443. cFYLJG001.AuthNo = ""
  7444. }
  7445. cFYLJG001.BizTypeCode = "01"
  7446. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7447. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7448. cFYLJG001.RxTypeCode = "1"
  7449. tempTime := time.Unix(item.PreTime, 0)
  7450. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7451. cFYLJG001.PrscTime = timeFormatOne
  7452. var count float64
  7453. if item.Type == 1 {
  7454. for _, sumItem := range item.HisDoctorAdviceInfo {
  7455. count = count + sumItem.PrescribingNumber
  7456. }
  7457. }
  7458. cFYLJG001.RxDrugCnt = count
  7459. cFYLJG001.ValiDays = "5"
  7460. ts := time.Unix(item.PreTime, 0)
  7461. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7462. tempTime3 := time.Unix(record_time2, 0)
  7463. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7464. cFYLJG001.ValiEndTime = timeFormat3
  7465. cFYLJG001.RxCotnFlag = "0"
  7466. for _, subItem := range item.HisDoctorAdviceInfo {
  7467. var drug models.RxDrug
  7468. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7469. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7470. drug.RxItemTypeCode = "11"
  7471. drug.DrugDosform = "乳膏剂" //TODO
  7472. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7473. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7474. }
  7475. drug.MedcWayDscr = subItem.DeliveryWay
  7476. tempTime2 := time.Unix(subItem.StartTime, 0)
  7477. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7478. drug.MedcBegntime = timeFormatTwo
  7479. if subItem.Day > 0 {
  7480. ts := time.Unix(subItem.StartTime, 0)
  7481. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7482. tempTime4 := time.Unix(record_time, 0)
  7483. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7484. drug.MedcEndtime = timeFormat5
  7485. } else {
  7486. tempTime2 := time.Unix(subItem.StartTime, 0)
  7487. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7488. drug.MedcEndtime = timeFormatTwo
  7489. }
  7490. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7491. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7492. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7493. drug.DrugCnt = subItem.PrescribingNumber
  7494. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7495. drug.DrugGenname = subItem.AdviceName
  7496. drug.MedcWayCodg = subItem.DeliveryWay
  7497. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7498. drug.SinDoscnt = subItem.SingleDose
  7499. drug.SinDosunt = subItem.SingleDoseUnit
  7500. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7501. drug.UsedFrquName = subItem.ExecutionFrequency
  7502. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7503. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7504. drug.HospApprFlag = "1"
  7505. cFYLJG001.List = append(cFYLJG001.List, drug)
  7506. }
  7507. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7508. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7509. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7510. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7511. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7512. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7513. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7514. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7515. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7516. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7517. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7518. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7519. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7520. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7521. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7522. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7523. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7524. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7525. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7526. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7527. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7528. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7529. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7530. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7531. tempTime2 := time.Now().Unix()
  7532. tempTime6 := time.Unix(tempTime2, 0)
  7533. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7534. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7535. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7536. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7537. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7538. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7539. //memo := make(map[string]interface{})
  7540. //inputData := make(map[string]interface{}, 0)
  7541. //type MyData struct {
  7542. // Insutype string `json:"insutype"`
  7543. //}
  7544. //
  7545. // data := MyData{
  7546. // Insutype: his.Insutype,
  7547. //}
  7548. //
  7549. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7550. var config []*models.HisXtDiagnoseConfig
  7551. for _, item := range diagnosis_ids {
  7552. id, _ := strconv.ParseInt(item, 10, 64)
  7553. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7554. config = append(config, &diagnosisConfig)
  7555. }
  7556. for index, subitem := range config {
  7557. if index == 0 {
  7558. var dia models.DiseInfo
  7559. dia.DiagType = "1"
  7560. dia.MaindiagFlag = "1"
  7561. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7562. dia.DiagCode = subitem.CountryCode
  7563. dia.DiagName = subitem.ClassName
  7564. dia.DiagDept = "肾内科"
  7565. dia.DiagDrNo = doctor.DoctorNumber
  7566. dia.DiagDrName = doctor.UserName
  7567. tempTime3 := time.Unix(item.PreTime, 0)
  7568. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7569. dia.DiagTime = timeFormatTwo
  7570. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7571. } else {
  7572. var dia models.DiseInfo
  7573. dia.DiagType = "1"
  7574. dia.MaindiagFlag = "0"
  7575. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7576. dia.DiagCode = subitem.CountryCode
  7577. dia.DiagName = subitem.ClassName
  7578. dia.DiagDept = "肾内科"
  7579. dia.DiagDrNo = doctor.DoctorNumber
  7580. dia.DiagDrName = doctor.UserName
  7581. tempTime3 := time.Unix(item.PreTime, 0)
  7582. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7583. dia.DiagTime = timeFormatTwo
  7584. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7585. }
  7586. }
  7587. if miConfig.MdtrtareaAdmvs == "340699" {
  7588. result, request := service.GetAHCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7589. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7590. } else {
  7591. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7592. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7593. }
  7594. var res ResultCFYLJG001
  7595. var respJSON2 map[string]interface{}
  7596. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7599. return
  7600. }
  7601. userJSONBytes2, _ := json.Marshal(respJSON2)
  7602. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7603. utils.ErrorLog("解析失败:%v", err)
  7604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7605. return
  7606. }
  7607. if res.Infcode == -1 {
  7608. c.ServeSuccessJSON(map[string]interface{}{
  7609. "failed_code": -10,
  7610. "msg": res.ErrMsg,
  7611. })
  7612. return
  7613. } else {
  7614. var flow models.HisPrescriptionFlow
  7615. flow.Ctime = time.Now().Unix()
  7616. flow.SignDigest = ""
  7617. flow.RxTraceCode = res.Output.RxTraceCode
  7618. flow.HiRxno = res.Output.HiRxno
  7619. flow.MID = his.Number
  7620. flow.Status = 1
  7621. flow.DCode = doctor_info.DoctorNumber
  7622. flow.OriginalRxFile = ""
  7623. flow.OriginalValue = ""
  7624. flow.SignCertDn = ""
  7625. flow.UserOrgId = 10454
  7626. flow.SignCertSn = ""
  7627. flow.Mtime = time.Now().Unix()
  7628. service.Createflow(&flow)
  7629. c.ServeSuccessJSON(map[string]interface{}{
  7630. "msg": "上传成功",
  7631. })
  7632. }
  7633. }
  7634. }
  7635. func (c *HisApiController) GetCFYLJG002() {
  7636. admin_user_id, _ := c.GetInt64("admin_user_id")
  7637. his_patient_id, _ := c.GetInt64("his_patient_id")
  7638. record_time := c.GetString("record_time")
  7639. admin_user_id = 3626
  7640. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7641. //id, _ := c.GetInt64("id")
  7642. admin_user_id = 3626
  7643. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7644. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7645. flow, _ := service.Getflowtwo(his.Number)
  7646. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7647. //record_time := c.GetString("record_time")
  7648. patient_id, _ := c.GetInt64("patient_id")
  7649. //patient_id = 23834
  7650. //record_time = "2023-09-18"
  7651. timeLayout := "2006-01-02"
  7652. loc, _ := time.LoadLocation("Local")
  7653. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7654. if err != nil {
  7655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7656. return
  7657. }
  7658. recordDateTime := theTime.Unix()
  7659. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7660. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7661. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7662. dept, _ := service.GetDepartMentDetail(info.Departments)
  7663. inputData := make(map[string]interface{})
  7664. inputData["rxTraceCode"] = flow.RxTraceCode
  7665. inputData["hiRxno"] = flow.HiRxno
  7666. inputData["mdtrtId"] = flow.MID
  7667. inputData["patnName"] = his.PsnName
  7668. inputData["psnCertType"] = his.PsnCertType
  7669. inputData["certno"] = his.Certno
  7670. inputData["fixmedinsName"] = miConfig.OrgName
  7671. inputData["fixmedinsCode"] = miConfig.Code
  7672. inputData["drCode"] = doctor_info.DoctorNumber
  7673. inputData["prscDrName"] = doctor_info.UserName
  7674. inputData["pharDeptName"] = dept.Name
  7675. inputData["pharDeptCode"] = dept.Number
  7676. inputData["pharProfttlCodg"] = dept.Name
  7677. inputData["pharProfttlName"] = ""
  7678. inputData["pharCode"] = "HY440309002107"
  7679. inputData["pharCertType"] = "01"
  7680. inputData["pharCertno"] = "430482199408260023"
  7681. inputData["pharName"] = "彭斯遥"
  7682. inputData["pharPracCertNo"] = ""
  7683. tempTime2 := time.Unix(info.Ctime, 0)
  7684. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7685. inputData["pharChkTime"] = timeFormatTwo
  7686. bytesData, _ := json.Marshal(inputData)
  7687. fmt.Println(string(bytesData))
  7688. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7689. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7690. if err != nil {
  7691. fmt.Println("Error reading PDF file:", err)
  7692. return
  7693. }
  7694. // 将 PDF 文件内容进行 Base64 编码
  7695. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7696. fmt.Println(err)
  7697. if miConfig.MdtrtareaAdmvs == "340699" {
  7698. result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7699. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7700. } else {
  7701. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7702. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7703. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7704. }
  7705. var res2 Result002
  7706. var respJSON2 map[string]interface{}
  7707. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7710. return
  7711. }
  7712. userJSONBytes2, _ := json.Marshal(respJSON2)
  7713. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7714. utils.ErrorLog("解析失败:%v", err)
  7715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7716. return
  7717. }
  7718. if res2.Infcode == 0 {
  7719. flow.Ctime = time.Now().Unix()
  7720. flow.SignDigest = res2.Output.SignDigest
  7721. flow.RxFile = res2.Output.RxFile
  7722. flow.MID = his.Number
  7723. flow.Status = 1
  7724. flow.DCode = doctor_info.DoctorNumber
  7725. flow.OriginalRxFile = rx_encoded
  7726. flow.OriginalValue = encoded
  7727. flow.SignCertDn = res2.Output.SignCertDn
  7728. flow.SignCertSn = res2.Output.SignCertSn
  7729. flow.Mtime = time.Now().Unix()
  7730. service.Saveflow(flow)
  7731. c.ServeSuccessJSON(map[string]interface{}{
  7732. "msg": "预签名成功",
  7733. })
  7734. } else {
  7735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7736. return
  7737. }
  7738. }
  7739. func (c *HisApiController) GetCFYLJG003() {
  7740. admin_user_id, _ := c.GetInt64("admin_user_id")
  7741. his_patient_id, _ := c.GetInt64("his_patient_id")
  7742. record_time := c.GetString("record_time")
  7743. admin_user_id = 3626
  7744. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7745. //id, _ := c.GetInt64("id")
  7746. admin_user_id = 3626
  7747. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7748. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7749. flow, _ := service.Getflowtwo(his.Number)
  7750. //id = 3
  7751. patient_id, _ := c.GetInt64("patient_id")
  7752. //patient_id = 23834
  7753. //record_time = "2023-09-18"
  7754. timeLayout := "2006-01-02"
  7755. loc, _ := time.LoadLocation("Local")
  7756. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7757. if err != nil {
  7758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7759. return
  7760. }
  7761. recordDateTime := theTime.Unix()
  7762. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7763. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7764. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7765. dept, _ := service.GetDepartMentDetail(info.Departments)
  7766. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7767. var cFYLJG003 models.CFYLJG003
  7768. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7769. cFYLJG003.HiRxno = flow.HiRxno
  7770. cFYLJG003.MdtrtID = flow.MID
  7771. cFYLJG003.PatnName = his.Name
  7772. cFYLJG003.Certno = his.Certno
  7773. cFYLJG003.FixmedinsName = miConfig.OrgName
  7774. cFYLJG003.FixmedinsCode = miConfig.Code
  7775. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7776. cFYLJG003.PrscDrName = doctor_info.UserName
  7777. cFYLJG003.PharDeptName = dept.Name
  7778. cFYLJG003.PharDeptCode = dept.Number
  7779. cFYLJG003.PharCode = "HY440309002107"
  7780. cFYLJG003.PharCertType = "01"
  7781. cFYLJG003.PharCertno = "430482199408260023"
  7782. cFYLJG003.PharName = "彭斯遥"
  7783. cFYLJG003.PsnCertType = "01"
  7784. cFYLJG003.RxFile = flow.RxFile
  7785. cFYLJG003.SignDigest = flow.SignDigest
  7786. cFYLJG003.FixmedinsCode = miConfig.Code
  7787. cFYLJG003.PsnCertType = "01"
  7788. cFYLJG003.PharProfttlCodg = dept.Name
  7789. //inputData["pharProfttlCodg"] =dept.Name
  7790. tempTime2 := time.Unix(info.Ctime, 0)
  7791. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7792. cFYLJG003.PharChkTime = timeFormatTwo
  7793. if miConfig.MdtrtareaAdmvs == "340699" {
  7794. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7795. result, request := service.GetAHCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7796. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  7797. } else {
  7798. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7799. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7800. }
  7801. var res ResultCFYLJG003
  7802. var respJSON2 map[string]interface{}
  7803. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7806. return
  7807. }
  7808. userJSONBytes2, _ := json.Marshal(respJSON2)
  7809. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7810. utils.ErrorLog("解析失败:%v", err)
  7811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7812. return
  7813. }
  7814. if res.Infcode == -1 {
  7815. c.ServeSuccessJSON(map[string]interface{}{
  7816. "failed_code": -10,
  7817. "msg": res.ErrMsg,
  7818. })
  7819. return
  7820. } else {
  7821. c.ServeSuccessJSON(map[string]interface{}{
  7822. "info": res.Output,
  7823. })
  7824. }
  7825. }
  7826. func (c *HisApiController) GetCFYLJG004() {
  7827. admin_user_id, _ := c.GetInt64("admin_user_id")
  7828. his_patient_id, _ := c.GetInt64("his_patient_id")
  7829. record_time := c.GetString("record_time")
  7830. admin_user_id = 3626
  7831. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7832. //id, _ := c.GetInt64("id")
  7833. admin_user_id = 3626
  7834. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7835. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7836. flow, _ := service.Getflowtwo(his.Number)
  7837. //id = 3
  7838. patient_id, _ := c.GetInt64("patient_id")
  7839. //patient_id = 23834
  7840. //record_time = "2023-09-18"
  7841. timeLayout := "2006-01-02"
  7842. loc, _ := time.LoadLocation("Local")
  7843. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7844. if err != nil {
  7845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7846. return
  7847. }
  7848. recordDateTime := theTime.Unix()
  7849. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7850. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7851. var cFYLJG004 models.CFYLJG004
  7852. cFYLJG004.HiRxno = flow.HiRxno
  7853. cFYLJG004.FixmedinsCode = miConfig.Code
  7854. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7855. cFYLJG004.UndoDrCertType = "01"
  7856. cFYLJG004.UndoRea = "撤销处方"
  7857. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7858. cFYLJG004.UndoDrName = doctor_info.UserName
  7859. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7860. if miConfig.MdtrtareaAdmvs == "340699" {
  7861. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7862. result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7863. saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  7864. } else {
  7865. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7866. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7867. }
  7868. var res ResultCFYLJG004
  7869. var respJSON2 map[string]interface{}
  7870. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7873. return
  7874. }
  7875. userJSONBytes2, _ := json.Marshal(respJSON2)
  7876. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7877. utils.ErrorLog("解析失败:%v", err)
  7878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7879. return
  7880. }
  7881. if res.Infcode == -1 {
  7882. c.ServeSuccessJSON(map[string]interface{}{
  7883. "failed_code": -10,
  7884. "msg": res.ErrMsg,
  7885. })
  7886. return
  7887. } else {
  7888. flow.Status = 0
  7889. service.Saveflow(flow)
  7890. c.ServeSuccessJSON(map[string]interface{}{
  7891. "msg": "撤销成功",
  7892. })
  7893. return
  7894. }
  7895. }
  7896. func (c *HisApiController) GetCFYLJG005() {
  7897. admin_user_id, _ := c.GetInt64("admin_user_id")
  7898. his_patient_id, _ := c.GetInt64("his_patient_id")
  7899. //record_time := c.GetString("record_time")
  7900. admin_user_id = 3626
  7901. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7902. //id, _ := c.GetInt64("id")
  7903. admin_user_id = 3626
  7904. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7905. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7906. flow, _ := service.Getflowtwo(his.Number)
  7907. //id = 3
  7908. var cFYLJG005 models.CFYLJG005
  7909. //patient_id, _ := c.GetInt64("patient_id")
  7910. cFYLJG005.HiRxno = flow.HiRxno
  7911. cFYLJG005.MdtrtID = flow.MID
  7912. cFYLJG005.EcToken = ""
  7913. cFYLJG005.PsnName = his.Name
  7914. cFYLJG005.PsnCertType = "01"
  7915. cFYLJG005.Certno = his.IdCardNo
  7916. if miConfig.MdtrtareaAdmvs == "340699" {
  7917. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7918. result, request := service.GetAHCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7919. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7920. } else {
  7921. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7922. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7923. }
  7924. var res ResultCFYLJG005
  7925. var respJSON2 map[string]interface{}
  7926. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7929. return
  7930. }
  7931. userJSONBytes2, _ := json.Marshal(respJSON2)
  7932. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7933. utils.ErrorLog("解析失败:%v", err)
  7934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7935. return
  7936. }
  7937. if res.Infcode == -1 {
  7938. c.ServeSuccessJSON(map[string]interface{}{
  7939. "failed_code": -10,
  7940. "msg": res.ErrMsg,
  7941. })
  7942. return
  7943. } else {
  7944. c.ServeSuccessJSON(map[string]interface{}{
  7945. "info": res.Output,
  7946. })
  7947. return
  7948. }
  7949. }
  7950. func (c *HisApiController) GetCFYLJG006() {
  7951. admin_user_id, _ := c.GetInt64("admin_user_id")
  7952. his_patient_id, _ := c.GetInt64("his_patient_id")
  7953. admin_user_id = 3626
  7954. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7955. //id, _ := c.GetInt64("id")
  7956. admin_user_id = 3626
  7957. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7958. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7959. flow, _ := service.Getflowtwo(his.Number)
  7960. //id = 3
  7961. patient_id, _ := c.GetInt64("patient_id")
  7962. var cFYLJG006 models.CFYLJG006
  7963. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7964. cFYLJG006.HiRxno = flow.HiRxno
  7965. cFYLJG006.MdtrtID = flow.MID
  7966. cFYLJG006.PsnName = patient.Name
  7967. cFYLJG006.PsnCertType = "01"
  7968. cFYLJG006.Certno = patient.IdCardNo
  7969. if miConfig.MdtrtareaAdmvs == "340699" {
  7970. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7971. result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7972. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7973. } else {
  7974. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7975. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7976. }
  7977. var res ResultCFYLJG006
  7978. var respJSON2 map[string]interface{}
  7979. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7982. return
  7983. }
  7984. userJSONBytes2, _ := json.Marshal(respJSON2)
  7985. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7986. utils.ErrorLog("解析失败:%v", err)
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. if res.Infcode == -1 {
  7991. c.ServeSuccessJSON(map[string]interface{}{
  7992. "failed_code": -10,
  7993. "msg": res.ErrMsg,
  7994. })
  7995. return
  7996. } else {
  7997. c.ServeSuccessJSON(map[string]interface{}{
  7998. "info": res.Output,
  7999. })
  8000. return
  8001. }
  8002. }
  8003. func (c *HisApiController) GetCFYLJG007() {
  8004. admin_user_id, _ := c.GetInt64("admin_user_id")
  8005. his_patient_id, _ := c.GetInt64("his_patient_id")
  8006. admin_user_id = 3626
  8007. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8008. //id, _ := c.GetInt64("id")
  8009. admin_user_id = 3626
  8010. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8011. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8012. flow, _ := service.Getflowtwo(his.Number)
  8013. //id = 3
  8014. patient_id, _ := c.GetInt64("patient_id")
  8015. var cFYLJG007 models.CFYLJG007
  8016. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8017. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8018. cFYLJG007.HiRxno = flow.HiRxno
  8019. cFYLJG007.MdtrtID = flow.MID
  8020. cFYLJG007.PsnNo = his.PsnNo
  8021. cFYLJG007.PsnCertType = "01"
  8022. cFYLJG007.Certno = patient.IdCardNo
  8023. cFYLJG007.PsnName = patient.Name
  8024. if miConfig.MdtrtareaAdmvs == "340699" {
  8025. result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8026. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8027. } else {
  8028. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8029. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8030. }
  8031. var res ResultCFYLJG007
  8032. var respJSON2 map[string]interface{}
  8033. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8036. return
  8037. }
  8038. userJSONBytes2, _ := json.Marshal(respJSON2)
  8039. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8040. utils.ErrorLog("解析失败:%v", err)
  8041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8042. return
  8043. }
  8044. if res.Infcode == -1 {
  8045. c.ServeSuccessJSON(map[string]interface{}{
  8046. "failed_code": -10,
  8047. "msg": res.ErrMsg,
  8048. })
  8049. return
  8050. } else {
  8051. c.ServeSuccessJSON(map[string]interface{}{
  8052. "info": res,
  8053. })
  8054. return
  8055. }
  8056. }
  8057. func (c *HisApiController) GetCFYLJG008() {
  8058. admin_user_id, _ := c.GetInt64("admin_user_id")
  8059. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8060. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8061. var cFYLJG008 models.CFYLJG008
  8062. //id, _ := c.GetInt64("id")
  8063. patient_id, _ := c.GetInt64("patient_id")
  8064. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8065. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8066. //id = 3
  8067. //flow, _ := service.Getflow(id)
  8068. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8069. //
  8070. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8071. //patient_id, _ := c.GetInt64("patient_id")
  8072. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8073. record_time := c.GetString("record_time")
  8074. admin_user_id = 3626
  8075. patient_id = 19424
  8076. //his_patient_id = 263947
  8077. record_time = "2023-08-29"
  8078. timeLayout := "2006-01-02"
  8079. loc, _ := time.LoadLocation("Local")
  8080. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8081. if err != nil {
  8082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8083. return
  8084. }
  8085. recordDateTime := theTime.Unix()
  8086. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8087. cFYLJG008.FixmedinsName = ""
  8088. cFYLJG008.Lat = ""
  8089. cFYLJG008.Lng = ""
  8090. cFYLJG008.OrderType = "1"
  8091. cFYLJG008.PoolareaNo = ""
  8092. cFYLJG008.Lng = ""
  8093. cFYLJG008.PageNum = 1
  8094. cFYLJG008.PageSize = 10
  8095. var MPI models.MedinsProdInvChgDDTO
  8096. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8097. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8098. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8099. if miConfig.MdtrtareaAdmvs == "340699" {
  8100. result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8101. saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8102. } else {
  8103. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8104. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8105. var res ResultCFYLJG008
  8106. var respJSON2 map[string]interface{}
  8107. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8110. return
  8111. }
  8112. userJSONBytes2, _ := json.Marshal(respJSON2)
  8113. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8114. utils.ErrorLog("解析失败:%v", err)
  8115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8116. return
  8117. }
  8118. if res.Infcode == -1 {
  8119. c.ServeSuccessJSON(map[string]interface{}{
  8120. "failed_code": -10,
  8121. "msg": res.ErrMsg,
  8122. })
  8123. return
  8124. } else {
  8125. c.ServeSuccessJSON(map[string]interface{}{
  8126. "info": res.Output,
  8127. })
  8128. return
  8129. }
  8130. }
  8131. }
  8132. func (c *HisApiController) GetBL4201A() {
  8133. order_id, _ := c.GetInt64("order_id")
  8134. admin_user_id, _ := c.GetInt64("admin_user_id")
  8135. order, _ := service.GetHisOrderByIDTwo(order_id)
  8136. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8137. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8138. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8139. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8140. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8141. department, _ := service.GetDepartMentDetail(his.Departments)
  8142. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8143. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8144. if order.ID == 0 {
  8145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8146. return
  8147. }
  8148. var struct4201A models.Struct4201A
  8149. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8150. for _, items := range order_info {
  8151. memo := make(map[string]interface{})
  8152. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8153. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8154. fsiOPFLD.MedType = "14"
  8155. fsiOPFLD.BkkpSn = items.FeedetlSn
  8156. fsiOPFLD.FixmedinsCode = miConfig.Code
  8157. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8158. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8159. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8160. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8161. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8162. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8163. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8164. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8165. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8166. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8167. fsiOPFLD.BilgDeptName = department.Name
  8168. fsiOPFLD.BilgDeptCodg = department.Number
  8169. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8170. fsiOPFLD.BilgDrName = doctor.UserName
  8171. fsiOPFLD.MedChrgitmType = "09"
  8172. memo["hosp_appr_flag"] = "1"
  8173. memo["invoice_no"] = order.MdtrtId
  8174. memo["memo"] = "自费"
  8175. bytesData, _ := json.Marshal(memo)
  8176. fsiOPFLD.Memo = string(bytesData)
  8177. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8178. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8179. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8180. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8181. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8182. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8183. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8184. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8185. fsiOPFLD.BilgDeptName = department.Name
  8186. fsiOPFLD.BilgDeptCodg = department.Number
  8187. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8188. fsiOPFLD.BilgDrName = doctor.UserName
  8189. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8190. case 0:
  8191. break
  8192. case 1:
  8193. fsiOPFLD.MedChrgitmType = "14"
  8194. break
  8195. case 2:
  8196. fsiOPFLD.MedChrgitmType = "05"
  8197. break
  8198. case 3:
  8199. fsiOPFLD.MedChrgitmType = "03"
  8200. break
  8201. case 4:
  8202. fsiOPFLD.MedChrgitmType = "03"
  8203. break
  8204. case 5:
  8205. fsiOPFLD.MedChrgitmType = "08"
  8206. break
  8207. case 6:
  8208. fsiOPFLD.MedChrgitmType = "14"
  8209. break
  8210. case 7:
  8211. fsiOPFLD.MedChrgitmType = "14"
  8212. break
  8213. case 8:
  8214. fsiOPFLD.MedChrgitmType = "03"
  8215. break
  8216. case 9:
  8217. fsiOPFLD.MedChrgitmType = "14"
  8218. break
  8219. case 10:
  8220. fsiOPFLD.MedChrgitmType = "14"
  8221. break
  8222. case 11:
  8223. fsiOPFLD.MedChrgitmType = "06"
  8224. break
  8225. case 12:
  8226. fsiOPFLD.MedChrgitmType = "12"
  8227. break
  8228. case 13:
  8229. fsiOPFLD.MedChrgitmType = "01"
  8230. break
  8231. case 14:
  8232. fsiOPFLD.MedChrgitmType = "04"
  8233. break
  8234. case 15:
  8235. fsiOPFLD.MedChrgitmType = "14"
  8236. break
  8237. }
  8238. memo["hosp_appr_flag"] = "1"
  8239. memo["invoice_no"] = order.MdtrtId
  8240. memo["memo"] = "自费"
  8241. bytesData, _ := json.Marshal(memo)
  8242. fsiOPFLD.Memo = string(bytesData)
  8243. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8244. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8245. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8246. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8247. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8248. fsiOPFLD.BilgDeptName = department.Name
  8249. fsiOPFLD.BilgDeptCodg = department.Number
  8250. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8251. fsiOPFLD.BilgDrName = doctor.UserName
  8252. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8253. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8254. fsiOPFLD.MedChrgitmType = "08"
  8255. memo["hosp_appr_flag"] = "1"
  8256. memo["invoice_no"] = order.MdtrtId
  8257. memo["memo"] = "自费"
  8258. bytesData, _ := json.Marshal(memo)
  8259. fsiOPFLD.Memo = string(bytesData)
  8260. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8261. }
  8262. }
  8263. }
  8264. for _, items := range order_info_two {
  8265. memo := make(map[string]interface{})
  8266. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8267. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8268. fsiOPFLD.MedType = "14"
  8269. fsiOPFLD.BkkpSn = items.FeedetlSn
  8270. fsiOPFLD.FixmedinsCode = miConfig.Code
  8271. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8272. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8273. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8274. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8275. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8276. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8277. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8278. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8279. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8280. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8281. fsiOPFLD.BilgDeptName = department.Name
  8282. fsiOPFLD.BilgDeptCodg = department.Number
  8283. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8284. fsiOPFLD.BilgDrName = doctor.UserName
  8285. fsiOPFLD.MedChrgitmType = "09"
  8286. memo["hosp_appr_flag"] = "1"
  8287. memo["invoice_no"] = order.MdtrtId
  8288. memo["memo"] = "自费"
  8289. bytesData, _ := json.Marshal(memo)
  8290. fsiOPFLD.Memo = string(bytesData)
  8291. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8292. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8293. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8294. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8295. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8296. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8297. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8298. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8299. fsiOPFLD.BilgDeptName = department.Name
  8300. fsiOPFLD.BilgDeptCodg = department.Number
  8301. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8302. fsiOPFLD.BilgDrName = doctor.UserName
  8303. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8304. case 0:
  8305. break
  8306. case 1:
  8307. fsiOPFLD.MedChrgitmType = "14"
  8308. break
  8309. case 2:
  8310. fsiOPFLD.MedChrgitmType = "05"
  8311. break
  8312. case 3:
  8313. fsiOPFLD.MedChrgitmType = "03"
  8314. break
  8315. case 4:
  8316. fsiOPFLD.MedChrgitmType = "03"
  8317. break
  8318. case 5:
  8319. fsiOPFLD.MedChrgitmType = "08"
  8320. break
  8321. case 6:
  8322. fsiOPFLD.MedChrgitmType = "14"
  8323. break
  8324. case 7:
  8325. fsiOPFLD.MedChrgitmType = "14"
  8326. break
  8327. case 8:
  8328. fsiOPFLD.MedChrgitmType = "03"
  8329. break
  8330. case 9:
  8331. fsiOPFLD.MedChrgitmType = "14"
  8332. break
  8333. case 10:
  8334. fsiOPFLD.MedChrgitmType = "14"
  8335. break
  8336. case 11:
  8337. fsiOPFLD.MedChrgitmType = "06"
  8338. break
  8339. case 12:
  8340. fsiOPFLD.MedChrgitmType = "12"
  8341. break
  8342. case 13:
  8343. fsiOPFLD.MedChrgitmType = "01"
  8344. break
  8345. case 14:
  8346. fsiOPFLD.MedChrgitmType = "04"
  8347. break
  8348. case 15:
  8349. fsiOPFLD.MedChrgitmType = "14"
  8350. break
  8351. }
  8352. memo["hosp_appr_flag"] = "1"
  8353. memo["invoice_no"] = order.MdtrtId
  8354. memo["memo"] = "自费"
  8355. bytesData, _ := json.Marshal(memo)
  8356. fsiOPFLD.Memo = string(bytesData)
  8357. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8358. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8359. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8360. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8361. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8362. fsiOPFLD.BilgDeptName = department.Name
  8363. fsiOPFLD.BilgDeptCodg = department.Number
  8364. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8365. fsiOPFLD.BilgDrName = doctor.UserName
  8366. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8367. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8368. fsiOPFLD.MedChrgitmType = "08"
  8369. memo["hosp_appr_flag"] = "1"
  8370. memo["invoice_no"] = order.MdtrtId
  8371. memo["memo"] = "自费"
  8372. bytesData, _ := json.Marshal(memo)
  8373. fsiOPFLD.Memo = string(bytesData)
  8374. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8375. }
  8376. }
  8377. }
  8378. fmt.Println(fsiOPFLDs)
  8379. struct4201A.Fopfd = fsiOPFLDs
  8380. fmt.Println(struct4201A.Fopfd)
  8381. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8382. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8383. var res2 ResultSix
  8384. var respJSON2 map[string]interface{}
  8385. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8388. return
  8389. }
  8390. userJSONBytes2, _ := json.Marshal(respJSON2)
  8391. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8392. utils.ErrorLog("解析失败:%v", err)
  8393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8394. return
  8395. }
  8396. if res2.Infcode != 0 {
  8397. c.ServeSuccessJSON(map[string]interface{}{
  8398. "failed_code": -10,
  8399. "msg": res2.ErrMsg,
  8400. })
  8401. return
  8402. } else {
  8403. order.IsUploadOrderInfo = 1
  8404. service.UpdateOrder(order)
  8405. c.ServeSuccessJSON(map[string]interface{}{
  8406. "msg": "上传成功",
  8407. })
  8408. }
  8409. }
  8410. func (c *HisApiController) Get2505() {
  8411. admin_user_id, _ := c.GetInt64("admin_user_id")
  8412. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8413. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8414. 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)
  8415. }
  8416. func (c *HisApiController) Get4201A() {
  8417. order_id, _ := c.GetInt64("order_id")
  8418. admin_user_id, _ := c.GetInt64("admin_user_id")
  8419. order, _ := service.GetHisOrderByIDTwo(order_id)
  8420. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8421. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8422. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8423. //order_info = append(order_info, order_info_two...)
  8424. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8425. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8426. department, _ := service.GetDepartMentDetail(his.Departments)
  8427. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8428. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8429. if order.ID == 0 {
  8430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8431. return
  8432. }
  8433. var struct4201A models.Struct4201A
  8434. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8435. for _, items := range order_info {
  8436. memo := make(map[string]interface{})
  8437. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8438. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8439. fsiOPFLD.MedType = "14"
  8440. fsiOPFLD.BkkpSn = items.FeedetlSn
  8441. fsiOPFLD.FixmedinsCode = miConfig.Code
  8442. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8443. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8444. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8445. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8446. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8447. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8448. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8449. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8450. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8451. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8452. fsiOPFLD.BilgDeptName = department.Name
  8453. fsiOPFLD.BilgDeptCodg = department.Number
  8454. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8455. fsiOPFLD.BilgDrName = doctor.UserName
  8456. fsiOPFLD.MedChrgitmType = "09"
  8457. memo["hosp_appr_flag"] = "1"
  8458. memo["invoice_no"] = order.MdtrtId
  8459. memo["memo"] = "自费"
  8460. bytesData, _ := json.Marshal(memo)
  8461. fsiOPFLD.Memo = string(bytesData)
  8462. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8463. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8464. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8465. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8466. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8467. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8468. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8469. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8470. fsiOPFLD.BilgDeptName = department.Name
  8471. fsiOPFLD.BilgDeptCodg = department.Number
  8472. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8473. fsiOPFLD.BilgDrName = doctor.UserName
  8474. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8475. case 0:
  8476. break
  8477. case 1:
  8478. fsiOPFLD.MedChrgitmType = "14"
  8479. break
  8480. case 2:
  8481. fsiOPFLD.MedChrgitmType = "05"
  8482. break
  8483. case 3:
  8484. fsiOPFLD.MedChrgitmType = "03"
  8485. break
  8486. case 4:
  8487. fsiOPFLD.MedChrgitmType = "03"
  8488. break
  8489. case 5:
  8490. fsiOPFLD.MedChrgitmType = "08"
  8491. break
  8492. case 6:
  8493. fsiOPFLD.MedChrgitmType = "14"
  8494. break
  8495. case 7:
  8496. fsiOPFLD.MedChrgitmType = "14"
  8497. break
  8498. case 8:
  8499. fsiOPFLD.MedChrgitmType = "03"
  8500. break
  8501. case 9:
  8502. fsiOPFLD.MedChrgitmType = "14"
  8503. break
  8504. case 10:
  8505. fsiOPFLD.MedChrgitmType = "14"
  8506. break
  8507. case 11:
  8508. fsiOPFLD.MedChrgitmType = "06"
  8509. break
  8510. case 12:
  8511. fsiOPFLD.MedChrgitmType = "12"
  8512. break
  8513. case 13:
  8514. fsiOPFLD.MedChrgitmType = "01"
  8515. break
  8516. case 14:
  8517. fsiOPFLD.MedChrgitmType = "04"
  8518. break
  8519. case 15:
  8520. fsiOPFLD.MedChrgitmType = "14"
  8521. break
  8522. }
  8523. memo["hosp_appr_flag"] = "1"
  8524. memo["invoice_no"] = order.MdtrtId
  8525. memo["memo"] = "自费"
  8526. bytesData, _ := json.Marshal(memo)
  8527. fsiOPFLD.Memo = string(bytesData)
  8528. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8529. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8530. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8531. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8532. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8533. fsiOPFLD.BilgDeptName = department.Name
  8534. fsiOPFLD.BilgDeptCodg = department.Number
  8535. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8536. fsiOPFLD.BilgDrName = doctor.UserName
  8537. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8538. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8539. fsiOPFLD.MedChrgitmType = "08"
  8540. memo["hosp_appr_flag"] = "1"
  8541. memo["invoice_no"] = order.MdtrtId
  8542. memo["memo"] = "自费"
  8543. bytesData, _ := json.Marshal(memo)
  8544. fsiOPFLD.Memo = string(bytesData)
  8545. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8546. }
  8547. }
  8548. }
  8549. for _, items := range order_info_two {
  8550. memo := make(map[string]interface{})
  8551. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8552. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8553. fsiOPFLD.MedType = "14"
  8554. fsiOPFLD.BkkpSn = items.FeedetlSn
  8555. fsiOPFLD.FixmedinsCode = miConfig.Code
  8556. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8557. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8558. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8559. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8560. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8561. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8562. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8563. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8564. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8565. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8566. fsiOPFLD.BilgDeptName = department.Name
  8567. fsiOPFLD.BilgDeptCodg = department.Number
  8568. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8569. fsiOPFLD.BilgDrName = doctor.UserName
  8570. fsiOPFLD.MedChrgitmType = "09"
  8571. memo["hosp_appr_flag"] = "1"
  8572. memo["invoice_no"] = order.MdtrtId
  8573. memo["memo"] = "自费"
  8574. bytesData, _ := json.Marshal(memo)
  8575. fsiOPFLD.Memo = string(bytesData)
  8576. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8577. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8578. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8579. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8580. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8581. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8582. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8583. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8584. fsiOPFLD.BilgDeptName = department.Name
  8585. fsiOPFLD.BilgDeptCodg = department.Number
  8586. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8587. fsiOPFLD.BilgDrName = doctor.UserName
  8588. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8589. case 0:
  8590. break
  8591. case 1:
  8592. fsiOPFLD.MedChrgitmType = "14"
  8593. break
  8594. case 2:
  8595. fsiOPFLD.MedChrgitmType = "05"
  8596. break
  8597. case 3:
  8598. fsiOPFLD.MedChrgitmType = "03"
  8599. break
  8600. case 4:
  8601. fsiOPFLD.MedChrgitmType = "03"
  8602. break
  8603. case 5:
  8604. fsiOPFLD.MedChrgitmType = "08"
  8605. break
  8606. case 6:
  8607. fsiOPFLD.MedChrgitmType = "14"
  8608. break
  8609. case 7:
  8610. fsiOPFLD.MedChrgitmType = "14"
  8611. break
  8612. case 8:
  8613. fsiOPFLD.MedChrgitmType = "03"
  8614. break
  8615. case 9:
  8616. fsiOPFLD.MedChrgitmType = "14"
  8617. break
  8618. case 10:
  8619. fsiOPFLD.MedChrgitmType = "14"
  8620. break
  8621. case 11:
  8622. fsiOPFLD.MedChrgitmType = "06"
  8623. break
  8624. case 12:
  8625. fsiOPFLD.MedChrgitmType = "12"
  8626. break
  8627. case 13:
  8628. fsiOPFLD.MedChrgitmType = "01"
  8629. break
  8630. case 14:
  8631. fsiOPFLD.MedChrgitmType = "04"
  8632. break
  8633. case 15:
  8634. fsiOPFLD.MedChrgitmType = "14"
  8635. break
  8636. }
  8637. memo["hosp_appr_flag"] = "1"
  8638. memo["invoice_no"] = order.MdtrtId
  8639. memo["memo"] = "自费"
  8640. bytesData, _ := json.Marshal(memo)
  8641. fsiOPFLD.Memo = string(bytesData)
  8642. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8643. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8644. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8645. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8646. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8647. fsiOPFLD.BilgDeptName = department.Name
  8648. fsiOPFLD.BilgDeptCodg = department.Number
  8649. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8650. fsiOPFLD.BilgDrName = doctor.UserName
  8651. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8652. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8653. fsiOPFLD.MedChrgitmType = "08"
  8654. memo["hosp_appr_flag"] = "1"
  8655. memo["invoice_no"] = order.MdtrtId
  8656. memo["memo"] = "自费"
  8657. bytesData, _ := json.Marshal(memo)
  8658. fsiOPFLD.Memo = string(bytesData)
  8659. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8660. }
  8661. }
  8662. }
  8663. fmt.Println(fsiOPFLDs)
  8664. struct4201A.Fopfd = fsiOPFLDs
  8665. fmt.Println(struct4201A.Fopfd)
  8666. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8667. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8668. var res2 ResultSix
  8669. var respJSON2 map[string]interface{}
  8670. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8673. return
  8674. }
  8675. userJSONBytes2, _ := json.Marshal(respJSON2)
  8676. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8677. utils.ErrorLog("解析失败:%v", err)
  8678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8679. return
  8680. }
  8681. if res2.Infcode != 0 {
  8682. c.ServeSuccessJSON(map[string]interface{}{
  8683. "failed_code": -10,
  8684. "msg": res2.ErrMsg,
  8685. })
  8686. return
  8687. } else {
  8688. order.IsUploadOrderInfo = 1
  8689. service.UpdateOrder(order)
  8690. c.ServeSuccessJSON(map[string]interface{}{
  8691. "msg": "上传成功",
  8692. })
  8693. }
  8694. }
  8695. func (c *HisApiController) Get4202() {
  8696. order_id, _ := c.GetInt64("order_id")
  8697. admin_user_id, _ := c.GetInt64("admin_user_id")
  8698. order, _ := service.GetHisOrderByIDTwo(order_id)
  8699. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8700. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8701. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8702. if order.ID == 0 {
  8703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8704. return
  8705. }
  8706. var struct4202 models.Struct4202
  8707. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8708. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8709. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8710. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8711. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8712. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8713. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8714. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8715. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8716. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8717. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8718. var config []*models.HisXtDiagnoseConfig
  8719. for _, item := range diagnosis_ids {
  8720. id, _ := strconv.ParseInt(item, 10, 64)
  8721. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8722. config = append(config, &diagnosisConfig)
  8723. }
  8724. var tempDiaginfos []models.OwnPayPatnDiagListD
  8725. for index, item := range config {
  8726. if index == 0 {
  8727. var tempDiaginfo models.OwnPayPatnDiagListD
  8728. tempDiaginfo.InoutDiagType = "1"
  8729. tempDiaginfo.DiagCode = item.CountryCode
  8730. tempDiaginfo.DiagName = item.CountryContentName
  8731. tempDiaginfo.DiagType = "1"
  8732. tempDiaginfo.DiagSrtNo = "1"
  8733. tempDiaginfo.MaindiagFlag = "1"
  8734. tempDiaginfo.ValiFlag = "1"
  8735. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8736. } else {
  8737. var tempDiaginfo models.OwnPayPatnDiagListD
  8738. tempDiaginfo.DiagCode = item.CountryCode
  8739. tempDiaginfo.DiagName = item.CountryContentName
  8740. tempDiaginfo.DiagType = "2"
  8741. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8742. tempDiaginfo.MaindiagFlag = "0"
  8743. tempDiaginfo.ValiFlag = "1"
  8744. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8745. }
  8746. }
  8747. struct4202.ODiagListD = tempDiaginfos
  8748. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8749. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8750. var res2 ResultSix
  8751. var respJSON2 map[string]interface{}
  8752. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8755. return
  8756. }
  8757. userJSONBytes2, _ := json.Marshal(respJSON2)
  8758. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8759. utils.ErrorLog("解析失败:%v", err)
  8760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8761. return
  8762. }
  8763. if res2.Infcode != 0 {
  8764. c.ServeSuccessJSON(map[string]interface{}{
  8765. "failed_code": -10,
  8766. "msg": res2.ErrMsg,
  8767. })
  8768. return
  8769. } else {
  8770. order.IsUploadDiagnose = 1
  8771. service.UpdateOrder(order)
  8772. c.ServeSuccessJSON(map[string]interface{}{
  8773. "msg": "上传成功",
  8774. })
  8775. }
  8776. }
  8777. func (c *HisApiController) Get4203() {
  8778. admin_user_id, _ := c.GetInt64("admin_user_id")
  8779. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8780. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8781. order_id, _ := c.GetInt64("order_id")
  8782. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8783. number := ""
  8784. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8785. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8786. if his.ID == 0 {
  8787. number = hospital.Number
  8788. } else {
  8789. number = his.Number
  8790. }
  8791. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8792. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8793. var res2 ResultSix
  8794. var respJSON2 map[string]interface{}
  8795. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8798. return
  8799. }
  8800. userJSONBytes2, _ := json.Marshal(respJSON2)
  8801. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8802. utils.ErrorLog("解析失败:%v", err)
  8803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8804. return
  8805. }
  8806. if res2.Infcode != 0 {
  8807. c.ServeSuccessJSON(map[string]interface{}{
  8808. "failed_code": -10,
  8809. "msg": res2.ErrMsg,
  8810. })
  8811. return
  8812. } else {
  8813. order.IsUploadSuccess = 1
  8814. service.UpdateOrderTwo(order)
  8815. c.ServeSuccessJSON(map[string]interface{}{
  8816. "msg": "上传成功",
  8817. })
  8818. }
  8819. }
  8820. func (c *HisApiController) Get4205() {
  8821. order_id, _ := c.GetInt64("order_id")
  8822. admin_user_id, _ := c.GetInt64("admin_user_id")
  8823. fapiao_code := c.GetString("fapiao_code")
  8824. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8825. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8826. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8827. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8828. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8829. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8830. //order_info = append(order_info, order_info_two...)
  8831. department, _ := service.GetDepartMentDetail(his.Departments)
  8832. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8833. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8834. if order.ID == 0 {
  8835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8836. return
  8837. }
  8838. var struct4201A models.Struct4201A
  8839. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8840. for _, items := range order_info {
  8841. memo := make(map[string]interface{})
  8842. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8843. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8844. fsiOPFLD.MedType = pre.MedType
  8845. fsiOPFLD.FixmedinsCode = miConfig.Code
  8846. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8847. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8848. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8849. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8850. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8851. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8852. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8853. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8854. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8855. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8856. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8857. fsiOPFLD.BilgDeptName = department.Name
  8858. fsiOPFLD.BilgDeptCodg = department.Number
  8859. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8860. fsiOPFLD.BilgDrName = doctor.UserName
  8861. fsiOPFLD.MedChrgitmType = "09"
  8862. memo["hosp_appr_flag"] = "1"
  8863. memo["invoice_no"] = fapiao_code
  8864. memo["memo"] = "自费"
  8865. bytesData, _ := json.Marshal(memo)
  8866. fsiOPFLD.Memo = string(bytesData)
  8867. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8868. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8869. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8870. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8871. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8872. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8873. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8874. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8875. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8876. fsiOPFLD.BilgDeptName = department.Name
  8877. fsiOPFLD.BilgDeptCodg = department.Number
  8878. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8879. fsiOPFLD.BilgDrName = doctor.UserName
  8880. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8881. case 0:
  8882. break
  8883. case 1:
  8884. fsiOPFLD.MedChrgitmType = "14"
  8885. break
  8886. case 2:
  8887. fsiOPFLD.MedChrgitmType = "05"
  8888. break
  8889. case 3:
  8890. fsiOPFLD.MedChrgitmType = "03"
  8891. break
  8892. case 4:
  8893. fsiOPFLD.MedChrgitmType = "03"
  8894. break
  8895. case 5:
  8896. fsiOPFLD.MedChrgitmType = "08"
  8897. break
  8898. case 6:
  8899. fsiOPFLD.MedChrgitmType = "14"
  8900. break
  8901. case 7:
  8902. fsiOPFLD.MedChrgitmType = "14"
  8903. break
  8904. case 8:
  8905. fsiOPFLD.MedChrgitmType = "03"
  8906. break
  8907. case 9:
  8908. fsiOPFLD.MedChrgitmType = "14"
  8909. break
  8910. case 10:
  8911. fsiOPFLD.MedChrgitmType = "14"
  8912. break
  8913. case 11:
  8914. fsiOPFLD.MedChrgitmType = "06"
  8915. break
  8916. case 12:
  8917. fsiOPFLD.MedChrgitmType = "12"
  8918. break
  8919. case 13:
  8920. fsiOPFLD.MedChrgitmType = "01"
  8921. break
  8922. case 14:
  8923. fsiOPFLD.MedChrgitmType = "04"
  8924. break
  8925. case 15:
  8926. fsiOPFLD.MedChrgitmType = "14"
  8927. break
  8928. }
  8929. memo["hosp_appr_flag"] = "1"
  8930. memo["invoice_no"] = fapiao_code
  8931. memo["memo"] = "自费"
  8932. bytesData, _ := json.Marshal(memo)
  8933. fsiOPFLD.Memo = string(bytesData)
  8934. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8935. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8936. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8937. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8938. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8939. fsiOPFLD.BilgDeptName = department.Name
  8940. fsiOPFLD.BilgDeptCodg = department.Number
  8941. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8942. fsiOPFLD.BilgDrName = doctor.UserName
  8943. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8944. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8945. fsiOPFLD.MedChrgitmType = "08"
  8946. memo["hosp_appr_flag"] = "1"
  8947. memo["invoice_no"] = fapiao_code
  8948. memo["memo"] = "自费"
  8949. bytesData, _ := json.Marshal(memo)
  8950. fsiOPFLD.Memo = string(bytesData)
  8951. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8952. }
  8953. }
  8954. }
  8955. for _, items := range order_info_two {
  8956. memo := make(map[string]interface{})
  8957. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8958. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8959. fsiOPFLD.MedType = pre.MedType
  8960. fsiOPFLD.BkkpSn = items.FeedetlSn
  8961. fsiOPFLD.FixmedinsCode = miConfig.Code
  8962. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8963. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8964. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8965. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8966. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8967. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8968. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8969. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8970. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8971. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8972. fsiOPFLD.BilgDeptName = department.Name
  8973. fsiOPFLD.BilgDeptCodg = department.Number
  8974. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8975. fsiOPFLD.BilgDrName = doctor.UserName
  8976. fsiOPFLD.MedChrgitmType = "09"
  8977. memo["hosp_appr_flag"] = "1"
  8978. memo["invoice_no"] = fapiao_code
  8979. memo["memo"] = "自费"
  8980. bytesData, _ := json.Marshal(memo)
  8981. fsiOPFLD.Memo = string(bytesData)
  8982. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8983. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8984. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8985. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8986. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8987. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8988. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8989. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8990. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8991. fsiOPFLD.BilgDeptName = department.Name
  8992. fsiOPFLD.BilgDeptCodg = department.Number
  8993. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8994. fsiOPFLD.BilgDrName = doctor.UserName
  8995. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8996. case 0:
  8997. break
  8998. case 1:
  8999. fsiOPFLD.MedChrgitmType = "14"
  9000. break
  9001. case 2:
  9002. fsiOPFLD.MedChrgitmType = "05"
  9003. break
  9004. case 3:
  9005. fsiOPFLD.MedChrgitmType = "03"
  9006. break
  9007. case 4:
  9008. fsiOPFLD.MedChrgitmType = "03"
  9009. break
  9010. case 5:
  9011. fsiOPFLD.MedChrgitmType = "08"
  9012. break
  9013. case 6:
  9014. fsiOPFLD.MedChrgitmType = "14"
  9015. break
  9016. case 7:
  9017. fsiOPFLD.MedChrgitmType = "14"
  9018. break
  9019. case 8:
  9020. fsiOPFLD.MedChrgitmType = "03"
  9021. break
  9022. case 9:
  9023. fsiOPFLD.MedChrgitmType = "14"
  9024. break
  9025. case 10:
  9026. fsiOPFLD.MedChrgitmType = "14"
  9027. break
  9028. case 11:
  9029. fsiOPFLD.MedChrgitmType = "06"
  9030. break
  9031. case 12:
  9032. fsiOPFLD.MedChrgitmType = "12"
  9033. break
  9034. case 13:
  9035. fsiOPFLD.MedChrgitmType = "01"
  9036. break
  9037. case 14:
  9038. fsiOPFLD.MedChrgitmType = "04"
  9039. break
  9040. case 15:
  9041. fsiOPFLD.MedChrgitmType = "14"
  9042. break
  9043. }
  9044. memo["hosp_appr_flag"] = "1"
  9045. memo["invoice_no"] = fapiao_code
  9046. memo["memo"] = "自费"
  9047. bytesData, _ := json.Marshal(memo)
  9048. fsiOPFLD.Memo = string(bytesData)
  9049. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9050. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9051. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9052. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9053. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9054. fsiOPFLD.BilgDeptName = department.Name
  9055. fsiOPFLD.BilgDeptCodg = department.Number
  9056. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9057. fsiOPFLD.BilgDrName = doctor.UserName
  9058. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9059. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9060. fsiOPFLD.MedChrgitmType = "08"
  9061. memo["hosp_appr_flag"] = "1"
  9062. memo["invoice_no"] = fapiao_code
  9063. memo["memo"] = "自费"
  9064. bytesData, _ := json.Marshal(memo)
  9065. fsiOPFLD.Memo = string(bytesData)
  9066. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9067. }
  9068. }
  9069. }
  9070. fmt.Println(fsiOPFLDs)
  9071. struct4201A.Fopfd = fsiOPFLDs
  9072. fmt.Println(struct4201A.Fopfd)
  9073. var struct4202 models.Struct4202
  9074. timeLayout := "2006-01-02 15:04:05"
  9075. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9076. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9077. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9078. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9079. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9080. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9081. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9082. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9083. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9084. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9085. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9086. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9087. var config []*models.HisXtDiagnoseConfig
  9088. for _, item := range diagnosis_ids {
  9089. id, _ := strconv.ParseInt(item, 10, 64)
  9090. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9091. config = append(config, &diagnosisConfig)
  9092. }
  9093. var tempDiaginfos []models.OwnPayPatnDiagListD
  9094. for index, item := range config {
  9095. if index == 0 {
  9096. var tempDiaginfo models.OwnPayPatnDiagListD
  9097. tempDiaginfo.InoutDiagType = "1"
  9098. tempDiaginfo.DiagCode = item.CountryCode
  9099. tempDiaginfo.DiagName = item.CountryContentName
  9100. tempDiaginfo.DiagType = "1"
  9101. tempDiaginfo.DiagSrtNo = "1"
  9102. tempDiaginfo.MaindiagFlag = "1"
  9103. tempDiaginfo.ValiFlag = "1"
  9104. tempDiaginfo.DiagDrName = doctor.UserName
  9105. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9106. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9107. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9108. } else {
  9109. var tempDiaginfo models.OwnPayPatnDiagListD
  9110. tempDiaginfo.DiagCode = item.CountryCode
  9111. tempDiaginfo.DiagName = item.CountryContentName
  9112. tempDiaginfo.DiagType = "2"
  9113. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9114. tempDiaginfo.MaindiagFlag = "0"
  9115. tempDiaginfo.ValiFlag = "1"
  9116. tempDiaginfo.DiagDrName = doctor.UserName
  9117. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9118. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9119. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9120. }
  9121. }
  9122. struct4202.ODiagListD = tempDiaginfos
  9123. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9124. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9125. var res2 ResultSix
  9126. var respJSON2 map[string]interface{}
  9127. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9130. return
  9131. }
  9132. userJSONBytes2, _ := json.Marshal(respJSON2)
  9133. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9134. utils.ErrorLog("解析失败:%v", err)
  9135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9136. return
  9137. }
  9138. if res2.Infcode != 0 {
  9139. c.ServeSuccessJSON(map[string]interface{}{
  9140. "failed_code": -10,
  9141. "msg": res2.ErrMsg,
  9142. })
  9143. return
  9144. } else {
  9145. order.IsUploadDiagnose = 1
  9146. order.IsUploadOrderInfo = 1
  9147. service.UpdateOrderTwo(order)
  9148. c.ServeSuccessJSON(map[string]interface{}{
  9149. "msg": "上传成功",
  9150. })
  9151. }
  9152. }
  9153. func (c *HisApiController) Get4207() {
  9154. admin_user_id, _ := c.GetInt64("admin_user_id")
  9155. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9156. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9157. order_id, _ := c.GetInt64("order_id")
  9158. order, _ := service.GetHisOrderByIDTwo(order_id)
  9159. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9160. var struct4207 models.Struct4207
  9161. struct4207.PageNum = "1"
  9162. struct4207.PageSize = "1000"
  9163. struct4207.FixmedinsCode = miConfig.Code
  9164. struct4207.FixmedinsMdtrtID = order.Number
  9165. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9166. saveLog(result, requestLog, "4207", "查询")
  9167. var res2 ResultSix
  9168. var respJSON2 map[string]interface{}
  9169. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9172. return
  9173. }
  9174. userJSONBytes2, _ := json.Marshal(respJSON2)
  9175. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9176. utils.ErrorLog("解析失败:%v", err)
  9177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9178. return
  9179. }
  9180. if res2.Infcode != 0 {
  9181. c.ServeSuccessJSON(map[string]interface{}{
  9182. "failed_code": -10,
  9183. "msg": res2.ErrMsg,
  9184. })
  9185. return
  9186. } else {
  9187. c.ServeSuccessJSON(map[string]interface{}{
  9188. "msg": "查询成功",
  9189. })
  9190. }
  9191. }
  9192. func (c *HisApiController) Get4208() {
  9193. admin_user_id, _ := c.GetInt64("admin_user_id")
  9194. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9195. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9196. order_id, _ := c.GetInt64("order_id")
  9197. order, _ := service.GetHisOrderByIDTwo(order_id)
  9198. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9199. var struct4208 models.Struct4208
  9200. struct4208.PageNum = "1"
  9201. struct4208.PageSize = "1000"
  9202. struct4208.PsnCertType = "01"
  9203. struct4208.Certno = his.Certno
  9204. struct4208.MedType = order.MedType
  9205. struct4208.PsnName = his.Name
  9206. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9207. saveLog(result, requestLog, "4208", "查询")
  9208. var res2 ResultSix
  9209. var respJSON2 map[string]interface{}
  9210. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9213. return
  9214. }
  9215. userJSONBytes2, _ := json.Marshal(respJSON2)
  9216. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9217. utils.ErrorLog("解析失败:%v", err)
  9218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9219. return
  9220. }
  9221. if res2.Infcode != 0 {
  9222. c.ServeSuccessJSON(map[string]interface{}{
  9223. "failed_code": -10,
  9224. "msg": res2.ErrMsg,
  9225. })
  9226. return
  9227. } else {
  9228. c.ServeSuccessJSON(map[string]interface{}{
  9229. "msg": "查询成功",
  9230. })
  9231. }
  9232. }
  9233. func (c *HisApiController) Get4209() {
  9234. admin_user_id, _ := c.GetInt64("admin_user_id")
  9235. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9236. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9237. order_id, _ := c.GetInt64("order_id")
  9238. order, _ := service.GetHisOrderByIDTwo(order_id)
  9239. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9240. var struct4209 models.Struct4209
  9241. struct4209.FixmedinsMdtrtID = order.Number
  9242. struct4209.FixmedinsCode = miConfig.Code
  9243. struct4209.PageSize = "1000"
  9244. struct4209.PageNum = "1"
  9245. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9246. saveLog(result, requestLog, "4209", "查询")
  9247. var res2 ResultSix
  9248. var respJSON2 map[string]interface{}
  9249. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9252. return
  9253. }
  9254. userJSONBytes2, _ := json.Marshal(respJSON2)
  9255. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9256. utils.ErrorLog("解析失败:%v", err)
  9257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9258. return
  9259. }
  9260. if res2.Infcode != 0 {
  9261. c.ServeSuccessJSON(map[string]interface{}{
  9262. "failed_code": -10,
  9263. "msg": res2.ErrMsg,
  9264. })
  9265. return
  9266. } else {
  9267. c.ServeSuccessJSON(map[string]interface{}{
  9268. "msg": "查询成功",
  9269. })
  9270. }
  9271. }
  9272. type Result3101 struct {
  9273. Infcode string `json:"infcode"`
  9274. InfRefmsgid string `json:"inf_refmsgid"`
  9275. RefmsgTime string `json:"refmsg_time"`
  9276. RespondTime string `json:"respond_time"`
  9277. Enctype string `json:"enctype"`
  9278. Signtype string `json:"signtype"`
  9279. ErrMsg string `json:"err_msg"`
  9280. Output struct {
  9281. Result []struct {
  9282. JudgeResultDetailDtos []struct {
  9283. VolaItemType string `json:"vola_item_type"`
  9284. MdtrtID string `json:"mdtrt_id"`
  9285. JrdID string `json:"jrd_id"`
  9286. PatnID string `json:"patn_id"`
  9287. RxID string `json:"rx_id"`
  9288. VolaAmt interface{} `json:"vola_amt"`
  9289. } `json:"judge_result_detail_dtos"`
  9290. RuleID string `json:"rule_id"`
  9291. VolaEvid string `json:"vola_evid"`
  9292. MdtrtID string `json:"mdtrt_id"`
  9293. RuleName string `json:"rule_name"`
  9294. VolaAmtStas string `json:"vola_amt_stas"`
  9295. JrID string `json:"jr_id"`
  9296. PatnID string `json:"patn_id"`
  9297. SevDeg string `json:"sev_deg"`
  9298. VolaAmt float64 `json:"vola_amt"`
  9299. VolaBhvrType string `json:"vola_bhvr_type"`
  9300. VolaCont string `json:"vola_cont"`
  9301. } `json:"result"`
  9302. } `json:"output"`
  9303. }
  9304. type Resultgd3101 struct {
  9305. Infcode int64 `json:"infcode"`
  9306. InfRefmsgid string `json:"inf_refmsgid"`
  9307. RefmsgTime string `json:"refmsg_time"`
  9308. RespondTime string `json:"respond_time"`
  9309. Enctype string `json:"enctype"`
  9310. Signtype string `json:"signtype"`
  9311. ErrMsg string `json:"err_msg"`
  9312. Output struct {
  9313. Result []struct {
  9314. JudgeResultDetailDtos []struct {
  9315. VolaItemType string `json:"vola_item_type"`
  9316. MdtrtID string `json:"mdtrt_id"`
  9317. JrdID string `json:"jrd_id"`
  9318. PatnID string `json:"patn_id"`
  9319. RxID string `json:"rx_id"`
  9320. VolaAmt interface{} `json:"vola_amt"`
  9321. } `json:"judge_result_detail_dtos"`
  9322. RuleID string `json:"rule_id"`
  9323. VolaEvid string `json:"vola_evid"`
  9324. MdtrtID string `json:"mdtrt_id"`
  9325. RuleName string `json:"rule_name"`
  9326. VolaAmtStas string `json:"vola_amt_stas"`
  9327. JrID string `json:"jr_id"`
  9328. PatnID string `json:"patn_id"`
  9329. SevDeg string `json:"sev_deg"`
  9330. VolaAmt float64 `json:"vola_amt"`
  9331. VolaBhvrType string `json:"vola_bhvr_type"`
  9332. VolaCont string `json:"vola_cont"`
  9333. } `json:"result"`
  9334. } `json:"output"`
  9335. }
  9336. func (c *HisApiController) ReadEleToken() {
  9337. admin_user_id, _ := c.GetInt64("admin_user_id")
  9338. his_patient_id, _ := c.GetInt64("his_patient_id")
  9339. adminUser := c.GetAdminUserInfo()
  9340. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9341. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9342. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9343. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9344. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9345. if len(tokens) > 0 {
  9346. c.ServeSuccessJSON(map[string]interface{}{
  9347. "msg": "读取成功",
  9348. })
  9349. } else {
  9350. c.ServeSuccessJSON(map[string]interface{}{
  9351. "failed_code": -10,
  9352. "msg": "读取失败",
  9353. })
  9354. }
  9355. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9356. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9357. if len(tokens) > 0 {
  9358. c.ServeSuccessJSON(map[string]interface{}{
  9359. "msg": "读取成功",
  9360. })
  9361. } else {
  9362. c.ServeSuccessJSON(map[string]interface{}{
  9363. "failed_code": -10,
  9364. "msg": "读取失败",
  9365. })
  9366. }
  9367. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9368. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9369. if len(tokens) > 0 {
  9370. c.ServeSuccessJSON(map[string]interface{}{
  9371. "msg": "读取成功",
  9372. })
  9373. } else {
  9374. c.ServeSuccessJSON(map[string]interface{}{
  9375. "failed_code": -10,
  9376. "msg": "读取失败",
  9377. })
  9378. }
  9379. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9380. var api string
  9381. 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 +
  9382. "&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"
  9383. resp, requestErr := http.Get(api)
  9384. if requestErr != nil {
  9385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9386. }
  9387. body, ioErr := ioutil.ReadAll(resp.Body)
  9388. if ioErr != nil {
  9389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9391. }
  9392. var respJSON map[string]interface{}
  9393. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9396. return
  9397. }
  9398. var status string
  9399. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9400. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9401. var token string
  9402. var res ResultTwo //1101结果
  9403. var res10265 ResultTwo10265 //1101结果
  9404. if status == "0" { //读卡成功
  9405. var card_info string //卡信息
  9406. var busi_card_info string
  9407. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9408. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9409. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9410. fmt.Println(card_info)
  9411. fmt.Println(busi_card_info)
  9412. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9413. result, _ := json.Marshal(respJSON)
  9414. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9415. utils.ErrorLog("解析失败:%v", err)
  9416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9417. return
  9418. }
  9419. res.ErrMsg = res10265.ErrMsg
  9420. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9421. res.Infcode = infocode
  9422. res.Output = res10265.Output
  9423. res.InfRefmsgid = res10265.InfRefmsgid
  9424. if res.Infcode == 0 {
  9425. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9426. if err == gorm.ErrRecordNotFound {
  9427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9428. return
  9429. } else if err != nil {
  9430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9431. return
  9432. } else {
  9433. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9434. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9435. infoStr := string(Iinfos)
  9436. idetinfoStr := string(Idetinfos)
  9437. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9438. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9439. psn := &models.HisPsn{
  9440. PsnNo: res.Output.Baseinfo.PsnNo,
  9441. PatientId: patient.ID,
  9442. Certno: res.Output.Baseinfo.Certno,
  9443. Gend: res.Output.Baseinfo.Gend,
  9444. Naty: res.Output.Baseinfo.Naty,
  9445. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9446. PsnName: res.Output.Baseinfo.PsnName,
  9447. Age: float64(age),
  9448. Brdy: b,
  9449. Idetinfo: idetinfoStr,
  9450. Insuinfo: infoStr,
  9451. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9452. CardInfo: card_info,
  9453. VerifyNumber: token,
  9454. IdCardType: 4,
  9455. }
  9456. var rf []*ResultFive
  9457. json.Unmarshal([]byte(infoStr), &rf)
  9458. var insutypes []*ResultFive
  9459. var insutype string
  9460. var is390 int = 0
  9461. var is310 int = 0
  9462. for _, item := range rf {
  9463. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9464. insutypes = append(insutypes, item)
  9465. }
  9466. }
  9467. if len(insutypes) == 1 {
  9468. insutype = insutypes[0].Insutype
  9469. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9470. } else {
  9471. for _, i := range insutypes {
  9472. if i.Insutype == "390" {
  9473. is390 = 1
  9474. }
  9475. if i.Insutype == "310" {
  9476. is310 = 1
  9477. }
  9478. }
  9479. }
  9480. if is390 == 1 {
  9481. insutype = "390"
  9482. }
  9483. if is310 == 1 {
  9484. insutype = "310"
  9485. }
  9486. if len(insutypes) == 0 {
  9487. insutype = "310"
  9488. }
  9489. service.CreateHisPsn(psn)
  9490. c.ServeSuccessJSON(map[string]interface{}{
  9491. "patient": patient,
  9492. "number": token,
  9493. "insutype": insutype,
  9494. })
  9495. }
  9496. } else {
  9497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9498. return
  9499. }
  9500. } else { //读卡失败
  9501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9502. return
  9503. }
  9504. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9505. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9506. if len(errMsg) == 0 {
  9507. type ELeData struct {
  9508. Data struct {
  9509. IdNo string `json:"idNo"`
  9510. IdType string `json:"idType"`
  9511. UserName string `json:"userName"`
  9512. EcToken string `json:"ecToken"`
  9513. InsuOrg string `json:"insuOrg"`
  9514. Gender string `json:"gender"`
  9515. Birthday string `json:"birthday"`
  9516. Nationality string `json:"nationality"`
  9517. Email string `json:"email"`
  9518. Extra string `json:"extra"`
  9519. } `json:"data"`
  9520. Code int `json:"code"`
  9521. Message string `json:"message"`
  9522. }
  9523. var ele ELeData
  9524. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9525. if err != nil {
  9526. utils.ErrorLog("解析失败:%v", err)
  9527. }
  9528. token := ele.Data.EcToken
  9529. if len(token) > 0 {
  9530. psn := &models.HisPsn{
  9531. PsnNo: his.PsnNo,
  9532. Age: 0,
  9533. PatientId: his.PatientId,
  9534. Certno: his.Certno,
  9535. Brdy: his.Brdy,
  9536. Gend: his.Gend,
  9537. Naty: his.Naty,
  9538. PsnCertType: his.PsnCertType,
  9539. PsnName: his.PsnName,
  9540. Idetinfo: his.Idetinfo,
  9541. Insuinfo: his.Iinfo,
  9542. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9543. CardInfo: outPutInfo,
  9544. VerifyNumber: token,
  9545. }
  9546. service.CreateHisPsn(psn)
  9547. }
  9548. if len(token) > 0 {
  9549. c.ServeSuccessJSON(map[string]interface{}{
  9550. "msg": "读取成功",
  9551. })
  9552. } else {
  9553. c.ServeSuccessJSON(map[string]interface{}{
  9554. "failed_code": -10,
  9555. "msg": "读取失败",
  9556. })
  9557. }
  9558. }
  9559. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9560. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9561. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9562. type ELeData struct {
  9563. Data struct {
  9564. IdNo string `json:"idNo"`
  9565. IdType string `json:"idType"`
  9566. UserName string `json:"userName"`
  9567. EcToken string `json:"ecToken"`
  9568. InsuOrg string `json:"insuOrg"`
  9569. Gender string `json:"gender"`
  9570. Birthday string `json:"birthday"`
  9571. Nationality string `json:"nationality"`
  9572. Email string `json:"email"`
  9573. Extra string `json:"extra"`
  9574. } `json:"data"`
  9575. Code int `json:"code"`
  9576. Message string `json:"message"`
  9577. }
  9578. var ele ELeData
  9579. err := json.Unmarshal([]byte(result), &ele)
  9580. if err != nil {
  9581. utils.ErrorLog("解析失败:%v", err)
  9582. }
  9583. token := ele.Data.EcToken
  9584. token = Remove0000(token)
  9585. fmt.Println(ele.Data.UserName)
  9586. 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)
  9587. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9588. var res ResultTwo
  9589. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9590. utils.ErrorLog("解析失败:%v", err)
  9591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9592. return
  9593. }
  9594. if res.Infcode == 0 {
  9595. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9596. if err == gorm.ErrRecordNotFound {
  9597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9598. return
  9599. } else if err != nil {
  9600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9601. return
  9602. } else {
  9603. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9604. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9605. infoStr := string(Iinfos)
  9606. idetinfoStr := string(Idetinfos)
  9607. psn := &models.HisPsn{
  9608. PsnNo: res.Output.Baseinfo.PsnNo,
  9609. PatientId: patient.ID,
  9610. Certno: res.Output.Baseinfo.Certno,
  9611. Gend: res.Output.Baseinfo.Gend,
  9612. Naty: res.Output.Baseinfo.Naty,
  9613. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9614. PsnName: res.Output.Baseinfo.PsnName,
  9615. Idetinfo: idetinfoStr,
  9616. Insuinfo: infoStr,
  9617. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9618. CardInfo: "",
  9619. VerifyNumber: token,
  9620. }
  9621. service.CreateHisPsn(psn)
  9622. c.ServeSuccessJSON(map[string]interface{}{
  9623. "patient": patient,
  9624. "number": token,
  9625. })
  9626. }
  9627. } else {
  9628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9629. return
  9630. }
  9631. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9632. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9633. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9634. type ELeData struct {
  9635. Data struct {
  9636. IdNo string `json:"idNo"`
  9637. IdType string `json:"idType"`
  9638. UserName string `json:"userName"`
  9639. EcToken string `json:"ecToken"`
  9640. InsuOrg string `json:"insuOrg"`
  9641. Gender string `json:"gender"`
  9642. Birthday string `json:"birthday"`
  9643. Nationality string `json:"nationality"`
  9644. Email string `json:"email"`
  9645. Extra string `json:"extra"`
  9646. } `json:"data"`
  9647. Code int `json:"code"`
  9648. Message string `json:"message"`
  9649. }
  9650. var ele ELeData
  9651. err := json.Unmarshal([]byte(result), &ele)
  9652. if err != nil {
  9653. utils.ErrorLog("解析失败:%v", err)
  9654. }
  9655. token := ele.Data.EcToken
  9656. token = Remove0000(token)
  9657. fmt.Println(ele.Data.UserName)
  9658. 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)
  9659. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9660. var res ResultTwo
  9661. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9662. utils.ErrorLog("解析失败:%v", err)
  9663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9664. return
  9665. }
  9666. if res.Infcode == 0 {
  9667. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9668. if err == gorm.ErrRecordNotFound {
  9669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9670. return
  9671. } else if err != nil {
  9672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9673. return
  9674. } else {
  9675. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9676. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9677. infoStr := string(Iinfos)
  9678. idetinfoStr := string(Idetinfos)
  9679. psn := &models.HisPsn{
  9680. PsnNo: res.Output.Baseinfo.PsnNo,
  9681. PatientId: patient.ID,
  9682. Certno: res.Output.Baseinfo.Certno,
  9683. Gend: res.Output.Baseinfo.Gend,
  9684. Naty: res.Output.Baseinfo.Naty,
  9685. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9686. PsnName: res.Output.Baseinfo.PsnName,
  9687. Idetinfo: idetinfoStr,
  9688. Insuinfo: infoStr,
  9689. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9690. CardInfo: "",
  9691. VerifyNumber: token,
  9692. }
  9693. service.CreateHisPsn(psn)
  9694. c.ServeSuccessJSON(map[string]interface{}{
  9695. "patient": patient,
  9696. "number": token,
  9697. })
  9698. }
  9699. } else {
  9700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9701. return
  9702. }
  9703. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9704. //if initFlag == 0 {
  9705. //c.TestGetJiangXiBasBaseInit()
  9706. //}
  9707. //if initEleFlag == 0 {
  9708. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9709. //}
  9710. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9711. utils.ErrorLog("解析失败:%v", json_result)
  9712. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9713. type ELeData struct {
  9714. Data struct {
  9715. IdNo string `json:"idNo"`
  9716. IdType string `json:"idType"`
  9717. UserName string `json:"userName"`
  9718. EcToken string `json:"ecToken"`
  9719. InsuOrg string `json:"insuOrg"`
  9720. Gender string `json:"gender"`
  9721. Birthday string `json:"birthday"`
  9722. Nationality string `json:"nationality"`
  9723. Email string `json:"email"`
  9724. Extra string `json:"extra"`
  9725. } `json:"data"`
  9726. Code int `json:"code"`
  9727. Message string `json:"message"`
  9728. }
  9729. var ele ELeData
  9730. err := json.Unmarshal([]byte(json_result), &ele)
  9731. if err != nil {
  9732. utils.ErrorLog("解析失败:%v", err)
  9733. }
  9734. token := ele.Data.EcToken
  9735. token = Remove0000(token)
  9736. //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)
  9737. 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)
  9738. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9739. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9740. var res ResultTwo
  9741. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9742. utils.ErrorLog("解析失败:%v", err)
  9743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9744. return
  9745. }
  9746. if res.Infcode == 0 {
  9747. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9748. if err == gorm.ErrRecordNotFound {
  9749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9750. return
  9751. } else if err != nil {
  9752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9753. return
  9754. } else {
  9755. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9756. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9757. infoStr := string(Iinfos)
  9758. idetinfoStr := string(Idetinfos)
  9759. psn := &models.HisPsn{
  9760. PsnNo: res.Output.Baseinfo.PsnNo,
  9761. PatientId: patient.ID,
  9762. Certno: res.Output.Baseinfo.Certno,
  9763. Gend: res.Output.Baseinfo.Gend,
  9764. Naty: res.Output.Baseinfo.Naty,
  9765. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9766. PsnName: res.Output.Baseinfo.PsnName,
  9767. Idetinfo: idetinfoStr,
  9768. Insuinfo: infoStr,
  9769. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9770. CardInfo: "",
  9771. VerifyNumber: token,
  9772. InsuplcAdmdvs: ele.Data.InsuOrg,
  9773. }
  9774. service.CreateHisPsn(psn)
  9775. c.ServeSuccessJSON(map[string]interface{}{
  9776. "patient": patient,
  9777. "number": token,
  9778. })
  9779. }
  9780. } else {
  9781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9782. return
  9783. }
  9784. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9785. res := c.GetoleInfo()
  9786. if res.Infcode == 0 {
  9787. var result string
  9788. if res.Output.MdtrtCertType == "01" {
  9789. 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)
  9790. } else if res.Output.MdtrtCertType == "02" {
  9791. 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)
  9792. } else if res.Output.MdtrtCertType == "03" {
  9793. 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)
  9794. }
  9795. var dat map[string]interface{}
  9796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9797. fmt.Println(dat)
  9798. } else {
  9799. fmt.Println(err)
  9800. }
  9801. userJSONBytes, _ := json.Marshal(dat)
  9802. var res2 ResultTwo
  9803. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9804. utils.ErrorLog("解析失败:%v", err)
  9805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9806. return
  9807. }
  9808. if res2.Infcode == 0 {
  9809. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9810. if err == gorm.ErrRecordNotFound {
  9811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9812. return
  9813. } else if err != nil {
  9814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9815. return
  9816. } else {
  9817. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9818. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9819. infoStr := string(Iinfos)
  9820. idetinfoStr := string(Idetinfos)
  9821. var rf []*ResultFive
  9822. json.Unmarshal([]byte(infoStr), &rf)
  9823. var insutypes []*ResultFive
  9824. var insutype string
  9825. var is390 int = 0
  9826. var is310 int = 0
  9827. //var insuplc_admdvs string
  9828. for _, item := range rf {
  9829. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9830. insutypes = append(insutypes, item)
  9831. }
  9832. }
  9833. if len(insutypes) == 1 {
  9834. insutype = insutypes[0].Insutype
  9835. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9836. } else {
  9837. for _, i := range insutypes {
  9838. if i.Insutype == "390" {
  9839. is390 = 1
  9840. }
  9841. if i.Insutype == "310" {
  9842. is310 = 1
  9843. }
  9844. }
  9845. }
  9846. if is390 == 1 {
  9847. insutype = "390"
  9848. }
  9849. if is310 == 1 {
  9850. insutype = "310"
  9851. }
  9852. if len(insutypes) == 0 {
  9853. insutype = "310"
  9854. }
  9855. psn := &models.HisPsn{
  9856. PsnNo: res2.Output.Baseinfo.PsnNo,
  9857. PatientId: patient.ID,
  9858. Certno: res2.Output.Baseinfo.Certno,
  9859. Gend: res2.Output.Baseinfo.Gend,
  9860. Naty: res2.Output.Baseinfo.Naty,
  9861. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9862. PsnName: res2.Output.Baseinfo.PsnName,
  9863. Idetinfo: idetinfoStr,
  9864. Insuinfo: infoStr,
  9865. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9866. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9867. VerifyNumber: res.Output.EcToken,
  9868. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9869. }
  9870. service.CreateHisPsn(psn)
  9871. c.ServeSuccessJSON(map[string]interface{}{
  9872. "patient": patient,
  9873. "number": res.Output.CardNo,
  9874. "insutype": insutype,
  9875. })
  9876. }
  9877. } else {
  9878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9879. return
  9880. }
  9881. } else {
  9882. c.ServeSuccessJSON(map[string]interface{}{
  9883. "failed_code": -10,
  9884. "msg": res.ErrMsg,
  9885. })
  9886. }
  9887. } else {
  9888. //if initFlag == 0 {
  9889. // c.TestGetBasBaseInit()
  9890. //}
  9891. //token := c.GetEleBaseInfo()
  9892. //token = Remove0000(token)
  9893. type ELeData struct {
  9894. Code string `json:"code"`
  9895. Data struct {
  9896. Aac002 string `json:"aac002"`
  9897. Aaz500 string `json:"aaz500"`
  9898. ActCardNo string `json:"actCardNo"`
  9899. Bab520 string `json:"bab520"`
  9900. Bkz543 string `json:"bkz543"`
  9901. BusinessType string `json:"businessType"`
  9902. CertfCodg string `json:"certfCodg"`
  9903. EcIndexNo string `json:"ecIndexNo"`
  9904. EcToken string `json:"ecToken"`
  9905. ID0000 string `json:"id0000"`
  9906. IDNo string `json:"idNo"`
  9907. IDType string `json:"idType"`
  9908. Idcode string `json:"idcode"`
  9909. IdentityToken string `json:"identity_token"`
  9910. InsuOrg string `json:"insuOrg"`
  9911. OfficeID string `json:"officeId"`
  9912. OfficeName string `json:"officeName"`
  9913. OperatorID string `json:"operatorId"`
  9914. OperatorName string `json:"operatorName"`
  9915. OrgID string `json:"orgId"`
  9916. UserName string `json:"userName"`
  9917. } `json:"data"`
  9918. Infno interface{} `json:"infno"`
  9919. Message string `json:"message"`
  9920. OrgID string `json:"orgId"`
  9921. TransType string `json:"transType"`
  9922. }
  9923. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9924. fmt.Println(result)
  9925. outPutInfo := Remove0000(result)
  9926. fmt.Println(outPutInfo)
  9927. var ele ELeData
  9928. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9929. if err != nil {
  9930. utils.ErrorLog("解析失败:%v", err)
  9931. }
  9932. token := ele.Data.EcToken
  9933. var result2 string
  9934. var requestLog2 string
  9935. if len(token) > 0 {
  9936. if strings.Contains(ele.Data.IDNo, "HKG") {
  9937. 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)
  9938. } else {
  9939. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9940. }
  9941. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9942. var res ResultTwo
  9943. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9944. utils.ErrorLog("解析失败:%v", err)
  9945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9946. return
  9947. }
  9948. if res.Infcode == 0 {
  9949. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9950. if err == gorm.ErrRecordNotFound {
  9951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9952. return
  9953. } else if err != nil {
  9954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9955. return
  9956. } else {
  9957. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9958. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9959. infoStr := string(Iinfos)
  9960. idetinfoStr := string(Idetinfos)
  9961. psn := &models.HisPsn{
  9962. PsnNo: res.Output.Baseinfo.PsnNo,
  9963. PatientId: patient.ID,
  9964. Certno: res.Output.Baseinfo.Certno,
  9965. Gend: res.Output.Baseinfo.Gend,
  9966. Naty: res.Output.Baseinfo.Naty,
  9967. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9968. PsnName: res.Output.Baseinfo.PsnName,
  9969. Idetinfo: idetinfoStr,
  9970. Insuinfo: infoStr,
  9971. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9972. CardInfo: "",
  9973. VerifyNumber: token,
  9974. }
  9975. service.CreateHisPsn(psn)
  9976. c.ServeSuccessJSON(map[string]interface{}{
  9977. "msg": "读取成功",
  9978. })
  9979. }
  9980. } else {
  9981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9982. return
  9983. }
  9984. } else {
  9985. c.ServeSuccessJSON(map[string]interface{}{
  9986. "failed_code": -10,
  9987. "msg": "读取失败",
  9988. })
  9989. }
  9990. }
  9991. }
  9992. func (c *HisApiController) ReadEleFace() {
  9993. admin_user_id, _ := c.GetInt64("admin_user_id")
  9994. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9995. adminUser := c.GetAdminUserInfo()
  9996. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9997. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9998. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9999. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10000. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10001. if len(tokens) > 0 {
  10002. c.ServeSuccessJSON(map[string]interface{}{
  10003. "msg": "读取成功",
  10004. })
  10005. } else {
  10006. c.ServeSuccessJSON(map[string]interface{}{
  10007. "failed_code": -10,
  10008. "msg": "读取失败",
  10009. })
  10010. }
  10011. }
  10012. }
  10013. func (c *HisApiController) Get9001() {
  10014. adminUser := c.GetAdminUserInfo()
  10015. admin_user_id, _ := c.GetInt64("admin_user_id")
  10016. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10017. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10018. if miConfig.MdtrtareaAdmvs == "350500" {
  10019. service.GetFjAuthorizationInfo(miConfig.Code)
  10020. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10021. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10022. var dat map[string]interface{}
  10023. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10024. fmt.Println(dat)
  10025. } else {
  10026. fmt.Println(err)
  10027. }
  10028. userJSONBytes, _ := json.Marshal(dat)
  10029. var res models.Result9001
  10030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10031. utils.ErrorLog("解析失败:%v", err)
  10032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10033. return
  10034. }
  10035. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10036. fmt.Println(miConfig.SecretKey)
  10037. var res models.Result9001Two
  10038. 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 +
  10039. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10040. resp, requestErr := http.Get(api)
  10041. if requestErr != nil {
  10042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10043. return
  10044. }
  10045. body, ioErr := ioutil.ReadAll(resp.Body)
  10046. if ioErr != nil {
  10047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10049. return
  10050. }
  10051. var respJSON map[string]interface{}
  10052. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10055. return
  10056. }
  10057. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10058. if status == "0" {
  10059. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10060. c.ServeSuccessJSON(map[string]interface{}{
  10061. "failed_code": -10,
  10062. "msg": err_msg,
  10063. })
  10064. return
  10065. }
  10066. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10067. result, _ := json.Marshal(respJSON)
  10068. fmt.Println("log")
  10069. fmt.Println(string(result))
  10070. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10071. utils.ErrorLog("解析失败:%v", err)
  10072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10073. return
  10074. }
  10075. if res.Infcode == 0 {
  10076. sign := models.HisSignIn{
  10077. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10078. SignNo: res.Output.Signinoutb.SignNo,
  10079. SignTime: "",
  10080. Ctime: time.Now().Unix(),
  10081. Mtime: time.Now().Unix(),
  10082. Status: 1,
  10083. InputLog: "",
  10084. OutputLog: "",
  10085. FixmedinsCode: miConfig.Code,
  10086. }
  10087. err := service.CreateSignIn(&sign)
  10088. if err == nil {
  10089. c.ServeSuccessJSON(map[string]interface{}{
  10090. "msg": "签到成功",
  10091. })
  10092. }
  10093. } else {
  10094. c.ServeSuccessJSON(map[string]interface{}{
  10095. "failed_code": -10,
  10096. "msg": res.ErrMsg,
  10097. })
  10098. return
  10099. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10100. //return
  10101. }
  10102. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10103. fmt.Println(miConfig.SecretKey)
  10104. var res models.Result9001Two
  10105. 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 +
  10106. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10107. resp, requestErr := http.Get(api)
  10108. if requestErr != nil {
  10109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10110. return
  10111. }
  10112. body, ioErr := ioutil.ReadAll(resp.Body)
  10113. if ioErr != nil {
  10114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10116. return
  10117. }
  10118. var respJSON map[string]interface{}
  10119. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10122. return
  10123. }
  10124. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10125. if status == "0" {
  10126. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10127. c.ServeSuccessJSON(map[string]interface{}{
  10128. "failed_code": -10,
  10129. "msg": err_msg,
  10130. })
  10131. return
  10132. }
  10133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10134. result, _ := json.Marshal(respJSON)
  10135. fmt.Println("log")
  10136. fmt.Println(string(result))
  10137. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10138. utils.ErrorLog("解析失败:%v", err)
  10139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10140. return
  10141. }
  10142. if res.Infcode == 0 {
  10143. sign := models.HisSignIn{
  10144. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10145. SignNo: res.Output.Signinoutb.SignNo,
  10146. SignTime: "",
  10147. Ctime: time.Now().Unix(),
  10148. Mtime: time.Now().Unix(),
  10149. Status: 1,
  10150. InputLog: "",
  10151. OutputLog: "",
  10152. FixmedinsCode: miConfig.Code,
  10153. }
  10154. err := service.CreateSignIn(&sign)
  10155. if err == nil {
  10156. c.ServeSuccessJSON(map[string]interface{}{
  10157. "msg": "签到成功",
  10158. })
  10159. }
  10160. } else {
  10161. c.ServeSuccessJSON(map[string]interface{}{
  10162. "failed_code": -10,
  10163. "msg": res.ErrMsg,
  10164. })
  10165. return
  10166. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10167. //return
  10168. }
  10169. } else {
  10170. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10171. var dat map[string]interface{}
  10172. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10173. fmt.Println(dat)
  10174. } else {
  10175. fmt.Println(err)
  10176. }
  10177. userJSONBytes, _ := json.Marshal(dat)
  10178. var res models.Result9001
  10179. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10180. utils.ErrorLog("解析失败:%v", err)
  10181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10182. return
  10183. }
  10184. if res.Infcode == 0 {
  10185. sign := models.HisSignIn{
  10186. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10187. SignNo: res.Output.Signinoutb.SignNo,
  10188. SignTime: res.Output.Signinoutb.SignTime,
  10189. Ctime: time.Now().Unix(),
  10190. Mtime: time.Now().Unix(),
  10191. Status: 1,
  10192. InputLog: "",
  10193. OutputLog: "",
  10194. FixmedinsCode: miConfig.Code,
  10195. }
  10196. err := service.CreateSignIn(&sign)
  10197. if err == nil {
  10198. c.ServeSuccessJSON(map[string]interface{}{
  10199. "msg": "签到成功",
  10200. })
  10201. }
  10202. }
  10203. }
  10204. }
  10205. 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) {
  10206. var res Result3101
  10207. adminUser := c.GetAdminUserInfo()
  10208. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10209. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10210. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10211. //record_time := c.GetString("record_time")
  10212. //trig_scen := c.GetString("trig_scen")
  10213. timeLayout := "2006-01-02"
  10214. loc, _ := time.LoadLocation("Local")
  10215. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10216. if err != nil {
  10217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10218. return res
  10219. }
  10220. recordDateTime := theTime.Unix()
  10221. var patientPrescription models.HisPrescriptionInfo
  10222. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10223. //if patientPrescription.ID == 0 {
  10224. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10225. //}
  10226. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10227. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10228. //
  10229. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10230. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10231. var pp models.PublicParams
  10232. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10233. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10234. pp.FixmedinsName = miConfig.OrgName
  10235. pp.FixmedinsCode = miConfig.Code
  10236. pp.RequestUrl = miConfig.Url
  10237. pp.Cainfo = miConfig.Cainfo
  10238. pp.SecretKey = miConfig.SecretKey
  10239. pp.AccessKey = miConfig.AccessKey
  10240. pp.OpterName = roles.UserName
  10241. var config []*models.HisXtDiagnoseConfig
  10242. for _, item := range diagnosis_ids {
  10243. id, _ := strconv.ParseInt(item, 10, 64)
  10244. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10245. config = append(config, &diagnosisConfig)
  10246. }
  10247. var pd models.PatientDtos
  10248. pd.PatnID = his.PsnNo
  10249. pd.PatnName = his.Name
  10250. pd.Gend = his.Gend
  10251. pd.Brdy = his.Brdy
  10252. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10253. pd.CurrMdtrtID = his.Number
  10254. var fed models.FsiEncounterDtos
  10255. fed.MdtrtID = his.Number
  10256. fed.MedinsID = miConfig.Code
  10257. fed.MedinsName = miConfig.OrgName
  10258. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10259. fed.MedMdtrtType = "1"
  10260. fed.MedinsType = "1"
  10261. fed.MedinsLv = "11"
  10262. tm := time.Unix(his.RecordDate, 0)
  10263. s_tm := tm.Format("2006-01-02 15:04:05")
  10264. fed.AdmDate = s_tm
  10265. fed.DscgDate = s_tm
  10266. fed.DscgMainDiseCodg = config[0].CountryCode
  10267. fed.DscgMainDiseName = config[0].CountryContentName
  10268. //诊断信息
  10269. var fdds []*models.FsiDiagnoseDtos
  10270. for index, item := range config {
  10271. if index == 0 {
  10272. var fdd models.FsiDiagnoseDtos
  10273. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10274. fdd.InoutDiseType = "1"
  10275. fdd.MaindiseFlag = "1"
  10276. fdd.DiseDate = s_tm
  10277. fdd.DiasSrtNo = "1"
  10278. fdd.DiseName = item.CountryContentName
  10279. fdd.DiseCodg = item.CountryCode
  10280. fdds = append(fdds, &fdd)
  10281. } else {
  10282. var fdd models.FsiDiagnoseDtos
  10283. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10284. fdd.InoutDiseType = "1"
  10285. fdd.MaindiseFlag = "1"
  10286. fdd.DiseDate = s_tm
  10287. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10288. fdd.DiseName = item.CountryContentName
  10289. fdd.DiseCodg = item.CountryCode
  10290. fdds = append(fdds, &fdd)
  10291. }
  10292. }
  10293. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10294. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10295. fed.AdmDeptName = de.Name
  10296. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10297. fed.DscgDeptName = de.Name
  10298. fed.MedMdtrtType = "1"
  10299. fed.MedType = "11"
  10300. //if his.Insutype == "390" {
  10301. // fed.MedType = "1402"
  10302. //} else {
  10303. // fed.MedType = "9933"
  10304. //}
  10305. var orders []*models.FsiOrderDtos
  10306. if trig_scen == "2" {
  10307. //处方医嘱信息
  10308. for _, item := range prescriptions {
  10309. for _, subItem := range item.HisDoctorAdviceInfo {
  10310. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10311. var order models.FsiOrderDtos
  10312. order.RxID = strconv.FormatInt(item.ID, 10)
  10313. order.Rxno = strconv.FormatInt(item.ID, 10)
  10314. order.LongDrordFlag = "0"
  10315. order.HilistType = "1"
  10316. order.ChrgType = "1"
  10317. order.DrordBhvr = "-"
  10318. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10319. order.HosplistName = subItem.BaseDrugLib.DrugName
  10320. order.HilistLv = "1"
  10321. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10322. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10323. order.HosplistName = subItem.BaseDrugLib.DrugName
  10324. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10325. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10326. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10327. order.OwnpayAmt = ""
  10328. order.SelfpayAmt = ""
  10329. order.Spec = ""
  10330. order.SpecUnt = ""
  10331. order.DrordBegnDate = s_tm
  10332. order.DrordStopDate = ""
  10333. order.DrordDrCodg = doctor_info.DoctorNumber
  10334. order.DrordDeptName = department.Name
  10335. order.DrordDeptCodg = department.Number
  10336. order.DrordDrName = doctor_info.UserName
  10337. order.DrordDrProfttl = "234"
  10338. order.CurrDrordFlag = "1"
  10339. orders = append(orders, &order)
  10340. }
  10341. }
  10342. for _, subItem := range item.HisPrescriptionProject {
  10343. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10344. var order models.FsiOrderDtos
  10345. order.RxID = strconv.FormatInt(item.ID, 10)
  10346. order.Rxno = strconv.FormatInt(item.ID, 10)
  10347. order.LongDrordFlag = "0"
  10348. order.HilistType = "1"
  10349. order.ChrgType = "1"
  10350. order.DrordBhvr = "-"
  10351. order.HilistCode = subItem.HisProject.MedicalCode
  10352. order.HosplistName = subItem.HisProject.ProjectName
  10353. order.HilistLv = "1"
  10354. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10355. order.HosplistCode = subItem.HisProject.MedicalCode
  10356. order.HosplistName = subItem.HisProject.ProjectName
  10357. order.Cnt = subItem.Count
  10358. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10359. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10360. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10361. order.OwnpayAmt = ""
  10362. order.SelfpayAmt = ""
  10363. order.Spec = ""
  10364. order.SpecUnt = ""
  10365. order.DrordBegnDate = s_tm
  10366. order.DrordStopDate = ""
  10367. order.DrordDrCodg = doctor_info.DoctorNumber
  10368. order.DrordDeptName = department.Name
  10369. order.DrordDeptCodg = department.Number
  10370. order.DrordDrName = doctor_info.UserName
  10371. order.DrordDrProfttl = "234"
  10372. order.CurrDrordFlag = "1"
  10373. orders = append(orders, &order)
  10374. }
  10375. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10376. var order models.FsiOrderDtos
  10377. order.RxID = strconv.FormatInt(item.ID, 10)
  10378. order.Rxno = strconv.FormatInt(item.ID, 10)
  10379. order.LongDrordFlag = "0"
  10380. order.HilistType = "1"
  10381. order.ChrgType = "1"
  10382. order.DrordBhvr = "-"
  10383. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10384. order.HosplistName = subItem.GoodInfo.GoodName
  10385. order.HilistLv = "1"
  10386. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10387. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10388. order.HosplistName = subItem.GoodInfo.GoodName
  10389. order.Cnt = subItem.Count
  10390. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10391. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10392. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10393. order.OwnpayAmt = ""
  10394. order.SelfpayAmt = ""
  10395. order.Spec = ""
  10396. order.SpecUnt = ""
  10397. order.DrordBegnDate = s_tm
  10398. order.DrordStopDate = ""
  10399. order.DrordDrCodg = doctor_info.DoctorNumber
  10400. order.DrordDeptName = department.Name
  10401. order.DrordDeptCodg = department.Number
  10402. order.DrordDrName = doctor_info.UserName
  10403. order.DrordDrProfttl = "234"
  10404. order.CurrDrordFlag = "1"
  10405. orders = append(orders, &order)
  10406. }
  10407. }
  10408. }
  10409. //处方医嘱信息
  10410. }
  10411. fed.MatnStas = "0"
  10412. fed.MedfeeSumamt = "0"
  10413. fed.OwnpayAmt = "0"
  10414. fed.SelfpayAmt = "0"
  10415. fed.AcctPayamt = "0"
  10416. fed.MaAmt = "0"
  10417. fed.HifpPayamt = "0"
  10418. fed.SetlTotlnum = "1"
  10419. fed.Insutype = his.Insutype
  10420. fed.ReimFlag = "0"
  10421. fed.OutSetlFlag = "0"
  10422. var fopd []*models.FsiOperationDtosData
  10423. data := make(map[string]interface{})
  10424. data["fed"] = fed
  10425. data["fdd"] = fdds
  10426. data["fod"] = orders
  10427. data["pd"] = pd
  10428. data["pp"] = pp
  10429. data["fopd"] = fopd
  10430. data["trig_scen"] = trig_scen
  10431. fmt.Println(data)
  10432. fmt.Println(fed)
  10433. fmt.Println(fdds)
  10434. fmt.Println(orders)
  10435. fmt.Println(pd)
  10436. fmt.Println(pp)
  10437. fmt.Println(fopd)
  10438. client := &http.Client{}
  10439. bytesData, _ := json.Marshal(data)
  10440. var req *http.Request
  10441. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10442. if miConfig.MdtrtareaAdmvs == "320921" {
  10443. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10444. } else {
  10445. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10446. }
  10447. resp, _ := client.Do(req)
  10448. defer resp.Body.Close()
  10449. body, ioErr := ioutil.ReadAll(resp.Body)
  10450. if ioErr != nil {
  10451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10453. return res
  10454. }
  10455. var respJSON map[string]interface{}
  10456. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10459. return res
  10460. }
  10461. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10462. fmt.Println(respJSON)
  10463. result, _ := json.Marshal(respJSON)
  10464. fmt.Println(result)
  10465. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10466. utils.ErrorLog("解析失败:%v", err)
  10467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10468. return res
  10469. }
  10470. return res
  10471. } else {
  10472. //if miConfig.MdtrtareaAdmvs == "441202" {
  10473. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10474. saveLog(output, input, "3101", "事前")
  10475. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10476. utils.ErrorLog("解析失败:%v", err)
  10477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10478. return
  10479. }
  10480. return res
  10481. //}
  10482. }
  10483. }
  10484. 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) {
  10485. adminUser := c.GetAdminUserInfo()
  10486. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10487. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10488. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10489. //record_time := c.GetString("record_time")
  10490. //trig_scen := c.GetString("trig_scen")
  10491. timeLayout := "2006-01-02"
  10492. loc, _ := time.LoadLocation("Local")
  10493. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10494. if err != nil {
  10495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10496. return res
  10497. }
  10498. recordDateTime := theTime.Unix()
  10499. var patientPrescription models.HisPrescriptionInfo
  10500. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10501. if patientPrescription.ID == 0 {
  10502. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10503. }
  10504. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10505. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10506. //
  10507. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10508. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10509. var pp models.PublicParams
  10510. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10511. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10512. pp.FixmedinsName = miConfig.OrgName
  10513. pp.FixmedinsCode = miConfig.Code
  10514. pp.RequestUrl = miConfig.Url
  10515. pp.Cainfo = miConfig.Cainfo
  10516. pp.SecretKey = miConfig.SecretKey
  10517. pp.AccessKey = miConfig.AccessKey
  10518. pp.OpterName = roles.UserName
  10519. var config []*models.HisXtDiagnoseConfig
  10520. for _, item := range diagnosis_ids {
  10521. id, _ := strconv.ParseInt(item, 10, 64)
  10522. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10523. config = append(config, &diagnosisConfig)
  10524. }
  10525. var pd models.PatientDtos
  10526. pd.PatnID = his.PsnNo
  10527. pd.PatnName = his.Name
  10528. pd.Gend = his.Gend
  10529. pd.Brdy = his.Brdy
  10530. pd.Poolarea = his.InsuplcAdmdvs
  10531. pd.CurrMdtrtID = his.Number
  10532. var fed models.FsiEncounterDtos
  10533. fed.MdtrtID = his.Number
  10534. fed.MedinsID = miConfig.Code
  10535. fed.MedinsName = miConfig.OrgName
  10536. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10537. fed.MedMdtrtType = "1"
  10538. fed.MedinsType = "1"
  10539. fed.MedinsLv = "11"
  10540. tm := time.Unix(his.RecordDate, 0)
  10541. s_tm := tm.Format("2006-01-02 15:04:05")
  10542. fed.AdmDate = s_tm
  10543. fed.DscgDate = s_tm
  10544. fed.DscgMainDiseCodg = config[0].CountryCode
  10545. fed.DscgMainDiseName = config[0].CountryContentName
  10546. //诊断信息
  10547. var fdds []*models.FsiDiagnoseDtos
  10548. for index, item := range config {
  10549. if index == 0 {
  10550. var fdd models.FsiDiagnoseDtos
  10551. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10552. fdd.InoutDiseType = "1"
  10553. fdd.MaindiseFlag = "1"
  10554. fdd.DiseDate = s_tm
  10555. fdd.DiasSrtNo = "1"
  10556. fdd.DiseName = item.CountryContentName
  10557. fdd.DiseCodg = item.CountryCode
  10558. fdds = append(fdds, &fdd)
  10559. } else {
  10560. var fdd models.FsiDiagnoseDtos
  10561. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10562. fdd.InoutDiseType = "1"
  10563. fdd.MaindiseFlag = "1"
  10564. fdd.DiseDate = s_tm
  10565. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10566. fdd.DiseName = item.CountryContentName
  10567. fdd.DiseCodg = item.CountryCode
  10568. fdds = append(fdds, &fdd)
  10569. }
  10570. }
  10571. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10572. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10573. fed.AdmDeptName = department.Name
  10574. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10575. fed.DscgDeptName = department.Name
  10576. fed.MedMdtrtType = "1"
  10577. fed.MedType = "11"
  10578. //if his.Insutype == "390" {
  10579. // fed.MedType = "1402"
  10580. //} else {
  10581. // fed.MedType = "9933"
  10582. //}
  10583. var orders []*models.FsiOrderDtos
  10584. if trig_scen == "2" {
  10585. //处方医嘱信息
  10586. for _, item := range prescriptions {
  10587. for _, subItem := range item.HisDoctorAdviceInfo {
  10588. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10589. var order models.FsiOrderDtos
  10590. order.RxID = strconv.FormatInt(item.ID, 10)
  10591. order.Rxno = strconv.FormatInt(item.ID, 10)
  10592. order.LongDrordFlag = "0"
  10593. order.HilistType = "1"
  10594. order.ChrgType = "1"
  10595. order.DrordBhvr = "-"
  10596. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10597. order.HosplistName = subItem.BaseDrugLib.DrugName
  10598. order.HilistLv = "1"
  10599. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10600. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10601. order.HosplistName = subItem.BaseDrugLib.DrugName
  10602. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10603. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10604. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10605. order.OwnpayAmt = ""
  10606. order.SelfpayAmt = ""
  10607. order.Spec = ""
  10608. order.SpecUnt = ""
  10609. order.DrordBegnDate = s_tm
  10610. order.DrordStopDate = ""
  10611. order.DrordDrCodg = doctor_info.DoctorNumber
  10612. order.DrordDeptName = department.Name
  10613. order.DrordDeptCodg = department.Number
  10614. order.DrordDrName = doctor_info.UserName
  10615. order.DrordDrProfttl = "234"
  10616. order.CurrDrordFlag = "1"
  10617. orders = append(orders, &order)
  10618. }
  10619. }
  10620. for _, subItem := range item.HisPrescriptionProject {
  10621. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10622. var order models.FsiOrderDtos
  10623. order.RxID = strconv.FormatInt(item.ID, 10)
  10624. order.Rxno = strconv.FormatInt(item.ID, 10)
  10625. order.LongDrordFlag = "0"
  10626. order.HilistType = "1"
  10627. order.ChrgType = "1"
  10628. order.DrordBhvr = "-"
  10629. order.HilistCode = subItem.HisProject.MedicalCode
  10630. order.HosplistName = subItem.HisProject.ProjectName
  10631. order.HilistLv = "1"
  10632. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10633. order.HosplistCode = subItem.HisProject.MedicalCode
  10634. order.HosplistName = subItem.HisProject.ProjectName
  10635. order.Cnt = subItem.Count
  10636. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10637. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10638. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10639. order.OwnpayAmt = ""
  10640. order.SelfpayAmt = ""
  10641. order.Spec = ""
  10642. order.SpecUnt = ""
  10643. order.DrordBegnDate = s_tm
  10644. order.DrordStopDate = ""
  10645. order.DrordDrCodg = doctor_info.DoctorNumber
  10646. order.DrordDeptName = department.Name
  10647. order.DrordDeptCodg = department.Number
  10648. order.DrordDrName = doctor_info.UserName
  10649. order.DrordDrProfttl = "234"
  10650. order.CurrDrordFlag = "1"
  10651. orders = append(orders, &order)
  10652. }
  10653. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10654. var order models.FsiOrderDtos
  10655. order.RxID = strconv.FormatInt(item.ID, 10)
  10656. order.Rxno = strconv.FormatInt(item.ID, 10)
  10657. order.LongDrordFlag = "0"
  10658. order.HilistType = "1"
  10659. order.ChrgType = "1"
  10660. order.DrordBhvr = "-"
  10661. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10662. order.HosplistName = subItem.GoodInfo.GoodName
  10663. order.HilistLv = "1"
  10664. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10665. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10666. order.HosplistName = subItem.GoodInfo.GoodName
  10667. order.Cnt = subItem.Count
  10668. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10669. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10670. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10671. order.OwnpayAmt = ""
  10672. order.SelfpayAmt = ""
  10673. order.Spec = ""
  10674. order.SpecUnt = ""
  10675. order.DrordBegnDate = s_tm
  10676. order.DrordStopDate = ""
  10677. order.DrordDrCodg = doctor_info.DoctorNumber
  10678. order.DrordDeptName = department.Name
  10679. order.DrordDeptCodg = department.Number
  10680. order.DrordDrName = doctor_info.UserName
  10681. order.DrordDrProfttl = "234"
  10682. order.CurrDrordFlag = "1"
  10683. orders = append(orders, &order)
  10684. }
  10685. }
  10686. }
  10687. //处方医嘱信息
  10688. }
  10689. fed.MatnStas = "0"
  10690. fed.MedfeeSumamt = "0"
  10691. fed.OwnpayAmt = "0"
  10692. fed.SelfpayAmt = "0"
  10693. fed.AcctPayamt = "0"
  10694. fed.MaAmt = "0"
  10695. fed.HifpPayamt = "0"
  10696. fed.SetlTotlnum = "1"
  10697. fed.Insutype = his.Insutype
  10698. fed.ReimFlag = "0"
  10699. fed.OutSetlFlag = "0"
  10700. var fopd []*models.FsiOperationDtosData
  10701. data := make(map[string]interface{})
  10702. data["fed"] = fed
  10703. data["fdd"] = fdds
  10704. data["fod"] = orders
  10705. data["pd"] = pd
  10706. data["pp"] = pp
  10707. data["fopd"] = fopd
  10708. data["trig_scen"] = trig_scen
  10709. fmt.Println(data)
  10710. fmt.Println(fed)
  10711. fmt.Println(fdds)
  10712. fmt.Println(orders)
  10713. fmt.Println(pd)
  10714. fmt.Println(pp)
  10715. fmt.Println(fopd)
  10716. client := &http.Client{}
  10717. bytesData, _ := json.Marshal(data)
  10718. var req *http.Request
  10719. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10720. if miConfig.MdtrtareaAdmvs == "320921" {
  10721. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10722. } else {
  10723. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10724. }
  10725. resp, _ := client.Do(req)
  10726. defer resp.Body.Close()
  10727. body, ioErr := ioutil.ReadAll(resp.Body)
  10728. if ioErr != nil {
  10729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10731. return res
  10732. }
  10733. var respJSON map[string]interface{}
  10734. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10737. return res
  10738. }
  10739. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10740. fmt.Println(respJSON)
  10741. result, _ := json.Marshal(respJSON)
  10742. fmt.Println(result)
  10743. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10744. utils.ErrorLog("解析失败:%v", err)
  10745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10746. return res
  10747. }
  10748. return res
  10749. } else {
  10750. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10751. saveLog(output, input, "3101", "事前")
  10752. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10753. utils.ErrorLog("解析失败:%v", err)
  10754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10755. return
  10756. }
  10757. return res
  10758. }
  10759. return res
  10760. }
  10761. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10762. ////patient_id, _ := c.GetInt64("patient_id")
  10763. //order_id, _ := c.GetInt64("order_id")
  10764. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10765. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10766. //trig_scen := c.GetString("trig_scen")
  10767. adminUser := c.GetAdminUserInfo()
  10768. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10769. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10770. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10771. record_time := c.GetString("record_time")
  10772. order, _ := service.GetHisOrderByID(order_id)
  10773. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10774. timeLayout := "2006-01-02"
  10775. loc, _ := time.LoadLocation("Local")
  10776. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10777. if err != nil {
  10778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10779. return
  10780. }
  10781. recordDateTime := theTime.Unix()
  10782. var patientPrescription models.HisPrescriptionInfo
  10783. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10784. if patientPrescription.ID == 0 {
  10785. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10786. }
  10787. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10788. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10789. //
  10790. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10791. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10792. var pp models.PublicParams
  10793. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10794. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10795. pp.FixmedinsName = miConfig.OrgName
  10796. pp.FixmedinsCode = miConfig.Code
  10797. pp.RequestUrl = miConfig.Url
  10798. pp.Cainfo = miConfig.Cainfo
  10799. pp.SecretKey = miConfig.SecretKey
  10800. pp.AccessKey = miConfig.AccessKey
  10801. pp.OpterName = roles.UserName
  10802. var config []*models.HisXtDiagnoseConfig
  10803. for _, item := range diagnosis_ids {
  10804. id, _ := strconv.ParseInt(item, 10, 64)
  10805. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10806. config = append(config, &diagnosisConfig)
  10807. }
  10808. var pd models.PatientDtos
  10809. pd.PatnID = his.PsnNo
  10810. pd.PatnName = his.Name
  10811. pd.Gend = his.Gend
  10812. pd.Brdy = psn_info.Brdy
  10813. pd.Poolarea = his.InsuplcAdmdvs
  10814. pd.CurrMdtrtID = his.Number
  10815. var fed models.FsiEncounterDtos
  10816. fed.MdtrtID = his.Number
  10817. fed.MedinsID = miConfig.Code
  10818. fed.MedinsName = miConfig.OrgName
  10819. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10820. fed.MedMdtrtType = "1"
  10821. fed.MedinsType = "1"
  10822. fed.MedinsLv = "11"
  10823. tm := time.Unix(his.RecordDate, 0)
  10824. s_tm := tm.Format("2006-01-02 15:04:05")
  10825. fed.AdmDate = s_tm
  10826. fed.DscgDate = s_tm
  10827. fed.DscgMainDiseCodg = config[0].CountryCode
  10828. fed.DscgMainDiseName = config[0].CountryContentName
  10829. //诊断信息
  10830. var fdds []*models.FsiDiagnoseDtos
  10831. for index, item := range config {
  10832. if index == 0 {
  10833. var fdd models.FsiDiagnoseDtos
  10834. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10835. fdd.InoutDiseType = "1"
  10836. fdd.MaindiseFlag = "1"
  10837. fdd.DiseDate = s_tm
  10838. fdd.DiasSrtNo = "1"
  10839. fdd.DiseName = item.CountryContentName
  10840. fdd.DiseCodg = item.CountryCode
  10841. fdds = append(fdds, &fdd)
  10842. } else {
  10843. var fdd models.FsiDiagnoseDtos
  10844. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10845. fdd.InoutDiseType = "1"
  10846. fdd.MaindiseFlag = "1"
  10847. fdd.DiseDate = s_tm
  10848. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10849. fdd.DiseName = item.CountryContentName
  10850. fdd.DiseCodg = item.CountryCode
  10851. fdds = append(fdds, &fdd)
  10852. }
  10853. }
  10854. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10855. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10856. fed.AdmDeptName = department.Name
  10857. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10858. fed.DscgDeptName = department.Name
  10859. fed.MedType = order.MedType
  10860. //处方医嘱信息
  10861. var orders []*models.FsiOrderDtos
  10862. //for _, item := range prescriptions {
  10863. // for _, subItem := range item.HisDoctorAdviceInfo {
  10864. // var order models.FsiOrderDtos
  10865. // order.RxID = strconv.FormatInt(item.ID, 10)
  10866. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10867. // order.LongDrordFlag = "0"
  10868. // order.HilistType = "1"
  10869. // order.ChrgType = "1"
  10870. // order.DrordBhvr = "-"
  10871. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10872. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10873. // order.HilistLv = "1"
  10874. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10875. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10876. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10877. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10878. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10879. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10880. // order.OwnpayAmt = ""
  10881. // order.SelfpayAmt = ""
  10882. // order.Spec = ""
  10883. // order.SpecUnt = ""
  10884. // order.DrordBegnDate = s_tm
  10885. // order.DrordStopDate = ""
  10886. // order.DrordDrCodg = "1"
  10887. // order.DrordDeptName = department.Name
  10888. // order.DrordDrCodg = "1"
  10889. // order.DrordDrName = doctor_info.UserName
  10890. // order.DrordDrProfttl = ""
  10891. // order.CurrDrordFlag = "1"
  10892. // orders = append(orders, &order)
  10893. // }
  10894. // for _, subItem := range item.HisPrescriptionProject {
  10895. // if subItem.Type == 2 {
  10896. // var order models.FsiOrderDtos
  10897. // order.RxID = strconv.FormatInt(item.ID, 10)
  10898. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10899. // order.LongDrordFlag = "0"
  10900. // order.HilistType = "1"
  10901. // order.ChrgType = "1"
  10902. // order.DrordBhvr = "-"
  10903. // order.HilistCode = subItem.HisProject.MedicalCode
  10904. // order.HosplistName = subItem.HisProject.ProjectName
  10905. // order.HilistLv = "1"
  10906. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10907. // order.HosplistCode = subItem.HisProject.MedicalCode
  10908. // order.HosplistName = subItem.HisProject.ProjectName
  10909. // order.Cnt = subItem.Count
  10910. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10911. //
  10912. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10913. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10914. // order.OwnpayAmt = ""
  10915. // order.SelfpayAmt = ""
  10916. // order.Spec = ""
  10917. // order.SpecUnt = ""
  10918. // order.DrordBegnDate = s_tm
  10919. // order.DrordStopDate = ""
  10920. // order.DrordDrCodg = "1"
  10921. // order.DrordDeptName = department.Name
  10922. // order.DrordDrCodg = "1"
  10923. // order.DrordDrName = doctor_info.UserName
  10924. // order.DrordDrProfttl = ""
  10925. // order.CurrDrordFlag = "1"
  10926. // orders = append(orders, &order)
  10927. //
  10928. // }
  10929. // if subItem.Type == 3 {
  10930. //
  10931. // var order models.FsiOrderDtos
  10932. // order.RxID = strconv.FormatInt(item.ID, 10)
  10933. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10934. // order.LongDrordFlag = "0"
  10935. // order.HilistType = "1"
  10936. // order.ChrgType = "1"
  10937. // order.DrordBhvr = "-"
  10938. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10939. // order.HosplistName = subItem.GoodInfo.GoodName
  10940. // order.HilistLv = "1"
  10941. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10942. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10943. // order.HosplistName = subItem.GoodInfo.GoodName
  10944. // order.Cnt = subItem.Count
  10945. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10946. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10947. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10948. // order.OwnpayAmt = ""
  10949. // order.SelfpayAmt = ""
  10950. // order.Spec = ""
  10951. // order.SpecUnt = ""
  10952. // order.DrordBegnDate = s_tm
  10953. // order.DrordStopDate = ""
  10954. // order.DrordDrCodg = "1"
  10955. // order.DrordDeptName = department.Name
  10956. // order.DrordDrCodg = "1"
  10957. // order.DrordDrName = doctor_info.UserName
  10958. // order.DrordDrProfttl = ""
  10959. // order.CurrDrordFlag = "1"
  10960. // orders = append(orders, &order)
  10961. //
  10962. // }
  10963. // }
  10964. //}
  10965. for _, item := range prescriptions {
  10966. for _, subItem := range item.HisDoctorAdviceInfo {
  10967. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10968. var order models.FsiOrderDtos
  10969. order.RxID = strconv.FormatInt(item.ID, 10)
  10970. order.Rxno = strconv.FormatInt(item.ID, 10)
  10971. order.LongDrordFlag = "0"
  10972. order.HilistType = "1"
  10973. order.ChrgType = "1"
  10974. order.DrordBhvr = "-"
  10975. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10976. order.HosplistName = subItem.BaseDrugLib.DrugName
  10977. order.HilistLv = "1"
  10978. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10979. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10980. order.HosplistName = subItem.BaseDrugLib.DrugName
  10981. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10982. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10983. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10984. order.OwnpayAmt = ""
  10985. order.SelfpayAmt = ""
  10986. order.Spec = ""
  10987. order.SpecUnt = ""
  10988. order.DrordBegnDate = s_tm
  10989. order.DrordStopDate = ""
  10990. order.DrordDrCodg = doctor_info.DoctorNumber
  10991. order.DrordDeptName = department.Name
  10992. order.DrordDeptCodg = department.Number
  10993. order.DrordDrName = doctor_info.UserName
  10994. order.DrordDrProfttl = "234"
  10995. order.CurrDrordFlag = "1"
  10996. orders = append(orders, &order)
  10997. }
  10998. }
  10999. for _, subItem := range item.HisPrescriptionProject {
  11000. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11001. var order models.FsiOrderDtos
  11002. order.RxID = strconv.FormatInt(item.ID, 10)
  11003. order.Rxno = strconv.FormatInt(item.ID, 10)
  11004. order.LongDrordFlag = "0"
  11005. order.HilistType = "1"
  11006. order.ChrgType = "1"
  11007. order.DrordBhvr = "-"
  11008. order.HilistCode = subItem.HisProject.MedicalCode
  11009. order.HosplistName = subItem.HisProject.ProjectName
  11010. order.HilistLv = "1"
  11011. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11012. order.HosplistCode = subItem.HisProject.MedicalCode
  11013. order.HosplistName = subItem.HisProject.ProjectName
  11014. order.Cnt = subItem.Count
  11015. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11016. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11017. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11018. order.OwnpayAmt = ""
  11019. order.SelfpayAmt = ""
  11020. order.Spec = ""
  11021. order.SpecUnt = ""
  11022. order.DrordBegnDate = s_tm
  11023. order.DrordStopDate = ""
  11024. order.DrordDrCodg = doctor_info.DoctorNumber
  11025. order.DrordDeptName = department.Name
  11026. order.DrordDeptCodg = department.Number
  11027. order.DrordDrName = doctor_info.UserName
  11028. order.DrordDrProfttl = "234"
  11029. order.CurrDrordFlag = "1"
  11030. orders = append(orders, &order)
  11031. }
  11032. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11033. var order models.FsiOrderDtos
  11034. order.RxID = strconv.FormatInt(item.ID, 10)
  11035. order.Rxno = strconv.FormatInt(item.ID, 10)
  11036. order.LongDrordFlag = "0"
  11037. order.HilistType = "1"
  11038. order.ChrgType = "1"
  11039. order.DrordBhvr = "0"
  11040. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11041. order.HosplistName = subItem.GoodInfo.GoodName
  11042. order.HilistLv = "1"
  11043. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11044. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11045. order.HosplistName = subItem.GoodInfo.GoodName
  11046. order.Cnt = subItem.Count
  11047. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11048. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11049. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11050. order.OwnpayAmt = ""
  11051. order.SelfpayAmt = ""
  11052. order.Spec = ""
  11053. order.SpecUnt = ""
  11054. order.DrordBegnDate = s_tm
  11055. order.DrordStopDate = ""
  11056. order.DrordDrCodg = doctor_info.DoctorNumber
  11057. order.DrordDeptName = department.Name
  11058. order.DrordDeptCodg = department.Number
  11059. order.DrordDrName = doctor_info.UserName
  11060. order.DrordDrProfttl = "234"
  11061. order.CurrDrordFlag = "1"
  11062. orders = append(orders, &order)
  11063. }
  11064. }
  11065. }
  11066. //处方医嘱信息
  11067. fed.MatnStas = "0"
  11068. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11069. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11070. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11071. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11072. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11073. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11074. fed.SetlTotlnum = "1"
  11075. fed.Insutype = his.Insutype
  11076. fed.ReimFlag = "0"
  11077. fed.OutSetlFlag = "0"
  11078. var fopd []*models.FsiOperationDtosData
  11079. data := make(map[string]interface{})
  11080. data["fed"] = fed
  11081. data["fdd"] = fdds
  11082. data["fod"] = orders
  11083. data["pd"] = pd
  11084. data["pp"] = pp
  11085. data["fopd"] = fopd
  11086. data["trig_scen"] = trig_scen
  11087. client := &http.Client{}
  11088. bytesData, _ := json.Marshal(data)
  11089. var req *http.Request
  11090. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11091. if miConfig.MdtrtareaAdmvs == "320921" {
  11092. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11093. } else {
  11094. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11095. }
  11096. resp, _ := client.Do(req)
  11097. defer resp.Body.Close()
  11098. body, ioErr := ioutil.ReadAll(resp.Body)
  11099. if ioErr != nil {
  11100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11102. return res
  11103. }
  11104. var respJSON map[string]interface{}
  11105. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11108. return res
  11109. }
  11110. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11111. result, _ := json.Marshal(respJSON)
  11112. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11113. utils.ErrorLog("解析失败:%v", err)
  11114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11115. return res
  11116. }
  11117. return res
  11118. } else {
  11119. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11120. saveLog(output, input, "3102", "事中")
  11121. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11122. utils.ErrorLog("解析失败:%v", err)
  11123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11124. return
  11125. }
  11126. return res
  11127. }
  11128. return res
  11129. }
  11130. 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) {
  11131. var res Resultgd3101
  11132. adminUser := c.GetAdminUserInfo()
  11133. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11134. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11135. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11136. //record_time := c.GetString("record_time")
  11137. //trig_scen := c.GetString("trig_scen")
  11138. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11139. //psn_info, _ := service.GetPatientId(patient_id)
  11140. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11141. timeLayout := "2006-01-02"
  11142. loc, _ := time.LoadLocation("Local")
  11143. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11144. if err != nil {
  11145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11146. return res
  11147. }
  11148. recordDateTime := theTime.Unix()
  11149. var patientPrescription models.HisPrescriptionInfo
  11150. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11151. //if patientPrescription.ID == 0 {
  11152. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11153. //}
  11154. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11155. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11156. //
  11157. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11158. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11159. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11160. var pp models.PublicParams
  11161. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11162. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11163. pp.FixmedinsName = miConfig.OrgName
  11164. pp.FixmedinsCode = miConfig.Code
  11165. pp.RequestUrl = miConfig.Url
  11166. pp.Cainfo = miConfig.Cainfo
  11167. pp.SecretKey = miConfig.SecretKey
  11168. pp.AccessKey = miConfig.AccessKey
  11169. pp.OpterName = roles.UserName
  11170. var config []*models.HisXtDiagnoseConfig
  11171. for _, item := range diagnosis_ids {
  11172. id, _ := strconv.ParseInt(item, 10, 64)
  11173. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11174. config = append(config, &diagnosisConfig)
  11175. }
  11176. var pd models.PatientDtos
  11177. pd.PatnID = his.PsnNo
  11178. pd.PatnName = his.Name
  11179. pd.Gend = his.Gend
  11180. pd.Brdy = str
  11181. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11182. pd.CurrMdtrtID = his.Number
  11183. var fed models.FsiEncounterDtos
  11184. fed.MdtrtID = his.Number
  11185. fed.MedinsID = miConfig.Code
  11186. fed.MedinsName = miConfig.OrgName
  11187. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11188. fed.MedMdtrtType = "1"
  11189. fed.MedinsType = "1"
  11190. fed.MedinsLv = "11"
  11191. tm := time.Unix(his.RecordDate, 0)
  11192. s_tm := tm.Format("2006-01-02 15:04:05")
  11193. fed.AdmDate = s_tm
  11194. fed.DscgDate = s_tm
  11195. fed.DscgMainDiseCodg = config[0].CountryCode
  11196. fed.DscgMainDiseName = config[0].CountryContentName
  11197. //诊断信息
  11198. var fdds []*models.FsiDiagnoseDtos
  11199. for index, item := range config {
  11200. if index == 0 {
  11201. var fdd models.FsiDiagnoseDtos
  11202. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11203. fdd.InoutDiseType = "1"
  11204. fdd.MaindiseFlag = "1"
  11205. fdd.DiseDate = s_tm
  11206. fdd.DiasSrtNo = "1"
  11207. fdd.DiseName = item.CountryContentName
  11208. fdd.DiseCodg = item.CountryCode
  11209. fdds = append(fdds, &fdd)
  11210. } else {
  11211. var fdd models.FsiDiagnoseDtos
  11212. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11213. fdd.InoutDiseType = "1"
  11214. fdd.MaindiseFlag = "1"
  11215. fdd.DiseDate = s_tm
  11216. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11217. fdd.DiseName = item.CountryContentName
  11218. fdd.DiseCodg = item.CountryCode
  11219. fdds = append(fdds, &fdd)
  11220. }
  11221. }
  11222. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11223. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11224. fed.AdmDeptName = de.Name
  11225. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11226. fed.DscgDeptName = de.Name
  11227. fed.MedMdtrtType = "1"
  11228. fed.MedType = "11"
  11229. //if his.Insutype == "390" {
  11230. // fed.MedType = "1402"
  11231. //} else {
  11232. // fed.MedType = "9933"
  11233. //}
  11234. var orders []*models.FsiOrderDtos
  11235. if trig_scen == "2" {
  11236. //处方医嘱信息
  11237. for _, item := range prescriptions {
  11238. for _, subItem := range item.HisDoctorAdviceInfo {
  11239. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11240. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11241. var order models.FsiOrderDtos
  11242. order.RxID = strconv.FormatInt(item.ID, 10)
  11243. order.Rxno = strconv.FormatInt(item.ID, 10)
  11244. order.LongDrordFlag = "0"
  11245. order.HilistType = "1"
  11246. order.ChrgType = "1"
  11247. order.DrordBhvr = "0"
  11248. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11249. order.HosplistName = subItem.BaseDrugLib.DrugName
  11250. order.HilistLv = "1"
  11251. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11252. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11253. order.HosplistName = subItem.BaseDrugLib.DrugName
  11254. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11255. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11256. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11257. order.OwnpayAmt = ""
  11258. order.SelfpayAmt = ""
  11259. order.Spec = spec
  11260. order.SpecUnt = subItem.PrescribingNumberUnit
  11261. order.DrordBegnDate = s_tm
  11262. order.DrordStopDate = ""
  11263. order.DrordDrCodg = doctor_info.DoctorNumber
  11264. order.DrordDeptName = department.Name
  11265. order.DrordDeptCodg = department.Number
  11266. order.DrordDrName = doctor_info.UserName
  11267. order.DrordDrProfttl = "234"
  11268. order.CurrDrordFlag = "1"
  11269. orders = append(orders, &order)
  11270. }
  11271. }
  11272. for _, subItem := range item.HisPrescriptionProject {
  11273. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11274. var order models.FsiOrderDtos
  11275. order.RxID = strconv.FormatInt(item.ID, 10)
  11276. order.Rxno = strconv.FormatInt(item.ID, 10)
  11277. order.LongDrordFlag = "0"
  11278. order.HilistType = "1"
  11279. order.ChrgType = "1"
  11280. order.DrordBhvr = "0"
  11281. order.HilistCode = subItem.HisProject.MedicalCode
  11282. order.HosplistName = subItem.HisProject.ProjectName
  11283. order.HilistLv = "1"
  11284. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11285. order.HosplistCode = subItem.HisProject.MedicalCode
  11286. order.HosplistName = subItem.HisProject.ProjectName
  11287. order.Cnt = subItem.Count
  11288. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11289. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11290. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11291. order.OwnpayAmt = ""
  11292. order.SelfpayAmt = ""
  11293. order.Spec = subItem.Unit
  11294. order.SpecUnt = subItem.Unit
  11295. order.DrordBegnDate = s_tm
  11296. order.DrordStopDate = ""
  11297. order.DrordDrCodg = doctor_info.DoctorNumber
  11298. order.DrordDeptName = department.Name
  11299. order.DrordDeptCodg = department.Number
  11300. order.DrordDrName = doctor_info.UserName
  11301. order.DrordDrProfttl = "234"
  11302. order.CurrDrordFlag = "1"
  11303. orders = append(orders, &order)
  11304. }
  11305. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11306. var order models.FsiOrderDtos
  11307. order.RxID = strconv.FormatInt(item.ID, 10)
  11308. order.Rxno = strconv.FormatInt(item.ID, 10)
  11309. order.LongDrordFlag = "0"
  11310. order.HilistType = "1"
  11311. order.ChrgType = "1"
  11312. order.DrordBhvr = "0"
  11313. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11314. order.HosplistName = subItem.GoodInfo.GoodName
  11315. order.HilistLv = "1"
  11316. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11317. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11318. order.HosplistName = subItem.GoodInfo.GoodName
  11319. order.Cnt = subItem.Count
  11320. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11321. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11322. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11323. order.OwnpayAmt = ""
  11324. order.SelfpayAmt = ""
  11325. order.Spec = subItem.GoodInfo.SpecificationName
  11326. order.SpecUnt = subItem.Unit
  11327. order.DrordBegnDate = s_tm
  11328. order.DrordStopDate = ""
  11329. order.DrordDrCodg = doctor_info.DoctorNumber
  11330. order.DrordDeptName = department.Name
  11331. order.DrordDeptCodg = department.Number
  11332. order.DrordDrName = doctor_info.UserName
  11333. order.DrordDrProfttl = "234"
  11334. order.CurrDrordFlag = "1"
  11335. orders = append(orders, &order)
  11336. }
  11337. }
  11338. }
  11339. //处方医嘱信息
  11340. }
  11341. fed.MatnStas = "0"
  11342. fed.MedfeeSumamt = "0"
  11343. fed.OwnpayAmt = "0"
  11344. fed.SelfpayAmt = "0"
  11345. fed.AcctPayamt = "0"
  11346. fed.MaAmt = "0"
  11347. fed.HifpPayamt = "0"
  11348. fed.SetlTotlnum = "1"
  11349. fed.Insutype = his.Insutype
  11350. fed.ReimFlag = "0"
  11351. fed.OutSetlFlag = "0"
  11352. var fopd []*models.FsiOperationDtosData
  11353. data := make(map[string]interface{})
  11354. data["fed"] = fed
  11355. data["fdd"] = fdds
  11356. data["fod"] = orders
  11357. data["pd"] = pd
  11358. data["pp"] = pp
  11359. data["fopd"] = fopd
  11360. data["trig_scen"] = trig_scen
  11361. fmt.Println(data)
  11362. fmt.Println(fed)
  11363. fmt.Println(fdds)
  11364. fmt.Println(orders)
  11365. fmt.Println(pd)
  11366. fmt.Println(pp)
  11367. fmt.Println(fopd)
  11368. client := &http.Client{}
  11369. bytesData, _ := json.Marshal(data)
  11370. var req *http.Request
  11371. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11372. if miConfig.MdtrtareaAdmvs == "320921" {
  11373. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11374. } else {
  11375. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11376. }
  11377. resp, _ := client.Do(req)
  11378. defer resp.Body.Close()
  11379. body, ioErr := ioutil.ReadAll(resp.Body)
  11380. if ioErr != nil {
  11381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11383. return res
  11384. }
  11385. var respJSON map[string]interface{}
  11386. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11389. return res
  11390. }
  11391. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11392. fmt.Println(respJSON)
  11393. result, _ := json.Marshal(respJSON)
  11394. fmt.Println(result)
  11395. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11396. utils.ErrorLog("解析失败:%v", err)
  11397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11398. return res
  11399. }
  11400. return res
  11401. } else {
  11402. //if miConfig.MdtrtareaAdmvs == "441202" {
  11403. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11404. saveLog(output, input, "3101", "事前")
  11405. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11406. utils.ErrorLog("解析失败:%v", err)
  11407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11408. return
  11409. }
  11410. return res
  11411. //}
  11412. }
  11413. }
  11414. 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) {
  11415. adminUser := c.GetAdminUserInfo()
  11416. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11417. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11418. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11419. //record_time := c.GetString("record_time")
  11420. //trig_scen := c.GetString("trig_scen")
  11421. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11422. timeLayout := "2006-01-02"
  11423. loc, _ := time.LoadLocation("Local")
  11424. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11425. if err != nil {
  11426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11427. return res
  11428. }
  11429. recordDateTime := theTime.Unix()
  11430. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11431. var patientPrescription models.HisPrescriptionInfo
  11432. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11433. if patientPrescription.ID == 0 {
  11434. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11435. }
  11436. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11437. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11438. //
  11439. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11440. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11441. var pp models.PublicParams
  11442. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11443. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11444. pp.FixmedinsName = miConfig.OrgName
  11445. pp.FixmedinsCode = miConfig.Code
  11446. pp.RequestUrl = miConfig.Url
  11447. pp.Cainfo = miConfig.Cainfo
  11448. pp.SecretKey = miConfig.SecretKey
  11449. pp.AccessKey = miConfig.AccessKey
  11450. pp.OpterName = roles.UserName
  11451. var config []*models.HisXtDiagnoseConfig
  11452. for _, item := range diagnosis_ids {
  11453. id, _ := strconv.ParseInt(item, 10, 64)
  11454. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11455. config = append(config, &diagnosisConfig)
  11456. }
  11457. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11458. var pd models.PatientDtos
  11459. pd.PatnID = his.PsnNo
  11460. pd.PatnName = his.Name
  11461. pd.Gend = his.Gend
  11462. pd.Brdy = str
  11463. pd.Poolarea = his.InsuplcAdmdvs
  11464. pd.CurrMdtrtID = his.Number
  11465. var fed models.FsiEncounterDtos
  11466. fed.MdtrtID = his.Number
  11467. fed.MedinsID = miConfig.Code
  11468. fed.MedinsName = miConfig.OrgName
  11469. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11470. fed.MedMdtrtType = "1"
  11471. fed.MedinsType = "1"
  11472. fed.MedinsLv = "11"
  11473. tm := time.Unix(his.RecordDate, 0)
  11474. s_tm := tm.Format("2006-01-02 15:04:05")
  11475. fed.AdmDate = s_tm
  11476. fed.DscgDate = s_tm
  11477. fed.DscgMainDiseCodg = config[0].CountryCode
  11478. fed.DscgMainDiseName = config[0].CountryContentName
  11479. //诊断信息
  11480. var fdds []*models.FsiDiagnoseDtos
  11481. for index, item := range config {
  11482. if index == 0 {
  11483. var fdd models.FsiDiagnoseDtos
  11484. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11485. fdd.InoutDiseType = "1"
  11486. fdd.MaindiseFlag = "1"
  11487. fdd.DiseDate = s_tm
  11488. fdd.DiasSrtNo = "1"
  11489. fdd.DiseName = item.CountryContentName
  11490. fdd.DiseCodg = item.CountryCode
  11491. fdds = append(fdds, &fdd)
  11492. } else {
  11493. var fdd models.FsiDiagnoseDtos
  11494. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11495. fdd.InoutDiseType = "1"
  11496. fdd.MaindiseFlag = "1"
  11497. fdd.DiseDate = s_tm
  11498. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11499. fdd.DiseName = item.CountryContentName
  11500. fdd.DiseCodg = item.CountryCode
  11501. fdds = append(fdds, &fdd)
  11502. }
  11503. }
  11504. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11505. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11506. fed.AdmDeptName = department.Name
  11507. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11508. fed.DscgDeptName = department.Name
  11509. fed.MedMdtrtType = "1"
  11510. fed.MedType = "11"
  11511. //if his.Insutype == "390" {
  11512. // fed.MedType = "1402"
  11513. //} else {
  11514. // fed.MedType = "9933"
  11515. //}
  11516. var orders []*models.FsiOrderDtos
  11517. if trig_scen == "2" {
  11518. //处方医嘱信息
  11519. for _, item := range prescriptions {
  11520. for _, subItem := range item.HisDoctorAdviceInfo {
  11521. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11522. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11523. var order models.FsiOrderDtos
  11524. order.RxID = strconv.FormatInt(item.ID, 10)
  11525. order.Rxno = strconv.FormatInt(item.ID, 10)
  11526. order.LongDrordFlag = "0"
  11527. order.HilistType = "1"
  11528. order.ChrgType = "1"
  11529. order.DrordBhvr = "0"
  11530. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11531. order.HosplistName = subItem.BaseDrugLib.DrugName
  11532. order.HilistLv = "1"
  11533. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11534. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11535. order.HosplistName = subItem.BaseDrugLib.DrugName
  11536. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11537. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11538. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11539. order.OwnpayAmt = ""
  11540. order.SelfpayAmt = ""
  11541. order.Spec = spec
  11542. order.SpecUnt = subItem.PrescribingNumberUnit
  11543. order.DrordBegnDate = s_tm
  11544. order.DrordStopDate = ""
  11545. order.DrordDrCodg = doctor_info.DoctorNumber
  11546. order.DrordDeptName = department.Name
  11547. order.DrordDeptCodg = department.Number
  11548. order.DrordDrName = doctor_info.UserName
  11549. order.DrordDrProfttl = "234"
  11550. order.CurrDrordFlag = "1"
  11551. orders = append(orders, &order)
  11552. }
  11553. }
  11554. for _, subItem := range item.HisPrescriptionProject {
  11555. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11556. var order models.FsiOrderDtos
  11557. order.RxID = strconv.FormatInt(item.ID, 10)
  11558. order.Rxno = strconv.FormatInt(item.ID, 10)
  11559. order.LongDrordFlag = "0"
  11560. order.HilistType = "1"
  11561. order.ChrgType = "1"
  11562. order.DrordBhvr = "0"
  11563. order.HilistCode = subItem.HisProject.MedicalCode
  11564. order.HosplistName = subItem.HisProject.ProjectName
  11565. order.HilistLv = "1"
  11566. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11567. order.HosplistCode = subItem.HisProject.MedicalCode
  11568. order.HosplistName = subItem.HisProject.ProjectName
  11569. order.Cnt = subItem.Count
  11570. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11571. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11572. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11573. order.OwnpayAmt = ""
  11574. order.SelfpayAmt = ""
  11575. order.Spec = subItem.Unit
  11576. order.SpecUnt = subItem.Unit
  11577. order.DrordBegnDate = s_tm
  11578. order.DrordStopDate = ""
  11579. order.DrordDrCodg = doctor_info.DoctorNumber
  11580. order.DrordDeptName = department.Name
  11581. order.DrordDeptCodg = department.Number
  11582. order.DrordDrName = doctor_info.UserName
  11583. order.DrordDrProfttl = "234"
  11584. order.CurrDrordFlag = "1"
  11585. orders = append(orders, &order)
  11586. }
  11587. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11588. var order models.FsiOrderDtos
  11589. order.RxID = strconv.FormatInt(item.ID, 10)
  11590. order.Rxno = strconv.FormatInt(item.ID, 10)
  11591. order.LongDrordFlag = "0"
  11592. order.HilistType = "1"
  11593. order.ChrgType = "1"
  11594. order.DrordBhvr = "0"
  11595. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11596. order.HosplistName = subItem.GoodInfo.GoodName
  11597. order.HilistLv = "1"
  11598. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11599. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11600. order.HosplistName = subItem.GoodInfo.GoodName
  11601. order.Cnt = subItem.Count
  11602. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11603. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11604. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11605. order.OwnpayAmt = ""
  11606. order.SelfpayAmt = ""
  11607. order.Spec = subItem.GoodInfo.SpecificationName
  11608. order.SpecUnt = subItem.Unit
  11609. order.DrordBegnDate = s_tm
  11610. order.DrordStopDate = ""
  11611. order.DrordDrCodg = doctor_info.DoctorNumber
  11612. order.DrordDeptName = department.Name
  11613. order.DrordDeptCodg = department.Number
  11614. order.DrordDrName = doctor_info.UserName
  11615. order.DrordDrProfttl = "234"
  11616. order.CurrDrordFlag = "1"
  11617. orders = append(orders, &order)
  11618. }
  11619. }
  11620. }
  11621. //处方医嘱信息
  11622. }
  11623. fed.MatnStas = "0"
  11624. fed.MedfeeSumamt = "0"
  11625. fed.OwnpayAmt = "0"
  11626. fed.SelfpayAmt = "0"
  11627. fed.AcctPayamt = "0"
  11628. fed.MaAmt = "0"
  11629. fed.HifpPayamt = "0"
  11630. fed.SetlTotlnum = "1"
  11631. fed.Insutype = his.Insutype
  11632. fed.ReimFlag = "0"
  11633. fed.OutSetlFlag = "0"
  11634. var fopd []*models.FsiOperationDtosData
  11635. data := make(map[string]interface{})
  11636. data["fed"] = fed
  11637. data["fdd"] = fdds
  11638. data["fod"] = orders
  11639. data["pd"] = pd
  11640. data["pp"] = pp
  11641. data["fopd"] = fopd
  11642. data["trig_scen"] = trig_scen
  11643. fmt.Println(data)
  11644. fmt.Println(fed)
  11645. fmt.Println(fdds)
  11646. fmt.Println(orders)
  11647. fmt.Println(pd)
  11648. fmt.Println(pp)
  11649. fmt.Println(fopd)
  11650. client := &http.Client{}
  11651. bytesData, _ := json.Marshal(data)
  11652. var req *http.Request
  11653. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11654. if miConfig.MdtrtareaAdmvs == "320921" {
  11655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11656. } else {
  11657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11658. }
  11659. resp, _ := client.Do(req)
  11660. defer resp.Body.Close()
  11661. body, ioErr := ioutil.ReadAll(resp.Body)
  11662. if ioErr != nil {
  11663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11665. return res
  11666. }
  11667. var respJSON map[string]interface{}
  11668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11671. return res
  11672. }
  11673. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11674. fmt.Println(respJSON)
  11675. result, _ := json.Marshal(respJSON)
  11676. fmt.Println(result)
  11677. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11678. utils.ErrorLog("解析失败:%v", err)
  11679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11680. return res
  11681. }
  11682. return res
  11683. } else {
  11684. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11685. saveLog(output, input, "3101", "事前")
  11686. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11687. utils.ErrorLog("解析失败:%v", err)
  11688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11689. return
  11690. }
  11691. return res
  11692. }
  11693. return res
  11694. }
  11695. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11696. ////patient_id, _ := c.GetInt64("patient_id")
  11697. //order_id, _ := c.GetInt64("order_id")
  11698. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11699. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11700. //trig_scen := c.GetString("trig_scen")
  11701. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11702. //utils.ErrorLog("解析失败:%v", psn_info)
  11703. adminUser := c.GetAdminUserInfo()
  11704. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11705. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11706. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11707. record_time := c.GetString("record_time")
  11708. order, _ := service.GetHisOrderByID(order_id)
  11709. timeLayout := "2006-01-02"
  11710. loc, _ := time.LoadLocation("Local")
  11711. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11712. if err != nil {
  11713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11714. return
  11715. }
  11716. recordDateTime := theTime.Unix()
  11717. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11718. var patientPrescription models.HisPrescriptionInfo
  11719. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11720. if patientPrescription.ID == 0 {
  11721. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11722. }
  11723. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11724. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11725. //
  11726. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11727. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11728. var pp models.PublicParams
  11729. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11730. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11731. pp.FixmedinsName = miConfig.OrgName
  11732. pp.FixmedinsCode = miConfig.Code
  11733. pp.RequestUrl = miConfig.Url
  11734. pp.Cainfo = miConfig.Cainfo
  11735. pp.SecretKey = miConfig.SecretKey
  11736. pp.AccessKey = miConfig.AccessKey
  11737. pp.OpterName = roles.UserName
  11738. var config []*models.HisXtDiagnoseConfig
  11739. for _, item := range diagnosis_ids {
  11740. id, _ := strconv.ParseInt(item, 10, 64)
  11741. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11742. config = append(config, &diagnosisConfig)
  11743. }
  11744. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11745. var pd models.PatientDtos
  11746. pd.PatnID = his.PsnNo
  11747. pd.PatnName = his.Name
  11748. pd.Gend = his.Gend
  11749. pd.Brdy = str
  11750. pd.Poolarea = his.InsuplcAdmdvs
  11751. pd.CurrMdtrtID = his.Number
  11752. var fed models.FsiEncounterDtos
  11753. fed.MdtrtID = his.Number
  11754. fed.MedinsID = miConfig.Code
  11755. fed.MedinsName = miConfig.OrgName
  11756. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11757. fed.MedMdtrtType = "1"
  11758. fed.MedinsType = "1"
  11759. fed.MedinsLv = "11"
  11760. tm := time.Unix(his.RecordDate, 0)
  11761. s_tm := tm.Format("2006-01-02 15:04:05")
  11762. fed.AdmDate = s_tm
  11763. fed.DscgDate = s_tm
  11764. fed.DscgMainDiseCodg = config[0].CountryCode
  11765. fed.DscgMainDiseName = config[0].CountryContentName
  11766. //诊断信息
  11767. var fdds []*models.FsiDiagnoseDtos
  11768. for index, item := range config {
  11769. if index == 0 {
  11770. var fdd models.FsiDiagnoseDtos
  11771. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11772. fdd.InoutDiseType = "1"
  11773. fdd.MaindiseFlag = "1"
  11774. fdd.DiseDate = s_tm
  11775. fdd.DiasSrtNo = "1"
  11776. fdd.DiseName = item.CountryContentName
  11777. fdd.DiseCodg = item.CountryCode
  11778. fdds = append(fdds, &fdd)
  11779. } else {
  11780. var fdd models.FsiDiagnoseDtos
  11781. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11782. fdd.InoutDiseType = "1"
  11783. fdd.MaindiseFlag = "1"
  11784. fdd.DiseDate = s_tm
  11785. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11786. fdd.DiseName = item.CountryContentName
  11787. fdd.DiseCodg = item.CountryCode
  11788. fdds = append(fdds, &fdd)
  11789. }
  11790. }
  11791. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11792. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11793. fed.AdmDeptName = department.Name
  11794. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11795. fed.DscgDeptName = department.Name
  11796. fed.MedType = order.MedType
  11797. //处方医嘱信息
  11798. var orders []*models.FsiOrderDtos
  11799. //for _, item := range prescriptions {
  11800. // for _, subItem := range item.HisDoctorAdviceInfo {
  11801. // var order models.FsiOrderDtos
  11802. // order.RxID = strconv.FormatInt(item.ID, 10)
  11803. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11804. // order.LongDrordFlag = "0"
  11805. // order.HilistType = "1"
  11806. // order.ChrgType = "1"
  11807. // order.DrordBhvr = "-"
  11808. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11809. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11810. // order.HilistLv = "1"
  11811. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11812. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11813. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11814. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11815. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11816. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11817. // order.OwnpayAmt = ""
  11818. // order.SelfpayAmt = ""
  11819. // order.Spec = ""
  11820. // order.SpecUnt = ""
  11821. // order.DrordBegnDate = s_tm
  11822. // order.DrordStopDate = ""
  11823. // order.DrordDrCodg = "1"
  11824. // order.DrordDeptName = department.Name
  11825. // order.DrordDrCodg = "1"
  11826. // order.DrordDrName = doctor_info.UserName
  11827. // order.DrordDrProfttl = ""
  11828. // order.CurrDrordFlag = "1"
  11829. // orders = append(orders, &order)
  11830. // }
  11831. // for _, subItem := range item.HisPrescriptionProject {
  11832. // if subItem.Type == 2 {
  11833. // var order models.FsiOrderDtos
  11834. // order.RxID = strconv.FormatInt(item.ID, 10)
  11835. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11836. // order.LongDrordFlag = "0"
  11837. // order.HilistType = "1"
  11838. // order.ChrgType = "1"
  11839. // order.DrordBhvr = "-"
  11840. // order.HilistCode = subItem.HisProject.MedicalCode
  11841. // order.HosplistName = subItem.HisProject.ProjectName
  11842. // order.HilistLv = "1"
  11843. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11844. // order.HosplistCode = subItem.HisProject.MedicalCode
  11845. // order.HosplistName = subItem.HisProject.ProjectName
  11846. // order.Cnt = subItem.Count
  11847. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11848. //
  11849. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11850. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11851. // order.OwnpayAmt = ""
  11852. // order.SelfpayAmt = ""
  11853. // order.Spec = ""
  11854. // order.SpecUnt = ""
  11855. // order.DrordBegnDate = s_tm
  11856. // order.DrordStopDate = ""
  11857. // order.DrordDrCodg = "1"
  11858. // order.DrordDeptName = department.Name
  11859. // order.DrordDrCodg = "1"
  11860. // order.DrordDrName = doctor_info.UserName
  11861. // order.DrordDrProfttl = ""
  11862. // order.CurrDrordFlag = "1"
  11863. // orders = append(orders, &order)
  11864. //
  11865. // }
  11866. // if subItem.Type == 3 {
  11867. //
  11868. // var order models.FsiOrderDtos
  11869. // order.RxID = strconv.FormatInt(item.ID, 10)
  11870. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11871. // order.LongDrordFlag = "0"
  11872. // order.HilistType = "1"
  11873. // order.ChrgType = "1"
  11874. // order.DrordBhvr = "-"
  11875. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11876. // order.HosplistName = subItem.GoodInfo.GoodName
  11877. // order.HilistLv = "1"
  11878. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11879. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11880. // order.HosplistName = subItem.GoodInfo.GoodName
  11881. // order.Cnt = subItem.Count
  11882. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11883. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11884. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11885. // order.OwnpayAmt = ""
  11886. // order.SelfpayAmt = ""
  11887. // order.Spec = ""
  11888. // order.SpecUnt = ""
  11889. // order.DrordBegnDate = s_tm
  11890. // order.DrordStopDate = ""
  11891. // order.DrordDrCodg = "1"
  11892. // order.DrordDeptName = department.Name
  11893. // order.DrordDrCodg = "1"
  11894. // order.DrordDrName = doctor_info.UserName
  11895. // order.DrordDrProfttl = ""
  11896. // order.CurrDrordFlag = "1"
  11897. // orders = append(orders, &order)
  11898. //
  11899. // }
  11900. // }
  11901. //}
  11902. for _, item := range prescriptions {
  11903. for _, subItem := range item.HisDoctorAdviceInfo {
  11904. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11905. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11906. var order models.FsiOrderDtos
  11907. order.RxID = strconv.FormatInt(item.ID, 10)
  11908. order.Rxno = strconv.FormatInt(item.ID, 10)
  11909. order.LongDrordFlag = "0"
  11910. order.HilistType = "1"
  11911. order.ChrgType = "1"
  11912. order.DrordBhvr = "0"
  11913. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11914. order.HosplistName = subItem.BaseDrugLib.DrugName
  11915. order.HilistLv = "1"
  11916. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11917. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11918. order.HosplistName = subItem.BaseDrugLib.DrugName
  11919. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11920. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11921. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11922. order.OwnpayAmt = ""
  11923. order.SelfpayAmt = ""
  11924. order.Spec = spec
  11925. order.SpecUnt = subItem.PrescribingNumberUnit
  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. }
  11937. for _, subItem := range item.HisPrescriptionProject {
  11938. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11939. var order models.FsiOrderDtos
  11940. order.RxID = strconv.FormatInt(item.ID, 10)
  11941. order.Rxno = strconv.FormatInt(item.ID, 10)
  11942. order.LongDrordFlag = "0"
  11943. order.HilistType = "1"
  11944. order.ChrgType = "1"
  11945. order.DrordBhvr = "0"
  11946. order.HilistCode = subItem.HisProject.MedicalCode
  11947. order.HosplistName = subItem.HisProject.ProjectName
  11948. order.HilistLv = "1"
  11949. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11950. order.HosplistCode = subItem.HisProject.MedicalCode
  11951. order.HosplistName = subItem.HisProject.ProjectName
  11952. order.Cnt = subItem.Count
  11953. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11954. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11955. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11956. order.OwnpayAmt = ""
  11957. order.SelfpayAmt = ""
  11958. order.Spec = subItem.Unit
  11959. order.SpecUnt = subItem.Unit
  11960. order.DrordBegnDate = s_tm
  11961. order.DrordStopDate = ""
  11962. order.DrordDrCodg = doctor_info.DoctorNumber
  11963. order.DrordDeptName = department.Name
  11964. order.DrordDeptCodg = department.Number
  11965. order.DrordDrName = doctor_info.UserName
  11966. order.DrordDrProfttl = "234"
  11967. order.CurrDrordFlag = "1"
  11968. orders = append(orders, &order)
  11969. }
  11970. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11971. var order models.FsiOrderDtos
  11972. order.RxID = strconv.FormatInt(item.ID, 10)
  11973. order.Rxno = strconv.FormatInt(item.ID, 10)
  11974. order.LongDrordFlag = "0"
  11975. order.HilistType = "1"
  11976. order.ChrgType = "1"
  11977. order.DrordBhvr = "0"
  11978. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11979. order.HosplistName = subItem.GoodInfo.GoodName
  11980. order.HilistLv = "1"
  11981. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11982. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11983. order.HosplistName = subItem.GoodInfo.GoodName
  11984. order.Cnt = subItem.Count
  11985. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11986. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11987. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11988. order.OwnpayAmt = ""
  11989. order.SelfpayAmt = ""
  11990. order.Spec = subItem.GoodInfo.SpecificationName
  11991. order.SpecUnt = subItem.Unit
  11992. order.DrordBegnDate = s_tm
  11993. order.DrordStopDate = ""
  11994. order.DrordDrCodg = doctor_info.DoctorNumber
  11995. order.DrordDeptName = department.Name
  11996. order.DrordDeptCodg = department.Number
  11997. order.DrordDrName = doctor_info.UserName
  11998. order.DrordDrProfttl = "234"
  11999. order.CurrDrordFlag = "1"
  12000. orders = append(orders, &order)
  12001. }
  12002. }
  12003. }
  12004. //处方医嘱信息
  12005. fed.MatnStas = "0"
  12006. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12007. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12008. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12009. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12010. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12011. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12012. fed.SetlTotlnum = "1"
  12013. fed.Insutype = his.Insutype
  12014. fed.ReimFlag = "0"
  12015. fed.OutSetlFlag = "0"
  12016. var fopd []*models.FsiOperationDtosData
  12017. data := make(map[string]interface{})
  12018. data["fed"] = fed
  12019. data["fdd"] = fdds
  12020. data["fod"] = orders
  12021. data["pd"] = pd
  12022. data["pp"] = pp
  12023. data["fopd"] = fopd
  12024. data["trig_scen"] = trig_scen
  12025. client := &http.Client{}
  12026. bytesData, _ := json.Marshal(data)
  12027. var req *http.Request
  12028. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12029. if miConfig.MdtrtareaAdmvs == "320921" {
  12030. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12031. } else {
  12032. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12033. }
  12034. resp, _ := client.Do(req)
  12035. defer resp.Body.Close()
  12036. body, ioErr := ioutil.ReadAll(resp.Body)
  12037. if ioErr != nil {
  12038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12040. return res
  12041. }
  12042. var respJSON map[string]interface{}
  12043. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12046. return res
  12047. }
  12048. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12049. result, _ := json.Marshal(respJSON)
  12050. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12051. utils.ErrorLog("解析失败:%v", err)
  12052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12053. return res
  12054. }
  12055. return res
  12056. } else {
  12057. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12058. saveLog(output, input, "3102", "事中")
  12059. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12060. utils.ErrorLog("解析失败:%v", err)
  12061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12062. return
  12063. }
  12064. return res
  12065. }
  12066. return res
  12067. }
  12068. func (c *HisApiController) Check() {
  12069. psn_no := c.GetString("psn_no")
  12070. in := c.GetString("in")
  12071. mt := c.GetString("mt")
  12072. baseParams := models.BaseParams{
  12073. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12074. FixmedinsCode: "H15049901371",
  12075. InsuplcAdmdvs: "150499",
  12076. MdtrtareaAdmvs: "150499",
  12077. OrgName: "赤峰费森血液透析中心",
  12078. Doctor: "1111",
  12079. }
  12080. service.Gdyb2001(baseParams, psn_no, in, mt)
  12081. }
  12082. func (c *HisApiController) GetPsnNcdsInfo() {
  12083. admin_user_id, _ := c.GetInt64("admin_user_id")
  12084. patient_id, _ := c.GetInt64("patient_id")
  12085. //id, _ := c.GetInt64("id")
  12086. adminUser := c.GetAdminUserInfo()
  12087. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12088. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12089. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12090. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12091. //psn_record, _ := service.GetP(id)
  12092. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12093. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12094. //
  12095. //if psn_record.ID == 0 {
  12096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12097. // return
  12098. //}
  12099. var res Result5301
  12100. var res10265 Result5301For10265
  12101. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12102. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12103. var api string
  12104. if miConfig.MdtrtareaAdmvs == "320921" {
  12105. 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 +
  12106. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12107. } else {
  12108. 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 +
  12109. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12110. }
  12111. resp, requestErr := http.Get(api)
  12112. if requestErr != nil {
  12113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12114. return
  12115. }
  12116. body, ioErr := ioutil.ReadAll(resp.Body)
  12117. if ioErr != nil {
  12118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12120. return
  12121. }
  12122. var respJSON map[string]interface{}
  12123. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12126. return
  12127. }
  12128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12129. result, _ := json.Marshal(respJSON)
  12130. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12131. utils.ErrorLog("解析失败:%v", err)
  12132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12133. return
  12134. }
  12135. res.ErrMsg = res10265.ErrMsg
  12136. res.Output = res10265.Output
  12137. res.InfRefmsgid = res10265.InfRefmsgid
  12138. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12139. res.Infcode = infocode
  12140. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12141. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12142. var api string
  12143. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12144. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12145. resp, requestErr := http.Get(api)
  12146. if requestErr != nil {
  12147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12148. return
  12149. }
  12150. body, ioErr := ioutil.ReadAll(resp.Body)
  12151. if ioErr != nil {
  12152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12154. return
  12155. }
  12156. var respJSON map[string]interface{}
  12157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12160. return
  12161. }
  12162. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12163. if status == "0" {
  12164. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12165. c.ServeSuccessJSON(map[string]interface{}{
  12166. "failed_code": -10,
  12167. "msg": err_msg,
  12168. })
  12169. return
  12170. }
  12171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12172. result, _ := json.Marshal(respJSON)
  12173. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12174. utils.ErrorLog("解析失败:%v", err)
  12175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12176. return
  12177. }
  12178. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12179. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12180. var api string
  12181. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12182. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12183. resp, requestErr := http.Get(api)
  12184. if requestErr != nil {
  12185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12186. return
  12187. }
  12188. body, ioErr := ioutil.ReadAll(resp.Body)
  12189. if ioErr != nil {
  12190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12192. return
  12193. }
  12194. var respJSON map[string]interface{}
  12195. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12198. return
  12199. }
  12200. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12201. if status == "0" {
  12202. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12203. c.ServeSuccessJSON(map[string]interface{}{
  12204. "failed_code": -10,
  12205. "msg": err_msg,
  12206. })
  12207. return
  12208. }
  12209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12210. result, _ := json.Marshal(respJSON)
  12211. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12212. utils.ErrorLog("解析失败:%v", err)
  12213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12214. return
  12215. }
  12216. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12217. p, _ := service.GetHisPatientById(patient_id)
  12218. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12219. var dat map[string]interface{}
  12220. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12221. fmt.Println(dat)
  12222. } else {
  12223. fmt.Println(err)
  12224. }
  12225. userJSONBytes, _ := json.Marshal(dat)
  12226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12227. utils.ErrorLog("解析失败:%v", err)
  12228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12229. return
  12230. }
  12231. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12232. p, _ := service.GetHisPatientById(patient_id)
  12233. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12234. var dat map[string]interface{}
  12235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12236. fmt.Println(dat)
  12237. } else {
  12238. fmt.Println(err)
  12239. }
  12240. userJSONBytes, _ := json.Marshal(dat)
  12241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12242. utils.ErrorLog("解析失败:%v", err)
  12243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12244. return
  12245. }
  12246. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12247. p, _ := service.GetHisPatientById(patient_id)
  12248. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12249. var dat map[string]interface{}
  12250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12251. fmt.Println(dat)
  12252. } else {
  12253. fmt.Println(err)
  12254. }
  12255. userJSONBytes, _ := json.Marshal(dat)
  12256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12257. utils.ErrorLog("解析失败:%v", err)
  12258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12259. return
  12260. }
  12261. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12262. p, _ := service.GetHisPatientById(patient_id)
  12263. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12264. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12265. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12266. resp, requestErr := http.Get(api)
  12267. if requestErr != nil {
  12268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12269. return
  12270. }
  12271. body, ioErr := ioutil.ReadAll(resp.Body)
  12272. if ioErr != nil {
  12273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12275. return
  12276. }
  12277. var respJSON map[string]interface{}
  12278. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12281. return
  12282. }
  12283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12284. result, _ := json.Marshal(respJSON)
  12285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12286. utils.ErrorLog("解析失败:%v", err)
  12287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12288. return
  12289. }
  12290. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12291. p, _ := service.GetHisPatientById(patient_id)
  12292. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12293. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12294. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12295. resp, requestErr := http.Get(api)
  12296. if requestErr != nil {
  12297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12298. return
  12299. }
  12300. body, ioErr := ioutil.ReadAll(resp.Body)
  12301. if ioErr != nil {
  12302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12304. return
  12305. }
  12306. var respJSON map[string]interface{}
  12307. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12310. return
  12311. }
  12312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12313. result, _ := json.Marshal(respJSON)
  12314. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12315. utils.ErrorLog("解析失败:%v", err)
  12316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12317. return
  12318. }
  12319. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12320. p, _ := service.GetHisPatientById(patient_id)
  12321. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12322. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12323. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12324. resp, requestErr := http.Get(api)
  12325. if requestErr != nil {
  12326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12327. return
  12328. }
  12329. body, ioErr := ioutil.ReadAll(resp.Body)
  12330. if ioErr != nil {
  12331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12333. return
  12334. }
  12335. var respJSON map[string]interface{}
  12336. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12339. return
  12340. }
  12341. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12342. result, _ := json.Marshal(respJSON)
  12343. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12344. utils.ErrorLog("解析失败:%v", err)
  12345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12346. return
  12347. }
  12348. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12349. p, _ := service.GetHisPatientById(patient_id)
  12350. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12351. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12353. resp, requestErr := http.Get(api)
  12354. if requestErr != nil {
  12355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12356. return
  12357. }
  12358. body, ioErr := ioutil.ReadAll(resp.Body)
  12359. if ioErr != nil {
  12360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12362. return
  12363. }
  12364. var respJSON map[string]interface{}
  12365. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12368. return
  12369. }
  12370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12371. result, _ := json.Marshal(respJSON)
  12372. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12373. utils.ErrorLog("解析失败:%v", err)
  12374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12375. return
  12376. }
  12377. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12378. p, _ := service.GetHisPatientById(patient_id)
  12379. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12380. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12381. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12382. resp, requestErr := http.Get(api)
  12383. if requestErr != nil {
  12384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12385. return
  12386. }
  12387. body, ioErr := ioutil.ReadAll(resp.Body)
  12388. if ioErr != nil {
  12389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12391. return
  12392. }
  12393. var respJSON map[string]interface{}
  12394. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12397. return
  12398. }
  12399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12400. result, _ := json.Marshal(respJSON)
  12401. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12402. utils.ErrorLog("解析失败:%v", err)
  12403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12404. return
  12405. }
  12406. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12407. p, _ := service.GetHisPatientById(patient_id)
  12408. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12409. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12410. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12411. resp, requestErr := http.Get(api)
  12412. if requestErr != nil {
  12413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12414. return
  12415. }
  12416. body, ioErr := ioutil.ReadAll(resp.Body)
  12417. if ioErr != nil {
  12418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12420. return
  12421. }
  12422. var respJSON map[string]interface{}
  12423. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12426. return
  12427. }
  12428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12429. result, _ := json.Marshal(respJSON)
  12430. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12431. utils.ErrorLog("解析失败:%v", err)
  12432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12433. return
  12434. }
  12435. } else {
  12436. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12437. var dat map[string]interface{}
  12438. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12439. fmt.Println(dat)
  12440. } else {
  12441. fmt.Println(err)
  12442. }
  12443. userJSONBytes, _ := json.Marshal(dat)
  12444. if miConfig.Code == "H15049901371" {
  12445. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12446. utils.ErrorLog("解析失败:%v", err)
  12447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12448. return
  12449. }
  12450. res.InfRefmsgid = res10265.InfRefmsgid
  12451. res.Output = res10265.Output
  12452. res.ErrMsg = res10265.ErrMsg
  12453. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12454. res.Infcode = infocode
  12455. } else {
  12456. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12457. utils.ErrorLog("解析失败:%v", err)
  12458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12459. return
  12460. }
  12461. }
  12462. }
  12463. if res.Infcode == 0 {
  12464. c.ServeSuccessJSON(map[string]interface{}{
  12465. "result": res.Output.Result,
  12466. })
  12467. }
  12468. }
  12469. func (c *HisApiController) CheckInsutype() {
  12470. his_patient_id, _ := c.GetInt64("his_patient_id")
  12471. admin_user_id, _ := c.GetInt64("admin_user_id")
  12472. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12473. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12474. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12475. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12476. var dat map[string]interface{}
  12477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12478. fmt.Println(dat)
  12479. } else {
  12480. fmt.Println(err)
  12481. }
  12482. userJSONBytes, _ := json.Marshal(dat)
  12483. var res Result90100
  12484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12485. utils.ErrorLog("解析失败:%v", err)
  12486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12487. return
  12488. }
  12489. if res.Infcode != 0 {
  12490. c.ServeSuccessJSON(map[string]interface{}{
  12491. "failed_code": -10,
  12492. "msg": res.ErrMsg,
  12493. })
  12494. return
  12495. } else {
  12496. fmt.Println(res)
  12497. }
  12498. }
  12499. func (c *HisApiController) CheckCardPWD() {
  12500. card_pwd := c.GetString("card_pwd")
  12501. his_patient_id, _ := c.GetInt64("his_patient_id")
  12502. admin_user_id, _ := c.GetInt64("admin_user_id")
  12503. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12504. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12505. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12506. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12507. bas := strings.Split(psn.CardInfo, "|")
  12508. basNumber := bas[2]
  12509. if psn.InsuplcAdmdvs[:4] == "4403" {
  12510. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12511. var dat map[string]interface{}
  12512. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12513. fmt.Println(dat)
  12514. } else {
  12515. fmt.Println(err)
  12516. }
  12517. userJSONBytes, _ := json.Marshal(dat)
  12518. var res Result90991
  12519. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12520. utils.ErrorLog("解析失败:%v", err)
  12521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12522. return
  12523. }
  12524. if res.Infcode != 0 {
  12525. c.ServeSuccessJSON(map[string]interface{}{
  12526. "failed_code": -10,
  12527. "msg": res.ErrMsg,
  12528. })
  12529. return
  12530. } else {
  12531. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12532. var msg string
  12533. switch res.Output.Result.CardStat {
  12534. case "00":
  12535. msg = "未激活"
  12536. break
  12537. case "10":
  12538. msg = "激活"
  12539. break
  12540. case "20":
  12541. msg = "窗口挂失"
  12542. break
  12543. case "21":
  12544. msg = "电话挂失"
  12545. break
  12546. case "22":
  12547. msg = "单位网上申报挂失"
  12548. break
  12549. case "23":
  12550. msg = "保健办挂失"
  12551. break
  12552. case "24":
  12553. msg = "个人网上挂失"
  12554. break
  12555. case "25":
  12556. msg = "网上服务大厅挂失"
  12557. break
  12558. case "30":
  12559. msg = "注销"
  12560. break
  12561. case "40":
  12562. msg = "回收"
  12563. break
  12564. case "99":
  12565. msg = "制卡中(无效卡)"
  12566. break
  12567. }
  12568. c.ServeSuccessJSON(map[string]interface{}{
  12569. "failed_code": -10,
  12570. "msg": msg,
  12571. })
  12572. return
  12573. } else {
  12574. c.ServeSuccessJSON(map[string]interface{}{
  12575. "msg": "校验成功",
  12576. })
  12577. return
  12578. }
  12579. }
  12580. } else {
  12581. c.ServeSuccessJSON(map[string]interface{}{
  12582. "msg": "校验成功",
  12583. })
  12584. return
  12585. }
  12586. }
  12587. func (c *HisApiController) CheckCardPWDTwo() {
  12588. //card_pwd := c.GetString("card_pwd")
  12589. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12590. admin_user_id, _ := c.GetInt64("admin_user_id")
  12591. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12592. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12593. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12594. var dat map[string]interface{}
  12595. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12596. fmt.Println(dat)
  12597. } else {
  12598. fmt.Println(err)
  12599. }
  12600. userJSONBytes, _ := json.Marshal(dat)
  12601. var res Result90991
  12602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12603. utils.ErrorLog("解析失败:%v", err)
  12604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12605. return
  12606. }
  12607. if res.Infcode != 0 {
  12608. c.ServeSuccessJSON(map[string]interface{}{
  12609. "failed_code": -10,
  12610. "msg": res.ErrMsg,
  12611. })
  12612. return
  12613. } else {
  12614. if res.Output.Result.SscnoCheckStat == "0" {
  12615. var msg string
  12616. switch res.Output.Result.CardStat {
  12617. case "00":
  12618. msg = "未激活"
  12619. break
  12620. case "10":
  12621. msg = "激活"
  12622. break
  12623. case "20":
  12624. msg = "窗口挂失"
  12625. break
  12626. case "21":
  12627. msg = "电话挂失"
  12628. break
  12629. case "22":
  12630. msg = "单位网上申报挂失"
  12631. break
  12632. case "23":
  12633. msg = "保健办挂失"
  12634. break
  12635. case "24":
  12636. msg = "个人网上挂失"
  12637. break
  12638. case "25":
  12639. msg = "网上服务大厅挂失"
  12640. break
  12641. case "30":
  12642. msg = "注销"
  12643. break
  12644. case "40":
  12645. msg = "回收"
  12646. break
  12647. case "99":
  12648. msg = "制卡中(无效卡)"
  12649. break
  12650. }
  12651. c.ServeSuccessJSON(map[string]interface{}{
  12652. "failed_code": -10,
  12653. "msg": msg,
  12654. })
  12655. return
  12656. } else {
  12657. c.ServeSuccessJSON(map[string]interface{}{
  12658. "msg": "校验成功",
  12659. })
  12660. return
  12661. }
  12662. }
  12663. }
  12664. type ELeCertData struct {
  12665. Data struct {
  12666. Extra string `json:"extra"`
  12667. IDNo string `json:"idNo"`
  12668. IDType string `json:"idType"`
  12669. EcToken string `json:"ecToken"`
  12670. InsuOrg string `json:"insuOrg"`
  12671. UserName string `json:"userName"`
  12672. EcIndexNo string `json:"ecIndexNo"`
  12673. Gender string `json:"gender"`
  12674. Birthday string `json:"birthday"`
  12675. Nationality string `json:"nationality"`
  12676. Email string `json:"email"`
  12677. } `json:"OutData"`
  12678. }
  12679. func (c *HisApiController) ReadCard() {
  12680. id_card_type, _ := c.GetInt64("id_card_type")
  12681. admin_user_id, _ := c.GetInt64("admin_user_id")
  12682. certificates, _ := c.GetInt64("certificates")
  12683. //
  12684. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12685. id_card_no := c.GetString("id_card_no")
  12686. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12687. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12688. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12689. switch id_card_type {
  12690. case 1:
  12691. if miConfig.MdtrtareaAdmvs == "421300" {
  12692. var res ResultTwo
  12693. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12694. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12695. "&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)
  12696. resp, requestErr := http.Get(api)
  12697. if requestErr != nil {
  12698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12699. return
  12700. }
  12701. body, ioErr := ioutil.ReadAll(resp.Body)
  12702. if ioErr != nil {
  12703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12705. return
  12706. }
  12707. var respJSON map[string]interface{}
  12708. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12711. return
  12712. }
  12713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12714. result, _ := json.Marshal(respJSON)
  12715. fmt.Println("log")
  12716. fmt.Println(string(result))
  12717. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12718. utils.ErrorLog("解析失败:%v", err)
  12719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12720. return
  12721. }
  12722. if res.Infcode == 0 {
  12723. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12724. if err == gorm.ErrRecordNotFound {
  12725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12726. return
  12727. } else if err != nil {
  12728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12729. return
  12730. } else {
  12731. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12732. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12733. infoStr := string(Iinfos)
  12734. idetinfoStr := string(Idetinfos)
  12735. var rf []*ResultFive
  12736. json.Unmarshal([]byte(infoStr), &rf)
  12737. var insutypes []*ResultFive
  12738. var insutype string
  12739. var is390 int = 0
  12740. var is310 int = 0
  12741. for _, item := range rf {
  12742. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12743. insutypes = append(insutypes, item)
  12744. }
  12745. }
  12746. if len(insutypes) == 1 {
  12747. insutype = insutypes[0].Insutype
  12748. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12749. } else {
  12750. for _, i := range insutypes {
  12751. if i.Insutype == "390" {
  12752. is390 = 1
  12753. }
  12754. if i.Insutype == "310" {
  12755. is310 = 1
  12756. }
  12757. }
  12758. }
  12759. if is390 == 1 {
  12760. insutype = "390"
  12761. }
  12762. if is310 == 1 {
  12763. insutype = "310"
  12764. }
  12765. if len(insutypes) == 0 {
  12766. insutype = "390"
  12767. }
  12768. var insuplc_admdvs string
  12769. for _, item := range rf {
  12770. if item.Insutype == insutype {
  12771. insuplc_admdvs = item.InsuplcAdmdvs
  12772. }
  12773. }
  12774. if strings.Contains(insuplc_admdvs, "4213") {
  12775. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12776. }
  12777. psn := &models.HisPsn{
  12778. PsnNo: res.Output.Baseinfo.PsnNo,
  12779. PatientId: patient.ID,
  12780. Certno: res.Output.Baseinfo.Certno,
  12781. Gend: res.Output.Baseinfo.Gend,
  12782. Naty: res.Output.Baseinfo.Naty,
  12783. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12784. PsnName: res.Output.Baseinfo.PsnName,
  12785. Idetinfo: idetinfoStr,
  12786. Insuinfo: infoStr,
  12787. InsuplcAdmdvs: insuplc_admdvs,
  12788. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12789. }
  12790. service.CreateHisPsn(psn)
  12791. c.ServeSuccessJSON(map[string]interface{}{
  12792. "patient": patient,
  12793. "number": res.Output.Baseinfo.Certno,
  12794. })
  12795. }
  12796. } else {
  12797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12798. return
  12799. }
  12800. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12801. var res ResultTwo
  12802. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12803. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12804. "&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)
  12805. resp, requestErr := http.Get(api)
  12806. if requestErr != nil {
  12807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12808. return
  12809. }
  12810. body, ioErr := ioutil.ReadAll(resp.Body)
  12811. if ioErr != nil {
  12812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12814. return
  12815. }
  12816. var respJSON map[string]interface{}
  12817. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12820. return
  12821. }
  12822. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12823. result, _ := json.Marshal(respJSON)
  12824. fmt.Println("log")
  12825. fmt.Println(string(result))
  12826. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12827. utils.ErrorLog("解析失败:%v", err)
  12828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12829. return
  12830. }
  12831. if res.Infcode == 0 {
  12832. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12833. if err == gorm.ErrRecordNotFound {
  12834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12835. return
  12836. } else if err != nil {
  12837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12838. return
  12839. } else {
  12840. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12841. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12842. infoStr := string(Iinfos)
  12843. idetinfoStr := string(Idetinfos)
  12844. psn := &models.HisPsn{
  12845. PsnNo: res.Output.Baseinfo.PsnNo,
  12846. PatientId: patient.ID,
  12847. Certno: res.Output.Baseinfo.Certno,
  12848. Gend: res.Output.Baseinfo.Gend,
  12849. Naty: res.Output.Baseinfo.Naty,
  12850. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12851. PsnName: res.Output.Baseinfo.PsnName,
  12852. Idetinfo: idetinfoStr,
  12853. Insuinfo: infoStr,
  12854. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12855. }
  12856. service.CreateHisPsn(psn)
  12857. var rf []*ResultFive
  12858. json.Unmarshal([]byte(infoStr), &rf)
  12859. var insutypes []*ResultFive
  12860. var insutype string
  12861. var is390 int = 0
  12862. var is310 int = 0
  12863. for _, item := range rf {
  12864. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12865. insutypes = append(insutypes, item)
  12866. }
  12867. }
  12868. if len(insutypes) == 1 {
  12869. insutype = insutypes[0].Insutype
  12870. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12871. } else {
  12872. for _, i := range insutypes {
  12873. if i.Insutype == "390" {
  12874. is390 = 1
  12875. }
  12876. if i.Insutype == "310" {
  12877. is310 = 1
  12878. }
  12879. }
  12880. }
  12881. if is390 == 1 {
  12882. insutype = "390"
  12883. }
  12884. if is310 == 1 {
  12885. insutype = "310"
  12886. }
  12887. if len(insutypes) == 0 {
  12888. insutype = "310"
  12889. }
  12890. c.ServeSuccessJSON(map[string]interface{}{
  12891. "patient": patient,
  12892. "number": res.Output.Baseinfo.Certno,
  12893. "insutype": insutype,
  12894. })
  12895. }
  12896. } else {
  12897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12898. return
  12899. }
  12900. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12901. var res ResultTwo
  12902. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12903. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12904. "&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)
  12905. resp, requestErr := http.Get(api)
  12906. if requestErr != nil {
  12907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12908. return
  12909. }
  12910. body, ioErr := ioutil.ReadAll(resp.Body)
  12911. if ioErr != nil {
  12912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12914. return
  12915. }
  12916. var respJSON map[string]interface{}
  12917. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12920. return
  12921. }
  12922. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12923. result, _ := json.Marshal(respJSON)
  12924. fmt.Println("log")
  12925. fmt.Println(string(result))
  12926. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12927. utils.ErrorLog("解析失败:%v", err)
  12928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12929. return
  12930. }
  12931. if res.Infcode == 0 {
  12932. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12933. if err == gorm.ErrRecordNotFound {
  12934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12935. return
  12936. } else if err != nil {
  12937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12938. return
  12939. } else {
  12940. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12941. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12942. infoStr := string(Iinfos)
  12943. idetinfoStr := string(Idetinfos)
  12944. var rf []*ResultFive
  12945. json.Unmarshal([]byte(infoStr), &rf)
  12946. var insutypes []*ResultFive
  12947. var insutype string
  12948. var is390 int = 0
  12949. var is310 int = 0
  12950. for _, item := range rf {
  12951. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12952. insutypes = append(insutypes, item)
  12953. }
  12954. }
  12955. if len(insutypes) == 1 {
  12956. insutype = insutypes[0].Insutype
  12957. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12958. } else {
  12959. for _, i := range insutypes {
  12960. if i.Insutype == "390" {
  12961. is390 = 1
  12962. }
  12963. if i.Insutype == "310" {
  12964. is310 = 1
  12965. }
  12966. }
  12967. }
  12968. if is390 == 1 {
  12969. insutype = "390"
  12970. }
  12971. if is310 == 1 {
  12972. insutype = "310"
  12973. }
  12974. if len(insutypes) == 0 {
  12975. insutype = "390"
  12976. }
  12977. var insuplc_admdvs string
  12978. for _, item := range rf {
  12979. if item.Insutype == insutype {
  12980. insuplc_admdvs = item.InsuplcAdmdvs
  12981. }
  12982. }
  12983. psn := &models.HisPsn{
  12984. PsnNo: res.Output.Baseinfo.PsnNo,
  12985. PatientId: patient.ID,
  12986. Certno: res.Output.Baseinfo.Certno,
  12987. Gend: res.Output.Baseinfo.Gend,
  12988. Naty: res.Output.Baseinfo.Naty,
  12989. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12990. PsnName: res.Output.Baseinfo.PsnName,
  12991. Idetinfo: idetinfoStr,
  12992. Insuinfo: infoStr,
  12993. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12994. InsuplcAdmdvs: insuplc_admdvs,
  12995. }
  12996. service.CreateHisPsn(psn)
  12997. for _, item := range rf {
  12998. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12999. insutypes = append(insutypes, item)
  13000. }
  13001. }
  13002. if len(insutypes) == 1 {
  13003. insutype = insutypes[0].Insutype
  13004. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13005. } else {
  13006. for _, i := range insutypes {
  13007. if i.Insutype == "390" {
  13008. is390 = 1
  13009. }
  13010. if i.Insutype == "310" {
  13011. is310 = 1
  13012. }
  13013. }
  13014. }
  13015. if is390 == 1 {
  13016. insutype = "390"
  13017. }
  13018. if is310 == 1 {
  13019. insutype = "310"
  13020. }
  13021. if len(insutypes) == 0 {
  13022. insutype = "310"
  13023. }
  13024. c.ServeSuccessJSON(map[string]interface{}{
  13025. "patient": patient,
  13026. "number": res.Output.Baseinfo.Certno,
  13027. "insutype": insutype,
  13028. })
  13029. }
  13030. } else {
  13031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13032. return
  13033. }
  13034. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13035. var res ResultTwo
  13036. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13037. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13038. "&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)
  13039. resp, requestErr := http.Get(api)
  13040. if requestErr != nil {
  13041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13042. return
  13043. }
  13044. body, ioErr := ioutil.ReadAll(resp.Body)
  13045. if ioErr != nil {
  13046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13048. return
  13049. }
  13050. var respJSON map[string]interface{}
  13051. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13054. return
  13055. }
  13056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13057. result, _ := json.Marshal(respJSON)
  13058. fmt.Println("log")
  13059. fmt.Println(string(result))
  13060. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13061. utils.ErrorLog("解析失败:%v", err)
  13062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13063. return
  13064. }
  13065. if res.Infcode == 0 {
  13066. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13067. if err == gorm.ErrRecordNotFound {
  13068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13069. return
  13070. } else if err != nil {
  13071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13072. return
  13073. } else {
  13074. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13075. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13076. infoStr := string(Iinfos)
  13077. idetinfoStr := string(Idetinfos)
  13078. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13079. psn := &models.HisPsn{
  13080. PsnNo: res.Output.Baseinfo.PsnNo,
  13081. PatientId: patient.ID,
  13082. Certno: res.Output.Baseinfo.Certno,
  13083. Brdy: b,
  13084. Age: float64(age),
  13085. Gend: res.Output.Baseinfo.Gend,
  13086. Naty: res.Output.Baseinfo.Naty,
  13087. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13088. PsnName: res.Output.Baseinfo.PsnName,
  13089. Idetinfo: idetinfoStr,
  13090. Insuinfo: infoStr,
  13091. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13092. }
  13093. service.CreateHisPsn(psn)
  13094. var rf []*ResultFive
  13095. json.Unmarshal([]byte(infoStr), &rf)
  13096. var insutypes []*ResultFive
  13097. var insutype string
  13098. var is390 int = 0
  13099. var is310 int = 0
  13100. for _, item := range rf {
  13101. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13102. insutypes = append(insutypes, item)
  13103. }
  13104. }
  13105. if len(insutypes) == 1 {
  13106. insutype = insutypes[0].Insutype
  13107. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13108. } else {
  13109. for _, i := range insutypes {
  13110. if i.Insutype == "390" {
  13111. is390 = 1
  13112. }
  13113. if i.Insutype == "310" {
  13114. is310 = 1
  13115. }
  13116. }
  13117. }
  13118. if is390 == 1 {
  13119. insutype = "390"
  13120. }
  13121. if is310 == 1 {
  13122. insutype = "310"
  13123. }
  13124. if len(insutypes) == 0 {
  13125. insutype = "310"
  13126. }
  13127. c.ServeSuccessJSON(map[string]interface{}{
  13128. "patient": patient,
  13129. "number": res.Output.Baseinfo.Certno,
  13130. "insutype": insutype,
  13131. })
  13132. }
  13133. } else {
  13134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13135. return
  13136. }
  13137. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13138. var api string
  13139. if miConfig.MdtrtareaAdmvs == "320921" {
  13140. 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 +
  13141. "&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
  13142. fmt.Println(api)
  13143. } else {
  13144. 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 +
  13145. "&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)
  13146. }
  13147. resp, requestErr := http.Get(api)
  13148. if requestErr != nil {
  13149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13150. return
  13151. }
  13152. body, ioErr := ioutil.ReadAll(resp.Body)
  13153. if ioErr != nil {
  13154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13156. return
  13157. }
  13158. var respJSON map[string]interface{}
  13159. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13162. return
  13163. }
  13164. var status string
  13165. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13166. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13167. //console.log()
  13168. fmt.Println("type===")
  13169. fmt.Println(card_type)
  13170. var token string
  13171. var res ResultTwo //1101结果
  13172. var res10265 ResultTwo10265 //1101结果
  13173. var card_info string //卡信息
  13174. var busi_card_info string
  13175. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13176. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13177. if status == "0" { //读卡成功
  13178. if card_type == "1" {
  13179. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13180. result, _ := json.Marshal(respJSON)
  13181. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13182. utils.ErrorLog("解析失败:%v", err)
  13183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13184. return
  13185. }
  13186. res.ErrMsg = res10265.ErrMsg
  13187. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13188. res.Infcode = infocode
  13189. res.Output = res10265.Output
  13190. res.InfRefmsgid = res10265.InfRefmsgid
  13191. } else {
  13192. //var card_info string //卡信息
  13193. //var busi_card_info string
  13194. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13195. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13196. //fmt.Println(card_info)
  13197. //fmt.Println(busi_card_info)
  13198. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13199. result, _ := json.Marshal(respJSON)
  13200. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13201. utils.ErrorLog("解析失败:%v", err)
  13202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13203. return
  13204. }
  13205. res.ErrMsg = res10265.ErrMsg
  13206. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13207. res.Infcode = infocode
  13208. res.Output = res10265.Output
  13209. res.InfRefmsgid = res10265.InfRefmsgid
  13210. }
  13211. if res.Infcode == 0 {
  13212. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13213. if err == gorm.ErrRecordNotFound {
  13214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13215. return
  13216. } else if err != nil {
  13217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13218. return
  13219. } else {
  13220. if card_type == "1" {
  13221. bas := strings.Split(card_info, "|")
  13222. basNumber := bas[2]
  13223. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13224. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13225. infoStr := string(Iinfos)
  13226. idetinfoStr := string(Idetinfos)
  13227. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13228. psn := &models.HisPsn{
  13229. PsnNo: res.Output.Baseinfo.PsnNo,
  13230. PatientId: patient.ID,
  13231. Certno: res.Output.Baseinfo.Certno,
  13232. Brdy: b,
  13233. Age: float64(age),
  13234. Gend: res.Output.Baseinfo.Gend,
  13235. Naty: res.Output.Baseinfo.Naty,
  13236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13237. PsnName: res.Output.Baseinfo.PsnName,
  13238. Idetinfo: idetinfoStr,
  13239. Insuinfo: infoStr,
  13240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13241. CardInfo: card_info,
  13242. VerifyNumber: busi_card_info,
  13243. }
  13244. service.CreateHisPsn(psn)
  13245. var rf []*ResultFive
  13246. json.Unmarshal([]byte(infoStr), &rf)
  13247. var insutypes []*ResultFive
  13248. var insutype string
  13249. var is390 int = 0
  13250. var is310 int = 0
  13251. for _, item := range rf {
  13252. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13253. insutypes = append(insutypes, item)
  13254. }
  13255. }
  13256. if len(insutypes) == 1 {
  13257. insutype = insutypes[0].Insutype
  13258. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13259. } else {
  13260. for _, i := range insutypes {
  13261. if i.Insutype == "390" {
  13262. is390 = 1
  13263. }
  13264. if i.Insutype == "310" {
  13265. is310 = 1
  13266. }
  13267. }
  13268. }
  13269. if is390 == 1 {
  13270. insutype = "390"
  13271. }
  13272. if is310 == 1 {
  13273. insutype = "310"
  13274. }
  13275. if len(insutypes) == 0 {
  13276. insutype = "310"
  13277. }
  13278. c.ServeSuccessJSON(map[string]interface{}{
  13279. "patient": patient,
  13280. "number": basNumber,
  13281. "insutype": insutype,
  13282. })
  13283. } else {
  13284. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13285. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13286. infoStr := string(Iinfos)
  13287. idetinfoStr := string(Idetinfos)
  13288. psn := &models.HisPsn{
  13289. PsnNo: res.Output.Baseinfo.PsnNo,
  13290. PatientId: patient.ID,
  13291. Certno: res.Output.Baseinfo.Certno,
  13292. Gend: res.Output.Baseinfo.Gend,
  13293. Naty: res.Output.Baseinfo.Naty,
  13294. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13295. PsnName: res.Output.Baseinfo.PsnName,
  13296. Idetinfo: idetinfoStr,
  13297. Insuinfo: infoStr,
  13298. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13299. CardInfo: card_info,
  13300. VerifyNumber: token,
  13301. }
  13302. service.CreateHisPsn(psn)
  13303. c.ServeSuccessJSON(map[string]interface{}{
  13304. "patient": patient,
  13305. "number": token,
  13306. })
  13307. }
  13308. }
  13309. } else {
  13310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13311. return
  13312. }
  13313. } else { //读卡失败
  13314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13315. return
  13316. }
  13317. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13318. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13319. cardnum = DeleteExtraSpaceTwo(cardnum)
  13320. cardCode = DeleteExtraSpaceTwo(cardCode)
  13321. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13322. name = DeleteExtraSpaceTwo(name)
  13323. errmsg = DeleteExtraSpaceTwo(errmsg)
  13324. cardnum = Remove0000(cardnum)
  13325. cardCode = Remove0000(cardCode)
  13326. id_card_no = Remove0000(id_card_no)
  13327. name = Remove0000(name)
  13328. errmsg = Remove0000(errmsg)
  13329. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13330. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13331. //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)
  13332. //fmt.Println(result2)
  13333. //fmt.Println(requestLog2)
  13334. //fmt.Println(errMsgLog2)
  13335. 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)
  13336. saveLog(result, requestLog, "1101", "获取人员信息")
  13337. fmt.Println(errMsgLog)
  13338. if len(errMsgLog) > 0 {
  13339. } else {
  13340. var dat map[string]interface{}
  13341. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13342. fmt.Println(dat)
  13343. } else {
  13344. fmt.Println(err)
  13345. }
  13346. userJSONBytes, _ := json.Marshal(dat)
  13347. var res ResultTwo
  13348. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13349. utils.ErrorLog("解析失败:%v", err)
  13350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13351. return
  13352. }
  13353. res.ErrMsg = errMsgLog
  13354. if res.Infcode == 0 {
  13355. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13356. if err == gorm.ErrRecordNotFound {
  13357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13358. return
  13359. } else if err != nil {
  13360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13361. return
  13362. } else {
  13363. fmt.Println(res)
  13364. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13365. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13366. infoStr := string(Iinfos)
  13367. idetinfoStr := string(Idetinfos)
  13368. var rf []*ResultFive
  13369. json.Unmarshal([]byte(infoStr), &rf)
  13370. var insutypes []*ResultFive
  13371. var insutype string
  13372. var is390 int = 0
  13373. var is310 int = 0
  13374. for _, item := range rf {
  13375. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13376. insutypes = append(insutypes, item)
  13377. }
  13378. }
  13379. if len(insutypes) == 1 {
  13380. insutype = insutypes[0].Insutype
  13381. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13382. } else {
  13383. for _, i := range insutypes {
  13384. if i.Insutype == "390" {
  13385. is390 = 1
  13386. }
  13387. if i.Insutype == "310" {
  13388. is310 = 1
  13389. }
  13390. }
  13391. }
  13392. if is390 == 1 {
  13393. insutype = "390"
  13394. }
  13395. if is310 == 1 {
  13396. insutype = "310"
  13397. }
  13398. if len(insutypes) == 0 {
  13399. insutype = "390"
  13400. }
  13401. var insuplc_admdvs string
  13402. for _, item := range rf {
  13403. if item.Insutype == insutype {
  13404. insuplc_admdvs = item.InsuplcAdmdvs
  13405. }
  13406. }
  13407. psn := &models.HisPsn{
  13408. PsnNo: res.Output.Baseinfo.PsnNo,
  13409. PatientId: patient.ID,
  13410. Certno: res.Output.Baseinfo.Certno,
  13411. Gend: res.Output.Baseinfo.Gend,
  13412. Naty: res.Output.Baseinfo.Naty,
  13413. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13414. PsnName: res.Output.Baseinfo.PsnName,
  13415. Idetinfo: idetinfoStr,
  13416. Insuinfo: infoStr,
  13417. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13418. CardInfo: basStr,
  13419. VerifyNumber: "",
  13420. InsuplcAdmdvs: insuplc_admdvs,
  13421. }
  13422. service.CreateHisPsn(psn)
  13423. c.ServeSuccessJSON(map[string]interface{}{
  13424. "patient": patient,
  13425. "number": cardnum,
  13426. "insutype": insutype,
  13427. })
  13428. }
  13429. } else {
  13430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13431. return
  13432. }
  13433. }
  13434. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13435. fmt.Println(initFlag)
  13436. fmt.Println("initFlag")
  13437. if initFlag == 0 {
  13438. c.TestGetJiangXiBasBaseInit()
  13439. }
  13440. basStr := c.GetBasBaseInfo()
  13441. if len(basStr) == 0 {
  13442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13443. return
  13444. }
  13445. fmt.Println(basStr)
  13446. bas := strings.Split(basStr, "|")
  13447. basNumber := bas[1]
  13448. fmt.Println(basNumber)
  13449. card_sn := bas[3]
  13450. fmt.Println(card_sn)
  13451. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13452. 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)
  13453. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13454. var dat map[string]interface{}
  13455. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13456. fmt.Println(dat)
  13457. } else {
  13458. fmt.Println(err)
  13459. }
  13460. userJSONBytes, _ := json.Marshal(dat)
  13461. var res ResultTwo
  13462. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13463. utils.ErrorLog("解析失败:%v", err)
  13464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13465. return
  13466. }
  13467. if res.Infcode == 0 {
  13468. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13469. if err == gorm.ErrRecordNotFound {
  13470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13471. return
  13472. } else if err != nil {
  13473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13474. return
  13475. } else {
  13476. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13477. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13478. infoStr := string(Iinfos)
  13479. idetinfoStr := string(Idetinfos)
  13480. var rf []*ResultFive
  13481. json.Unmarshal([]byte(infoStr), &rf)
  13482. var insutypes []*ResultFive
  13483. var insutype string
  13484. var is390 int = 0
  13485. var is310 int = 0
  13486. var insuplc_admdvs string
  13487. for _, item := range rf {
  13488. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13489. insutypes = append(insutypes, item)
  13490. }
  13491. }
  13492. if len(insutypes) == 1 {
  13493. insutype = insutypes[0].Insutype
  13494. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13495. } else {
  13496. for _, i := range insutypes {
  13497. if i.Insutype == "390" {
  13498. is390 = 1
  13499. }
  13500. if i.Insutype == "310" {
  13501. is310 = 1
  13502. }
  13503. }
  13504. }
  13505. if is390 == 1 {
  13506. insutype = "390"
  13507. }
  13508. if is310 == 1 {
  13509. insutype = "310"
  13510. }
  13511. if len(insutypes) == 0 {
  13512. insutype = "310"
  13513. }
  13514. for _, item := range rf {
  13515. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13516. insuplc_admdvs = item.InsuplcAdmdvs
  13517. }
  13518. }
  13519. psn := &models.HisPsn{
  13520. PsnNo: res.Output.Baseinfo.PsnNo,
  13521. PatientId: patient.ID,
  13522. Certno: res.Output.Baseinfo.Certno,
  13523. Gend: res.Output.Baseinfo.Gend,
  13524. Naty: res.Output.Baseinfo.Naty,
  13525. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13526. PsnName: res.Output.Baseinfo.PsnName,
  13527. Idetinfo: idetinfoStr,
  13528. Insuinfo: infoStr,
  13529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13530. CardInfo: basStr,
  13531. InsuplcAdmdvs: insuplc_admdvs,
  13532. VerifyNumber: "",
  13533. }
  13534. service.CreateHisPsn(psn)
  13535. c.ServeSuccessJSON(map[string]interface{}{
  13536. "patient": patient,
  13537. "number": basNumber,
  13538. "insutype": insutype,
  13539. })
  13540. }
  13541. } else {
  13542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13543. return
  13544. }
  13545. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13546. basStr := c.GetBasBaseInfo22222()
  13547. fmt.Println(basStr)
  13548. if len(basStr) == 0 {
  13549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13550. return
  13551. }
  13552. fmt.Println(basStr)
  13553. bas := strings.Split(basStr, "|")
  13554. basNumber := bas[2] //卡号
  13555. card_sn := bas[3] //
  13556. id_card_No := bas[1] //卡号
  13557. fmt.Println(basNumber)
  13558. fmt.Println(card_sn)
  13559. fmt.Println(id_card_No)
  13560. var patient service.Patients
  13561. if len(id_card_No) == 0 {
  13562. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13563. } else {
  13564. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13565. }
  13566. 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)
  13567. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13568. var dat map[string]interface{}
  13569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13570. fmt.Println(dat)
  13571. } else {
  13572. fmt.Println(err)
  13573. }
  13574. userJSONBytes, _ := json.Marshal(dat)
  13575. var res ResultTwo
  13576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13577. utils.ErrorLog("解析失败:%v", err)
  13578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13579. return
  13580. }
  13581. if res.Infcode == 0 {
  13582. var pateint2 service.Patients
  13583. var err error
  13584. if len(id_card_No) == 0 {
  13585. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13586. } else {
  13587. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13588. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13589. }
  13590. if err == gorm.ErrRecordNotFound {
  13591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13592. return
  13593. } else if err != nil {
  13594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13595. return
  13596. } else {
  13597. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13598. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13599. infoStr := string(Iinfos)
  13600. idetinfoStr := string(Idetinfos)
  13601. var rf []*ResultFive
  13602. json.Unmarshal([]byte(infoStr), &rf)
  13603. var insutypes []*ResultFive
  13604. var insutype string
  13605. var is390 int = 0
  13606. var is310 int = 0
  13607. var insuplc_admdvs string
  13608. for _, item := range rf {
  13609. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13610. insutypes = append(insutypes, item)
  13611. }
  13612. }
  13613. if len(insutypes) == 1 {
  13614. insutype = insutypes[0].Insutype
  13615. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13616. } else {
  13617. for _, i := range insutypes {
  13618. if i.Insutype == "390" {
  13619. is390 = 1
  13620. }
  13621. if i.Insutype == "310" {
  13622. is310 = 1
  13623. }
  13624. }
  13625. }
  13626. if is390 == 1 {
  13627. insutype = "390"
  13628. }
  13629. if is310 == 1 {
  13630. insutype = "310"
  13631. }
  13632. if len(insutypes) == 0 {
  13633. insutype = "310"
  13634. }
  13635. for _, item := range rf {
  13636. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13637. insuplc_admdvs = item.InsuplcAdmdvs
  13638. }
  13639. }
  13640. psn := &models.HisPsn{
  13641. PsnNo: res.Output.Baseinfo.PsnNo,
  13642. PatientId: pateint2.ID,
  13643. Certno: res.Output.Baseinfo.Certno,
  13644. Gend: res.Output.Baseinfo.Gend,
  13645. Naty: res.Output.Baseinfo.Naty,
  13646. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13647. PsnName: res.Output.Baseinfo.PsnName,
  13648. Idetinfo: idetinfoStr,
  13649. Insuinfo: infoStr,
  13650. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13651. CardInfo: basStr,
  13652. InsuplcAdmdvs: insuplc_admdvs,
  13653. VerifyNumber: "",
  13654. }
  13655. service.CreateHisPsn(psn)
  13656. c.ServeSuccessJSON(map[string]interface{}{
  13657. "patient": patient,
  13658. "number": basNumber,
  13659. "insutype": insutype,
  13660. })
  13661. }
  13662. } else {
  13663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13664. return
  13665. }
  13666. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13667. fmt.Println(initFlag)
  13668. fmt.Println("initFlag")
  13669. if initFlag == 0 {
  13670. c.TestGetHnBasBaseInit()
  13671. }
  13672. basStr := c.GetBasBaseInfo()
  13673. if len(basStr) == 0 {
  13674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13675. return
  13676. }
  13677. fmt.Println(basStr)
  13678. bas := strings.Split(basStr, "|")
  13679. basNumber := bas[1]
  13680. fmt.Println(basNumber)
  13681. card_sn := bas[3]
  13682. card_no := bas[2]
  13683. fmt.Println(card_sn)
  13684. name := bas[4]
  13685. name = ConvertToString(name, "gbk", "utf-8")
  13686. 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)
  13687. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13688. var dat map[string]interface{}
  13689. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13690. fmt.Println(dat)
  13691. } else {
  13692. fmt.Println(err)
  13693. }
  13694. userJSONBytes, _ := json.Marshal(dat)
  13695. var res ResultTwo
  13696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13697. utils.ErrorLog("解析失败:%v", err)
  13698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13699. return
  13700. }
  13701. if res.Infcode == 0 {
  13702. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13703. if err == gorm.ErrRecordNotFound {
  13704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13705. return
  13706. } else if err != nil {
  13707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13708. return
  13709. } else {
  13710. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13711. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13712. infoStr := string(Iinfos)
  13713. idetinfoStr := string(Idetinfos)
  13714. psn := &models.HisPsn{
  13715. PsnNo: res.Output.Baseinfo.PsnNo,
  13716. PatientId: patient.ID,
  13717. Certno: res.Output.Baseinfo.Certno,
  13718. Gend: res.Output.Baseinfo.Gend,
  13719. Naty: res.Output.Baseinfo.Naty,
  13720. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13721. PsnName: res.Output.Baseinfo.PsnName,
  13722. Idetinfo: idetinfoStr,
  13723. Insuinfo: infoStr,
  13724. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13725. CardInfo: basStr,
  13726. VerifyNumber: "",
  13727. }
  13728. service.CreateHisPsn(psn)
  13729. var rf []*ResultFive
  13730. json.Unmarshal([]byte(infoStr), &rf)
  13731. var insutypes []*ResultFive
  13732. var insutype string
  13733. var is390 int = 0
  13734. var is310 int = 0
  13735. for _, item := range rf {
  13736. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13737. insutypes = append(insutypes, item)
  13738. }
  13739. }
  13740. if len(insutypes) == 1 {
  13741. insutype = insutypes[0].Insutype
  13742. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13743. } else {
  13744. for _, i := range insutypes {
  13745. if i.Insutype == "390" {
  13746. is390 = 1
  13747. }
  13748. if i.Insutype == "310" {
  13749. is310 = 1
  13750. }
  13751. }
  13752. }
  13753. if is390 == 1 {
  13754. insutype = "390"
  13755. }
  13756. if is310 == 1 {
  13757. insutype = "310"
  13758. }
  13759. if len(insutypes) == 0 {
  13760. insutype = "310"
  13761. }
  13762. c.ServeSuccessJSON(map[string]interface{}{
  13763. "patient": patient,
  13764. "number": basNumber,
  13765. "insutype": insutype,
  13766. })
  13767. }
  13768. } else {
  13769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13770. return
  13771. }
  13772. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13773. var api string
  13774. 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 +
  13775. "&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
  13776. fmt.Println(api)
  13777. resp, requestErr := http.Get(api)
  13778. if requestErr != nil {
  13779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13780. return
  13781. }
  13782. body, ioErr := ioutil.ReadAll(resp.Body)
  13783. if ioErr != nil {
  13784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13786. return
  13787. }
  13788. var respJSON map[string]interface{}
  13789. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13792. return
  13793. }
  13794. var res ResultTwo //1101结果
  13795. var res10265 ResultTwo10265 //1101结果
  13796. var card_info string //卡信息
  13797. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13798. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13799. result, _ := json.Marshal(respJSON)
  13800. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13801. utils.ErrorLog("解析失败:%v", err)
  13802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13803. return
  13804. }
  13805. res.ErrMsg = res10265.ErrMsg
  13806. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13807. res.Infcode = infocode
  13808. res.Output = res10265.Output
  13809. res.InfRefmsgid = res10265.InfRefmsgid
  13810. if res.Infcode == 0 {
  13811. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13812. if err == gorm.ErrRecordNotFound {
  13813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13814. return
  13815. } else if err != nil {
  13816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13817. return
  13818. } else {
  13819. bas := strings.Split(card_info, "|")
  13820. basNumber := bas[2]
  13821. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13822. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13823. infoStr := string(Iinfos)
  13824. idetinfoStr := string(Idetinfos)
  13825. psn := &models.HisPsn{
  13826. PsnNo: res.Output.Baseinfo.PsnNo,
  13827. PatientId: patient.ID,
  13828. Certno: res.Output.Baseinfo.Certno,
  13829. Gend: res.Output.Baseinfo.Gend,
  13830. Naty: res.Output.Baseinfo.Naty,
  13831. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13832. PsnName: res.Output.Baseinfo.PsnName,
  13833. Idetinfo: idetinfoStr,
  13834. Insuinfo: infoStr,
  13835. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13836. CardInfo: card_info,
  13837. VerifyNumber: token,
  13838. }
  13839. service.CreateHisPsn(psn)
  13840. var rf []*ResultFive
  13841. json.Unmarshal([]byte(infoStr), &rf)
  13842. var insutypes []*ResultFive
  13843. var insutype string
  13844. var is390 int = 0
  13845. var is310 int = 0
  13846. for _, item := range rf {
  13847. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13848. insutypes = append(insutypes, item)
  13849. }
  13850. }
  13851. if len(insutypes) == 1 {
  13852. insutype = insutypes[0].Insutype
  13853. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13854. } else {
  13855. for _, i := range insutypes {
  13856. if i.Insutype == "390" {
  13857. is390 = 1
  13858. }
  13859. if i.Insutype == "310" {
  13860. is310 = 1
  13861. }
  13862. }
  13863. }
  13864. if is390 == 1 {
  13865. insutype = "390"
  13866. }
  13867. if is310 == 1 {
  13868. insutype = "310"
  13869. }
  13870. if len(insutypes) == 0 {
  13871. insutype = "310"
  13872. }
  13873. c.ServeSuccessJSON(map[string]interface{}{
  13874. "patient": patient,
  13875. "number": basNumber,
  13876. "insutype": insutype,
  13877. })
  13878. }
  13879. } else {
  13880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13881. return
  13882. }
  13883. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13884. res := c.GetoleInfo()
  13885. if res.Infcode == 0 {
  13886. var result string
  13887. if res.Output.MdtrtCertType == "01" {
  13888. 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)
  13889. } else if res.Output.MdtrtCertType == "02" {
  13890. 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)
  13891. } else if res.Output.MdtrtCertType == "03" {
  13892. 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)
  13893. }
  13894. var dat map[string]interface{}
  13895. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13896. fmt.Println(dat)
  13897. } else {
  13898. fmt.Println(err)
  13899. }
  13900. userJSONBytes, _ := json.Marshal(dat)
  13901. var res2 ResultTwo
  13902. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13903. utils.ErrorLog("解析失败:%v", err)
  13904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13905. return
  13906. }
  13907. if res2.Infcode == 0 {
  13908. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13909. if err == gorm.ErrRecordNotFound {
  13910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13911. return
  13912. } else if err != nil {
  13913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13914. return
  13915. } else {
  13916. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13917. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13918. infoStr := string(Iinfos)
  13919. idetinfoStr := string(Idetinfos)
  13920. var rf []*ResultFive
  13921. json.Unmarshal([]byte(infoStr), &rf)
  13922. var insutypes []*ResultFive
  13923. var insutype string
  13924. var is390 int = 0
  13925. var is310 int = 0
  13926. //var insuplc_admdvs string
  13927. for _, item := range rf {
  13928. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13929. insutypes = append(insutypes, item)
  13930. }
  13931. }
  13932. if len(insutypes) == 1 {
  13933. insutype = insutypes[0].Insutype
  13934. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13935. } else {
  13936. for _, i := range insutypes {
  13937. if i.Insutype == "390" {
  13938. is390 = 1
  13939. }
  13940. if i.Insutype == "310" {
  13941. is310 = 1
  13942. }
  13943. }
  13944. }
  13945. if is390 == 1 {
  13946. insutype = "390"
  13947. }
  13948. if is310 == 1 {
  13949. insutype = "310"
  13950. }
  13951. if len(insutypes) == 0 {
  13952. insutype = "310"
  13953. }
  13954. psn := &models.HisPsn{
  13955. PsnNo: res2.Output.Baseinfo.PsnNo,
  13956. PatientId: patient.ID,
  13957. Certno: res2.Output.Baseinfo.Certno,
  13958. Gend: res2.Output.Baseinfo.Gend,
  13959. Naty: res2.Output.Baseinfo.Naty,
  13960. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13961. PsnName: res2.Output.Baseinfo.PsnName,
  13962. Idetinfo: idetinfoStr,
  13963. Insuinfo: infoStr,
  13964. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13965. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13966. VerifyNumber: res.Output.EcToken,
  13967. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13968. }
  13969. if res.Output.MdtrtCertType == "01" {
  13970. psn.VerifyNumber = res.Output.EcToken
  13971. //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)
  13972. } else if res.Output.MdtrtCertType == "02" {
  13973. psn.VerifyNumber = res.Output.MdtrtCertNo
  13974. //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)
  13975. } else if res.Output.MdtrtCertType == "03" {
  13976. psn.VerifyNumber = res.Output.MdtrtCertNo
  13977. //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)
  13978. }
  13979. var balc float64
  13980. for _, item := range rf {
  13981. if item.Insutype == insutype {
  13982. balc = item.Balc
  13983. }
  13984. }
  13985. service.CreateHisPsn(psn)
  13986. c.ServeSuccessJSON(map[string]interface{}{
  13987. "patient": patient,
  13988. "number": res.Output.CardNo,
  13989. "insutype": insutype,
  13990. "blac": balc,
  13991. "desc": idetinfoStr,
  13992. })
  13993. }
  13994. } else {
  13995. c.ServeSuccessJSON(map[string]interface{}{
  13996. "failed_code": -10,
  13997. "msg": res2.ErrMsg,
  13998. })
  13999. }
  14000. } else {
  14001. c.ServeSuccessJSON(map[string]interface{}{
  14002. "failed_code": -10,
  14003. "msg": res.ErrMsg,
  14004. })
  14005. }
  14006. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14007. var api string
  14008. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14009. "&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
  14010. fmt.Println(api)
  14011. resp, requestErr := http.Get(api)
  14012. if requestErr != nil {
  14013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14014. return
  14015. }
  14016. body, ioErr := ioutil.ReadAll(resp.Body)
  14017. if ioErr != nil {
  14018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14020. return
  14021. }
  14022. var respJSON map[string]interface{}
  14023. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14026. return
  14027. }
  14028. var status string
  14029. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14030. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14031. //console.log()
  14032. fmt.Println("type===")
  14033. fmt.Println(card_type)
  14034. var token string
  14035. var res ResultTwo //1101结果
  14036. //var res10265 ResultTwoesultTwo10265 //1101结果
  14037. var card_info string //卡信息
  14038. var busi_card_info string
  14039. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14040. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14041. if status == "0" { //读卡成功
  14042. if card_type == "1" {
  14043. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14044. result, _ := json.Marshal(respJSON)
  14045. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14046. utils.ErrorLog("解析失败:%v", err)
  14047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14048. return
  14049. }
  14050. } else {
  14051. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14052. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14053. result, _ := json.Marshal(respJSON)
  14054. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14055. utils.ErrorLog("解析失败:%v", err)
  14056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14057. return
  14058. }
  14059. }
  14060. if res.Infcode == 0 {
  14061. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14062. if err == gorm.ErrRecordNotFound {
  14063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14064. return
  14065. } else if err != nil {
  14066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14067. return
  14068. } else {
  14069. if card_type == "1" {
  14070. bas := strings.Split(card_info, "|")
  14071. basNumber := bas[2]
  14072. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14073. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14074. infoStr := string(Iinfos)
  14075. idetinfoStr := string(Idetinfos)
  14076. psn := &models.HisPsn{
  14077. PsnNo: res.Output.Baseinfo.PsnNo,
  14078. PatientId: patient.ID,
  14079. Certno: res.Output.Baseinfo.Certno,
  14080. Gend: res.Output.Baseinfo.Gend,
  14081. Naty: res.Output.Baseinfo.Naty,
  14082. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14083. PsnName: res.Output.Baseinfo.PsnName,
  14084. Idetinfo: idetinfoStr,
  14085. Insuinfo: infoStr,
  14086. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14087. CardInfo: card_info,
  14088. VerifyNumber: busi_card_info,
  14089. }
  14090. service.CreateHisPsn(psn)
  14091. var rf []*ResultFive
  14092. json.Unmarshal([]byte(infoStr), &rf)
  14093. var insutypes []*ResultFive
  14094. var insutype string
  14095. var is390 int = 0
  14096. var is310 int = 0
  14097. for _, item := range rf {
  14098. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14099. insutypes = append(insutypes, item)
  14100. }
  14101. }
  14102. if len(insutypes) == 1 {
  14103. insutype = insutypes[0].Insutype
  14104. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14105. } else {
  14106. for _, i := range insutypes {
  14107. if i.Insutype == "390" {
  14108. is390 = 1
  14109. }
  14110. if i.Insutype == "310" {
  14111. is310 = 1
  14112. }
  14113. }
  14114. }
  14115. if is390 == 1 {
  14116. insutype = "390"
  14117. }
  14118. if is310 == 1 {
  14119. insutype = "310"
  14120. }
  14121. if len(insutypes) == 0 {
  14122. insutype = "310"
  14123. }
  14124. c.ServeSuccessJSON(map[string]interface{}{
  14125. "patient": patient,
  14126. "number": basNumber,
  14127. "insutype": insutype,
  14128. })
  14129. } else {
  14130. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14131. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14132. infoStr := string(Iinfos)
  14133. idetinfoStr := string(Idetinfos)
  14134. psn := &models.HisPsn{
  14135. PsnNo: res.Output.Baseinfo.PsnNo,
  14136. PatientId: patient.ID,
  14137. Certno: res.Output.Baseinfo.Certno,
  14138. Gend: res.Output.Baseinfo.Gend,
  14139. Naty: res.Output.Baseinfo.Naty,
  14140. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14141. PsnName: res.Output.Baseinfo.PsnName,
  14142. Idetinfo: idetinfoStr,
  14143. Insuinfo: infoStr,
  14144. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14145. CardInfo: card_info,
  14146. VerifyNumber: token,
  14147. }
  14148. service.CreateHisPsn(psn)
  14149. c.ServeSuccessJSON(map[string]interface{}{
  14150. "patient": patient,
  14151. "number": token,
  14152. })
  14153. }
  14154. }
  14155. } else {
  14156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14157. return
  14158. }
  14159. } else { //读卡失败
  14160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14161. return
  14162. }
  14163. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14164. var api string
  14165. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14166. "&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
  14167. fmt.Println(api)
  14168. resp, requestErr := http.Get(api)
  14169. if requestErr != nil {
  14170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14171. return
  14172. }
  14173. body, ioErr := ioutil.ReadAll(resp.Body)
  14174. if ioErr != nil {
  14175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14177. return
  14178. }
  14179. var respJSON map[string]interface{}
  14180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14183. return
  14184. }
  14185. var status string
  14186. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14187. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14188. //console.log()
  14189. fmt.Println("type===")
  14190. fmt.Println(card_type)
  14191. var token string
  14192. var res ResultTwo //1101结果
  14193. //var res10265 ResultTwoesultTwo10265 //1101结果
  14194. var card_info string //卡信息
  14195. //var busi_card_info string
  14196. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14197. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14198. if status == "0" { //读卡成功
  14199. if card_type == "1" {
  14200. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14201. result, _ := json.Marshal(respJSON)
  14202. fmt.Println(result)
  14203. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14204. utils.ErrorLog("解析失败:%v", err)
  14205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14206. return
  14207. }
  14208. fmt.Println(res)
  14209. } else {
  14210. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14211. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14212. result, _ := json.Marshal(respJSON)
  14213. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14214. utils.ErrorLog("解析失败:%v", err)
  14215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14216. return
  14217. }
  14218. }
  14219. if res.Infcode == 0 {
  14220. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14221. if err == gorm.ErrRecordNotFound {
  14222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14223. return
  14224. } else if err != nil {
  14225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14226. return
  14227. } else {
  14228. if card_type == "1" {
  14229. bas := strings.Split(card_info, "|")
  14230. basNumber := bas[2]
  14231. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14232. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14233. infoStr := string(Iinfos)
  14234. idetinfoStr := string(Idetinfos)
  14235. psn := &models.HisPsn{
  14236. PsnNo: res.Output.Baseinfo.PsnNo,
  14237. PatientId: patient.ID,
  14238. Certno: res.Output.Baseinfo.Certno,
  14239. Gend: res.Output.Baseinfo.Gend,
  14240. Naty: res.Output.Baseinfo.Naty,
  14241. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14242. PsnName: res.Output.Baseinfo.PsnName,
  14243. Idetinfo: idetinfoStr,
  14244. Insuinfo: infoStr,
  14245. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14246. CardInfo: card_info,
  14247. //VerifyNumber: busi_card_info,
  14248. }
  14249. service.CreateHisPsn(psn)
  14250. var rf []*ResultFive
  14251. json.Unmarshal([]byte(infoStr), &rf)
  14252. var insutypes []*ResultFive
  14253. var insutype string
  14254. var is390 int = 0
  14255. var is310 int = 0
  14256. for _, item := range rf {
  14257. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14258. insutypes = append(insutypes, item)
  14259. }
  14260. }
  14261. if len(insutypes) == 1 {
  14262. insutype = insutypes[0].Insutype
  14263. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14264. } else {
  14265. for _, i := range insutypes {
  14266. if i.Insutype == "390" {
  14267. is390 = 1
  14268. }
  14269. if i.Insutype == "310" {
  14270. is310 = 1
  14271. }
  14272. }
  14273. }
  14274. if is390 == 1 {
  14275. insutype = "390"
  14276. }
  14277. if is310 == 1 {
  14278. insutype = "310"
  14279. }
  14280. if len(insutypes) == 0 {
  14281. insutype = "310"
  14282. }
  14283. c.ServeSuccessJSON(map[string]interface{}{
  14284. "patient": patient,
  14285. "number": basNumber,
  14286. "insutype": insutype,
  14287. })
  14288. } else {
  14289. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14290. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14291. infoStr := string(Iinfos)
  14292. idetinfoStr := string(Idetinfos)
  14293. psn := &models.HisPsn{
  14294. PsnNo: res.Output.Baseinfo.PsnNo,
  14295. PatientId: patient.ID,
  14296. Certno: res.Output.Baseinfo.Certno,
  14297. Gend: res.Output.Baseinfo.Gend,
  14298. Naty: res.Output.Baseinfo.Naty,
  14299. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14300. PsnName: res.Output.Baseinfo.PsnName,
  14301. Idetinfo: idetinfoStr,
  14302. Insuinfo: infoStr,
  14303. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14304. CardInfo: card_info,
  14305. VerifyNumber: token,
  14306. }
  14307. service.CreateHisPsn(psn)
  14308. c.ServeSuccessJSON(map[string]interface{}{
  14309. "patient": patient,
  14310. "number": token,
  14311. })
  14312. }
  14313. }
  14314. } else {
  14315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14316. return
  14317. }
  14318. } else { //读卡失败
  14319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14320. return
  14321. }
  14322. } else {
  14323. if initFlag == 0 {
  14324. c.TestGetBasBaseInit()
  14325. }
  14326. basStr := c.GetBasBaseInfo()
  14327. if len(basStr) == 0 {
  14328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14329. return
  14330. }
  14331. fmt.Println(basStr)
  14332. bas := strings.Split(basStr, "|")
  14333. basNumber := bas[1]
  14334. fmt.Println(basNumber)
  14335. card_sn := bas[3]
  14336. fmt.Println(card_sn)
  14337. cardNumber := bas[2]
  14338. fmt.Println(cardNumber)
  14339. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14340. var result string
  14341. if bas[0][:2] == "44" {
  14342. 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)
  14343. } else {
  14344. 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)
  14345. }
  14346. var dat map[string]interface{}
  14347. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14348. fmt.Println(dat)
  14349. } else {
  14350. fmt.Println(err)
  14351. }
  14352. userJSONBytes, _ := json.Marshal(dat)
  14353. var res ResultTwo
  14354. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14355. utils.ErrorLog("解析失败:%v", err)
  14356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14357. return
  14358. }
  14359. if res.Infcode == 0 {
  14360. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14361. if err == gorm.ErrRecordNotFound {
  14362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14363. return
  14364. } else if err != nil {
  14365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14366. return
  14367. } else {
  14368. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14369. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14370. infoStr := string(Iinfos)
  14371. idetinfoStr := string(Idetinfos)
  14372. var rf []*ResultFive
  14373. json.Unmarshal([]byte(infoStr), &rf)
  14374. var insutypes []*ResultFive
  14375. var insutype string
  14376. var is390 int = 0
  14377. var is310 int = 0
  14378. var insuplc_admdvs string
  14379. for _, item := range rf {
  14380. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14381. insutypes = append(insutypes, item)
  14382. }
  14383. }
  14384. if len(insutypes) == 1 {
  14385. insutype = insutypes[0].Insutype
  14386. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14387. } else {
  14388. for _, i := range insutypes {
  14389. if i.Insutype == "390" {
  14390. is390 = 1
  14391. }
  14392. if i.Insutype == "310" {
  14393. is310 = 1
  14394. }
  14395. }
  14396. }
  14397. if is390 == 1 {
  14398. insutype = "390"
  14399. }
  14400. if is310 == 1 {
  14401. insutype = "310"
  14402. }
  14403. if len(insutypes) == 0 {
  14404. insutype = "310"
  14405. }
  14406. for _, item := range rf {
  14407. if item.Insutype == insutype {
  14408. insuplc_admdvs = item.InsuplcAdmdvs
  14409. }
  14410. }
  14411. psn := &models.HisPsn{
  14412. PsnNo: res.Output.Baseinfo.PsnNo,
  14413. PatientId: patient.ID,
  14414. Certno: res.Output.Baseinfo.Certno,
  14415. Gend: res.Output.Baseinfo.Gend,
  14416. Naty: res.Output.Baseinfo.Naty,
  14417. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14418. PsnName: res.Output.Baseinfo.PsnName,
  14419. Idetinfo: idetinfoStr,
  14420. Insuinfo: infoStr,
  14421. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14422. CardInfo: basStr,
  14423. VerifyNumber: "",
  14424. InsuplcAdmdvs: insuplc_admdvs,
  14425. }
  14426. service.CreateHisPsn(psn)
  14427. c.ServeSuccessJSON(map[string]interface{}{
  14428. "patient": patient,
  14429. "number": basNumber,
  14430. })
  14431. }
  14432. } else {
  14433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14434. return
  14435. }
  14436. break
  14437. }
  14438. case 2:
  14439. if miConfig.MdtrtareaAdmvs == "430800" {
  14440. if initFlag == 0 {
  14441. c.TestGetHnBasBaseInit()
  14442. }
  14443. SFZStr := c.GetSFZBaseInfo()
  14444. if len(SFZStr) == 0 {
  14445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14446. return
  14447. }
  14448. fmt.Println(SFZStr)
  14449. id_card_str := strings.Split(SFZStr, "^")
  14450. card_no := id_card_str[0]
  14451. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14452. //name := id_card_str[1]
  14453. //name = ConvertToString(name, "gbk", "utf-8")
  14454. 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)
  14455. var dat map[string]interface{}
  14456. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14457. fmt.Println(dat)
  14458. } else {
  14459. fmt.Println(err)
  14460. }
  14461. userJSONBytes, _ := json.Marshal(dat)
  14462. var res ResultTwo
  14463. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14464. utils.ErrorLog("解析失败:%v", err)
  14465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14466. return
  14467. }
  14468. if res.Infcode == 0 {
  14469. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14470. if err == gorm.ErrRecordNotFound {
  14471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14472. return
  14473. } else if err != nil {
  14474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14475. return
  14476. } else {
  14477. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14478. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14479. infoStr := string(Iinfos)
  14480. idetinfoStr := string(Idetinfos)
  14481. var rf []*ResultFive
  14482. json.Unmarshal([]byte(infoStr), &rf)
  14483. var insutypes []*ResultFive
  14484. var insutype string
  14485. var is390 int = 0
  14486. var is310 int = 0
  14487. for _, item := range rf {
  14488. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14489. insutypes = append(insutypes, item)
  14490. }
  14491. }
  14492. if len(insutypes) == 1 {
  14493. insutype = insutypes[0].Insutype
  14494. } else {
  14495. for _, i := range insutypes {
  14496. if i.Insutype == "390" {
  14497. is390 = 1
  14498. }
  14499. if i.Insutype == "310" {
  14500. is310 = 1
  14501. }
  14502. }
  14503. }
  14504. if is390 == 1 {
  14505. insutype = "390"
  14506. }
  14507. if is310 == 1 {
  14508. insutype = "310"
  14509. }
  14510. if len(insutypes) == 0 {
  14511. insutype = "310"
  14512. }
  14513. var InsuplcAdmdvs string
  14514. for _, item := range rf {
  14515. if item.Insutype == insutype {
  14516. InsuplcAdmdvs = item.InsuplcAdmdvs
  14517. }
  14518. }
  14519. psn := &models.HisPsn{
  14520. PsnNo: res.Output.Baseinfo.PsnNo,
  14521. PatientId: patient.ID,
  14522. Certno: res.Output.Baseinfo.Certno,
  14523. Gend: res.Output.Baseinfo.Gend,
  14524. Naty: res.Output.Baseinfo.Naty,
  14525. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14526. PsnName: res.Output.Baseinfo.PsnName,
  14527. Idetinfo: idetinfoStr,
  14528. Insuinfo: infoStr,
  14529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14530. CardInfo: SFZStr,
  14531. VerifyNumber: "",
  14532. InsuplcAdmdvs: InsuplcAdmdvs,
  14533. }
  14534. service.CreateHisPsn(psn)
  14535. c.ServeSuccessJSON(map[string]interface{}{
  14536. "patient": patient,
  14537. "number": card_no,
  14538. "insutype": insutype,
  14539. })
  14540. }
  14541. } else {
  14542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14543. return
  14544. }
  14545. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14546. var res ResultTwo
  14547. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14548. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14549. "&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)
  14550. resp, requestErr := http.Get(api)
  14551. if requestErr != nil {
  14552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14553. return
  14554. }
  14555. body, ioErr := ioutil.ReadAll(resp.Body)
  14556. if ioErr != nil {
  14557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14559. return
  14560. }
  14561. var respJSON map[string]interface{}
  14562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14565. return
  14566. }
  14567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14568. result, _ := json.Marshal(respJSON)
  14569. fmt.Println("log")
  14570. fmt.Println(string(result))
  14571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14572. utils.ErrorLog("解析失败:%v", err)
  14573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14574. return
  14575. }
  14576. if res.Infcode == 0 {
  14577. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14578. if err == gorm.ErrRecordNotFound {
  14579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14580. return
  14581. } else if err != nil {
  14582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14583. return
  14584. } else {
  14585. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14586. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14587. infoStr := string(Iinfos)
  14588. idetinfoStr := string(Idetinfos)
  14589. psn := &models.HisPsn{
  14590. PsnNo: res.Output.Baseinfo.PsnNo,
  14591. PatientId: patient.ID,
  14592. Certno: res.Output.Baseinfo.Certno,
  14593. Gend: res.Output.Baseinfo.Gend,
  14594. Naty: res.Output.Baseinfo.Naty,
  14595. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14596. PsnName: res.Output.Baseinfo.PsnName,
  14597. Idetinfo: idetinfoStr,
  14598. Insuinfo: infoStr,
  14599. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14600. }
  14601. service.CreateHisPsn(psn)
  14602. c.ServeSuccessJSON(map[string]interface{}{
  14603. "patient": patient,
  14604. "number": res.Output.Baseinfo.Certno,
  14605. })
  14606. }
  14607. } else {
  14608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14609. return
  14610. }
  14611. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14612. var res ResultTwo
  14613. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14614. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14615. "&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)
  14616. resp, requestErr := http.Get(api)
  14617. if requestErr != nil {
  14618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14619. return
  14620. }
  14621. body, ioErr := ioutil.ReadAll(resp.Body)
  14622. if ioErr != nil {
  14623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14625. return
  14626. }
  14627. var respJSON map[string]interface{}
  14628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14631. return
  14632. }
  14633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14634. result, _ := json.Marshal(respJSON)
  14635. fmt.Println("log")
  14636. fmt.Println(string(result))
  14637. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14638. utils.ErrorLog("解析失败:%v", err)
  14639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14640. return
  14641. }
  14642. if res.Infcode == 0 {
  14643. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14644. if err == gorm.ErrRecordNotFound {
  14645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14646. return
  14647. } else if err != nil {
  14648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14649. return
  14650. } else {
  14651. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14652. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14653. infoStr := string(Iinfos)
  14654. idetinfoStr := string(Idetinfos)
  14655. psn := &models.HisPsn{
  14656. PsnNo: res.Output.Baseinfo.PsnNo,
  14657. PatientId: patient.ID,
  14658. Certno: res.Output.Baseinfo.Certno,
  14659. Gend: res.Output.Baseinfo.Gend,
  14660. Naty: res.Output.Baseinfo.Naty,
  14661. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14662. PsnName: res.Output.Baseinfo.PsnName,
  14663. Idetinfo: idetinfoStr,
  14664. Insuinfo: infoStr,
  14665. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14666. }
  14667. service.CreateHisPsn(psn)
  14668. c.ServeSuccessJSON(map[string]interface{}{
  14669. "patient": patient,
  14670. "number": res.Output.Baseinfo.Certno,
  14671. })
  14672. }
  14673. } else {
  14674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14675. return
  14676. }
  14677. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14678. var res ResultTwo
  14679. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14680. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14681. "&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)
  14682. resp, requestErr := http.Get(api)
  14683. if requestErr != nil {
  14684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14685. return
  14686. }
  14687. body, ioErr := ioutil.ReadAll(resp.Body)
  14688. if ioErr != nil {
  14689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14691. return
  14692. }
  14693. var respJSON map[string]interface{}
  14694. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14697. return
  14698. }
  14699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14700. result, _ := json.Marshal(respJSON)
  14701. fmt.Println("log")
  14702. fmt.Println(string(result))
  14703. if err := json.Unmarshal([]byte(result), &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.GetPatientByIDCard(res.Output.Baseinfo.Certno, 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. for _, item := range rf {
  14728. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14729. insutypes = append(insutypes, item)
  14730. }
  14731. }
  14732. if len(insutypes) == 1 {
  14733. insutype = insutypes[0].Insutype
  14734. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14735. } else {
  14736. for _, i := range insutypes {
  14737. if i.Insutype == "390" {
  14738. is390 = 1
  14739. }
  14740. if i.Insutype == "310" {
  14741. is310 = 1
  14742. }
  14743. }
  14744. }
  14745. if is390 == 1 {
  14746. insutype = "390"
  14747. }
  14748. if is310 == 1 {
  14749. insutype = "310"
  14750. }
  14751. if len(insutypes) == 0 {
  14752. insutype = "390"
  14753. }
  14754. var insuplc_admdvs string
  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. InsuplcAdmdvs: insuplc_admdvs,
  14772. }
  14773. service.CreateHisPsn(psn)
  14774. c.ServeSuccessJSON(map[string]interface{}{
  14775. "patient": patient,
  14776. "number": res.Output.Baseinfo.Certno,
  14777. })
  14778. }
  14779. } else {
  14780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14781. return
  14782. }
  14783. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14784. res := c.GetoleInfo()
  14785. if res.Infcode == 0 {
  14786. var result string
  14787. if res.Output.MdtrtCertType == "01" {
  14788. 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)
  14789. } else if res.Output.MdtrtCertType == "02" {
  14790. 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)
  14791. } else if res.Output.MdtrtCertType == "03" {
  14792. 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)
  14793. }
  14794. var dat map[string]interface{}
  14795. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14796. fmt.Println(dat)
  14797. } else {
  14798. fmt.Println(err)
  14799. }
  14800. userJSONBytes, _ := json.Marshal(dat)
  14801. var res2 ResultTwo
  14802. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14803. utils.ErrorLog("解析失败:%v", err)
  14804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14805. return
  14806. }
  14807. if res2.Infcode == 0 {
  14808. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14809. if err == gorm.ErrRecordNotFound {
  14810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14811. return
  14812. } else if err != nil {
  14813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14814. return
  14815. } else {
  14816. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14817. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14818. infoStr := string(Iinfos)
  14819. idetinfoStr := string(Idetinfos)
  14820. var rf []*ResultFive
  14821. json.Unmarshal([]byte(infoStr), &rf)
  14822. var insutypes []*ResultFive
  14823. var insutype string
  14824. var is390 int = 0
  14825. var is310 int = 0
  14826. //var insuplc_admdvs string
  14827. for _, item := range rf {
  14828. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14829. insutypes = append(insutypes, item)
  14830. }
  14831. }
  14832. if len(insutypes) == 1 {
  14833. insutype = insutypes[0].Insutype
  14834. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14835. } else {
  14836. for _, i := range insutypes {
  14837. if i.Insutype == "390" {
  14838. is390 = 1
  14839. }
  14840. if i.Insutype == "310" {
  14841. is310 = 1
  14842. }
  14843. }
  14844. }
  14845. if is390 == 1 {
  14846. insutype = "390"
  14847. }
  14848. if is310 == 1 {
  14849. insutype = "310"
  14850. }
  14851. if len(insutypes) == 0 {
  14852. insutype = "310"
  14853. }
  14854. psn := &models.HisPsn{
  14855. PsnNo: res2.Output.Baseinfo.PsnNo,
  14856. PatientId: patient.ID,
  14857. //Brdy: res2.Output.Baseinfo.Brdy,
  14858. Certno: res2.Output.Baseinfo.Certno,
  14859. Gend: res2.Output.Baseinfo.Gend,
  14860. Naty: res2.Output.Baseinfo.Naty,
  14861. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14862. PsnName: res2.Output.Baseinfo.PsnName,
  14863. Idetinfo: idetinfoStr,
  14864. Insuinfo: infoStr,
  14865. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14866. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14867. VerifyNumber: res.Output.EcToken,
  14868. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14869. }
  14870. service.CreateHisPsn(psn)
  14871. var balc float64
  14872. for _, item := range rf {
  14873. if item.Insutype == insutype {
  14874. balc = item.Balc
  14875. }
  14876. }
  14877. c.ServeSuccessJSON(map[string]interface{}{
  14878. "patient": patient,
  14879. "number": res.Output.CardNo,
  14880. "insutype": insutype,
  14881. "blac": balc,
  14882. "desc": idetinfoStr,
  14883. })
  14884. }
  14885. } else {
  14886. c.ServeSuccessJSON(map[string]interface{}{
  14887. "failed_code": -10,
  14888. "msg": res2.ErrMsg,
  14889. })
  14890. }
  14891. } else {
  14892. c.ServeSuccessJSON(map[string]interface{}{
  14893. "failed_code": -10,
  14894. "msg": res.ErrMsg,
  14895. })
  14896. }
  14897. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14898. var insuplc_admdvs string
  14899. if len(patient.InsuplcAdmdvs) > 0 {
  14900. insuplc_admdvs = patient.InsuplcAdmdvs
  14901. } else {
  14902. if len(insuplc_admdvs_str) > 0 {
  14903. insuplc_admdvs = insuplc_admdvs_str
  14904. } else {
  14905. insuplc_admdvs = miConfig.InsuplcAdmdvs
  14906. }
  14907. }
  14908. //请求内网数据
  14909. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  14910. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14911. "&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=" + ""
  14912. resp, requestErr := http.Get(api)
  14913. if requestErr != nil {
  14914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14915. return
  14916. }
  14917. body, ioErr := ioutil.ReadAll(resp.Body)
  14918. if ioErr != nil {
  14919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14921. return
  14922. }
  14923. var respJSON map[string]interface{}
  14924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14927. return
  14928. }
  14929. status := respJSON["data"].(map[string]interface{})["status"].(string)
  14930. if status == "0" {
  14931. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  14932. c.ServeSuccessJSON(map[string]interface{}{
  14933. "failed_code": -10,
  14934. "msg": err_msg,
  14935. })
  14936. return
  14937. }
  14938. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14939. var res ResultTwo
  14940. result, _ := json.Marshal(respJSON)
  14941. fmt.Println("log")
  14942. fmt.Println(string(result))
  14943. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14944. utils.ErrorLog("解析失败:%v", err)
  14945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14946. return
  14947. }
  14948. if res.Infcode == 0 {
  14949. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14950. if err == gorm.ErrRecordNotFound {
  14951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14952. return
  14953. } else if err != nil {
  14954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14955. return
  14956. } else {
  14957. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14958. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14959. infoStr := string(Iinfos)
  14960. idetinfoStr := string(Idetinfos)
  14961. psn := &models.HisPsn{
  14962. PsnNo: res.Output.Baseinfo.PsnNo,
  14963. PatientId: patient.ID,
  14964. Certno: res.Output.Baseinfo.Certno,
  14965. Gend: res.Output.Baseinfo.Gend,
  14966. Naty: res.Output.Baseinfo.Naty,
  14967. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14968. PsnName: res.Output.Baseinfo.PsnName,
  14969. Idetinfo: idetinfoStr,
  14970. Insuinfo: infoStr,
  14971. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14972. }
  14973. service.CreateHisPsn(psn)
  14974. var rf []*ResultFive
  14975. json.Unmarshal([]byte(infoStr), &rf)
  14976. var insutypes []*ResultFive
  14977. var is390 int = 0
  14978. var is310 int = 0
  14979. var insutype string
  14980. for _, item := range rf {
  14981. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14982. insutypes = append(insutypes, item)
  14983. }
  14984. }
  14985. if len(insutypes) == 1 {
  14986. insutype = insutypes[0].Insutype
  14987. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14988. } else {
  14989. for _, i := range insutypes {
  14990. if i.Insutype == "390" {
  14991. is390 = 1
  14992. }
  14993. if i.Insutype == "310" {
  14994. is310 = 1
  14995. }
  14996. }
  14997. }
  14998. if is390 == 1 {
  14999. insutype = "390"
  15000. }
  15001. if is310 == 1 {
  15002. insutype = "310"
  15003. }
  15004. if len(insutypes) == 0 {
  15005. insutype = "390"
  15006. }
  15007. c.ServeSuccessJSON(map[string]interface{}{
  15008. "patient": patient,
  15009. "insutype": insutype,
  15010. "number": res.Output.Baseinfo.Certno,
  15011. "info": res,
  15012. })
  15013. }
  15014. } else {
  15015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15016. return
  15017. }
  15018. } else {
  15019. SFZStr := c.GetSFZBaseInfo()
  15020. id_card_str := strings.Split(SFZStr, "^")
  15021. id_card_number := id_card_str[0]
  15022. card_sn := ""
  15023. 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)
  15024. var dat map[string]interface{}
  15025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15026. fmt.Println(dat)
  15027. } else {
  15028. fmt.Println(err)
  15029. }
  15030. userJSONBytes, _ := json.Marshal(dat)
  15031. var res ResultTwo
  15032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15033. utils.ErrorLog("解析失败:%v", err)
  15034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15035. return
  15036. }
  15037. if res.Infcode == 0 {
  15038. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15039. if err == gorm.ErrRecordNotFound {
  15040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15041. return
  15042. } else if err != nil {
  15043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15044. return
  15045. } else {
  15046. c.ServeSuccessJSON(map[string]interface{}{
  15047. "patient": patient,
  15048. "number": id_card_number,
  15049. })
  15050. }
  15051. } else {
  15052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15053. return
  15054. }
  15055. }
  15056. break
  15057. case 3:
  15058. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15059. var api string
  15060. if miConfig.MdtrtareaAdmvs == "320921" {
  15061. 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 +
  15062. "&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
  15063. fmt.Println(api)
  15064. } else {
  15065. 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 +
  15066. "&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)
  15067. }
  15068. resp, requestErr := http.Get(api)
  15069. if requestErr != nil {
  15070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15071. return
  15072. }
  15073. body, ioErr := ioutil.ReadAll(resp.Body)
  15074. if ioErr != nil {
  15075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15077. return
  15078. }
  15079. var respJSON map[string]interface{}
  15080. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15083. return
  15084. }
  15085. var status string
  15086. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15087. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15088. var token string
  15089. var res ResultTwo //1101结果
  15090. var res10265 ResultTwo10265 //1101结果
  15091. var card_info string //卡信息
  15092. var busi_card_info string
  15093. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15094. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15095. if status == "0" { //读卡成功
  15096. if card_type == "1" {
  15097. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15098. result, _ := json.Marshal(respJSON)
  15099. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15100. utils.ErrorLog("解析失败:%v", err)
  15101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15102. return
  15103. }
  15104. res.ErrMsg = res10265.ErrMsg
  15105. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15106. res.Infcode = infocode
  15107. res.Output = res10265.Output
  15108. res.InfRefmsgid = res10265.InfRefmsgid
  15109. } else {
  15110. //var card_info string //卡信息
  15111. //var busi_card_info string
  15112. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15113. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15114. //fmt.Println(card_info)
  15115. //fmt.Println(busi_card_info)
  15116. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15117. result, _ := json.Marshal(respJSON)
  15118. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15119. utils.ErrorLog("解析失败:%v", err)
  15120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15121. return
  15122. }
  15123. res.ErrMsg = res10265.ErrMsg
  15124. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15125. res.Infcode = infocode
  15126. res.Output = res10265.Output
  15127. res.InfRefmsgid = res10265.InfRefmsgid
  15128. }
  15129. if res.Infcode == 0 {
  15130. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15131. if err == gorm.ErrRecordNotFound {
  15132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15133. return
  15134. } else if err != nil {
  15135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15136. return
  15137. } else {
  15138. if card_type == "1" {
  15139. bas := strings.Split(card_info, "|")
  15140. basNumber := bas[2]
  15141. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15142. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15143. infoStr := string(Iinfos)
  15144. idetinfoStr := string(Idetinfos)
  15145. psn := &models.HisPsn{
  15146. PsnNo: res.Output.Baseinfo.PsnNo,
  15147. PatientId: patient.ID,
  15148. Certno: res.Output.Baseinfo.Certno,
  15149. //Brdy: res.Output.Baseinfo.Brdy,
  15150. Gend: res.Output.Baseinfo.Gend,
  15151. Naty: res.Output.Baseinfo.Naty,
  15152. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15153. PsnName: res.Output.Baseinfo.PsnName,
  15154. Idetinfo: idetinfoStr,
  15155. Insuinfo: infoStr,
  15156. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15157. CardInfo: card_info,
  15158. VerifyNumber: busi_card_info,
  15159. }
  15160. service.CreateHisPsn(psn)
  15161. c.ServeSuccessJSON(map[string]interface{}{
  15162. "patient": patient,
  15163. "number": basNumber,
  15164. })
  15165. } else {
  15166. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15167. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15168. infoStr := string(Iinfos)
  15169. idetinfoStr := string(Idetinfos)
  15170. psn := &models.HisPsn{
  15171. PsnNo: res.Output.Baseinfo.PsnNo,
  15172. PatientId: patient.ID,
  15173. Certno: res.Output.Baseinfo.Certno,
  15174. Gend: res.Output.Baseinfo.Gend,
  15175. Naty: res.Output.Baseinfo.Naty,
  15176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15177. PsnName: res.Output.Baseinfo.PsnName,
  15178. Idetinfo: idetinfoStr,
  15179. Insuinfo: infoStr,
  15180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15181. CardInfo: card_info,
  15182. VerifyNumber: token,
  15183. }
  15184. service.CreateHisPsn(psn)
  15185. var rf []*ResultFive
  15186. json.Unmarshal([]byte(infoStr), &rf)
  15187. var insutypes []*ResultFive
  15188. var insutype string
  15189. var is390 int = 0
  15190. var is310 int = 0
  15191. for _, item := range rf {
  15192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15193. insutypes = append(insutypes, item)
  15194. }
  15195. }
  15196. if len(insutypes) == 1 {
  15197. insutype = insutypes[0].Insutype
  15198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15199. } else {
  15200. for _, i := range insutypes {
  15201. if i.Insutype == "390" {
  15202. is390 = 1
  15203. }
  15204. if i.Insutype == "310" {
  15205. is310 = 1
  15206. }
  15207. }
  15208. }
  15209. if is390 == 1 {
  15210. insutype = "390"
  15211. }
  15212. if is310 == 1 {
  15213. insutype = "310"
  15214. }
  15215. if len(insutypes) == 0 {
  15216. insutype = "310"
  15217. }
  15218. c.ServeSuccessJSON(map[string]interface{}{
  15219. "patient": patient,
  15220. "number": token,
  15221. "insutype": insutype,
  15222. })
  15223. }
  15224. }
  15225. } else {
  15226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15227. return
  15228. }
  15229. } else { //读卡失败
  15230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15231. return
  15232. }
  15233. }
  15234. break
  15235. case 4:
  15236. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15237. var api string
  15238. if miConfig.MdtrtareaAdmvs == "320921" {
  15239. 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 +
  15240. "&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
  15241. fmt.Println(api)
  15242. } else {
  15243. 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 +
  15244. "&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)
  15245. }
  15246. resp, requestErr := http.Get(api)
  15247. if requestErr != nil {
  15248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15249. return
  15250. }
  15251. body, ioErr := ioutil.ReadAll(resp.Body)
  15252. if ioErr != nil {
  15253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15255. return
  15256. }
  15257. var respJSON map[string]interface{}
  15258. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15261. return
  15262. }
  15263. var status string
  15264. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15265. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15266. var token string
  15267. var res ResultTwo //1101结果
  15268. var res10265 ResultTwo10265 //1101结果
  15269. if status == "0" { //读卡成功
  15270. var card_info string //卡信息
  15271. var busi_card_info string
  15272. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15273. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15274. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15275. fmt.Println(card_info)
  15276. fmt.Println(busi_card_info)
  15277. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15278. result, _ := json.Marshal(respJSON)
  15279. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15280. utils.ErrorLog("解析失败:%v", err)
  15281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15282. return
  15283. }
  15284. res.ErrMsg = res10265.ErrMsg
  15285. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15286. res.Infcode = infocode
  15287. res.Output = res10265.Output
  15288. res.InfRefmsgid = res10265.InfRefmsgid
  15289. if res.Infcode == 0 {
  15290. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15291. if err == gorm.ErrRecordNotFound {
  15292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15293. return
  15294. } else if err != nil {
  15295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15296. return
  15297. } else {
  15298. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15299. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15300. infoStr := string(Iinfos)
  15301. idetinfoStr := string(Idetinfos)
  15302. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15303. psn := &models.HisPsn{
  15304. PsnNo: res.Output.Baseinfo.PsnNo,
  15305. PatientId: patient.ID,
  15306. Certno: res.Output.Baseinfo.Certno,
  15307. Brdy: b,
  15308. Age: float64(age),
  15309. //Brdy: res.Output.Baseinfo.Brdy,
  15310. Gend: res.Output.Baseinfo.Gend,
  15311. Naty: res.Output.Baseinfo.Naty,
  15312. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15313. PsnName: res.Output.Baseinfo.PsnName,
  15314. Idetinfo: idetinfoStr,
  15315. Insuinfo: infoStr,
  15316. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15317. CardInfo: card_info,
  15318. VerifyNumber: token,
  15319. }
  15320. var rf []*ResultFive
  15321. json.Unmarshal([]byte(infoStr), &rf)
  15322. var insutypes []*ResultFive
  15323. var insutype string
  15324. var is390 int = 0
  15325. var is310 int = 0
  15326. for _, item := range rf {
  15327. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15328. insutypes = append(insutypes, item)
  15329. }
  15330. }
  15331. if len(insutypes) == 1 {
  15332. insutype = insutypes[0].Insutype
  15333. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15334. } else {
  15335. for _, i := range insutypes {
  15336. if i.Insutype == "390" {
  15337. is390 = 1
  15338. }
  15339. if i.Insutype == "310" {
  15340. is310 = 1
  15341. }
  15342. }
  15343. }
  15344. if is390 == 1 {
  15345. insutype = "390"
  15346. }
  15347. if is310 == 1 {
  15348. insutype = "310"
  15349. }
  15350. if len(insutypes) == 0 {
  15351. insutype = "310"
  15352. }
  15353. service.CreateHisPsn(psn)
  15354. c.ServeSuccessJSON(map[string]interface{}{
  15355. "patient": patient,
  15356. "number": token,
  15357. "insutype": insutype,
  15358. })
  15359. }
  15360. } else {
  15361. c.ServeSuccessJSON(map[string]interface{}{
  15362. "failed_code": -10,
  15363. "msg": res.ErrMsg,
  15364. })
  15365. }
  15366. } else { //读卡失败
  15367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15368. return
  15369. }
  15370. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15371. var api string
  15372. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15373. "&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
  15374. resp, requestErr := http.Get(api)
  15375. if requestErr != nil {
  15376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15377. return
  15378. }
  15379. body, ioErr := ioutil.ReadAll(resp.Body)
  15380. if ioErr != nil {
  15381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15383. return
  15384. }
  15385. var respJSON map[string]interface{}
  15386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15389. return
  15390. }
  15391. var status string
  15392. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15393. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15394. var token string
  15395. var res ResultTwo //1101结果
  15396. if status == "1" { //读卡成功
  15397. var card_info string //卡信息
  15398. var busi_card_info string
  15399. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15400. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15401. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15402. fmt.Println(card_info)
  15403. fmt.Println(busi_card_info)
  15404. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15405. result, _ := json.Marshal(respJSON)
  15406. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15407. utils.ErrorLog("解析失败:%v", err)
  15408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15409. return
  15410. }
  15411. if res.Infcode == 0 {
  15412. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15413. if err == gorm.ErrRecordNotFound {
  15414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15415. return
  15416. } else if err != nil {
  15417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15418. return
  15419. } else {
  15420. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15421. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15422. infoStr := string(Iinfos)
  15423. idetinfoStr := string(Idetinfos)
  15424. psn := &models.HisPsn{
  15425. PsnNo: res.Output.Baseinfo.PsnNo,
  15426. PatientId: patient.ID,
  15427. Certno: res.Output.Baseinfo.Certno,
  15428. Gend: res.Output.Baseinfo.Gend,
  15429. Naty: res.Output.Baseinfo.Naty,
  15430. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15431. PsnName: res.Output.Baseinfo.PsnName,
  15432. Idetinfo: idetinfoStr,
  15433. Insuinfo: infoStr,
  15434. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15435. CardInfo: card_info,
  15436. VerifyNumber: token,
  15437. }
  15438. var rf []*ResultFive
  15439. json.Unmarshal([]byte(infoStr), &rf)
  15440. var insutypes []*ResultFive
  15441. var insutype string
  15442. var is390 int = 0
  15443. var is310 int = 0
  15444. for _, item := range rf {
  15445. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15446. insutypes = append(insutypes, item)
  15447. }
  15448. }
  15449. if len(insutypes) == 1 {
  15450. insutype = insutypes[0].Insutype
  15451. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15452. } else {
  15453. for _, i := range insutypes {
  15454. if i.Insutype == "390" {
  15455. is390 = 1
  15456. }
  15457. if i.Insutype == "310" {
  15458. is310 = 1
  15459. }
  15460. }
  15461. }
  15462. if is390 == 1 {
  15463. insutype = "390"
  15464. }
  15465. if is310 == 1 {
  15466. insutype = "310"
  15467. }
  15468. if len(insutypes) == 0 {
  15469. insutype = "310"
  15470. }
  15471. service.CreateHisPsn(psn)
  15472. c.ServeSuccessJSON(map[string]interface{}{
  15473. "patient": patient,
  15474. "number": token,
  15475. "insutype": insutype,
  15476. })
  15477. }
  15478. } else {
  15479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15480. return
  15481. }
  15482. } else { //读卡失败
  15483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15484. return
  15485. }
  15486. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15487. var api string
  15488. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15489. "&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
  15490. resp, requestErr := http.Get(api)
  15491. if requestErr != nil {
  15492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15493. return
  15494. }
  15495. body, ioErr := ioutil.ReadAll(resp.Body)
  15496. if ioErr != nil {
  15497. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15499. return
  15500. }
  15501. var respJSON map[string]interface{}
  15502. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15505. return
  15506. }
  15507. var status string
  15508. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15509. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15510. var token string
  15511. var res ResultTwo //1101结果
  15512. if status == "1" { //读卡成功
  15513. var card_info string //卡信息
  15514. var busi_card_info string
  15515. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15516. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15517. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15518. fmt.Println(card_info)
  15519. fmt.Println(busi_card_info)
  15520. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15521. result, _ := json.Marshal(respJSON)
  15522. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15523. utils.ErrorLog("解析失败:%v", err)
  15524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15525. return
  15526. }
  15527. if res.Infcode == 0 {
  15528. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15529. if err == gorm.ErrRecordNotFound {
  15530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15531. return
  15532. } else if err != nil {
  15533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15534. return
  15535. } else {
  15536. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15537. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15538. infoStr := string(Iinfos)
  15539. idetinfoStr := string(Idetinfos)
  15540. psn := &models.HisPsn{
  15541. PsnNo: res.Output.Baseinfo.PsnNo,
  15542. PatientId: patient.ID,
  15543. Certno: res.Output.Baseinfo.Certno,
  15544. Gend: res.Output.Baseinfo.Gend,
  15545. Naty: res.Output.Baseinfo.Naty,
  15546. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15547. PsnName: res.Output.Baseinfo.PsnName,
  15548. Idetinfo: idetinfoStr,
  15549. Insuinfo: infoStr,
  15550. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15551. CardInfo: card_info,
  15552. VerifyNumber: token,
  15553. }
  15554. var rf []*ResultFive
  15555. json.Unmarshal([]byte(infoStr), &rf)
  15556. var insutypes []*ResultFive
  15557. var insutype string
  15558. var is390 int = 0
  15559. var is310 int = 0
  15560. for _, item := range rf {
  15561. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15562. insutypes = append(insutypes, item)
  15563. }
  15564. }
  15565. if len(insutypes) == 1 {
  15566. insutype = insutypes[0].Insutype
  15567. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15568. } else {
  15569. for _, i := range insutypes {
  15570. if i.Insutype == "390" {
  15571. is390 = 1
  15572. }
  15573. if i.Insutype == "310" {
  15574. is310 = 1
  15575. }
  15576. }
  15577. }
  15578. if is390 == 1 {
  15579. insutype = "390"
  15580. }
  15581. if is310 == 1 {
  15582. insutype = "310"
  15583. }
  15584. if len(insutypes) == 0 {
  15585. insutype = "310"
  15586. }
  15587. service.CreateHisPsn(psn)
  15588. c.ServeSuccessJSON(map[string]interface{}{
  15589. "patient": patient,
  15590. "number": token,
  15591. "insutype": insutype,
  15592. })
  15593. }
  15594. } else {
  15595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15596. return
  15597. }
  15598. } else { //读卡失败
  15599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15600. return
  15601. }
  15602. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15603. //idNo := c.GetString("idNo")
  15604. //userName := c.GetString("userName")
  15605. //ecToken := c.GetString("ecToken")
  15606. //insuOrg := c.GetString("insuOrg")
  15607. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15608. utils.ErrorLog("解析失败:%v", json_result)
  15609. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15610. type ELeData struct {
  15611. Data struct {
  15612. IdNo string `json:"idNo"`
  15613. IdType string `json:"idType"`
  15614. UserName string `json:"userName"`
  15615. EcToken string `json:"ecToken"`
  15616. InsuOrg string `json:"insuOrg"`
  15617. Gender string `json:"gender"`
  15618. Birthday string `json:"birthday"`
  15619. Nationality string `json:"nationality"`
  15620. Email string `json:"email"`
  15621. Extra string `json:"extra"`
  15622. } `json:"data"`
  15623. Code int `json:"code"`
  15624. Message string `json:"message"`
  15625. }
  15626. var ele ELeData
  15627. err := json.Unmarshal([]byte(json_result), &ele)
  15628. if err != nil {
  15629. utils.ErrorLog("解析失败:%v", err)
  15630. }
  15631. token := ele.Data.EcToken
  15632. token = Remove0000(token)
  15633. 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)
  15634. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15635. var res ResultTwo
  15636. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15637. utils.ErrorLog("解析失败:%v", err)
  15638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15639. return
  15640. }
  15641. if res.Infcode == 0 {
  15642. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15643. if err == gorm.ErrRecordNotFound {
  15644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15645. return
  15646. } else if err != nil {
  15647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15648. return
  15649. } else {
  15650. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15651. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15652. infoStr := string(Iinfos)
  15653. idetinfoStr := string(Idetinfos)
  15654. psn := &models.HisPsn{
  15655. PsnNo: res.Output.Baseinfo.PsnNo,
  15656. PatientId: patient.ID,
  15657. Certno: res.Output.Baseinfo.Certno,
  15658. Gend: res.Output.Baseinfo.Gend,
  15659. Naty: res.Output.Baseinfo.Naty,
  15660. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15661. PsnName: res.Output.Baseinfo.PsnName,
  15662. Idetinfo: idetinfoStr,
  15663. Insuinfo: infoStr,
  15664. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15665. CardInfo: "",
  15666. Stage: "1",
  15667. VerifyNumber: token,
  15668. InsuplcAdmdvs: ele.Data.InsuOrg,
  15669. }
  15670. service.CreateHisPsn(psn)
  15671. var rf []*ResultFive
  15672. json.Unmarshal([]byte(infoStr), &rf)
  15673. var insutypes []*ResultFive
  15674. var insutype string
  15675. var is390 int = 0
  15676. var is310 int = 0
  15677. for _, item := range rf {
  15678. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15679. insutypes = append(insutypes, item)
  15680. }
  15681. }
  15682. if len(insutypes) == 1 {
  15683. insutype = insutypes[0].Insutype
  15684. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15685. } else {
  15686. for _, i := range insutypes {
  15687. if i.Insutype == "390" {
  15688. is390 = 1
  15689. }
  15690. if i.Insutype == "310" {
  15691. is310 = 1
  15692. }
  15693. }
  15694. }
  15695. if is390 == 1 {
  15696. insutype = "390"
  15697. }
  15698. if is310 == 1 {
  15699. insutype = "310"
  15700. }
  15701. if len(insutypes) == 0 {
  15702. insutype = "310"
  15703. }
  15704. c.ServeSuccessJSON(map[string]interface{}{
  15705. "patient": patient,
  15706. "number": token,
  15707. "insutype": insutype,
  15708. })
  15709. }
  15710. } else {
  15711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15712. return
  15713. }
  15714. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15715. //if initFlag == 0 {
  15716. //c.TestGetJiangXiBasBaseInit()
  15717. //}
  15718. //if initEleFlag == 0 {
  15719. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15720. //}
  15721. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15722. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15723. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15724. type ELeData struct {
  15725. Data struct {
  15726. IdNo string `json:"idNo"`
  15727. IdType string `json:"idType"`
  15728. UserName string `json:"userName"`
  15729. EcToken string `json:"ecToken"`
  15730. InsuOrg string `json:"insuOrg"`
  15731. Gender string `json:"gender"`
  15732. Birthday string `json:"birthday"`
  15733. Nationality string `json:"nationality"`
  15734. Email string `json:"email"`
  15735. Extra string `json:"extra"`
  15736. } `json:"data"`
  15737. Code int `json:"code"`
  15738. Message string `json:"message"`
  15739. }
  15740. var ele ELeData
  15741. err := json.Unmarshal([]byte(result), &ele)
  15742. if err != nil {
  15743. utils.ErrorLog("解析失败:%v", err)
  15744. }
  15745. token := ele.Data.EcToken
  15746. token = Remove0000(token)
  15747. 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)
  15748. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15749. var res ResultTwo
  15750. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15751. utils.ErrorLog("解析失败:%v", err)
  15752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15753. return
  15754. }
  15755. if res.Infcode == 0 {
  15756. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15757. if err == gorm.ErrRecordNotFound {
  15758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15759. return
  15760. } else if err != nil {
  15761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15762. return
  15763. } else {
  15764. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15765. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15766. infoStr := string(Iinfos)
  15767. idetinfoStr := string(Idetinfos)
  15768. psn := &models.HisPsn{
  15769. PsnNo: res.Output.Baseinfo.PsnNo,
  15770. PatientId: patient.ID,
  15771. Certno: res.Output.Baseinfo.Certno,
  15772. Gend: res.Output.Baseinfo.Gend,
  15773. Naty: res.Output.Baseinfo.Naty,
  15774. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15775. PsnName: res.Output.Baseinfo.PsnName,
  15776. Idetinfo: idetinfoStr,
  15777. Insuinfo: infoStr,
  15778. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15779. CardInfo: "",
  15780. VerifyNumber: token,
  15781. InsuplcAdmdvs: ele.Data.InsuOrg,
  15782. }
  15783. service.CreateHisPsn(psn)
  15784. var rf []*ResultFive
  15785. json.Unmarshal([]byte(infoStr), &rf)
  15786. var insutypes []*ResultFive
  15787. var insutype string
  15788. var is390 int = 0
  15789. var is310 int = 0
  15790. for _, item := range rf {
  15791. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15792. insutypes = append(insutypes, item)
  15793. }
  15794. }
  15795. if len(insutypes) == 1 {
  15796. insutype = insutypes[0].Insutype
  15797. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15798. } else {
  15799. for _, i := range insutypes {
  15800. if i.Insutype == "390" {
  15801. is390 = 1
  15802. }
  15803. if i.Insutype == "310" {
  15804. is310 = 1
  15805. }
  15806. }
  15807. }
  15808. if is390 == 1 {
  15809. insutype = "390"
  15810. }
  15811. if is310 == 1 {
  15812. insutype = "310"
  15813. }
  15814. if len(insutypes) == 0 {
  15815. insutype = "310"
  15816. }
  15817. c.ServeSuccessJSON(map[string]interface{}{
  15818. "patient": patient,
  15819. "number": token,
  15820. "insutype": insutype,
  15821. })
  15822. }
  15823. } else {
  15824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15825. return
  15826. }
  15827. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15828. //if initFlag == 0 {
  15829. //c.TestGetJiangXiBasBaseInit()
  15830. //}
  15831. //if initEleFlag == 0 {
  15832. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15833. //}
  15834. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15835. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15836. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15837. type ELeData struct {
  15838. Data struct {
  15839. IdNo string `json:"idNo"`
  15840. IdType string `json:"idType"`
  15841. UserName string `json:"userName"`
  15842. EcToken string `json:"ecToken"`
  15843. InsuOrg string `json:"insuOrg"`
  15844. Gender string `json:"gender"`
  15845. Birthday string `json:"birthday"`
  15846. Nationality string `json:"nationality"`
  15847. Email string `json:"email"`
  15848. Extra string `json:"extra"`
  15849. } `json:"data"`
  15850. Code int `json:"code"`
  15851. Message string `json:"message"`
  15852. }
  15853. var ele ELeData
  15854. err := json.Unmarshal([]byte(result), &ele)
  15855. if err != nil {
  15856. utils.ErrorLog("解析失败:%v", err)
  15857. }
  15858. token := ele.Data.EcToken
  15859. token = Remove0000(token)
  15860. 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)
  15861. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15862. var res ResultTwo
  15863. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15864. utils.ErrorLog("解析失败:%v", err)
  15865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15866. return
  15867. }
  15868. if res.Infcode == 0 {
  15869. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15870. if err == gorm.ErrRecordNotFound {
  15871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15872. return
  15873. } else if err != nil {
  15874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15875. return
  15876. } else {
  15877. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15878. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15879. infoStr := string(Iinfos)
  15880. idetinfoStr := string(Idetinfos)
  15881. psn := &models.HisPsn{
  15882. PsnNo: res.Output.Baseinfo.PsnNo,
  15883. PatientId: patient.ID,
  15884. Certno: res.Output.Baseinfo.Certno,
  15885. Gend: res.Output.Baseinfo.Gend,
  15886. Naty: res.Output.Baseinfo.Naty,
  15887. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15888. PsnName: res.Output.Baseinfo.PsnName,
  15889. Idetinfo: idetinfoStr,
  15890. Insuinfo: infoStr,
  15891. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15892. CardInfo: "",
  15893. VerifyNumber: token,
  15894. InsuplcAdmdvs: ele.Data.InsuOrg,
  15895. }
  15896. service.CreateHisPsn(psn)
  15897. var rf []*ResultFive
  15898. json.Unmarshal([]byte(infoStr), &rf)
  15899. var insutypes []*ResultFive
  15900. var insutype string
  15901. var is390 int = 0
  15902. var is310 int = 0
  15903. for _, item := range rf {
  15904. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15905. insutypes = append(insutypes, item)
  15906. }
  15907. }
  15908. if len(insutypes) == 1 {
  15909. insutype = insutypes[0].Insutype
  15910. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15911. } else {
  15912. for _, i := range insutypes {
  15913. if i.Insutype == "390" {
  15914. is390 = 1
  15915. }
  15916. if i.Insutype == "310" {
  15917. is310 = 1
  15918. }
  15919. }
  15920. }
  15921. if is390 == 1 {
  15922. insutype = "390"
  15923. }
  15924. if is310 == 1 {
  15925. insutype = "310"
  15926. }
  15927. if len(insutypes) == 0 {
  15928. insutype = "310"
  15929. }
  15930. c.ServeSuccessJSON(map[string]interface{}{
  15931. "patient": patient,
  15932. "number": token,
  15933. "insutype": insutype,
  15934. })
  15935. }
  15936. } else {
  15937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15938. return
  15939. }
  15940. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15941. //if initFlag == 0 {
  15942. c.TestGetJiangXiBasBaseInit()
  15943. //}
  15944. //if initEleFlag == 0 {
  15945. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15946. //}
  15947. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15948. type ELeData struct {
  15949. Data struct {
  15950. IdNo string `json:"idNo"`
  15951. IdType string `json:"idType"`
  15952. UserName string `json:"userName"`
  15953. EcToken string `json:"ecToken"`
  15954. InsuOrg string `json:"insuOrg"`
  15955. Gender string `json:"gender"`
  15956. Birthday string `json:"birthday"`
  15957. Nationality string `json:"nationality"`
  15958. Email string `json:"email"`
  15959. Extra string `json:"extra"`
  15960. } `json:"data"`
  15961. Code int `json:"code"`
  15962. Message string `json:"message"`
  15963. }
  15964. var ele ELeData
  15965. err := json.Unmarshal([]byte(json_result), &ele)
  15966. if err != nil {
  15967. utils.ErrorLog("解析失败:%v", err)
  15968. }
  15969. token := ele.Data.EcToken
  15970. token = Remove0000(token)
  15971. 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)
  15972. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15973. var res ResultTwo
  15974. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15975. utils.ErrorLog("解析失败:%v", err)
  15976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15977. return
  15978. }
  15979. if res.Infcode == 0 {
  15980. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15981. if err == gorm.ErrRecordNotFound {
  15982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15983. return
  15984. } else if err != nil {
  15985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15986. return
  15987. } else {
  15988. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15989. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15990. infoStr := string(Iinfos)
  15991. idetinfoStr := string(Idetinfos)
  15992. psn := &models.HisPsn{
  15993. PsnNo: res.Output.Baseinfo.PsnNo,
  15994. PatientId: patient.ID,
  15995. Certno: res.Output.Baseinfo.Certno,
  15996. Gend: res.Output.Baseinfo.Gend,
  15997. Naty: res.Output.Baseinfo.Naty,
  15998. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15999. PsnName: res.Output.Baseinfo.PsnName,
  16000. Idetinfo: idetinfoStr,
  16001. Insuinfo: infoStr,
  16002. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16003. CardInfo: "",
  16004. VerifyNumber: token,
  16005. }
  16006. service.CreateHisPsn(psn)
  16007. var rf []*ResultFive
  16008. json.Unmarshal([]byte(infoStr), &rf)
  16009. var insutypes []*ResultFive
  16010. var insutype string
  16011. var is390 int = 0
  16012. var is310 int = 0
  16013. for _, item := range rf {
  16014. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16015. insutypes = append(insutypes, item)
  16016. }
  16017. }
  16018. if len(insutypes) == 1 {
  16019. insutype = insutypes[0].Insutype
  16020. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16021. } else {
  16022. for _, i := range insutypes {
  16023. if i.Insutype == "390" {
  16024. is390 = 1
  16025. }
  16026. if i.Insutype == "310" {
  16027. is310 = 1
  16028. }
  16029. }
  16030. }
  16031. if is390 == 1 {
  16032. insutype = "390"
  16033. }
  16034. if is310 == 1 {
  16035. insutype = "310"
  16036. }
  16037. if len(insutypes) == 0 {
  16038. insutype = "310"
  16039. }
  16040. c.ServeSuccessJSON(map[string]interface{}{
  16041. "patient": patient,
  16042. "number": token,
  16043. "insutype": insutype,
  16044. })
  16045. }
  16046. } else {
  16047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16048. return
  16049. }
  16050. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16051. type ELeData struct {
  16052. Code string `json:"code"`
  16053. Data struct {
  16054. Aac002 string `json:"aac002"`
  16055. Aaz500 string `json:"aaz500"`
  16056. ActCardNo string `json:"actCardNo"`
  16057. Bab520 string `json:"bab520"`
  16058. Bkz543 string `json:"bkz543"`
  16059. BusinessType string `json:"businessType"`
  16060. CertfCodg string `json:"certfCodg"`
  16061. EcIndexNo string `json:"ecIndexNo"`
  16062. EcToken string `json:"ecToken"`
  16063. ID0000 string `json:"id0000"`
  16064. IDNo string `json:"idNo"`
  16065. IDType string `json:"idType"`
  16066. Idcode string `json:"idcode"`
  16067. IdentityToken string `json:"identity_token"`
  16068. InsuOrg string `json:"insuOrg"`
  16069. OfficeID string `json:"officeId"`
  16070. OfficeName string `json:"officeName"`
  16071. OperatorID string `json:"operatorId"`
  16072. OperatorName string `json:"operatorName"`
  16073. OrgID string `json:"orgId"`
  16074. UserName string `json:"userName"`
  16075. } `json:"data"`
  16076. Infno interface{} `json:"infno"`
  16077. Message string `json:"message"`
  16078. OrgID string `json:"orgId"`
  16079. TransType string `json:"transType"`
  16080. }
  16081. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16082. outPutInfo = Remove0000(outPutInfo)
  16083. if len(outPutInfo) > 0 {
  16084. var ele ELeData
  16085. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16086. if err != nil {
  16087. utils.ErrorLog("解析失败:%v", err)
  16088. }
  16089. token := ele.Data.EcToken
  16090. fmt.Println(inputInfo)
  16091. fmt.Println(outPutInfo)
  16092. 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)
  16093. saveLog(result, requestLog, "1101", "获取人员信息")
  16094. var dat map[string]interface{}
  16095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16096. fmt.Println(dat)
  16097. } else {
  16098. fmt.Println(err)
  16099. }
  16100. userJSONBytes, _ := json.Marshal(dat)
  16101. var res ResultTwo
  16102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16103. utils.ErrorLog("解析失败:%v", err)
  16104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16105. return
  16106. }
  16107. res.ErrMsg = errMsgLog
  16108. if res.Infcode == 0 {
  16109. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16110. if err == gorm.ErrRecordNotFound {
  16111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16112. return
  16113. } else if err != nil {
  16114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16115. return
  16116. } else {
  16117. fmt.Println(res)
  16118. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16119. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16120. infoStr := string(Iinfos)
  16121. idetinfoStr := string(Idetinfos)
  16122. psn := &models.HisPsn{
  16123. PsnNo: res.Output.Baseinfo.PsnNo,
  16124. PatientId: patient.ID,
  16125. Certno: res.Output.Baseinfo.Certno,
  16126. Gend: res.Output.Baseinfo.Gend,
  16127. Naty: res.Output.Baseinfo.Naty,
  16128. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16129. PsnName: res.Output.Baseinfo.PsnName,
  16130. Idetinfo: idetinfoStr,
  16131. Insuinfo: infoStr,
  16132. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16133. CardInfo: outPutInfo,
  16134. VerifyNumber: token,
  16135. InsuplcAdmdvs: ele.Data.InsuOrg,
  16136. }
  16137. service.CreateHisPsn(psn)
  16138. var rf []*ResultFive
  16139. json.Unmarshal([]byte(infoStr), &rf)
  16140. var insutypes []*ResultFive
  16141. var insutype string
  16142. var is390 int = 0
  16143. var is310 int = 0
  16144. for _, item := range rf {
  16145. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16146. insutypes = append(insutypes, item)
  16147. }
  16148. }
  16149. if len(insutypes) == 1 {
  16150. insutype = insutypes[0].Insutype
  16151. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16152. } else {
  16153. for _, i := range insutypes {
  16154. if i.Insutype == "390" {
  16155. is390 = 1
  16156. }
  16157. if i.Insutype == "310" {
  16158. is310 = 1
  16159. }
  16160. }
  16161. }
  16162. if is390 == 1 {
  16163. insutype = "390"
  16164. }
  16165. if is310 == 1 {
  16166. insutype = "310"
  16167. }
  16168. if len(insutypes) == 0 {
  16169. insutype = "310"
  16170. }
  16171. c.ServeSuccessJSON(map[string]interface{}{
  16172. "patient": patient,
  16173. "number": token,
  16174. "insutype": insutype,
  16175. })
  16176. }
  16177. } else {
  16178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16179. return
  16180. }
  16181. }
  16182. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16183. var api string
  16184. 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 +
  16185. "&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
  16186. resp, requestErr := http.Get(api)
  16187. if requestErr != nil {
  16188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16189. return
  16190. }
  16191. body, ioErr := ioutil.ReadAll(resp.Body)
  16192. if ioErr != nil {
  16193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16195. return
  16196. }
  16197. var respJSON map[string]interface{}
  16198. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16201. return
  16202. }
  16203. var status string
  16204. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16205. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16206. var token string
  16207. var res ResultTwo //1101结果
  16208. var res10265 ResultTwo10265 //1101结果
  16209. if status == "0" { //读卡成功
  16210. var card_info string //卡信息
  16211. var busi_card_info string
  16212. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16213. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16214. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16215. fmt.Println(card_info)
  16216. fmt.Println(busi_card_info)
  16217. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16218. result, _ := json.Marshal(respJSON)
  16219. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16220. utils.ErrorLog("解析失败:%v", err)
  16221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16222. return
  16223. }
  16224. res.ErrMsg = res10265.ErrMsg
  16225. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16226. res.Infcode = infocode
  16227. res.Output = res10265.Output
  16228. res.InfRefmsgid = res10265.InfRefmsgid
  16229. if res.Infcode == 0 {
  16230. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16231. if err == gorm.ErrRecordNotFound {
  16232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16233. return
  16234. } else if err != nil {
  16235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16236. return
  16237. } else {
  16238. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16239. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16240. infoStr := string(Iinfos)
  16241. idetinfoStr := string(Idetinfos)
  16242. psn := &models.HisPsn{
  16243. PsnNo: res.Output.Baseinfo.PsnNo,
  16244. PatientId: patient.ID,
  16245. Certno: res.Output.Baseinfo.Certno,
  16246. Gend: res.Output.Baseinfo.Gend,
  16247. Naty: res.Output.Baseinfo.Naty,
  16248. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16249. PsnName: res.Output.Baseinfo.PsnName,
  16250. Idetinfo: idetinfoStr,
  16251. Insuinfo: infoStr,
  16252. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16253. CardInfo: card_info,
  16254. VerifyNumber: token,
  16255. }
  16256. var rf []*ResultFive
  16257. json.Unmarshal([]byte(infoStr), &rf)
  16258. var insutypes []*ResultFive
  16259. var insutype string
  16260. var is390 int = 0
  16261. var is310 int = 0
  16262. for _, item := range rf {
  16263. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16264. insutypes = append(insutypes, item)
  16265. }
  16266. }
  16267. if len(insutypes) == 1 {
  16268. insutype = insutypes[0].Insutype
  16269. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16270. } else {
  16271. for _, i := range insutypes {
  16272. if i.Insutype == "390" {
  16273. is390 = 1
  16274. }
  16275. if i.Insutype == "310" {
  16276. is310 = 1
  16277. }
  16278. }
  16279. }
  16280. if is390 == 1 {
  16281. insutype = "390"
  16282. }
  16283. if is310 == 1 {
  16284. insutype = "310"
  16285. }
  16286. if len(insutypes) == 0 {
  16287. insutype = "310"
  16288. }
  16289. service.CreateHisPsn(psn)
  16290. c.ServeSuccessJSON(map[string]interface{}{
  16291. "patient": patient,
  16292. "number": token,
  16293. "insutype": insutype,
  16294. })
  16295. }
  16296. } else {
  16297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16298. return
  16299. }
  16300. } else { //读卡失败
  16301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16302. return
  16303. }
  16304. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16305. res := c.GetoleInfo()
  16306. if res.Infcode == 0 {
  16307. var result string
  16308. if res.Output.MdtrtCertType == "01" {
  16309. 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)
  16310. } else if res.Output.MdtrtCertType == "02" {
  16311. 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)
  16312. } else if res.Output.MdtrtCertType == "03" {
  16313. 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)
  16314. }
  16315. var dat map[string]interface{}
  16316. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16317. fmt.Println(dat)
  16318. } else {
  16319. fmt.Println(err)
  16320. }
  16321. userJSONBytes, _ := json.Marshal(dat)
  16322. var res2 ResultTwo
  16323. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16324. utils.ErrorLog("解析失败:%v", err)
  16325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16326. return
  16327. }
  16328. if res2.Infcode == 0 {
  16329. patient, err := service.GetPatientByNumber(res.Output.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(res2.Output.Iinfo)
  16338. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16339. infoStr := string(Iinfos)
  16340. idetinfoStr := string(Idetinfos)
  16341. var rf []*ResultFive
  16342. json.Unmarshal([]byte(infoStr), &rf)
  16343. var insutypes []*ResultFive
  16344. var insutype string
  16345. var is390 int = 0
  16346. var is310 int = 0
  16347. //var insuplc_admdvs string
  16348. for _, item := range rf {
  16349. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16350. insutypes = append(insutypes, item)
  16351. }
  16352. }
  16353. if len(insutypes) == 1 {
  16354. insutype = insutypes[0].Insutype
  16355. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16356. } else {
  16357. for _, i := range insutypes {
  16358. if i.Insutype == "390" {
  16359. is390 = 1
  16360. }
  16361. if i.Insutype == "310" {
  16362. is310 = 1
  16363. }
  16364. }
  16365. }
  16366. if is390 == 1 {
  16367. insutype = "390"
  16368. }
  16369. if is310 == 1 {
  16370. insutype = "310"
  16371. }
  16372. if len(insutypes) == 0 {
  16373. insutype = "310"
  16374. }
  16375. psn := &models.HisPsn{
  16376. PsnNo: res2.Output.Baseinfo.PsnNo,
  16377. PatientId: patient.ID,
  16378. Certno: res2.Output.Baseinfo.Certno,
  16379. Gend: res2.Output.Baseinfo.Gend,
  16380. Naty: res2.Output.Baseinfo.Naty,
  16381. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16382. PsnName: res2.Output.Baseinfo.PsnName,
  16383. Idetinfo: idetinfoStr,
  16384. Insuinfo: infoStr,
  16385. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16386. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16387. VerifyNumber: res.Output.EcToken,
  16388. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16389. }
  16390. if res.Output.MdtrtCertType == "01" {
  16391. psn.VerifyNumber = res.Output.EcToken
  16392. //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)
  16393. } else if res.Output.MdtrtCertType == "02" {
  16394. psn.VerifyNumber = res.Output.CardNo
  16395. //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)
  16396. } else if res.Output.MdtrtCertType == "03" {
  16397. psn.VerifyNumber = res.Output.MdtrtCertNo
  16398. //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)
  16399. }
  16400. service.CreateHisPsn(psn)
  16401. var balc float64
  16402. for _, item := range rf {
  16403. if item.Insutype == insutype {
  16404. balc = item.Balc
  16405. }
  16406. }
  16407. c.ServeSuccessJSON(map[string]interface{}{
  16408. "patient": patient,
  16409. "number": res.Output.CardNo,
  16410. "insutype": insutype,
  16411. "blac": balc,
  16412. "desc": idetinfoStr,
  16413. })
  16414. }
  16415. } else {
  16416. c.ServeSuccessJSON(map[string]interface{}{
  16417. "failed_code": -10,
  16418. "msg": res2.ErrMsg,
  16419. })
  16420. }
  16421. } else {
  16422. c.ServeSuccessJSON(map[string]interface{}{
  16423. "failed_code": -10,
  16424. "msg": res.ErrMsg,
  16425. })
  16426. }
  16427. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16428. var res ResultTwo
  16429. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16430. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16431. "&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)
  16432. resp, requestErr := http.Get(api)
  16433. if requestErr != nil {
  16434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16435. return
  16436. }
  16437. body, ioErr := ioutil.ReadAll(resp.Body)
  16438. if ioErr != nil {
  16439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16441. return
  16442. }
  16443. var respJSON map[string]interface{}
  16444. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16447. return
  16448. }
  16449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16450. result, _ := json.Marshal(respJSON)
  16451. fmt.Println("log")
  16452. fmt.Println(string(result))
  16453. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16454. utils.ErrorLog("解析失败:%v", err)
  16455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16456. return
  16457. }
  16458. if res.Infcode == 0 {
  16459. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16460. if err == gorm.ErrRecordNotFound {
  16461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16462. return
  16463. } else if err != nil {
  16464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16465. return
  16466. } else {
  16467. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16468. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16469. infoStr := string(Iinfos)
  16470. idetinfoStr := string(Idetinfos)
  16471. var rf []*ResultFive
  16472. json.Unmarshal([]byte(infoStr), &rf)
  16473. var insutypes []*ResultFive
  16474. var insutype string
  16475. var is390 int = 0
  16476. var is310 int = 0
  16477. for _, item := range rf {
  16478. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16479. insutypes = append(insutypes, item)
  16480. }
  16481. }
  16482. if len(insutypes) == 1 {
  16483. insutype = insutypes[0].Insutype
  16484. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16485. } else {
  16486. for _, i := range insutypes {
  16487. if i.Insutype == "390" {
  16488. is390 = 1
  16489. }
  16490. if i.Insutype == "310" {
  16491. is310 = 1
  16492. }
  16493. }
  16494. }
  16495. if is390 == 1 {
  16496. insutype = "390"
  16497. }
  16498. if is310 == 1 {
  16499. insutype = "310"
  16500. }
  16501. if len(insutypes) == 0 {
  16502. insutype = "390"
  16503. }
  16504. var insuplc_admdvs string
  16505. for _, item := range rf {
  16506. if item.Insutype == insutype {
  16507. insuplc_admdvs = item.InsuplcAdmdvs
  16508. }
  16509. }
  16510. psn := &models.HisPsn{
  16511. PsnNo: res.Output.Baseinfo.PsnNo,
  16512. PatientId: patient.ID,
  16513. Certno: res.Output.Baseinfo.Certno,
  16514. Gend: res.Output.Baseinfo.Gend,
  16515. Naty: res.Output.Baseinfo.Naty,
  16516. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16517. PsnName: res.Output.Baseinfo.PsnName,
  16518. Idetinfo: idetinfoStr,
  16519. Insuinfo: infoStr,
  16520. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16521. InsuplcAdmdvs: insuplc_admdvs,
  16522. }
  16523. service.CreateHisPsn(psn)
  16524. c.ServeSuccessJSON(map[string]interface{}{
  16525. "patient": patient,
  16526. "number": res.Output.Baseinfo.Certno,
  16527. })
  16528. }
  16529. } else {
  16530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16531. return
  16532. }
  16533. } else {
  16534. type ELeData struct {
  16535. Code string `json:"code"`
  16536. Data struct {
  16537. Aac002 string `json:"aac002"`
  16538. Aaz500 string `json:"aaz500"`
  16539. ActCardNo string `json:"actCardNo"`
  16540. Bab520 string `json:"bab520"`
  16541. Bkz543 string `json:"bkz543"`
  16542. BusinessType string `json:"businessType"`
  16543. CertfCodg string `json:"certfCodg"`
  16544. EcIndexNo string `json:"ecIndexNo"`
  16545. EcToken string `json:"ecToken"`
  16546. ID0000 string `json:"id0000"`
  16547. IDNo string `json:"idNo"`
  16548. IDType string `json:"idType"`
  16549. Idcode string `json:"idcode"`
  16550. IdentityToken string `json:"identity_token"`
  16551. InsuOrg string `json:"insuOrg"`
  16552. OfficeID string `json:"officeId"`
  16553. OfficeName string `json:"officeName"`
  16554. OperatorID string `json:"operatorId"`
  16555. OperatorName string `json:"operatorName"`
  16556. OrgID string `json:"orgId"`
  16557. UserName string `json:"userName"`
  16558. } `json:"data"`
  16559. Infno interface{} `json:"infno"`
  16560. Message string `json:"message"`
  16561. OrgID string `json:"orgId"`
  16562. TransType string `json:"transType"`
  16563. }
  16564. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16565. fmt.Println(result)
  16566. outPutInfo := Remove0000(result)
  16567. fmt.Println(outPutInfo)
  16568. if len(outPutInfo) > 0 {
  16569. var ele ELeData
  16570. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16571. if err != nil {
  16572. utils.ErrorLog("解析失败:%v", err)
  16573. }
  16574. token := ele.Data.EcToken
  16575. fmt.Println(outPutInfo)
  16576. 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)
  16577. saveLog(result, requestLog, "1101", "获取人员信息")
  16578. var dat map[string]interface{}
  16579. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16580. fmt.Println(dat)
  16581. } else {
  16582. fmt.Println(err)
  16583. }
  16584. userJSONBytes, _ := json.Marshal(dat)
  16585. var res ResultTwo
  16586. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16587. utils.ErrorLog("解析失败:%v", err)
  16588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16589. return
  16590. }
  16591. if res.Infcode == 0 {
  16592. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16593. if err == gorm.ErrRecordNotFound {
  16594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16595. return
  16596. } else if err != nil {
  16597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16598. return
  16599. } else {
  16600. fmt.Println(res)
  16601. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16602. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16603. infoStr := string(Iinfos)
  16604. idetinfoStr := string(Idetinfos)
  16605. psn := &models.HisPsn{
  16606. PsnNo: res.Output.Baseinfo.PsnNo,
  16607. PatientId: patient.ID,
  16608. Certno: res.Output.Baseinfo.Certno,
  16609. Gend: res.Output.Baseinfo.Gend,
  16610. Naty: res.Output.Baseinfo.Naty,
  16611. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16612. PsnName: res.Output.Baseinfo.PsnName,
  16613. Idetinfo: idetinfoStr,
  16614. Insuinfo: infoStr,
  16615. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16616. CardInfo: outPutInfo,
  16617. VerifyNumber: token,
  16618. InsuplcAdmdvs: ele.Data.InsuOrg,
  16619. }
  16620. service.CreateHisPsn(psn)
  16621. var rf []*ResultFive
  16622. json.Unmarshal([]byte(infoStr), &rf)
  16623. var insutypes []*ResultFive
  16624. var insutype string
  16625. var is390 int = 0
  16626. var is310 int = 0
  16627. for _, item := range rf {
  16628. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16629. insutypes = append(insutypes, item)
  16630. }
  16631. }
  16632. if len(insutypes) == 1 {
  16633. insutype = insutypes[0].Insutype
  16634. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16635. } else {
  16636. for _, i := range insutypes {
  16637. if i.Insutype == "390" {
  16638. is390 = 1
  16639. }
  16640. if i.Insutype == "310" {
  16641. is310 = 1
  16642. }
  16643. }
  16644. }
  16645. if is390 == 1 {
  16646. insutype = "390"
  16647. }
  16648. if is310 == 1 {
  16649. insutype = "310"
  16650. }
  16651. if len(insutypes) == 0 {
  16652. insutype = "310"
  16653. }
  16654. c.ServeSuccessJSON(map[string]interface{}{
  16655. "patient": patient,
  16656. "number": token,
  16657. "insutype": insutype,
  16658. })
  16659. }
  16660. } else {
  16661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16662. return
  16663. }
  16664. }
  16665. //fmt.Println(result)
  16666. //
  16667. //if initFlag == 0 {
  16668. // c.TestGetBasBaseInit()
  16669. //}
  16670. //token := c.GetEleBaseInfo()
  16671. //
  16672. //token = Remove0000(token)
  16673. //
  16674. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16675. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16676. ////
  16677. //var res ResultTwo
  16678. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16679. // utils.ErrorLog("解析失败:%v", err)
  16680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16681. // return
  16682. //}
  16683. //
  16684. //if res.Infcode == 0 {
  16685. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16686. // if err == gorm.ErrRecordNotFound {
  16687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16688. // return
  16689. // } else if err != nil {
  16690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16691. // return
  16692. //
  16693. // } else {
  16694. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16695. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16696. // infoStr := string(Iinfos)
  16697. // idetinfoStr := string(Idetinfos)
  16698. //
  16699. //
  16700. //
  16701. //
  16702. // var rf []*ResultFive
  16703. // json.Unmarshal([]byte(infoStr), &rf)
  16704. //
  16705. // var insutypes []*ResultFive
  16706. // var insutype string
  16707. // var is390 int = 0
  16708. // var is310 int = 0
  16709. // var insuplc_admdvs string
  16710. //
  16711. // for _, item := range rf {
  16712. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16713. // insutypes = append(insutypes, item)
  16714. // }
  16715. // }
  16716. //
  16717. // if len(insutypes) == 1 {
  16718. // insutype = insutypes[0].Insutype
  16719. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16720. // } else {
  16721. // for _, i := range insutypes {
  16722. // if i.Insutype == "390" {
  16723. // is390 = 1
  16724. // }
  16725. //
  16726. // if i.Insutype == "310" {
  16727. // is310 = 1
  16728. // }
  16729. // }
  16730. // }
  16731. // if is390 == 1 {
  16732. // insutype = "390"
  16733. // }
  16734. //
  16735. // if is310 == 1 {
  16736. // insutype = "310"
  16737. // }
  16738. // if len(insutypes) == 0 {
  16739. // insutype = "310"
  16740. // }
  16741. // for _, item := range rf {
  16742. // if item.Insutype == insutype {
  16743. // insuplc_admdvs = item.InsuplcAdmdvs
  16744. // }
  16745. // }
  16746. // psn := &models.HisPsn{
  16747. // PsnNo: res.Output.Baseinfo.PsnNo,
  16748. // Age: res.Output.Baseinfo.Age,
  16749. // PatientId: patient.ID,
  16750. // Certno: res.Output.Baseinfo.Certno,
  16751. // Brdy: res.Output.Baseinfo.Brdy,
  16752. // Gend: res.Output.Baseinfo.Gend,
  16753. // Naty: res.Output.Baseinfo.Naty,
  16754. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16755. // PsnName: res.Output.Baseinfo.PsnName,
  16756. // Idetinfo: idetinfoStr,
  16757. // Insuinfo: infoStr,
  16758. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16759. // CardInfo: "",
  16760. // VerifyNumber: token,
  16761. // InsuplcAdmdvs: insuplc_admdvs,
  16762. // }
  16763. // service.CreateHisPsn(psn)
  16764. //
  16765. // c.ServeSuccessJSON(map[string]interface{}{
  16766. // "patient": patient,
  16767. // "number": token,
  16768. // })
  16769. // }
  16770. //} else {
  16771. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16772. // return
  16773. //}
  16774. }
  16775. break
  16776. case 5:
  16777. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16778. var api string
  16779. if miConfig.MdtrtareaAdmvs == "320921" {
  16780. 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 +
  16781. "&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
  16782. fmt.Println(api)
  16783. } else {
  16784. 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 +
  16785. "&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)
  16786. }
  16787. resp, requestErr := http.Get(api)
  16788. if requestErr != nil {
  16789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16790. return
  16791. }
  16792. body, ioErr := ioutil.ReadAll(resp.Body)
  16793. if ioErr != nil {
  16794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16796. return
  16797. }
  16798. var respJSON map[string]interface{}
  16799. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16802. return
  16803. }
  16804. var status string
  16805. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16806. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16807. var token string
  16808. var res ResultTwo //1101结果
  16809. var res10265 ResultTwo10265 //1101结果
  16810. if status == "0" { //读卡成功
  16811. var card_info string //卡信息
  16812. //var busi_card_info string
  16813. var auth_info string
  16814. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16815. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16816. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16817. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16818. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16819. result, _ := json.Marshal(respJSON)
  16820. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16821. utils.ErrorLog("解析失败:%v", err)
  16822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16823. return
  16824. }
  16825. res.ErrMsg = res10265.ErrMsg
  16826. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16827. res.Infcode = infocode
  16828. res.Output = res10265.Output
  16829. res.InfRefmsgid = res10265.InfRefmsgid
  16830. if res.Infcode == 0 {
  16831. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16832. if err == gorm.ErrRecordNotFound {
  16833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16834. return
  16835. } else if err != nil {
  16836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16837. return
  16838. } else {
  16839. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16840. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16841. infoStr := string(Iinfos)
  16842. idetinfoStr := string(Idetinfos)
  16843. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16844. psn := &models.HisPsn{
  16845. PsnNo: res.Output.Baseinfo.PsnNo,
  16846. PatientId: patient.ID,
  16847. Certno: res.Output.Baseinfo.Certno,
  16848. Gend: res.Output.Baseinfo.Gend,
  16849. Brdy: b,
  16850. Age: float64(age),
  16851. Naty: res.Output.Baseinfo.Naty,
  16852. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16853. PsnName: res.Output.Baseinfo.PsnName,
  16854. Idetinfo: idetinfoStr,
  16855. Insuinfo: infoStr,
  16856. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16857. CardInfo: card_info,
  16858. VerifyNumber: token,
  16859. AuthInfo: auth_info,
  16860. }
  16861. var rf []*ResultFive
  16862. json.Unmarshal([]byte(infoStr), &rf)
  16863. var insutypes []*ResultFive
  16864. var insutype string
  16865. var is390 int = 0
  16866. var is310 int = 0
  16867. for _, item := range rf {
  16868. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16869. insutypes = append(insutypes, item)
  16870. }
  16871. }
  16872. if len(insutypes) == 1 {
  16873. insutype = insutypes[0].Insutype
  16874. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16875. } else {
  16876. for _, i := range insutypes {
  16877. if i.Insutype == "390" {
  16878. is390 = 1
  16879. }
  16880. if i.Insutype == "310" {
  16881. is310 = 1
  16882. }
  16883. }
  16884. }
  16885. if is390 == 1 {
  16886. insutype = "390"
  16887. }
  16888. if is310 == 1 {
  16889. insutype = "310"
  16890. }
  16891. if len(insutypes) == 0 {
  16892. insutype = "310"
  16893. }
  16894. service.CreateHisPsn(psn)
  16895. c.ServeSuccessJSON(map[string]interface{}{
  16896. "patient": patient,
  16897. "number": token,
  16898. "insutype": insutype,
  16899. })
  16900. }
  16901. } else {
  16902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16903. return
  16904. }
  16905. } else { //读卡失败
  16906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16907. return
  16908. }
  16909. }
  16910. break
  16911. }
  16912. }
  16913. var initFlag int64 = 0
  16914. var initEleFlag int64 = 0
  16915. func (c *HisApiController) TestGetBasBaseInit() {
  16916. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16917. Iinit := DllDef.MustFindProc("Init")
  16918. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16919. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  16920. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  16921. if ret != 0 {
  16922. fmt.Println("SSCard的报错原因:", err)
  16923. fmt.Println("SSCard的运算结果为:", ret)
  16924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16925. return
  16926. }
  16927. result := int(ret)
  16928. fmt.Println("SSCard的运算结果为1:", result)
  16929. initFlag = 1
  16930. return
  16931. }
  16932. func (c *HisApiController) HandleJiangXiReadCard() {
  16933. fmt.Println("~~~~~~")
  16934. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16935. admin_user_id, _ := c.GetInt64("admin_user_id")
  16936. id_card_type, _ := c.GetInt64("id_card_type")
  16937. //certificates, _ := c.GetInt64("certificates")
  16938. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16939. if initFlag == 0 {
  16940. c.TestGetJiangXiBasBaseInit()
  16941. }
  16942. basStr := c.GetBasBaseInfo()
  16943. if len(basStr) == 0 {
  16944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16945. return
  16946. }
  16947. fmt.Println(basStr)
  16948. bas := strings.Split(basStr, "|")
  16949. basNumber := bas[1]
  16950. fmt.Println(basNumber)
  16951. card_sn := bas[3]
  16952. fmt.Println(card_sn)
  16953. 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, "")
  16954. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  16955. var dat map[string]interface{}
  16956. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16957. fmt.Println(dat)
  16958. } else {
  16959. fmt.Println(err)
  16960. }
  16961. userJSONBytes, _ := json.Marshal(dat)
  16962. var res ResultTwo
  16963. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16964. utils.ErrorLog("解析失败:%v", err)
  16965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16966. return
  16967. }
  16968. if res.Infcode == 0 {
  16969. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  16970. if err == gorm.ErrRecordNotFound {
  16971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16972. return
  16973. } else if err != nil {
  16974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16975. return
  16976. } else {
  16977. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16978. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16979. infoStr := string(Iinfos)
  16980. idetinfoStr := string(Idetinfos)
  16981. psn := &models.HisPsn{
  16982. PsnNo: res.Output.Baseinfo.PsnNo,
  16983. PatientId: patient.ID,
  16984. Certno: res.Output.Baseinfo.Certno,
  16985. Gend: res.Output.Baseinfo.Gend,
  16986. Naty: res.Output.Baseinfo.Naty,
  16987. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16988. PsnName: res.Output.Baseinfo.PsnName,
  16989. Idetinfo: idetinfoStr,
  16990. Insuinfo: infoStr,
  16991. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16992. CardInfo: basStr,
  16993. VerifyNumber: "",
  16994. }
  16995. service.CreateHisPsn(psn)
  16996. c.ServeSuccessJSON(map[string]interface{}{
  16997. "patient": patient,
  16998. "number": basNumber,
  16999. })
  17000. }
  17001. } else {
  17002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17003. return
  17004. }
  17005. }
  17006. func (c *HisApiController) TestGetHnBasBaseInit() {
  17007. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17008. Iinit := DllDef.MustFindProc("Init")
  17009. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17010. //http://10.77.211.236/CSB/hsa-fsi-1303
  17011. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17012. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17013. // 调用 Init 函数
  17014. 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"))))
  17015. //if ret != 0 {
  17016. fmt.Println("SSCard的报错原因:", err)
  17017. fmt.Println("SSCard的运算结果为:", ret)
  17018. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17019. // return
  17020. //}
  17021. result := int(ret)
  17022. fmt.Println("SSCard的运算结果为1:", result)
  17023. initFlag = 1
  17024. return
  17025. }
  17026. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17027. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17028. Iinit := DllDef.MustFindProc("Init")
  17029. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17030. //http://10.77.211.236/CSB/hsa-fsi-1303
  17031. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  17032. if ret != 0 {
  17033. fmt.Println("SSCard的报错原因:", err)
  17034. fmt.Println("SSCard的运算结果为:", ret)
  17035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17036. return
  17037. }
  17038. result := int(ret)
  17039. fmt.Println("SSCard的运算结果为1:", result)
  17040. initFlag = 1
  17041. return
  17042. }
  17043. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17044. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17045. Iinit := DllDef.MustFindProc("Init")
  17046. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17047. //http://10.77.211.236/CSB/hsa-fsi-1303
  17048. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17049. if ret != 0 {
  17050. fmt.Println("SSCard的报错原因:", err)
  17051. fmt.Println("SSCard的运算结果为:", ret)
  17052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17053. return
  17054. }
  17055. result := int(ret)
  17056. fmt.Println("SSCard的运算结果为1:", result)
  17057. initFlag = 1
  17058. return
  17059. }
  17060. func (c *HisApiController) GetSFZBaseInfo() string {
  17061. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17062. readCard := DllDef.MustFindProc("ReadSFZ")
  17063. if readCard == nil {
  17064. fmt.Println("readcard is nil")
  17065. readCard = DllDef.MustFindProc("ReadSFZ")
  17066. }
  17067. str := make([]byte, 8096)
  17068. str1 := make([]byte, 8096)
  17069. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17070. fmt.Println(r)
  17071. return Remove0000(string(str))
  17072. }
  17073. func (c *HisApiController) GetEleBaseInfo() string {
  17074. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17075. readCard := DllDef.MustFindProc("GetQRBase")
  17076. fmt.Println(readCard)
  17077. if readCard == nil {
  17078. fmt.Println("readcard is nil")
  17079. readCard = DllDef.MustFindProc("GetQRBase")
  17080. }
  17081. str := make([]byte, 1024)
  17082. str1 := make([]byte, 1024)
  17083. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17084. fmt.Println(ret2)
  17085. fmt.Println(string(str1))
  17086. fmt.Println(string(str))
  17087. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17088. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17089. if ret2 != 0 {
  17090. return ""
  17091. }
  17092. return string(str)
  17093. }
  17094. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17095. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17096. readCard := DllDef.MustFindProc("NationEcTrans")
  17097. fmt.Println(readCard)
  17098. fmt.Println("!!!!!")
  17099. pBusiCardInfo := make([]byte, 2048)
  17100. input := make(map[string]interface{})
  17101. inputData := make(map[string]interface{})
  17102. inputData["orgId"] = code
  17103. inputData["businessType"] = "01101"
  17104. inputData["operatorId"] = "1"
  17105. inputData["operatorName"] = "admin"
  17106. inputData["officeId"] = "001"
  17107. inputData["officeName"] = "血透室"
  17108. inputData["deviceType"] = ""
  17109. input["data"] = inputData
  17110. input["orgId"] = code
  17111. input["transType"] = "ec.query"
  17112. bytesData, _ := json.Marshal(input)
  17113. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17114. fmt.Println(ret2)
  17115. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17116. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17117. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17118. }
  17119. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17120. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17121. readCard := DllDef.MustFindProc("NationEcTrans")
  17122. fmt.Println(readCard)
  17123. fmt.Println("!!!!!")
  17124. pBusiCardInfo := make([]byte, 2048)
  17125. input := make(map[string]interface{})
  17126. inputData := make(map[string]interface{})
  17127. inputData["orgId"] = code
  17128. inputData["businessType"] = "01101"
  17129. inputData["operatorId"] = "9"
  17130. inputData["operatorName"] = "admin"
  17131. inputData["officeId"] = "001"
  17132. inputData["officeName"] = "血透室"
  17133. inputData["deviceType"] = ""
  17134. input["data"] = inputData
  17135. input["orgId"] = code
  17136. input["transType"] = "ec.query"
  17137. bytesData, _ := json.Marshal(input)
  17138. 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])))
  17139. fmt.Println(ret2)
  17140. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17141. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17142. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17143. }
  17144. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17145. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17146. readCard := DllDef.MustFindProc("NationEcTrans")
  17147. fmt.Println(readCard)
  17148. fmt.Println("!!!!!")
  17149. pBusiCardInfo := make([]byte, 2048)
  17150. input := make(map[string]interface{})
  17151. inputData := make(map[string]interface{})
  17152. inputData["orgId"] = code
  17153. inputData["businessType"] = "01301"
  17154. inputData["operatorId"] = "9"
  17155. inputData["operatorName"] = "admin"
  17156. inputData["officeId"] = "001"
  17157. inputData["officeName"] = "血透室"
  17158. inputData["deviceType"] = ""
  17159. input["data"] = inputData
  17160. input["orgId"] = code
  17161. input["transType"] = "ec.query"
  17162. bytesData, _ := json.Marshal(input)
  17163. 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])))
  17164. fmt.Println(ret2)
  17165. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17166. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17167. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17168. }
  17169. func GetJxEleBaseInfo(org_id int64) string {
  17170. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17171. readCard := DllDef.MustFindProc("NationEcTrans")
  17172. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17173. if readCard == nil {
  17174. fmt.Println("readcard is nil")
  17175. readCard = DllDef.MustFindProc("NationEcTrans")
  17176. }
  17177. str1 := make([]byte, 1024)
  17178. data := make(map[string]interface{})
  17179. inputData := make(map[string]interface{})
  17180. inputData["orgId"] = miConfig.Code
  17181. inputData["businessType"] = "01101"
  17182. inputData["operatorId"] = "test001"
  17183. inputData["operatorName"] = "cn"
  17184. inputData["officeId"] = "32760"
  17185. inputData["officeName"] = "waike"
  17186. inputData["deviceType"] = ""
  17187. data["data"] = inputData
  17188. data["transType"] = "ec.query"
  17189. data["extra "] = ""
  17190. data["orgId"] = miConfig.Code
  17191. bytesData, _ := json.Marshal(data)
  17192. //bytesData, _ := json.Marshal(data)
  17193. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17194. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17195. fmt.Println(ret2)
  17196. fmt.Println(string(str1))
  17197. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17198. if ret2 != 0 {
  17199. return ""
  17200. }
  17201. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17202. }
  17203. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17204. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17205. // readCard := DllDef.MustFindProc("NationEcTrans")
  17206. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17207. //
  17208. // if readCard == nil {
  17209. // fmt.Println("readcard is nil")
  17210. // readCard = DllDef.MustFindProc("NationEcTrans")
  17211. // }
  17212. // str1 := make([]byte, 1024)
  17213. //
  17214. // data := make(map[string]interface{})
  17215. //
  17216. // inputData := make(map[string]interface{})
  17217. // inputData["orgId"] = miConfig.Code
  17218. // inputData["businessType"] = "01101"
  17219. // inputData["operatorId"] = "test001"
  17220. // inputData["operatorName"] = "cn"
  17221. // inputData["officeId"] = "32760"
  17222. // inputData["officeName"] = "waike"
  17223. // inputData["deviceType"] = ""
  17224. //
  17225. // data["data"] = inputData
  17226. // data["transType"] = "ec.query"
  17227. // data["extra "] = ""
  17228. // data["orgId"] = miConfig.Code
  17229. // bytesData, _ := json.Marshal(data)
  17230. // //bytesData, _ := json.Marshal(data)
  17231. //
  17232. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17233. //
  17234. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17235. // fmt.Println(ret2)
  17236. // fmt.Println(string(str1))
  17237. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17238. //
  17239. // if ret2 != 0 {
  17240. // return ""
  17241. // }
  17242. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17243. //}
  17244. func GetJxEleBaseInitInfo(org_id int64) string {
  17245. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17246. readCard := DllDef.MustFindProc("NationEcTrans")
  17247. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17248. if readCard == nil {
  17249. fmt.Println("readcard is nil")
  17250. readCard = DllDef.MustFindProc("NationEcTrans")
  17251. }
  17252. str1 := make([]byte, 2048)
  17253. data := make(map[string]interface{})
  17254. inputData := make(map[string]interface{})
  17255. inputData["orgId"] = miConfig.Code
  17256. inputData["businessType"] = "01101"
  17257. inputData["operatorId"] = "1"
  17258. inputData["operatorName"] = "huangchuang"
  17259. inputData["officeId"] = "101"
  17260. inputData["officeName"] = "xuetou"
  17261. inputData["deviceType"] = ""
  17262. data["data"] = inputData
  17263. data["transType"] = "ec.query"
  17264. data["orgId"] = miConfig.Code
  17265. bytesData, _ := json.Marshal(data)
  17266. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17267. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17268. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17269. fmt.Println(ret2)
  17270. fmt.Println(string(str1))
  17271. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17272. if ret2 != 0 {
  17273. return ""
  17274. }
  17275. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17276. initEleFlag = 1
  17277. }
  17278. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17279. }
  17280. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17281. // // 构建命令
  17282. // cmd := exec.Command("python", "b.py")
  17283. //
  17284. // // 执行命令并等待完成
  17285. // output, err := cmd.CombinedOutput()
  17286. // if err != nil {
  17287. // fmt.Println("Error executing Python script:", err)
  17288. // return
  17289. // }
  17290. //
  17291. // // 打印Python脚本的输出
  17292. // fmt.Println(string(output))
  17293. //}
  17294. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17295. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17296. readCard := DllDef.MustFindProc("gxyb_call")
  17297. if readCard == nil {
  17298. fmt.Println("readcard is nil")
  17299. readCard = DllDef.MustFindProc("gxyb_call")
  17300. }
  17301. str := make([]byte, 1024)
  17302. str1 := make([]byte, 1024)
  17303. //data := make(map[string]interface{})
  17304. currentTime := time.Now()
  17305. // 格式化时间为 "YYYYMMDDHH24MISS"
  17306. formattedTime := currentTime.Format("20060102150405")
  17307. inputData := make(map[string]interface{})
  17308. inputData2 := make(map[string]interface{})
  17309. inputData["transNo"] = "1401"
  17310. inputData["transType"] = "passwordCheck"
  17311. inputData["timestamp"] = formattedTime
  17312. inputData2["fixmedinsCode"] = code
  17313. inputData2["psnNo"] = ""
  17314. inputData["data"] = inputData2
  17315. jsonBytes, err := json.Marshal(inputData)
  17316. if err != nil {
  17317. fmt.Println("Error encoding map to JSON:", err)
  17318. }
  17319. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17320. fmt.Println(string(str1))
  17321. fmt.Println(string(str))
  17322. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17323. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17324. if ret2 != 0 {
  17325. return ""
  17326. }
  17327. return string(str)
  17328. }
  17329. func (c *HisApiController) GetoleInfo() Response {
  17330. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17331. defer ole.CoUninitialize()
  17332. // Replace with the ProgID or CLSID of your COM object
  17333. progID := "YinHai.XJ.Actual.Interface.New"
  17334. // Create COM object
  17335. unknown, err := oleutil.CreateObject(progID)
  17336. if err != nil {
  17337. fmt.Println("Unable to create COM object:", err)
  17338. }
  17339. defer unknown.Release()
  17340. // Query for the IDispatch interface
  17341. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17342. if err != nil {
  17343. fmt.Println("Unable to get IDispatch interface:", err)
  17344. }
  17345. defer dispatch.Release()
  17346. // Prepare parameters
  17347. transNo := "1401"
  17348. transType := "passwordCheck"
  17349. timestamp := time.Now().Unix()
  17350. fixmedinsCode := "H45072101171"
  17351. psnNo := ""
  17352. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17353. result2 := ""
  17354. // Call COM object's method using the IDispatch interface
  17355. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17356. fmt.Println(resulr)
  17357. fmt.Println(result2)
  17358. if err != nil {
  17359. fmt.Println("调用COM对象方法失败:", err)
  17360. }
  17361. var response Response
  17362. err2 := json.Unmarshal([]byte(result2), &response)
  17363. if err2 != nil {
  17364. fmt.Println("解析JSON失败:", err)
  17365. }
  17366. return response
  17367. }
  17368. func (c *HisApiController) GetBasBaseInfo() string {
  17369. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17370. readCard := DllDef.MustFindProc("ReadCardBas")
  17371. if readCard == nil {
  17372. fmt.Println("readcard is nil")
  17373. readCard = DllDef.MustFindProc("ReadCardBas")
  17374. }
  17375. str := make([]byte, 1024)
  17376. str1 := make([]byte, 1024)
  17377. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17378. fmt.Println(string(str1))
  17379. fmt.Println(string(str))
  17380. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17381. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17382. if ret2 != 0 {
  17383. return ""
  17384. }
  17385. return string(str)
  17386. }
  17387. type Program struct {
  17388. FunctionID string `xml:"function_id"`
  17389. CardInfo string `xml:"cardinfo"`
  17390. User string `xml:"user"`
  17391. }
  17392. func (c *HisApiController) GetBasBaseInfo1111() string {
  17393. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17394. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17395. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17396. if readCard == nil {
  17397. fmt.Println("readcard is nil")
  17398. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17399. }
  17400. if readCard2 == nil {
  17401. fmt.Println("readcard is nil")
  17402. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17403. }
  17404. str := make([]byte, 1024)
  17405. str1 := make([]byte, 1024)
  17406. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17407. str3 := make([]byte, 1024)
  17408. str4 := make([]byte, 1024)
  17409. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17410. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17411. //if err != nil {
  17412. // fmt.Println("Error opening file:", err)
  17413. //}
  17414. //defer file.Close()
  17415. //
  17416. //var lastProgram Program
  17417. //scanner := bufio.NewScanner(file)
  17418. //inProgram := false
  17419. //
  17420. //for scanner.Scan() {
  17421. // line := scanner.Text()
  17422. // if strings.Contains(line, "<program>") {
  17423. // inProgram = true
  17424. // programXML := "<program>"
  17425. // for scanner.Scan() {
  17426. // line = scanner.Text()
  17427. // programXML += line
  17428. // if strings.Contains(line, "</program>") {
  17429. // programXML += "</program>"
  17430. // break
  17431. // }
  17432. // }
  17433. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17434. // // 解析成功,更新最后的 Program
  17435. // }
  17436. // inProgram = false
  17437. // }
  17438. //}
  17439. //
  17440. // fmt.Println("Error reading file:", inProgram)
  17441. //
  17442. //if err := scanner.Err(); err != nil {
  17443. // fmt.Println("Error reading file:", err)
  17444. //}
  17445. // 输出最后一次的 Program
  17446. //fmt.Printf("最后一次的 <program>:\n")
  17447. //fmt.Printf("<program>\n")
  17448. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17449. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17450. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17451. //fmt.Printf("</program>\n")
  17452. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17453. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17454. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17455. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17456. return ConvertToString(string(str), "gbk", "utf-8")
  17457. }
  17458. func (c *HisApiController) GetBasBaseInfo22222() string {
  17459. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17460. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17461. if readCard == nil {
  17462. fmt.Println("readcard is nil")
  17463. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17464. }
  17465. str := make([]byte, 1024)
  17466. str1 := make([]byte, 1024)
  17467. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17468. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17469. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17470. //if err != nil {
  17471. // fmt.Println("Error opening file:", err)
  17472. //}
  17473. //defer file.Close()
  17474. //
  17475. //var lastProgram Program
  17476. //scanner := bufio.NewScanner(file)
  17477. //inProgram := false
  17478. //
  17479. //for scanner.Scan() {
  17480. // line := scanner.Text()
  17481. // if strings.Contains(line, "<program>") {
  17482. // inProgram = true
  17483. // programXML := "<program>"
  17484. // for scanner.Scan() {
  17485. // line = scanner.Text()
  17486. // programXML += line
  17487. // if strings.Contains(line, "</program>") {
  17488. // programXML += "</program>"
  17489. // break
  17490. // }
  17491. // }
  17492. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17493. // // 解析成功,更新最后的 Program
  17494. // }
  17495. // inProgram = false
  17496. // }
  17497. //}
  17498. //
  17499. // fmt.Println("Error reading file:", inProgram)
  17500. //
  17501. //if err := scanner.Err(); err != nil {
  17502. // fmt.Println("Error reading file:", err)
  17503. //}
  17504. // 输出最后一次的 Program
  17505. //fmt.Printf("最后一次的 <program>:\n")
  17506. //fmt.Printf("<program>\n")
  17507. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17508. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17509. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17510. //fmt.Printf("</program>\n")
  17511. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17512. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17513. return ConvertToString(string(str1), "gbk", "utf-8")
  17514. }
  17515. func (c *HisApiController) GetahBasBaseInfo() string {
  17516. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17517. readCard := DllDef.MustFindProc("iReadCardBas")
  17518. if readCard == nil {
  17519. fmt.Println("readcard is nil")
  17520. readCard = DllDef.MustFindProc("iReadCardBas")
  17521. }
  17522. //str := make([]byte, 1024)
  17523. str1 := make([]byte, 1024)
  17524. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17525. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17526. //if err != nil {
  17527. // fmt.Println("Error opening file:", err)
  17528. //}
  17529. //defer file.Close()
  17530. //
  17531. //var lastProgram Program
  17532. //scanner := bufio.NewScanner(file)
  17533. //inProgram := false
  17534. //
  17535. //for scanner.Scan() {
  17536. // line := scanner.Text()
  17537. // if strings.Contains(line, "<program>") {
  17538. // inProgram = true
  17539. // programXML := "<program>"
  17540. // for scanner.Scan() {
  17541. // line = scanner.Text()
  17542. // programXML += line
  17543. // if strings.Contains(line, "</program>") {
  17544. // programXML += "</program>"
  17545. // break
  17546. // }
  17547. // }
  17548. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17549. // // 解析成功,更新最后的 Program
  17550. // }
  17551. // inProgram = false
  17552. // }
  17553. //}
  17554. //
  17555. // fmt.Println("Error reading file:", inProgram)
  17556. //
  17557. //if err := scanner.Err(); err != nil {
  17558. // fmt.Println("Error reading file:", err)
  17559. //}
  17560. // 输出最后一次的 Program
  17561. //fmt.Printf("最后一次的 <program>:\n")
  17562. //fmt.Printf("<program>\n")
  17563. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17564. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17565. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17566. //fmt.Printf("</program>\n")
  17567. fmt.Println(string(str1))
  17568. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17569. if ret2 != 0 {
  17570. return ""
  17571. }
  17572. return string(str1)
  17573. }
  17574. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17575. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17576. readCard := DllDef.MustFindProc("read_cardinfo")
  17577. if readCard == nil {
  17578. fmt.Println("readcard is nil")
  17579. readCard = DllDef.MustFindProc("read_cardinfo")
  17580. }
  17581. str := make([]byte, 1024) //卡号
  17582. str1 := make([]byte, 1024) //卡识别码
  17583. str2 := make([]byte, 1024) //身份证号
  17584. str3 := make([]byte, 1024) //姓名
  17585. str4 := make([]byte, 1024) //错误信息
  17586. 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])))
  17587. fmt.Println(string(str1))
  17588. fmt.Println(string(str))
  17589. fmt.Println(string(str2))
  17590. fmt.Println(string(str3))
  17591. fmt.Println(string(str4))
  17592. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17593. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17594. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17595. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17596. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17597. if ret2 != 0 {
  17598. return "", "", "", "", ""
  17599. }
  17600. return string(str), string(str1), string(str2), string(str3), string(str4)
  17601. }
  17602. type CustomFundPay struct {
  17603. FundPayType string `json:"fund_pay_type"`
  17604. FundPayamt float64 `json:"fund_payamt"`
  17605. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17606. }
  17607. //func (c *HisApiController) GetBatchSettleList() {
  17608. // start_time_str := c.GetString("start_time")
  17609. // //end_time_str := c.GetString("end_time")
  17610. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17611. //
  17612. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17613. //
  17614. // for _, item := range orders {
  17615. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17616. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17617. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17618. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17619. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17620. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17621. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17622. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17623. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17624. //
  17625. // if order.ID == 0 {
  17626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17627. // return
  17628. // }
  17629. //
  17630. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17631. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17632. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17633. // //fmt.Println(count)
  17634. // //var zero string
  17635. // //number := count + 1
  17636. // //if number >= 1000 {
  17637. // // zero = "0000" + strconv.FormatInt(number, 10)
  17638. // //} else if number >= 10000 {
  17639. // // zero = "000" + strconv.FormatInt(number, 10)
  17640. // //} else if number >= 100000 {
  17641. // // zero = "00" + strconv.FormatInt(number, 10)
  17642. // //} else if number >= 1000000 {
  17643. // // zero = "0" + strconv.FormatInt(number, 10)
  17644. // //} else {
  17645. // // zero = strconv.FormatInt(number, 10)
  17646. // //}
  17647. // //fmt.Println(zero)
  17648. //
  17649. // struct4101 := service.Struct4101{
  17650. // PsnNo: order.PsnNo,
  17651. // MdtrtId: order.MdtrtId,
  17652. // SetlId: order.SetlId,
  17653. // PsnName: order.PsnName,
  17654. // Gend: order.Gend,
  17655. // Brdy: his.Brdy,
  17656. // Age: his.Age,
  17657. // Naty: order.Naty,
  17658. // PatnCertType: "01",
  17659. // Certno: order.Certno,
  17660. // Prfs: "90",
  17661. // ConerName: roles[0].UserName,
  17662. // PatnRlts: "99",
  17663. // ConerAddr: miConfig.OrgName,
  17664. // ConerTel: admin.Mobile,
  17665. // HiType: order.Insutype,
  17666. // Insuplc: miConfig.InsuplcAdmdvs,
  17667. // MaindiagFlag: "1",
  17668. // BillCode: order.SetlId,
  17669. // BillNo: order.SetlId,
  17670. // BizSn: order.Number,
  17671. // PsnSelfPay: order.PsnPartAmt,
  17672. // PsnOwnPay: order.PsnPartAmt,
  17673. // AcctPay: order.AcctPay,
  17674. // PsnCashpay: order.PsnCashPay,
  17675. // HiPaymtd: "1",
  17676. // Hsorg: miConfig.InsuplcAdmdvs,
  17677. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17678. // MedinsFillPsn: curRoles.UserName,
  17679. // MedinsFillDept: miConfig.OrgName,
  17680. // IptMedType: "2",
  17681. // }
  17682. // struct4101.SetlBegnDate = order.SetlTime
  17683. // struct4101.SetlEndDate = order.SetlTime
  17684. // time_arr := strings.Split(order.SetlTime, " ")
  17685. // struct4101.AdmTime = time_arr[0]
  17686. // struct4101.AdmEndTime = time_arr[0]
  17687. //
  17688. // var rf []CustomFundPay
  17689. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17690. //
  17691. // var tempFunPays []service.CustomStruct
  17692. // for _, item := range rf {
  17693. // var tempFunPay service.CustomStruct
  17694. // tempFunPay.FundPayamt = item.FundPayamt
  17695. // tempFunPay.FundPayType = item.FundPayType
  17696. // tempFunPays = append(tempFunPays, tempFunPay)
  17697. // }
  17698. // struct4101.CustomStruct = tempFunPays
  17699. //
  17700. // var tempDiaginfos []service.DiaginfoStructTwo
  17701. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17702. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17703. //
  17704. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17705. // var config []*models.HisXtDiagnoseConfig
  17706. // for _, item := range diagnosis_ids {
  17707. // id, _ := strconv.ParseInt(item, 10, 64)
  17708. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17709. // config = append(config, &diagnosisConfig)
  17710. // }
  17711. //
  17712. // for index, item := range config {
  17713. // if index == 0 {
  17714. // var tempDiaginfo service.DiaginfoStructTwo
  17715. // tempDiaginfo.DiagCode = item.CountryCode
  17716. // tempDiaginfo.DiagName = item.CountryContentName
  17717. // tempDiaginfo.DiagType = "1"
  17718. // tempDiaginfo.MaindiagFlag = "1"
  17719. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17720. // } else {
  17721. // var tempDiaginfo service.DiaginfoStructTwo
  17722. // tempDiaginfo.DiagCode = item.CountryCode
  17723. // tempDiaginfo.DiagName = item.CountryContentName
  17724. // tempDiaginfo.DiagType = "1"
  17725. // tempDiaginfo.MaindiagFlag = "0"
  17726. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17727. // }
  17728. // }
  17729. // struct4101.Diseinfo = tempDiaginfos
  17730. //
  17731. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17732. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17733. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17734. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17735. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17736. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17737. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17738. //
  17739. // var iteminfo service.IteminfoStruct
  17740. //
  17741. // var bedCostTotal float64 = 0 //床位总费
  17742. // var bedCostSelfTotal float64 = 0 //床位自费
  17743. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17744. //
  17745. // var operationCostTotal float64 = 0 //手术费
  17746. // var operationCostSelfTotal float64 = 0 //手术费
  17747. // var operationCostPartSelfTotal float64 = 0 //手术费
  17748. //
  17749. // var otherCostTotal float64 = 0 //其他费用
  17750. // var otherCostSelfTotal float64 = 0 //其他费用
  17751. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17752. //
  17753. // var materialCostTotal float64 = 0 //材料费
  17754. // var materialCostSelfTotal float64 = 0 //材料费
  17755. // var materialCostPartSelfTotal float64 = 0 //材料费
  17756. //
  17757. // var westernMedicineCostTotal float64 = 0 //西药费
  17758. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17759. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17760. //
  17761. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17762. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17763. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17764. //
  17765. // var checkCostTotal float64 = 0 //检查费
  17766. // var checkCostSelfTotal float64 = 0 //检查费
  17767. // var checkCostPartSelfTotal float64 = 0 //检查费
  17768. //
  17769. // var laboratoryCostTotal float64 = 0 //化验费
  17770. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17771. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17772. //
  17773. // var treatCostTotal float64 = 0 //治疗费用
  17774. // var treatCostSelfTotal float64 = 0 //治疗费用
  17775. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17776. //
  17777. // decimal.DivisionPrecision = 2
  17778. //
  17779. // var bed_fulamt_ownpay_amt float64 = 0
  17780. // var operation_fulamt_ownpay_amt float64 = 0
  17781. // var other_fulamt_ownpay_amt float64 = 0
  17782. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17783. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17784. // var check_fulamt_ownpay_amt float64 = 0
  17785. // var material_fulamt_ownpay_amt float64 = 0
  17786. // var laboratory_fulamt_ownpay_amt float64 = 0
  17787. // var treat_fulamt_ownpay_amt float64 = 0
  17788. //
  17789. // var bed_claa_sunmfee float64 = 0
  17790. // var bed_clab_amt float64 = 0
  17791. // var bed_other_amt float64 = 0
  17792. //
  17793. // var operation_claa_sunmfee float64 = 0
  17794. // var operation_clab_amt float64 = 0
  17795. // var operation_other_amt float64 = 0
  17796. //
  17797. // var other_claa_sunmfee float64 = 0
  17798. // var other_clab_amt float64 = 0
  17799. // var other_other_amt float64 = 0
  17800. //
  17801. // var westernMedicine_claa_sunmfee float64 = 0
  17802. // var westernMedicine_clab_amt float64 = 0
  17803. // var westernMedicine_other_amt float64 = 0
  17804. //
  17805. // var chineseTraditional_claa_sunmfee float64 = 0
  17806. // var chineseTraditional_clab_amt float64 = 0
  17807. // var chineseTraditional_other_amt float64 = 0
  17808. //
  17809. // var check_claa_sunmfee float64 = 0
  17810. // var check_clab_amt float64 = 0
  17811. // var check_other_amt float64 = 0
  17812. //
  17813. // var material_claa_sunmfee float64 = 0
  17814. // var material_clab_amt float64 = 0
  17815. // var material_other_amt float64 = 0
  17816. //
  17817. // var laboratory_claa_sunmfee float64 = 0
  17818. // var laboratory_clab_amt float64 = 0
  17819. // var laboratory_other_amt float64 = 0
  17820. //
  17821. // var treat_claa_sunmfee float64 = 0
  17822. // var treat_clab_amt float64 = 0
  17823. // var treat_other_amt float64 = 0
  17824. //
  17825. // for _, item := range order.HisOrderInfo {
  17826. // if item.MedChrgitmType == "01" { //床位费
  17827. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17828. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17829. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17830. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17831. // if item.ChrgitmLv == "1" {
  17832. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17833. // }
  17834. // if item.ChrgitmLv == "2" {
  17835. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17836. //
  17837. // }
  17838. // if item.ChrgitmLv == "3" {
  17839. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17840. // }
  17841. //
  17842. // }
  17843. //
  17844. // if item.MedChrgitmType == "03" { //检查费
  17845. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17846. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17847. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17848. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17849. // if item.ChrgitmLv == "1" {
  17850. //
  17851. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17852. //
  17853. // }
  17854. // if item.ChrgitmLv == "2" {
  17855. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17856. //
  17857. // }
  17858. // if item.ChrgitmLv == "3" {
  17859. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17860. // }
  17861. // }
  17862. //
  17863. // if item.MedChrgitmType == "04" { //化验费
  17864. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17865. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17866. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17867. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17868. // if item.ChrgitmLv == "1" {
  17869. //
  17870. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17871. //
  17872. // }
  17873. // if item.ChrgitmLv == "2" {
  17874. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17875. //
  17876. // }
  17877. // if item.ChrgitmLv == "3" {
  17878. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17879. // }
  17880. // }
  17881. //
  17882. // if item.MedChrgitmType == "05" { //治疗费
  17883. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17884. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17885. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17886. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17887. // if item.ChrgitmLv == "1" {
  17888. //
  17889. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17890. //
  17891. // }
  17892. // if item.ChrgitmLv == "2" {
  17893. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17894. //
  17895. // }
  17896. // if item.ChrgitmLv == "3" {
  17897. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17898. // }
  17899. // }
  17900. //
  17901. // if item.MedChrgitmType == "06" { //手术费
  17902. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17903. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17904. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17905. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17906. //
  17907. // if item.ChrgitmLv == "1" {
  17908. //
  17909. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17910. //
  17911. // }
  17912. // if item.ChrgitmLv == "2" {
  17913. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17914. //
  17915. // }
  17916. // if item.ChrgitmLv == "3" {
  17917. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17918. // }
  17919. // }
  17920. //
  17921. // if item.MedChrgitmType == "08" { //材料费
  17922. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17923. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17924. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17925. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17926. // if item.ChrgitmLv == "1" {
  17927. //
  17928. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17929. //
  17930. // }
  17931. // if item.ChrgitmLv == "2" {
  17932. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17933. //
  17934. // }
  17935. // if item.ChrgitmLv == "3" {
  17936. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17937. // }
  17938. // }
  17939. //
  17940. // if item.MedChrgitmType == "09" { //西药费
  17941. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17942. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17943. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17944. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17945. // if item.ChrgitmLv == "1" {
  17946. //
  17947. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17948. //
  17949. // }
  17950. // if item.ChrgitmLv == "2" {
  17951. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17952. //
  17953. // }
  17954. // if item.ChrgitmLv == "3" {
  17955. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17956. // }
  17957. // }
  17958. //
  17959. // if item.MedChrgitmType == "11" { //中成费
  17960. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17961. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17962. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17963. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17964. // if item.ChrgitmLv == "1" {
  17965. //
  17966. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17967. //
  17968. // }
  17969. // if item.ChrgitmLv == "2" {
  17970. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17971. //
  17972. // }
  17973. // if item.ChrgitmLv == "3" {
  17974. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17975. // }
  17976. // }
  17977. //
  17978. // if item.MedChrgitmType == "14" { //其他费
  17979. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17980. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17981. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17982. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17983. // if item.ChrgitmLv == "1" {
  17984. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17985. //
  17986. // }
  17987. // if item.ChrgitmLv == "2" {
  17988. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17989. //
  17990. // }
  17991. // if item.ChrgitmLv == "3" {
  17992. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17993. // }
  17994. // }
  17995. //
  17996. // }
  17997. //
  17998. // var iteminfoStructs []service.IteminfoStruct
  17999. //
  18000. // if bedCostTotal != 0 {
  18001. // iteminfo.MedChrgitm = "01"
  18002. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18003. // iteminfo.Amt = bedCostTotal
  18004. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18005. // iteminfo.ClabAmt = bed_clab_amt
  18006. // iteminfo.OthAmt = bed_other_amt
  18007. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18008. // }
  18009. //
  18010. // if checkCostTotal != 0 {
  18011. // iteminfo.MedChrgitm = "03"
  18012. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18013. // iteminfo.Amt = checkCostTotal
  18014. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18015. // iteminfo.ClabAmt = check_clab_amt
  18016. // iteminfo.OthAmt = check_other_amt
  18017. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18018. //
  18019. // }
  18020. //
  18021. // if laboratoryCostTotal != 0 {
  18022. // iteminfo.MedChrgitm = "04"
  18023. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18024. // iteminfo.Amt = laboratoryCostTotal
  18025. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18026. // iteminfo.ClabAmt = laboratory_clab_amt
  18027. // iteminfo.OthAmt = laboratory_other_amt
  18028. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18029. //
  18030. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18031. //
  18032. // }
  18033. //
  18034. // if treatCostTotal != 0 {
  18035. // iteminfo.MedChrgitm = "05"
  18036. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18037. // iteminfo.Amt = treatCostTotal
  18038. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18039. // iteminfo.ClabAmt = treat_clab_amt
  18040. // iteminfo.OthAmt = treat_other_amt
  18041. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18042. // //(struct4101.IteminfoStruct, iteminfo)
  18043. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18044. // }
  18045. //
  18046. // if operationCostTotal != 0 {
  18047. // iteminfo.MedChrgitm = "06"
  18048. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18049. // iteminfo.Amt = operationCostTotal
  18050. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18051. // iteminfo.ClabAmt = operation_clab_amt
  18052. // iteminfo.OthAmt = operation_other_amt
  18053. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18054. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18055. // }
  18056. //
  18057. // if materialCostTotal != 0 {
  18058. // iteminfo.MedChrgitm = "08"
  18059. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18060. // iteminfo.Amt = materialCostTotal
  18061. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18062. // iteminfo.ClabAmt = material_clab_amt
  18063. // iteminfo.OthAmt = material_other_amt
  18064. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18065. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18066. // }
  18067. //
  18068. // if westernMedicineCostTotal != 0 {
  18069. // iteminfo.MedChrgitm = "09"
  18070. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18071. // iteminfo.Amt = westernMedicineCostTotal
  18072. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18073. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18074. // iteminfo.OthAmt = westernMedicine_other_amt
  18075. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18076. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18077. //
  18078. // }
  18079. // if chineseTraditionalMedicineCostTotal != 0 {
  18080. // iteminfo.MedChrgitm = "11"
  18081. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18082. // iteminfo.Amt = westernMedicineCostTotal
  18083. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18084. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18085. // iteminfo.OthAmt = westernMedicine_other_amt
  18086. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18087. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18088. //
  18089. // }
  18090. // if otherCostTotal != 0 {
  18091. // iteminfo.MedChrgitm = "14"
  18092. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18093. // iteminfo.Amt = otherCostTotal
  18094. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18095. // iteminfo.ClabAmt = other_clab_amt
  18096. // iteminfo.OthAmt = other_other_amt
  18097. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18098. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18099. //
  18100. // }
  18101. // struct4101.IteminfoStruct = iteminfoStructs
  18102. // struct4101.Ntly = "中国"
  18103. // struct4101.AdmCaty = "A03.06"
  18104. //
  18105. // struct4101.DoctorName = doctor.UserName
  18106. // struct4101.DoctorCode = doctor.DoctorNumber
  18107. //
  18108. // var res ResultSeventeen
  18109. //
  18110. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18111. // struct4101.BillCode = order.Number
  18112. // struct4101.BillNo = order.SetlId
  18113. // var resOther ResultSeventeenOther
  18114. // var pp models.PublicParams
  18115. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18116. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18117. // pp.FixmedinsName = miConfig.OrgName
  18118. // pp.FixmedinsCode = miConfig.Code
  18119. // pp.RequestUrl = miConfig.Url
  18120. // pp.Cainfo = miConfig.Cainfo
  18121. // pp.SecretKey = miConfig.SecretKey
  18122. // pp.AccessKey = miConfig.AccessKey
  18123. // pp.OpterName = curRoles.UserName
  18124. //
  18125. // client := &http.Client{}
  18126. // var req *http.Request
  18127. // data := make(map[string]interface{})
  18128. // data["struct4101"] = struct4101
  18129. // data["pp"] = pp
  18130. // bytesData, _ := json.Marshal(data)
  18131. // if miConfig.MdtrtareaAdmvs == "320921" {
  18132. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18133. // } else {
  18134. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18135. // }
  18136. // resp, _ := client.Do(req)
  18137. // defer resp.Body.Close()
  18138. // body, ioErr := ioutil.ReadAll(resp.Body)
  18139. // if ioErr != nil {
  18140. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18142. // return
  18143. // }
  18144. // var respJSON map[string]interface{}
  18145. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18146. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18147. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18148. // return
  18149. // }
  18150. //
  18151. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18152. // userJSONBytes, _ := json.Marshal(respJSON)
  18153. // fmt.Println("log")
  18154. // fmt.Println(string(userJSONBytes))
  18155. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18156. // utils.ErrorLog("解析失败:%v", err)
  18157. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18158. // return
  18159. // }
  18160. // res.InfRefmsgid = resOther.InfRefmsgid
  18161. // res.Output = resOther.Output
  18162. // res.ErrMsg = resOther.ErrMsg
  18163. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18164. // res.Infcode = infocode
  18165. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18166. //
  18167. // var pp models.PublicParams
  18168. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18169. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18170. // pp.FixmedinsName = miConfig.OrgName
  18171. // pp.FixmedinsCode = miConfig.Code
  18172. // pp.RequestUrl = miConfig.Url
  18173. // pp.Cainfo = miConfig.Cainfo
  18174. // pp.SecretKey = miConfig.SecretKey
  18175. // pp.AccessKey = miConfig.AccessKey
  18176. // pp.OpterName = curRoles.UserName
  18177. // result, _ := service.Jxyb4101(struct4101, pp)
  18178. // var dat map[string]interface{}
  18179. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18180. // fmt.Println(dat)
  18181. // } else {
  18182. // fmt.Println(err)
  18183. // }
  18184. // userJSONBytes, _ := json.Marshal(dat)
  18185. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18186. // utils.ErrorLog("解析失败:%v", err)
  18187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18188. // return
  18189. // }
  18190. //
  18191. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18192. // var pp models.PublicParams
  18193. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18194. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18195. // pp.FixmedinsName = miConfig.OrgName
  18196. // pp.FixmedinsCode = miConfig.Code
  18197. // pp.RequestUrl = miConfig.Url
  18198. // pp.Cainfo = miConfig.Cainfo
  18199. // pp.SecretKey = miConfig.SecretKey
  18200. // pp.AccessKey = miConfig.AccessKey
  18201. // pp.OpterName = curRoles.UserName
  18202. // result, _ := service.Hnyb4101(struct4101, pp)
  18203. // var dat map[string]interface{}
  18204. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18205. // fmt.Println(dat)
  18206. // } else {
  18207. // fmt.Println(err)
  18208. // }
  18209. // userJSONBytes, _ := json.Marshal(dat)
  18210. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18211. // utils.ErrorLog("解析失败:%v", err)
  18212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18213. // return
  18214. // }
  18215. //
  18216. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18217. // var resOther ResultSeventeenOther
  18218. //
  18219. // var pp models.PublicParams
  18220. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18221. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18222. // pp.FixmedinsName = miConfig.OrgName
  18223. // pp.FixmedinsCode = miConfig.Code
  18224. // pp.RequestUrl = miConfig.Url
  18225. // pp.Cainfo = miConfig.Cainfo
  18226. // pp.SecretKey = miConfig.SecretKey
  18227. // pp.AccessKey = miConfig.AccessKey
  18228. // pp.OpterName = curRoles.UserName
  18229. // client := &http.Client{}
  18230. // var req *http.Request
  18231. // data := make(map[string]interface{})
  18232. // data["struct4101"] = struct4101
  18233. // data["pp"] = pp
  18234. // bytesData, _ := json.Marshal(data)
  18235. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18236. // resp, _ := client.Do(req)
  18237. // defer resp.Body.Close()
  18238. // body, ioErr := ioutil.ReadAll(resp.Body)
  18239. // if ioErr != nil {
  18240. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18242. // return
  18243. // }
  18244. // var respJSON map[string]interface{}
  18245. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18246. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18247. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18248. // return
  18249. // }
  18250. //
  18251. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18252. // userJSONBytes, _ := json.Marshal(respJSON)
  18253. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18254. // utils.ErrorLog("解析失败:%v", err)
  18255. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18256. // return
  18257. // }
  18258. // res.InfRefmsgid = resOther.InfRefmsgid
  18259. // res.Output = resOther.Output
  18260. // res.ErrMsg = resOther.ErrMsg
  18261. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18262. // res.Infcode = infocode
  18263. //
  18264. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18265. // var pp models.PublicParams
  18266. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18267. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18268. // pp.FixmedinsName = miConfig.OrgName
  18269. // pp.FixmedinsCode = miConfig.Code
  18270. // pp.RequestUrl = miConfig.Url
  18271. // pp.Cainfo = miConfig.Cainfo
  18272. // pp.SecretKey = miConfig.SecretKey
  18273. // pp.AccessKey = miConfig.AccessKey
  18274. // pp.OpterName = curRoles.UserName
  18275. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18276. // fmt.Println(requestLog)
  18277. // fmt.Println(errMsgLog)
  18278. //
  18279. // saveLog(result, requestLog, "4101a", "上传清单")
  18280. //
  18281. // var dat map[string]interface{}
  18282. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18283. // fmt.Println(dat)
  18284. // } else {
  18285. // fmt.Println(err)
  18286. // }
  18287. // userJSONBytes, _ := json.Marshal(dat)
  18288. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18289. // utils.ErrorLog("解析失败:%v", err)
  18290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18291. // return
  18292. // }
  18293. //
  18294. // } else {
  18295. //
  18296. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18297. // var dat map[string]interface{}
  18298. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18299. // fmt.Println(dat)
  18300. // } else {
  18301. // fmt.Println(err)
  18302. // }
  18303. // userJSONBytes, _ := json.Marshal(dat)
  18304. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18305. // utils.ErrorLog("解析失败:%v", err)
  18306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18307. // return
  18308. // }
  18309. // }
  18310. //
  18311. // if res.Infcode != 0 {
  18312. // adminUser := c.GetAdminUserInfo()
  18313. // errlog := &models.HisOrderError{
  18314. // UserOrgId: adminUser.CurrentOrgId,
  18315. // Ctime: time.Now().Unix(),
  18316. // Mtime: time.Now().Unix(),
  18317. // ErrMsg: res.ErrMsg,
  18318. // Status: 1,
  18319. // PatientId: order.ID,
  18320. // Stage: 10265,
  18321. // }
  18322. // service.CreateErrMsgLog(errlog)
  18323. // continue
  18324. // } else {
  18325. // //order.FaPiaoNumber = zero
  18326. // //order.FaPiaoCode = last_order.FaPiaoCode
  18327. // //service.UpdateOrder(order)
  18328. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18329. // Number: res.Output.SetlListId,
  18330. // Status: 1,
  18331. // Ctime: time.Now().Unix(),
  18332. // Mtime: time.Now().Unix(),
  18333. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18334. // IsUpload: 1,
  18335. // OrderId: order.ID,
  18336. // }
  18337. // service.CreateUploadRecord(hisFundSettleListResult)
  18338. // c.ServeSuccessJSON(map[string]interface{}{
  18339. // "msg": "上传成功",
  18340. // "result": hisFundSettleListResult,
  18341. // })
  18342. // continue
  18343. // }
  18344. // }
  18345. //}
  18346. func (c *HisApiController) GetbatchSettleList() {
  18347. //order_id, _ := c.GetInt64("order_id")
  18348. admin_user_id, _ := c.GetInt64("admin_user_id")
  18349. orders, _ := service.GetAllHisOrderTwo10485()
  18350. for _, item := range orders {
  18351. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18352. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18353. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18354. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18355. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18356. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18357. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18358. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18359. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18360. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18361. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18362. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18363. //fmt.Println(count)
  18364. //var zero string
  18365. //number := count + 1
  18366. //if number >= 1000 {
  18367. // zero = "0000" + strconv.FormatInt(number, 10)
  18368. //} else if number >= 10000 {
  18369. // zero = "000" + strconv.FormatInt(number, 10)
  18370. //} else if number >= 100000 {
  18371. // zero = "00" + strconv.FormatInt(number, 10)
  18372. //} else if number >= 1000000 {
  18373. // zero = "0" + strconv.FormatInt(number, 10)
  18374. //} else {
  18375. // zero = strconv.FormatInt(number, 10)
  18376. //}
  18377. //fmt.Println(zero)
  18378. struct4101 := service.Struct4101{
  18379. PsnNo: order.PsnNo,
  18380. MdtrtId: order.MdtrtId,
  18381. SetlId: order.SetlId,
  18382. PsnName: order.PsnName,
  18383. Gend: order.Gend,
  18384. Brdy: his.Brdy,
  18385. Age: his.Age,
  18386. Naty: order.Naty,
  18387. PatnCertType: "01",
  18388. Certno: order.Certno,
  18389. Prfs: "90",
  18390. ConerName: roles[0].UserName,
  18391. PatnRlts: "99",
  18392. ConerAddr: miConfig.OrgName,
  18393. ConerTel: admin.Mobile,
  18394. HiType: order.Insutype,
  18395. Insuplc: miConfig.InsuplcAdmdvs,
  18396. MaindiagFlag: "1",
  18397. BillCode: order.SetlId,
  18398. BillNo: order.SetlId,
  18399. BizSn: order.Number,
  18400. PsnSelfPay: order.PsnPartAmt,
  18401. PsnOwnPay: order.PsnPartAmt,
  18402. AcctPay: order.AcctPay,
  18403. PsnCashpay: order.PsnCashPay,
  18404. HiPaymtd: "1",
  18405. Hsorg: miConfig.InsuplcAdmdvs,
  18406. HsorgOpter: miConfig.InsuplcAdmdvs,
  18407. MedinsFillPsn: curRoles.UserName,
  18408. MedinsFillDept: miConfig.OrgName,
  18409. IptMedType: "2",
  18410. }
  18411. struct4101.SetlBegnDate = order.SetlTime
  18412. struct4101.SetlEndDate = order.SetlTime
  18413. time_arr := strings.Split(order.SetlTime, " ")
  18414. struct4101.AdmTime = time_arr[0]
  18415. struct4101.AdmEndTime = time_arr[0]
  18416. //var rf []CustomFundPay
  18417. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18418. //
  18419. //var tempFunPays []service.CustomStruct
  18420. //for _, item := range rf {
  18421. // var tempFunPay service.CustomStruct
  18422. // tempFunPay.FundPayamt = item.FundPayamt
  18423. // tempFunPay.FundPayType = item.FundPayType
  18424. // tempFunPays = append(tempFunPays, tempFunPay)
  18425. //}
  18426. //struct4101.CustomStruct = tempFunPays
  18427. var tempDiaginfos []service.DiaginfoStructTwo
  18428. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18429. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18430. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18431. var config []*models.HisXtDiagnoseConfig
  18432. for _, item := range diagnosis_ids {
  18433. id, _ := strconv.ParseInt(item, 10, 64)
  18434. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18435. config = append(config, &diagnosisConfig)
  18436. }
  18437. for index, item := range config {
  18438. if index == 0 {
  18439. var tempDiaginfo service.DiaginfoStructTwo
  18440. tempDiaginfo.DiagCode = item.CountryCode
  18441. tempDiaginfo.DiagName = item.CountryContentName
  18442. tempDiaginfo.DiagType = "1"
  18443. tempDiaginfo.MaindiagFlag = "1"
  18444. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18445. } else {
  18446. var tempDiaginfo service.DiaginfoStructTwo
  18447. tempDiaginfo.DiagCode = item.CountryCode
  18448. tempDiaginfo.DiagName = item.CountryContentName
  18449. tempDiaginfo.DiagType = "1"
  18450. tempDiaginfo.MaindiagFlag = "0"
  18451. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18452. }
  18453. }
  18454. struct4101.Diseinfo = tempDiaginfos
  18455. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18456. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18457. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18458. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18459. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18460. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18461. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18462. var iteminfo service.IteminfoStruct
  18463. var bedCostTotal float64 = 0 //床位总费
  18464. var bedCostSelfTotal float64 = 0 //床位自费
  18465. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18466. var operationCostTotal float64 = 0 //手术费
  18467. var operationCostSelfTotal float64 = 0 //手术费
  18468. var operationCostPartSelfTotal float64 = 0 //手术费
  18469. var otherCostTotal float64 = 0 //其他费用
  18470. var otherCostSelfTotal float64 = 0 //其他费用
  18471. var otherCostPartSelfTotal float64 = 0 //其他费用
  18472. var materialCostTotal float64 = 0 //材料费
  18473. var materialCostSelfTotal float64 = 0 //材料费
  18474. var materialCostPartSelfTotal float64 = 0 //材料费
  18475. var westernMedicineCostTotal float64 = 0 //西药费
  18476. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18477. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18478. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18479. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18480. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18481. var checkCostTotal float64 = 0 //检查费
  18482. var checkCostSelfTotal float64 = 0 //检查费
  18483. var checkCostPartSelfTotal float64 = 0 //检查费
  18484. var laboratoryCostTotal float64 = 0 //化验费
  18485. var laboratoryCostSelfTotal float64 = 0 //化验费
  18486. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18487. var treatCostTotal float64 = 0 //治疗费用
  18488. var treatCostSelfTotal float64 = 0 //治疗费用
  18489. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18490. decimal.DivisionPrecision = 2
  18491. var bed_fulamt_ownpay_amt float64 = 0
  18492. var operation_fulamt_ownpay_amt float64 = 0
  18493. var other_fulamt_ownpay_amt float64 = 0
  18494. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18495. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18496. var check_fulamt_ownpay_amt float64 = 0
  18497. var material_fulamt_ownpay_amt float64 = 0
  18498. var laboratory_fulamt_ownpay_amt float64 = 0
  18499. var treat_fulamt_ownpay_amt float64 = 0
  18500. var bed_claa_sunmfee float64 = 0
  18501. var bed_clab_amt float64 = 0
  18502. var bed_other_amt float64 = 0
  18503. var operation_claa_sunmfee float64 = 0
  18504. var operation_clab_amt float64 = 0
  18505. var operation_other_amt float64 = 0
  18506. var other_claa_sunmfee float64 = 0
  18507. var other_clab_amt float64 = 0
  18508. var other_other_amt float64 = 0
  18509. var westernMedicine_claa_sunmfee float64 = 0
  18510. var westernMedicine_clab_amt float64 = 0
  18511. var westernMedicine_other_amt float64 = 0
  18512. var chineseTraditional_claa_sunmfee float64 = 0
  18513. var chineseTraditional_clab_amt float64 = 0
  18514. var chineseTraditional_other_amt float64 = 0
  18515. var check_claa_sunmfee float64 = 0
  18516. var check_clab_amt float64 = 0
  18517. var check_other_amt float64 = 0
  18518. var material_claa_sunmfee float64 = 0
  18519. var material_clab_amt float64 = 0
  18520. var material_other_amt float64 = 0
  18521. var laboratory_claa_sunmfee float64 = 0
  18522. var laboratory_clab_amt float64 = 0
  18523. var laboratory_other_amt float64 = 0
  18524. var treat_claa_sunmfee float64 = 0
  18525. var treat_clab_amt float64 = 0
  18526. var treat_other_amt float64 = 0
  18527. for _, item := range order.HisOrderInfo {
  18528. if item.MedChrgitmType == "01" { //床位费
  18529. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18530. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18531. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18532. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18533. if item.ChrgitmLv == "1" {
  18534. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18535. }
  18536. if item.ChrgitmLv == "2" {
  18537. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18538. }
  18539. if item.ChrgitmLv == "3" {
  18540. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18541. }
  18542. }
  18543. if item.MedChrgitmType == "03" { //检查费
  18544. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18545. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18546. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18547. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18548. if item.ChrgitmLv == "1" {
  18549. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18550. }
  18551. if item.ChrgitmLv == "2" {
  18552. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18553. }
  18554. if item.ChrgitmLv == "3" {
  18555. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18556. }
  18557. }
  18558. if item.MedChrgitmType == "04" { //化验费
  18559. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18560. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18561. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18562. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18563. if item.ChrgitmLv == "1" {
  18564. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18565. }
  18566. if item.ChrgitmLv == "2" {
  18567. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18568. }
  18569. if item.ChrgitmLv == "3" {
  18570. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18571. }
  18572. }
  18573. if item.MedChrgitmType == "05" { //治疗费
  18574. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18575. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18576. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18577. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18578. if item.ChrgitmLv == "1" {
  18579. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18580. }
  18581. if item.ChrgitmLv == "2" {
  18582. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18583. }
  18584. if item.ChrgitmLv == "3" {
  18585. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18586. }
  18587. }
  18588. if item.MedChrgitmType == "06" { //手术费
  18589. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18590. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18591. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18592. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18593. if item.ChrgitmLv == "1" {
  18594. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18595. }
  18596. if item.ChrgitmLv == "2" {
  18597. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18598. }
  18599. if item.ChrgitmLv == "3" {
  18600. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18601. }
  18602. }
  18603. if item.MedChrgitmType == "08" { //材料费
  18604. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18605. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18606. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18607. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18608. if item.ChrgitmLv == "1" {
  18609. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18610. }
  18611. if item.ChrgitmLv == "2" {
  18612. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18613. }
  18614. if item.ChrgitmLv == "3" {
  18615. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18616. }
  18617. }
  18618. if item.MedChrgitmType == "09" { //西药费
  18619. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18620. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18621. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18622. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18623. if item.ChrgitmLv == "1" {
  18624. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18625. }
  18626. if item.ChrgitmLv == "2" {
  18627. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18628. }
  18629. if item.ChrgitmLv == "3" {
  18630. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18631. }
  18632. }
  18633. if item.MedChrgitmType == "11" { //中成费
  18634. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18635. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18636. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18637. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18638. if item.ChrgitmLv == "1" {
  18639. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18640. }
  18641. if item.ChrgitmLv == "2" {
  18642. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18643. }
  18644. if item.ChrgitmLv == "3" {
  18645. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18646. }
  18647. }
  18648. if item.MedChrgitmType == "14" { //其他费
  18649. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18650. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18651. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18652. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18653. if item.ChrgitmLv == "1" {
  18654. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18655. }
  18656. if item.ChrgitmLv == "2" {
  18657. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18658. }
  18659. if item.ChrgitmLv == "3" {
  18660. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18661. }
  18662. }
  18663. }
  18664. var iteminfoStructs []service.IteminfoStruct
  18665. if bedCostTotal != 0 {
  18666. iteminfo.MedChrgitm = "01"
  18667. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18668. iteminfo.Amt = bedCostTotal
  18669. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18670. iteminfo.ClabAmt = bed_clab_amt
  18671. iteminfo.OthAmt = bed_other_amt
  18672. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18673. }
  18674. if checkCostTotal != 0 {
  18675. iteminfo.MedChrgitm = "03"
  18676. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18677. iteminfo.Amt = checkCostTotal
  18678. iteminfo.ClaaSumfee = check_claa_sunmfee
  18679. iteminfo.ClabAmt = check_clab_amt
  18680. iteminfo.OthAmt = check_other_amt
  18681. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18682. }
  18683. if laboratoryCostTotal != 0 {
  18684. iteminfo.MedChrgitm = "04"
  18685. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18686. iteminfo.Amt = laboratoryCostTotal
  18687. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18688. iteminfo.ClabAmt = laboratory_clab_amt
  18689. iteminfo.OthAmt = laboratory_other_amt
  18690. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18691. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18692. }
  18693. if treatCostTotal != 0 {
  18694. iteminfo.MedChrgitm = "05"
  18695. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18696. iteminfo.Amt = treatCostTotal
  18697. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18698. iteminfo.ClabAmt = treat_clab_amt
  18699. iteminfo.OthAmt = treat_other_amt
  18700. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18701. //(struct4101.IteminfoStruct, iteminfo)
  18702. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18703. }
  18704. if operationCostTotal != 0 {
  18705. iteminfo.MedChrgitm = "06"
  18706. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18707. iteminfo.Amt = operationCostTotal
  18708. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18709. iteminfo.ClabAmt = operation_clab_amt
  18710. iteminfo.OthAmt = operation_other_amt
  18711. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18712. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18713. }
  18714. if materialCostTotal != 0 {
  18715. iteminfo.MedChrgitm = "08"
  18716. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18717. iteminfo.Amt = materialCostTotal
  18718. iteminfo.ClaaSumfee = material_claa_sunmfee
  18719. iteminfo.ClabAmt = material_clab_amt
  18720. iteminfo.OthAmt = material_other_amt
  18721. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18722. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18723. }
  18724. if westernMedicineCostTotal != 0 {
  18725. iteminfo.MedChrgitm = "09"
  18726. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18727. iteminfo.Amt = westernMedicineCostTotal
  18728. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18729. iteminfo.ClabAmt = westernMedicine_clab_amt
  18730. iteminfo.OthAmt = westernMedicine_other_amt
  18731. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18732. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18733. }
  18734. if chineseTraditionalMedicineCostTotal != 0 {
  18735. iteminfo.MedChrgitm = "11"
  18736. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18737. iteminfo.Amt = westernMedicineCostTotal
  18738. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18739. iteminfo.ClabAmt = westernMedicine_clab_amt
  18740. iteminfo.OthAmt = westernMedicine_other_amt
  18741. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18742. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18743. }
  18744. if otherCostTotal != 0 {
  18745. iteminfo.MedChrgitm = "14"
  18746. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18747. iteminfo.Amt = otherCostTotal
  18748. iteminfo.ClaaSumfee = other_claa_sunmfee
  18749. iteminfo.ClabAmt = other_clab_amt
  18750. iteminfo.OthAmt = other_other_amt
  18751. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18752. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18753. }
  18754. struct4101.IteminfoStruct = iteminfoStructs
  18755. struct4101.Ntly = "中国"
  18756. struct4101.AdmCaty = "A03.06"
  18757. struct4101.DoctorName = doctor.UserName
  18758. struct4101.DoctorCode = doctor.DoctorNumber
  18759. var res ResultSeventeen
  18760. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18761. struct4101.BillCode = order.Number
  18762. struct4101.BillNo = order.SetlId
  18763. var resOther ResultSeventeenOther
  18764. var pp models.PublicParams
  18765. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18766. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18767. pp.FixmedinsName = miConfig.OrgName
  18768. pp.FixmedinsCode = miConfig.Code
  18769. pp.RequestUrl = miConfig.Url
  18770. pp.Cainfo = miConfig.Cainfo
  18771. pp.SecretKey = miConfig.SecretKey
  18772. pp.AccessKey = miConfig.AccessKey
  18773. pp.OpterName = curRoles.UserName
  18774. client := &http.Client{}
  18775. var req *http.Request
  18776. data := make(map[string]interface{})
  18777. data["struct4101"] = struct4101
  18778. data["pp"] = pp
  18779. bytesData, _ := json.Marshal(data)
  18780. if miConfig.MdtrtareaAdmvs == "320921" {
  18781. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18782. } else {
  18783. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18784. }
  18785. resp, _ := client.Do(req)
  18786. defer resp.Body.Close()
  18787. body, ioErr := ioutil.ReadAll(resp.Body)
  18788. if ioErr != nil {
  18789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18791. return
  18792. }
  18793. var respJSON map[string]interface{}
  18794. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18797. return
  18798. }
  18799. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18800. userJSONBytes, _ := json.Marshal(respJSON)
  18801. fmt.Println("log")
  18802. fmt.Println(string(userJSONBytes))
  18803. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18804. utils.ErrorLog("解析失败:%v", err)
  18805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18806. return
  18807. }
  18808. res.InfRefmsgid = resOther.InfRefmsgid
  18809. res.Output = resOther.Output
  18810. res.ErrMsg = resOther.ErrMsg
  18811. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18812. res.Infcode = infocode
  18813. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18814. var pp models.PublicParams
  18815. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18816. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18817. pp.FixmedinsName = miConfig.OrgName
  18818. pp.FixmedinsCode = miConfig.Code
  18819. pp.RequestUrl = miConfig.Url
  18820. pp.Cainfo = miConfig.Cainfo
  18821. pp.SecretKey = miConfig.SecretKey
  18822. pp.AccessKey = miConfig.AccessKey
  18823. pp.OpterName = curRoles.UserName
  18824. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18825. result, _ := service.Jxyb4101(struct4101, pp)
  18826. var dat map[string]interface{}
  18827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18828. fmt.Println(dat)
  18829. } else {
  18830. fmt.Println(err)
  18831. }
  18832. userJSONBytes, _ := json.Marshal(dat)
  18833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18834. utils.ErrorLog("解析失败:%v", err)
  18835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18836. return
  18837. }
  18838. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18839. var pp models.PublicParams
  18840. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18841. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18842. pp.FixmedinsName = miConfig.OrgName
  18843. pp.FixmedinsCode = miConfig.Code
  18844. pp.RequestUrl = miConfig.Url
  18845. pp.Cainfo = miConfig.Cainfo
  18846. pp.SecretKey = miConfig.SecretKey
  18847. pp.AccessKey = miConfig.AccessKey
  18848. pp.OpterName = curRoles.UserName
  18849. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18850. result, _ := service.Jxyb4101(struct4101, pp)
  18851. var dat map[string]interface{}
  18852. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18853. fmt.Println(dat)
  18854. } else {
  18855. fmt.Println(err)
  18856. }
  18857. userJSONBytes, _ := json.Marshal(dat)
  18858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18859. utils.ErrorLog("解析失败:%v", err)
  18860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18861. return
  18862. }
  18863. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18864. var pp models.PublicParams
  18865. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18866. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18867. pp.FixmedinsName = miConfig.OrgName
  18868. pp.FixmedinsCode = miConfig.Code
  18869. pp.RequestUrl = miConfig.Url
  18870. pp.Cainfo = miConfig.Cainfo
  18871. pp.SecretKey = miConfig.SecretKey
  18872. pp.AccessKey = miConfig.AccessKey
  18873. pp.OpterName = curRoles.UserName
  18874. result, _ := service.Hnyb4101(struct4101, pp)
  18875. var dat map[string]interface{}
  18876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18877. fmt.Println(dat)
  18878. } else {
  18879. fmt.Println(err)
  18880. }
  18881. userJSONBytes, _ := json.Marshal(dat)
  18882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18883. utils.ErrorLog("解析失败:%v", err)
  18884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18885. return
  18886. }
  18887. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18888. var resOther ResultSeventeenOther
  18889. var pp models.PublicParams
  18890. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18891. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18892. pp.FixmedinsName = miConfig.OrgName
  18893. pp.FixmedinsCode = miConfig.Code
  18894. pp.RequestUrl = miConfig.Url
  18895. pp.Cainfo = miConfig.Cainfo
  18896. pp.SecretKey = miConfig.SecretKey
  18897. pp.AccessKey = miConfig.AccessKey
  18898. pp.OpterName = curRoles.UserName
  18899. client := &http.Client{}
  18900. var req *http.Request
  18901. data := make(map[string]interface{})
  18902. data["struct4101"] = struct4101
  18903. data["pp"] = pp
  18904. bytesData, _ := json.Marshal(data)
  18905. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18906. resp, _ := client.Do(req)
  18907. defer resp.Body.Close()
  18908. body, ioErr := ioutil.ReadAll(resp.Body)
  18909. if ioErr != nil {
  18910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18912. return
  18913. }
  18914. var respJSON map[string]interface{}
  18915. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18918. return
  18919. }
  18920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18921. userJSONBytes, _ := json.Marshal(respJSON)
  18922. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18923. utils.ErrorLog("解析失败:%v", err)
  18924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18925. return
  18926. }
  18927. res.InfRefmsgid = resOther.InfRefmsgid
  18928. res.Output = resOther.Output
  18929. res.ErrMsg = resOther.ErrMsg
  18930. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18931. res.Infcode = infocode
  18932. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18933. var pp models.PublicParams
  18934. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18935. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18936. pp.FixmedinsName = miConfig.OrgName
  18937. pp.FixmedinsCode = miConfig.Code
  18938. pp.RequestUrl = miConfig.Url
  18939. pp.Cainfo = miConfig.Cainfo
  18940. pp.SecretKey = miConfig.SecretKey
  18941. pp.AccessKey = miConfig.AccessKey
  18942. pp.OpterName = curRoles.UserName
  18943. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18944. fmt.Println(requestLog)
  18945. fmt.Println(errMsgLog)
  18946. saveLog(result, requestLog, "4101a", "上传清单")
  18947. var dat map[string]interface{}
  18948. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18949. fmt.Println(dat)
  18950. } else {
  18951. fmt.Println(err)
  18952. }
  18953. userJSONBytes, _ := json.Marshal(dat)
  18954. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18955. utils.ErrorLog("解析失败:%v", err)
  18956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18957. return
  18958. }
  18959. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18960. var pp models.PublicParams
  18961. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18962. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18963. pp.FixmedinsName = miConfig.OrgName
  18964. pp.FixmedinsCode = miConfig.Code
  18965. pp.RequestUrl = miConfig.Url
  18966. pp.Cainfo = miConfig.Cainfo
  18967. pp.SecretKey = miConfig.SecretKey
  18968. pp.AccessKey = miConfig.AccessKey
  18969. pp.OpterName = curRoles.UserName
  18970. client := &http.Client{}
  18971. var req *http.Request
  18972. data := make(map[string]interface{})
  18973. data["struct4101"] = struct4101
  18974. data["pp"] = pp
  18975. bytesData, _ := json.Marshal(data)
  18976. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18977. resp, _ := client.Do(req)
  18978. defer resp.Body.Close()
  18979. body, ioErr := ioutil.ReadAll(resp.Body)
  18980. if ioErr != nil {
  18981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18983. return
  18984. }
  18985. var respJSON map[string]interface{}
  18986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18989. return
  18990. }
  18991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18992. userJSONBytes, _ := json.Marshal(respJSON)
  18993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18994. utils.ErrorLog("解析失败:%v", err)
  18995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18996. return
  18997. }
  18998. } else {
  18999. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19000. var dat map[string]interface{}
  19001. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19002. fmt.Println(dat)
  19003. } else {
  19004. fmt.Println(err)
  19005. }
  19006. userJSONBytes, _ := json.Marshal(dat)
  19007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19008. utils.ErrorLog("解析失败:%v", err)
  19009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19010. return
  19011. }
  19012. }
  19013. if res.Infcode != 0 {
  19014. errlog := &models.HisOrderError{
  19015. UserOrgId: order.UserOrgId,
  19016. Ctime: time.Now().Unix(),
  19017. Mtime: time.Now().Unix(),
  19018. ErrMsg: res.ErrMsg + "解析失败",
  19019. Status: 1,
  19020. PatientId: order.ID,
  19021. Stage: 10485,
  19022. }
  19023. service.CreateErrMsgLog(errlog)
  19024. continue
  19025. //c.ServeSuccessJSON(map[string]interface{}{
  19026. // "failed_code": -10,
  19027. // "msg": res.ErrMsg,
  19028. //})
  19029. } else {
  19030. //order.FaPiaoNumber = zero
  19031. //order.FaPiaoCode = last_order.FaPiaoCode
  19032. //service.UpdateOrder(order)
  19033. hisFundSettleListResult := &models.HisFundSettleListResult{
  19034. Number: res.Output.SetlListId,
  19035. Status: 1,
  19036. Ctime: time.Now().Unix(),
  19037. Mtime: time.Now().Unix(),
  19038. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19039. IsUpload: 1,
  19040. OrderId: order.ID,
  19041. }
  19042. service.CreateUploadRecord(hisFundSettleListResult)
  19043. continue
  19044. }
  19045. }
  19046. }
  19047. func (c *HisApiController) GetSettleList() {
  19048. order_id, _ := c.GetInt64("order_id")
  19049. admin_user_id, _ := c.GetInt64("admin_user_id")
  19050. order, _ := service.GetHisOrderByIDTwo(order_id)
  19051. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19052. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19053. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19054. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19055. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19056. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19057. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19058. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19059. if order.ID == 0 {
  19060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19061. return
  19062. }
  19063. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19064. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19065. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19066. //fmt.Println(count)
  19067. //var zero string
  19068. //number := count + 1
  19069. //if number >= 1000 {
  19070. // zero = "0000" + strconv.FormatInt(number, 10)
  19071. //} else if number >= 10000 {
  19072. // zero = "000" + strconv.FormatInt(number, 10)
  19073. //} else if number >= 100000 {
  19074. // zero = "00" + strconv.FormatInt(number, 10)
  19075. //} else if number >= 1000000 {
  19076. // zero = "0" + strconv.FormatInt(number, 10)
  19077. //} else {
  19078. // zero = strconv.FormatInt(number, 10)
  19079. //}
  19080. //fmt.Println(zero)
  19081. struct4101 := service.Struct4101{
  19082. PsnNo: order.PsnNo,
  19083. MdtrtId: order.MdtrtId,
  19084. SetlId: order.SetlId,
  19085. PsnName: order.PsnName,
  19086. Gend: order.Gend,
  19087. Brdy: his.Brdy,
  19088. Age: his.Age,
  19089. Naty: order.Naty,
  19090. PatnCertType: "01",
  19091. Certno: order.Certno,
  19092. Prfs: "90",
  19093. ConerName: roles[0].UserName,
  19094. PatnRlts: "99",
  19095. ConerAddr: miConfig.OrgName,
  19096. ConerTel: admin.Mobile,
  19097. HiType: order.Insutype,
  19098. Insuplc: miConfig.InsuplcAdmdvs,
  19099. MaindiagFlag: "1",
  19100. BillCode: order.SetlId,
  19101. BillNo: order.SetlId,
  19102. BizSn: order.Number,
  19103. PsnSelfPay: order.PsnPartAmt,
  19104. PsnOwnPay: order.PsnPartAmt,
  19105. AcctPay: order.AcctPay,
  19106. PsnCashpay: order.PsnCashPay,
  19107. HiPaymtd: "1",
  19108. Hsorg: miConfig.InsuplcAdmdvs,
  19109. HsorgOpter: miConfig.InsuplcAdmdvs,
  19110. MedinsFillPsn: curRoles.UserName,
  19111. MedinsFillDept: miConfig.OrgName,
  19112. IptMedType: "2",
  19113. }
  19114. struct4101.SetlBegnDate = order.SetlTime
  19115. struct4101.SetlEndDate = order.SetlTime
  19116. time_arr := strings.Split(order.SetlTime, " ")
  19117. struct4101.AdmTime = time_arr[0]
  19118. struct4101.AdmEndTime = time_arr[0]
  19119. //
  19120. //var rf []CustomFundPay
  19121. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19122. //
  19123. //var tempFunPays []service.CustomStruct
  19124. //for _, item := range rf {
  19125. // var tempFunPay service.CustomStruct
  19126. // tempFunPay.FundPayamt = item.FundPayamt
  19127. // tempFunPay.FundPayType = item.FundPayType
  19128. // tempFunPays = append(tempFunPays, tempFunPay)
  19129. //}
  19130. //struct4101.CustomStruct = tempFunPays
  19131. var tempDiaginfos []service.DiaginfoStructTwo
  19132. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19133. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19134. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19135. var config []*models.HisXtDiagnoseConfig
  19136. for _, item := range diagnosis_ids {
  19137. id, _ := strconv.ParseInt(item, 10, 64)
  19138. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19139. config = append(config, &diagnosisConfig)
  19140. }
  19141. if miConfig.Code == "H15049901371" {
  19142. //for _, item := range config {
  19143. // if item.ID == 138 {
  19144. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19145. var tempDiaginfo service.DiaginfoStructTwo
  19146. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19147. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19148. tempDiaginfo.DiagType = "1"
  19149. tempDiaginfo.MaindiagFlag = "1"
  19150. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19151. //}
  19152. //}
  19153. for _, item := range config {
  19154. if item.ID != 138 {
  19155. var tempDiaginfo service.DiaginfoStructTwo
  19156. tempDiaginfo.DiagCode = item.CountryCode
  19157. tempDiaginfo.DiagName = item.CountryContentName
  19158. tempDiaginfo.DiagType = "1"
  19159. tempDiaginfo.MaindiagFlag = "0"
  19160. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19161. }
  19162. }
  19163. } else {
  19164. for index, item := range config {
  19165. if index == 0 {
  19166. var tempDiaginfo service.DiaginfoStructTwo
  19167. tempDiaginfo.DiagCode = item.CountryCode
  19168. tempDiaginfo.DiagName = item.CountryContentName
  19169. tempDiaginfo.DiagType = "1"
  19170. tempDiaginfo.MaindiagFlag = "1"
  19171. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19172. } else {
  19173. var tempDiaginfo service.DiaginfoStructTwo
  19174. tempDiaginfo.DiagCode = item.CountryCode
  19175. tempDiaginfo.DiagName = item.CountryContentName
  19176. tempDiaginfo.DiagType = "1"
  19177. tempDiaginfo.MaindiagFlag = "0"
  19178. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19179. }
  19180. }
  19181. }
  19182. struct4101.Diseinfo = tempDiaginfos
  19183. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19184. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19185. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19186. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19187. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19188. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19189. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19190. var iteminfo service.IteminfoStruct
  19191. var bedCostTotal float64 = 0 //床位总费
  19192. var bedCostSelfTotal float64 = 0 //床位自费
  19193. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19194. var operationCostTotal float64 = 0 //手术费
  19195. var operationCostSelfTotal float64 = 0 //手术费
  19196. var operationCostPartSelfTotal float64 = 0 //手术费
  19197. var otherCostTotal float64 = 0 //其他费用
  19198. var otherCostSelfTotal float64 = 0 //其他费用
  19199. var otherCostPartSelfTotal float64 = 0 //其他费用
  19200. var materialCostTotal float64 = 0 //材料费
  19201. var materialCostSelfTotal float64 = 0 //材料费
  19202. var materialCostPartSelfTotal float64 = 0 //材料费
  19203. var westernMedicineCostTotal float64 = 0 //西药费
  19204. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19205. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19206. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19207. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19208. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19209. var checkCostTotal float64 = 0 //检查费
  19210. var checkCostSelfTotal float64 = 0 //检查费
  19211. var checkCostPartSelfTotal float64 = 0 //检查费
  19212. var laboratoryCostTotal float64 = 0 //化验费
  19213. var laboratoryCostSelfTotal float64 = 0 //化验费
  19214. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19215. var treatCostTotal float64 = 0 //治疗费用
  19216. var treatCostSelfTotal float64 = 0 //治疗费用
  19217. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19218. decimal.DivisionPrecision = 2
  19219. var bed_fulamt_ownpay_amt float64 = 0
  19220. var operation_fulamt_ownpay_amt float64 = 0
  19221. var other_fulamt_ownpay_amt float64 = 0
  19222. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19223. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19224. var check_fulamt_ownpay_amt float64 = 0
  19225. var material_fulamt_ownpay_amt float64 = 0
  19226. var laboratory_fulamt_ownpay_amt float64 = 0
  19227. var treat_fulamt_ownpay_amt float64 = 0
  19228. var bed_claa_sunmfee float64 = 0
  19229. var bed_clab_amt float64 = 0
  19230. var bed_other_amt float64 = 0
  19231. var operation_claa_sunmfee float64 = 0
  19232. var operation_clab_amt float64 = 0
  19233. var operation_other_amt float64 = 0
  19234. var other_claa_sunmfee float64 = 0
  19235. var other_clab_amt float64 = 0
  19236. var other_other_amt float64 = 0
  19237. var westernMedicine_claa_sunmfee float64 = 0
  19238. var westernMedicine_clab_amt float64 = 0
  19239. var westernMedicine_other_amt float64 = 0
  19240. var chineseTraditional_claa_sunmfee float64 = 0
  19241. var chineseTraditional_clab_amt float64 = 0
  19242. var chineseTraditional_other_amt float64 = 0
  19243. var check_claa_sunmfee float64 = 0
  19244. var check_clab_amt float64 = 0
  19245. var check_other_amt float64 = 0
  19246. var material_claa_sunmfee float64 = 0
  19247. var material_clab_amt float64 = 0
  19248. var material_other_amt float64 = 0
  19249. var laboratory_claa_sunmfee float64 = 0
  19250. var laboratory_clab_amt float64 = 0
  19251. var laboratory_other_amt float64 = 0
  19252. var treat_claa_sunmfee float64 = 0
  19253. var treat_clab_amt float64 = 0
  19254. var treat_other_amt float64 = 0
  19255. for _, item := range order.HisOrderInfo {
  19256. if item.MedChrgitmType == "01" { //床位费
  19257. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19258. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19259. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19260. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19261. if item.ChrgitmLv == "1" {
  19262. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19263. }
  19264. if item.ChrgitmLv == "2" {
  19265. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19266. }
  19267. if item.ChrgitmLv == "3" {
  19268. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19269. }
  19270. }
  19271. if item.MedChrgitmType == "03" { //检查费
  19272. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19273. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19274. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19275. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19276. if item.ChrgitmLv == "1" {
  19277. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19278. }
  19279. if item.ChrgitmLv == "2" {
  19280. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19281. }
  19282. if item.ChrgitmLv == "3" {
  19283. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19284. }
  19285. }
  19286. if item.MedChrgitmType == "04" { //化验费
  19287. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19288. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19289. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19290. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19291. if item.ChrgitmLv == "1" {
  19292. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19293. }
  19294. if item.ChrgitmLv == "2" {
  19295. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19296. }
  19297. if item.ChrgitmLv == "3" {
  19298. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19299. }
  19300. }
  19301. if item.MedChrgitmType == "05" { //治疗费
  19302. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19303. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19304. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19305. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19306. if item.ChrgitmLv == "1" {
  19307. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19308. }
  19309. if item.ChrgitmLv == "2" {
  19310. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19311. }
  19312. if item.ChrgitmLv == "3" {
  19313. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19314. }
  19315. }
  19316. if item.MedChrgitmType == "06" { //手术费
  19317. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19318. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19319. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19320. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19321. if item.ChrgitmLv == "1" {
  19322. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19323. }
  19324. if item.ChrgitmLv == "2" {
  19325. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19326. }
  19327. if item.ChrgitmLv == "3" {
  19328. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19329. }
  19330. }
  19331. if item.MedChrgitmType == "08" { //材料费
  19332. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19333. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19334. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19335. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19336. if item.ChrgitmLv == "1" {
  19337. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19338. }
  19339. if item.ChrgitmLv == "2" {
  19340. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19341. }
  19342. if item.ChrgitmLv == "3" {
  19343. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19344. }
  19345. }
  19346. if item.MedChrgitmType == "09" { //西药费
  19347. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19348. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19349. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19350. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19351. if item.ChrgitmLv == "1" {
  19352. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19353. }
  19354. if item.ChrgitmLv == "2" {
  19355. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19356. }
  19357. if item.ChrgitmLv == "3" {
  19358. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19359. }
  19360. }
  19361. if item.MedChrgitmType == "11" { //中成费
  19362. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19363. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19364. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19365. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19366. if item.ChrgitmLv == "1" {
  19367. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19368. }
  19369. if item.ChrgitmLv == "2" {
  19370. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19371. }
  19372. if item.ChrgitmLv == "3" {
  19373. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19374. }
  19375. }
  19376. if item.MedChrgitmType == "14" { //其他费
  19377. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19378. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19379. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19380. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19381. if item.ChrgitmLv == "1" {
  19382. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19383. }
  19384. if item.ChrgitmLv == "2" {
  19385. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19386. }
  19387. if item.ChrgitmLv == "3" {
  19388. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19389. }
  19390. }
  19391. }
  19392. var iteminfoStructs []service.IteminfoStruct
  19393. if bedCostTotal != 0 {
  19394. iteminfo.MedChrgitm = "01"
  19395. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19396. iteminfo.Amt = bedCostTotal
  19397. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19398. iteminfo.ClabAmt = bed_clab_amt
  19399. iteminfo.OthAmt = bed_other_amt
  19400. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19401. }
  19402. if checkCostTotal != 0 {
  19403. iteminfo.MedChrgitm = "03"
  19404. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19405. iteminfo.Amt = checkCostTotal
  19406. iteminfo.ClaaSumfee = check_claa_sunmfee
  19407. iteminfo.ClabAmt = check_clab_amt
  19408. iteminfo.OthAmt = check_other_amt
  19409. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19410. }
  19411. if laboratoryCostTotal != 0 {
  19412. iteminfo.MedChrgitm = "04"
  19413. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19414. iteminfo.Amt = laboratoryCostTotal
  19415. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19416. iteminfo.ClabAmt = laboratory_clab_amt
  19417. iteminfo.OthAmt = laboratory_other_amt
  19418. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19419. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19420. }
  19421. if treatCostTotal != 0 {
  19422. iteminfo.MedChrgitm = "05"
  19423. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19424. iteminfo.Amt = treatCostTotal
  19425. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19426. iteminfo.ClabAmt = treat_clab_amt
  19427. iteminfo.OthAmt = treat_other_amt
  19428. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19429. //(struct4101.IteminfoStruct, iteminfo)
  19430. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19431. }
  19432. if operationCostTotal != 0 {
  19433. iteminfo.MedChrgitm = "06"
  19434. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19435. iteminfo.Amt = operationCostTotal
  19436. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19437. iteminfo.ClabAmt = operation_clab_amt
  19438. iteminfo.OthAmt = operation_other_amt
  19439. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19440. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19441. }
  19442. if materialCostTotal != 0 {
  19443. iteminfo.MedChrgitm = "08"
  19444. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19445. iteminfo.Amt = materialCostTotal
  19446. iteminfo.ClaaSumfee = material_claa_sunmfee
  19447. iteminfo.ClabAmt = material_clab_amt
  19448. iteminfo.OthAmt = material_other_amt
  19449. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19450. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19451. }
  19452. if westernMedicineCostTotal != 0 {
  19453. iteminfo.MedChrgitm = "09"
  19454. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19455. iteminfo.Amt = westernMedicineCostTotal
  19456. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19457. iteminfo.ClabAmt = westernMedicine_clab_amt
  19458. iteminfo.OthAmt = westernMedicine_other_amt
  19459. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19460. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19461. }
  19462. if chineseTraditionalMedicineCostTotal != 0 {
  19463. iteminfo.MedChrgitm = "11"
  19464. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19465. iteminfo.Amt = westernMedicineCostTotal
  19466. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19467. iteminfo.ClabAmt = westernMedicine_clab_amt
  19468. iteminfo.OthAmt = westernMedicine_other_amt
  19469. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19470. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19471. }
  19472. if otherCostTotal != 0 {
  19473. iteminfo.MedChrgitm = "14"
  19474. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19475. iteminfo.Amt = otherCostTotal
  19476. iteminfo.ClaaSumfee = other_claa_sunmfee
  19477. iteminfo.ClabAmt = other_clab_amt
  19478. iteminfo.OthAmt = other_other_amt
  19479. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19480. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19481. }
  19482. struct4101.IteminfoStruct = iteminfoStructs
  19483. struct4101.Ntly = "中国"
  19484. struct4101.AdmCaty = "A03.06"
  19485. struct4101.DoctorName = doctor.UserName
  19486. struct4101.DoctorCode = doctor.DoctorNumber
  19487. var res ResultSeventeen
  19488. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19489. struct4101.BillCode = order.Number
  19490. struct4101.BillNo = order.SetlId
  19491. var resOther ResultSeventeenOther
  19492. var pp models.PublicParams
  19493. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19494. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19495. pp.FixmedinsName = miConfig.OrgName
  19496. pp.FixmedinsCode = miConfig.Code
  19497. pp.RequestUrl = miConfig.Url
  19498. pp.Cainfo = miConfig.Cainfo
  19499. pp.SecretKey = miConfig.SecretKey
  19500. pp.AccessKey = miConfig.AccessKey
  19501. pp.OpterName = curRoles.UserName
  19502. client := &http.Client{}
  19503. var req *http.Request
  19504. data := make(map[string]interface{})
  19505. data["struct4101"] = struct4101
  19506. data["pp"] = pp
  19507. bytesData, _ := json.Marshal(data)
  19508. if miConfig.MdtrtareaAdmvs == "320921" {
  19509. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19510. } else {
  19511. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19512. }
  19513. resp, _ := client.Do(req)
  19514. defer resp.Body.Close()
  19515. body, ioErr := ioutil.ReadAll(resp.Body)
  19516. if ioErr != nil {
  19517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19519. return
  19520. }
  19521. var respJSON map[string]interface{}
  19522. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19525. return
  19526. }
  19527. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19528. userJSONBytes, _ := json.Marshal(respJSON)
  19529. fmt.Println("log")
  19530. fmt.Println(string(userJSONBytes))
  19531. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19532. utils.ErrorLog("解析失败:%v", err)
  19533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19534. return
  19535. }
  19536. res.InfRefmsgid = resOther.InfRefmsgid
  19537. res.Output = resOther.Output
  19538. res.ErrMsg = resOther.ErrMsg
  19539. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19540. res.Infcode = infocode
  19541. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19542. var pp models.PublicParams
  19543. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19544. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19545. pp.FixmedinsName = miConfig.OrgName
  19546. pp.FixmedinsCode = miConfig.Code
  19547. pp.RequestUrl = miConfig.Url
  19548. pp.Cainfo = miConfig.Cainfo
  19549. pp.SecretKey = miConfig.SecretKey
  19550. pp.AccessKey = miConfig.AccessKey
  19551. pp.OpterName = curRoles.UserName
  19552. result, _ := service.Jxyb4101(struct4101, pp)
  19553. var dat map[string]interface{}
  19554. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19555. fmt.Println(dat)
  19556. } else {
  19557. fmt.Println(err)
  19558. }
  19559. userJSONBytes, _ := json.Marshal(dat)
  19560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19561. utils.ErrorLog("解析失败:%v", err)
  19562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19563. return
  19564. }
  19565. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19566. var pp models.PublicParams
  19567. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19568. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19569. pp.FixmedinsName = miConfig.OrgName
  19570. pp.FixmedinsCode = miConfig.Code
  19571. pp.RequestUrl = miConfig.Url
  19572. pp.Cainfo = miConfig.Cainfo
  19573. pp.SecretKey = miConfig.SecretKey
  19574. pp.AccessKey = miConfig.AccessKey
  19575. pp.OpterName = curRoles.UserName
  19576. result, _ := service.Jxyb4101(struct4101, pp)
  19577. var dat map[string]interface{}
  19578. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19579. fmt.Println(dat)
  19580. } else {
  19581. fmt.Println(err)
  19582. }
  19583. userJSONBytes, _ := json.Marshal(dat)
  19584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19585. utils.ErrorLog("解析失败:%v", err)
  19586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19587. return
  19588. }
  19589. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19590. var pp models.PublicParams
  19591. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19592. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19593. pp.FixmedinsName = miConfig.OrgName
  19594. pp.FixmedinsCode = miConfig.Code
  19595. pp.RequestUrl = miConfig.Url
  19596. pp.Cainfo = miConfig.Cainfo
  19597. pp.SecretKey = miConfig.SecretKey
  19598. pp.AccessKey = miConfig.AccessKey
  19599. pp.OpterName = curRoles.UserName
  19600. result, _ := service.Hnyb4101(struct4101, pp)
  19601. var dat map[string]interface{}
  19602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19603. fmt.Println(dat)
  19604. } else {
  19605. fmt.Println(err)
  19606. }
  19607. userJSONBytes, _ := json.Marshal(dat)
  19608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19609. utils.ErrorLog("解析失败:%v", err)
  19610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19611. return
  19612. }
  19613. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19614. var resOther ResultSeventeenOther
  19615. var pp models.PublicParams
  19616. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19617. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19618. pp.FixmedinsName = miConfig.OrgName
  19619. pp.FixmedinsCode = miConfig.Code
  19620. pp.RequestUrl = miConfig.Url
  19621. pp.Cainfo = miConfig.Cainfo
  19622. pp.SecretKey = miConfig.SecretKey
  19623. pp.AccessKey = miConfig.AccessKey
  19624. pp.OpterName = curRoles.UserName
  19625. client := &http.Client{}
  19626. var req *http.Request
  19627. data := make(map[string]interface{})
  19628. data["struct4101"] = struct4101
  19629. data["pp"] = pp
  19630. bytesData, _ := json.Marshal(data)
  19631. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19632. resp, _ := client.Do(req)
  19633. defer resp.Body.Close()
  19634. body, ioErr := ioutil.ReadAll(resp.Body)
  19635. if ioErr != nil {
  19636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19638. return
  19639. }
  19640. var respJSON map[string]interface{}
  19641. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19644. return
  19645. }
  19646. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19647. userJSONBytes, _ := json.Marshal(respJSON)
  19648. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19649. utils.ErrorLog("解析失败:%v", err)
  19650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19651. return
  19652. }
  19653. res.InfRefmsgid = resOther.InfRefmsgid
  19654. res.Output = resOther.Output
  19655. res.ErrMsg = resOther.ErrMsg
  19656. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19657. res.Infcode = infocode
  19658. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19659. var pp models.PublicParams
  19660. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19661. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19662. pp.FixmedinsName = miConfig.OrgName
  19663. pp.FixmedinsCode = miConfig.Code
  19664. pp.RequestUrl = miConfig.Url
  19665. pp.Cainfo = miConfig.Cainfo
  19666. pp.SecretKey = miConfig.SecretKey
  19667. pp.AccessKey = miConfig.AccessKey
  19668. pp.OpterName = curRoles.UserName
  19669. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19670. fmt.Println(requestLog)
  19671. fmt.Println(errMsgLog)
  19672. saveLog(result, requestLog, "4101a", "上传清单")
  19673. var dat map[string]interface{}
  19674. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19675. fmt.Println(dat)
  19676. } else {
  19677. fmt.Println(err)
  19678. }
  19679. userJSONBytes, _ := json.Marshal(dat)
  19680. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19681. utils.ErrorLog("解析失败:%v", err)
  19682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19683. return
  19684. }
  19685. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19686. var pp models.PublicParams
  19687. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19688. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19689. pp.FixmedinsName = miConfig.OrgName
  19690. pp.FixmedinsCode = miConfig.Code
  19691. pp.RequestUrl = miConfig.Url
  19692. pp.Cainfo = miConfig.Cainfo
  19693. pp.SecretKey = miConfig.SecretKey
  19694. pp.AccessKey = miConfig.AccessKey
  19695. pp.OpterName = curRoles.UserName
  19696. client := &http.Client{}
  19697. var req *http.Request
  19698. data := make(map[string]interface{})
  19699. data["struct4101"] = struct4101
  19700. data["pp"] = pp
  19701. bytesData, _ := json.Marshal(data)
  19702. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19703. resp, _ := client.Do(req)
  19704. defer resp.Body.Close()
  19705. body, ioErr := ioutil.ReadAll(resp.Body)
  19706. if ioErr != nil {
  19707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19709. return
  19710. }
  19711. var respJSON map[string]interface{}
  19712. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19715. return
  19716. }
  19717. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19718. userJSONBytes, _ := json.Marshal(respJSON)
  19719. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19720. utils.ErrorLog("解析失败:%v", err)
  19721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19722. return
  19723. }
  19724. } else {
  19725. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19726. var dat map[string]interface{}
  19727. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19728. fmt.Println(dat)
  19729. } else {
  19730. fmt.Println(err)
  19731. }
  19732. userJSONBytes, _ := json.Marshal(dat)
  19733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19734. utils.ErrorLog("解析失败:%v", err)
  19735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19736. return
  19737. }
  19738. }
  19739. if res.Infcode != 0 {
  19740. c.ServeSuccessJSON(map[string]interface{}{
  19741. "failed_code": -10,
  19742. "msg": res.ErrMsg,
  19743. })
  19744. return
  19745. } else {
  19746. //order.FaPiaoNumber = zero
  19747. //order.FaPiaoCode = last_order.FaPiaoCode
  19748. //service.UpdateOrder(order)
  19749. hisFundSettleListResult := &models.HisFundSettleListResult{
  19750. Number: res.Output.SetlListId,
  19751. Status: 1,
  19752. Ctime: time.Now().Unix(),
  19753. Mtime: time.Now().Unix(),
  19754. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19755. IsUpload: 1,
  19756. OrderId: order_id,
  19757. }
  19758. service.CreateUploadRecord(hisFundSettleListResult)
  19759. c.ServeSuccessJSON(map[string]interface{}{
  19760. "msg": "上传成功",
  19761. "result": hisFundSettleListResult,
  19762. })
  19763. return
  19764. }
  19765. }
  19766. func (c *HisApiController) GetSettleListHospital() {
  19767. order_id, _ := c.GetInt64("order_id")
  19768. admin_user_id, _ := c.GetInt64("admin_user_id")
  19769. order, _ := service.GetHisOrderByIDTwo(order_id)
  19770. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19771. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19772. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19773. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19774. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19775. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19776. if order.ID == 0 {
  19777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19778. return
  19779. }
  19780. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19781. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19782. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19783. fmt.Println(count)
  19784. var zero string
  19785. number := count + 1
  19786. if number >= 1000 {
  19787. zero = "0000" + strconv.FormatInt(number, 10)
  19788. } else if number >= 10000 {
  19789. zero = "000" + strconv.FormatInt(number, 10)
  19790. } else if number >= 100000 {
  19791. zero = "00" + strconv.FormatInt(number, 10)
  19792. } else if number >= 1000000 {
  19793. zero = "0" + strconv.FormatInt(number, 10)
  19794. } else {
  19795. zero = strconv.FormatInt(number, 10)
  19796. }
  19797. fmt.Println(zero)
  19798. struct4101 := service.Struct4101{
  19799. PsnNo: order.PsnNo,
  19800. MdtrtId: order.MdtrtId,
  19801. SetlId: order.SetlId,
  19802. PsnName: order.PsnName,
  19803. Gend: order.Gend,
  19804. Brdy: his.Brdy,
  19805. Age: int64(order.Age),
  19806. Naty: order.Naty,
  19807. PatnCertType: "01",
  19808. Certno: order.Certno,
  19809. Prfs: "90",
  19810. ConerName: roles[0].UserName,
  19811. PatnRlts: "99",
  19812. ConerAddr: miConfig.OrgName,
  19813. ConerTel: admin.Mobile,
  19814. HiType: order.Insutype,
  19815. Insuplc: miConfig.InsuplcAdmdvs,
  19816. MaindiagFlag: "1",
  19817. BillCode: order.SetlId,
  19818. BillNo: order.SetlId,
  19819. BizSn: order.Number,
  19820. PsnSelfPay: order.PsnPartAmt,
  19821. PsnOwnPay: order.PsnPartAmt,
  19822. AcctPay: order.AcctPay,
  19823. PsnCashpay: order.PsnCashPay,
  19824. HiPaymtd: "1",
  19825. Hsorg: miConfig.InsuplcAdmdvs,
  19826. HsorgOpter: miConfig.InsuplcAdmdvs,
  19827. MedinsFillPsn: curRoles.UserName,
  19828. MedinsFillDept: depart.Name,
  19829. IptMedType: "2",
  19830. AdmTime: his.InHosptialTime,
  19831. AdmEndTime: his.OutHosptialTime,
  19832. }
  19833. struct4101.SetlBegnDate = order.SetlTime
  19834. struct4101.SetlEndDate = order.SetlTime
  19835. //var rf []CustomFundPay
  19836. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19837. //
  19838. //var tempFunPays []service.CustomStruct
  19839. //for _, item := range rf {
  19840. // var tempFunPay service.CustomStruct
  19841. // tempFunPay.FundPayamt = item.FundPayamt
  19842. // tempFunPay.FundPayType = item.FundPayType
  19843. // tempFunPays = append(tempFunPays, tempFunPay)
  19844. //}
  19845. //struct4101.CustomStruct = tempFunPays
  19846. var tempDiaginfos []service.DiaginfoStructTwo
  19847. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19848. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19849. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19850. //for _, item := range infos {
  19851. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19852. //}
  19853. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19854. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19855. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19856. fmt.Println(diagnosis_ids_arr)
  19857. if order.UserOrgId == 10210 {
  19858. var diagnosis_ids_arr_two []int64
  19859. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19860. var config []*models.HisXtDiagnoseConfig
  19861. for _, id := range diagnosis_ids_arr_two {
  19862. //id, _ := strconv.ParseInt(item, 10, 64)
  19863. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19864. if diagnosisConfig.ID > 0 {
  19865. config = append(config, &diagnosisConfig)
  19866. }
  19867. }
  19868. for index, item := range config {
  19869. if item.ID > 0 {
  19870. if index == 0 {
  19871. var tempDiaginfo service.DiaginfoStructTwo
  19872. tempDiaginfo.DiagCode = item.CountryCode
  19873. tempDiaginfo.DiagName = item.CountryContentName
  19874. tempDiaginfo.DiagType = "1"
  19875. tempDiaginfo.MaindiagFlag = "1"
  19876. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19877. } else {
  19878. var tempDiaginfo service.DiaginfoStructTwo
  19879. tempDiaginfo.DiagCode = item.CountryCode
  19880. tempDiaginfo.DiagName = item.CountryContentName
  19881. tempDiaginfo.DiagType = "1"
  19882. tempDiaginfo.MaindiagFlag = "0"
  19883. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19884. }
  19885. }
  19886. }
  19887. struct4101.Diseinfo = tempDiaginfos
  19888. } else {
  19889. var config []*models.HisXtDiagnoseConfig
  19890. for _, item := range diagnosis_ids_arr {
  19891. id, _ := strconv.ParseInt(item, 10, 64)
  19892. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19893. if diagnosisConfig.ID > 0 {
  19894. config = append(config, &diagnosisConfig)
  19895. }
  19896. }
  19897. for index, item := range config {
  19898. if item.ID > 0 {
  19899. if index == 0 {
  19900. var tempDiaginfo service.DiaginfoStructTwo
  19901. tempDiaginfo.DiagCode = item.CountryCode
  19902. tempDiaginfo.DiagName = item.CountryContentName
  19903. tempDiaginfo.DiagType = "1"
  19904. tempDiaginfo.MaindiagFlag = "1"
  19905. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19906. } else {
  19907. var tempDiaginfo service.DiaginfoStructTwo
  19908. tempDiaginfo.DiagCode = item.CountryCode
  19909. tempDiaginfo.DiagName = item.CountryContentName
  19910. tempDiaginfo.DiagType = "1"
  19911. tempDiaginfo.MaindiagFlag = "0"
  19912. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19913. }
  19914. }
  19915. }
  19916. struct4101.Diseinfo = tempDiaginfos
  19917. }
  19918. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19919. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19920. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19921. tempOpspdiseinfo2.OprnOprtCode = ""
  19922. tempOpspdiseinfo2.OprnOprtName = ""
  19923. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19924. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19925. var iteminfo service.IteminfoStruct
  19926. var bedCostTotal float64 = 0 //床位总费
  19927. var bedCostSelfTotal float64 = 0 //床位自费
  19928. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19929. var operationCostTotal float64 = 0 //手术费
  19930. var operationCostSelfTotal float64 = 0 //手术费
  19931. var operationCostPartSelfTotal float64 = 0 //手术费
  19932. var otherCostTotal float64 = 0 //其他费用
  19933. var otherCostSelfTotal float64 = 0 //其他费用
  19934. var otherCostPartSelfTotal float64 = 0 //其他费用
  19935. var materialCostTotal float64 = 0 //材料费
  19936. var materialCostSelfTotal float64 = 0 //材料费
  19937. var materialCostPartSelfTotal float64 = 0 //材料费
  19938. var westernMedicineCostTotal float64 = 0 //西药费
  19939. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19940. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19941. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19942. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19943. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19944. var checkCostTotal float64 = 0 //检查费
  19945. var checkCostSelfTotal float64 = 0 //检查费
  19946. var checkCostPartSelfTotal float64 = 0 //检查费
  19947. var laboratoryCostTotal float64 = 0 //化验费
  19948. var laboratoryCostSelfTotal float64 = 0 //化验费
  19949. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19950. var treatCostTotal float64 = 0 //治疗费用
  19951. var treatCostSelfTotal float64 = 0 //治疗费用
  19952. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19953. decimal.DivisionPrecision = 2
  19954. var bed_fulamt_ownpay_amt float64 = 0
  19955. var operation_fulamt_ownpay_amt float64 = 0
  19956. var other_fulamt_ownpay_amt float64 = 0
  19957. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19958. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19959. var check_fulamt_ownpay_amt float64 = 0
  19960. var material_fulamt_ownpay_amt float64 = 0
  19961. var laboratory_fulamt_ownpay_amt float64 = 0
  19962. var treat_fulamt_ownpay_amt float64 = 0
  19963. var bed_claa_sunmfee float64 = 0
  19964. var bed_clab_amt float64 = 0
  19965. var bed_other_amt float64 = 0
  19966. var operation_claa_sunmfee float64 = 0
  19967. var operation_clab_amt float64 = 0
  19968. var operation_other_amt float64 = 0
  19969. var other_claa_sunmfee float64 = 0
  19970. var other_clab_amt float64 = 0
  19971. var other_other_amt float64 = 0
  19972. var westernMedicine_claa_sunmfee float64 = 0
  19973. var westernMedicine_clab_amt float64 = 0
  19974. var westernMedicine_other_amt float64 = 0
  19975. var chineseTraditional_claa_sunmfee float64 = 0
  19976. var chineseTraditional_clab_amt float64 = 0
  19977. var chineseTraditional_other_amt float64 = 0
  19978. var check_claa_sunmfee float64 = 0
  19979. var check_clab_amt float64 = 0
  19980. var check_other_amt float64 = 0
  19981. var material_claa_sunmfee float64 = 0
  19982. var material_clab_amt float64 = 0
  19983. var material_other_amt float64 = 0
  19984. var laboratory_claa_sunmfee float64 = 0
  19985. var laboratory_clab_amt float64 = 0
  19986. var laboratory_other_amt float64 = 0
  19987. var treat_claa_sunmfee float64 = 0
  19988. var treat_clab_amt float64 = 0
  19989. var treat_other_amt float64 = 0
  19990. for _, item := range order.HisOrderInfo {
  19991. if item.MedChrgitmType == "01" { //床位费
  19992. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19993. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19994. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19995. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19996. if item.ChrgitmLv == "1" {
  19997. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19998. }
  19999. if item.ChrgitmLv == "2" {
  20000. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20001. }
  20002. if item.ChrgitmLv == "3" {
  20003. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20004. }
  20005. }
  20006. if item.MedChrgitmType == "03" { //检查费
  20007. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20008. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20009. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20010. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20011. if item.ChrgitmLv == "1" {
  20012. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20013. }
  20014. if item.ChrgitmLv == "2" {
  20015. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20016. }
  20017. if item.ChrgitmLv == "3" {
  20018. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20019. }
  20020. }
  20021. if item.MedChrgitmType == "04" { //化验费
  20022. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20023. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20024. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20025. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20026. if item.ChrgitmLv == "1" {
  20027. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20028. }
  20029. if item.ChrgitmLv == "2" {
  20030. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20031. }
  20032. if item.ChrgitmLv == "3" {
  20033. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20034. }
  20035. }
  20036. if item.MedChrgitmType == "05" { //治疗费
  20037. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20038. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20039. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20040. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20041. if item.ChrgitmLv == "1" {
  20042. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20043. }
  20044. if item.ChrgitmLv == "2" {
  20045. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20046. }
  20047. if item.ChrgitmLv == "3" {
  20048. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20049. }
  20050. }
  20051. if item.MedChrgitmType == "06" { //手术费
  20052. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20053. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20054. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20055. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20056. if item.ChrgitmLv == "1" {
  20057. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20058. }
  20059. if item.ChrgitmLv == "2" {
  20060. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20061. }
  20062. if item.ChrgitmLv == "3" {
  20063. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20064. }
  20065. }
  20066. if item.MedChrgitmType == "08" { //材料费
  20067. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20068. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20069. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20070. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20071. if item.ChrgitmLv == "1" {
  20072. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20073. }
  20074. if item.ChrgitmLv == "2" {
  20075. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20076. }
  20077. if item.ChrgitmLv == "3" {
  20078. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20079. }
  20080. }
  20081. if item.MedChrgitmType == "09" { //西药费
  20082. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20083. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20084. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20085. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20086. if item.ChrgitmLv == "1" {
  20087. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20088. }
  20089. if item.ChrgitmLv == "2" {
  20090. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20091. }
  20092. if item.ChrgitmLv == "3" {
  20093. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20094. }
  20095. }
  20096. if item.MedChrgitmType == "11" { //中成费
  20097. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20098. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20099. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20100. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20101. if item.ChrgitmLv == "1" {
  20102. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20103. }
  20104. if item.ChrgitmLv == "2" {
  20105. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20106. }
  20107. if item.ChrgitmLv == "3" {
  20108. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20109. }
  20110. }
  20111. if item.MedChrgitmType == "14" { //其他费
  20112. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20113. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20114. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20115. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20116. if item.ChrgitmLv == "1" {
  20117. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20118. }
  20119. if item.ChrgitmLv == "2" {
  20120. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20121. }
  20122. if item.ChrgitmLv == "3" {
  20123. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20124. }
  20125. }
  20126. }
  20127. var iteminfoStructs []service.IteminfoStruct
  20128. if bedCostTotal != 0 {
  20129. iteminfo.MedChrgitm = "01"
  20130. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20131. iteminfo.Amt = bedCostTotal
  20132. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20133. iteminfo.ClabAmt = bed_clab_amt
  20134. iteminfo.OthAmt = bed_other_amt
  20135. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20136. }
  20137. if checkCostTotal != 0 {
  20138. iteminfo.MedChrgitm = "03"
  20139. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20140. iteminfo.Amt = checkCostTotal
  20141. iteminfo.ClaaSumfee = check_claa_sunmfee
  20142. iteminfo.ClabAmt = check_clab_amt
  20143. iteminfo.OthAmt = check_other_amt
  20144. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20145. }
  20146. if laboratoryCostTotal != 0 {
  20147. iteminfo.MedChrgitm = "04"
  20148. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20149. iteminfo.Amt = laboratoryCostTotal
  20150. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20151. iteminfo.ClabAmt = laboratory_clab_amt
  20152. iteminfo.OthAmt = laboratory_other_amt
  20153. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20154. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20155. }
  20156. if treatCostTotal != 0 {
  20157. iteminfo.MedChrgitm = "05"
  20158. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20159. iteminfo.Amt = treatCostTotal
  20160. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20161. iteminfo.ClabAmt = treat_clab_amt
  20162. iteminfo.OthAmt = treat_other_amt
  20163. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20164. //(struct4101.IteminfoStruct, iteminfo)
  20165. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20166. }
  20167. if operationCostTotal != 0 {
  20168. iteminfo.MedChrgitm = "06"
  20169. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20170. iteminfo.Amt = operationCostTotal
  20171. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20172. iteminfo.ClabAmt = operation_clab_amt
  20173. iteminfo.OthAmt = operation_other_amt
  20174. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20175. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20176. }
  20177. if materialCostTotal != 0 {
  20178. iteminfo.MedChrgitm = "08"
  20179. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20180. iteminfo.Amt = materialCostTotal
  20181. iteminfo.ClaaSumfee = material_claa_sunmfee
  20182. iteminfo.ClabAmt = material_clab_amt
  20183. iteminfo.OthAmt = material_other_amt
  20184. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20185. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20186. }
  20187. if westernMedicineCostTotal != 0 {
  20188. iteminfo.MedChrgitm = "09"
  20189. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20190. iteminfo.Amt = westernMedicineCostTotal
  20191. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20192. iteminfo.ClabAmt = westernMedicine_clab_amt
  20193. iteminfo.OthAmt = westernMedicine_other_amt
  20194. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20195. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20196. }
  20197. if chineseTraditionalMedicineCostTotal != 0 {
  20198. iteminfo.MedChrgitm = "11"
  20199. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20200. iteminfo.Amt = westernMedicineCostTotal
  20201. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20202. iteminfo.ClabAmt = westernMedicine_clab_amt
  20203. iteminfo.OthAmt = westernMedicine_other_amt
  20204. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20205. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20206. }
  20207. if otherCostTotal != 0 {
  20208. iteminfo.MedChrgitm = "14"
  20209. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20210. iteminfo.Amt = otherCostTotal
  20211. iteminfo.ClaaSumfee = other_claa_sunmfee
  20212. iteminfo.ClabAmt = other_clab_amt
  20213. iteminfo.OthAmt = other_other_amt
  20214. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20215. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20216. }
  20217. struct4101.IteminfoStruct = iteminfoStructs
  20218. struct4101.Ntly = "中国"
  20219. struct4101.AdmCaty = "A03.06"
  20220. var resOther ResultSeventeenOther
  20221. var res ResultSeventeen
  20222. if miConfig.MdtrtareaAdmvs == "150499" {
  20223. var pp models.PublicParams
  20224. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20225. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20226. pp.FixmedinsName = miConfig.OrgName
  20227. pp.FixmedinsCode = miConfig.Code
  20228. pp.RequestUrl = miConfig.Url
  20229. pp.Cainfo = miConfig.Cainfo
  20230. pp.SecretKey = miConfig.SecretKey
  20231. pp.AccessKey = miConfig.AccessKey
  20232. pp.OpterName = curRoles.UserName
  20233. client := &http.Client{}
  20234. var req *http.Request
  20235. data := make(map[string]interface{})
  20236. data["struct4101"] = struct4101
  20237. data["pp"] = pp
  20238. bytesData, _ := json.Marshal(data)
  20239. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20240. resp, _ := client.Do(req)
  20241. defer resp.Body.Close()
  20242. body, ioErr := ioutil.ReadAll(resp.Body)
  20243. if ioErr != nil {
  20244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20246. return
  20247. }
  20248. var respJSON map[string]interface{}
  20249. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20252. return
  20253. }
  20254. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20255. userJSONBytes, _ := json.Marshal(respJSON)
  20256. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20257. utils.ErrorLog("解析失败:%v", err)
  20258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20259. return
  20260. }
  20261. res.InfRefmsgid = resOther.InfRefmsgid
  20262. res.Output = resOther.Output
  20263. res.ErrMsg = resOther.ErrMsg
  20264. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20265. res.Infcode = infocode
  20266. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20267. var pp models.PublicParams
  20268. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20269. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20270. pp.FixmedinsName = miConfig.OrgName
  20271. pp.FixmedinsCode = miConfig.Code
  20272. pp.RequestUrl = miConfig.Url
  20273. pp.Cainfo = miConfig.Cainfo
  20274. pp.SecretKey = miConfig.SecretKey
  20275. pp.AccessKey = miConfig.AccessKey
  20276. pp.OpterName = curRoles.UserName
  20277. result, _ := service.Jxyb4101(struct4101, pp)
  20278. var dat map[string]interface{}
  20279. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20280. fmt.Println(dat)
  20281. } else {
  20282. fmt.Println(err)
  20283. }
  20284. userJSONBytes, _ := json.Marshal(dat)
  20285. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20286. utils.ErrorLog("解析失败:%v", err)
  20287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20288. return
  20289. }
  20290. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20291. var pp models.PublicParams
  20292. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20293. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20294. pp.FixmedinsName = miConfig.OrgName
  20295. pp.FixmedinsCode = miConfig.Code
  20296. pp.RequestUrl = miConfig.Url
  20297. pp.Cainfo = miConfig.Cainfo
  20298. pp.SecretKey = miConfig.SecretKey
  20299. pp.AccessKey = miConfig.AccessKey
  20300. pp.OpterName = curRoles.UserName
  20301. result, _ := service.Jxyb4101(struct4101, pp)
  20302. var dat map[string]interface{}
  20303. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20304. fmt.Println(dat)
  20305. } else {
  20306. fmt.Println(err)
  20307. }
  20308. userJSONBytes, _ := json.Marshal(dat)
  20309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20310. utils.ErrorLog("解析失败:%v", err)
  20311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20312. return
  20313. }
  20314. } else {
  20315. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20316. var dat map[string]interface{}
  20317. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20318. fmt.Println(dat)
  20319. } else {
  20320. fmt.Println(err)
  20321. }
  20322. userJSONBytes, _ := json.Marshal(dat)
  20323. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20324. utils.ErrorLog("解析失败:%v", err)
  20325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20326. return
  20327. }
  20328. }
  20329. if res.Infcode != 0 {
  20330. c.ServeSuccessJSON(map[string]interface{}{
  20331. "failed_code": -10,
  20332. "msg": res.ErrMsg,
  20333. })
  20334. return
  20335. } else {
  20336. if miConfig.MdtrtareaAdmvs != "150499" {
  20337. order.FaPiaoNumber = zero
  20338. order.FaPiaoCode = last_order.FaPiaoCode
  20339. service.UpdateOrder(order)
  20340. }
  20341. hisFundSettleListResult := &models.HisFundSettleListResult{
  20342. Number: res.Output.SetlListId,
  20343. Status: 1,
  20344. Ctime: time.Now().Unix(),
  20345. Mtime: time.Now().Unix(),
  20346. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20347. IsUpload: 1,
  20348. OrderId: order_id,
  20349. }
  20350. service.CreateUploadRecord(hisFundSettleListResult)
  20351. c.ServeSuccessJSON(map[string]interface{}{
  20352. "msg": "上传成功",
  20353. "result": hisFundSettleListResult,
  20354. })
  20355. return
  20356. }
  20357. }
  20358. //func (c *HisApiController) GetBatchSettleList() {
  20359. // orders, _ := service.GetAllHisOrder(10106)
  20360. // for _, item := range orders {
  20361. // order_id := item.ID
  20362. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20363. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20364. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20365. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20366. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20367. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20368. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20369. //
  20370. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20371. //
  20372. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20373. //
  20374. // if order.ID == 0 {
  20375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20376. // return
  20377. // }
  20378. // if his.BalanceAccountsType == 2 {
  20379. // continue
  20380. // }
  20381. // struct4101 := service.Struct4101{
  20382. // PsnNo: order.PsnNo,
  20383. // MdtrtId: order.MdtrtId,
  20384. // SetlId: order.SetlId,
  20385. // PsnName: order.PsnName,
  20386. // Gend: order.Gend,
  20387. // Brdy: his.Brdy,
  20388. // Age: his.Age,
  20389. // Naty: order.Naty,
  20390. // PatnCertType: "01",
  20391. // Certno: order.Certno,
  20392. // Prfs: "90",
  20393. // ConerName: roles[0].UserName,
  20394. // PatnRlts: "99",
  20395. // ConerAddr: miConfig.OrgName,
  20396. // ConerTel: admin.Mobile,
  20397. // HiType: order.Insutype,
  20398. // Insuplc: his.InsuplcAdmdvs,
  20399. // MaindiagFlag: "1",
  20400. // BillCode: order.SetlId,
  20401. // BillNo: order.SetlId,
  20402. // BizSn: order.Number,
  20403. // PsnSelfPay: order.PsnPartAmt,
  20404. // PsnOwnPay: order.PsnPartAmt,
  20405. // AcctPay: order.AcctPay,
  20406. // PsnCashpay: order.PsnCashPay,
  20407. // HiPaymtd: "1",
  20408. // Hsorg: his.InsuplcAdmdvs,
  20409. // HsorgOpter: his.InsuplcAdmdvs,
  20410. // MedinsFillPsn: curRoles.UserName,
  20411. // MedinsFillDept: depart.Name,
  20412. // IptMedType: "2",
  20413. // }
  20414. // struct4101.SetlBegnDate = order.SetlTime
  20415. // struct4101.SetlEndDate = order.SetlTime
  20416. // //if order.SettleType == 1 {
  20417. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20418. // // dateStr := t.Format("2006-01-02")
  20419. // // struct4101.SetlBegnDate = dateStr
  20420. // // struct4101.SetlEndDate = dateStr
  20421. // //} else {
  20422. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20423. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20424. // // dateStartStr := t.Format("2006-01-02")
  20425. // // dateEndStr := t2.Format("2006-01-02")
  20426. // // struct4101.SetlBegnDate = dateStartStr
  20427. // // struct4101.SetlEndDate = dateEndStr
  20428. // //}
  20429. //
  20430. // var rf []CustomFundPay
  20431. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20432. //
  20433. // var tempFunPays []service.CustomStruct
  20434. // var tempFunPay610100 service.CustomStruct
  20435. //
  20436. // for _, item := range rf {
  20437. // if item.FundPayType == "610100" {
  20438. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20439. // tempFunPay610100.FundPayType = item.FundPayType
  20440. // } else {
  20441. // var tempFunPay service.CustomStruct
  20442. // tempFunPay.FundPayamt = item.FundPayamt
  20443. // tempFunPay.FundPayType = item.FundPayType
  20444. // tempFunPays = append(tempFunPays, tempFunPay)
  20445. // }
  20446. // }
  20447. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20448. // struct4101.CustomStruct = tempFunPays
  20449. //
  20450. // var tempDiaginfos []service.DiaginfoStructTwo
  20451. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20452. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20453. //
  20454. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20455. // var config []*models.HisXtDiagnoseConfig
  20456. // for _, item := range diagnosis_ids {
  20457. // id, _ := strconv.ParseInt(item, 10, 64)
  20458. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20459. // config = append(config, &diagnosisConfig)
  20460. // }
  20461. //
  20462. // for index, item := range config {
  20463. // if index == 0 {
  20464. // var tempDiaginfo service.DiaginfoStructTwo
  20465. // tempDiaginfo.DiagCode = item.CountryCode
  20466. // tempDiaginfo.DiagName = item.CountryContentName
  20467. // tempDiaginfo.DiagType = "1"
  20468. // tempDiaginfo.MaindiagFlag = "1"
  20469. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20470. // } else {
  20471. //
  20472. // var tempDiaginfo service.DiaginfoStructTwo
  20473. // tempDiaginfo.DiagCode = item.CountryCode
  20474. // tempDiaginfo.DiagName = item.CountryContentName
  20475. // tempDiaginfo.DiagType = "2"
  20476. // tempDiaginfo.MaindiagFlag = "0"
  20477. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20478. // }
  20479. // }
  20480. // struct4101.Diseinfo = tempDiaginfos
  20481. //
  20482. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20483. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20484. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20485. // tempOpspdiseinfo2.OprnOprtCode = ""
  20486. // tempOpspdiseinfo2.OprnOprtName = ""
  20487. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20488. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20489. //
  20490. // var iteminfo service.IteminfoStruct
  20491. //
  20492. // var bedCostTotal float64 = 0 //床位总费
  20493. // var bedCostSelfTotal float64 = 0 //床位自费
  20494. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20495. //
  20496. // var examineCostTotal float64 = 0 //诊查总费
  20497. // var examineCostSelfTotal float64 = 0 //诊查自费
  20498. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20499. //
  20500. // var nursingCostTotal float64 = 0 //护理总费
  20501. // var nursingCostSelfTotal float64 = 0 //护理自费
  20502. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20503. //
  20504. // var chineseMedicineCostTotal float64 = 0 //中成药
  20505. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20506. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20507. //
  20508. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20509. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20510. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20511. //
  20512. // var registerCostTotal float64 = 0 //一般诊疗费
  20513. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20514. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20515. //
  20516. // var operationCostTotal float64 = 0 //手术费
  20517. // var operationCostSelfTotal float64 = 0 //手术费
  20518. // var operationCostPartSelfTotal float64 = 0 //手术费
  20519. //
  20520. // var otherCostTotal float64 = 0 //其他费用
  20521. // var otherCostSelfTotal float64 = 0 //其他费用
  20522. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20523. //
  20524. // var materialCostTotal float64 = 0 //材料费
  20525. // var materialCostSelfTotal float64 = 0 //材料费
  20526. // var materialCostPartSelfTotal float64 = 0 //材料费
  20527. //
  20528. // var westernMedicineCostTotal float64 = 0 //西药费
  20529. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20530. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20531. //
  20532. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20533. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20534. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20535. //
  20536. // var checkCostTotal float64 = 0 //检查费
  20537. // var checkCostSelfTotal float64 = 0 //检查费
  20538. // var checkCostPartSelfTotal float64 = 0 //检查费
  20539. //
  20540. // var laboratoryCostTotal float64 = 0 //化验费
  20541. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20542. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20543. //
  20544. // var treatCostTotal float64 = 0 //治疗费用
  20545. // var treatCostSelfTotal float64 = 0 //治疗费用
  20546. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20547. //
  20548. // decimal.DivisionPrecision = 2
  20549. //
  20550. // var bed_fulamt_ownpay_amt float64 = 0
  20551. //
  20552. // var examine_fulamt_ownpay_amt float64 = 0
  20553. //
  20554. // var nursing_fulamt_ownpay_amt float64 = 0
  20555. //
  20556. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20557. //
  20558. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20559. //
  20560. // var register_fulamt_ownpay_amt float64 = 0
  20561. //
  20562. // var operation_fulamt_ownpay_amt float64 = 0
  20563. // var other_fulamt_ownpay_amt float64 = 0
  20564. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20565. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20566. // var check_fulamt_ownpay_amt float64 = 0
  20567. // var material_fulamt_ownpay_amt float64 = 0
  20568. // var laboratory_fulamt_ownpay_amt float64 = 0
  20569. // var treat_fulamt_ownpay_amt float64 = 0
  20570. //
  20571. // var bed_claa_sunmfee float64 = 0
  20572. // var bed_clab_amt float64 = 0
  20573. // var bed_other_amt float64 = 0
  20574. //
  20575. // var examine_claa_sunmfee float64 = 0
  20576. // var examine_clab_amt float64 = 0
  20577. // var examine_other_amt float64 = 0
  20578. //
  20579. // var nursing_claa_sunmfee float64 = 0
  20580. // var nursing_clab_amt float64 = 0
  20581. // var nursing_other_amt float64 = 0
  20582. //
  20583. // var chinese_medicine_claa_sunmfee float64 = 0
  20584. // var chinese_medicine_clab_amt float64 = 0
  20585. // var chinese_medicine_other_amt float64 = 0
  20586. //
  20587. // var commonly_treatment_claa_sunmfee float64 = 0
  20588. // var commonly_treatment_clab_amt float64 = 0
  20589. // var commonly_treatment_other_amt float64 = 0
  20590. //
  20591. // var operation_claa_sunmfee float64 = 0
  20592. // var operation_clab_amt float64 = 0
  20593. // var operation_other_amt float64 = 0
  20594. //
  20595. // var other_claa_sunmfee float64 = 0
  20596. // var other_clab_amt float64 = 0
  20597. // var other_other_amt float64 = 0
  20598. //
  20599. // var westernMedicine_claa_sunmfee float64 = 0
  20600. // var westernMedicine_clab_amt float64 = 0
  20601. // var westernMedicine_other_amt float64 = 0
  20602. //
  20603. // var chineseTraditional_claa_sunmfee float64 = 0
  20604. // var chineseTraditional_clab_amt float64 = 0
  20605. // var chineseTraditional_other_amt float64 = 0
  20606. //
  20607. // var check_claa_sunmfee float64 = 0
  20608. // var check_clab_amt float64 = 0
  20609. // var check_other_amt float64 = 0
  20610. //
  20611. // var material_claa_sunmfee float64 = 0
  20612. // var material_clab_amt float64 = 0
  20613. // var material_other_amt float64 = 0
  20614. //
  20615. // var laboratory_claa_sunmfee float64 = 0
  20616. // var laboratory_clab_amt float64 = 0
  20617. // var laboratory_other_amt float64 = 0
  20618. //
  20619. // var treat_claa_sunmfee float64 = 0
  20620. // var treat_clab_amt float64 = 0
  20621. // var treat_other_amt float64 = 0
  20622. //
  20623. // var register_claa_sunmfee float64 = 0
  20624. // var register_clab_amt float64 = 0
  20625. // var register_other_amt float64 = 0
  20626. //
  20627. // for _, item := range order.HisOrderInfo {
  20628. // if item.MedChrgitmType == "01" { //床位费
  20629. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20630. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20631. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20632. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20633. // if item.ChrgitmLv == "1" {
  20634. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20635. // }
  20636. // if item.ChrgitmLv == "2" {
  20637. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20638. //
  20639. // }
  20640. // if item.ChrgitmLv == "3" {
  20641. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20642. // }
  20643. //
  20644. // }
  20645. //
  20646. // if item.MedChrgitmType == "02" { //诊查
  20647. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20648. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20649. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20650. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20651. // if item.ChrgitmLv == "1" {
  20652. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20653. // }
  20654. // if item.ChrgitmLv == "2" {
  20655. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20656. //
  20657. // }
  20658. // if item.ChrgitmLv == "3" {
  20659. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20660. // }
  20661. //
  20662. // }
  20663. //
  20664. // if item.MedChrgitmType == "03" { //检查费
  20665. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20666. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20667. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20668. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20669. // if item.ChrgitmLv == "1" {
  20670. //
  20671. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20672. //
  20673. // }
  20674. // if item.ChrgitmLv == "2" {
  20675. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20676. //
  20677. // }
  20678. // if item.ChrgitmLv == "3" {
  20679. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20680. // }
  20681. // }
  20682. //
  20683. // if item.MedChrgitmType == "04" { //化验费
  20684. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20685. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20686. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20687. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20688. // if item.ChrgitmLv == "1" {
  20689. //
  20690. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20691. //
  20692. // }
  20693. // if item.ChrgitmLv == "2" {
  20694. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20695. //
  20696. // }
  20697. // if item.ChrgitmLv == "3" {
  20698. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20699. // }
  20700. // }
  20701. //
  20702. // if item.MedChrgitmType == "05" { //治疗费
  20703. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20704. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20705. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20706. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20707. // if item.ChrgitmLv == "1" {
  20708. //
  20709. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20710. //
  20711. // }
  20712. // if item.ChrgitmLv == "2" {
  20713. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20714. //
  20715. // }
  20716. // if item.ChrgitmLv == "3" {
  20717. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20718. // }
  20719. // }
  20720. //
  20721. // if item.MedChrgitmType == "06" { //手术费
  20722. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20723. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20724. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20725. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20726. //
  20727. // if item.ChrgitmLv == "1" {
  20728. //
  20729. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20730. //
  20731. // }
  20732. // if item.ChrgitmLv == "2" {
  20733. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20734. //
  20735. // }
  20736. // if item.ChrgitmLv == "3" {
  20737. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20738. // }
  20739. // }
  20740. //
  20741. // if item.MedChrgitmType == "07" { //手术费
  20742. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20743. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20744. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20745. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20746. //
  20747. // if item.ChrgitmLv == "1" {
  20748. //
  20749. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20750. //
  20751. // }
  20752. // if item.ChrgitmLv == "2" {
  20753. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20754. //
  20755. // }
  20756. // if item.ChrgitmLv == "3" {
  20757. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20758. // }
  20759. // }
  20760. //
  20761. // if item.MedChrgitmType == "08" { //材料费
  20762. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20763. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20764. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20765. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20766. // if item.ChrgitmLv == "1" {
  20767. //
  20768. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20769. //
  20770. // }
  20771. // if item.ChrgitmLv == "2" {
  20772. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20773. //
  20774. // }
  20775. // if item.ChrgitmLv == "3" {
  20776. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20777. // }
  20778. // }
  20779. // if item.MedChrgitmType == "09" { //西药费
  20780. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20781. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20782. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20783. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20784. // if item.ChrgitmLv == "1" {
  20785. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20786. // }
  20787. // if item.ChrgitmLv == "2" {
  20788. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20789. // }
  20790. // if item.ChrgitmLv == "3" {
  20791. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20792. // }
  20793. // }
  20794. // if item.MedChrgitmType == "10" { //中药饮片
  20795. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20796. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20797. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20798. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20799. // if item.ChrgitmLv == "1" {
  20800. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20801. // }
  20802. // if item.ChrgitmLv == "2" {
  20803. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20804. // }
  20805. // if item.ChrgitmLv == "3" {
  20806. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20807. // }
  20808. // }
  20809. //
  20810. // if item.MedChrgitmType == "11" { //中成费
  20811. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20812. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20813. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20814. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20815. // if item.ChrgitmLv == "1" {
  20816. //
  20817. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20818. //
  20819. // }
  20820. // if item.ChrgitmLv == "2" {
  20821. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20822. //
  20823. // }
  20824. // if item.ChrgitmLv == "3" {
  20825. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20826. // }
  20827. // }
  20828. //
  20829. // if item.MedChrgitmType == "12" { //中成费
  20830. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20831. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20832. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20833. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20834. // if item.ChrgitmLv == "1" {
  20835. //
  20836. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20837. //
  20838. // }
  20839. // if item.ChrgitmLv == "2" {
  20840. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20841. //
  20842. // }
  20843. // if item.ChrgitmLv == "3" {
  20844. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20845. // }
  20846. // }
  20847. //
  20848. // if item.MedChrgitmType == "13" { //中成费
  20849. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20850. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20851. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20852. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20853. // if item.ChrgitmLv == "1" {
  20854. //
  20855. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20856. //
  20857. // }
  20858. // if item.ChrgitmLv == "2" {
  20859. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20860. //
  20861. // }
  20862. // if item.ChrgitmLv == "3" {
  20863. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20864. // }
  20865. // }
  20866. //
  20867. // if item.MedChrgitmType == "14" { //其他费
  20868. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20869. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20870. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20871. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20872. // if item.ChrgitmLv == "1" {
  20873. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20874. //
  20875. // }
  20876. // if item.ChrgitmLv == "2" {
  20877. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20878. //
  20879. // }
  20880. // if item.ChrgitmLv == "3" {
  20881. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20882. // }
  20883. // }
  20884. //
  20885. // }
  20886. //
  20887. // var iteminfoStructs []service.IteminfoStruct
  20888. //
  20889. // if bedCostTotal != 0 {
  20890. // iteminfo.MedChrgitm = "01"
  20891. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20892. // iteminfo.Amt = bedCostTotal
  20893. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20894. // iteminfo.ClabAmt = bed_clab_amt
  20895. // iteminfo.OthAmt = bed_other_amt
  20896. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20897. // }
  20898. //
  20899. // if examineCostTotal != 0 {
  20900. // iteminfo.MedChrgitm = "02"
  20901. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20902. // iteminfo.Amt = examineCostTotal
  20903. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20904. // iteminfo.ClabAmt = examine_clab_amt
  20905. // iteminfo.OthAmt = examine_other_amt
  20906. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20907. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20908. // }
  20909. //
  20910. // if checkCostTotal != 0 {
  20911. // iteminfo.MedChrgitm = "03"
  20912. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20913. // iteminfo.Amt = checkCostTotal
  20914. // iteminfo.ClaaSumfee = check_claa_sunmfee
  20915. // iteminfo.ClabAmt = check_clab_amt
  20916. // iteminfo.OthAmt = check_other_amt
  20917. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20918. //
  20919. // }
  20920. //
  20921. // if laboratoryCostTotal != 0 {
  20922. // iteminfo.MedChrgitm = "04"
  20923. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20924. // iteminfo.Amt = laboratoryCostTotal
  20925. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20926. // iteminfo.ClabAmt = laboratory_clab_amt
  20927. // iteminfo.OthAmt = laboratory_other_amt
  20928. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20929. //
  20930. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20931. //
  20932. // }
  20933. //
  20934. // if treatCostTotal != 0 {
  20935. // iteminfo.MedChrgitm = "05"
  20936. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20937. // iteminfo.Amt = treatCostTotal
  20938. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  20939. // iteminfo.ClabAmt = treat_clab_amt
  20940. // iteminfo.OthAmt = treat_other_amt
  20941. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20942. // //(struct4101.IteminfoStruct, iteminfo)
  20943. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20944. // }
  20945. //
  20946. // if operationCostTotal != 0 {
  20947. // iteminfo.MedChrgitm = "06"
  20948. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20949. // iteminfo.Amt = operationCostTotal
  20950. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  20951. // iteminfo.ClabAmt = operation_clab_amt
  20952. // iteminfo.OthAmt = operation_other_amt
  20953. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20954. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20955. // }
  20956. //
  20957. // if nursingCostTotal != 0 {
  20958. // iteminfo.MedChrgitm = "07"
  20959. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  20960. // iteminfo.Amt = nursingCostTotal
  20961. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  20962. // iteminfo.ClabAmt = nursing_clab_amt
  20963. // iteminfo.OthAmt = nursing_other_amt
  20964. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20965. // }
  20966. //
  20967. // if materialCostTotal != 0 {
  20968. // iteminfo.MedChrgitm = "08"
  20969. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20970. // iteminfo.Amt = materialCostTotal
  20971. // iteminfo.ClaaSumfee = material_claa_sunmfee
  20972. // iteminfo.ClabAmt = material_clab_amt
  20973. // iteminfo.OthAmt = material_other_amt
  20974. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20975. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20976. // }
  20977. //
  20978. // if westernMedicineCostTotal != 0 {
  20979. // iteminfo.MedChrgitm = "09"
  20980. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20981. // iteminfo.Amt = westernMedicineCostTotal
  20982. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20983. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20984. // iteminfo.OthAmt = westernMedicine_other_amt
  20985. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20986. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20987. //
  20988. // }
  20989. //
  20990. // if chineseMedicineCostTotal != 0 {
  20991. // iteminfo.MedChrgitm = "10"
  20992. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  20993. // iteminfo.Amt = chineseMedicineCostTotal
  20994. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  20995. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  20996. // iteminfo.OthAmt = chinese_medicine_other_amt
  20997. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20998. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20999. //
  21000. // }
  21001. //
  21002. // if chineseTraditionalMedicineCostTotal != 0 {
  21003. // iteminfo.MedChrgitm = "11"
  21004. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21005. // iteminfo.Amt = westernMedicineCostTotal
  21006. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21007. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21008. // iteminfo.OthAmt = westernMedicine_other_amt
  21009. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21010. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21011. //
  21012. // }
  21013. //
  21014. // if commonlyTreatmentCostTotal != 0 {
  21015. // iteminfo.MedChrgitm = "12"
  21016. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21017. // iteminfo.Amt = commonlyTreatmentCostTotal
  21018. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21019. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21020. // iteminfo.OthAmt = commonly_treatment_other_amt
  21021. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21022. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21023. //
  21024. // }
  21025. //
  21026. // if registerCostTotal != 0 {
  21027. // iteminfo.MedChrgitm = "13"
  21028. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21029. // iteminfo.Amt = registerCostTotal
  21030. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21031. // iteminfo.ClabAmt = register_clab_amt
  21032. // iteminfo.OthAmt = register_other_amt
  21033. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21034. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21035. //
  21036. // }
  21037. //
  21038. // if otherCostTotal != 0 {
  21039. // iteminfo.MedChrgitm = "14"
  21040. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21041. // iteminfo.Amt = otherCostTotal
  21042. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21043. // iteminfo.ClabAmt = other_clab_amt
  21044. // iteminfo.OthAmt = other_other_amt
  21045. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21046. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21047. //
  21048. // }
  21049. // struct4101.IteminfoStruct = iteminfoStructs
  21050. // time_arr := strings.Split(order.SetlTime, " ")
  21051. // struct4101.AdmTime = time_arr[0]
  21052. // struct4101.AdmEndTime = time_arr[0]
  21053. //
  21054. // struct4101.DoctorName = doctor.UserName
  21055. // struct4101.DoctorCode = doctor.DoctorNumber
  21056. //
  21057. // struct4101.Ntly = "中国"
  21058. // struct4101.AdmCaty = "A03.06"
  21059. // var res ResultSeventeen
  21060. // if miConfig.MdtrtareaAdmvs == "421300" {
  21061. // data := make(map[string]interface{})
  21062. // data["struct4101"] = struct4101
  21063. // data["secret_key"] = miConfig.SecretKey
  21064. // data["org_name"] = miConfig.OrgName
  21065. // data["opera"] = curRoles.UserName
  21066. // data["code"] = miConfig.Code
  21067. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21068. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21069. //
  21070. // client := &http.Client{}
  21071. // bytesData, _ := json.Marshal(data)
  21072. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21073. // resp, _ := client.Do(req)
  21074. // defer resp.Body.Close()
  21075. // body, ioErr := ioutil.ReadAll(resp.Body)
  21076. // if ioErr != nil {
  21077. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21079. // return
  21080. // }
  21081. // var respJSON map[string]interface{}
  21082. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21083. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21084. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21085. // return
  21086. // }
  21087. //
  21088. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21089. // userJSONBytes, _ := json.Marshal(respJSON)
  21090. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21091. // utils.ErrorLog("解析失败:%v", err)
  21092. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21093. // adminUser := c.GetAdminUserInfo()
  21094. // errlog := &models.HisOrderError{
  21095. // UserOrgId: adminUser.CurrentOrgId,
  21096. // Ctime: time.Now().Unix(),
  21097. // Mtime: time.Now().Unix(),
  21098. // ErrMsg: res.ErrMsg + "解析失败",
  21099. // Status: 1,
  21100. // PatientId: order_id,
  21101. // Stage: 10088,
  21102. // }
  21103. // service.CreateErrMsgLog(errlog)
  21104. // continue
  21105. // }
  21106. //
  21107. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21108. // data := make(map[string]interface{})
  21109. // data["struct4101"] = struct4101
  21110. // data["secret_key"] = miConfig.SecretKey
  21111. // data["org_name"] = miConfig.OrgName
  21112. // data["opera"] = curRoles.UserName
  21113. // data["code"] = miConfig.Code
  21114. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21115. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21116. //
  21117. // client := &http.Client{}
  21118. // bytesData, _ := json.Marshal(data)
  21119. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21120. // resp, _ := client.Do(req)
  21121. // defer resp.Body.Close()
  21122. // body, ioErr := ioutil.ReadAll(resp.Body)
  21123. // if ioErr != nil {
  21124. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21125. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21126. // return
  21127. // }
  21128. // var respJSON map[string]interface{}
  21129. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21130. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21132. // return
  21133. // }
  21134. //
  21135. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21136. // userJSONBytes, _ := json.Marshal(respJSON)
  21137. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21138. // utils.ErrorLog("解析失败:%v", err)
  21139. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21140. // adminUser := c.GetAdminUserInfo()
  21141. // errlog := &models.HisOrderError{
  21142. // UserOrgId: adminUser.CurrentOrgId,
  21143. // Ctime: time.Now().Unix(),
  21144. // Mtime: time.Now().Unix(),
  21145. // ErrMsg: res.ErrMsg + "解析失败",
  21146. // Status: 1,
  21147. // PatientId: order_id,
  21148. // Stage: 10088,
  21149. // }
  21150. // service.CreateErrMsgLog(errlog)
  21151. // continue
  21152. // }
  21153. //
  21154. // } else {
  21155. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21156. // fmt.Println(result)
  21157. //
  21158. // var dat map[string]interface{}
  21159. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21160. // fmt.Println(dat)
  21161. // } else {
  21162. // fmt.Println(err)
  21163. // }
  21164. // userJSONBytes, _ := json.Marshal(dat)
  21165. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21166. // utils.ErrorLog("解析失败:%v", err)
  21167. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21168. // adminUser := c.GetAdminUserInfo()
  21169. // errlog := &models.HisOrderError{
  21170. // UserOrgId: adminUser.CurrentOrgId,
  21171. // Ctime: time.Now().Unix(),
  21172. // Mtime: time.Now().Unix(),
  21173. // ErrMsg: res.ErrMsg + "解析失败",
  21174. // Status: 1,
  21175. // PatientId: order_id,
  21176. // Stage: 10106,
  21177. // }
  21178. // service.CreateErrMsgLog(errlog)
  21179. // continue
  21180. // }
  21181. // }
  21182. //
  21183. // if res.Infcode != 0 {
  21184. // adminUser := c.GetAdminUserInfo()
  21185. // errlog := &models.HisOrderError{
  21186. // UserOrgId: adminUser.CurrentOrgId,
  21187. // Ctime: time.Now().Unix(),
  21188. // Mtime: time.Now().Unix(),
  21189. // ErrMsg: res.ErrMsg,
  21190. // Status: 1,
  21191. // PatientId: order_id,
  21192. // Stage: 10106,
  21193. // }
  21194. // service.CreateErrMsgLog(errlog)
  21195. // continue
  21196. // } else {
  21197. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21198. // Number: res.Output.SetlListId,
  21199. // Status: 1,
  21200. // Ctime: time.Now().Unix(),
  21201. // Mtime: time.Now().Unix(),
  21202. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21203. // IsUpload: 1,
  21204. // OrderId: order_id,
  21205. // }
  21206. // service.CreateUploadRecord(hisFundSettleListResult)
  21207. // continue
  21208. // }
  21209. // }
  21210. //}
  21211. func (c *HisApiController) GetOrgInfo() {
  21212. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21213. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21214. }
  21215. func (c *HisApiController) GetHisPatientInfo() {
  21216. medical_insurance_card := c.GetString("medical_insurance_card")
  21217. id_card_type, _ := c.GetInt64("id_card_type")
  21218. id_card := c.GetString("id_card")
  21219. adminInfo := c.GetAdminUserInfo()
  21220. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21221. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21222. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21223. IdCardNo := ""
  21224. if id_card_type == 1 {
  21225. IdCardNo = medical_insurance_card
  21226. } else if id_card_type == 2 {
  21227. IdCardNo = id_card
  21228. }
  21229. if config.IsOpen == 1 {
  21230. 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
  21231. resp, requestErr := http.Get(api)
  21232. if requestErr != nil {
  21233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21234. return
  21235. }
  21236. defer resp.Body.Close()
  21237. body, ioErr := ioutil.ReadAll(resp.Body)
  21238. if ioErr != nil {
  21239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21241. return
  21242. }
  21243. var respJSON map[string]interface{}
  21244. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21247. return
  21248. }
  21249. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21250. userJSONBytes, _ := json.Marshal(userJSON)
  21251. var res ResultTwo
  21252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21253. utils.ErrorLog("解析失败:%v", err)
  21254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21255. return
  21256. }
  21257. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21258. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21259. infoStr := string(Iinfos)
  21260. idetinfoStr := string(Idetinfos)
  21261. if res.Infcode == 0 {
  21262. his := models.VMHisPatient{
  21263. Status: 1,
  21264. Ctime: time.Now().Unix(),
  21265. Mtime: time.Now().Unix(),
  21266. PsnNo: res.Output.Baseinfo.PsnNo,
  21267. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21268. Certno: res.Output.Baseinfo.Certno,
  21269. PsnName: res.Output.Baseinfo.PsnName,
  21270. Gend: res.Output.Baseinfo.Gend,
  21271. Naty: res.Output.Baseinfo.Naty,
  21272. Iinfo: infoStr,
  21273. Idetinfo: idetinfoStr,
  21274. UserOrgId: adminInfo.CurrentOrgId,
  21275. IsReturn: 1,
  21276. IdCardType: id_card_type,
  21277. }
  21278. c.ServeSuccessJSON(map[string]interface{}{
  21279. "info": his,
  21280. })
  21281. } else {
  21282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21283. return
  21284. }
  21285. }
  21286. }
  21287. //func GetBasBaseInfo() (jsonStr string, err error) {
  21288. //
  21289. // handle := syscall.NewLazyDLL("SSCard.dll")
  21290. // add := handle.NewProc("ReadCardBas")
  21291. // str := make([]byte, 1024)
  21292. // str1 := make([]byte, 1024)
  21293. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21294. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21295. //
  21296. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21297. //
  21298. // fmt.Println("> Add(4,5)的结果为:", ret)
  21299. // handle.Release()
  21300. //
  21301. // return "", nil
  21302. //
  21303. //}
  21304. //func GetQRBaseInfo() (jsonStr string, err error) {
  21305. // handle := syscall.LoadDLL("SSCard.dll")
  21306. // ReadCardBas := handle.FindProc("GetQRBase")
  21307. //
  21308. // str := make([]byte, 256)
  21309. // str1 := make([]byte, 256)
  21310. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21311. //
  21312. // fmt.Println(string(str))
  21313. // fmt.Println(r)
  21314. // return string(str), nil
  21315. //}
  21316. //func CardInit() int {
  21317. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21318. // add := DllTestDef.MustFindProc("Init")
  21319. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21320. // if err != nil {
  21321. // fmt.Println("SSCard的运算结果为:", ret)
  21322. // }
  21323. // result := int(ret)
  21324. // return result
  21325. //}
  21326. //func CardInit() int {
  21327. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21328. // if err != nil {
  21329. // fmt.Println("SSCard的运算结果为:", ret)
  21330. // }
  21331. // fmt.Println(err)
  21332. // result := int(ret)
  21333. // return result
  21334. //}
  21335. func IntPtr(n int) uintptr {
  21336. return uintptr(n)
  21337. }
  21338. func StrPtr(s string) uintptr {
  21339. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21340. }
  21341. type Result2001 struct {
  21342. Cainfo interface{} `json:"cainfo"`
  21343. ErrMsg string `json:"err_msg"`
  21344. InfRefmsgid string `json:"inf_refmsgid"`
  21345. Infcode int64 `json:"infcode"`
  21346. Output struct {
  21347. Trtinfo struct {
  21348. PsnNo string `json:"psn_no"`
  21349. TrtChkType string `json:"trt_chk_type"`
  21350. FundPayType string `json:"fund_pay_type"`
  21351. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21352. Begndate string `json:"begndate"`
  21353. Enddate string `json:"enddate"`
  21354. TrtChkRslt string `json:"trt_chk_rslt"`
  21355. } `json:"trtinfo"`
  21356. } `json:"output"`
  21357. RefmsgTime string `json:"refmsg_time"`
  21358. RespondTime string `json:"respond_time"`
  21359. Signtype interface{} `json:"signtype"`
  21360. WarnMsg interface{} `json:"warn_msg"`
  21361. }
  21362. type Result2001Org10265 struct {
  21363. Cainfo interface{} `json:"cainfo"`
  21364. ErrMsg string `json:"err_msg"`
  21365. InfRefmsgid string `json:"inf_refmsgid"`
  21366. Infcode string `json:"infcode"`
  21367. Output struct {
  21368. Trtinfo struct {
  21369. PsnNo string `json:"psn_no"`
  21370. TrtChkType string `json:"trt_chk_type"`
  21371. FundPayType string `json:"fund_pay_type"`
  21372. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21373. Begndate string `json:"begndate"`
  21374. Enddate string `json:"enddate"`
  21375. TrtChkRslt string `json:"trt_chk_rslt"`
  21376. } `json:"trtinfo"`
  21377. } `json:"output"`
  21378. RefmsgTime string `json:"refmsg_time"`
  21379. RespondTime string `json:"respond_time"`
  21380. Signtype interface{} `json:"signtype"`
  21381. WarnMsg interface{} `json:"warn_msg"`
  21382. }
  21383. type ResultTwo struct {
  21384. ErrMsg string `json:"err_msg"`
  21385. InfRefmsgid string `json:"inf_refmsgid"`
  21386. Infcode int64 `json:"infcode"`
  21387. Output struct {
  21388. Baseinfo struct {
  21389. //Brdy string `json:"brdy"`
  21390. Certno string `json:"certno"`
  21391. Gend string `json:"gend"`
  21392. Naty string `json:"naty"`
  21393. PsnCertType string `json:"psn_cert_type"`
  21394. PsnName string `json:"psn_name"`
  21395. PsnNo string `json:"psn_no"`
  21396. } `json:"baseinfo"`
  21397. Idetinfo []interface{} `json:"idetinfo"`
  21398. Iinfo []struct {
  21399. Balc float64 `json:"balc"`
  21400. CvlservFlag string `json:"cvlserv_flag"`
  21401. EmpName string `json:"emp_name"`
  21402. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21403. Insutype string `json:"insutype"`
  21404. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21405. //PausInsuDate string `json:"paus_insu_date"`
  21406. //PsnInsuDate string `json:"psn_insu_date"`
  21407. PsnInsuStas string `json:"psn_insu_stas"`
  21408. PsnType string `json:"psn_type"`
  21409. } `json:"insuinfo"`
  21410. } `json:"output"`
  21411. RefmsgTime string `json:"refmsg_time"`
  21412. RespondTime string `json:"respond_time"`
  21413. Signtype interface{} `json:"signtype"`
  21414. WarnInfo interface{} `json:"warn_info"`
  21415. }
  21416. type ResultTwo10265 struct {
  21417. ErrMsg string `json:"err_msg"`
  21418. InfRefmsgid string `json:"inf_refmsgid"`
  21419. Infcode string `json:"infcode"`
  21420. Output struct {
  21421. Baseinfo struct {
  21422. //Brdy string `json:"brdy"`
  21423. Certno string `json:"certno"`
  21424. Gend string `json:"gend"`
  21425. Naty string `json:"naty"`
  21426. PsnCertType string `json:"psn_cert_type"`
  21427. PsnName string `json:"psn_name"`
  21428. PsnNo string `json:"psn_no"`
  21429. } `json:"baseinfo"`
  21430. Idetinfo []interface{} `json:"idetinfo"`
  21431. Iinfo []struct {
  21432. Balc float64 `json:"balc"`
  21433. CvlservFlag string `json:"cvlserv_flag"`
  21434. EmpName string `json:"emp_name"`
  21435. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21436. Insutype string `json:"insutype"`
  21437. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21438. PsnInsuStas string `json:"psn_insu_stas"`
  21439. PsnType string `json:"psn_type"`
  21440. } `json:"insuinfo"`
  21441. } `json:"output"`
  21442. RefmsgTime string `json:"refmsg_time"`
  21443. RespondTime string `json:"respond_time"`
  21444. Signtype interface{} `json:"signtype"`
  21445. WarnInfo interface{} `json:"warn_info"`
  21446. }
  21447. type ResultThree struct {
  21448. Cainfo interface{} `json:"cainfo"`
  21449. ErrMsg string `json:"err_msg"`
  21450. InfRefmsgid string `json:"inf_refmsgid"`
  21451. Infcode int64 `json:"infcode"`
  21452. Output struct {
  21453. Data struct {
  21454. IptOtpNo string `json:"ipt_otp_no"`
  21455. MdtrtID string `json:"mdtrt_id"`
  21456. PsnNo string `json:"psn_no"`
  21457. } `json:"data"`
  21458. } `json:"output"`
  21459. RefmsgTime string `json:"refmsg_time"`
  21460. RespondTime string `json:"respond_time"`
  21461. Signtype interface{} `json:"signtype"`
  21462. WarnMsg interface{} `json:"warn_msg"`
  21463. }
  21464. type ResultThree10265 struct {
  21465. Cainfo interface{} `json:"cainfo"`
  21466. ErrMsg string `json:"err_msg"`
  21467. InfRefmsgid string `json:"inf_refmsgid"`
  21468. Infcode string `json:"infcode"`
  21469. Output struct {
  21470. Data struct {
  21471. IptOtpNo string `json:"ipt_otp_no"`
  21472. MdtrtID string `json:"mdtrt_id"`
  21473. PsnNo string `json:"psn_no"`
  21474. } `json:"data"`
  21475. } `json:"output"`
  21476. RefmsgTime string `json:"refmsg_time"`
  21477. RespondTime string `json:"respond_time"`
  21478. Signtype interface{} `json:"signtype"`
  21479. WarnMsg interface{} `json:"warn_msg"`
  21480. }
  21481. type ResultFour struct {
  21482. Cainfo string `json:"cainfo"`
  21483. ErrMsg string `json:"err_msg"`
  21484. InfRefmsgid string `json:"inf_refmsgid"`
  21485. Infcode int64 `json:"infcode"`
  21486. Output struct {
  21487. Result []struct {
  21488. BasMednFlag string `json:"bas_medn_flag"`
  21489. ChldMedcFlag string `json:"chld_medc_flag"`
  21490. ChrgitmLv string `json:"chrgitm_lv"`
  21491. Cnt float64 `json:"cnt"`
  21492. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21493. DrtReimFlag string `json:"drt_reim_flag"`
  21494. FeedetlSn string `json:"feedetl_sn"`
  21495. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21496. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21497. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21498. ListSpItemFlag string `json:"list_sp_item_flag"`
  21499. LmtUsedFlag string `json:"lmt_used_flag"`
  21500. MedChrgitmType string `json:"med_chrgitm_type"`
  21501. Memo string `json:"memo"`
  21502. OverlmtAmt float64 `json:"overlmt_amt"`
  21503. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21504. Pric float64 `json:"pric"`
  21505. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21506. SelfpayProp float64 `json:"selfpay_prop"`
  21507. } `json:"result"`
  21508. } `json:"output"`
  21509. RefmsgTime string `json:"refmsg_time"`
  21510. RespondTime string `json:"respond_time"`
  21511. Signtype string `json:"signtype"`
  21512. WarnMsg string `json:"warn_msg"`
  21513. }
  21514. type ResultFour10265 struct {
  21515. Cainfo string `json:"cainfo"`
  21516. ErrMsg string `json:"err_msg"`
  21517. InfRefmsgid string `json:"inf_refmsgid"`
  21518. Infcode string `json:"infcode"`
  21519. Output struct {
  21520. Result []struct {
  21521. BasMednFlag string `json:"bas_medn_flag"`
  21522. ChldMedcFlag string `json:"chld_medc_flag"`
  21523. ChrgitmLv string `json:"chrgitm_lv"`
  21524. Cnt float64 `json:"cnt"`
  21525. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21526. DrtReimFlag string `json:"drt_reim_flag"`
  21527. FeedetlSn string `json:"feedetl_sn"`
  21528. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21529. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21530. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21531. ListSpItemFlag string `json:"list_sp_item_flag"`
  21532. LmtUsedFlag string `json:"lmt_used_flag"`
  21533. MedChrgitmType string `json:"med_chrgitm_type"`
  21534. Memo string `json:"memo"`
  21535. OverlmtAmt float64 `json:"overlmt_amt"`
  21536. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21537. Pric float64 `json:"pric"`
  21538. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21539. SelfpayProp float64 `json:"selfpay_prop"`
  21540. } `json:"result"`
  21541. } `json:"output"`
  21542. RefmsgTime string `json:"refmsg_time"`
  21543. RespondTime string `json:"respond_time"`
  21544. Signtype string `json:"signtype"`
  21545. WarnMsg string `json:"warn_msg"`
  21546. }
  21547. type ResultMemo struct {
  21548. InsuAdmdvs string `json:"insuAdmdvs"`
  21549. }
  21550. // [{"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}]
  21551. type ResultIDInfo struct {
  21552. Begntime string `json:"begntime"`
  21553. Endtime string `json:"endtime"`
  21554. Memo string `json:"memo"`
  21555. }
  21556. type ResultFive struct {
  21557. Balc float64 `json:"balc"`
  21558. CvlservFlag string `json:"cvlserv_flag"`
  21559. EmpName string `json:"emp_name"`
  21560. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21561. Insutype string `json:"insutype"`
  21562. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21563. PausInsuDate string `json:"paus_insu_date"`
  21564. PsnInsuDate string `json:"psn_insu_date"`
  21565. PsnInsuStas string `json:"psn_insu_stas"`
  21566. PsnType string `json:"psn_type"`
  21567. }
  21568. type ResultSix struct {
  21569. Cainfo interface{} `json:"cainfo"`
  21570. ErrMsg string `json:"err_msg"`
  21571. InfRefmsgid string `json:"inf_refmsgid"`
  21572. Infcode int64 `json:"infcode"`
  21573. Output struct {
  21574. } `json:"output"`
  21575. RefmsgTime string `json:"refmsg_time"`
  21576. RespondTime string `json:"respond_time"`
  21577. Signtype interface{} `json:"signtype"`
  21578. WarnMsg interface{} `json:"warn_msg"`
  21579. }
  21580. type FJ3507Result struct {
  21581. Cainfo interface{} `json:"cainfo"`
  21582. ErrMsg string `json:"err_msg"`
  21583. InfRefmsgid string `json:"inf_refmsgid"`
  21584. Infcode int64 `json:"infcode"`
  21585. Output struct {
  21586. retRslt string `json:"retRslt"`
  21587. msgRslt string `json:"msgRslt"`
  21588. } `json:"output"`
  21589. RefmsgTime string `json:"refmsg_time"`
  21590. RespondTime string `json:"respond_time"`
  21591. Signtype interface{} `json:"signtype"`
  21592. WarnMsg interface{} `json:"warn_msg"`
  21593. }
  21594. type FJ3507ResultFor10188 struct {
  21595. Cainfo interface{} `json:"cainfo"`
  21596. ErrMsg string `json:"err_msg"`
  21597. InfRefmsgid string `json:"inf_refmsgid"`
  21598. Infcode string `json:"infcode"`
  21599. RefmsgTime string `json:"refmsg_time"`
  21600. RespondTime string `json:"respond_time"`
  21601. Signtype interface{} `json:"signtype"`
  21602. WarnMsg interface{} `json:"warn_msg"`
  21603. }
  21604. type Result2406 struct {
  21605. Cainfo interface{} `json:"cainfo"`
  21606. ErrMsg string `json:"err_msg"`
  21607. InfRefmsgid string `json:"inf_refmsgid"`
  21608. Infcode int64 `json:"infcode"`
  21609. Output struct {
  21610. Result struct {
  21611. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21612. } `json:"result"`
  21613. } `json:"output"`
  21614. RefmsgTime string `json:"refmsg_time"`
  21615. RespondTime string `json:"respond_time"`
  21616. Signtype interface{} `json:"signtype"`
  21617. WarnMsg interface{} `json:"warn_msg"`
  21618. }
  21619. type GZResultSix struct {
  21620. Cainfo interface{} `json:"cainfo"`
  21621. ErrMsg string `json:"err_msg"`
  21622. InfRefmsgid string `json:"inf_refmsgid"`
  21623. Infcode int64 `json:"infcode"`
  21624. Output string `json:"output"`
  21625. RefmsgTime string `json:"refmsg_time"`
  21626. RespondTime string `json:"respond_time"`
  21627. Signtype interface{} `json:"signtype"`
  21628. WarnMsg interface{} `json:"warn_msg"`
  21629. }
  21630. type ResultSix10265 struct {
  21631. Cainfo interface{} `json:"cainfo"`
  21632. ErrMsg string `json:"err_msg"`
  21633. InfRefmsgid string `json:"inf_refmsgid"`
  21634. Infcode string `json:"infcode"`
  21635. Output struct {
  21636. } `json:"output"`
  21637. RefmsgTime string `json:"refmsg_time"`
  21638. RespondTime string `json:"respond_time"`
  21639. Signtype interface{} `json:"signtype"`
  21640. WarnMsg interface{} `json:"warn_msg"`
  21641. }
  21642. type ResultSeven struct {
  21643. Cainfo string `json:"cainfo"`
  21644. ErrMsg string `json:"err_msg"`
  21645. InfRefmsgid string `json:"inf_refmsgid"`
  21646. Infcode int64 `json:"infcode"`
  21647. Output struct {
  21648. Setlinfo struct {
  21649. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21650. AcctPay float64 `json:"acct_pay"`
  21651. ActPayDedc float64 `json:"act_pay_dedc"`
  21652. Age float64 `json:"age"`
  21653. Balc float64 `json:"balc"`
  21654. Certno string `json:"certno"`
  21655. ClrOptins string `json:"clr_optins"`
  21656. ClrType string `json:"clr_type"`
  21657. ClrWay string `json:"clr_way"`
  21658. CvlservFlag string `json:"cvlserv_flag"`
  21659. CvlservPay float64 `json:"cvlserv_pay"`
  21660. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21661. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21662. Gend string `json:"gend"`
  21663. HifesPay float64 `json:"hifes_pay"`
  21664. HifmiPay float64 `json:"hifmi_pay"`
  21665. HifpPay float64 `json:"hifp_pay"`
  21666. HospPartAmt float64 `json:"hosp_part_amt"`
  21667. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21668. Insutype string `json:"insutype"`
  21669. MafPay float64 `json:"maf_pay"`
  21670. MdtrtCertType string `json:"mdtrt_cert_type"`
  21671. HifobPay float64 `json:"hifob_pay"`
  21672. MdtrtID string `json:"mdtrt_id"`
  21673. MedType string `json:"med_type"`
  21674. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21675. MedinsSetlID string `json:"medins_setl_id"`
  21676. Naty string `json:"naty"`
  21677. OthPay float64 `json:"oth_pay"`
  21678. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21679. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21680. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21681. PsnCashPay float64 `json:"psn_cash_pay"`
  21682. PsnCertType string `json:"psn_cert_type"`
  21683. PsnName string `json:"psn_name"`
  21684. PsnNo string `json:"psn_no"`
  21685. PsnPartAmt float64 `json:"psn_part_amt"`
  21686. PsnType string `json:"psn_type"`
  21687. SetlID string `json:"setl_id"`
  21688. SetlTime string `json:"setl_time"`
  21689. } `json:"setlinfo"`
  21690. Setldetail interface{} `json:"setldetail"`
  21691. } `json:"output"`
  21692. RefmsgTime string `json:"refmsg_time"`
  21693. RespondTime string `json:"respond_time"`
  21694. Signtype interface{} `json:"signtype"`
  21695. WarnMsg interface{} `json:"warn_msg"`
  21696. }
  21697. type ResultSevenAH struct {
  21698. Cainfo string `json:"cainfo"`
  21699. ErrMsg string `json:"err_msg"`
  21700. InfRefmsgid string `json:"inf_refmsgid"`
  21701. Infcode int64 `json:"infcode"`
  21702. Output struct {
  21703. Setlinfo struct {
  21704. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21705. AcctPay float64 `json:"acct_pay"`
  21706. ActPayDedc float64 `json:"act_pay_dedc"`
  21707. Age float64 `json:"age"`
  21708. Balc float64 `json:"balc"`
  21709. Certno string `json:"certno"`
  21710. ClrOptins string `json:"clr_optins"`
  21711. ClrType string `json:"clr_type"`
  21712. ClrWay string `json:"clr_way"`
  21713. CvlservFlag string `json:"cvlserv_flag"`
  21714. CvlservPay float64 `json:"cvlserv_pay"`
  21715. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21716. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21717. Gend string `json:"gend"`
  21718. HifesPay float64 `json:"hifes_pay"`
  21719. HifmiPay float64 `json:"hifmi_pay"`
  21720. HifpPay float64 `json:"hifp_pay"`
  21721. HospPartAmt float64 `json:"hosp_part_amt"`
  21722. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21723. Insutype string `json:"insutype"`
  21724. MafPay float64 `json:"maf_pay"`
  21725. MdtrtCertType string `json:"mdtrt_cert_type"`
  21726. HifobPay float64 `json:"hifob_pay"`
  21727. MdtrtID string `json:"mdtrt_id"`
  21728. MedType string `json:"med_type"`
  21729. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21730. MedinsSetlID string `json:"medins_setl_id"`
  21731. Naty string `json:"naty"`
  21732. OthPay float64 `json:"oth_pay"`
  21733. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21734. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21735. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21736. PsnCashPay float64 `json:"psn_cash_pay"`
  21737. PsnCertType string `json:"psn_cert_type"`
  21738. PsnName string `json:"psn_name"`
  21739. PsnNo string `json:"psn_no"`
  21740. PsnPartAmt float64 `json:"psn_part_amt"`
  21741. PsnType string `json:"psn_type"`
  21742. SetlID string `json:"setl_id"`
  21743. SetlTime int64 `json:"setl_time"`
  21744. } `json:"setlinfo"`
  21745. Setldetail interface{} `json:"setldetail"`
  21746. } `json:"output"`
  21747. RefmsgTime string `json:"refmsg_time"`
  21748. RespondTime string `json:"respond_time"`
  21749. Signtype interface{} `json:"signtype"`
  21750. WarnMsg interface{} `json:"warn_msg"`
  21751. }
  21752. type ResultSeven10265 struct {
  21753. Cainfo string `json:"cainfo"`
  21754. ErrMsg string `json:"err_msg"`
  21755. InfRefmsgid string `json:"inf_refmsgid"`
  21756. Infcode string `json:"infcode"`
  21757. Output struct {
  21758. Setlinfo struct {
  21759. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21760. AcctPay float64 `json:"acct_pay"`
  21761. ActPayDedc float64 `json:"act_pay_dedc"`
  21762. Age float64 `json:"age"`
  21763. Balc float64 `json:"balc"`
  21764. Certno string `json:"certno"`
  21765. ClrOptins string `json:"clr_optins"`
  21766. ClrType string `json:"clr_type"`
  21767. ClrWay string `json:"clr_way"`
  21768. CvlservFlag string `json:"cvlserv_flag"`
  21769. CvlservPay float64 `json:"cvlserv_pay"`
  21770. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21771. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21772. Gend string `json:"gend"`
  21773. HifesPay float64 `json:"hifes_pay"`
  21774. HifmiPay float64 `json:"hifmi_pay"`
  21775. HifpPay float64 `json:"hifp_pay"`
  21776. HospPartAmt float64 `json:"hosp_part_amt"`
  21777. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21778. Insutype string `json:"insutype"`
  21779. MafPay float64 `json:"maf_pay"`
  21780. MdtrtCertType string `json:"mdtrt_cert_type"`
  21781. HifobPay float64 `json:"hifob_pay"`
  21782. MdtrtID string `json:"mdtrt_id"`
  21783. MedType string `json:"med_type"`
  21784. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21785. MedinsSetlID string `json:"medins_setl_id"`
  21786. Naty string `json:"naty"`
  21787. OthPay float64 `json:"oth_pay"`
  21788. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21789. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21790. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21791. PsnCashPay float64 `json:"psn_cash_pay"`
  21792. PsnCertType string `json:"psn_cert_type"`
  21793. PsnName string `json:"psn_name"`
  21794. PsnNo string `json:"psn_no"`
  21795. PsnPartAmt float64 `json:"psn_part_amt"`
  21796. PsnType string `json:"psn_type"`
  21797. SetlID string `json:"setl_id"`
  21798. SetlTime string `json:"setl_time"`
  21799. } `json:"setlinfo"`
  21800. Setldetail interface{} `json:"setldetail"`
  21801. } `json:"output"`
  21802. RefmsgTime string `json:"refmsg_time"`
  21803. RespondTime string `json:"respond_time"`
  21804. Signtype interface{} `json:"signtype"`
  21805. WarnMsg interface{} `json:"warn_msg"`
  21806. }
  21807. type ResultSeven10265Two struct {
  21808. Cainfo string `json:"cainfo"`
  21809. ErrMsg string `json:"err_msg"`
  21810. InfRefmsgid string `json:"inf_refmsgid"`
  21811. Infcode string `json:"infcode"`
  21812. Output struct {
  21813. Setlinfo struct {
  21814. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21815. AcctPay float64 `json:"acct_pay"`
  21816. ActPayDedc float64 `json:"act_pay_dedc"`
  21817. Age float64 `json:"age"`
  21818. Balc float64 `json:"balc"`
  21819. Certno string `json:"certno"`
  21820. ClrOptins string `json:"clr_optins"`
  21821. ClrType string `json:"clr_type"`
  21822. ClrWay string `json:"clr_way"`
  21823. CvlservFlag string `json:"cvlserv_flag"`
  21824. CvlservPay float64 `json:"cvlserv_pay"`
  21825. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21826. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21827. Gend string `json:"gend"`
  21828. HifesPay float64 `json:"hifes_pay"`
  21829. HifmiPay float64 `json:"hifmi_pay"`
  21830. HifpPay float64 `json:"hifp_pay"`
  21831. HospPartAmt string `json:"hosp_part_amt"`
  21832. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21833. Insutype string `json:"insutype"`
  21834. MafPay float64 `json:"maf_pay"`
  21835. MdtrtCertType string `json:"mdtrt_cert_type"`
  21836. HifobPay float64 `json:"hifob_pay"`
  21837. MdtrtID string `json:"mdtrt_id"`
  21838. MedType string `json:"med_type"`
  21839. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21840. MedinsSetlID string `json:"medins_setl_id"`
  21841. Naty string `json:"naty"`
  21842. OthPay float64 `json:"oth_pay"`
  21843. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21844. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21845. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21846. PsnCashPay float64 `json:"psn_cash_pay"`
  21847. PsnCertType string `json:"psn_cert_type"`
  21848. PsnName string `json:"psn_name"`
  21849. PsnNo string `json:"psn_no"`
  21850. PsnPartAmt float64 `json:"psn_part_amt"`
  21851. PsnType string `json:"psn_type"`
  21852. SetlID string `json:"setl_id"`
  21853. SetlTime string `json:"setl_time"`
  21854. } `json:"setlinfo"`
  21855. Setldetail interface{} `json:"setldetail"`
  21856. } `json:"output"`
  21857. RefmsgTime string `json:"refmsg_time"`
  21858. RespondTime string `json:"respond_time"`
  21859. Signtype interface{} `json:"signtype"`
  21860. WarnMsg interface{} `json:"warn_msg"`
  21861. }
  21862. type GZResultSeven10265Two struct {
  21863. Cainfo string `json:"cainfo"`
  21864. ErrMsg string `json:"err_msg"`
  21865. InfRefmsgid string `json:"inf_refmsgid"`
  21866. Infcode int64 `json:"infcode"`
  21867. Output struct {
  21868. Setlinfo struct {
  21869. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21870. AcctPay float64 `json:"acct_pay"`
  21871. ActPayDedc float64 `json:"act_pay_dedc"`
  21872. Age float64 `json:"age"`
  21873. Balc float64 `json:"balc"`
  21874. Certno string `json:"certno"`
  21875. ClrOptins string `json:"clr_optins"`
  21876. ClrType string `json:"clr_type"`
  21877. ClrWay string `json:"clr_way"`
  21878. CvlservFlag string `json:"cvlserv_flag"`
  21879. CvlservPay float64 `json:"cvlserv_pay"`
  21880. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21881. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21882. Gend string `json:"gend"`
  21883. HifesPay float64 `json:"hifes_pay"`
  21884. HifmiPay float64 `json:"hifmi_pay"`
  21885. HifpPay float64 `json:"hifp_pay"`
  21886. HospPartAmt float64 `json:"hosp_part_amt"`
  21887. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21888. Insutype string `json:"insutype"`
  21889. MafPay float64 `json:"maf_pay"`
  21890. MdtrtCertType string `json:"mdtrt_cert_type"`
  21891. HifobPay float64 `json:"hifob_pay"`
  21892. MdtrtID string `json:"mdtrt_id"`
  21893. MedType string `json:"med_type"`
  21894. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21895. MedinsSetlID string `json:"medins_setl_id"`
  21896. Naty string `json:"naty"`
  21897. OthPay float64 `json:"oth_pay"`
  21898. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21899. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21900. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21901. PsnCashPay float64 `json:"psn_cash_pay"`
  21902. PsnCertType string `json:"psn_cert_type"`
  21903. PsnName string `json:"psn_name"`
  21904. PsnNo string `json:"psn_no"`
  21905. PsnPartAmt float64 `json:"psn_part_amt"`
  21906. PsnType string `json:"psn_type"`
  21907. SetlID string `json:"setl_id"`
  21908. SetlTime string `json:"setl_time"`
  21909. } `json:"setlinfo"`
  21910. Setldetail interface{} `json:"setldetail"`
  21911. } `json:"output"`
  21912. RefmsgTime string `json:"refmsg_time"`
  21913. RespondTime string `json:"respond_time"`
  21914. Signtype interface{} `json:"signtype"`
  21915. WarnMsg interface{} `json:"warn_msg"`
  21916. }
  21917. type ResultEight struct {
  21918. Cainfo string `json:"cainfo"`
  21919. ErrMsg string `json:"err_msg"`
  21920. InfRefmsgid string `json:"inf_refmsgid"`
  21921. Infcode int64 `json:"infcode"`
  21922. Output struct {
  21923. Stmtinfo struct {
  21924. SetlOptins string `json:"setl_optins"`
  21925. StmtRslt string `json:"stmt_rslt"`
  21926. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21927. } `json:"stmtinfo"`
  21928. } `json:"output"`
  21929. RefmsgTime string `json:"refmsg_time"`
  21930. RespondTime string `json:"respond_time"`
  21931. Signtype interface{} `json:"signtype"`
  21932. WarnMsg interface{} `json:"warn_msg"`
  21933. }
  21934. type ResultEightFor10188 struct {
  21935. Cainfo string `json:"cainfo"`
  21936. ErrMsg string `json:"err_msg"`
  21937. InfRefmsgid string `json:"inf_refmsgid"`
  21938. Infcode string `json:"infcode"`
  21939. Output struct {
  21940. Stmtinfo struct {
  21941. SetlOptins string `json:"setl_optins"`
  21942. StmtRslt string `json:"stmt_rslt"`
  21943. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21944. } `json:"stmtinfo"`
  21945. } `json:"output"`
  21946. RefmsgTime string `json:"refmsg_time"`
  21947. RespondTime string `json:"respond_time"`
  21948. Signtype interface{} `json:"signtype"`
  21949. WarnMsg interface{} `json:"warn_msg"`
  21950. }
  21951. type ResultNine struct {
  21952. Cainfo string `json:"cainfo"`
  21953. ErrMsg string `json:"err_msg"`
  21954. InfRefmsgid string `json:"inf_refmsgid"`
  21955. Infcode int64 `json:"infcode"`
  21956. Output struct {
  21957. FileQuryNo string `json:"file_qury_no"`
  21958. } `json:"output"`
  21959. RefmsgTime string `json:"refmsg_time"`
  21960. RespondTime string `json:"respond_time"`
  21961. Signtype interface{} `json:"signtype"`
  21962. WarnMsg interface{} `json:"warn_msg"`
  21963. }
  21964. type ResultTen struct {
  21965. Cainfo string `json:"cainfo"`
  21966. ErrMsg string `json:"err_msg"`
  21967. InfRefmsgid string `json:"inf_refmsgid"`
  21968. Infcode int64 `json:"infcode"`
  21969. Output struct {
  21970. Fileinfo struct {
  21971. DldEndtime string `json:"dld_endtime"`
  21972. FileQuryNo string `json:"file_qury_no"`
  21973. Filename string `json:"filename"`
  21974. } `json:"fileinfo"`
  21975. } `json:"output"`
  21976. RefmsgTime string `json:"refmsg_time"`
  21977. RespondTime string `json:"respond_time"`
  21978. Signtype interface{} `json:"signtype"`
  21979. WarnMsg interface{} `json:"warn_msg"`
  21980. }
  21981. type Result5262 struct {
  21982. ErrMsg string `json:"err_msg"`
  21983. InfRefmsgid string `json:"inf_refmsgid"`
  21984. Infcode int64 `json:"infcode"`
  21985. Output struct {
  21986. PageInfo struct {
  21987. Size int `json:"size"`
  21988. RecordCounts int `json:"record_counts"`
  21989. } `json:"page_info"`
  21990. Idetinfo []interface{} `json:"idetinfo"`
  21991. Result []struct {
  21992. SetlID string `json:"setl_id"`
  21993. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21994. MdtrtID string `json:"mdtrt_id"`
  21995. InitSetlID string `json:"init_setl_id,omitempty"`
  21996. PsnNo string `json:"psn_no"`
  21997. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21998. PsnName string `json:"psn_name"`
  21999. PsnCertType string `json:"psn_cert_type"`
  22000. Certno string `json:"certno"`
  22001. Gend string `json:"gend,omitempty"`
  22002. Naty string `json:"naty,omitempty"`
  22003. Brdy string `json:"brdy,omitempty"`
  22004. Age float64 `json:"age,omitempty"`
  22005. Insutype string `json:"insutype,omitempty"`
  22006. PsnType string `json:"psn_type"`
  22007. CvlservFlag string `json:"cvlserv_flag"`
  22008. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22009. SpPsnType string `json:"sp_psn_type,omitempty"`
  22010. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22011. ClctGrde string `json:"clct_grde,omitempty"`
  22012. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22013. NwbFlag string `json:"nwb_flag,omitempty"`
  22014. InsuAdmdvs string `json:"insu_admdvs"`
  22015. EmpNo string `json:"emp_no,omitempty"`
  22016. EmpName string `json:"emp_name,omitempty"`
  22017. EmpType string `json:"emp_type,omitempty"`
  22018. EconType string `json:"econ_type,omitempty"`
  22019. AfilIndu string `json:"afil_indu,omitempty"`
  22020. AfilRlts string `json:"afil_rlts,omitempty"`
  22021. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22022. PayLoc string `json:"pay_loc,omitempty"`
  22023. FixmedinsCode string `json:"fixmedins_code"`
  22024. FixmedinsName string `json:"fixmedins_name"`
  22025. HospLv string `json:"hosp_lv,omitempty"`
  22026. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22027. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22028. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22029. Begndate string `json:"begndate"`
  22030. Enddate string `json:"enddate"`
  22031. SetlTime string `json:"setl_time"`
  22032. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22033. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22034. MedType string `json:"med_type"`
  22035. SetlType string `json:"setl_type,omitempty"`
  22036. ClrType string `json:"clr_type,omitempty"`
  22037. ClrWay string `json:"clr_way,omitempty"`
  22038. PsnSetlway string `json:"psn_setlway,omitempty"`
  22039. ClrOptins string `json:"clr_optins,omitempty"`
  22040. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22041. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22042. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22043. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22044. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22045. DedcStd float64 `json:"dedc_std,omitempty"`
  22046. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22047. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22048. HifpPay float64 `json:"hifp_pay,omitempty"`
  22049. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22050. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22051. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22052. HifesPay float64 `json:"hifes_pay,omitempty"`
  22053. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22054. HifobPay float64 `json:"hifob_pay,omitempty"`
  22055. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22056. MafPay float64 `json:"maf_pay,omitempty"`
  22057. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22058. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22059. PsnPay float64 `json:"psn_pay,omitempty"`
  22060. AcctPay float64 `json:"acct_pay,omitempty"`
  22061. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22062. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22063. Balc float64 `json:"balc,omitempty"`
  22064. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22065. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22066. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22067. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22068. Year string `json:"year,omitempty"`
  22069. DiseNo string `json:"dise_no,omitempty"`
  22070. DiseName string `json:"dise_name,omitempty"`
  22071. Invono string `json:"invono,omitempty"`
  22072. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22073. ValiFlag string `json:"vali_flag,omitempty"`
  22074. Memo string `json:"memo,omitempty"`
  22075. Rid string `json:"rid"`
  22076. UpdtTime string `json:"updt_time,omitempty"`
  22077. CrterID string `json:"crter_id,omitempty"`
  22078. CrterName string `json:"crter_name,omitempty"`
  22079. CrteTime string `json:"crte_time,omitempty"`
  22080. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22081. OpterID string `json:"opter_id,omitempty"`
  22082. OpterName string `json:"opter_name,omitempty"`
  22083. OptTime string `json:"opt_time,omitempty"`
  22084. OptinsNo string `json:"optins_no,omitempty"`
  22085. PoolareaNo string `json:"poolarea_no,omitempty"`
  22086. } `json:"result"`
  22087. } `json:"output"`
  22088. RefmsgTime string `json:"refmsg_time"`
  22089. RespondTime string `json:"respond_time"`
  22090. Signtype interface{} `json:"signtype"`
  22091. WarnInfo interface{} `json:"warn_info"`
  22092. }
  22093. type Result5267 struct {
  22094. ErrMsg string `json:"err_msg"`
  22095. InfRefmsgid string `json:"inf_refmsgid"`
  22096. Infcode int64 `json:"infcode"`
  22097. Output struct {
  22098. PageInfo struct {
  22099. Size int `json:"size"`
  22100. RecordCounts int `json:"record_counts"`
  22101. } `json:"pageinfo"`
  22102. Result []struct {
  22103. SetlID string `json:"setl_id"`
  22104. ClrOptins string `json:"clr_optins"`
  22105. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22106. MdtrtID string `json:"mdtrt_id"`
  22107. InitSetlID string `json:"init_setl_id,omitempty"`
  22108. PsnNo string `json:"psn_no"`
  22109. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22110. PsnName string `json:"psn_name"`
  22111. PsnCertType string `json:"psn_cert_type"`
  22112. Certno string `json:"certno"`
  22113. Gend string `json:"gend,omitempty"`
  22114. Naty string `json:"naty,omitempty"`
  22115. Brdy string `json:"brdy,omitempty"`
  22116. Age float64 `json:"age,omitempty"`
  22117. Insutype string `json:"insutype,omitempty"`
  22118. PsnType string `json:"psn_type"`
  22119. CvlservFlag string `json:"cvlserv_flag"`
  22120. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22121. SpPsnType string `json:"sp_psn_type,omitempty"`
  22122. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22123. ClctGrde string `json:"clct_grde,omitempty"`
  22124. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22125. NwbFlag string `json:"nwb_flag,omitempty"`
  22126. InsuAdmdvs string `json:"insu_admdvs"`
  22127. EmpNo string `json:"emp_no,omitempty"`
  22128. EmpName string `json:"emp_name,omitempty"`
  22129. EmpType string `json:"emp_type,omitempty"`
  22130. EconType string `json:"econ_type,omitempty"`
  22131. AfilIndu string `json:"afil_indu,omitempty"`
  22132. AfilRlts string `json:"afil_rlts,omitempty"`
  22133. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22134. PayLoc string `json:"pay_loc,omitempty"`
  22135. FixmedinsCode string `json:"fixmedins_code"`
  22136. FixmedinsName string `json:"fixmedins_name"`
  22137. HospLv string `json:"hosp_lv,omitempty"`
  22138. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22139. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22140. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22141. Begndate string `json:"begndate,omitempty"`
  22142. Enddate string `json:"enddate,omitempty"`
  22143. SetlTime string `json:"setl_time,omitempty"`
  22144. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22145. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22146. MedType string `json:"med_type"`
  22147. SetlType string `json:"setl_type,omitempty"`
  22148. ClrType string `json:"clr_type,omitempty"`
  22149. ClrWay string `json:"clr_way,omitempty"`
  22150. PsnSetlway string `json:"psn_setlway,omitempty"`
  22151. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22152. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22153. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22154. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22155. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22156. DedcStd float64 `json:"dedc_std,omitempty"`
  22157. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22158. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22159. HifpPay float64 `json:"hifp_pay,omitempty"`
  22160. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22161. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22162. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22163. HifesPay float64 `json:"hifes_pay,omitempty"`
  22164. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22165. HifobPay float64 `json:"hifob_pay,omitempty"`
  22166. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22167. MafPay float64 `json:"maf_pay,omitempty"`
  22168. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22169. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22170. PsnPay float64 `json:"psn_pay,omitempty"`
  22171. AcctPay float64 `json:"acct_pay,omitempty"`
  22172. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22173. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22174. Balc float64 `json:"balc,omitempty"`
  22175. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22176. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22177. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22178. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22179. Year string `json:"year,omitempty"`
  22180. DiseNo string `json:"dise_no,omitempty"`
  22181. DiseName string `json:"dise_name,omitempty"`
  22182. Invono string `json:"invono,omitempty"`
  22183. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22184. Memo string `json:"memo,omitempty"`
  22185. UpdtTime string `json:"updt_time,omitempty"`
  22186. OpterID string `json:"opter_id,omitempty"`
  22187. OpterName string `json:"opter_name,omitempty"`
  22188. OptTime string `json:"opt_time,omitempty"`
  22189. OptinsNo string `json:"optins_no,omitempty"`
  22190. PoolareaNo string `json:"poolarea_no,omitempty"`
  22191. } `json:"result"`
  22192. } `json:"output"`
  22193. RefmsgTime string `json:"refmsg_time"`
  22194. RespondTime string `json:"respond_time"`
  22195. Signtype interface{} `json:"signtype"`
  22196. WarnInfo interface{} `json:"warn_info"`
  22197. }
  22198. // type Autogenerated struct {
  22199. // Output struct {
  22200. // Setlinfo struct {
  22201. // SetlTime string `json:"setl_time"`
  22202. // CvlservPay float64 `json:"cvlserv_pay"`
  22203. // Year string `json:"year"`
  22204. // MedType string `json:"med_type"`
  22205. // PsnPay float64 `json:"psn_pay"`
  22206. // OpterID string `json:"opter_id"`
  22207. // Begndate string `json:"begndate"`
  22208. // FlxempeFlag string `json:"flxempe_flag"`
  22209. // HifmiPay float64 `json:"hifmi_pay"`
  22210. // PsnNo string `json:"psn_no"`
  22211. // ActPayDedc float64 `json:"act_pay_dedc"`
  22212. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22213. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22214. // ClrWay string `json:"clr_way"`
  22215. // OthPay float64 `json:"oth_pay"`
  22216. // Gend string `json:"gend"`
  22217. // MdtrtID string `json:"mdtrt_id"`
  22218. // AcctPay float64 `json:"acct_pay"`
  22219. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22220. // Insutype string `json:"insutype"`
  22221. // Invono interface{} `json:"invono"`
  22222. // Enddate string `json:"enddate"`
  22223. // CashPayamt float64 `json:"cash_payamt"`
  22224. // PsnType string `json:"psn_type"`
  22225. // FixmedinsName string `json:"fixmedins_name"`
  22226. // HifpPay float64 `json:"hifp_pay"`
  22227. // NewFlag interface{} `json:"new_flag"`
  22228. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22229. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22230. // PayLoc string `json:"pay_loc"`
  22231. // ClrType string `json:"clr_type"`
  22232. // RefdSetlFlag string `json:"refd_setl_flag"`
  22233. // CvlservFlag string `json:"cvlserv_flag"`
  22234. // EmpName string `json:"emp_name"`
  22235. // Brdy string `json:"brdy"`
  22236. // Naty string `json:"naty"`
  22237. // Certno string `json:"certno"`
  22238. // DiseCode string `json:"dise_code"`
  22239. // FixmedinsCode string `json:"fixmedins_code"`
  22240. // DedcHospLv string `json:"dedc_hosp_lv"`
  22241. // OpterName string `json:"opter_name"`
  22242. // Balc float64 `json:"balc"`
  22243. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22244. // PsnCertType string `json:"psn_cert_type"`
  22245. // HifobPay float64 `json:"hifob_pay"`
  22246. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22247. // HifesPay float64 `json:"hifes_pay"`
  22248. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22249. // OptTime string `json:"opt_time"`
  22250. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22251. // SetlID string `json:"setl_id"`
  22252. // MafPay float64 `json:"maf_pay"`
  22253. // PsnName string `json:"psn_name"`
  22254. // InsuOptins interface{} `json:"insu_optins"`
  22255. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22256. // ClrOptins string `json:"clr_optins"`
  22257. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22258. // DiseName string `json:"dise_name"`
  22259. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22260. // Age float64 `json:"age"`
  22261. // DtrtCertType string `json:"dtrt_cert_type"`
  22262. // HospLv string `json:"hosp_lv"`
  22263. // } `json:"setlinfo"`
  22264. // Setldetail []struct {
  22265. // FundPayType string `json:"fund_pay_type"`
  22266. // FundPayamt float64 `json:"fund_payamt"`
  22267. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22268. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22269. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22270. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22271. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22272. // } `json:"setldetail"`
  22273. // } `json:"output"`
  22274. // Infcode int `json:"infcode"`
  22275. // WarnMsg interface{} `json:"warn_msg"`
  22276. // Cainfo interface{} `json:"cainfo"`
  22277. // ErrMsg interface{} `json:"err_msg"`
  22278. // RefmsgTime string `json:"refmsg_time"`
  22279. // Signtype interface{} `json:"signtype"`
  22280. // RespondTime string `json:"respond_time"`
  22281. // InfRefmsgid string `json:"inf_refmsgid"`
  22282. // }
  22283. type Result002 struct {
  22284. Cainfo interface{} `json:"cainfo"`
  22285. ErrMsg string `json:"err_msg"`
  22286. InfRefmsgid string `json:"inf_refmsgid"`
  22287. Infcode int64 `json:"infcode"`
  22288. Output struct {
  22289. RxFile string `json:"rx_file"`
  22290. SignDigest string `json:"sign_digest"`
  22291. SignCertSn string `json:"sign_cert_sn"`
  22292. SignCertDn string `json:"sign_cert_dn"`
  22293. } `json:"output"`
  22294. RefmsgTime string `json:"refmsg_time"`
  22295. RespondTime string `json:"respond_time"`
  22296. Signtype interface{} `json:"signtype"`
  22297. WarnMsg interface{} `json:"warn_msg"`
  22298. }
  22299. type Result003 struct {
  22300. Cainfo interface{} `json:"cainfo"`
  22301. ErrMsg string `json:"err_msg"`
  22302. InfRefmsgid string `json:"inf_refmsgid"`
  22303. Infcode int64 `json:"infcode"`
  22304. Output struct {
  22305. HiRxno string `json:"hi_rxno"`
  22306. RxStasCodg string `json:"rx_stas_codg"`
  22307. RxStasName string `json:"rx_stas_name"`
  22308. } `json:"output"`
  22309. RefmsgTime string `json:"refmsg_time"`
  22310. RespondTime string `json:"respond_time"`
  22311. Signtype interface{} `json:"signtype"`
  22312. WarnMsg interface{} `json:"warn_msg"`
  22313. }
  22314. type ResultEleven struct {
  22315. Cainfo string `json:"cainfo"`
  22316. ErrMsg string `json:"err_msg"`
  22317. InfRefmsgid string `json:"inf_refmsgid"`
  22318. Infcode int64 `json:"infcode"`
  22319. Output struct {
  22320. Setlinfo struct {
  22321. SetlTime string `json:"setl_time"`
  22322. CvlservPay float64 `json:"cvlserv_pay"`
  22323. Year string `json:"year"`
  22324. MedType string `json:"med_type"`
  22325. PsnPay float64 `json:"psn_pay"`
  22326. OpterID string `json:"opter_id"`
  22327. Begndate string `json:"begndate"`
  22328. FlxempeFlag string `json:"flxempe_flag"`
  22329. HifmiPay float64 `json:"hifmi_pay"`
  22330. PsnNo string `json:"psn_no"`
  22331. ActPayDedc float64 `json:"act_pay_dedc"`
  22332. MedinsSetlID interface{} `json:"medins_setl_id"`
  22333. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22334. ClrWay string `json:"clr_way"`
  22335. OthPay float64 `json:"oth_pay"`
  22336. Gend string `json:"gend"`
  22337. MdtrtID string `json:"mdtrt_id"`
  22338. AcctPay float64 `json:"acct_pay"`
  22339. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22340. Insutype string `json:"insutype"`
  22341. Invono interface{} `json:"invono"`
  22342. Enddate string `json:"enddate"`
  22343. CashPayamt float64 `json:"cash_payamt"`
  22344. PsnType string `json:"psn_type"`
  22345. FixmedinsName string `json:"fixmedins_name"`
  22346. HifpPay float64 `json:"hifp_pay"`
  22347. NewFlag interface{} `json:"new_flag"`
  22348. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22349. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22350. PayLoc string `json:"pay_loc"`
  22351. ClrType string `json:"clr_type"`
  22352. RefdSetlFlag string `json:"refd_setl_flag"`
  22353. CvlservFlag string `json:"cvlserv_flag"`
  22354. EmpName string `json:"emp_name"`
  22355. Brdy string `json:"brdy"`
  22356. Naty string `json:"naty"`
  22357. Certno string `json:"certno"`
  22358. DiseCode string `json:"dise_code"`
  22359. FixmedinsCode string `json:"fixmedins_code"`
  22360. DedcHospLv string `json:"dedc_hosp_lv"`
  22361. OpterName string `json:"opter_name"`
  22362. Balc float64 `json:"balc"`
  22363. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22364. PsnCertType string `json:"psn_cert_type"`
  22365. HifobPay float64 `json:"hifob_pay"`
  22366. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22367. HifesPay float64 `json:"hifes_pay"`
  22368. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22369. OptTime string `json:"opt_time"`
  22370. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22371. SetlID string `json:"setl_id"`
  22372. MafPay float64 `json:"maf_pay"`
  22373. PsnName string `json:"psn_name"`
  22374. InsuOptins interface{} `json:"insu_optins"`
  22375. PrefFundPay interface{} `json:"pref_fund_pay"`
  22376. ClrOptins string `json:"clr_optins"`
  22377. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22378. DiseName string `json:"dise_name"`
  22379. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22380. Age float64 `json:"age"`
  22381. DtrtCertType string `json:"dtrt_cert_type"`
  22382. HospLv string `json:"hosp_lv"`
  22383. PsnCashPay float64 `json:"psn_cash_pay"`
  22384. } `json:"setlinfo"`
  22385. } `json:"output"`
  22386. RefmsgTime string `json:"refmsg_time"`
  22387. RespondTime string `json:"respond_time"`
  22388. Signtype interface{} `json:"signtype"`
  22389. WarnMsg interface{} `json:"warn_msg"`
  22390. }
  22391. type ResultElevenah struct {
  22392. Cainfo string `json:"cainfo"`
  22393. ErrMsg string `json:"err_msg"`
  22394. InfRefmsgid string `json:"inf_refmsgid"`
  22395. Infcode int64 `json:"infcode"`
  22396. Output struct {
  22397. Setlinfo struct {
  22398. SetlTime int64 `json:"setl_time"`
  22399. CvlservPay float64 `json:"cvlserv_pay"`
  22400. Year string `json:"year"`
  22401. MedType string `json:"med_type"`
  22402. PsnPay float64 `json:"psn_pay"`
  22403. OpterID string `json:"opter_id"`
  22404. Begndate int64 `json:"begndate"`
  22405. FlxempeFlag string `json:"flxempe_flag"`
  22406. HifmiPay float64 `json:"hifmi_pay"`
  22407. PsnNo string `json:"psn_no"`
  22408. ActPayDedc float64 `json:"act_pay_dedc"`
  22409. MedinsSetlID interface{} `json:"medins_setl_id"`
  22410. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22411. ClrWay string `json:"clr_way"`
  22412. OthPay float64 `json:"oth_pay"`
  22413. Gend string `json:"gend"`
  22414. MdtrtID string `json:"mdtrt_id"`
  22415. AcctPay float64 `json:"acct_pay"`
  22416. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22417. Insutype string `json:"insutype"`
  22418. Invono interface{} `json:"invono"`
  22419. Enddate int64 `json:"enddate"`
  22420. CashPayamt float64 `json:"cash_payamt"`
  22421. PsnType string `json:"psn_type"`
  22422. FixmedinsName string `json:"fixmedins_name"`
  22423. HifpPay float64 `json:"hifp_pay"`
  22424. NewFlag interface{} `json:"new_flag"`
  22425. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22426. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22427. PayLoc string `json:"pay_loc"`
  22428. ClrType string `json:"clr_type"`
  22429. RefdSetlFlag string `json:"refd_setl_flag"`
  22430. CvlservFlag string `json:"cvlserv_flag"`
  22431. EmpName string `json:"emp_name"`
  22432. Brdy int64 `json:"brdy"`
  22433. Naty string `json:"naty"`
  22434. Certno string `json:"certno"`
  22435. DiseCode string `json:"dise_code"`
  22436. FixmedinsCode string `json:"fixmedins_code"`
  22437. DedcHospLv string `json:"dedc_hosp_lv"`
  22438. OpterName string `json:"opter_name"`
  22439. Balc float64 `json:"balc"`
  22440. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22441. PsnCertType string `json:"psn_cert_type"`
  22442. HifobPay float64 `json:"hifob_pay"`
  22443. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22444. HifesPay float64 `json:"hifes_pay"`
  22445. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22446. OptTime int64 `json:"opt_time"`
  22447. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22448. SetlID string `json:"setl_id"`
  22449. MafPay float64 `json:"maf_pay"`
  22450. PsnName string `json:"psn_name"`
  22451. InsuOptins interface{} `json:"insu_optins"`
  22452. PrefFundPay interface{} `json:"pref_fund_pay"`
  22453. ClrOptins string `json:"clr_optins"`
  22454. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22455. DiseName string `json:"dise_name"`
  22456. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22457. Age float64 `json:"age"`
  22458. DtrtCertType string `json:"dtrt_cert_type"`
  22459. HospLv string `json:"hosp_lv"`
  22460. PsnCashPay float64 `json:"psn_cash_pay"`
  22461. } `json:"setlinfo"`
  22462. } `json:"output"`
  22463. RefmsgTime string `json:"refmsg_time"`
  22464. RespondTime string `json:"respond_time"`
  22465. Signtype interface{} `json:"signtype"`
  22466. WarnMsg interface{} `json:"warn_msg"`
  22467. }
  22468. type ResultEleven10265 struct {
  22469. Cainfo string `json:"cainfo"`
  22470. ErrMsg string `json:"err_msg"`
  22471. InfRefmsgid string `json:"inf_refmsgid"`
  22472. Infcode string `json:"infcode"`
  22473. Output struct {
  22474. Setlinfo struct {
  22475. SetlTime string `json:"setl_time"`
  22476. CvlservPay float64 `json:"cvlserv_pay"`
  22477. Year string `json:"year"`
  22478. MedType string `json:"med_type"`
  22479. PsnPay float64 `json:"psn_pay"`
  22480. OpterID string `json:"opter_id"`
  22481. Begndate string `json:"begndate"`
  22482. FlxempeFlag string `json:"flxempe_flag"`
  22483. HifmiPay float64 `json:"hifmi_pay"`
  22484. PsnNo string `json:"psn_no"`
  22485. ActPayDedc float64 `json:"act_pay_dedc"`
  22486. MedinsSetlID interface{} `json:"medins_setl_id"`
  22487. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22488. ClrWay string `json:"clr_way"`
  22489. OthPay float64 `json:"oth_pay"`
  22490. Gend string `json:"gend"`
  22491. MdtrtID string `json:"mdtrt_id"`
  22492. AcctPay float64 `json:"acct_pay"`
  22493. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22494. Insutype string `json:"insutype"`
  22495. Invono interface{} `json:"invono"`
  22496. Enddate string `json:"enddate"`
  22497. CashPayamt float64 `json:"cash_payamt"`
  22498. PsnType string `json:"psn_type"`
  22499. FixmedinsName string `json:"fixmedins_name"`
  22500. HifpPay float64 `json:"hifp_pay"`
  22501. NewFlag interface{} `json:"new_flag"`
  22502. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22503. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22504. PayLoc string `json:"pay_loc"`
  22505. ClrType string `json:"clr_type"`
  22506. RefdSetlFlag string `json:"refd_setl_flag"`
  22507. CvlservFlag string `json:"cvlserv_flag"`
  22508. EmpName string `json:"emp_name"`
  22509. Brdy string `json:"brdy"`
  22510. Naty string `json:"naty"`
  22511. Certno string `json:"certno"`
  22512. DiseCode string `json:"dise_code"`
  22513. FixmedinsCode string `json:"fixmedins_code"`
  22514. DedcHospLv string `json:"dedc_hosp_lv"`
  22515. OpterName string `json:"opter_name"`
  22516. Balc float64 `json:"balc"`
  22517. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22518. PsnCertType string `json:"psn_cert_type"`
  22519. HifobPay float64 `json:"hifob_pay"`
  22520. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22521. HifesPay float64 `json:"hifes_pay"`
  22522. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22523. OptTime string `json:"opt_time"`
  22524. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22525. SetlID string `json:"setl_id"`
  22526. MafPay float64 `json:"maf_pay"`
  22527. PsnName string `json:"psn_name"`
  22528. InsuOptins interface{} `json:"insu_optins"`
  22529. PrefFundPay interface{} `json:"pref_fund_pay"`
  22530. ClrOptins string `json:"clr_optins"`
  22531. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22532. DiseName string `json:"dise_name"`
  22533. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22534. Age float64 `json:"age"`
  22535. DtrtCertType string `json:"dtrt_cert_type"`
  22536. HospLv string `json:"hosp_lv"`
  22537. PsnCashPay float64 `json:"psn_cash_pay"`
  22538. } `json:"setlinfo"`
  22539. } `json:"output"`
  22540. RefmsgTime string `json:"refmsg_time"`
  22541. RespondTime string `json:"respond_time"`
  22542. Signtype interface{} `json:"signtype"`
  22543. WarnMsg interface{} `json:"warn_msg"`
  22544. }
  22545. type ResultTwelve struct {
  22546. Cainfo string `json:"cainfo"`
  22547. ErrMsg string `json:"err_msg"`
  22548. InfRefmsgid string `json:"inf_refmsgid"`
  22549. Infcode int64 `json:"infcode"`
  22550. Output struct {
  22551. MdtrtId string `json:"mdtrt_id"`
  22552. ChrgBchno string `json:"chrg_bchno"`
  22553. PsnNo string `json:"psn_no"`
  22554. } `json:"output"`
  22555. RefmsgTime string `json:"refmsg_time"`
  22556. RespondTime string `json:"respond_time"`
  22557. Signtype interface{} `json:"signtype"`
  22558. WarnMsg interface{} `json:"warn_msg"`
  22559. }
  22560. type ResultThirteen struct {
  22561. ErrMsg string `json:"err_msg"`
  22562. InfRefmsgid string `json:"inf_refmsgid"`
  22563. Infcode int64 `json:"infcode"`
  22564. Output struct {
  22565. Result struct {
  22566. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22567. } `json:"result"`
  22568. } `json:"output"`
  22569. RefmsgTime string `json:"refmsg_time"`
  22570. RespondTime string `json:"respond_time"`
  22571. Signtype interface{} `json:"signtype"`
  22572. WarnInfo interface{} `json:"warn_info"`
  22573. }
  22574. type ResultThirteen10265 struct {
  22575. ErrMsg string `json:"err_msg"`
  22576. InfRefmsgid string `json:"inf_refmsgid"`
  22577. Infcode string `json:"infcode"`
  22578. Output struct {
  22579. Result struct {
  22580. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22581. } `json:"result"`
  22582. } `json:"output"`
  22583. RefmsgTime string `json:"refmsg_time"`
  22584. RespondTime string `json:"respond_time"`
  22585. Signtype interface{} `json:"signtype"`
  22586. WarnInfo interface{} `json:"warn_info"`
  22587. }
  22588. type ResultFourteen struct {
  22589. ErrMsg string `json:"err_msg"`
  22590. InfRefmsgid string `json:"inf_refmsgid"`
  22591. Infcode int64 `json:"infcode"`
  22592. Output struct {
  22593. } `json:"output"`
  22594. RefmsgTime string `json:"refmsg_time"`
  22595. RespondTime string `json:"respond_time"`
  22596. Signtype interface{} `json:"signtype"`
  22597. WarnInfo interface{} `json:"warn_info"`
  22598. }
  22599. type ResultCFYLJG001 struct {
  22600. ErrMsg string `json:"err_msg"`
  22601. InfRefmsgid string `json:"inf_refmsgid"`
  22602. Infcode int64 `json:"infcode"`
  22603. Output struct {
  22604. RxTraceCode string `json:"rx_trace_code"`
  22605. HiRxno string `json:"hi_rxno"`
  22606. } `json:"output"`
  22607. RefmsgTime string `json:"refmsg_time"`
  22608. RespondTime string `json:"respond_time"`
  22609. Signtype interface{} `json:"signtype"`
  22610. WarnInfo interface{} `json:"warn_info"`
  22611. }
  22612. type ResultCFYLJG007 struct {
  22613. ErrMsg string `json:"err_msg"`
  22614. InfRefmsgid string `json:"inf_refmsgid"`
  22615. Infcode int64 `json:"infcode"`
  22616. Output struct {
  22617. HiRxno string `json:"hi_rxno"`
  22618. RxStasName string `json:"rx_stas_name"`
  22619. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22620. Seltdelts []interface{} `json:"seltdelts"`
  22621. RxUsedStasName string `json:"rx_used_stas_name"`
  22622. RxStasCodg string `json:"rx_stas_codg"`
  22623. } `json:"output"`
  22624. RefmsgTime string `json:"refmsg_time"`
  22625. RespondTime string `json:"respond_time"`
  22626. Signtype interface{} `json:"signtype"`
  22627. WarnInfo interface{} `json:"warn_info"`
  22628. }
  22629. type ResultCFYLJG002 struct {
  22630. ErrMsg string `json:"err_msg"`
  22631. InfRefmsgid string `json:"inf_refmsgid"`
  22632. Infcode int64 `json:"infcode"`
  22633. Output struct {
  22634. RxFile string `json:"rx_file"`
  22635. SignDigest string `json:"sign_digest"`
  22636. SignCertSn string `json:"sign_cert_sn"`
  22637. SignCertDn string `json:"sign_cert_dn"`
  22638. } `json:"output"`
  22639. RefmsgTime string `json:"refmsg_time"`
  22640. RespondTime string `json:"respond_time"`
  22641. Signtype interface{} `json:"signtype"`
  22642. WarnInfo interface{} `json:"warn_info"`
  22643. }
  22644. type ResultCFYLJG003 struct {
  22645. ErrMsg string `json:"err_msg"`
  22646. InfRefmsgid string `json:"inf_refmsgid"`
  22647. Infcode int64 `json:"infcode"`
  22648. Output struct {
  22649. HiRxno string `json:"hi_rxno"`
  22650. RxStasCodg string `json:"rx_stas_codg"`
  22651. RxStasName string `json:"rx_stas_name"`
  22652. } `json:"output"`
  22653. RefmsgTime string `json:"refmsg_time"`
  22654. RespondTime string `json:"respond_time"`
  22655. Signtype interface{} `json:"signtype"`
  22656. WarnInfo interface{} `json:"warn_info"`
  22657. }
  22658. type ResultCFYLJG004 struct {
  22659. ErrMsg string `json:"err_msg"`
  22660. InfRefmsgid string `json:"inf_refmsgid"`
  22661. Infcode int64 `json:"infcode"`
  22662. Output struct {
  22663. HiRxno string `json:"hi_rxno"`
  22664. RxStasCodg string `json:"rx_stas_codg"`
  22665. RxStasName string `json:"rx_stas_name"`
  22666. } `json:"output"`
  22667. RefmsgTime string `json:"refmsg_time"`
  22668. RespondTime string `json:"respond_time"`
  22669. Signtype interface{} `json:"signtype"`
  22670. WarnInfo interface{} `json:"warn_info"`
  22671. }
  22672. type ResultCFYLJG008 struct {
  22673. ErrMsg string `json:"err_msg"`
  22674. InfRefmsgid string `json:"inf_refmsgid"`
  22675. Infcode int64 `json:"infcode"`
  22676. Output struct {
  22677. PoolareaNo string `json:"poolareaNo"`
  22678. AdmdvsName string `json:"admdvsName"`
  22679. Count string `json:"count"`
  22680. } `json:"output"`
  22681. RefmsgTime string `json:"refmsg_time"`
  22682. RespondTime string `json:"respond_time"`
  22683. Signtype interface{} `json:"signtype"`
  22684. WarnInfo interface{} `json:"warn_info"`
  22685. }
  22686. type ResultCFYLJG005 struct {
  22687. ErrMsg string `json:"err_msg"`
  22688. InfRefmsgid string `json:"inf_refmsgid"`
  22689. Infcode int64 `json:"infcode"`
  22690. Output struct {
  22691. HiRxNo string `json:"hi_rxno"`
  22692. FixMedinsCode string `json:"fixmedins_code"`
  22693. FixMedinsName string `json:"fixmedins_name"`
  22694. RxStasCodg string `json:"rx_stas_codg"`
  22695. RxStasName string `json:"rx_stas_name"`
  22696. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22697. RxUserdStasName string `json:"rx_userd_stas_name"`
  22698. PrscTime string `json:"prsc_time"`
  22699. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22700. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22701. RxUsedWayName string `json:"rx_used_way_name"`
  22702. RxFrquCodg string `json:"rx_frqu_codg"`
  22703. RxFrquName string `json:"rx_frqu_name"`
  22704. RxDosunt string `json:"rx_dosunt"`
  22705. RxDoscnt float64 `json:"rx_doscnt"`
  22706. RxDrordDscr string `json:"rx_drord_dscr"`
  22707. ValiDays int64 `json:"vali_days"`
  22708. ValiEndTime string `json:"vali_end_time"`
  22709. ReptFlag string `json:"rept_flag"`
  22710. MaxReptCnt int64 `json:"max_rept_cnt"`
  22711. ReptdCnt int64 `json:"reptd_cnt"`
  22712. MinInrvDays int64 `json:"min_inrv_days"`
  22713. RxTypeCode string `json:"rx_type_code"`
  22714. RxTypeName string `json:"rx_type_name"`
  22715. LongRxFlag string `json:"long_rx_flag"`
  22716. RxDetlList []struct {
  22717. MedListCodg string `json:"med_list_codg"`
  22718. MedinsListCodg string `json:"medins_list_codg"`
  22719. HospPrepFlag string `json:"hosp_prep_flag"`
  22720. RxItemTypeCode string `json:"rx_item_type_code"`
  22721. RxItemTypeName string `json:"rx_item_type_name"`
  22722. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22723. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22724. TcmHerbFoote string `json:"tcmherb_foote"`
  22725. MednTypeCode string `json:"medn_type_code"`
  22726. MednTypeName string `json:"medn_type_name"`
  22727. MainMedcFlag string `json:"main_medc_flag"`
  22728. UrgtFlag string `json:"urgt_flag"`
  22729. BasMednFlag string `json:"bas_medn_flag"`
  22730. ImpDrugFlag string `json:"imp_drug_flag"`
  22731. ProdBarc string `json:"prod_barc"`
  22732. DrugProdname string `json:"drug_prodname"`
  22733. GennameCodg string `json:"genname_codg"`
  22734. DrugGenname string `json:"drug_genname"`
  22735. DrugDosform string `json:"drug_dosform"`
  22736. DrugSpec string `json:"drug_spec"`
  22737. PrdrName string `json:"prdr_name"`
  22738. MedcWayCodg string `json:"medc_way_codg"`
  22739. MedcWayDscr string `json:"medc_way_dscr"`
  22740. MedcBegntime string `json:"medc_begntime"`
  22741. MedcEndtime string `json:"medc_endtime"`
  22742. MedcDays float64 `json:"medc_days"`
  22743. DrugPric float64 `json:"drug_pric"`
  22744. DrugSumamt float64 `json:"drug_sumamt"`
  22745. DrugCnt float64 `json:"drug_cnt"`
  22746. DrugDosunt string `json:"drug_dosunt"`
  22747. SinDoscnt float64 `json:"sin_doscnt"`
  22748. SinDosunt string `json:"sin_dosunt"`
  22749. UsedFrquCodg string `json:"used_frqu_codg"`
  22750. UsedFrquName string `json:"used_frqu_name"`
  22751. DrugTotlcnt string `json:"drug_totlcnt"`
  22752. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22753. DiseCodg string `json:"dise_codg"`
  22754. HospApprFlag string `json:"hosp_appr_flag"`
  22755. } `json:"rx_detl_list"`
  22756. RxOtpinfo struct {
  22757. MedType string `json:"med_type"`
  22758. IptOtpNo string `json:"ipt_otp_no"`
  22759. OtpIptFlag string `json:"otp_ipt_flag"`
  22760. PatnName string `json:"patn_name"`
  22761. PatnAge float64 `json:"patn_age"`
  22762. PatnHgt float64 `json:"patn_hgt"`
  22763. PatnWt float64 `json:"patn_wt"`
  22764. Gend string `json:"gend"`
  22765. GesoVal float64 `json:"geso_val"`
  22766. NwbFlag string `json:"nwb_flag"`
  22767. NwbAge string `json:"nwb_age"`
  22768. SuckPrdFlag string `json:"suck_prd_flag"`
  22769. AlgsHis string `json:"algs_his"`
  22770. Insutype string `json:"insutype"`
  22771. PrscDeptName string `json:"prsc_dept_name"`
  22772. PrscDrName string `json:"prsc_dr_name"`
  22773. PharName string `json:"phar_name"`
  22774. PharChkTime string `json:"phar_chk_time"`
  22775. MdtrtTime string `json:"mdtrt_time"`
  22776. DiseCodg string `json:"dise_codg"`
  22777. DiseName string `json:"dise_name"`
  22778. SpDiseFlag string `json:"sp_dise_flag"`
  22779. MaindiagCode string `json:"maindiag_code"`
  22780. MaindiagName string `json:"maindiag_name"`
  22781. DiseCondDscr string `json:"dise_cond_dscr"`
  22782. FstdiagFlag string `json:"fstdiag_flag"`
  22783. } `json:"rx_otpinfo"`
  22784. RxDiseList []struct {
  22785. DiagType string `json:"diag_type"`
  22786. MaindiagFlag string `json:"maindiag_flag"`
  22787. DiagSrtNo string `json:"diag_srt_no"`
  22788. DiagCode string `json:"diag_code"`
  22789. DiagName string `json:"diag_name"`
  22790. DiagDept string `json:"diag_dept"`
  22791. DiagDrNo string `json:"diag_dr_no"`
  22792. DiagDrName string `json:"diag_dr_name"`
  22793. DiagTime string `json:"diag_time"`
  22794. TcmDiseCode string `json:"tcm_dise_code"`
  22795. TcmDiseName string `json:"tcm_dise_name"`
  22796. TcmSympCode string `json:"tcmsymp_code"`
  22797. TcmSymp string `json:"tcmsymp"`
  22798. } `json:"rx_dise_list"`
  22799. } `json:"output"`
  22800. RefmsgTime string `json:"refmsg_time"`
  22801. RespondTime string `json:"respond_time"`
  22802. Signtype interface{} `json:"signtype"`
  22803. WarnInfo interface{} `json:"warn_info"`
  22804. }
  22805. type ResultCFYLJG006 struct {
  22806. ErrMsg string `json:"err_msg"`
  22807. InfRefmsgid string `json:"inf_refmsgid"`
  22808. Infcode int64 `json:"infcode"`
  22809. Output struct {
  22810. HiRxNo string `json:"hi_rxno"`
  22811. PharCode string `json:"phar_code"`
  22812. PharName string `json:"phar_name"`
  22813. RxChkOpnn string `json:"rx_chk_opnn"`
  22814. RxChkTime string `json:"rx_chk_time"`
  22815. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22816. RxChkStasName string `json:"rx_chk_stas_name"`
  22817. RxStasCodg string `json:"rx_stas_codg"`
  22818. RxStasName string `json:"rx_stas_name"`
  22819. } `json:"output"`
  22820. RefmsgTime string `json:"refmsg_time"`
  22821. RespondTime string `json:"respond_time"`
  22822. Signtype interface{} `json:"signtype"`
  22823. WarnInfo interface{} `json:"warn_info"`
  22824. }
  22825. type ResultFourteen10265 struct {
  22826. ErrMsg string `json:"err_msg"`
  22827. InfRefmsgid string `json:"inf_refmsgid"`
  22828. Infcode string `json:"infcode"`
  22829. Output struct {
  22830. } `json:"output"`
  22831. RefmsgTime string `json:"refmsg_time"`
  22832. RespondTime string `json:"respond_time"`
  22833. Signtype interface{} `json:"signtype"`
  22834. WarnInfo interface{} `json:"warn_info"`
  22835. }
  22836. type ResultSixteen struct {
  22837. Cainfo string `json:"cainfo"`
  22838. ErrMsg string `json:"err_msg"`
  22839. InfRefmsgid string `json:"inf_refmsgid"`
  22840. Infcode int64 `json:"infcode"`
  22841. Output struct {
  22842. Setlinfo struct {
  22843. MdtrtID string `json:"mdtrt_id"`
  22844. SetlID string `json:"setl_id"`
  22845. ClrOptins string `json:"clr_optins"`
  22846. SetlTime string `json:"setl_time"`
  22847. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22848. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22849. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22850. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22851. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22852. ActPayDedc float64 `json:"act_pay_dedc"`
  22853. HifpPay float64 `json:"hifp_pay"`
  22854. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22855. Lfpay float64 `json:"selfpay"`
  22856. CvlservPay float64 `json:"cvlserv_pay"`
  22857. HifesPay float64 `json:"hifes_pay"`
  22858. HifmiPay float64 `json:"hifmi_pay"`
  22859. HifobPay float64 `json:"hifob_pay"`
  22860. MafPay float64 `json:"maf_pay"`
  22861. OthPay float64 `json:"oth_pay"`
  22862. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22863. PsnPartAmt float64 `json:"psn_part_amt"`
  22864. AcctPay float64 `json:"acct_pay"`
  22865. Balc float64 `json:"balc"`
  22866. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22867. HospPartAmt float64 `json:"hosp_part_amt"`
  22868. MedinsSetlID string `json:"medins_setl_id"`
  22869. PdnCashPay string `json:"pdn_cash_pay"`
  22870. } `json:"setlinfo"`
  22871. } `json:"output"`
  22872. RefmsgTime string `json:"refmsg_time"`
  22873. RespondTime string `json:"respond_time"`
  22874. Signtype interface{} `json:"signtype"`
  22875. WarnMsg interface{} `json:"warn_msg"`
  22876. }
  22877. type ResultSixteen10265 struct {
  22878. Cainfo string `json:"cainfo"`
  22879. ErrMsg string `json:"err_msg"`
  22880. InfRefmsgid string `json:"inf_refmsgid"`
  22881. Infcode string `json:"infcode"`
  22882. Output struct {
  22883. Setlinfo struct {
  22884. MdtrtID string `json:"mdtrt_id"`
  22885. SetlID string `json:"setl_id"`
  22886. ClrOptins string `json:"clr_optins"`
  22887. SetlTime string `json:"setl_time"`
  22888. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22889. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22890. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22891. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22892. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22893. ActPayDedc float64 `json:"act_pay_dedc"`
  22894. HifpPay float64 `json:"hifp_pay"`
  22895. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22896. Lfpay float64 `json:"selfpay"`
  22897. CvlservPay float64 `json:"cvlserv_pay"`
  22898. HifesPay float64 `json:"hifes_pay"`
  22899. HifmiPay float64 `json:"hifmi_pay"`
  22900. HifobPay float64 `json:"hifob_pay"`
  22901. MafPay float64 `json:"maf_pay"`
  22902. OthPay float64 `json:"oth_pay"`
  22903. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22904. PsnPartAmt float64 `json:"psn_part_amt"`
  22905. AcctPay float64 `json:"acct_pay"`
  22906. Balc float64 `json:"balc"`
  22907. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22908. HospPartAmt float64 `json:"hosp_part_amt"`
  22909. MedinsSetlID string `json:"medins_setl_id"`
  22910. PdnCashPay string `json:"pdn_cash_pay"`
  22911. } `json:"setlinfo"`
  22912. } `json:"output"`
  22913. RefmsgTime string `json:"refmsg_time"`
  22914. RespondTime string `json:"respond_time"`
  22915. Signtype interface{} `json:"signtype"`
  22916. WarnMsg interface{} `json:"warn_msg"`
  22917. }
  22918. type ResultSixteen10265Two struct {
  22919. Cainfo string `json:"cainfo"`
  22920. ErrMsg string `json:"err_msg"`
  22921. InfRefmsgid string `json:"inf_refmsgid"`
  22922. Infcode string `json:"infcode"`
  22923. Output struct {
  22924. Setlinfo interface{} `json:"setlinfo"`
  22925. } `json:"output"`
  22926. RefmsgTime string `json:"refmsg_time"`
  22927. RespondTime string `json:"respond_time"`
  22928. Signtype interface{} `json:"signtype"`
  22929. WarnMsg interface{} `json:"warn_msg"`
  22930. }
  22931. type ResultgzSixteen10265Two struct {
  22932. Cainfo string `json:"cainfo"`
  22933. ErrMsg string `json:"err_msg"`
  22934. InfRefmsgid string `json:"inf_refmsgid"`
  22935. Infcode int64 `json:"infcode"`
  22936. Output struct {
  22937. Setlinfo interface{} `json:"setlinfo"`
  22938. } `json:"output"`
  22939. RefmsgTime string `json:"refmsg_time"`
  22940. RespondTime string `json:"respond_time"`
  22941. Signtype interface{} `json:"signtype"`
  22942. WarnMsg interface{} `json:"warn_msg"`
  22943. }
  22944. type ResultSeventeen struct {
  22945. ErrMsg string `json:"err_msg"`
  22946. InfRefmsgid string `json:"inf_refmsgid"`
  22947. Infcode int64 `json:"infcode"`
  22948. Output struct {
  22949. SetlListId string `json:"setl_list_id"`
  22950. } `json:"output"`
  22951. RefmsgTime string `json:"refmsg_time"`
  22952. RespondTime string `json:"respond_time"`
  22953. Signtype string `json:"signtype"`
  22954. WarnInfo string `json:"warn_info"`
  22955. }
  22956. type ResultSeventeenOther struct {
  22957. ErrMsg string `json:"err_msg"`
  22958. InfRefmsgid string `json:"inf_refmsgid"`
  22959. Infcode string `json:"infcode"`
  22960. Output struct {
  22961. SetlListId string `json:"setl_list_id"`
  22962. } `json:"output"`
  22963. RefmsgTime string `json:"refmsg_time"`
  22964. RespondTime string `json:"respond_time"`
  22965. Signtype string `json:"signtype"`
  22966. WarnInfo string `json:"warn_info"`
  22967. }
  22968. type Result90991 struct {
  22969. ErrMsg string `json:"err_msg"`
  22970. InfRefmsgid string `json:"inf_refmsgid"`
  22971. Infcode int64 `json:"infcode"`
  22972. Output struct {
  22973. Result struct {
  22974. PsnNo string `json:"psn_no"`
  22975. CardStat string `json:"card_stat"`
  22976. Certno string `json:"certno"`
  22977. PsnName string `json:"psn_name"`
  22978. CheckStat string `json:"check_stat"`
  22979. SscnoCheckStat string `json:"sscno_check_stat"`
  22980. } `json:"result"`
  22981. } `json:"output"`
  22982. RefmsgTime string `json:"refmsg_time"`
  22983. RespondTime string `json:"respond_time"`
  22984. Signtype interface{} `json:"signtype"`
  22985. WarnInfo interface{} `json:"warn_info"`
  22986. }
  22987. type Result90100 struct {
  22988. ErrMsg string `json:"err_msg"`
  22989. InfRefmsgid string `json:"inf_refmsgid"`
  22990. Infcode int64 `json:"infcode"`
  22991. Output struct {
  22992. PoolareaNo string `json:"poolarea_no"`
  22993. PoolareaNoName string `json:"poolarea_no_name"`
  22994. Insutype string `json:"insutype"`
  22995. InsutypeName string `json:"insutype_name"`
  22996. ClctType string `json:"clct_type"`
  22997. ClctTypeName string `json:"clct_type_name"`
  22998. ClctFlag string `json:"clct_flag"`
  22999. ClctFlagName string `json:"clct_flag_name"`
  23000. AccrymBegn string `json:"accrym_begn"`
  23001. AccrymEnd string `json:"accrym_end"`
  23002. ClctTime string `json:"clct_time"`
  23003. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23004. } `json:"output"`
  23005. RefmsgTime string `json:"refmsg_time"`
  23006. RespondTime string `json:"respond_time"`
  23007. Signtype interface{} `json:"signtype"`
  23008. WarnInfo interface{} `json:"warn_info"`
  23009. }
  23010. type Custom struct {
  23011. DetItemFeeSumamt string
  23012. Cut string
  23013. FeedetlSn string
  23014. Price string
  23015. MedListCodg string
  23016. Type int64
  23017. AdviceId int64
  23018. ProjectId int64
  23019. ItemId int64
  23020. }
  23021. type Result5301 struct {
  23022. ErrMsg string `json:"err_msg"`
  23023. InfRefmsgid string `json:"inf_refmsgid"`
  23024. Infcode int64 `json:"infcode"`
  23025. Output struct {
  23026. Result []struct {
  23027. OpspDiseCode string `json:"opsp_dise_code"`
  23028. OpspDiseName string `json:"opsp_dise_name"`
  23029. Begndate string `json:"begndate"`
  23030. Enddate string `json:"enddate"`
  23031. } `json:"feedetail"`
  23032. } `json:"output"`
  23033. RefmsgTime string `json:"refmsg_time"`
  23034. RespondTime string `json:"respond_time"`
  23035. Signtype interface{} `json:"signtype"`
  23036. WarnInfo interface{} `json:"warn_info"`
  23037. }
  23038. type Result5301For10265 struct {
  23039. ErrMsg string `json:"err_msg"`
  23040. InfRefmsgid string `json:"inf_refmsgid"`
  23041. Infcode string `json:"infcode"`
  23042. Output struct {
  23043. Result []struct {
  23044. OpspDiseCode string `json:"opsp_dise_code"`
  23045. OpspDiseName string `json:"opsp_dise_name"`
  23046. Begndate string `json:"begndate"`
  23047. Enddate string `json:"enddate"`
  23048. } `json:"feedetail"`
  23049. } `json:"output"`
  23050. RefmsgTime string `json:"refmsg_time"`
  23051. RespondTime string `json:"respond_time"`
  23052. Signtype interface{} `json:"signtype"`
  23053. WarnInfo interface{} `json:"warn_info"`
  23054. }
  23055. //获取个人信息----挂号-----上传就诊信息
  23056. func (c *HisApiController) GetRegisterInfo() {
  23057. id, _ := c.GetInt64("id")
  23058. record_time := c.GetString("record_time")
  23059. settlementValue, _ := c.GetInt64("settlement_value")
  23060. medical_insurance_card := c.GetString("medical_insurance_card")
  23061. name := c.GetString("name")
  23062. id_card_type, _ := c.GetInt64("id_card_type")
  23063. certificates, _ := c.GetInt64("certificates")
  23064. medical_care, _ := c.GetInt64("medical_care")
  23065. birthday := c.GetString("birthday")
  23066. id_card := c.GetString("id_card")
  23067. register_type, _ := c.GetInt64("register")
  23068. doctor, _ := c.GetInt64("doctor")
  23069. department, _ := c.GetInt64("department")
  23070. gender, _ := c.GetInt64("sex")
  23071. registration_fee, _ := c.GetFloat("registration_fee")
  23072. medical_expenses, _ := c.GetFloat("medical_expenses")
  23073. social_type, _ := c.GetInt64("social_type")
  23074. admin_user_id, _ := c.GetInt64("admin_user_id")
  23075. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23076. mdtrt_type := c.GetString("mdtrt_type")
  23077. if id_card_type == 5 {
  23078. id_card_type = 4
  23079. }
  23080. timeLayout := "2006-01-02"
  23081. loc, _ := time.LoadLocation("Local")
  23082. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23083. birthUnix := birthdays.Unix()
  23084. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23085. if err != nil {
  23086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23087. return
  23088. }
  23089. recordDateTime := theTime.Unix()
  23090. adminInfo := c.GetAdminUserInfo()
  23091. var patient service.Patients
  23092. if id == 0 {
  23093. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23094. } else {
  23095. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23096. }
  23097. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23098. if patientPrescription.ID == 0 {
  23099. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23100. }
  23101. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23102. if patient.ID == 0 {
  23103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23104. return
  23105. }
  23106. if len(patient.IdCardNo) == 0 {
  23107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23108. return
  23109. }
  23110. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23111. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23112. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23113. //就诊结算未完成,不能进行二次挂号
  23114. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23115. if len(his) >= 1 {
  23116. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23117. if len(his) >= 1 && order.ID == 0 {
  23118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23119. return
  23120. }
  23121. }
  23122. //var register_log string
  23123. if config.IsOpen == 1 {
  23124. var res ResultTwo
  23125. var res10265 ResultTwo10265
  23126. var PsnNo string
  23127. var PsnCertType string
  23128. var Certno string
  23129. var PsnName string
  23130. var Gend string
  23131. var Naty string
  23132. var Brdy string
  23133. var Age float64
  23134. var infoStr string
  23135. var idetinfoStr string
  23136. var infocode int64
  23137. var verify_number string
  23138. fmt.Println(verify_number)
  23139. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23140. psn_info, _ := service.GetPsnByPatientId(id)
  23141. PsnNo = psn_info.PsnNo
  23142. PsnCertType = psn_info.PsnCertType
  23143. Certno = psn_info.Certno
  23144. PsnName = psn_info.PsnName
  23145. Gend = psn_info.Gend
  23146. Naty = psn_info.Naty
  23147. Brdy = psn_info.Brdy
  23148. Age = psn_info.Age
  23149. infoStr = psn_info.Insuinfo
  23150. idetinfoStr = psn_info.Idetinfo
  23151. infocode = 0
  23152. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23153. psn_info, _ := service.GetPsnByPatientId(id)
  23154. PsnNo = psn_info.PsnNo
  23155. PsnCertType = psn_info.PsnCertType
  23156. Certno = psn_info.Certno
  23157. PsnName = psn_info.PsnName
  23158. Gend = psn_info.Gend
  23159. Naty = psn_info.Naty
  23160. Brdy = psn_info.Brdy
  23161. Age = psn_info.Age
  23162. infoStr = psn_info.Insuinfo
  23163. idetinfoStr = psn_info.Idetinfo
  23164. infocode = 0
  23165. verify_number = psn_info.VerifyNumber
  23166. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23167. if id_card_type == 2 {
  23168. //请求内网数据
  23169. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23170. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23171. "&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
  23172. resp, requestErr := http.Get(api)
  23173. if requestErr != nil {
  23174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23175. return
  23176. }
  23177. body, ioErr := ioutil.ReadAll(resp.Body)
  23178. if ioErr != nil {
  23179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23181. return
  23182. }
  23183. var respJSON map[string]interface{}
  23184. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23187. return
  23188. }
  23189. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23190. result_byte, _ := json.Marshal(respJSON)
  23191. result := string(result_byte)
  23192. var dat map[string]interface{}
  23193. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23194. fmt.Println(dat)
  23195. } else {
  23196. fmt.Println(err)
  23197. }
  23198. userJSONBytes, _ := json.Marshal(dat)
  23199. var res ResultTwo
  23200. var resTwo10265 ResultTwo10265
  23201. if miConfig.Code == "H15049901371" {
  23202. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23203. utils.ErrorLog("解析失败:%v", err)
  23204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23205. return
  23206. }
  23207. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23208. res.Infcode = Infcode
  23209. res.ErrMsg = resTwo10265.ErrMsg
  23210. res.Output = resTwo10265.Output
  23211. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23212. res.RespondTime = resTwo10265.RespondTime
  23213. res.WarnInfo = resTwo10265.WarnInfo
  23214. } else {
  23215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23216. utils.ErrorLog("解析失败:%v", err)
  23217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23218. return
  23219. }
  23220. }
  23221. //var insutypes []string
  23222. //var insutype string
  23223. //var is390 int = 0
  23224. //var is310 int = 0
  23225. //for _, item := range res.Output.Iinfo {
  23226. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23227. // insutypes = append(insutypes, item.Insutype)
  23228. // }
  23229. //}
  23230. //if len(insutypes) == 1 {
  23231. // insutype = insutypes[0]
  23232. //} else {
  23233. // for _, i := range insutypes {
  23234. // if i == "390" {
  23235. // is390 = 1
  23236. // }
  23237. //
  23238. // if i == "310" {
  23239. // is310 = 1
  23240. // }
  23241. // }
  23242. //}
  23243. //if is390 == 1 {
  23244. // insutype = "390"
  23245. //}
  23246. //if is310 == 1 {
  23247. // insutype = "310"
  23248. //}
  23249. //if len(insutypes) == 0 {
  23250. // insutype = "310"
  23251. //}
  23252. PsnNo = res.Output.Baseinfo.PsnNo
  23253. PsnCertType = res.Output.Baseinfo.PsnCertType
  23254. Certno = res.Output.Baseinfo.Certno
  23255. PsnName = res.Output.Baseinfo.PsnName
  23256. Gend = res.Output.Baseinfo.Gend
  23257. Naty = res.Output.Baseinfo.Naty
  23258. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23259. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23260. infoStr = string(Iinfos)
  23261. idetinfoStr = string(Idetinfos)
  23262. infocode = res.Infcode
  23263. //infocode = 0
  23264. //verify_number = psn_info.VerifyNumber
  23265. } else {
  23266. psn_info, _ := service.GetPsnByPatientId(id)
  23267. PsnNo = psn_info.PsnNo
  23268. PsnCertType = psn_info.PsnCertType
  23269. Certno = psn_info.Certno
  23270. PsnName = psn_info.PsnName
  23271. Gend = psn_info.Gend
  23272. Naty = psn_info.Naty
  23273. Brdy = psn_info.Brdy
  23274. Age = psn_info.Age
  23275. infoStr = psn_info.Insuinfo
  23276. idetinfoStr = psn_info.Idetinfo
  23277. infocode = 0
  23278. verify_number = psn_info.VerifyNumber
  23279. }
  23280. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23281. if id_card_type == 1 {
  23282. psn_info, _ := service.GetPsnByPatientId(id)
  23283. PsnNo = psn_info.PsnNo
  23284. PsnCertType = psn_info.PsnCertType
  23285. Certno = psn_info.Certno
  23286. PsnName = psn_info.PsnName
  23287. Gend = psn_info.Gend
  23288. Naty = psn_info.Naty
  23289. Brdy = psn_info.Brdy
  23290. Age = psn_info.Age
  23291. infoStr = psn_info.Insuinfo
  23292. idetinfoStr = psn_info.Idetinfo
  23293. infocode = 0
  23294. verify_number = psn_info.VerifyNumber
  23295. } else if id_card_type == 2 {
  23296. 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)
  23297. fmt.Println(errMsgLog)
  23298. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23299. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23300. utils.ErrorLog("解析失败:%v", err)
  23301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23302. return
  23303. }
  23304. PsnNo = res.Output.Baseinfo.PsnNo
  23305. PsnCertType = res.Output.Baseinfo.PsnCertType
  23306. Certno = res.Output.Baseinfo.Certno
  23307. PsnName = res.Output.Baseinfo.PsnName
  23308. Gend = res.Output.Baseinfo.Gend
  23309. Naty = res.Output.Baseinfo.Naty
  23310. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23311. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23312. infoStr = string(Iinfos)
  23313. idetinfoStr = string(Idetinfos)
  23314. infocode = res.Infcode
  23315. }
  23316. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23317. if id_card_type == 1 {
  23318. psn_info, _ := service.GetPsnByPatientId(id)
  23319. PsnNo = psn_info.PsnNo
  23320. PsnCertType = psn_info.PsnCertType
  23321. Certno = psn_info.Certno
  23322. PsnName = psn_info.PsnName
  23323. Gend = psn_info.Gend
  23324. Naty = psn_info.Naty
  23325. Brdy = psn_info.Brdy
  23326. Age = psn_info.Age
  23327. infoStr = psn_info.Insuinfo
  23328. idetinfoStr = psn_info.Idetinfo
  23329. infocode = 0
  23330. verify_number = psn_info.VerifyNumber
  23331. } else if id_card_type == 2 {
  23332. 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, "")
  23333. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23334. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23335. utils.ErrorLog("解析失败:%v", err)
  23336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23337. return
  23338. }
  23339. PsnNo = res.Output.Baseinfo.PsnNo
  23340. PsnCertType = res.Output.Baseinfo.PsnCertType
  23341. Certno = res.Output.Baseinfo.Certno
  23342. PsnName = res.Output.Baseinfo.PsnName
  23343. Gend = res.Output.Baseinfo.Gend
  23344. Naty = res.Output.Baseinfo.Naty
  23345. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23346. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23347. infoStr = string(Iinfos)
  23348. idetinfoStr = string(Idetinfos)
  23349. infocode = res.Infcode
  23350. } else {
  23351. psn_info, _ := service.GetPsnByPatientId(id)
  23352. PsnNo = psn_info.PsnNo
  23353. PsnCertType = psn_info.PsnCertType
  23354. Certno = psn_info.Certno
  23355. PsnName = psn_info.PsnName
  23356. Gend = psn_info.Gend
  23357. Naty = psn_info.Naty
  23358. Brdy = psn_info.Brdy
  23359. Age = psn_info.Age
  23360. infoStr = psn_info.Insuinfo
  23361. idetinfoStr = psn_info.Idetinfo
  23362. infocode = 0
  23363. verify_number = psn_info.VerifyNumber
  23364. }
  23365. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23366. if id_card_type == 1 {
  23367. psn_info, _ := service.GetPsnByPatientId(id)
  23368. PsnNo = psn_info.PsnNo
  23369. PsnCertType = psn_info.PsnCertType
  23370. Certno = psn_info.Certno
  23371. PsnName = psn_info.PsnName
  23372. Gend = psn_info.Gend
  23373. Naty = psn_info.Naty
  23374. Brdy = psn_info.Brdy
  23375. Age = psn_info.Age
  23376. infoStr = psn_info.Insuinfo
  23377. idetinfoStr = psn_info.Idetinfo
  23378. infocode = 0
  23379. verify_number = psn_info.VerifyNumber
  23380. } else if id_card_type == 2 {
  23381. psn_info, _ := service.GetPsnByPatientId(id)
  23382. PsnNo = psn_info.PsnNo
  23383. PsnCertType = psn_info.PsnCertType
  23384. Certno = psn_info.Certno
  23385. PsnName = psn_info.PsnName
  23386. Gend = psn_info.Gend
  23387. Naty = psn_info.Naty
  23388. Brdy = psn_info.Brdy
  23389. Age = psn_info.Age
  23390. infoStr = psn_info.Insuinfo
  23391. idetinfoStr = psn_info.Idetinfo
  23392. infocode = 0
  23393. verify_number = psn_info.VerifyNumber
  23394. } else {
  23395. psn_info, _ := service.GetPsnByPatientId(id)
  23396. PsnNo = psn_info.PsnNo
  23397. PsnCertType = psn_info.PsnCertType
  23398. Certno = psn_info.Certno
  23399. PsnName = psn_info.PsnName
  23400. Gend = psn_info.Gend
  23401. Naty = psn_info.Naty
  23402. Brdy = psn_info.Brdy
  23403. Age = psn_info.Age
  23404. infoStr = psn_info.Insuinfo
  23405. idetinfoStr = psn_info.Idetinfo
  23406. infocode = 0
  23407. verify_number = psn_info.VerifyNumber
  23408. }
  23409. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23410. psn_info, _ := service.GetPsnByPatientId(id)
  23411. PsnNo = psn_info.PsnNo
  23412. PsnCertType = psn_info.PsnCertType
  23413. Certno = psn_info.Certno
  23414. PsnName = psn_info.PsnName
  23415. Gend = psn_info.Gend
  23416. Naty = psn_info.Naty
  23417. Brdy = psn_info.Brdy
  23418. Age = psn_info.Age
  23419. infoStr = psn_info.Insuinfo
  23420. idetinfoStr = psn_info.Idetinfo
  23421. infocode = 0
  23422. verify_number = psn_info.VerifyNumber
  23423. idetinfoStr = psn_info.Idetinfo
  23424. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23425. if id_card_type == 1 {
  23426. psn_info, _ := service.GetPsnByPatientId(id)
  23427. PsnNo = psn_info.PsnNo
  23428. PsnCertType = psn_info.PsnCertType
  23429. Certno = psn_info.Certno
  23430. PsnName = psn_info.PsnName
  23431. Gend = psn_info.Gend
  23432. Naty = psn_info.Naty
  23433. Brdy = psn_info.Brdy
  23434. Age = psn_info.Age
  23435. infoStr = psn_info.Insuinfo
  23436. idetinfoStr = psn_info.Idetinfo
  23437. infocode = 0
  23438. verify_number = psn_info.VerifyNumber
  23439. } else if id_card_type == 2 {
  23440. 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)
  23441. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23442. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23443. utils.ErrorLog("解析失败:%v", err)
  23444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23445. return
  23446. }
  23447. PsnNo = res.Output.Baseinfo.PsnNo
  23448. PsnCertType = res.Output.Baseinfo.PsnCertType
  23449. Certno = res.Output.Baseinfo.Certno
  23450. PsnName = res.Output.Baseinfo.PsnName
  23451. Gend = res.Output.Baseinfo.Gend
  23452. Naty = res.Output.Baseinfo.Naty
  23453. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23454. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23455. infoStr = string(Iinfos)
  23456. idetinfoStr = string(Idetinfos)
  23457. infocode = res.Infcode
  23458. } else if id_card_type == 4 {
  23459. psn_info, _ := service.GetPsnByPatientId(id)
  23460. PsnNo = psn_info.PsnNo
  23461. PsnCertType = psn_info.PsnCertType
  23462. Certno = psn_info.Certno
  23463. PsnName = psn_info.PsnName
  23464. Gend = psn_info.Gend
  23465. Naty = psn_info.Naty
  23466. Brdy = psn_info.Brdy
  23467. Age = psn_info.Age
  23468. infoStr = psn_info.Insuinfo
  23469. idetinfoStr = psn_info.Idetinfo
  23470. infocode = 0
  23471. verify_number = psn_info.VerifyNumber
  23472. }
  23473. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23474. var result string
  23475. var requestLog string
  23476. 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), "")
  23477. if id_card_type == 4 {
  23478. psn_info, _ := service.GetPsnByPatientId(id)
  23479. PsnNo = psn_info.PsnNo
  23480. PsnCertType = psn_info.PsnCertType
  23481. Certno = psn_info.Certno
  23482. PsnName = psn_info.PsnName
  23483. Gend = psn_info.Gend
  23484. Naty = psn_info.Naty
  23485. Brdy = psn_info.Brdy
  23486. Age = psn_info.Age
  23487. infoStr = psn_info.Insuinfo
  23488. idetinfoStr = psn_info.Idetinfo
  23489. infocode = 0
  23490. verify_number = psn_info.VerifyNumber
  23491. } else {
  23492. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23493. if miConfig.Code == "H15049901371" {
  23494. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23495. utils.ErrorLog("解析失败:%v", err)
  23496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23497. return
  23498. }
  23499. res.ErrMsg = res10265.ErrMsg
  23500. res.Output = res10265.Output
  23501. res.InfRefmsgid = res10265.InfRefmsgid
  23502. } else {
  23503. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23504. utils.ErrorLog("解析失败:%v", err)
  23505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23506. return
  23507. }
  23508. }
  23509. PsnNo = res.Output.Baseinfo.PsnNo
  23510. PsnCertType = res.Output.Baseinfo.PsnCertType
  23511. Certno = res.Output.Baseinfo.Certno
  23512. PsnName = res.Output.Baseinfo.PsnName
  23513. Gend = res.Output.Baseinfo.Gend
  23514. Naty = res.Output.Baseinfo.Naty
  23515. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23516. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23517. infoStr = string(Iinfos)
  23518. idetinfoStr = string(Idetinfos)
  23519. if miConfig.Code == "H15049901371" {
  23520. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23521. } else {
  23522. infocode = res.Infcode
  23523. }
  23524. }
  23525. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23526. psn_info, _ := service.GetPsnByPatientId(id)
  23527. PsnNo = psn_info.PsnNo
  23528. PsnCertType = psn_info.PsnCertType
  23529. Certno = psn_info.Certno
  23530. PsnName = psn_info.PsnName
  23531. Gend = psn_info.Gend
  23532. Naty = psn_info.Naty
  23533. Brdy = psn_info.Brdy
  23534. Age = psn_info.Age
  23535. infoStr = psn_info.Insuinfo
  23536. idetinfoStr = psn_info.Idetinfo
  23537. infocode = 0
  23538. verify_number = psn_info.VerifyNumber
  23539. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23540. psn_info, _ := service.GetPsnByPatientId(id)
  23541. PsnNo = psn_info.PsnNo
  23542. PsnCertType = psn_info.PsnCertType
  23543. Certno = psn_info.Certno
  23544. PsnName = psn_info.PsnName
  23545. Gend = psn_info.Gend
  23546. Naty = psn_info.Naty
  23547. Brdy = psn_info.Brdy
  23548. Age = psn_info.Age
  23549. infoStr = psn_info.Insuinfo
  23550. idetinfoStr = psn_info.Idetinfo
  23551. infocode = 0
  23552. verify_number = psn_info.VerifyNumber
  23553. } else {
  23554. var result string
  23555. var requestLog string
  23556. //if miConfig.UserOrgId == 10138 {
  23557. if id_card_type != 4 || id_card_type != 1 {
  23558. var insa string
  23559. if len(patient.InsuplcAdmdvs) > 0 {
  23560. insa = patient.InsuplcAdmdvs
  23561. } else {
  23562. insa = miConfig.InsuplcAdmdvs
  23563. }
  23564. //psn_info, _ := service.GetPsnByPatientId(id)
  23565. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23566. 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)
  23567. }
  23568. //}
  23569. //else {
  23570. // var insa string
  23571. // if len(patient.InsuplcAdmdvs) > 0 {
  23572. // insa = patient.InsuplcAdmdvs
  23573. // } else {
  23574. // insa = miConfig.InsuplcAdmdvs
  23575. // }
  23576. // 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)
  23577. //}
  23578. if id_card_type == 4 || id_card_type == 1 {
  23579. psn_info, _ := service.GetPsnByPatientId(id)
  23580. PsnNo = psn_info.PsnNo
  23581. PsnCertType = psn_info.PsnCertType
  23582. Certno = psn_info.Certno
  23583. PsnName = psn_info.PsnName
  23584. Gend = psn_info.Gend
  23585. Naty = psn_info.Naty
  23586. Brdy = psn_info.Brdy
  23587. Age = psn_info.Age
  23588. infoStr = psn_info.Insuinfo
  23589. idetinfoStr = psn_info.Idetinfo
  23590. infocode = 0
  23591. verify_number = psn_info.VerifyNumber
  23592. } else {
  23593. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23594. if miConfig.Code == "H15049901371" {
  23595. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23596. utils.ErrorLog("解析失败:%v", err)
  23597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23598. return
  23599. }
  23600. res.ErrMsg = res10265.ErrMsg
  23601. res.Output = res10265.Output
  23602. res.InfRefmsgid = res10265.InfRefmsgid
  23603. } else {
  23604. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23605. utils.ErrorLog("解析失败:%v", err)
  23606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23607. return
  23608. }
  23609. }
  23610. PsnNo = res.Output.Baseinfo.PsnNo
  23611. PsnCertType = res.Output.Baseinfo.PsnCertType
  23612. Certno = res.Output.Baseinfo.Certno
  23613. PsnName = res.Output.Baseinfo.PsnName
  23614. Gend = res.Output.Baseinfo.Gend
  23615. Naty = res.Output.Baseinfo.Naty
  23616. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23617. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23618. infoStr = string(Iinfos)
  23619. idetinfoStr = string(Idetinfos)
  23620. if miConfig.Code == "H15049901371" {
  23621. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23622. } else {
  23623. infocode = res.Infcode
  23624. }
  23625. }
  23626. }
  23627. if infocode == 0 {
  23628. his := models.VMHisPatient{
  23629. Name: name,
  23630. Gender: gender,
  23631. Birthday: birthUnix,
  23632. MedicalTreatmentType: medical_care,
  23633. IdType: certificates,
  23634. IdCardNo: id_card,
  23635. BalanceAccountsType: settlementValue,
  23636. SocialType: social_type,
  23637. MedicalInsuranceNumber: medical_insurance_card,
  23638. RegisterType: register_type,
  23639. RegisterCost: registration_fee,
  23640. TreatmentCost: medical_expenses,
  23641. Status: 1,
  23642. Ctime: time.Now().Unix(),
  23643. Mtime: time.Now().Unix(),
  23644. PsnNo: PsnNo,
  23645. PsnCertType: PsnCertType,
  23646. Certno: Certno,
  23647. PsnName: PsnName,
  23648. Gend: Gend,
  23649. Naty: Naty,
  23650. Brdy: Brdy,
  23651. Age: Age,
  23652. Iinfo: infoStr,
  23653. Idetinfo: idetinfoStr,
  23654. PatientId: patient.ID,
  23655. RecordDate: theTime.Unix(),
  23656. UserOrgId: adminInfo.CurrentOrgId,
  23657. AdminUserId: admin_user_id,
  23658. IsReturn: 1,
  23659. IdCardType: id_card_type,
  23660. Doctor: doctor,
  23661. Departments: department,
  23662. MdtrtGrpType: mdtrt_type,
  23663. }
  23664. timestamp := time.Now().Unix()
  23665. tempTime := time.Unix(timestamp, 0)
  23666. timeFormat := tempTime.Format("20060102150405")
  23667. chrgBchno := rand.Intn(100000) + 10000
  23668. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23669. his.Number = ipt_otp_no
  23670. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23671. department, _ := service.GetDepartMentDetail(department)
  23672. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23673. IdCardNo := ""
  23674. if id_card_type == 1 {
  23675. // IdCardNo = medical_insurance_card
  23676. IdCardNo = patient.IdCardNo
  23677. } else {
  23678. IdCardNo = patient.IdCardNo
  23679. }
  23680. var rf []*ResultFive
  23681. json.Unmarshal([]byte(his.Iinfo), &rf)
  23682. var insutypes []*ResultFive
  23683. var insutype string
  23684. var insuplc_admdvs_temp string
  23685. var is390 int = 0
  23686. var is310 int = 0
  23687. for _, item := range rf {
  23688. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23689. insutypes = append(insutypes, item)
  23690. }
  23691. }
  23692. if len(insutypes) == 1 {
  23693. insutype = insutypes[0].Insutype
  23694. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23695. if insutype == "390" {
  23696. is390 = 1
  23697. }
  23698. if insutype == "310" {
  23699. is310 = 1
  23700. }
  23701. } else {
  23702. for _, i := range insutypes {
  23703. if i.Insutype == "390" {
  23704. is390 = 1
  23705. }
  23706. if i.Insutype == "310" {
  23707. is310 = 1
  23708. }
  23709. }
  23710. }
  23711. if is390 == 1 {
  23712. insutype = "390"
  23713. }
  23714. if is310 == 1 {
  23715. insutype = "310"
  23716. }
  23717. fmt.Println(social_type)
  23718. if social_type > 0 {
  23719. insutype = strconv.FormatInt(social_type, 10)
  23720. }
  23721. var infocode int64
  23722. var resThree ResultThree
  23723. var resThree10265 ResultThree10265
  23724. if len(insuplc_admdvs) == 0 {
  23725. psn_info, _ := service.GetPsnByPatientId(id)
  23726. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23727. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23728. //}
  23729. } else {
  23730. insuplc_admdvs_temp = insuplc_admdvs
  23731. }
  23732. if miConfig.MdtrtareaAdmvs == "421300" {
  23733. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23734. psn_info, _ := service.GetPsnByPatientId(id)
  23735. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23736. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23737. "&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
  23738. resp, requestErr := http.Get(api)
  23739. if requestErr != nil {
  23740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23741. return
  23742. }
  23743. body, ioErr := ioutil.ReadAll(resp.Body)
  23744. if ioErr != nil {
  23745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23747. return
  23748. }
  23749. var respJSON map[string]interface{}
  23750. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23753. return
  23754. }
  23755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23756. result, _ := json.Marshal(respJSON)
  23757. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23758. utils.ErrorLog("解析失败:%v", err)
  23759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23760. return
  23761. }
  23762. infocode = resThree.Infcode
  23763. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23764. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23765. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23766. // insuplc_admdvs_temp =
  23767. //}
  23768. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23769. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23770. //}
  23771. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23772. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23773. "&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
  23774. resp, requestErr := http.Get(api)
  23775. if requestErr != nil {
  23776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23777. return
  23778. }
  23779. body, ioErr := ioutil.ReadAll(resp.Body)
  23780. if ioErr != nil {
  23781. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23783. return
  23784. }
  23785. var respJSON map[string]interface{}
  23786. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23789. return
  23790. }
  23791. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23792. result, _ := json.Marshal(respJSON)
  23793. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23794. utils.ErrorLog("解析失败:%v", err)
  23795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23796. return
  23797. }
  23798. infocode = resThree.Infcode
  23799. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23800. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23801. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23802. // insuplc_admdvs_temp =
  23803. //}
  23804. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23805. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23806. //}
  23807. utils.ErrorLog("解析失败:%v", insutype)
  23808. utils.ErrorLog("解析失败:%v", PsnNo)
  23809. utils.ErrorLog("解析失败:%v", Certno)
  23810. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23811. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23812. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23813. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23814. utils.ErrorLog("解析失败:%v", PsnNo)
  23815. utils.ErrorLog("解析失败:%v", department.Number)
  23816. utils.ErrorLog("解析失败:%v", department.Name)
  23817. utils.ErrorLog("解析失败:%v", roles.UserName)
  23818. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23819. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23820. "&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
  23821. resp, requestErr := http.Get(api)
  23822. if requestErr != nil {
  23823. utils.ErrorLog("解析失败:%v", requestErr)
  23824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23825. return
  23826. }
  23827. body, ioErr := ioutil.ReadAll(resp.Body)
  23828. if ioErr != nil {
  23829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23831. return
  23832. }
  23833. var respJSON map[string]interface{}
  23834. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23837. return
  23838. }
  23839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23840. result, _ := json.Marshal(respJSON)
  23841. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23842. utils.ErrorLog("解析失败:%v", err)
  23843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23844. return
  23845. }
  23846. infocode = resThree.Infcode
  23847. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23848. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23849. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23850. // insuplc_admdvs_temp =
  23851. //}
  23852. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23853. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23854. //}
  23855. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23856. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23857. "&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
  23858. resp, requestErr := http.Get(api)
  23859. if requestErr != nil {
  23860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23861. return
  23862. }
  23863. body, ioErr := ioutil.ReadAll(resp.Body)
  23864. if ioErr != nil {
  23865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23867. return
  23868. }
  23869. var respJSON map[string]interface{}
  23870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23873. return
  23874. }
  23875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23876. result, _ := json.Marshal(respJSON)
  23877. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23878. utils.ErrorLog("解析失败:%v", err)
  23879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23880. return
  23881. }
  23882. infocode = resThree.Infcode
  23883. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23884. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23885. psn_info, _ := service.GetPsnByPatientId(id)
  23886. var verify_number string
  23887. if id_card_type == 4 {
  23888. verify_number = psn_info.VerifyNumber
  23889. } else if id_card_type == 1 {
  23890. bas := strings.Split(psn_info.CardInfo, "|")
  23891. cardNumber := bas[2]
  23892. verify_number = cardNumber
  23893. }
  23894. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23895. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23896. "&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
  23897. resp, requestErr := http.Get(api)
  23898. if requestErr != nil {
  23899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23900. return
  23901. }
  23902. body, ioErr := ioutil.ReadAll(resp.Body)
  23903. if ioErr != nil {
  23904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23906. return
  23907. }
  23908. var respJSON map[string]interface{}
  23909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23912. return
  23913. }
  23914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23915. result, _ := json.Marshal(respJSON)
  23916. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23917. // utils.ErrorLog("解析失败:%v", err)
  23918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23919. // return
  23920. //}
  23921. //infocode = resThree.Infcode
  23922. //result, _ := json.Marshal(respJSON)
  23923. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23924. utils.ErrorLog("解析失败:%v", err)
  23925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23926. return
  23927. }
  23928. resThree.ErrMsg = resThree10265.ErrMsg
  23929. resThree.Output = resThree10265.Output
  23930. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23931. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23932. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23933. psn_info, _ := service.GetPsnByPatientId(id)
  23934. his.PsnNo = psn_info.PsnNo
  23935. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23936. var cert_no string
  23937. if id_card_type == 3 {
  23938. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  23939. cert_no = IdCardNo
  23940. } else if id_card_type == 4 {
  23941. cert_no = IdCardNo
  23942. psn_info.VerifyNumber = psn_info.VerifyNumber
  23943. } else {
  23944. bas := strings.Split(psn_info.CardInfo, "|")
  23945. cert_no = bas[2]
  23946. }
  23947. var hisPrescription []*models.HisPrescription
  23948. for _, item := range rf {
  23949. if item.Insutype == insutype {
  23950. //insuplc_admdvs = item.InsuplcAdmdvs
  23951. his.InsuplcAdmdvs = insuplc_admdvs
  23952. }
  23953. }
  23954. his.Insutype = insutype
  23955. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23956. fmt.Println(res3101)
  23957. fmt.Println(res3101.Infcode)
  23958. if res3101.Infcode == "0" {
  23959. fmt.Println("33333333")
  23960. if len(res3101.Output.Result) > 0 {
  23961. fmt.Println("222222")
  23962. for _, item := range res3101.Output.Result {
  23963. if len(res3101.ErrMsg) == 0 {
  23964. res3101.ErrMsg = item.VolaCont
  23965. } else {
  23966. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23967. }
  23968. }
  23969. c.ServeSuccessJSON(map[string]interface{}{
  23970. "failed_code": -10,
  23971. "msg": res3101.ErrMsg,
  23972. })
  23973. return
  23974. } else {
  23975. fmt.Println("11111")
  23976. var api string
  23977. if miConfig.MdtrtareaAdmvs == "320921" {
  23978. ipt_otp_no = timeFormat
  23979. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23980. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23981. "&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
  23982. } else {
  23983. ipt_otp_no = timeFormat
  23984. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23985. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23986. "&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
  23987. }
  23988. resp, requestErr := http.Get(api)
  23989. if requestErr != nil {
  23990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23991. return
  23992. }
  23993. body, ioErr := ioutil.ReadAll(resp.Body)
  23994. if ioErr != nil {
  23995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23997. return
  23998. }
  23999. var respJSON map[string]interface{}
  24000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24003. return
  24004. }
  24005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24006. result, _ := json.Marshal(respJSON)
  24007. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24008. utils.ErrorLog("解析失败:%v", err)
  24009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24010. return
  24011. }
  24012. resThree.ErrMsg = resThree10265.ErrMsg
  24013. resThree.Output = resThree10265.Output
  24014. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24015. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24016. }
  24017. } else if res3101.Infcode != "0" {
  24018. c.ServeSuccessJSON(map[string]interface{}{
  24019. "failed_code": -10,
  24020. "msg": res3101.ErrMsg,
  24021. })
  24022. return
  24023. }
  24024. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24025. psn_info, _ := service.GetPsnByPatientId(id)
  24026. var cert_no string
  24027. if id_card_type == 1 {
  24028. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24029. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24030. } else if id_card_type == 4 {
  24031. cert_no = psn_info.VerifyNumber
  24032. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24033. } else {
  24034. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24035. cert_no = psn_info.VerifyNumber
  24036. }
  24037. 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)
  24038. saveLog(result, requestLog, "2201", "挂号")
  24039. if miConfig.Code == "H15049901371" {
  24040. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24041. utils.ErrorLog("解析失败:%v", err)
  24042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24043. return
  24044. }
  24045. resThree.ErrMsg = resThree10265.ErrMsg
  24046. resThree.Output = resThree10265.Output
  24047. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24048. } else {
  24049. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24050. utils.ErrorLog("解析失败:%v", err)
  24051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24052. return
  24053. }
  24054. }
  24055. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24056. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24057. psn_info, _ := service.GetPsnByPatientId(id)
  24058. var result string
  24059. var requestLog string
  24060. if id_card_type == 1 {
  24061. bas := strings.Split(psn_info.CardInfo, "|")
  24062. basNumber := bas[2]
  24063. card_sn := bas[3]
  24064. 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)
  24065. saveLog(result, requestLog, "2201A", "挂号")
  24066. } else if id_card_type == 2 {
  24067. 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, "", "", "", "", "", "")
  24068. saveLog(result, requestLog, "2201A", "挂号")
  24069. } else {
  24070. 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)
  24071. saveLog(result, requestLog, "2201A", "挂号")
  24072. }
  24073. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24074. utils.ErrorLog("解析失败:%v", err)
  24075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24076. return
  24077. }
  24078. infocode = resThree.Infcode
  24079. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24080. psn_info, _ := service.GetPsnByPatientId(id)
  24081. var result string
  24082. var requestLog string
  24083. if id_card_type == 1 {
  24084. bas := strings.Split(psn_info.CardInfo, "|")
  24085. basNumber := bas[2]
  24086. card_sn := ""
  24087. 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)
  24088. saveLog(result, requestLog, "2201A", "挂号")
  24089. } else if id_card_type == 2 {
  24090. 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, "", "", "", "", "", "")
  24091. saveLog(result, requestLog, "2201A", "挂号")
  24092. } else {
  24093. 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)
  24094. saveLog(result, requestLog, "2201A", "挂号")
  24095. }
  24096. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24097. utils.ErrorLog("解析失败:%v", err)
  24098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24099. return
  24100. }
  24101. infocode = resThree.Infcode
  24102. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24103. psn_info, _ := service.GetPsnByPatientId(id)
  24104. his.PsnNo = psn_info.PsnNo
  24105. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24106. var cert_no string
  24107. if id_card_type == 1 {
  24108. bas := strings.Split(psn_info.CardInfo, "|")
  24109. cert_no = bas[2]
  24110. } else if id_card_type == 4 {
  24111. cert_no = psn_info.VerifyNumber
  24112. psn_info.VerifyNumber = psn_info.VerifyNumber
  24113. IdCardNo = psn_info.VerifyNumber
  24114. } else {
  24115. cert_no = IdCardNo
  24116. psn_info.VerifyNumber = cert_no
  24117. }
  24118. for _, item := range rf {
  24119. if item.Insutype == insutype {
  24120. his.InsuplcAdmdvs = insuplc_admdvs
  24121. }
  24122. }
  24123. his.Insutype = insutype
  24124. var api string
  24125. ipt_otp_no = timeFormat
  24126. 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 +
  24127. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24128. "&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
  24129. resp, requestErr := http.Get(api)
  24130. if requestErr != nil {
  24131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24132. return
  24133. }
  24134. body, ioErr := ioutil.ReadAll(resp.Body)
  24135. if ioErr != nil {
  24136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24138. return
  24139. }
  24140. var respJSON map[string]interface{}
  24141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24144. return
  24145. }
  24146. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24147. if status == "0" {
  24148. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24149. c.ServeSuccessJSON(map[string]interface{}{
  24150. "failed_code": -10,
  24151. "msg": err_msg,
  24152. })
  24153. return
  24154. }
  24155. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24156. result, _ := json.Marshal(respJSON)
  24157. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24158. utils.ErrorLog("解析失败:%v", err)
  24159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24160. return
  24161. }
  24162. infocode = resThree.Infcode
  24163. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24164. psn_info, _ := service.GetPsnByPatientId(id)
  24165. his.PsnNo = psn_info.PsnNo
  24166. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24167. var cert_no string
  24168. if id_card_type == 1 {
  24169. bas := strings.Split(psn_info.CardInfo, "|")
  24170. cert_no = bas[2]
  24171. } else if id_card_type == 4 {
  24172. cert_no = psn_info.VerifyNumber
  24173. psn_info.VerifyNumber = psn_info.VerifyNumber
  24174. IdCardNo = psn_info.VerifyNumber
  24175. } else {
  24176. cert_no = IdCardNo
  24177. psn_info.VerifyNumber = cert_no
  24178. }
  24179. for _, item := range rf {
  24180. if item.Insutype == insutype {
  24181. his.InsuplcAdmdvs = insuplc_admdvs
  24182. patient.InsuplcAdmdvs = insuplc_admdvs
  24183. }
  24184. }
  24185. his.Insutype = insutype
  24186. var api string
  24187. ipt_otp_no = timeFormat
  24188. 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 +
  24189. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24190. "&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
  24191. resp, requestErr := http.Get(api)
  24192. if requestErr != nil {
  24193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24194. return
  24195. }
  24196. body, ioErr := ioutil.ReadAll(resp.Body)
  24197. if ioErr != nil {
  24198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24200. return
  24201. }
  24202. var respJSON map[string]interface{}
  24203. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24206. return
  24207. }
  24208. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24209. if status == "0" {
  24210. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24211. c.ServeSuccessJSON(map[string]interface{}{
  24212. "failed_code": -10,
  24213. "msg": err_msg,
  24214. })
  24215. return
  24216. }
  24217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24218. result, _ := json.Marshal(respJSON)
  24219. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24220. utils.ErrorLog("解析失败:%v", err)
  24221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24222. return
  24223. }
  24224. infocode = resThree.Infcode
  24225. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24226. psn_info, _ := service.GetPsnByPatientId(id)
  24227. var result string
  24228. var requestLog string
  24229. if id_card_type == 1 {
  24230. bas := strings.Split(psn_info.CardInfo, "|")
  24231. basNumber := bas[2]
  24232. card_sn := bas[3]
  24233. 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)
  24234. saveLog(result, requestLog, "2201A", "挂号")
  24235. } else if id_card_type == 2 {
  24236. 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, "", "")
  24237. saveLog(result, requestLog, "2201A", "挂号")
  24238. } else {
  24239. 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, "", "")
  24240. saveLog(result, requestLog, "2201A", "挂号")
  24241. }
  24242. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24243. utils.ErrorLog("解析失败:%v", err)
  24244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24245. return
  24246. }
  24247. infocode = resThree.Infcode
  24248. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24249. psn_info, _ := service.GetPsnByPatientId(id)
  24250. 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)
  24251. saveLog(result, requestLog, "2201A", "挂号")
  24252. if miConfig.Code == "H15049901371" {
  24253. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24254. utils.ErrorLog("解析失败:%v", err)
  24255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24256. return
  24257. }
  24258. resThree.ErrMsg = resThree10265.ErrMsg
  24259. resThree.Output = resThree10265.Output
  24260. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24261. } else {
  24262. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24263. utils.ErrorLog("解析失败:%v", err)
  24264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24265. return
  24266. }
  24267. }
  24268. if miConfig.Code == "H15049901371" {
  24269. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24270. } else {
  24271. infocode = resThree.Infcode
  24272. }
  24273. } else {
  24274. psn_info, _ := service.GetPsnByPatientId(id)
  24275. if id_card_type == 4 || id_card_type == 1 {
  24276. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24277. }
  24278. var rf []*ResultFive
  24279. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24280. var insutypes []*ResultFive
  24281. var insutype string
  24282. var is390 int = 0
  24283. var is310 int = 0
  24284. for _, item := range rf {
  24285. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24286. insutypes = append(insutypes, item)
  24287. }
  24288. }
  24289. if len(insutypes) == 1 {
  24290. insutype = insutypes[0].Insutype
  24291. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24292. } else {
  24293. for _, i := range insutypes {
  24294. if i.Insutype == "390" {
  24295. is390 = 1
  24296. }
  24297. if i.Insutype == "310" {
  24298. is310 = 1
  24299. }
  24300. }
  24301. }
  24302. if is390 == 1 {
  24303. insutype = "390"
  24304. }
  24305. if is310 == 1 {
  24306. insutype = "310"
  24307. }
  24308. fmt.Println(len(insutypes))
  24309. if len(insutypes) == 0 {
  24310. for index, item := range rf {
  24311. if index == 0 {
  24312. insutype = item.Insutype
  24313. insuplc_admdvs = item.InsuplcAdmdvs
  24314. }
  24315. }
  24316. fmt.Println(insutype)
  24317. fmt.Println(insuplc_admdvs)
  24318. }
  24319. if social_type > 0 {
  24320. insutype = strconv.FormatInt(social_type, 10)
  24321. }
  24322. fmt.Println("--------")
  24323. fmt.Println(psn_info)
  24324. fmt.Println(psn_info.PsnNo)
  24325. if miConfig.MdtrtareaAdmvs == "441202" {
  24326. var hisPrescription []*models.HisPrescription
  24327. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24328. if res3101.Infcode == 0 {
  24329. fmt.Println("33333333")
  24330. if len(res3101.Output.Result) > 0 {
  24331. fmt.Println("222222")
  24332. for _, item := range res3101.Output.Result {
  24333. if len(res3101.ErrMsg) == 0 {
  24334. res3101.ErrMsg = item.VolaCont
  24335. } else {
  24336. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24337. }
  24338. }
  24339. c.ServeSuccessJSON(map[string]interface{}{
  24340. "failed_code": -10,
  24341. "msg": res3101.ErrMsg,
  24342. })
  24343. return
  24344. } else {
  24345. hour := time.Now().Format("15")
  24346. min := time.Now().Format("04")
  24347. sec := time.Now().Format("05")
  24348. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24349. fmt.Println(record_time_two)
  24350. 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)
  24351. saveLog(result, requestLog, "2201A", "挂号")
  24352. if miConfig.Code == "H15049901371" {
  24353. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24354. utils.ErrorLog("解析失败:%v", err)
  24355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24356. return
  24357. }
  24358. resThree.ErrMsg = resThree10265.ErrMsg
  24359. resThree.Output = resThree10265.Output
  24360. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24361. } else {
  24362. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24363. utils.ErrorLog("解析失败:%v", err)
  24364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24365. return
  24366. }
  24367. }
  24368. if miConfig.Code == "H15049901371" {
  24369. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24370. } else {
  24371. infocode = resThree.Infcode
  24372. }
  24373. }
  24374. } else if res3101.Infcode != 0 {
  24375. c.ServeSuccessJSON(map[string]interface{}{
  24376. "failed_code": -10,
  24377. "msg": res3101.ErrMsg,
  24378. })
  24379. return
  24380. }
  24381. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24382. var hisPrescription []*models.HisPrescription
  24383. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24384. if res3101.Infcode == 0 {
  24385. fmt.Println("33333333")
  24386. if len(res3101.Output.Result) > 0 {
  24387. fmt.Println("222222")
  24388. for _, item := range res3101.Output.Result {
  24389. if len(res3101.ErrMsg) == 0 {
  24390. res3101.ErrMsg = item.VolaCont
  24391. } else {
  24392. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24393. }
  24394. }
  24395. c.ServeSuccessJSON(map[string]interface{}{
  24396. "failed_code": -10,
  24397. "msg": res3101.ErrMsg,
  24398. })
  24399. return
  24400. } else {
  24401. hour := time.Now().Format("15")
  24402. min := time.Now().Format("04")
  24403. sec := time.Now().Format("05")
  24404. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24405. fmt.Println(record_time_two)
  24406. 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)
  24407. saveLog(result, requestLog, "2201A", "挂号")
  24408. if miConfig.Code == "H15049901371" {
  24409. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24410. utils.ErrorLog("解析失败:%v", err)
  24411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24412. return
  24413. }
  24414. resThree.ErrMsg = resThree10265.ErrMsg
  24415. resThree.Output = resThree10265.Output
  24416. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24417. } else {
  24418. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24419. utils.ErrorLog("解析失败:%v", err)
  24420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24421. return
  24422. }
  24423. }
  24424. if miConfig.Code == "H15049901371" {
  24425. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24426. } else {
  24427. infocode = resThree.Infcode
  24428. }
  24429. }
  24430. } else if res3101.Infcode != 0 {
  24431. c.ServeSuccessJSON(map[string]interface{}{
  24432. "failed_code": -10,
  24433. "msg": res3101.ErrMsg,
  24434. })
  24435. return
  24436. }
  24437. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24438. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24439. psn_info, _ := service.GetPsnByPatientId(id)
  24440. var verify_number string
  24441. if id_card_type == 4 {
  24442. verify_number = psn_info.VerifyNumber
  24443. } else if id_card_type == 1 {
  24444. bas := strings.Split(psn_info.CardInfo, "|")
  24445. cardNumber := bas[2]
  24446. verify_number = cardNumber
  24447. } else {
  24448. verify_number = psn_info.Certno
  24449. }
  24450. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24451. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24452. "&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
  24453. resp, requestErr := http.Get(api)
  24454. if requestErr != nil {
  24455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24456. return
  24457. }
  24458. body, ioErr := ioutil.ReadAll(resp.Body)
  24459. if ioErr != nil {
  24460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24462. return
  24463. }
  24464. var respJSON map[string]interface{}
  24465. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24468. return
  24469. }
  24470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24471. result, _ := json.Marshal(respJSON)
  24472. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24473. utils.ErrorLog("解析失败:%v", err)
  24474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24475. return
  24476. }
  24477. infocode = resThree.Infcode
  24478. } else {
  24479. hour := time.Now().Format("15")
  24480. min := time.Now().Format("04")
  24481. sec := time.Now().Format("05")
  24482. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24483. if id_card_type == 1 {
  24484. for _, item := range rf {
  24485. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24486. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24487. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24488. } else if strconv.FormatInt(social_type, 10) == "390" {
  24489. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24490. } else {
  24491. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24492. }
  24493. }
  24494. }
  24495. }
  24496. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24497. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24498. }
  24499. if id_card_type == 1 {
  24500. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24501. bas := strings.Split(psn_info.CardInfo, "|")
  24502. basNumber := bas[1]
  24503. IdCardNo = basNumber
  24504. }
  24505. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24506. IdCardNo = psn_info.VerifyNumber
  24507. }
  24508. if len(insuplc_admdvs_temp) == 0 {
  24509. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24510. }
  24511. var result string
  24512. var requestLog string
  24513. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  24514. var hisPrescription []*models.HisPrescription
  24515. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24516. if res3101.Infcode == 0 {
  24517. if len(res3101.Output.Result) > 0 {
  24518. for _, item := range res3101.Output.Result {
  24519. if len(res3101.ErrMsg) == 0 {
  24520. res3101.ErrMsg = item.VolaCont
  24521. } else {
  24522. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24523. }
  24524. }
  24525. c.ServeSuccessJSON(map[string]interface{}{
  24526. "failed_code": -10,
  24527. "msg": res3101.ErrMsg,
  24528. })
  24529. return
  24530. } else {
  24531. hour := time.Now().Format("15")
  24532. min := time.Now().Format("04")
  24533. sec := time.Now().Format("05")
  24534. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24535. fmt.Println(record_time_two)
  24536. if his.IdCardType == 2 {
  24537. IdCardNo = psn_info.Certno
  24538. psn_info.VerifyNumber = psn_info.Certno
  24539. } else if his.IdCardType == 4 {
  24540. IdCardNo = psn_info.Certno
  24541. }else{
  24542. bas := strings.Split(psn_info.CardInfo, "|")
  24543. IdCardNo = bas[2]
  24544. }
  24545. 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)
  24546. saveLog(result, requestLog, "2201A", "挂号")
  24547. if miConfig.Code == "H15049901371" {
  24548. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24549. utils.ErrorLog("解析失败:%v", err)
  24550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24551. return
  24552. }
  24553. resThree.ErrMsg = resThree10265.ErrMsg
  24554. resThree.Output = resThree10265.Output
  24555. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24556. } else {
  24557. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24558. utils.ErrorLog("解析失败:%v", err)
  24559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24560. return
  24561. }
  24562. }
  24563. if miConfig.Code == "H15049901371" {
  24564. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24565. } else {
  24566. infocode = resThree.Infcode
  24567. }
  24568. }
  24569. } else if res3101.Infcode != 0 {
  24570. c.ServeSuccessJSON(map[string]interface{}{
  24571. "failed_code": -10,
  24572. "msg": res3101.ErrMsg,
  24573. })
  24574. return
  24575. }
  24576. } else {
  24577. psn_info, _ := service.GetPsnByPatientId(id)
  24578. var rf []*ResultFive
  24579. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24580. //var insutypes []*ResultFive
  24581. var insutype string
  24582. var insutypes []*ResultFive
  24583. var is390 int = 0
  24584. var is310 int = 0
  24585. for _, item := range rf {
  24586. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24587. insutypes = append(insutypes, item)
  24588. }
  24589. }
  24590. if len(insutypes) == 1 {
  24591. insutype = insutypes[0].Insutype
  24592. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24593. } else {
  24594. for _, i := range insutypes {
  24595. if i.Insutype == "390" {
  24596. is390 = 1
  24597. }
  24598. if i.Insutype == "310" {
  24599. is310 = 1
  24600. }
  24601. }
  24602. }
  24603. if is390 == 1 {
  24604. insutype = "390"
  24605. }
  24606. if is310 == 1 {
  24607. insutype = "310"
  24608. }
  24609. if len(insutypes) == 0 {
  24610. insutype = "310"
  24611. }
  24612. if social_type > 0 {
  24613. insutype = strconv.FormatInt(social_type, 10)
  24614. }
  24615. for _, item := range rf {
  24616. if item.Insutype == insutype {
  24617. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24618. }
  24619. }
  24620. 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)
  24621. saveLog(result, requestLog, "2201A", "挂号")
  24622. }
  24623. if miConfig.Code == "H15049901371" {
  24624. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24625. utils.ErrorLog("解析失败:%v", err)
  24626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24627. return
  24628. }
  24629. resThree.ErrMsg = resThree10265.ErrMsg
  24630. resThree.Output = resThree10265.Output
  24631. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24632. } else {
  24633. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24634. utils.ErrorLog("解析失败:%v", err)
  24635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24636. return
  24637. }
  24638. }
  24639. if miConfig.Code == "H15049901371" {
  24640. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24641. } else {
  24642. infocode = resThree.Infcode
  24643. }
  24644. }
  24645. }
  24646. if infocode == -1 {
  24647. adminUser := c.GetAdminUserInfo()
  24648. errlog := &models.HisOrderError{
  24649. UserOrgId: adminUser.CurrentOrgId,
  24650. Ctime: time.Now().Unix(),
  24651. Mtime: time.Now().Unix(),
  24652. ErrMsg: resThree.ErrMsg,
  24653. Status: 1,
  24654. PatientId: id,
  24655. RecordTime: recordDateTime,
  24656. Stage: 2,
  24657. }
  24658. service.CreateErrMsgLog(errlog)
  24659. c.ServeSuccessJSON(map[string]interface{}{
  24660. "failed_code": -10,
  24661. "msg": resThree.ErrMsg,
  24662. })
  24663. return
  24664. }
  24665. his.Number = resThree.Output.Data.MdtrtID
  24666. his.PsnNo = resThree.Output.Data.PsnNo
  24667. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24668. his.IdCardNo = patient.IdCardNo
  24669. his.PhoneNumber = patient.Phone
  24670. his.UserOrgId = adminInfo.CurrentOrgId
  24671. his.Insutype = insutype
  24672. his.Ctime = time.Now().Unix()
  24673. his.Mtime = time.Now().Unix()
  24674. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24675. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24676. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24677. }
  24678. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24679. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24680. }
  24681. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24682. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24683. }
  24684. his.Status = 1
  24685. his.MdtrtGrpType = mdtrt_type
  24686. service.UpdateHisPatientStatus(&his)
  24687. service.UpdateHisPatient123(&patient)
  24688. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24689. c.ServeSuccessJSON(map[string]interface{}{
  24690. "his_info": his,
  24691. })
  24692. } else {
  24693. adminUser := c.GetAdminUserInfo()
  24694. errlog := &models.HisOrderError{
  24695. UserOrgId: adminUser.CurrentOrgId,
  24696. Ctime: time.Now().Unix(),
  24697. Mtime: time.Now().Unix(),
  24698. ErrMsg: res.ErrMsg,
  24699. Status: 1,
  24700. PatientId: id,
  24701. RecordTime: recordDateTime,
  24702. Stage: 1,
  24703. }
  24704. service.CreateErrMsgLog(errlog)
  24705. c.ServeSuccessJSON(map[string]interface{}{
  24706. "failed_code": -10,
  24707. "msg": res.ErrMsg,
  24708. })
  24709. return
  24710. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24711. }
  24712. }
  24713. }
  24714. func (c *HisApiController) GetUploadInfo() {
  24715. id, _ := c.GetInt64("id")
  24716. record_time := c.GetString("record_time")
  24717. his_patient_id, _ := c.GetInt64("his_patient_id")
  24718. order_id, _ := c.GetInt64("order_id")
  24719. pay_way, _ := c.GetInt64("pay_way")
  24720. pay_ways := c.GetString("pay_ways")
  24721. oth_desc := c.GetString("oth_desc")
  24722. pay_price, _ := c.GetFloat("pay_price")
  24723. pay_card_no := c.GetString("pay_card_no")
  24724. discount_price, _ := c.GetFloat("discount_price")
  24725. preferential_price, _ := c.GetFloat("preferential_price")
  24726. reality_price, _ := c.GetFloat("reality_price")
  24727. found_price, _ := c.GetFloat("found_price")
  24728. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24729. private_price, _ := c.GetFloat("private_price")
  24730. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24731. admin_user_id, _ := c.GetInt64("admin_user_id")
  24732. fapiao_code := c.GetString("fapiao_code")
  24733. fapiao_number := c.GetString("fapiao_number")
  24734. diagnosis_id := c.GetString("diagnosis")
  24735. sick_type, _ := c.GetInt64("sick_type")
  24736. reg_type, _ := c.GetInt64("p_type")
  24737. begin_time := c.GetString("begin_time")
  24738. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24739. cash_pay := c.GetString("cash_pay")
  24740. band_card_pay := c.GetString("band_card_pay")
  24741. wechat_pay := c.GetString("wechat_pay")
  24742. ali_pay := c.GetString("ali_pay")
  24743. jifen_pay := c.GetString("jifen_pay")
  24744. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24745. fmt.Println(acct_used_flag)
  24746. id_str := c.GetString("ids")
  24747. ids_arr := strings.Split(id_str, ",")
  24748. timeLayout := "2006-01-02"
  24749. loc, _ := time.LoadLocation("Local")
  24750. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24751. if err != nil {
  24752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24753. return
  24754. }
  24755. recordDateTime := theTime.Unix()
  24756. adminUser := c.GetAdminUserInfo()
  24757. var tempOrder models.HisOrder
  24758. tempOrder, _ = service.GetHisOrderByID(order_id)
  24759. var prescriptions []*models.HisPrescription
  24760. var start_time int64
  24761. var end_time int64
  24762. //押金模块
  24763. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24764. tmp_decimal := c.GetString("tmp_decimal")
  24765. var decimal float64 //本次使用的押金
  24766. var errmsg error
  24767. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24768. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24769. return
  24770. }
  24771. if len(tmp_decimal) > 0 {
  24772. if tmp_decimal[0] == 45 {
  24773. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24774. return
  24775. }
  24776. }
  24777. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24778. fmt.Println(errs)
  24779. decimal = tt
  24780. //if adminUser.CurrentOrgId == 10106{
  24781. // if len(fapiao_code) == 0{
  24782. // fapiao_code = "144072080589"
  24783. // }
  24784. // if len(fapiao_number) == 0{
  24785. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24786. // if order.ID == 0{
  24787. // fapiao_number = "00001520"
  24788. // }else{
  24789. // //fapiao_code = "00001520"
  24790. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24791. // var zero string
  24792. // if fpNumber >= 1000{
  24793. // zero = "0000" + strconv.Itoa(fpNumber)
  24794. // }else if fpNumber >= 10000{
  24795. // zero = "000" + strconv.Itoa(fpNumber)
  24796. // } else if fpNumber >= 100000{
  24797. // zero = "00" + strconv.Itoa(fpNumber)
  24798. // } else if fpNumber >= 1000000{
  24799. // zero = "0" + strconv.Itoa(fpNumber)
  24800. // }else {
  24801. // zero = strconv.Itoa(fpNumber)
  24802. // }
  24803. // fapiao_number = zero
  24804. // }
  24805. // }
  24806. //}
  24807. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24808. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24809. var patientPrescription models.HisPrescriptionInfo
  24810. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24811. if patientPrescription.ID == 0 {
  24812. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24813. }
  24814. //if patientPrescription.Do
  24815. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24816. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24817. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24818. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24819. var config []*models.HisXtDiagnoseConfig
  24820. for _, item := range diagnosis_ids {
  24821. id, _ := strconv.ParseInt(item, 10, 64)
  24822. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24823. config = append(config, &diagnosisConfig)
  24824. }
  24825. sickConfig, _ := service.FindSickById(sick_type)
  24826. //if tempOrder.ID == 0 {
  24827. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24828. //}
  24829. if tempOrder.ID == 0 {
  24830. var result string
  24831. var requestLog string
  24832. var res2 ResultSix
  24833. var res3 GZResultSix
  24834. var ressix10265 ResultSix10265
  24835. if miConfig.MdtrtareaAdmvs == "421300" {
  24836. data := make(map[string]interface{})
  24837. client := &http.Client{}
  24838. data["psn_no"] = his.PsnNo
  24839. data["mdtrt_id"] = his.Number
  24840. data["opter"] = roles.UserName
  24841. data["org_name"] = miConfig.OrgName
  24842. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24843. data["doctor_id"] = doctor_info.DoctorNumber
  24844. data["doctor_name"] = doctor_info.UserName
  24845. data["department"] = department.Name
  24846. data["fixmedins_code"] = miConfig.Code
  24847. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24848. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24849. data["secret_key"] = miConfig.SecretKey
  24850. data["sick_code"] = sickConfig.CountryCode
  24851. data["sick_name"] = sickConfig.ClassName
  24852. data["dept"] = strconv.FormatInt(department.ID, 10)
  24853. data["config"] = config
  24854. data["begin_time"] = begin_time
  24855. bytesData, _ := json.Marshal(data)
  24856. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24857. resp, _ := client.Do(req)
  24858. defer resp.Body.Close()
  24859. body, ioErr := ioutil.ReadAll(resp.Body)
  24860. if ioErr != nil {
  24861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24863. return
  24864. }
  24865. var respJSON map[string]interface{}
  24866. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24869. return
  24870. }
  24871. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24872. userJSONBytes, _ := json.Marshal(respJSON)
  24873. fmt.Println("log")
  24874. fmt.Println(string(userJSONBytes))
  24875. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24876. utils.ErrorLog("解析失败:%v", err)
  24877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24878. return
  24879. }
  24880. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24881. data := make(map[string]interface{})
  24882. client := &http.Client{}
  24883. data["psn_no"] = his.PsnNo
  24884. data["mdtrt_id"] = his.Number
  24885. data["opter"] = roles.UserName
  24886. data["org_name"] = miConfig.OrgName
  24887. if reg_type == 11 && his.Insutype == "390" {
  24888. data["med_type"] = "110104"
  24889. } else {
  24890. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24891. }
  24892. data["doctor_id"] = doctor_info.DoctorNumber
  24893. data["doctor_name"] = doctor_info.UserName
  24894. data["department"] = department.Name
  24895. data["fixmedins_code"] = miConfig.Code
  24896. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24897. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24898. data["secret_key"] = miConfig.SecretKey
  24899. data["sick_code"] = sickConfig.CountryCode
  24900. data["sick_name"] = sickConfig.ClassName
  24901. data["dept"] = strconv.FormatInt(department.ID, 10)
  24902. data["config"] = config
  24903. data["begin_time"] = begin_time
  24904. bytesData, _ := json.Marshal(data)
  24905. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24906. resp, _ := client.Do(req)
  24907. defer resp.Body.Close()
  24908. body, ioErr := ioutil.ReadAll(resp.Body)
  24909. if ioErr != nil {
  24910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24912. return
  24913. }
  24914. var respJSON map[string]interface{}
  24915. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24918. return
  24919. }
  24920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24921. userJSONBytes, _ := json.Marshal(respJSON)
  24922. fmt.Println("log")
  24923. fmt.Println(string(userJSONBytes))
  24924. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24925. utils.ErrorLog("解析失败:%v", err)
  24926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24927. return
  24928. }
  24929. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24930. data := make(map[string]interface{})
  24931. client := &http.Client{}
  24932. data["psn_no"] = his.PsnNo
  24933. data["mdtrt_id"] = his.Number
  24934. data["opter"] = roles.UserName
  24935. data["org_name"] = miConfig.OrgName
  24936. if reg_type == 11 && his.Insutype == "390" {
  24937. data["med_type"] = "110104"
  24938. } else {
  24939. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24940. }
  24941. data["doctor_id"] = doctor_info.DoctorNumber
  24942. data["doctor_name"] = doctor_info.UserName
  24943. data["department"] = department.Name
  24944. data["fixmedins_code"] = miConfig.Code
  24945. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24946. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24947. data["secret_key"] = miConfig.SecretKey
  24948. data["sick_code"] = sickConfig.CountryCode
  24949. data["sick_name"] = sickConfig.ClassName
  24950. data["dept"] = strconv.FormatInt(department.ID, 10)
  24951. data["config"] = config
  24952. data["begin_time"] = begin_time
  24953. bytesData, _ := json.Marshal(data)
  24954. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24955. resp, _ := client.Do(req)
  24956. defer resp.Body.Close()
  24957. body, ioErr := ioutil.ReadAll(resp.Body)
  24958. if ioErr != nil {
  24959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24961. return
  24962. }
  24963. var respJSON map[string]interface{}
  24964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24967. return
  24968. }
  24969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24970. userJSONBytes, _ := json.Marshal(respJSON)
  24971. fmt.Println("log")
  24972. fmt.Println(string(userJSONBytes))
  24973. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24974. utils.ErrorLog("解析失败:%v", err)
  24975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24976. return
  24977. }
  24978. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24979. data := make(map[string]interface{})
  24980. client := &http.Client{}
  24981. data["psn_no"] = his.PsnNo
  24982. data["mdtrt_id"] = his.Number
  24983. data["opter"] = roles.UserName
  24984. data["org_name"] = miConfig.OrgName
  24985. if reg_type == 11 && his.Insutype == "390" {
  24986. data["med_type"] = "110104"
  24987. } else {
  24988. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24989. }
  24990. data["doctor_id"] = doctor_info.DoctorNumber
  24991. data["doctor_name"] = doctor_info.UserName
  24992. data["department"] = department.Name
  24993. data["fixmedins_code"] = miConfig.Code
  24994. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24995. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24996. data["secret_key"] = miConfig.SecretKey
  24997. data["sick_code"] = sickConfig.CountryCode
  24998. data["sick_name"] = sickConfig.ClassName
  24999. data["dept"] = strconv.FormatInt(department.ID, 10)
  25000. data["config"] = config
  25001. data["begin_time"] = begin_time
  25002. bytesData, _ := json.Marshal(data)
  25003. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25004. resp, _ := client.Do(req)
  25005. defer resp.Body.Close()
  25006. body, ioErr := ioutil.ReadAll(resp.Body)
  25007. if ioErr != nil {
  25008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25010. return
  25011. }
  25012. var respJSON map[string]interface{}
  25013. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25016. return
  25017. }
  25018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25019. userJSONBytes, _ := json.Marshal(respJSON)
  25020. fmt.Println("log")
  25021. fmt.Println(string(userJSONBytes))
  25022. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25023. utils.ErrorLog("解析失败:%v", err)
  25024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25025. return
  25026. }
  25027. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25028. data := make(map[string]interface{})
  25029. client := &http.Client{}
  25030. data["psn_no"] = his.PsnNo
  25031. data["mdtrt_id"] = his.Number
  25032. data["doctor"] = roles.UserName
  25033. data["department"] = department.Name
  25034. data["org_name"] = miConfig.OrgName
  25035. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25036. data["doctor_id"] = doctor_info.DoctorNumber
  25037. data["new_doctor_name"] = doctor_info.UserName
  25038. data["fixmedins_code"] = miConfig.Code
  25039. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25040. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25041. data["secret_key"] = miConfig.SecretKey
  25042. data["sick_code"] = sickConfig.CountryCode
  25043. data["sick_name"] = sickConfig.ClassName
  25044. data["url"] = miConfig.Url
  25045. data["ak"] = miConfig.AccessKey
  25046. data["begin_time"] = begin_time
  25047. data["cainfo"] = miConfig.Cainfo
  25048. data["dept"] = strconv.FormatInt(department.ID, 10)
  25049. data["config"] = config
  25050. bytesData, _ := json.Marshal(data)
  25051. var req *http.Request
  25052. if miConfig.MdtrtareaAdmvs == "320921" {
  25053. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25054. //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 +
  25055. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25056. } else {
  25057. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25058. }
  25059. resp, _ := client.Do(req)
  25060. defer resp.Body.Close()
  25061. body, ioErr := ioutil.ReadAll(resp.Body)
  25062. if ioErr != nil {
  25063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25065. return
  25066. }
  25067. var respJSON map[string]interface{}
  25068. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25071. return
  25072. }
  25073. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25074. userJSONBytes, _ := json.Marshal(respJSON)
  25075. fmt.Println("log")
  25076. fmt.Println(string(userJSONBytes))
  25077. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25078. utils.ErrorLog("解析失败:%v", err)
  25079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25080. return
  25081. }
  25082. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25083. res2.Output = ressix10265.Output
  25084. res2.ErrMsg = ressix10265.ErrMsg
  25085. res2.Cainfo = ressix10265.Cainfo
  25086. res2.WarnMsg = ressix10265.WarnMsg
  25087. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25088. res2.Infcode = infocode
  25089. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25090. data := make(map[string]interface{})
  25091. client := &http.Client{}
  25092. data["psn_no"] = his.PsnNo
  25093. data["mdtrt_id"] = his.Number
  25094. data["doctor"] = roles.UserName
  25095. data["department"] = department.Name
  25096. data["org_name"] = miConfig.OrgName
  25097. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25098. data["doctor_id"] = doctor_info.DoctorNumber
  25099. data["new_doctor_name"] = doctor_info.UserName
  25100. data["fixmedins_code"] = miConfig.Code
  25101. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25102. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25103. data["secret_key"] = miConfig.SecretKey
  25104. data["sick_code"] = sickConfig.CountryCode
  25105. data["sick_name"] = sickConfig.ClassName
  25106. data["url"] = miConfig.Url
  25107. data["ak"] = miConfig.AccessKey
  25108. data["begin_time"] = begin_time
  25109. data["cainfo"] = miConfig.Cainfo
  25110. data["dept"] = strconv.FormatInt(department.ID, 10)
  25111. data["config"] = config
  25112. bytesData, _ := json.Marshal(data)
  25113. var req *http.Request
  25114. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25115. resp, _ := client.Do(req)
  25116. defer resp.Body.Close()
  25117. body, ioErr := ioutil.ReadAll(resp.Body)
  25118. if ioErr != nil {
  25119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25121. return
  25122. }
  25123. var respJSON map[string]interface{}
  25124. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25127. return
  25128. }
  25129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25130. userJSONBytes, _ := json.Marshal(respJSON)
  25131. fmt.Println("log")
  25132. fmt.Println(string(userJSONBytes))
  25133. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25134. utils.ErrorLog("解析失败:%v", err)
  25135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25136. return
  25137. }
  25138. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25139. res2.Output = ressix10265.Output
  25140. res2.ErrMsg = ressix10265.ErrMsg
  25141. res2.Cainfo = ressix10265.Cainfo
  25142. res2.WarnMsg = ressix10265.WarnMsg
  25143. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25144. res2.Infcode = infocode
  25145. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25146. 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)
  25147. saveLog(result, requestLog, "2203", "上传就诊信息")
  25148. var respJSON2 map[string]interface{}
  25149. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25152. return
  25153. }
  25154. userJSONBytes2, _ := json.Marshal(respJSON2)
  25155. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25156. utils.ErrorLog("解析失败:%v", err)
  25157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25158. return
  25159. }
  25160. 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)
  25161. fmt.Println(result2)
  25162. fmt.Println(src_request)
  25163. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25164. data := make(map[string]interface{})
  25165. client := &http.Client{}
  25166. data["psn_no"] = his.PsnNo
  25167. data["mdtrt_id"] = his.Number
  25168. data["doctor"] = roles.UserName
  25169. data["department"] = department.Name
  25170. data["org_name"] = miConfig.OrgName
  25171. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25172. data["doctor_id"] = doctor_info.DoctorNumber
  25173. data["new_doctor_name"] = doctor_info.UserName
  25174. data["fixmedins_code"] = miConfig.Code
  25175. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25176. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25177. data["secret_key"] = miConfig.SecretKey
  25178. data["sick_code"] = sickConfig.CountryCode
  25179. data["sick_name"] = sickConfig.ClassName
  25180. data["url"] = miConfig.Url
  25181. data["ak"] = miConfig.AccessKey
  25182. data["begin_time"] = begin_time
  25183. data["cainfo"] = miConfig.Cainfo
  25184. data["dept"] = strconv.FormatInt(department.ID, 10)
  25185. data["config"] = config
  25186. bytesData, _ := json.Marshal(data)
  25187. var req *http.Request
  25188. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25189. resp, _ := client.Do(req)
  25190. defer resp.Body.Close()
  25191. body, ioErr := ioutil.ReadAll(resp.Body)
  25192. if ioErr != nil {
  25193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25195. return
  25196. }
  25197. var respJSON map[string]interface{}
  25198. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25201. return
  25202. }
  25203. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25204. userJSONBytes, _ := json.Marshal(respJSON)
  25205. fmt.Println("log")
  25206. fmt.Println(string(userJSONBytes))
  25207. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25208. utils.ErrorLog("解析失败:%v", err)
  25209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25210. return
  25211. }
  25212. } else {
  25213. if miConfig.MdtrtareaAdmvs == "440781" { //
  25214. 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)
  25215. } else {
  25216. if miConfig.Code == "H15049901371" {
  25217. //赤峰地区国家医保医疗类别
  25218. //职工透析:医疗类别选特殊情况门诊990502
  25219. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25220. var med_type string
  25221. if his.Insutype == "390" {
  25222. if reg_type == 14 {
  25223. med_type = "9933"
  25224. } else if reg_type == 11 {
  25225. med_type = "11"
  25226. }
  25227. } else if his.Insutype == "310" {
  25228. if reg_type == 14 {
  25229. med_type = "990502"
  25230. } else if reg_type == 11 {
  25231. med_type = "11"
  25232. }
  25233. }
  25234. 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)
  25235. } else {
  25236. 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)
  25237. }
  25238. }
  25239. saveLog(result, requestLog, "2203", "上传就诊信息")
  25240. var respJSON2 map[string]interface{}
  25241. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25244. return
  25245. }
  25246. userJSONBytes2, _ := json.Marshal(respJSON2)
  25247. if miConfig.Code == "H15049901371" {
  25248. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25249. utils.ErrorLog("解析失败:%v", err)
  25250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25251. return
  25252. }
  25253. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25254. res2.Output = ressix10265.Output
  25255. res2.ErrMsg = ressix10265.ErrMsg
  25256. res2.Cainfo = ressix10265.Cainfo
  25257. res2.WarnMsg = ressix10265.WarnMsg
  25258. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25259. res2.Infcode = infocode
  25260. } else {
  25261. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25262. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25263. utils.ErrorLog("解析失败:%v", err)
  25264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25265. return
  25266. }
  25267. res2.Infcode = res3.Infcode
  25268. } else {
  25269. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25270. utils.ErrorLog("解析失败:%v", err)
  25271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25272. return
  25273. }
  25274. }
  25275. }
  25276. }
  25277. if res2.Infcode == -1 {
  25278. adminUser := c.GetAdminUserInfo()
  25279. errlog := &models.HisOrderError{
  25280. UserOrgId: adminUser.CurrentOrgId,
  25281. Ctime: time.Now().Unix(),
  25282. Mtime: time.Now().Unix(),
  25283. ErrMsg: res2.ErrMsg,
  25284. Status: 1,
  25285. PatientId: id,
  25286. RecordTime: recordDateTime,
  25287. Stage: 3,
  25288. }
  25289. service.CreateErrMsgLog(errlog)
  25290. c.ServeSuccessJSON(map[string]interface{}{
  25291. "failed_code": -10,
  25292. "msg": res2.ErrMsg,
  25293. })
  25294. return
  25295. } else {
  25296. his.Diagnosis = diagnosis_id
  25297. his.SickType = sickConfig.ID
  25298. //var p_type int64
  25299. //if reg_type == 1111 || reg_type == 1112 {
  25300. // p_type = 11
  25301. //
  25302. //}
  25303. his.PType = fmt.Sprintf("%d", reg_type)
  25304. service.UpdateHisPatientThree(&his)
  25305. data := make(map[string]interface{})
  25306. if settle_accounts_type == 1 { //日结
  25307. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25308. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25309. } else {
  25310. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25311. }
  25312. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25313. data["pre"] = prescriptions
  25314. } else { //月结
  25315. start_time_str := c.GetString("start_time")
  25316. end_time_str := c.GetString("end_time")
  25317. timeLayout := "2006-01-02"
  25318. loc, _ := time.LoadLocation("Local")
  25319. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25320. if err != nil {
  25321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25322. return
  25323. }
  25324. recordStartTime := theStartTime.Unix()
  25325. start_time = recordStartTime
  25326. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25327. if err != nil {
  25328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25329. return
  25330. }
  25331. recordEndTime := theEndTime.Unix()
  25332. end_time = recordEndTime
  25333. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25334. data["pre"] = prescriptions
  25335. }
  25336. timestamp := time.Now().Unix()
  25337. tempTime := time.Unix(timestamp, 0)
  25338. timeFormat := tempTime.Format("20060102150405")
  25339. chrgBchno := rand.Intn(100000) + 10000
  25340. new_chrg_bchno := ""
  25341. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25342. new_chrg_bchno = chrg_bchno
  25343. strconv.FormatInt(his.PatientId, 10)
  25344. client := &http.Client{}
  25345. if adminUser.CurrentOrgId == 10265 {
  25346. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25347. new_chrg_bchno = "0000"
  25348. }
  25349. }
  25350. data["psn_no"] = his.PsnNo
  25351. data["mdtrt_id"] = his.Number
  25352. data["chrg_bchno"] = new_chrg_bchno
  25353. data["org_name"] = miConfig.OrgName
  25354. data["doctor"] = doctor_info.UserName
  25355. data["doctor_id"] = doctor_info.DoctorNumber
  25356. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25357. data["fixmedins_code"] = miConfig.Code
  25358. data["dept_code"] = department.Number
  25359. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25360. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25361. data["secret_key"] = miConfig.SecretKey
  25362. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25363. data["url"] = miConfig.Url
  25364. data["ak"] = miConfig.AccessKey
  25365. data["new_doctor_name"] = patientPrescription.Doctor
  25366. data["diag_code"] = sickConfig.CountryCode
  25367. data["cainfo"] = miConfig.Cainfo
  25368. data["opter"] = roles.UserName
  25369. var ids []int64
  25370. for _, item := range prescriptions {
  25371. ids = append(ids, item.ID)
  25372. }
  25373. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25374. if config.IsOpen == 1 { //对接了医保,走医保流程
  25375. var res ResultFour
  25376. var resFour10265 ResultFour10265
  25377. if miConfig.MdtrtareaAdmvs == "421300" {
  25378. bytesData, _ := json.Marshal(data)
  25379. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25380. resp, _ := client.Do(req)
  25381. defer resp.Body.Close()
  25382. body, ioErr := ioutil.ReadAll(resp.Body)
  25383. if ioErr != nil {
  25384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25386. return
  25387. }
  25388. var respJSON map[string]interface{}
  25389. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25392. return
  25393. }
  25394. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25395. userJSONBytes, _ := json.Marshal(respJSON)
  25396. fmt.Println("log")
  25397. fmt.Println(string(userJSONBytes))
  25398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25399. utils.ErrorLog("解析失败:%v", err)
  25400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25401. return
  25402. }
  25403. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25404. bytesData, _ := json.Marshal(data)
  25405. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25406. resp, _ := client.Do(req)
  25407. defer resp.Body.Close()
  25408. body, ioErr := ioutil.ReadAll(resp.Body)
  25409. if ioErr != nil {
  25410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25412. return
  25413. }
  25414. var respJSON map[string]interface{}
  25415. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25418. return
  25419. }
  25420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25421. userJSONBytes, _ := json.Marshal(respJSON)
  25422. fmt.Println("log")
  25423. fmt.Println(string(userJSONBytes))
  25424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25425. utils.ErrorLog("解析失败:%v", err)
  25426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25427. return
  25428. }
  25429. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25430. bytesData, _ := json.Marshal(data)
  25431. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25432. resp, _ := client.Do(req)
  25433. defer resp.Body.Close()
  25434. body, ioErr := ioutil.ReadAll(resp.Body)
  25435. if ioErr != nil {
  25436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25438. return
  25439. }
  25440. var respJSON map[string]interface{}
  25441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25444. return
  25445. }
  25446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25447. userJSONBytes, _ := json.Marshal(respJSON)
  25448. fmt.Println("log")
  25449. fmt.Println(string(userJSONBytes))
  25450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25451. utils.ErrorLog("解析失败:%v", err)
  25452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25453. return
  25454. }
  25455. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25456. bytesData, _ := json.Marshal(data)
  25457. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25458. resp, _ := client.Do(req)
  25459. defer resp.Body.Close()
  25460. body, ioErr := ioutil.ReadAll(resp.Body)
  25461. if ioErr != nil {
  25462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25464. return
  25465. }
  25466. var respJSON map[string]interface{}
  25467. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25470. return
  25471. }
  25472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25473. userJSONBytes, _ := json.Marshal(respJSON)
  25474. fmt.Println("log")
  25475. fmt.Println(string(userJSONBytes))
  25476. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25477. utils.ErrorLog("解析失败:%v", err)
  25478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25479. return
  25480. }
  25481. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25482. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25483. if result3101.Infcode == "0" {
  25484. if len(result3101.Output.Result) > 0 {
  25485. var errMsgs []string
  25486. for _, item := range result3101.Output.Result {
  25487. errMsgs = append(errMsgs, item.VolaCont)
  25488. }
  25489. c.ServeSuccessJSON(map[string]interface{}{
  25490. "failed_code": -10,
  25491. "msg": errMsgs,
  25492. })
  25493. return
  25494. }
  25495. }
  25496. bytesData, _ := json.Marshal(data)
  25497. var req *http.Request
  25498. if miConfig.MdtrtareaAdmvs == "320921" {
  25499. data["diag_code"] = sickConfig.CountryCode
  25500. fmt.Println(data)
  25501. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25502. } else {
  25503. data["diag_code"] = sickConfig.CountryCode
  25504. fmt.Println(data)
  25505. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25506. }
  25507. resp, _ := client.Do(req)
  25508. defer resp.Body.Close()
  25509. body, ioErr := ioutil.ReadAll(resp.Body)
  25510. if ioErr != nil {
  25511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25513. return
  25514. }
  25515. var respJSON map[string]interface{}
  25516. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25519. return
  25520. }
  25521. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25522. userJSONBytes, _ := json.Marshal(respJSON)
  25523. fmt.Println("log")
  25524. fmt.Println(string(userJSONBytes))
  25525. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25526. utils.ErrorLog("解析失败:%v", err)
  25527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25528. return
  25529. }
  25530. res.InfRefmsgid = resFour10265.InfRefmsgid
  25531. res.Output = resFour10265.Output
  25532. res.ErrMsg = resFour10265.ErrMsg
  25533. res.Cainfo = resFour10265.Cainfo
  25534. res.WarnMsg = resFour10265.WarnMsg
  25535. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25536. res.Infcode = infocode
  25537. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25538. var pagesize int = 2
  25539. var start int = 1
  25540. var stop int
  25541. var pagecount int
  25542. var curpage int
  25543. var isSuccess bool = true
  25544. data["doctor_id"] = doctor_info.DoctorNumber
  25545. //总页数,向上取整,注意除之前要先转换类型为float64
  25546. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25547. for curpage = 1; curpage <= pagecount; curpage++ {
  25548. if curpage == 1 {
  25549. start = 1
  25550. } else {
  25551. start = (curpage-1)*pagesize + 1
  25552. }
  25553. stop = curpage * pagesize
  25554. if stop > len(prescriptions) {
  25555. stop = len(prescriptions)
  25556. }
  25557. //var requestLog string
  25558. data["pre"] = prescriptions[start-1 : stop]
  25559. fmt.Println(data["pre"])
  25560. bytesData, _ := json.Marshal(data)
  25561. var req *http.Request
  25562. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25563. resp, _ := client.Do(req)
  25564. defer resp.Body.Close()
  25565. body, ioErr := ioutil.ReadAll(resp.Body)
  25566. if ioErr != nil {
  25567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25569. return
  25570. }
  25571. var respJSON map[string]interface{}
  25572. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25575. return
  25576. }
  25577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25578. userJSONBytes, _ := json.Marshal(respJSON)
  25579. fmt.Println("log")
  25580. fmt.Println(string(userJSONBytes))
  25581. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25582. utils.ErrorLog("解析失败:%v", err)
  25583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25584. return
  25585. }
  25586. res.InfRefmsgid = resFour10265.InfRefmsgid
  25587. res.Output = resFour10265.Output
  25588. res.ErrMsg = resFour10265.ErrMsg
  25589. res.Cainfo = resFour10265.Cainfo
  25590. res.WarnMsg = resFour10265.WarnMsg
  25591. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25592. res.Infcode = infocode
  25593. if infocode == 0 {
  25594. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25595. } else {
  25596. isSuccess = false
  25597. errlog := &models.HisOrderError{
  25598. UserOrgId: adminUser.CurrentOrgId,
  25599. Ctime: time.Now().Unix(),
  25600. Mtime: time.Now().Unix(),
  25601. Number: chrg_bchno,
  25602. ErrMsg: "",
  25603. Status: 1,
  25604. PatientId: id,
  25605. RecordTime: recordDateTime,
  25606. Stage: 4,
  25607. }
  25608. service.CreateErrMsgLog(errlog)
  25609. c.ServeSuccessJSON(map[string]interface{}{
  25610. "failed_code": -10,
  25611. "msg": res.ErrMsg,
  25612. })
  25613. return
  25614. }
  25615. }
  25616. if isSuccess {
  25617. res.Infcode = 0
  25618. }
  25619. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25620. 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)
  25621. var dat map[string]interface{}
  25622. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25623. fmt.Println(dat)
  25624. } else {
  25625. fmt.Println(err)
  25626. }
  25627. saveLog(result, request_log, "2204", "上传费用明细")
  25628. userJSONBytes, _ := json.Marshal(dat)
  25629. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25630. utils.ErrorLog("解析失败:%v", err)
  25631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25632. return
  25633. }
  25634. res.InfRefmsgid = resFour10265.InfRefmsgid
  25635. res.Output = resFour10265.Output
  25636. res.ErrMsg = resFour10265.ErrMsg
  25637. res.Cainfo = resFour10265.Cainfo
  25638. res.WarnMsg = resFour10265.WarnMsg
  25639. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25640. res.Infcode = infocode
  25641. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25642. bytesData, _ := json.Marshal(data)
  25643. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25644. resp, _ := client.Do(req)
  25645. defer resp.Body.Close()
  25646. body, ioErr := ioutil.ReadAll(resp.Body)
  25647. if ioErr != nil {
  25648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25650. return
  25651. }
  25652. var respJSON map[string]interface{}
  25653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25656. return
  25657. }
  25658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25659. userJSONBytes, _ := json.Marshal(respJSON)
  25660. fmt.Println("log")
  25661. fmt.Println(string(userJSONBytes))
  25662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25663. utils.ErrorLog("解析失败:%v", err)
  25664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25665. return
  25666. }
  25667. } else {
  25668. if miConfig.Code == "H15049901371" {
  25669. 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)
  25670. var dat map[string]interface{}
  25671. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25672. fmt.Println(dat)
  25673. } else {
  25674. fmt.Println(err)
  25675. }
  25676. saveLog(result, request_log, "2204", "上传费用明细")
  25677. userJSONBytes, _ := json.Marshal(dat)
  25678. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25679. utils.ErrorLog("解析失败:%v", err)
  25680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25681. return
  25682. }
  25683. res.InfRefmsgid = resFour10265.InfRefmsgid
  25684. res.Output = resFour10265.Output
  25685. res.ErrMsg = resFour10265.ErrMsg
  25686. res.Cainfo = resFour10265.Cainfo
  25687. res.WarnMsg = resFour10265.WarnMsg
  25688. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25689. res.Infcode = infocode
  25690. } else {
  25691. 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)
  25692. var dat map[string]interface{}
  25693. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25694. fmt.Println(dat)
  25695. } else {
  25696. fmt.Println(err)
  25697. }
  25698. saveLog(result, request_log, "2204", "上传费用明细")
  25699. userJSONBytes, _ := json.Marshal(dat)
  25700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25701. utils.ErrorLog("解析失败:%v", err)
  25702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25703. return
  25704. }
  25705. }
  25706. }
  25707. if res.Infcode == 0 {
  25708. order := &models.HisOrder{
  25709. UserOrgId: adminUser.CurrentOrgId,
  25710. HisPatientId: his.ID,
  25711. PatientId: his.PatientId,
  25712. SettleAccountsDate: recordDateTime,
  25713. MdtrtId: his.Number,
  25714. PsnNo: his.PsnNo,
  25715. MedType: strconv.FormatInt(reg_type, 10),
  25716. Ctime: time.Now().Unix(),
  25717. Mtime: time.Now().Unix(),
  25718. Status: 1,
  25719. Number: chrg_bchno,
  25720. Infcode: res.Infcode,
  25721. WarnMsg: res.WarnMsg,
  25722. Cainfo: res.Cainfo,
  25723. ErrMsg: res.ErrMsg,
  25724. RespondTime: res.RefmsgTime,
  25725. InfRefmsgid: res.InfRefmsgid,
  25726. OrderStatus: 1,
  25727. PayWay: pay_way,
  25728. PayWays: pay_ways,
  25729. OthDesc: oth_desc,
  25730. PayPrice: pay_price,
  25731. PayCardNo: pay_card_no,
  25732. DiscountPrice: discount_price,
  25733. PreferentialPrice: preferential_price,
  25734. RealityPrice: reality_price,
  25735. FoundPrice: found_price,
  25736. MedicalInsurancePrice: medical_insurance_price,
  25737. PrivatePrice: private_price,
  25738. IsMedicineInsurance: 1,
  25739. SettleType: settle_accounts_type,
  25740. SettleStartTime: start_time,
  25741. SettleEndTime: end_time,
  25742. Creator: roles.AdminUserId,
  25743. Modify: roles.AdminUserId,
  25744. FaPiaoNumber: fapiao_number,
  25745. FaPiaoCode: fapiao_code,
  25746. PType: 2,
  25747. Diagnosis: diagnosis_id,
  25748. CashPay: cash_pay,
  25749. WechatPay: wechat_pay,
  25750. AliPay: ali_pay,
  25751. JifenPay: jifen_pay,
  25752. BandCardPay: band_card_pay,
  25753. }
  25754. err = service.CreateOrder(order)
  25755. if err != nil {
  25756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25757. return
  25758. }
  25759. for _, item := range res.Output.Result {
  25760. temp := strings.Split(item.FeedetlSn, "-")
  25761. var advice_id int64 = 0
  25762. var project_id int64 = 0
  25763. var types int64 = 0
  25764. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25765. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25766. if temp[1] == "1" {
  25767. advice_id = id
  25768. project_id = 0
  25769. } else if temp[1] == "2" {
  25770. advice_id = 0
  25771. project_id = id
  25772. }
  25773. if item.MedChrgitmType == "9" {
  25774. item.MedChrgitmType = "09"
  25775. }
  25776. info := &models.HisOrderInfo{
  25777. OrderNumber: order.Number,
  25778. FeedetlSn: item.FeedetlSn,
  25779. UploadDate: time.Now().Unix(),
  25780. AdviceId: advice_id,
  25781. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25782. Cnt: item.Cnt,
  25783. Pric: float64(item.Pric),
  25784. PatientId: his.PatientId,
  25785. PricUplmtAmt: item.PricUplmtAmt,
  25786. SelfpayProp: item.SelfpayProp,
  25787. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25788. OverlmtAmt: item.OverlmtAmt,
  25789. PreselfpayAmt: item.PreselfpayAmt,
  25790. BasMednFlag: item.BasMednFlag,
  25791. MedChrgitmType: item.MedChrgitmType,
  25792. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25793. Status: 1,
  25794. Memo: item.Memo,
  25795. Mtime: time.Now().Unix(),
  25796. InscpScpAmt: item.InscpScpAmt,
  25797. DrtReimFlag: item.DrtReimFlag,
  25798. Ctime: time.Now().Unix(),
  25799. ListSpItemFlag: item.ListSpItemFlag,
  25800. ChldMedcFlag: item.ChldMedcFlag,
  25801. LmtUsedFlag: item.LmtUsedFlag,
  25802. ChrgitmLv: item.ChrgitmLv,
  25803. UserOrgId: adminUser.CurrentOrgId,
  25804. HisPatientId: his.ID,
  25805. OrderId: order.ID,
  25806. ProjectId: project_id,
  25807. Type: types,
  25808. }
  25809. service.CreateOrderInfo(info)
  25810. }
  25811. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25812. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25813. var total float64
  25814. for _, item := range prescriptions {
  25815. if item.Type == 1 { //药品
  25816. for _, subItem := range item.HisDoctorAdviceInfo {
  25817. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25818. total_one := price * subItem.PrescribingNumber
  25819. total = total + total_one
  25820. }
  25821. }
  25822. if item.Type == 2 { //项目
  25823. for _, subItem := range item.HisPrescriptionProject {
  25824. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25825. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25826. total_one := price * cnt
  25827. total = total + total_one
  25828. }
  25829. }
  25830. }
  25831. allTotal := fmt.Sprintf("%.2f", total)
  25832. //if adminUser.CurrentOrgId == 9919 {
  25833. //
  25834. // allTotal = fmt.Sprintf("%.2f", total)
  25835. //
  25836. //} else {
  25837. //
  25838. // allTotal = fmt.Sprintf("%.2f", total)
  25839. //
  25840. //}
  25841. if res.Infcode == 0 {
  25842. var rf []*ResultFive
  25843. json.Unmarshal([]byte(his.Iinfo), &rf)
  25844. chrg_bchno := chrg_bchno
  25845. cert_no := his.Certno
  25846. var insutypes []string
  25847. var insutype string
  25848. var is390 int = 0
  25849. var is310 int = 0
  25850. for _, item := range rf {
  25851. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25852. insutypes = append(insutypes, item.Insutype)
  25853. }
  25854. }
  25855. if len(insutypes) == 1 {
  25856. insutype = insutypes[0]
  25857. } else {
  25858. for _, i := range insutypes {
  25859. if i == "390" {
  25860. is390 = 1
  25861. }
  25862. if i == "310" {
  25863. is310 = 1
  25864. }
  25865. }
  25866. }
  25867. if is390 == 1 {
  25868. insutype = "390"
  25869. }
  25870. if is310 == 1 {
  25871. insutype = "310"
  25872. }
  25873. if len(insutypes) == 0 {
  25874. insutype = "310"
  25875. }
  25876. if len(insutypes) == 2 {
  25877. insutype = strconv.FormatInt(his.SocialType, 10)
  25878. }
  25879. insutype = strconv.FormatInt(his.SocialType, 10)
  25880. //insutype = "390"
  25881. if his.IdCardType == 1 {
  25882. // cert_no = his.MedicalInsuranceNumber
  25883. cert_no = his.Certno
  25884. } else {
  25885. cert_no = his.Certno
  25886. }
  25887. var res ResultSeven
  25888. var resSeven10265 ResultSeven10265
  25889. var gzresSeven10265Two GZResultSeven10265Two
  25890. var src_resquest string
  25891. var result2 string
  25892. if miConfig.MdtrtareaAdmvs == "421300" {
  25893. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25894. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25895. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25896. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25897. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25898. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25899. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25900. resp, requestErr := http.Get(api)
  25901. if requestErr != nil {
  25902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25903. return
  25904. }
  25905. body, ioErr := ioutil.ReadAll(resp.Body)
  25906. if ioErr != nil {
  25907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25909. return
  25910. }
  25911. var respJSON map[string]interface{}
  25912. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25915. return
  25916. }
  25917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25918. result, _ := json.Marshal(respJSON)
  25919. if miConfig.Code == "H15049901371" {
  25920. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25921. utils.ErrorLog("解析失败:%v", err)
  25922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25923. return
  25924. }
  25925. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25926. res.Output = resSeven10265.Output
  25927. res.ErrMsg = resSeven10265.ErrMsg
  25928. res.Cainfo = resSeven10265.Cainfo
  25929. res.WarnMsg = resSeven10265.WarnMsg
  25930. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25931. res.Infcode = infocode
  25932. } else {
  25933. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25934. utils.ErrorLog("解析失败:%v", err)
  25935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25936. return
  25937. }
  25938. }
  25939. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25940. if reg_type == 11 && his.Insutype == "390" {
  25941. reg_type = 110104
  25942. }
  25943. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25944. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25945. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25946. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25947. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25948. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25949. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25950. resp, requestErr := http.Get(api)
  25951. if requestErr != nil {
  25952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25953. return
  25954. }
  25955. body, ioErr := ioutil.ReadAll(resp.Body)
  25956. if ioErr != nil {
  25957. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25959. return
  25960. }
  25961. var respJSON map[string]interface{}
  25962. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25965. return
  25966. }
  25967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25968. result, _ := json.Marshal(respJSON)
  25969. if miConfig.Code == "H15049901371" {
  25970. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25971. utils.ErrorLog("解析失败:%v", err)
  25972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25973. return
  25974. }
  25975. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25976. res.Output = resSeven10265.Output
  25977. res.ErrMsg = resSeven10265.ErrMsg
  25978. res.Cainfo = resSeven10265.Cainfo
  25979. res.WarnMsg = resSeven10265.WarnMsg
  25980. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25981. res.Infcode = infocode
  25982. } else {
  25983. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25984. utils.ErrorLog("解析失败:%v", err)
  25985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25986. return
  25987. }
  25988. }
  25989. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25990. if reg_type == 11 && his.Insutype == "390" {
  25991. reg_type = 110104
  25992. }
  25993. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25994. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25995. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25996. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25997. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25998. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25999. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26000. resp, requestErr := http.Get(api)
  26001. if requestErr != nil {
  26002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26003. return
  26004. }
  26005. body, ioErr := ioutil.ReadAll(resp.Body)
  26006. if ioErr != nil {
  26007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26009. return
  26010. }
  26011. var respJSON map[string]interface{}
  26012. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26015. return
  26016. }
  26017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26018. result, _ := json.Marshal(respJSON)
  26019. if miConfig.Code == "H15049901371" {
  26020. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26021. utils.ErrorLog("解析失败:%v", err)
  26022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26023. return
  26024. }
  26025. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26026. res.Output = resSeven10265.Output
  26027. res.ErrMsg = resSeven10265.ErrMsg
  26028. res.Cainfo = resSeven10265.Cainfo
  26029. res.WarnMsg = resSeven10265.WarnMsg
  26030. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26031. res.Infcode = infocode
  26032. } else {
  26033. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26034. utils.ErrorLog("解析失败:%v", err)
  26035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26036. return
  26037. }
  26038. }
  26039. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26040. if reg_type == 11 && his.Insutype == "390" {
  26041. reg_type = 110104
  26042. }
  26043. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26044. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26045. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26046. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26047. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26048. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26049. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26050. resp, requestErr := http.Get(api)
  26051. if requestErr != nil {
  26052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26053. return
  26054. }
  26055. body, ioErr := ioutil.ReadAll(resp.Body)
  26056. if ioErr != nil {
  26057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26059. return
  26060. }
  26061. var respJSON map[string]interface{}
  26062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26065. return
  26066. }
  26067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26068. result, _ := json.Marshal(respJSON)
  26069. if miConfig.Code == "H15049901371" {
  26070. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26071. utils.ErrorLog("解析失败:%v", err)
  26072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26073. return
  26074. }
  26075. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26076. res.Output = resSeven10265.Output
  26077. res.ErrMsg = resSeven10265.ErrMsg
  26078. res.Cainfo = resSeven10265.Cainfo
  26079. res.WarnMsg = resSeven10265.WarnMsg
  26080. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26081. res.Infcode = infocode
  26082. } else {
  26083. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26084. utils.ErrorLog("解析失败:%v", err)
  26085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26086. return
  26087. }
  26088. }
  26089. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26090. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26091. if result3101.Infcode == "0" {
  26092. if len(result3101.Output.Result) > 0 {
  26093. var errMsgs []string
  26094. for _, item := range result3101.Output.Result {
  26095. errMsgs = append(errMsgs, item.VolaCont)
  26096. }
  26097. c.ServeSuccessJSON(map[string]interface{}{
  26098. "failed_code": -10,
  26099. "msg": errMsgs,
  26100. })
  26101. return
  26102. } else {
  26103. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26104. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26105. bas := strings.Split(psn_info.CardInfo, "|")
  26106. if his.IdCardType == 1 {
  26107. cert_no = bas[2]
  26108. } else if his.IdCardType == 3 {
  26109. cert_no = his.Certno
  26110. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26111. } else if his.IdCardType == 4 {
  26112. cert_no = his.Certno
  26113. psn_info.VerifyNumber = psn_info.VerifyNumber
  26114. }
  26115. var api string
  26116. if miConfig.MdtrtareaAdmvs == "320921" {
  26117. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26118. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26119. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26120. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26121. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26122. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26123. "&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
  26124. } else {
  26125. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26126. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26127. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26128. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26129. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26130. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26131. "&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
  26132. }
  26133. resp, requestErr := http.Get(api)
  26134. if requestErr != nil {
  26135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26136. return
  26137. }
  26138. body, ioErr := ioutil.ReadAll(resp.Body)
  26139. if ioErr != nil {
  26140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26142. return
  26143. }
  26144. var respJSON map[string]interface{}
  26145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26148. return
  26149. }
  26150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26151. result, _ := json.Marshal(respJSON)
  26152. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26153. utils.ErrorLog("解析失败:%v", err)
  26154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26155. return
  26156. }
  26157. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26158. res.Output = resSeven10265.Output
  26159. res.ErrMsg = resSeven10265.ErrMsg
  26160. res.Cainfo = resSeven10265.Cainfo
  26161. res.WarnMsg = resSeven10265.WarnMsg
  26162. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26163. res.Infcode = infocode
  26164. }
  26165. }
  26166. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26167. psn_info, _ := service.GetPsnByPatientId(id)
  26168. var verify_number string
  26169. if psn_info.IdCardType == 4 {
  26170. verify_number = psn_info.VerifyNumber
  26171. } else if psn_info.IdCardType == 1 {
  26172. bas := strings.Split(psn_info.CardInfo, "|")
  26173. cardNumber := bas[2]
  26174. verify_number = cardNumber
  26175. } else {
  26176. psn_info.IdCardType = 2
  26177. verify_number = psn_info.Certno
  26178. }
  26179. var api string
  26180. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26181. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26182. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26183. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26184. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26185. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26186. "&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
  26187. resp, requestErr := http.Get(api)
  26188. if requestErr != nil {
  26189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26190. return
  26191. }
  26192. body, ioErr := ioutil.ReadAll(resp.Body)
  26193. if ioErr != nil {
  26194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26196. return
  26197. }
  26198. var respJSON map[string]interface{}
  26199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26202. return
  26203. }
  26204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26205. result, _ := json.Marshal(respJSON)
  26206. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26207. utils.ErrorLog("解析失败:%v", err)
  26208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26209. return
  26210. }
  26211. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26212. res.Output = resSeven10265.Output
  26213. res.ErrMsg = resSeven10265.ErrMsg
  26214. res.Cainfo = resSeven10265.Cainfo
  26215. res.WarnMsg = resSeven10265.WarnMsg
  26216. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26217. res.Infcode = infocode
  26218. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26219. var cert_no string
  26220. if his.IdCardType == 4 {
  26221. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26222. cert_no = psn_info.VerifyNumber
  26223. 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)
  26224. } else if his.IdCardType == 1 {
  26225. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26226. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26227. 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)
  26228. }
  26229. //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)
  26230. var dat map[string]interface{}
  26231. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26232. fmt.Println(dat)
  26233. } else {
  26234. fmt.Println(err)
  26235. }
  26236. saveLog(result2, src_resquest, "2207", "结算")
  26237. userJSONBytes, _ := json.Marshal(dat)
  26238. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26239. utils.ErrorLog("解析失败:%v", err)
  26240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26241. return
  26242. }
  26243. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26244. res.Output = resSeven10265.Output
  26245. res.ErrMsg = resSeven10265.ErrMsg
  26246. res.Cainfo = resSeven10265.Cainfo
  26247. res.WarnMsg = resSeven10265.WarnMsg
  26248. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26249. res.Infcode = infocode
  26250. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26251. res2 := c.GetoleInfo()
  26252. if res2.Infcode == 0 {
  26253. var result string
  26254. var request_log string
  26255. var result_log string
  26256. if res2.Output.MdtrtCertType == "02" {
  26257. 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)
  26258. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26259. } else if res2.Output.MdtrtCertType == "01" {
  26260. 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)
  26261. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26262. } else {
  26263. 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)
  26264. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26265. }
  26266. var dat map[string]interface{}
  26267. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26268. fmt.Println(dat)
  26269. } else {
  26270. fmt.Println(err)
  26271. }
  26272. userJSONBytes, _ := json.Marshal(dat)
  26273. var res5 ResultTwo
  26274. //var resTwo10265 ResultTwo10265
  26275. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26276. utils.ErrorLog("解析失败:%v", err)
  26277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26278. return
  26279. }
  26280. if res5.Infcode == -1 {
  26281. c.ServeSuccessJSON(map[string]interface{}{
  26282. "failed_code": -10,
  26283. "msg": res5.ErrMsg,
  26284. })
  26285. return
  26286. }
  26287. var insutypes []string
  26288. var insutype string
  26289. var is390 int = 0
  26290. var is310 int = 0
  26291. for _, item := range res5.Output.Iinfo {
  26292. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26293. insutypes = append(insutypes, item.Insutype)
  26294. }
  26295. }
  26296. if len(insutypes) == 1 {
  26297. insutype = insutypes[0]
  26298. } else {
  26299. for _, i := range insutypes {
  26300. if i == "390" {
  26301. is390 = 1
  26302. }
  26303. if i == "310" {
  26304. is310 = 1
  26305. }
  26306. }
  26307. }
  26308. if is390 == 1 {
  26309. insutype = "390"
  26310. }
  26311. if is310 == 1 {
  26312. insutype = "310"
  26313. }
  26314. if len(insutypes) == 0 {
  26315. insutype = "310"
  26316. }
  26317. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26318. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26319. infoStr := string(Iinfos)
  26320. idetinfoStr := string(Idetinfos)
  26321. psn := &models.HisPsn{
  26322. PsnNo: res5.Output.Baseinfo.PsnNo,
  26323. PatientId: id,
  26324. Certno: res5.Output.Baseinfo.Certno,
  26325. Gend: res5.Output.Baseinfo.Gend,
  26326. Naty: res5.Output.Baseinfo.Naty,
  26327. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26328. PsnName: res5.Output.Baseinfo.PsnName,
  26329. Idetinfo: idetinfoStr,
  26330. Insuinfo: infoStr,
  26331. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26332. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26333. VerifyNumber: res2.Output.EcToken,
  26334. }
  26335. if res2.Output.MdtrtCertType == "01" {
  26336. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26337. psn.VerifyNumber = res2.Output.EcToken
  26338. } else if res2.Output.MdtrtCertType == "02" {
  26339. psn.VerifyNumber = res2.Output.CardNo
  26340. } else {
  26341. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26342. }
  26343. service.CreateHisPsn(psn)
  26344. if res2.Output.MdtrtCertType == "01" {
  26345. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26346. token := res2.Output.EcToken
  26347. 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)
  26348. } else if res2.Output.MdtrtCertType == "02" {
  26349. 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)
  26350. } else {
  26351. 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)
  26352. }
  26353. var dat2 map[string]interface{}
  26354. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26355. fmt.Println(dat2)
  26356. } else {
  26357. fmt.Println(err)
  26358. }
  26359. userJSONBytes3, _ := json.Marshal(dat2)
  26360. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26361. utils.ErrorLog("解析失败:%v", err)
  26362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26363. return
  26364. }
  26365. saveLog(result2, src_resquest, "2207", "结算")
  26366. } else {
  26367. c.ServeSuccessJSON(map[string]interface{}{
  26368. "failed_code": -10,
  26369. "msg": res2.ErrMsg,
  26370. })
  26371. return
  26372. }
  26373. } else {
  26374. if miConfig.Code == "H15049901371" {
  26375. //赤峰地区国家医保医疗类别
  26376. //职工透析:医疗类别选特殊情况门诊990502
  26377. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26378. var med_type string
  26379. if his.Insutype == "390" {
  26380. if reg_type == 14 {
  26381. med_type = "9933"
  26382. } else if reg_type == 11 {
  26383. med_type = "11"
  26384. }
  26385. } else if his.Insutype == "310" {
  26386. if reg_type == 14 {
  26387. med_type = "990502"
  26388. } else if reg_type == 11 {
  26389. med_type = "11"
  26390. }
  26391. }
  26392. 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)
  26393. } else {
  26394. if his.IdCardType == 4 {
  26395. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26396. var token string
  26397. token = psn_info.VerifyNumber
  26398. 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)
  26399. } else {
  26400. if his.IdCardType == 1 {
  26401. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26402. bas := strings.Split(psn_info.CardInfo, "|")
  26403. basNumber := bas[2]
  26404. cert_no = basNumber
  26405. }
  26406. 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)
  26407. }
  26408. }
  26409. //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)
  26410. var dat map[string]interface{}
  26411. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26412. fmt.Println(dat)
  26413. } else {
  26414. fmt.Println(err)
  26415. }
  26416. saveLog(result2, src_resquest, "2207", "结算")
  26417. userJSONBytes, _ := json.Marshal(dat)
  26418. if miConfig.Code == "H15049901371" {
  26419. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26420. utils.ErrorLog("解析失败:%v", err)
  26421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26422. return
  26423. }
  26424. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26425. res.Output = resSeven10265.Output
  26426. res.ErrMsg = resSeven10265.ErrMsg
  26427. res.Cainfo = resSeven10265.Cainfo
  26428. res.WarnMsg = resSeven10265.WarnMsg
  26429. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26430. res.Infcode = infocode
  26431. } else {
  26432. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26433. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26434. utils.ErrorLog("解析失败:%v", err)
  26435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26436. return
  26437. }
  26438. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26439. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26440. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26441. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26442. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26443. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26444. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26445. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26446. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26447. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26448. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26449. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26450. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26451. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26452. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26453. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26454. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26455. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26456. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26457. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26458. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26459. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26460. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26461. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26462. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26463. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26464. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26465. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26466. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26467. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26468. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26469. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26470. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26471. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26472. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26473. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26474. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26475. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26476. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26477. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26478. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26479. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26480. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26481. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26482. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26483. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26484. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26485. res.Cainfo = gzresSeven10265Two.Cainfo
  26486. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26487. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26488. //res.Infcode = infocode
  26489. } else {
  26490. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26491. utils.ErrorLog("解析失败:%v", err)
  26492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26493. return
  26494. }
  26495. }
  26496. }
  26497. }
  26498. if res.Infcode == -1 {
  26499. errlog := &models.HisOrderError{
  26500. UserOrgId: adminUser.CurrentOrgId,
  26501. Ctime: time.Now().Unix(),
  26502. Mtime: time.Now().Unix(),
  26503. Number: chrg_bchno,
  26504. ErrMsg: res.ErrMsg,
  26505. Status: 1,
  26506. PatientId: id,
  26507. RecordTime: recordDateTime,
  26508. Stage: 6,
  26509. }
  26510. service.CreateErrMsgLog(errlog)
  26511. c.ServeSuccessJSON(map[string]interface{}{
  26512. "failed_code": -10,
  26513. "msg": res.ErrMsg,
  26514. })
  26515. return
  26516. } else {
  26517. sickConfig, _ := service.FindSickById(his.SickType)
  26518. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26519. order.OrderStatus = 2
  26520. order.Status = 1
  26521. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26522. order.SetlId = res.Output.Setlinfo.SetlID
  26523. order.PsnNo = res.Output.Setlinfo.PsnNo
  26524. order.PsnName = res.Output.Setlinfo.PsnName
  26525. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26526. order.Certno = res.Output.Setlinfo.Certno
  26527. order.Gend = res.Output.Setlinfo.Gend
  26528. order.Naty = res.Output.Setlinfo.Naty
  26529. order.Age = res.Output.Setlinfo.Age
  26530. order.Insutype = res.Output.Setlinfo.Insutype
  26531. order.PsnType = res.Output.Setlinfo.PsnType
  26532. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26533. order.SetlTime = res.Output.Setlinfo.SetlTime
  26534. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26535. if res.Output.Setlinfo.MedType == "140101" {
  26536. order.MedType = "14"
  26537. } else {
  26538. if res.Output.Setlinfo.MedType == "110104" {
  26539. order.MedType = "11"
  26540. } else {
  26541. order.MedType = res.Output.Setlinfo.MedType
  26542. }
  26543. }
  26544. if reg_type == 1112 {
  26545. order.MedType = "1112"
  26546. }
  26547. if reg_type == 1111 {
  26548. order.MedType = "1111"
  26549. }
  26550. order.ClrType = res.Output.Setlinfo.ClrType
  26551. if adminUser.CurrentOrgId == 10480 {
  26552. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26553. order.ClrType = "11"
  26554. } else {
  26555. order.ClrType = "9903"
  26556. }
  26557. }
  26558. if adminUser.CurrentOrgId == 10721 {
  26559. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26560. order.ClrType = "11"
  26561. } else {
  26562. order.ClrType = "9903"
  26563. }
  26564. }
  26565. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26566. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26567. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26568. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26569. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26570. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26571. order.HifpPay = res.Output.Setlinfo.HifpPay
  26572. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26573. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26574. order.HifesPay = res.Output.Setlinfo.HifesPay
  26575. order.HifobPay = res.Output.Setlinfo.HifobPay
  26576. order.MafPay = res.Output.Setlinfo.MafPay
  26577. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26578. order.OthPay = res.Output.Setlinfo.OthPay
  26579. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26580. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26581. order.AcctPay = res.Output.Setlinfo.AcctPay
  26582. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26583. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26584. order.Balc = res.Output.Setlinfo.Balc
  26585. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26586. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26587. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26588. //order.ClrType = res.Output.Setlinfo.ClrType
  26589. order.ClrWay = res.Output.Setlinfo.ClrWay
  26590. order.Creator = order.Creator
  26591. order.Modify = roles.AdminUserId
  26592. order.RequestLog = src_resquest
  26593. order.FaPiaoNumber = fapiao_number
  26594. order.FaPiaoCode = fapiao_code
  26595. order.SickName = sickConfig.ClassName
  26596. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26597. //detailStr := string(setlDetail)
  26598. //order.SetlDetail = detailStr
  26599. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26600. err = service.UpDateOrder(order)
  26601. if err == nil {
  26602. //判断是否使用了押金
  26603. if dec_way == "true" {
  26604. tmpstring := strconv.FormatInt(order.ID, 10)
  26605. order.Decimal = decimal
  26606. service.UpDateOrder(order)
  26607. //扣押金
  26608. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26609. if errmsg != nil {
  26610. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26611. return
  26612. }
  26613. }
  26614. c.ServeSuccessJSON(map[string]interface{}{
  26615. "msg": "结算成功",
  26616. })
  26617. } else {
  26618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26619. return
  26620. }
  26621. }
  26622. } else {
  26623. adminUser := c.GetAdminUserInfo()
  26624. errlog := &models.HisOrderError{
  26625. UserOrgId: adminUser.CurrentOrgId,
  26626. Ctime: time.Now().Unix(),
  26627. Mtime: time.Now().Unix(),
  26628. ErrMsg: res.ErrMsg,
  26629. Status: 1,
  26630. PatientId: id,
  26631. RecordTime: recordDateTime,
  26632. Stage: 4,
  26633. }
  26634. service.CreateErrMsgLog(errlog)
  26635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26636. return
  26637. }
  26638. } else {
  26639. adminUser := c.GetAdminUserInfo()
  26640. errlog := &models.HisOrderError{
  26641. UserOrgId: adminUser.CurrentOrgId,
  26642. Ctime: time.Now().Unix(),
  26643. Mtime: time.Now().Unix(),
  26644. ErrMsg: res.ErrMsg,
  26645. Status: 1,
  26646. PatientId: id,
  26647. RecordTime: recordDateTime,
  26648. Stage: 4,
  26649. }
  26650. service.CreateErrMsgLog(errlog)
  26651. c.ServeSuccessJSON(map[string]interface{}{
  26652. "failed_code": -10,
  26653. "msg": res.ErrMsg,
  26654. })
  26655. return
  26656. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26657. //return
  26658. }
  26659. }
  26660. }
  26661. } else if tempOrder.ID > 0 {
  26662. if tempOrder.IsPre == 1 {
  26663. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26664. var rf []*ResultFive
  26665. json.Unmarshal([]byte(his.Iinfo), &rf)
  26666. chrg_bchno := tempOrder.Number
  26667. cert_no := his.Certno
  26668. var insutypes []string
  26669. var insutype string
  26670. var is390 int = 0
  26671. var is310 int = 0
  26672. for _, item := range rf {
  26673. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26674. insutypes = append(insutypes, item.Insutype)
  26675. }
  26676. }
  26677. if len(insutypes) == 1 {
  26678. insutype = insutypes[0]
  26679. } else {
  26680. for _, i := range insutypes {
  26681. if i == "390" {
  26682. is390 = 1
  26683. }
  26684. if i == "310" {
  26685. is310 = 1
  26686. }
  26687. }
  26688. }
  26689. if is390 == 1 {
  26690. insutype = "390"
  26691. }
  26692. if is310 == 1 {
  26693. insutype = "310"
  26694. }
  26695. if len(insutypes) == 0 {
  26696. insutype = "310"
  26697. }
  26698. if len(insutypes) == 2 {
  26699. insutype = strconv.FormatInt(his.SocialType, 10)
  26700. }
  26701. //insutype = "390"
  26702. if his.IdCardType == 1 {
  26703. // cert_no = his.MedicalInsuranceNumber
  26704. cert_no = his.Certno
  26705. } else {
  26706. cert_no = his.Certno
  26707. }
  26708. var res ResultSeven
  26709. var ahres ResultSevenAH
  26710. var resSeven10265 ResultSeven10265
  26711. var gzresSeven10265Two GZResultSeven10265Two
  26712. var src_resquest string
  26713. var result2 string
  26714. if miConfig.MdtrtareaAdmvs == "450721" {
  26715. res2 := c.GetoleInfo()
  26716. if res2.Infcode == 0 {
  26717. var result string
  26718. var request_log string
  26719. var result_log string
  26720. if res2.Output.MdtrtCertType == "02" {
  26721. 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)
  26722. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26723. } else if res2.Output.MdtrtCertType == "01" {
  26724. 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)
  26725. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26726. } else {
  26727. 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)
  26728. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26729. }
  26730. var dat map[string]interface{}
  26731. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26732. fmt.Println(dat)
  26733. } else {
  26734. fmt.Println(err)
  26735. }
  26736. userJSONBytes, _ := json.Marshal(dat)
  26737. var res5 ResultTwo
  26738. //var resTwo10265 ResultTwo10265
  26739. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26740. utils.ErrorLog("解析失败:%v", err)
  26741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26742. return
  26743. }
  26744. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26745. if res5.Infcode == -1 {
  26746. c.ServeSuccessJSON(map[string]interface{}{
  26747. "failed_code": -10,
  26748. "msg": res5.ErrMsg,
  26749. })
  26750. return
  26751. }
  26752. var insutypes []string
  26753. var insutype string
  26754. var is390 int = 0
  26755. var is310 int = 0
  26756. for _, item := range res5.Output.Iinfo {
  26757. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26758. insutypes = append(insutypes, item.Insutype)
  26759. }
  26760. }
  26761. if len(insutypes) == 1 {
  26762. insutype = insutypes[0]
  26763. } else {
  26764. for _, i := range insutypes {
  26765. if i == "390" {
  26766. is390 = 1
  26767. }
  26768. if i == "310" {
  26769. is310 = 1
  26770. }
  26771. }
  26772. }
  26773. if is390 == 1 {
  26774. insutype = "390"
  26775. }
  26776. if is310 == 1 {
  26777. insutype = "310"
  26778. }
  26779. if len(insutypes) == 0 {
  26780. insutype = "310"
  26781. }
  26782. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26783. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26784. infoStr := string(Iinfos)
  26785. idetinfoStr := string(Idetinfos)
  26786. psn := &models.HisPsn{
  26787. PsnNo: res5.Output.Baseinfo.PsnNo,
  26788. PatientId: id,
  26789. Certno: res5.Output.Baseinfo.Certno,
  26790. Gend: res5.Output.Baseinfo.Gend,
  26791. Naty: res5.Output.Baseinfo.Naty,
  26792. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26793. PsnName: res5.Output.Baseinfo.PsnName,
  26794. Idetinfo: idetinfoStr,
  26795. Insuinfo: infoStr,
  26796. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26797. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26798. VerifyNumber: res2.Output.EcToken,
  26799. }
  26800. service.CreateHisPsn(psn)
  26801. if res2.Output.MdtrtCertType == "01" {
  26802. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26803. token := res2.Output.EcToken
  26804. 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)
  26805. } else if res2.Output.MdtrtCertType == "02" {
  26806. 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)
  26807. } else {
  26808. 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)
  26809. }
  26810. var dat2 map[string]interface{}
  26811. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26812. fmt.Println(dat2)
  26813. } else {
  26814. fmt.Println(err)
  26815. }
  26816. userJSONBytes3, _ := json.Marshal(dat2)
  26817. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26818. utils.ErrorLog("解析失败:%v", err)
  26819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26820. return
  26821. }
  26822. saveLog(result2, src_resquest, "2207", "结算")
  26823. } else {
  26824. c.ServeSuccessJSON(map[string]interface{}{
  26825. "failed_code": -10,
  26826. "msg": res2.ErrMsg,
  26827. })
  26828. return
  26829. }
  26830. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26831. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26832. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26833. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26834. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26835. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26836. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26837. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26838. resp, requestErr := http.Get(api)
  26839. if requestErr != nil {
  26840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26841. return
  26842. }
  26843. body, ioErr := ioutil.ReadAll(resp.Body)
  26844. if ioErr != nil {
  26845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26847. return
  26848. }
  26849. var respJSON map[string]interface{}
  26850. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26853. return
  26854. }
  26855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26856. result, _ := json.Marshal(respJSON)
  26857. fmt.Println("log")
  26858. fmt.Println(string(result))
  26859. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26860. utils.ErrorLog("解析失败:%v", err)
  26861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26862. return
  26863. }
  26864. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26865. if reg_type == 11 && his.Insutype == "390" {
  26866. reg_type = 110104
  26867. }
  26868. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26869. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26870. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26871. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26872. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26873. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26874. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26875. resp, requestErr := http.Get(api)
  26876. if requestErr != nil {
  26877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26878. return
  26879. }
  26880. body, ioErr := ioutil.ReadAll(resp.Body)
  26881. if ioErr != nil {
  26882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26884. return
  26885. }
  26886. var respJSON map[string]interface{}
  26887. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26890. return
  26891. }
  26892. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26893. result, _ := json.Marshal(respJSON)
  26894. fmt.Println("log")
  26895. fmt.Println(string(result))
  26896. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26897. utils.ErrorLog("解析失败:%v", err)
  26898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26899. return
  26900. }
  26901. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26902. if reg_type == 11 && his.Insutype == "390" {
  26903. reg_type = 110104
  26904. }
  26905. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26906. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26907. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26908. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26909. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26910. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26911. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26912. resp, requestErr := http.Get(api)
  26913. if requestErr != nil {
  26914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26915. return
  26916. }
  26917. body, ioErr := ioutil.ReadAll(resp.Body)
  26918. if ioErr != nil {
  26919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26921. return
  26922. }
  26923. var respJSON map[string]interface{}
  26924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26927. return
  26928. }
  26929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26930. result, _ := json.Marshal(respJSON)
  26931. fmt.Println("log")
  26932. fmt.Println(string(result))
  26933. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26934. utils.ErrorLog("解析失败:%v", err)
  26935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26936. return
  26937. }
  26938. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26939. if reg_type == 11 && his.Insutype == "390" {
  26940. reg_type = 110104
  26941. }
  26942. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26943. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26944. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26945. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26946. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26947. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26948. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26949. resp, requestErr := http.Get(api)
  26950. if requestErr != nil {
  26951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26952. return
  26953. }
  26954. body, ioErr := ioutil.ReadAll(resp.Body)
  26955. if ioErr != nil {
  26956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26958. return
  26959. }
  26960. var respJSON map[string]interface{}
  26961. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26964. return
  26965. }
  26966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26967. result, _ := json.Marshal(respJSON)
  26968. fmt.Println("log")
  26969. fmt.Println(string(result))
  26970. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26971. utils.ErrorLog("解析失败:%v", err)
  26972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26973. return
  26974. }
  26975. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26976. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  26977. if result3101.Infcode == "0" {
  26978. if len(result3101.Output.Result) > 0 {
  26979. var errMsgs []string
  26980. for _, item := range result3101.Output.Result {
  26981. errMsgs = append(errMsgs, item.VolaCont)
  26982. }
  26983. c.ServeSuccessJSON(map[string]interface{}{
  26984. "failed_code": -10,
  26985. "msg": errMsgs,
  26986. })
  26987. return
  26988. } else {
  26989. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26990. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26991. bas := strings.Split(psn_info.CardInfo, "|")
  26992. if his.IdCardType == 1 {
  26993. cert_no = bas[2]
  26994. } else if his.IdCardType == 3 {
  26995. cert_no = his.Certno
  26996. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26997. } else if his.IdCardType == 4 {
  26998. cert_no = his.Certno
  26999. psn_info.VerifyNumber = psn_info.VerifyNumber
  27000. }
  27001. //江苏地区国家医保医疗类别
  27002. //职工透析:医疗类别选特殊情况门诊9933
  27003. //居民血透门慢: 医疗类别选门诊慢病1402
  27004. //var med_type string
  27005. //if his.Insutype == "310" {
  27006. // if reg_type == 14 {
  27007. // med_type = "9933"
  27008. // } else if reg_type == 11 {
  27009. // med_type = "11"
  27010. //
  27011. // }
  27012. //} else if his.Insutype == "390" {
  27013. // if reg_type == 14 {
  27014. // med_type = "1402"
  27015. // } else if reg_type == 11 {
  27016. // med_type = "11"
  27017. // }
  27018. //}
  27019. var api string
  27020. if miConfig.MdtrtareaAdmvs == "320921" {
  27021. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27022. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27023. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27024. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27025. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27026. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27027. "&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
  27028. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27029. } else {
  27030. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27031. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27032. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27033. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27034. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27035. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27036. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27037. "&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
  27038. }
  27039. resp, requestErr := http.Get(api)
  27040. if requestErr != nil {
  27041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27042. return
  27043. }
  27044. body, ioErr := ioutil.ReadAll(resp.Body)
  27045. if ioErr != nil {
  27046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27048. return
  27049. }
  27050. var respJSON map[string]interface{}
  27051. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27054. return
  27055. }
  27056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27057. result, _ := json.Marshal(respJSON)
  27058. fmt.Println("log")
  27059. fmt.Println(string(result))
  27060. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27061. utils.ErrorLog("解析失败:%v", err)
  27062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27063. return
  27064. }
  27065. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27066. res.Output = resSeven10265.Output
  27067. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27068. res.ErrMsg = resSeven10265.ErrMsg
  27069. res.Cainfo = resSeven10265.Cainfo
  27070. res.WarnMsg = resSeven10265.WarnMsg
  27071. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27072. res.Infcode = infocode
  27073. }
  27074. }
  27075. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27076. psn_info, _ := service.GetPsnByPatientId(id)
  27077. var verify_number string
  27078. if psn_info.IdCardType == 4 {
  27079. verify_number = psn_info.VerifyNumber
  27080. } else if psn_info.IdCardType == 1 {
  27081. bas := strings.Split(psn_info.CardInfo, "|")
  27082. cardNumber := bas[2]
  27083. verify_number = cardNumber
  27084. } else {
  27085. verify_number = psn_info.Certno
  27086. psn_info.IdCardType = 2
  27087. }
  27088. var api string
  27089. new_chrg_bchno := chrg_bchno
  27090. if adminUser.CurrentOrgId == 10265 {
  27091. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27092. new_chrg_bchno = "0000"
  27093. }
  27094. }
  27095. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27096. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27097. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27098. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27099. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27100. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27101. "&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
  27102. resp, requestErr := http.Get(api)
  27103. if requestErr != nil {
  27104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27105. return
  27106. }
  27107. body, ioErr := ioutil.ReadAll(resp.Body)
  27108. if ioErr != nil {
  27109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27111. return
  27112. }
  27113. var respJSON map[string]interface{}
  27114. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27117. return
  27118. }
  27119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27120. result, _ := json.Marshal(respJSON)
  27121. fmt.Println("log")
  27122. fmt.Println(string(result))
  27123. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27124. utils.ErrorLog("解析失败:%v", err)
  27125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27126. return
  27127. }
  27128. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27129. res.Output = resSeven10265.Output
  27130. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27131. res.ErrMsg = resSeven10265.ErrMsg
  27132. res.Cainfo = resSeven10265.Cainfo
  27133. res.WarnMsg = resSeven10265.WarnMsg
  27134. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27135. res.Infcode = infocode
  27136. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27137. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27138. var cert_no string
  27139. if his.IdCardType == 1 {
  27140. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27141. } else {
  27142. cert_no = psn_info.VerifyNumber
  27143. }
  27144. 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)
  27145. var dat map[string]interface{}
  27146. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27147. fmt.Println(dat)
  27148. } else {
  27149. fmt.Println(err)
  27150. }
  27151. saveLog(result2, src_resquest, "2207", "结算")
  27152. userJSONBytes, _ := json.Marshal(dat)
  27153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27154. utils.ErrorLog("解析失败:%v", err)
  27155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27156. return
  27157. }
  27158. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27159. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27160. var cert_no string
  27161. var card_sn string
  27162. if his.IdCardType == 1 {
  27163. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27164. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27165. bas := strings.Split(psn_info.CardInfo, "|")
  27166. card_sn = bas[3]
  27167. } else if his.IdCardType == 2 {
  27168. cert_no = his.IdCardNo
  27169. } else {
  27170. cert_no = psn_info.VerifyNumber
  27171. }
  27172. var rf []*ResultFive
  27173. json.Unmarshal([]byte(his.Iinfo), &rf)
  27174. var psn_type string
  27175. for _, item := range rf {
  27176. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27177. psn_type = item.PsnType
  27178. }
  27179. }
  27180. 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)
  27181. var dat map[string]interface{}
  27182. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27183. fmt.Println(dat)
  27184. } else {
  27185. fmt.Println(err)
  27186. }
  27187. saveLog(result2, src_resquest, "2207", "结算")
  27188. userJSONBytes, _ := json.Marshal(dat)
  27189. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27190. utils.ErrorLog("解析失败:%v", err)
  27191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27192. return
  27193. }
  27194. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27195. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27196. var cert_no string
  27197. var card_sn string
  27198. if his.IdCardType == 1 {
  27199. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27200. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27201. //bas := strings.Split(psn_info.CardInfo, "|")
  27202. card_sn = ""
  27203. } else if his.IdCardType == 2 {
  27204. cert_no = his.IdCardNo
  27205. } else {
  27206. cert_no = psn_info.VerifyNumber
  27207. }
  27208. var rf []*ResultFive
  27209. json.Unmarshal([]byte(his.Iinfo), &rf)
  27210. var psn_type string
  27211. for _, item := range rf {
  27212. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27213. psn_type = item.PsnType
  27214. }
  27215. }
  27216. 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)
  27217. var dat map[string]interface{}
  27218. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27219. fmt.Println(dat)
  27220. } else {
  27221. fmt.Println(err)
  27222. }
  27223. saveLog(result2, src_resquest, "2207", "结算")
  27224. userJSONBytes, _ := json.Marshal(dat)
  27225. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27226. utils.ErrorLog("解析失败:%v", err)
  27227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27228. return
  27229. }
  27230. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27231. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27232. if his.IdCardType == 1 {
  27233. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27234. bas := strings.Split(psn_info.CardInfo, "|")
  27235. cert_no = bas[2]
  27236. } else if his.IdCardType == 3 {
  27237. cert_no = his.Certno
  27238. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27239. } else if his.IdCardType == 4 {
  27240. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27241. cert_no = psn_info.VerifyNumber
  27242. psn_info.VerifyNumber = psn_info.VerifyNumber
  27243. } else {
  27244. cert_no = his.Certno
  27245. psn_info.VerifyNumber = his.Certno
  27246. }
  27247. var api string
  27248. var med_type string
  27249. if his.Insutype == "390" {
  27250. if reg_type == 992102 {
  27251. med_type = "992102"
  27252. }
  27253. if reg_type == 140104 {
  27254. med_type = "140104"
  27255. }
  27256. if reg_type == 140201 {
  27257. med_type = "140201"
  27258. }
  27259. if reg_type == 14 {
  27260. med_type = "14"
  27261. }
  27262. } else if his.Insutype == "310" {
  27263. if reg_type == 992102 {
  27264. med_type = "992102"
  27265. }
  27266. if reg_type == 140104 {
  27267. med_type = "140104"
  27268. }
  27269. if reg_type == 140201 {
  27270. med_type = "140201"
  27271. }
  27272. if reg_type == 14 {
  27273. med_type = "14"
  27274. }
  27275. }
  27276. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27277. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27278. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27279. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27280. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27281. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27282. "&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
  27283. resp, requestErr := http.Get(api)
  27284. if requestErr != nil {
  27285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27286. return
  27287. }
  27288. body, ioErr := ioutil.ReadAll(resp.Body)
  27289. if ioErr != nil {
  27290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27292. return
  27293. }
  27294. var respJSON map[string]interface{}
  27295. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27298. return
  27299. }
  27300. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27301. if status == "0" {
  27302. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27303. c.ServeSuccessJSON(map[string]interface{}{
  27304. "failed_code": -10,
  27305. "msg": err_msg,
  27306. })
  27307. return
  27308. }
  27309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27310. result, _ := json.Marshal(respJSON)
  27311. fmt.Println("log")
  27312. fmt.Println(string(result))
  27313. if err := json.Unmarshal(result, &ahres); err != nil {
  27314. utils.ErrorLog("解析失败:%v", err)
  27315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27316. return
  27317. }
  27318. res.InfRefmsgid = ahres.InfRefmsgid
  27319. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27320. // 创建对应的Time类型
  27321. t := time.UnixMilli(timestamp)
  27322. // 格式化成指定的日期字符串
  27323. str := t.Format("2006-01-02 15:04:05")
  27324. res.Output.Setlinfo.SetlTime = str
  27325. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27326. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27327. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27328. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27329. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27330. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27331. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27332. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27333. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27334. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27335. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27336. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27337. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27338. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27339. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27340. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27341. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27342. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27343. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27344. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27345. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27346. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27347. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27348. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27349. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27350. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27351. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27352. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27353. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27354. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27355. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27356. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27357. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27358. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27359. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27360. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27361. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27362. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27363. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27364. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27365. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27366. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27367. res.Output.Setldetail = ahres.Output.Setldetail
  27368. res.ErrMsg = ahres.ErrMsg
  27369. res.Cainfo = ahres.Cainfo
  27370. res.WarnMsg = ahres.WarnMsg
  27371. res.Infcode = ahres.Infcode
  27372. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27373. res.Output.Setlinfo.ClrType = "11"
  27374. } else {
  27375. res.Output.Setlinfo.ClrType = "9903"
  27376. }
  27377. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27378. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27379. if his.IdCardType == 1 {
  27380. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27381. bas := strings.Split(psn_info.CardInfo, "|")
  27382. cert_no = bas[2]
  27383. } else if his.IdCardType == 3 {
  27384. cert_no = his.Certno
  27385. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27386. } else if his.IdCardType == 4 {
  27387. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27388. cert_no = his.Certno
  27389. psn_info.VerifyNumber = psn_info.VerifyNumber
  27390. } else {
  27391. cert_no = his.Certno
  27392. psn_info.VerifyNumber = his.Certno
  27393. }
  27394. var api string
  27395. var med_type string
  27396. if his.Insutype == "390" {
  27397. if reg_type == 992102 {
  27398. med_type = "992102"
  27399. }
  27400. if reg_type == 140104 {
  27401. med_type = "140104"
  27402. }
  27403. if reg_type == 14 {
  27404. med_type = "14"
  27405. }
  27406. if reg_type == 140201 {
  27407. med_type = "140201"
  27408. }
  27409. } else if his.Insutype == "310" {
  27410. if reg_type == 992102 {
  27411. med_type = "992102"
  27412. }
  27413. if reg_type == 14 {
  27414. med_type = "14"
  27415. }
  27416. if reg_type == 140104 {
  27417. med_type = "140104"
  27418. }
  27419. if reg_type == 140201 {
  27420. med_type = "140201"
  27421. }
  27422. }
  27423. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27424. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27425. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27426. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27427. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27428. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27429. "&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
  27430. resp, requestErr := http.Get(api)
  27431. if requestErr != nil {
  27432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27433. return
  27434. }
  27435. body, ioErr := ioutil.ReadAll(resp.Body)
  27436. if ioErr != nil {
  27437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27439. return
  27440. }
  27441. var respJSON map[string]interface{}
  27442. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27445. return
  27446. }
  27447. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27448. if status == "0" {
  27449. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27450. c.ServeSuccessJSON(map[string]interface{}{
  27451. "failed_code": -10,
  27452. "msg": err_msg,
  27453. })
  27454. return
  27455. }
  27456. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27457. result, _ := json.Marshal(respJSON)
  27458. fmt.Println("log")
  27459. fmt.Println(string(result))
  27460. if err := json.Unmarshal(result, &ahres); err != nil {
  27461. utils.ErrorLog("解析失败:%v", err)
  27462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27463. return
  27464. }
  27465. res.InfRefmsgid = ahres.InfRefmsgid
  27466. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27467. // 创建对应的Time类型
  27468. t := time.UnixMilli(timestamp)
  27469. // 格式化成指定的日期字符串
  27470. str := t.Format("2006-01-02 15:04:05")
  27471. res.Output.Setlinfo.SetlTime = str
  27472. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27473. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27474. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27475. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27476. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27477. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27478. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27479. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27480. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27481. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27482. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27483. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27484. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27485. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27486. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27487. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27488. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27489. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27490. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27491. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27492. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27493. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27494. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27495. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27496. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27497. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27498. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27499. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27500. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27501. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27502. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27503. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27504. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27505. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27506. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27507. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27508. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27509. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27510. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27511. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27512. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27513. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27514. res.Output.Setldetail = ahres.Output.Setldetail
  27515. res.ErrMsg = ahres.ErrMsg
  27516. res.Cainfo = ahres.Cainfo
  27517. res.WarnMsg = ahres.WarnMsg
  27518. res.Infcode = ahres.Infcode
  27519. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27520. res.Output.Setlinfo.ClrType = "11"
  27521. } else {
  27522. res.Output.Setlinfo.ClrType = "9903"
  27523. }
  27524. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27525. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27526. var cert_no string
  27527. if his.IdCardType == 1 {
  27528. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27529. } else if his.IdCardType == 2 {
  27530. cert_no = his.IdCardNo
  27531. } else {
  27532. cert_no = psn_info.VerifyNumber
  27533. }
  27534. 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, "")
  27535. var dat map[string]interface{}
  27536. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27537. fmt.Println(dat)
  27538. } else {
  27539. fmt.Println(err)
  27540. }
  27541. saveLog(result2, src_resquest, "2207", "结算")
  27542. userJSONBytes, _ := json.Marshal(dat)
  27543. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27544. utils.ErrorLog("解析失败:%v", err)
  27545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27546. return
  27547. }
  27548. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27549. psn_info, _ := service.GetPsnByPatientId(id)
  27550. var verify_number string
  27551. if psn_info.IdCardType == 4 {
  27552. verify_number = psn_info.VerifyNumber
  27553. } else if psn_info.IdCardType == 1 {
  27554. bas := strings.Split(psn_info.CardInfo, "|")
  27555. cardNumber := bas[2]
  27556. verify_number = cardNumber
  27557. } else {
  27558. verify_number = psn_info.Certno
  27559. psn_info.IdCardType = 2
  27560. }
  27561. var api string
  27562. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27563. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27564. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27565. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27566. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27567. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27568. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27569. resp, requestErr := http.Get(api)
  27570. if requestErr != nil {
  27571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27572. return
  27573. }
  27574. body, ioErr := ioutil.ReadAll(resp.Body)
  27575. if ioErr != nil {
  27576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27578. return
  27579. }
  27580. var respJSON map[string]interface{}
  27581. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27584. return
  27585. }
  27586. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27587. result, _ := json.Marshal(respJSON)
  27588. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27589. utils.ErrorLog("解析失败:%v", err)
  27590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27591. return
  27592. }
  27593. } else {
  27594. var src_resquest string
  27595. if miConfig.Code == "H15049901371" {
  27596. //赤峰地区国家医保医疗类别
  27597. //职工透析:医疗类别选特殊情况门诊990502
  27598. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27599. var med_type string
  27600. if his.Insutype == "390" {
  27601. if reg_type == 14 {
  27602. med_type = "9933"
  27603. } else if reg_type == 11 {
  27604. med_type = "11"
  27605. }
  27606. } else if his.Insutype == "310" {
  27607. if reg_type == 14 {
  27608. med_type = "990502"
  27609. } else if reg_type == 11 {
  27610. med_type = "11"
  27611. }
  27612. }
  27613. 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)
  27614. } else {
  27615. if his.IdCardType == 4 {
  27616. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27617. token := psn_info.VerifyNumber
  27618. 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)
  27619. } else {
  27620. 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)
  27621. }
  27622. }
  27623. var dat map[string]interface{}
  27624. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27625. fmt.Println(dat)
  27626. } else {
  27627. fmt.Println(err)
  27628. }
  27629. saveLog(result2, src_resquest, "2207", "结算")
  27630. userJSONBytes, _ := json.Marshal(dat)
  27631. if miConfig.Code == "H15049901371" {
  27632. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27633. utils.ErrorLog("解析失败:%v", err)
  27634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27635. return
  27636. }
  27637. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27638. res.Output = resSeven10265.Output
  27639. res.ErrMsg = resSeven10265.ErrMsg
  27640. res.Cainfo = resSeven10265.Cainfo
  27641. res.WarnMsg = resSeven10265.WarnMsg
  27642. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27643. res.Infcode = infocode
  27644. } else {
  27645. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27646. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27647. utils.ErrorLog("解析失败:%v", err)
  27648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27649. return
  27650. }
  27651. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27652. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27653. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27654. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27655. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27656. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27657. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27658. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27659. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27660. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27661. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27662. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27663. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27664. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27665. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27666. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27667. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27668. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27669. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27670. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27671. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27672. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27673. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27674. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27675. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27676. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27677. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27678. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27679. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27680. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27681. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27682. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27683. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27684. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27685. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27686. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27687. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27688. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27689. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27690. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27691. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27692. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27693. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27694. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27695. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27696. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27697. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27698. res.Cainfo = gzresSeven10265Two.Cainfo
  27699. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27700. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27701. //res.Infcode = infocode
  27702. } else {
  27703. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27704. utils.ErrorLog("解析失败:%v", err)
  27705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27706. return
  27707. }
  27708. }
  27709. }
  27710. }
  27711. if res.Infcode == -1 {
  27712. errlog := &models.HisOrderError{
  27713. UserOrgId: adminUser.CurrentOrgId,
  27714. Ctime: time.Now().Unix(),
  27715. Mtime: time.Now().Unix(),
  27716. Number: chrg_bchno,
  27717. ErrMsg: res.ErrMsg,
  27718. Status: 1,
  27719. PatientId: id,
  27720. RecordTime: recordDateTime,
  27721. Stage: 6,
  27722. }
  27723. service.CreateErrMsgLog(errlog)
  27724. c.ServeSuccessJSON(map[string]interface{}{
  27725. "failed_code": -10,
  27726. "msg": res.ErrMsg,
  27727. })
  27728. return
  27729. } else {
  27730. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27731. order.OrderStatus = 2
  27732. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27733. order.SetlId = res.Output.Setlinfo.SetlID
  27734. order.PsnNo = res.Output.Setlinfo.PsnNo
  27735. order.PsnName = res.Output.Setlinfo.PsnName
  27736. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27737. order.Certno = res.Output.Setlinfo.Certno
  27738. order.Gend = res.Output.Setlinfo.Gend
  27739. order.Naty = res.Output.Setlinfo.Naty
  27740. order.Age = res.Output.Setlinfo.Age
  27741. order.Insutype = res.Output.Setlinfo.Insutype
  27742. order.PsnType = res.Output.Setlinfo.PsnType
  27743. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27744. order.SetlTime = res.Output.Setlinfo.SetlTime
  27745. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27746. order.PayWays = pay_ways
  27747. order.AcctUsedFlag = acct_used_flag
  27748. order.WechatPay = wechat_pay
  27749. order.AliPay = ali_pay
  27750. order.JifenPay = jifen_pay
  27751. order.BandCardPay = band_card_pay
  27752. order.CashPay = cash_pay
  27753. order.OthDesc = oth_desc
  27754. //order.MedType = res.Output.Setlinfo.MedType
  27755. if reg_type == 1112 {
  27756. order.MedType = "1112"
  27757. }
  27758. if reg_type == 1111 {
  27759. order.MedType = "1111"
  27760. }
  27761. order.ClrType = res.Output.Setlinfo.ClrType
  27762. if adminUser.CurrentOrgId == 10480 {
  27763. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27764. order.ClrType = "11"
  27765. } else {
  27766. order.ClrType = "9903"
  27767. }
  27768. }
  27769. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27770. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27771. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27772. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27773. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27774. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27775. order.HifpPay = res.Output.Setlinfo.HifpPay
  27776. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27777. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27778. order.HifesPay = res.Output.Setlinfo.HifesPay
  27779. order.HifobPay = res.Output.Setlinfo.HifobPay
  27780. order.MafPay = res.Output.Setlinfo.MafPay
  27781. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27782. order.OthPay = res.Output.Setlinfo.OthPay
  27783. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27784. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27785. order.AcctPay = res.Output.Setlinfo.AcctPay
  27786. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27787. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27788. order.Balc = res.Output.Setlinfo.Balc
  27789. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27790. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27791. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27792. order.ClrWay = res.Output.Setlinfo.ClrWay
  27793. order.Creator = order.Creator
  27794. order.Modify = roles.AdminUserId
  27795. order.RequestLog = src_resquest
  27796. order.Diagnosis = diagnosis_id
  27797. order.FaPiaoNumber = fapiao_number
  27798. order.FaPiaoCode = fapiao_code
  27799. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27800. detailStr := string(setlDetail)
  27801. order.SetlDetail = detailStr
  27802. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27803. err = service.UpDateOrder(order)
  27804. if err == nil {
  27805. //判断是否使用了押金
  27806. if dec_way == "true" {
  27807. tmpstring := strconv.FormatInt(order.ID, 10)
  27808. //扣押金
  27809. order.Decimal = decimal
  27810. service.UpDateOrder(order)
  27811. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27812. if errmsg != nil {
  27813. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27814. return
  27815. }
  27816. }
  27817. c.ServeSuccessJSON(map[string]interface{}{
  27818. "msg": "结算成功",
  27819. })
  27820. } else {
  27821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27822. return
  27823. }
  27824. }
  27825. }
  27826. }
  27827. }
  27828. // 上传明细-预结算-
  27829. func (c *HisApiController) GetPreUploadInfo() {
  27830. id, _ := c.GetInt64("id")
  27831. record_time := c.GetString("record_time")
  27832. his_patient_id, _ := c.GetInt64("his_patient_id")
  27833. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27834. admin_user_id, _ := c.GetInt64("admin_user_id")
  27835. diagnosis_id := c.GetString("diagnosis")
  27836. sick_type, _ := c.GetInt64("sick_type")
  27837. reg_type, _ := c.GetInt64("p_type")
  27838. begin_time := c.GetString("begin_time")
  27839. acct_used_flag := c.GetString("acct_used_flag")
  27840. id_str := c.GetString("ids")
  27841. ids_arr := strings.Split(id_str, ",")
  27842. timeLayout := "2006-01-02"
  27843. loc, _ := time.LoadLocation("Local")
  27844. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27845. if err != nil {
  27846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27847. return
  27848. }
  27849. recordDateTime := theTime.Unix()
  27850. adminUser := c.GetAdminUserInfo()
  27851. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27852. var config []*models.HisXtDiagnoseConfig
  27853. for _, item := range diagnosis_ids {
  27854. id, _ := strconv.ParseInt(item, 10, 64)
  27855. if id > 0 {
  27856. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27857. config = append(config, &diagnosisConfig)
  27858. }
  27859. }
  27860. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27861. sickConfig, _ := service.FindSickById(sick_type)
  27862. var prescriptions []*models.HisPrescription
  27863. var start_time int64
  27864. var end_time int64
  27865. var isSuccess bool = true
  27866. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27867. fmt.Println(his_patient_id)
  27868. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27869. timestamp := time.Now().Unix()
  27870. tempTime := time.Unix(timestamp, 0)
  27871. timeFormat := tempTime.Format("20060102150405")
  27872. chrgBchno := rand.Intn(100000) + 10000
  27873. new_chrg_bchno := ""
  27874. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27875. new_chrg_bchno = chrg_bchno
  27876. if adminUser.CurrentOrgId == 10265 {
  27877. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27878. new_chrg_bchno = "0000"
  27879. }
  27880. }
  27881. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27882. var patientPrescription models.HisPrescriptionInfo
  27883. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27884. if patientPrescription.ID == 0 {
  27885. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27886. }
  27887. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27888. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27889. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27890. strconv.FormatInt(his.PatientId, 10)
  27891. var res2406 Result2406
  27892. //安徽单病种处理
  27893. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27894. data := make(map[string]interface{})
  27895. client := &http.Client{}
  27896. data["psn_no"] = his.PsnNo
  27897. data["mdtrt_id"] = his.Number
  27898. data["operator"] = roles.UserName
  27899. data["cert_no"] = his.IdCardNo
  27900. data["org_name"] = miConfig.OrgName
  27901. data["psn_name"] = his.Name
  27902. data["ipt_otp_no"] = his.IptOtpNo
  27903. data["ipt_psn_sp_flag_type"] = "0901"
  27904. data["ipt_psn_sp_flag"] = "1"
  27905. data["fixmedins_code"] = miConfig.Code
  27906. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27907. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27908. data["url"] = miConfig.Url
  27909. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27910. bytesData, _ := json.Marshal(data)
  27911. var req *http.Request
  27912. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27913. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27914. resp, _ := client.Do(req)
  27915. defer resp.Body.Close()
  27916. body, ioErr := ioutil.ReadAll(resp.Body)
  27917. if ioErr != nil {
  27918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27920. return
  27921. }
  27922. var respJSON map[string]interface{}
  27923. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27926. return
  27927. }
  27928. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27929. if status == "0" {
  27930. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27931. c.ServeSuccessJSON(map[string]interface{}{
  27932. "failed_code": -10,
  27933. "msg": err_msg,
  27934. })
  27935. return
  27936. }
  27937. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27938. userJSONBytes, _ := json.Marshal(respJSON)
  27939. fmt.Println("log")
  27940. fmt.Println(string(userJSONBytes))
  27941. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27942. utils.ErrorLog("解析失败:%v", err)
  27943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27944. return
  27945. }
  27946. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  27947. data := make(map[string]interface{})
  27948. client := &http.Client{}
  27949. data["psn_no"] = his.PsnNo
  27950. data["mdtrt_id"] = his.Number
  27951. data["operator"] = roles.UserName
  27952. data["cert_no"] = his.IdCardNo
  27953. data["org_name"] = miConfig.OrgName
  27954. data["psn_name"] = his.Name
  27955. data["ipt_otp_no"] = his.IptOtpNo
  27956. data["ipt_psn_sp_flag_type"] = "0901"
  27957. data["ipt_psn_sp_flag"] = "1"
  27958. data["fixmedins_code"] = miConfig.Code
  27959. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27960. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27961. data["url"] = miConfig.Url
  27962. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27963. bytesData, _ := json.Marshal(data)
  27964. var req *http.Request
  27965. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27966. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27967. resp, _ := client.Do(req)
  27968. defer resp.Body.Close()
  27969. body, ioErr := ioutil.ReadAll(resp.Body)
  27970. if ioErr != nil {
  27971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27973. return
  27974. }
  27975. var respJSON map[string]interface{}
  27976. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27979. return
  27980. }
  27981. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27982. if status == "0" {
  27983. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27984. c.ServeSuccessJSON(map[string]interface{}{
  27985. "failed_code": -10,
  27986. "msg": err_msg,
  27987. })
  27988. return
  27989. }
  27990. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27991. userJSONBytes, _ := json.Marshal(respJSON)
  27992. fmt.Println("log")
  27993. fmt.Println(string(userJSONBytes))
  27994. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27995. utils.ErrorLog("解析失败:%v", err)
  27996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27997. return
  27998. }
  27999. }
  28000. if res2406.Infcode != 0 {
  28001. adminUser := c.GetAdminUserInfo()
  28002. errlog := &models.HisOrderError{
  28003. UserOrgId: adminUser.CurrentOrgId,
  28004. Ctime: time.Now().Unix(),
  28005. Mtime: time.Now().Unix(),
  28006. ErrMsg: res2406.ErrMsg,
  28007. Status: 1,
  28008. PatientId: id,
  28009. RecordTime: recordDateTime,
  28010. Stage: 3,
  28011. }
  28012. service.CreateErrMsgLog(errlog)
  28013. c.ServeSuccessJSON(map[string]interface{}{
  28014. "failed_code": -10,
  28015. "msg": res2406.ErrMsg,
  28016. })
  28017. return
  28018. }
  28019. var res2 ResultSix
  28020. var res3 GZResultSix
  28021. var resSix10265 ResultSix10265
  28022. //var time_stamp string
  28023. if miConfig.MdtrtareaAdmvs == "421300" {
  28024. data := make(map[string]interface{})
  28025. client := &http.Client{}
  28026. data["psn_no"] = his.PsnNo
  28027. data["mdtrt_id"] = his.Number
  28028. data["department"] = department.Name
  28029. data["org_name"] = miConfig.OrgName
  28030. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28031. data["doctor_id"] = doctor_info.DoctorNumber
  28032. data["doctor_name"] = roles.UserName
  28033. data["fixmedins_code"] = miConfig.Code
  28034. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28035. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28036. data["secret_key"] = miConfig.SecretKey
  28037. data["sick_code"] = sickConfig.CountryCode
  28038. data["sick_name"] = sickConfig.ClassName
  28039. data["begin_time"] = begin_time
  28040. data["dept"] = strconv.FormatInt(department.ID, 10)
  28041. data["config"] = config
  28042. data["opter"] = roles.UserName
  28043. fmt.Println(data)
  28044. bytesData, _ := json.Marshal(data)
  28045. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28046. resp, _ := client.Do(req)
  28047. defer resp.Body.Close()
  28048. body, ioErr := ioutil.ReadAll(resp.Body)
  28049. if ioErr != nil {
  28050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28052. return
  28053. }
  28054. var respJSON map[string]interface{}
  28055. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28058. return
  28059. }
  28060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28061. userJSONBytes, _ := json.Marshal(respJSON)
  28062. fmt.Println("log")
  28063. fmt.Println(string(userJSONBytes))
  28064. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28065. utils.ErrorLog("解析失败:%v", err)
  28066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28067. return
  28068. }
  28069. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28070. data := make(map[string]interface{})
  28071. client := &http.Client{}
  28072. data["psn_no"] = his.PsnNo
  28073. data["mdtrt_id"] = his.Number
  28074. data["department"] = department.Name
  28075. data["org_name"] = miConfig.OrgName
  28076. if reg_type == 11 && his.Insutype == "390" {
  28077. data["med_type"] = "110104"
  28078. } else {
  28079. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28080. }
  28081. data["doctor_id"] = doctor_info.DoctorNumber
  28082. data["doctor_name"] = roles.UserName
  28083. data["fixmedins_code"] = miConfig.Code
  28084. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28085. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28086. data["secret_key"] = miConfig.SecretKey
  28087. data["sick_code"] = sickConfig.CountryCode
  28088. data["sick_name"] = sickConfig.ClassName
  28089. data["begin_time"] = begin_time
  28090. data["dept"] = strconv.FormatInt(department.ID, 10)
  28091. data["config"] = config
  28092. data["opter"] = roles.UserName
  28093. fmt.Println(data)
  28094. bytesData, _ := json.Marshal(data)
  28095. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28096. resp, _ := client.Do(req)
  28097. defer resp.Body.Close()
  28098. body, ioErr := ioutil.ReadAll(resp.Body)
  28099. if ioErr != nil {
  28100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28102. return
  28103. }
  28104. var respJSON map[string]interface{}
  28105. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28108. return
  28109. }
  28110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28111. userJSONBytes, _ := json.Marshal(respJSON)
  28112. fmt.Println("log")
  28113. fmt.Println(string(userJSONBytes))
  28114. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28115. utils.ErrorLog("解析失败:%v", err)
  28116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28117. return
  28118. }
  28119. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28120. data := make(map[string]interface{})
  28121. client := &http.Client{}
  28122. data["psn_no"] = his.PsnNo
  28123. data["mdtrt_id"] = his.Number
  28124. data["department"] = department.Name
  28125. data["org_name"] = miConfig.OrgName
  28126. if reg_type == 11 && his.Insutype == "390" {
  28127. data["med_type"] = "110104"
  28128. } else {
  28129. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28130. }
  28131. data["doctor_id"] = doctor_info.DoctorNumber
  28132. data["doctor_name"] = roles.UserName
  28133. data["fixmedins_code"] = miConfig.Code
  28134. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28135. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28136. data["secret_key"] = miConfig.SecretKey
  28137. data["sick_code"] = sickConfig.CountryCode
  28138. data["sick_name"] = sickConfig.ClassName
  28139. data["begin_time"] = begin_time
  28140. data["dept"] = strconv.FormatInt(department.ID, 10)
  28141. data["config"] = config
  28142. data["opter"] = roles.UserName
  28143. fmt.Println(data)
  28144. bytesData, _ := json.Marshal(data)
  28145. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28146. resp, _ := client.Do(req)
  28147. defer resp.Body.Close()
  28148. body, ioErr := ioutil.ReadAll(resp.Body)
  28149. if ioErr != nil {
  28150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28152. return
  28153. }
  28154. var respJSON map[string]interface{}
  28155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28158. return
  28159. }
  28160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28161. userJSONBytes, _ := json.Marshal(respJSON)
  28162. fmt.Println("log")
  28163. fmt.Println(string(userJSONBytes))
  28164. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28165. utils.ErrorLog("解析失败:%v", err)
  28166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28167. return
  28168. }
  28169. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28170. data := make(map[string]interface{})
  28171. client := &http.Client{}
  28172. data["psn_no"] = his.PsnNo
  28173. data["mdtrt_id"] = his.Number
  28174. data["department"] = department.Name
  28175. data["org_name"] = miConfig.OrgName
  28176. if reg_type == 11 && his.Insutype == "390" {
  28177. data["med_type"] = "110104"
  28178. } else {
  28179. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28180. }
  28181. data["doctor_id"] = doctor_info.DoctorNumber
  28182. data["doctor_name"] = roles.UserName
  28183. data["fixmedins_code"] = miConfig.Code
  28184. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28185. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28186. data["secret_key"] = miConfig.SecretKey
  28187. data["sick_code"] = sickConfig.CountryCode
  28188. data["sick_name"] = sickConfig.ClassName
  28189. data["begin_time"] = begin_time
  28190. data["dept"] = strconv.FormatInt(department.ID, 10)
  28191. data["config"] = config
  28192. data["opter"] = roles.UserName
  28193. fmt.Println(data)
  28194. bytesData, _ := json.Marshal(data)
  28195. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28196. resp, _ := client.Do(req)
  28197. defer resp.Body.Close()
  28198. body, ioErr := ioutil.ReadAll(resp.Body)
  28199. if ioErr != nil {
  28200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28202. return
  28203. }
  28204. var respJSON map[string]interface{}
  28205. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28208. return
  28209. }
  28210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28211. userJSONBytes, _ := json.Marshal(respJSON)
  28212. fmt.Println("log")
  28213. fmt.Println(string(userJSONBytes))
  28214. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28215. utils.ErrorLog("解析失败:%v", err)
  28216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28217. return
  28218. }
  28219. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28220. data := make(map[string]interface{})
  28221. client := &http.Client{}
  28222. data["psn_no"] = his.PsnNo
  28223. data["mdtrt_id"] = his.Number
  28224. data["doctor"] = roles.UserName
  28225. data["department"] = department.Name
  28226. data["org_name"] = miConfig.OrgName
  28227. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28228. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28229. data["fixmedins_code"] = miConfig.Code
  28230. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28231. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28232. data["secret_key"] = miConfig.SecretKey
  28233. data["sick_code"] = sickConfig.CountryCode
  28234. data["sick_name"] = sickConfig.ClassName
  28235. data["begin_time"] = begin_time
  28236. data["dept"] = strconv.FormatInt(department.ID, 10)
  28237. data["config"] = config
  28238. data["url"] = miConfig.Url
  28239. data["ak"] = miConfig.AccessKey
  28240. data["cainfo"] = miConfig.Cainfo
  28241. bytesData, _ := json.Marshal(data)
  28242. var req *http.Request
  28243. if miConfig.MdtrtareaAdmvs == "320921" {
  28244. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28245. } else {
  28246. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28247. }
  28248. resp, _ := client.Do(req)
  28249. defer resp.Body.Close()
  28250. body, ioErr := ioutil.ReadAll(resp.Body)
  28251. if ioErr != nil {
  28252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28254. return
  28255. }
  28256. var respJSON map[string]interface{}
  28257. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28260. return
  28261. }
  28262. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28263. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28264. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28266. userJSONBytes, _ := json.Marshal(respJSON)
  28267. fmt.Println("log")
  28268. fmt.Println(string(userJSONBytes))
  28269. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28270. utils.ErrorLog("解析失败:%v", err)
  28271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28272. return
  28273. }
  28274. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28275. res2.Output = resSix10265.Output
  28276. res2.ErrMsg = resSix10265.ErrMsg
  28277. res2.Cainfo = resSix10265.Cainfo
  28278. res2.WarnMsg = resSix10265.WarnMsg
  28279. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28280. res2.Infcode = infocode
  28281. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28282. data := make(map[string]interface{})
  28283. client := &http.Client{}
  28284. data["psn_no"] = his.PsnNo
  28285. data["mdtrt_id"] = his.Number
  28286. data["doctor"] = roles.UserName
  28287. data["department"] = department.Name
  28288. data["org_name"] = miConfig.OrgName
  28289. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28290. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28291. data["fixmedins_code"] = miConfig.Code
  28292. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28293. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28294. data["secret_key"] = miConfig.SecretKey
  28295. data["sick_code"] = sickConfig.CountryCode
  28296. data["sick_name"] = sickConfig.ClassName
  28297. data["begin_time"] = begin_time
  28298. data["dept"] = strconv.FormatInt(department.ID, 10)
  28299. data["config"] = config
  28300. //data["url"] = miConfig.Url
  28301. //data["ak"] = miConfig.AccessKey
  28302. data["cainfo"] = miConfig.Cainfo
  28303. fmt.Println(data)
  28304. bytesData, _ := json.Marshal(data)
  28305. var req *http.Request
  28306. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28307. resp, _ := client.Do(req)
  28308. defer resp.Body.Close()
  28309. body, ioErr := ioutil.ReadAll(resp.Body)
  28310. if ioErr != nil {
  28311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28313. return
  28314. }
  28315. var respJSON map[string]interface{}
  28316. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28319. return
  28320. }
  28321. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28322. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28323. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28325. userJSONBytes, _ := json.Marshal(respJSON)
  28326. fmt.Println("log")
  28327. fmt.Println(string(userJSONBytes))
  28328. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28329. utils.ErrorLog("解析失败:%v", err)
  28330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28331. return
  28332. }
  28333. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28334. res2.Output = resSix10265.Output
  28335. res2.ErrMsg = resSix10265.ErrMsg
  28336. res2.Cainfo = resSix10265.Cainfo
  28337. res2.WarnMsg = resSix10265.WarnMsg
  28338. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28339. res2.Infcode = infocode
  28340. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28341. 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)
  28342. saveLog(result, requestLog, "2203", "上传就诊信息")
  28343. var respJSON2 map[string]interface{}
  28344. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28347. return
  28348. }
  28349. userJSONBytes2, _ := json.Marshal(respJSON2)
  28350. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28351. utils.ErrorLog("解析失败:%v", err)
  28352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28353. return
  28354. }
  28355. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28356. var result string
  28357. var requestLog string
  28358. 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, "")
  28359. saveLog(result, requestLog, "2203", "上传就诊信息")
  28360. var respJSON2 map[string]interface{}
  28361. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28362. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28364. return
  28365. }
  28366. userJSONBytes2, _ := json.Marshal(respJSON2)
  28367. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28368. utils.ErrorLog("解析失败:%v", err)
  28369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28370. return
  28371. }
  28372. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28373. var result string
  28374. var requestLog string
  28375. 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, "")
  28376. saveLog(result, requestLog, "2203", "上传就诊信息")
  28377. var respJSON2 map[string]interface{}
  28378. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28381. return
  28382. }
  28383. userJSONBytes2, _ := json.Marshal(respJSON2)
  28384. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28385. utils.ErrorLog("解析失败:%v", err)
  28386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28387. return
  28388. }
  28389. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28390. data := make(map[string]interface{})
  28391. client := &http.Client{}
  28392. data["psn_no"] = his.PsnNo
  28393. data["mdtrt_id"] = his.Number
  28394. data["operator"] = roles.UserName
  28395. data["department"] = department.Name
  28396. data["org_name"] = miConfig.OrgName
  28397. var med_type string
  28398. if his.Insutype == "390" {
  28399. if reg_type == 992102 {
  28400. med_type = "992102"
  28401. data["sick_code"] = "ZDZ940"
  28402. data["sick_name"] = "慢性肾衰竭"
  28403. }
  28404. if reg_type == 140104 {
  28405. med_type = "140104"
  28406. data["sick_code"] = sickConfig.CountryCode
  28407. data["sick_name"] = sickConfig.ClassName
  28408. }
  28409. if reg_type == 14 {
  28410. med_type = "140104"
  28411. data["sick_code"] = sickConfig.CountryCode
  28412. data["sick_name"] = sickConfig.ClassName
  28413. }
  28414. } else if his.Insutype == "310" {
  28415. if reg_type == 992102 {
  28416. med_type = "992102"
  28417. data["sick_code"] = "ZDZ940"
  28418. data["sick_name"] = "慢性肾衰竭"
  28419. }
  28420. if reg_type == 140104 {
  28421. med_type = "140104"
  28422. data["sick_code"] = sickConfig.CountryCode
  28423. data["sick_name"] = sickConfig.ClassName
  28424. }
  28425. if reg_type == 14 {
  28426. med_type = "14"
  28427. data["sick_code"] = sickConfig.CountryCode
  28428. data["sick_name"] = sickConfig.ClassName
  28429. }
  28430. }
  28431. data["med_type"] = med_type
  28432. data["doctor_number"] = doctor_info.DoctorNumber
  28433. data["doctor_name"] = doctor_info.UserName
  28434. data["fixmedins_code"] = miConfig.Code
  28435. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28436. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28437. data["secret_key"] = miConfig.SecretKey
  28438. data["begin_time"] = begin_time
  28439. data["dept"] = strconv.FormatInt(department.ID, 10)
  28440. data["config"] = config
  28441. data["url"] = miConfig.Url
  28442. data["ak"] = miConfig.AccessKey
  28443. data["cainfo"] = miConfig.Cainfo
  28444. bytesData, _ := json.Marshal(data)
  28445. var req *http.Request
  28446. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28447. resp, _ := client.Do(req)
  28448. defer resp.Body.Close()
  28449. body, ioErr := ioutil.ReadAll(resp.Body)
  28450. if ioErr != nil {
  28451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28453. return
  28454. }
  28455. var respJSON map[string]interface{}
  28456. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28459. return
  28460. }
  28461. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28462. if status == "0" {
  28463. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28464. c.ServeSuccessJSON(map[string]interface{}{
  28465. "failed_code": -10,
  28466. "msg": err_msg,
  28467. })
  28468. return
  28469. }
  28470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28471. userJSONBytes, _ := json.Marshal(respJSON)
  28472. fmt.Println("log")
  28473. fmt.Println(string(userJSONBytes))
  28474. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28475. utils.ErrorLog("解析失败:%v", err)
  28476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28477. return
  28478. }
  28479. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28480. data := make(map[string]interface{})
  28481. client := &http.Client{}
  28482. data["psn_no"] = his.PsnNo
  28483. data["mdtrt_id"] = his.Number
  28484. data["operator"] = roles.UserName
  28485. data["department"] = department.Name
  28486. data["org_name"] = miConfig.OrgName
  28487. var med_type string
  28488. if his.Insutype == "390" {
  28489. if reg_type == 992102 {
  28490. med_type = "992102"
  28491. data["sick_code"] = sickConfig.CountryCode
  28492. data["sick_name"] = sickConfig.ClassName
  28493. }
  28494. if reg_type == 140104 {
  28495. med_type = "140104"
  28496. data["sick_code"] = sickConfig.CountryCode
  28497. data["sick_name"] = sickConfig.ClassName
  28498. }
  28499. if reg_type == 140201 {
  28500. med_type = "140201"
  28501. data["sick_code"] = sickConfig.CountryCode
  28502. data["sick_name"] = sickConfig.ClassName
  28503. }
  28504. if reg_type == 14 {
  28505. med_type = "14"
  28506. data["sick_code"] = sickConfig.CountryCode
  28507. data["sick_name"] = sickConfig.ClassName
  28508. }
  28509. } else if his.Insutype == "310" {
  28510. if reg_type == 992102 {
  28511. med_type = "992102"
  28512. data["sick_code"] = sickConfig.CountryCode
  28513. data["sick_name"] = sickConfig.ClassName
  28514. }
  28515. if reg_type == 140104 {
  28516. med_type = "140104"
  28517. data["sick_code"] = sickConfig.CountryCode
  28518. data["sick_name"] = sickConfig.ClassName
  28519. }
  28520. if reg_type == 140201 {
  28521. med_type = "140201"
  28522. data["sick_code"] = sickConfig.CountryCode
  28523. data["sick_name"] = sickConfig.ClassName
  28524. }
  28525. if reg_type == 14 {
  28526. med_type = "14"
  28527. data["sick_code"] = sickConfig.CountryCode
  28528. data["sick_name"] = sickConfig.ClassName
  28529. }
  28530. }
  28531. data["med_type"] = med_type
  28532. data["doctor_number"] = doctor_info.DoctorNumber
  28533. data["doctor_name"] = doctor_info.UserName
  28534. data["fixmedins_code"] = miConfig.Code
  28535. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28536. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28537. data["secret_key"] = miConfig.SecretKey
  28538. data["begin_time"] = begin_time
  28539. data["dept"] = strconv.FormatInt(department.ID, 10)
  28540. data["config"] = config
  28541. data["url"] = miConfig.Url
  28542. data["ak"] = miConfig.AccessKey
  28543. data["cainfo"] = miConfig.Cainfo
  28544. bytesData, _ := json.Marshal(data)
  28545. var req *http.Request
  28546. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28547. resp, _ := client.Do(req)
  28548. defer resp.Body.Close()
  28549. body, ioErr := ioutil.ReadAll(resp.Body)
  28550. if ioErr != nil {
  28551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28553. return
  28554. }
  28555. var respJSON map[string]interface{}
  28556. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28559. return
  28560. }
  28561. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28562. if status == "0" {
  28563. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28564. c.ServeSuccessJSON(map[string]interface{}{
  28565. "failed_code": -10,
  28566. "msg": err_msg,
  28567. })
  28568. return
  28569. }
  28570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28571. userJSONBytes, _ := json.Marshal(respJSON)
  28572. fmt.Println("log")
  28573. fmt.Println(string(userJSONBytes))
  28574. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28575. utils.ErrorLog("解析失败:%v", err)
  28576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28577. return
  28578. }
  28579. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28580. var result string
  28581. var requestLog string
  28582. 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, "")
  28583. saveLog(result, requestLog, "2203", "上传就诊信息")
  28584. var respJSON2 map[string]interface{}
  28585. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28588. return
  28589. }
  28590. userJSONBytes2, _ := json.Marshal(respJSON2)
  28591. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28592. utils.ErrorLog("解析失败:%v", err)
  28593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28594. return
  28595. }
  28596. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28597. data := make(map[string]interface{})
  28598. client := &http.Client{}
  28599. data["psn_no"] = his.PsnNo
  28600. data["mdtrt_id"] = his.Number
  28601. data["doctor"] = roles.UserName
  28602. data["department"] = department.Name
  28603. data["org_name"] = miConfig.OrgName
  28604. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28605. data["doctor_id"] = doctor_info.DoctorNumber
  28606. data["fixmedins_code"] = miConfig.Code
  28607. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28608. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28609. data["secret_key"] = miConfig.SecretKey
  28610. data["sick_code"] = sickConfig.CountryCode
  28611. data["sick_name"] = sickConfig.ClassName
  28612. data["begin_time"] = begin_time
  28613. data["new_doctor_name"] = doctor_info.UserName
  28614. data["dept"] = strconv.FormatInt(department.ID, 10)
  28615. data["config"] = config
  28616. bytesData, _ := json.Marshal(data)
  28617. var req *http.Request
  28618. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28619. resp, _ := client.Do(req)
  28620. defer resp.Body.Close()
  28621. body, ioErr := ioutil.ReadAll(resp.Body)
  28622. if ioErr != nil {
  28623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28625. return
  28626. }
  28627. var respJSON map[string]interface{}
  28628. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28631. return
  28632. }
  28633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28634. userJSONBytes, _ := json.Marshal(respJSON)
  28635. fmt.Println("log")
  28636. fmt.Println(string(userJSONBytes))
  28637. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28638. utils.ErrorLog("解析失败:%v", err)
  28639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28640. return
  28641. }
  28642. } else {
  28643. var result string
  28644. var requestLog string
  28645. if miConfig.MdtrtareaAdmvs == "440781" { //
  28646. 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)
  28647. } else {
  28648. if miConfig.Code == "H15049901371" {
  28649. //赤峰地区国家医保医疗类别
  28650. //职工透析:医疗类别选特殊情况门诊990502
  28651. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28652. var med_type string
  28653. if his.Insutype == "390" {
  28654. if reg_type == 14 {
  28655. med_type = "9933"
  28656. } else if reg_type == 11 {
  28657. med_type = "11"
  28658. }
  28659. } else if his.Insutype == "310" {
  28660. if reg_type == 14 {
  28661. med_type = "990502"
  28662. } else if reg_type == 11 {
  28663. med_type = "11"
  28664. }
  28665. }
  28666. 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)
  28667. } else {
  28668. 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)
  28669. }
  28670. saveLog(result, requestLog, "2203", "上传就诊信息")
  28671. var respJSON2 map[string]interface{}
  28672. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28675. return
  28676. }
  28677. userJSONBytes2, _ := json.Marshal(respJSON2)
  28678. if miConfig.Code == "H15049901371" {
  28679. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28680. utils.ErrorLog("解析失败:%v", err)
  28681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28682. return
  28683. }
  28684. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28685. res2.Output = resSix10265.Output
  28686. res2.ErrMsg = resSix10265.ErrMsg
  28687. res2.Cainfo = resSix10265.Cainfo
  28688. res2.WarnMsg = resSix10265.WarnMsg
  28689. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28690. res2.Infcode = infocode
  28691. } else {
  28692. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28693. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28694. utils.ErrorLog("解析失败:%v", err)
  28695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28696. return
  28697. }
  28698. res2.Infcode = res3.Infcode
  28699. } else {
  28700. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28701. utils.ErrorLog("解析失败:%v", err)
  28702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28703. return
  28704. }
  28705. }
  28706. }
  28707. }
  28708. }
  28709. if res2.Infcode == -1 {
  28710. adminUser := c.GetAdminUserInfo()
  28711. errlog := &models.HisOrderError{
  28712. UserOrgId: adminUser.CurrentOrgId,
  28713. Ctime: time.Now().Unix(),
  28714. Mtime: time.Now().Unix(),
  28715. ErrMsg: res2.ErrMsg,
  28716. Status: 1,
  28717. PatientId: id,
  28718. RecordTime: recordDateTime,
  28719. Stage: 3,
  28720. }
  28721. service.CreateErrMsgLog(errlog)
  28722. c.ServeSuccessJSON(map[string]interface{}{
  28723. "failed_code": -10,
  28724. "msg": res2.ErrMsg,
  28725. })
  28726. return
  28727. }
  28728. if res2.Infcode != 0 {
  28729. adminUser := c.GetAdminUserInfo()
  28730. errlog := &models.HisOrderError{
  28731. UserOrgId: adminUser.CurrentOrgId,
  28732. Ctime: time.Now().Unix(),
  28733. Mtime: time.Now().Unix(),
  28734. ErrMsg: res2.ErrMsg,
  28735. Status: 1,
  28736. PatientId: id,
  28737. RecordTime: recordDateTime,
  28738. Stage: 3,
  28739. }
  28740. service.CreateErrMsgLog(errlog)
  28741. c.ServeSuccessJSON(map[string]interface{}{
  28742. "failed_code": -10,
  28743. "msg": res2.ErrMsg,
  28744. })
  28745. return
  28746. } else {
  28747. his.Diagnosis = diagnosis_id
  28748. his.SickType = sickConfig.ID
  28749. his.PType = fmt.Sprintf("%d", reg_type)
  28750. service.UpdateHisPatientThree(&his)
  28751. data := make(map[string]interface{})
  28752. if settle_accounts_type == 1 { //日结
  28753. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28754. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28755. } else {
  28756. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28757. }
  28758. data["pre"] = prescriptions
  28759. } else { //月结
  28760. start_time_str := c.GetString("start_time")
  28761. end_time_str := c.GetString("end_time")
  28762. timeLayout := "2006-01-02"
  28763. loc, _ := time.LoadLocation("Local")
  28764. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28765. if err != nil {
  28766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28767. return
  28768. }
  28769. recordStartTime := theStartTime.Unix()
  28770. start_time = recordStartTime
  28771. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28772. if err != nil {
  28773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28774. return
  28775. }
  28776. recordEndTime := theEndTime.Unix()
  28777. end_time = recordEndTime
  28778. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28779. data["pre"] = prescriptions
  28780. }
  28781. client := &http.Client{}
  28782. data["psn_no"] = his.PsnNo
  28783. data["mdtrt_id"] = his.Number
  28784. data["chrg_bchno"] = new_chrg_bchno
  28785. data["org_name"] = miConfig.OrgName
  28786. data["doctor"] = doctor_info.UserName
  28787. data["doctor_id"] = doctor_info.DoctorNumber
  28788. data["dept"] = department.Name
  28789. data["fixmedins_code"] = miConfig.Code
  28790. data["opter"] = roles.UserName
  28791. data["dept_code"] = department.Number
  28792. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28793. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28794. data["secret_key"] = miConfig.SecretKey
  28795. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28796. data["url"] = miConfig.Url
  28797. data["ak"] = miConfig.AccessKey
  28798. data["new_doctor_name"] = patientPrescription.Doctor
  28799. if his.Insutype == "390" {
  28800. if reg_type == 992102 {
  28801. data["diag_code"] = "ZDZ940"
  28802. }
  28803. if reg_type == 140104 {
  28804. data["diag_code"] = sickConfig.CountryCode
  28805. }
  28806. if reg_type == 140201 {
  28807. data["diag_code"] = sickConfig.CountryCode
  28808. }
  28809. if reg_type == 14 {
  28810. data["diag_code"] = sickConfig.CountryCode
  28811. }
  28812. } else if his.Insutype == "310" {
  28813. if miConfig.MdtrtareaAdmvs == "341203" {
  28814. if reg_type == 992102 {
  28815. data["diag_code"] = "ZDZ940"
  28816. }
  28817. if reg_type != 992102 {
  28818. data["diag_code"] = sickConfig.CountryCode
  28819. }
  28820. } else {
  28821. data["diag_code"] = sickConfig.CountryCode
  28822. }
  28823. }
  28824. data["cainfo"] = miConfig.Cainfo
  28825. data["opter"] = roles.UserName
  28826. var ids []int64
  28827. for _, item := range prescriptions {
  28828. ids = append(ids, item.ID)
  28829. }
  28830. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28831. if config.IsOpen == 1 { //对接了医保,走医保流程
  28832. var res ResultFour
  28833. var resFour10265 ResultFour10265
  28834. if miConfig.MdtrtareaAdmvs == "421300" {
  28835. bytesData, _ := json.Marshal(data)
  28836. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", 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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28852. userJSONBytes, _ := json.Marshal(respJSON)
  28853. fmt.Println("log")
  28854. fmt.Println(string(userJSONBytes))
  28855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28856. utils.ErrorLog("解析失败:%v", err)
  28857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28858. return
  28859. }
  28860. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28861. bytesData, _ := json.Marshal(data)
  28862. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28863. resp, _ := client.Do(req)
  28864. defer resp.Body.Close()
  28865. body, ioErr := ioutil.ReadAll(resp.Body)
  28866. if ioErr != nil {
  28867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28869. return
  28870. }
  28871. var respJSON map[string]interface{}
  28872. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28875. return
  28876. }
  28877. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28878. userJSONBytes, _ := json.Marshal(respJSON)
  28879. fmt.Println("log")
  28880. fmt.Println(string(userJSONBytes))
  28881. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28882. utils.ErrorLog("解析失败:%v", err)
  28883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28884. return
  28885. }
  28886. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28887. bytesData, _ := json.Marshal(data)
  28888. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28889. resp, _ := client.Do(req)
  28890. defer resp.Body.Close()
  28891. body, ioErr := ioutil.ReadAll(resp.Body)
  28892. if ioErr != nil {
  28893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28895. return
  28896. }
  28897. var respJSON map[string]interface{}
  28898. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28901. return
  28902. }
  28903. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28904. userJSONBytes, _ := json.Marshal(respJSON)
  28905. fmt.Println("log")
  28906. fmt.Println(string(userJSONBytes))
  28907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28908. utils.ErrorLog("解析失败:%v", err)
  28909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28910. return
  28911. }
  28912. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28913. bytesData, _ := json.Marshal(data)
  28914. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28915. resp, _ := client.Do(req)
  28916. defer resp.Body.Close()
  28917. body, ioErr := ioutil.ReadAll(resp.Body)
  28918. if ioErr != nil {
  28919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28921. return
  28922. }
  28923. var respJSON map[string]interface{}
  28924. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28927. return
  28928. }
  28929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28930. userJSONBytes, _ := json.Marshal(respJSON)
  28931. fmt.Println("log")
  28932. fmt.Println(string(userJSONBytes))
  28933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28934. utils.ErrorLog("解析失败:%v", err)
  28935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28936. return
  28937. }
  28938. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28939. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28940. if result3101.Infcode == "0" {
  28941. if len(result3101.Output.Result) > 0 {
  28942. var errMsgs []string
  28943. for _, item := range result3101.Output.Result {
  28944. errMsgs = append(errMsgs, item.VolaCont)
  28945. }
  28946. c.ServeSuccessJSON(map[string]interface{}{
  28947. "failed_code": -10,
  28948. "msg": errMsgs,
  28949. })
  28950. return
  28951. } else {
  28952. if miConfig.MdtrtareaAdmvs == "320921" {
  28953. data["doctor_id"] = "D320923012139"
  28954. } else {
  28955. data["doctor_id"] = "D371621008686"
  28956. }
  28957. bytesData, _ := json.Marshal(data)
  28958. var req *http.Request
  28959. if miConfig.MdtrtareaAdmvs == "320921" {
  28960. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28961. } else {
  28962. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28963. }
  28964. resp, _ := client.Do(req)
  28965. defer resp.Body.Close()
  28966. body, ioErr := ioutil.ReadAll(resp.Body)
  28967. if ioErr != nil {
  28968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28970. return
  28971. }
  28972. var respJSON map[string]interface{}
  28973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28976. return
  28977. }
  28978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28979. userJSONBytes, _ := json.Marshal(respJSON)
  28980. fmt.Println("log")
  28981. fmt.Println(string(userJSONBytes))
  28982. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28983. utils.ErrorLog("解析失败:%v", err)
  28984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28985. return
  28986. }
  28987. res.InfRefmsgid = resFour10265.InfRefmsgid
  28988. res.Output = resFour10265.Output
  28989. res.ErrMsg = resFour10265.ErrMsg
  28990. res.Cainfo = resFour10265.Cainfo
  28991. res.WarnMsg = resFour10265.WarnMsg
  28992. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28993. res.Infcode = infocode
  28994. }
  28995. }
  28996. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28997. var pagesize int = 5
  28998. var start int = 1
  28999. var stop int
  29000. var pagecount int
  29001. var curpage int
  29002. data["doctor_id"] = doctor_info.DoctorNumber
  29003. var res2 ResultFour
  29004. //var result res.
  29005. //总页数,向上取整,注意除之前要先转换类型为float64
  29006. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29007. for curpage = 1; curpage <= pagecount; curpage++ {
  29008. if curpage == 1 {
  29009. start = 1
  29010. } else {
  29011. start = (curpage-1)*pagesize + 1
  29012. }
  29013. stop = curpage * pagesize
  29014. if stop > len(prescriptions) {
  29015. stop = len(prescriptions)
  29016. }
  29017. //var requestLog string
  29018. data["pre"] = prescriptions[start-1 : stop]
  29019. fmt.Println(data["pre"])
  29020. bytesData, _ := json.Marshal(data)
  29021. var req *http.Request
  29022. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29023. resp, _ := client.Do(req)
  29024. defer resp.Body.Close()
  29025. body, ioErr := ioutil.ReadAll(resp.Body)
  29026. if ioErr != nil {
  29027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29029. return
  29030. }
  29031. var respJSON map[string]interface{}
  29032. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29035. return
  29036. }
  29037. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29038. userJSONBytes, _ := json.Marshal(respJSON)
  29039. fmt.Println("log")
  29040. fmt.Println(string(userJSONBytes))
  29041. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29042. utils.ErrorLog("解析失败:%v", err)
  29043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29044. return
  29045. }
  29046. res.InfRefmsgid = resFour10265.InfRefmsgid
  29047. res.Output = resFour10265.Output
  29048. res.ErrMsg = resFour10265.ErrMsg
  29049. res.Cainfo = resFour10265.Cainfo
  29050. res.WarnMsg = resFour10265.WarnMsg
  29051. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29052. res.Infcode = infocode
  29053. if infocode == 0 {
  29054. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29055. } else {
  29056. isSuccess = false
  29057. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29058. res.Infcode = -1
  29059. res.ErrMsg = resFour10265.ErrMsg
  29060. errlog := &models.HisOrderError{
  29061. UserOrgId: adminUser.CurrentOrgId,
  29062. Ctime: time.Now().Unix(),
  29063. Mtime: time.Now().Unix(),
  29064. Number: chrg_bchno,
  29065. ErrMsg: "",
  29066. Status: 1,
  29067. PatientId: id,
  29068. RecordTime: recordDateTime,
  29069. Stage: 4,
  29070. }
  29071. service.CreateErrMsgLog(errlog)
  29072. }
  29073. }
  29074. if isSuccess {
  29075. res.Infcode = 0
  29076. res.Output.Result = res2.Output.Result
  29077. } else {
  29078. order := &models.HisOrder{
  29079. UserOrgId: adminUser.CurrentOrgId,
  29080. HisPatientId: his.ID,
  29081. PatientId: his.PatientId,
  29082. SettleAccountsDate: recordDateTime,
  29083. Ctime: time.Now().Unix(),
  29084. Mtime: time.Now().Unix(),
  29085. MdtrtId: his.Number,
  29086. PsnNo: his.PsnNo,
  29087. MedType: strconv.FormatInt(reg_type, 10),
  29088. Status: 1,
  29089. Number: chrg_bchno,
  29090. Infcode: res.Infcode,
  29091. WarnMsg: res.WarnMsg,
  29092. Cainfo: res.Cainfo,
  29093. ErrMsg: res.ErrMsg,
  29094. RespondTime: res.RefmsgTime,
  29095. InfRefmsgid: res.InfRefmsgid,
  29096. OrderStatus: 1,
  29097. IsMedicineInsurance: 1,
  29098. SettleType: settle_accounts_type,
  29099. SettleStartTime: start_time,
  29100. SettleEndTime: end_time,
  29101. Creator: roles.AdminUserId,
  29102. Modify: roles.AdminUserId,
  29103. PType: 2,
  29104. Diagnosis: diagnosis_id,
  29105. }
  29106. err = service.CreateOrder(order)
  29107. if err != nil {
  29108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29109. return
  29110. }
  29111. c.ServeSuccessJSON(map[string]interface{}{
  29112. "failed_code": -10,
  29113. "msg": res2.ErrMsg,
  29114. })
  29115. return
  29116. }
  29117. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29118. 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)
  29119. var dat map[string]interface{}
  29120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29121. fmt.Println(dat)
  29122. } else {
  29123. fmt.Println(err)
  29124. }
  29125. saveLog(result, request_log, "2204", "上传费用明细")
  29126. userJSONBytes, _ := json.Marshal(dat)
  29127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29128. utils.ErrorLog("解析失败:%v", err)
  29129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29130. return
  29131. }
  29132. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29133. 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, "", "")
  29134. var dat map[string]interface{}
  29135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29136. fmt.Println(dat)
  29137. } else {
  29138. fmt.Println(err)
  29139. }
  29140. saveLog(result, request_log, "2204", "上传费用明细")
  29141. userJSONBytes, _ := json.Marshal(dat)
  29142. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29143. utils.ErrorLog("解析失败:%v", err)
  29144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29145. return
  29146. }
  29147. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29148. 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, "", "")
  29149. var dat map[string]interface{}
  29150. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29151. fmt.Println(dat)
  29152. } else {
  29153. fmt.Println(err)
  29154. }
  29155. saveLog(result, request_log, "2204", "上传费用明细")
  29156. userJSONBytes, _ := json.Marshal(dat)
  29157. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29158. utils.ErrorLog("解析失败:%v", err)
  29159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29160. return
  29161. }
  29162. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29163. bytesData, _ := json.Marshal(data)
  29164. var req *http.Request
  29165. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29166. resp, _ := client.Do(req)
  29167. defer resp.Body.Close()
  29168. body, ioErr := ioutil.ReadAll(resp.Body)
  29169. if ioErr != nil {
  29170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29172. return
  29173. }
  29174. var respJSON map[string]interface{}
  29175. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29178. return
  29179. }
  29180. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29181. if status == "0" {
  29182. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29183. c.ServeSuccessJSON(map[string]interface{}{
  29184. "failed_code": -10,
  29185. "msg": err_msg,
  29186. })
  29187. return
  29188. }
  29189. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29190. userJSONBytes, _ := json.Marshal(respJSON)
  29191. fmt.Println("log")
  29192. fmt.Println(string(userJSONBytes))
  29193. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29194. utils.ErrorLog("解析失败:%v", err)
  29195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29196. return
  29197. }
  29198. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29199. bytesData, _ := json.Marshal(data)
  29200. var req *http.Request
  29201. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29202. resp, _ := client.Do(req)
  29203. defer resp.Body.Close()
  29204. body, ioErr := ioutil.ReadAll(resp.Body)
  29205. if ioErr != nil {
  29206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29208. return
  29209. }
  29210. var respJSON map[string]interface{}
  29211. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29214. return
  29215. }
  29216. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29217. if status == "0" {
  29218. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29219. c.ServeSuccessJSON(map[string]interface{}{
  29220. "failed_code": -10,
  29221. "msg": err_msg,
  29222. })
  29223. return
  29224. }
  29225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29226. userJSONBytes, _ := json.Marshal(respJSON)
  29227. fmt.Println("log")
  29228. fmt.Println(string(userJSONBytes))
  29229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29230. utils.ErrorLog("解析失败:%v", err)
  29231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29232. return
  29233. }
  29234. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29235. 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, "", "")
  29236. var dat map[string]interface{}
  29237. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29238. fmt.Println(dat)
  29239. } else {
  29240. fmt.Println(err)
  29241. }
  29242. saveLog(result, request_log, "2204", "上传费用明细")
  29243. userJSONBytes, _ := json.Marshal(dat)
  29244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29245. utils.ErrorLog("解析失败:%v", err)
  29246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29247. return
  29248. }
  29249. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29250. bytesData, _ := json.Marshal(data)
  29251. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29252. resp, _ := client.Do(req)
  29253. defer resp.Body.Close()
  29254. body, ioErr := ioutil.ReadAll(resp.Body)
  29255. if ioErr != nil {
  29256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29258. return
  29259. }
  29260. var respJSON map[string]interface{}
  29261. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29264. return
  29265. }
  29266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29267. userJSONBytes, _ := json.Marshal(respJSON)
  29268. fmt.Println("log")
  29269. fmt.Println(string(userJSONBytes))
  29270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29271. utils.ErrorLog("解析失败:%v", err)
  29272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29273. return
  29274. }
  29275. } else {
  29276. if miConfig.MdtrtareaAdmvs == "441202" {
  29277. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29278. if result3101.Infcode == 0 {
  29279. if len(result3101.Output.Result) > 0 {
  29280. var errMsgs []string
  29281. for _, item := range result3101.Output.Result {
  29282. errMsgs = append(errMsgs, item.VolaCont)
  29283. }
  29284. c.ServeSuccessJSON(map[string]interface{}{
  29285. "failed_code": -10,
  29286. "msg": errMsgs,
  29287. })
  29288. return
  29289. } else {
  29290. 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)
  29291. var dat map[string]interface{}
  29292. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29293. fmt.Println(dat)
  29294. } else {
  29295. fmt.Println(err)
  29296. }
  29297. saveLog(result, request_log, "2204", "上传费用明细")
  29298. userJSONBytes, _ := json.Marshal(dat)
  29299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29300. utils.ErrorLog("解析失败:%v", err)
  29301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29302. return
  29303. }
  29304. }
  29305. } else {
  29306. c.ServeSuccessJSON(map[string]interface{}{
  29307. "failed_code": -10,
  29308. "msg": result3101.ErrMsg,
  29309. })
  29310. return
  29311. }
  29312. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29313. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29314. if result3101.Infcode == 0 {
  29315. if len(result3101.Output.Result) > 0 {
  29316. var errMsgs []string
  29317. for _, item := range result3101.Output.Result {
  29318. errMsgs = append(errMsgs, item.VolaCont)
  29319. }
  29320. c.ServeSuccessJSON(map[string]interface{}{
  29321. "failed_code": -10,
  29322. "msg": errMsgs,
  29323. })
  29324. return
  29325. } else {
  29326. 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)
  29327. var dat map[string]interface{}
  29328. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29329. fmt.Println(dat)
  29330. } else {
  29331. fmt.Println(err)
  29332. }
  29333. saveLog(result, request_log, "2204", "上传费用明细")
  29334. userJSONBytes, _ := json.Marshal(dat)
  29335. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29336. utils.ErrorLog("解析失败:%v", err)
  29337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29338. return
  29339. }
  29340. }
  29341. } else {
  29342. c.ServeSuccessJSON(map[string]interface{}{
  29343. "failed_code": -10,
  29344. "msg": result3101.ErrMsg,
  29345. })
  29346. return
  29347. }
  29348. } else {
  29349. if miConfig.Code == "H15049901371" {
  29350. 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)
  29351. var dat map[string]interface{}
  29352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29353. fmt.Println(dat)
  29354. } else {
  29355. fmt.Println(err)
  29356. }
  29357. saveLog(result, request_log, "2204", "上传费用明细")
  29358. userJSONBytes, _ := json.Marshal(dat)
  29359. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29360. utils.ErrorLog("解析失败:%v", err)
  29361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29362. return
  29363. }
  29364. res.InfRefmsgid = resFour10265.InfRefmsgid
  29365. res.Output = resFour10265.Output
  29366. res.ErrMsg = resFour10265.ErrMsg
  29367. res.Cainfo = resFour10265.Cainfo
  29368. res.WarnMsg = resFour10265.WarnMsg
  29369. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29370. res.Infcode = infocode
  29371. } else {
  29372. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" {
  29373. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29374. if result3101.Infcode == 0 {
  29375. if len(result3101.Output.Result) > 0 {
  29376. var errMsgs []string
  29377. for _, item := range result3101.Output.Result {
  29378. errMsgs = append(errMsgs, item.VolaCont)
  29379. }
  29380. c.ServeSuccessJSON(map[string]interface{}{
  29381. "failed_code": -10,
  29382. "msg": errMsgs,
  29383. })
  29384. return
  29385. } else {
  29386. 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)
  29387. var dat map[string]interface{}
  29388. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29389. fmt.Println(dat)
  29390. } else {
  29391. fmt.Println(err)
  29392. }
  29393. saveLog(result, request_log, "2204", "上传费用明细")
  29394. userJSONBytes, _ := json.Marshal(dat)
  29395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29396. utils.ErrorLog("解析失败:%v", err)
  29397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29398. return
  29399. }
  29400. }
  29401. } else {
  29402. c.ServeSuccessJSON(map[string]interface{}{
  29403. "failed_code": -10,
  29404. "msg": result3101.ErrMsg,
  29405. })
  29406. return
  29407. }
  29408. } else {
  29409. 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)
  29410. var dat map[string]interface{}
  29411. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29412. fmt.Println(dat)
  29413. } else {
  29414. fmt.Println(err)
  29415. }
  29416. saveLog(result, request_log, "2204", "上传费用明细")
  29417. userJSONBytes, _ := json.Marshal(dat)
  29418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29419. utils.ErrorLog("解析失败:%v", err)
  29420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29421. return
  29422. }
  29423. }
  29424. }
  29425. }
  29426. }
  29427. var total_two float64
  29428. if res.Infcode == -1 {
  29429. errlog := &models.HisOrderError{
  29430. UserOrgId: adminUser.CurrentOrgId,
  29431. Ctime: time.Now().Unix(),
  29432. Mtime: time.Now().Unix(),
  29433. Number: chrg_bchno,
  29434. ErrMsg: res.ErrMsg,
  29435. Status: 1,
  29436. PatientId: id,
  29437. RecordTime: recordDateTime,
  29438. Stage: 4,
  29439. }
  29440. service.CreateErrMsgLog(errlog)
  29441. c.ServeSuccessJSON(map[string]interface{}{
  29442. "failed_code": -10,
  29443. "msg": res.ErrMsg,
  29444. })
  29445. return
  29446. }
  29447. if res.Infcode == 0 {
  29448. order := &models.HisOrder{
  29449. UserOrgId: adminUser.CurrentOrgId,
  29450. HisPatientId: his.ID,
  29451. PatientId: his.PatientId,
  29452. SettleAccountsDate: recordDateTime,
  29453. Ctime: time.Now().Unix(),
  29454. Mtime: time.Now().Unix(),
  29455. MdtrtId: his.Number,
  29456. PsnNo: his.PsnNo,
  29457. MedType: strconv.FormatInt(reg_type, 10),
  29458. Status: 1,
  29459. Number: chrg_bchno,
  29460. Infcode: res.Infcode,
  29461. WarnMsg: res.WarnMsg,
  29462. Cainfo: res.Cainfo,
  29463. ErrMsg: res.ErrMsg,
  29464. RespondTime: res.RefmsgTime,
  29465. InfRefmsgid: res.InfRefmsgid,
  29466. OrderStatus: 1,
  29467. IsMedicineInsurance: 1,
  29468. SettleType: settle_accounts_type,
  29469. SettleStartTime: start_time,
  29470. SettleEndTime: end_time,
  29471. Creator: roles.AdminUserId,
  29472. Modify: roles.AdminUserId,
  29473. PType: 2,
  29474. Diagnosis: diagnosis_id,
  29475. }
  29476. err = service.CreateOrder(order)
  29477. if err != nil {
  29478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29479. return
  29480. }
  29481. for _, item := range res.Output.Result {
  29482. temp := strings.Split(item.FeedetlSn, "-")
  29483. var advice_id int64 = 0
  29484. var project_id int64 = 0
  29485. var types int64 = 0
  29486. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29487. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29488. if temp[1] == "1" {
  29489. advice_id = id
  29490. project_id = 0
  29491. } else if temp[1] == "2" {
  29492. advice_id = 0
  29493. project_id = id
  29494. }
  29495. total_two = total_two + item.DetItemFeeSumamt
  29496. info := &models.HisOrderInfo{
  29497. OrderNumber: order.Number,
  29498. FeedetlSn: item.FeedetlSn,
  29499. UploadDate: time.Now().Unix(),
  29500. AdviceId: advice_id,
  29501. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29502. Cnt: item.Cnt,
  29503. Pric: float64(item.Pric),
  29504. PatientId: his.PatientId,
  29505. PricUplmtAmt: item.PricUplmtAmt,
  29506. SelfpayProp: item.SelfpayProp,
  29507. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29508. OverlmtAmt: item.OverlmtAmt,
  29509. PreselfpayAmt: item.PreselfpayAmt,
  29510. BasMednFlag: item.BasMednFlag,
  29511. MedChrgitmType: item.MedChrgitmType,
  29512. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29513. Status: 1,
  29514. Memo: item.Memo,
  29515. Mtime: time.Now().Unix(),
  29516. InscpScpAmt: item.InscpScpAmt,
  29517. DrtReimFlag: item.DrtReimFlag,
  29518. Ctime: time.Now().Unix(),
  29519. ListSpItemFlag: item.ListSpItemFlag,
  29520. ChldMedcFlag: item.ChldMedcFlag,
  29521. LmtUsedFlag: item.LmtUsedFlag,
  29522. ChrgitmLv: item.ChrgitmLv,
  29523. UserOrgId: adminUser.CurrentOrgId,
  29524. HisPatientId: his.ID,
  29525. OrderId: order.ID,
  29526. ProjectId: project_id,
  29527. Type: types,
  29528. }
  29529. service.CreateOrderInfo(info)
  29530. }
  29531. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29532. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29533. var total float64
  29534. for _, item := range prescriptions {
  29535. if item.Type == 1 { //药品
  29536. for _, subItem := range item.HisDoctorAdviceInfo {
  29537. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29538. total_one := price * subItem.PrescribingNumber
  29539. fmt.Println("subItem")
  29540. fmt.Println(subItem.Price)
  29541. fmt.Println("price")
  29542. fmt.Println(price)
  29543. fmt.Println("total_one")
  29544. fmt.Println(total_one)
  29545. total = total + total_one
  29546. fmt.Println(total)
  29547. }
  29548. }
  29549. if item.Type == 2 { //项目
  29550. for _, subItem := range item.HisPrescriptionProject {
  29551. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29552. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29553. total_one := price * cnt
  29554. total = total + total_one
  29555. }
  29556. }
  29557. }
  29558. allTotal := fmt.Sprintf("%.2f", total)
  29559. if res.Infcode == 0 {
  29560. var rf []*ResultFive
  29561. json.Unmarshal([]byte(his.Iinfo), &rf)
  29562. chrg_bchno := chrg_bchno
  29563. cert_no := his.Certno
  29564. var insutypes []string
  29565. var insutype string
  29566. var is390 int = 0
  29567. var is310 int = 0
  29568. for _, item := range rf {
  29569. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29570. insutypes = append(insutypes, item.Insutype)
  29571. }
  29572. }
  29573. if len(insutypes) == 1 {
  29574. insutype = insutypes[0]
  29575. } else {
  29576. for _, i := range insutypes {
  29577. if i == "390" {
  29578. is390 = 1
  29579. }
  29580. if i == "310" {
  29581. is310 = 1
  29582. }
  29583. }
  29584. }
  29585. if is390 == 1 {
  29586. insutype = "390"
  29587. }
  29588. if is310 == 1 {
  29589. insutype = "310"
  29590. }
  29591. if len(insutypes) == 0 {
  29592. insutype = "390"
  29593. }
  29594. if len(insutypes) == 2 {
  29595. insutype = strconv.FormatInt(his.SocialType, 10)
  29596. }
  29597. //insutype = "390"
  29598. if his.IdCardType == 1 {
  29599. cert_no = his.MedicalInsuranceNumber
  29600. } else {
  29601. cert_no = his.Certno
  29602. }
  29603. var res ResultSeven
  29604. var ahres ResultSevenAH
  29605. var resSeven10265 ResultSeven10265
  29606. var resSeven10265Two ResultSeven10265Two
  29607. var gzresSeven10265Two GZResultSeven10265Two
  29608. if miConfig.MdtrtareaAdmvs == "421300" {
  29609. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29610. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29611. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29612. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29613. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29614. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29615. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29616. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29617. resp, requestErr := http.Get(api)
  29618. if requestErr != nil {
  29619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29620. return
  29621. }
  29622. body, ioErr := ioutil.ReadAll(resp.Body)
  29623. if ioErr != nil {
  29624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29626. return
  29627. }
  29628. var respJSON map[string]interface{}
  29629. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29632. return
  29633. }
  29634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29635. result, _ := json.Marshal(respJSON)
  29636. fmt.Println("log")
  29637. fmt.Println(string(result))
  29638. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29639. utils.ErrorLog("解析失败:%v", err)
  29640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29641. return
  29642. }
  29643. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29644. if reg_type == 11 && his.Insutype == "390" {
  29645. reg_type = 110104
  29646. }
  29647. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29648. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29649. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29650. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29651. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29652. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29653. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29654. resp, requestErr := http.Get(api)
  29655. if requestErr != nil {
  29656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29657. return
  29658. }
  29659. body, ioErr := ioutil.ReadAll(resp.Body)
  29660. if ioErr != nil {
  29661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29663. return
  29664. }
  29665. var respJSON map[string]interface{}
  29666. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29669. return
  29670. }
  29671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29672. result, _ := json.Marshal(respJSON)
  29673. fmt.Println("log")
  29674. fmt.Println(string(result))
  29675. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29676. utils.ErrorLog("解析失败:%v", err)
  29677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29678. return
  29679. }
  29680. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29681. if reg_type == 11 && his.Insutype == "390" {
  29682. reg_type = 110104
  29683. }
  29684. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29685. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29686. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29687. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29688. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29689. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29690. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29691. resp, requestErr := http.Get(api)
  29692. if requestErr != nil {
  29693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29694. return
  29695. }
  29696. body, ioErr := ioutil.ReadAll(resp.Body)
  29697. if ioErr != nil {
  29698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29700. return
  29701. }
  29702. var respJSON map[string]interface{}
  29703. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29706. return
  29707. }
  29708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29709. result, _ := json.Marshal(respJSON)
  29710. fmt.Println("log")
  29711. fmt.Println(string(result))
  29712. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29713. utils.ErrorLog("解析失败:%v", err)
  29714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29715. return
  29716. }
  29717. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29718. if reg_type == 11 && his.Insutype == "390" {
  29719. reg_type = 110104
  29720. }
  29721. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29722. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29723. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29724. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29725. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29726. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29727. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29728. resp, requestErr := http.Get(api)
  29729. if requestErr != nil {
  29730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29731. return
  29732. }
  29733. body, ioErr := ioutil.ReadAll(resp.Body)
  29734. if ioErr != nil {
  29735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29737. return
  29738. }
  29739. var respJSON map[string]interface{}
  29740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29743. return
  29744. }
  29745. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29746. result, _ := json.Marshal(respJSON)
  29747. fmt.Println("log")
  29748. fmt.Println(string(result))
  29749. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29750. utils.ErrorLog("解析失败:%v", err)
  29751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29752. return
  29753. }
  29754. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29755. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29756. if result3101.Infcode == "0" {
  29757. if len(result3101.Output.Result) > 0 {
  29758. var errMsgs []string
  29759. for _, item := range result3101.Output.Result {
  29760. errMsgs = append(errMsgs, item.VolaCont)
  29761. }
  29762. c.ServeSuccessJSON(map[string]interface{}{
  29763. "failed_code": -10,
  29764. "msg": errMsgs,
  29765. })
  29766. return
  29767. } else {
  29768. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29769. if his.IdCardType != 4 {
  29770. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29771. bas := strings.Split(psn_info.CardInfo, "|")
  29772. if his.IdCardType == 1 {
  29773. cert_no = bas[2]
  29774. } else {
  29775. cert_no = bas[1]
  29776. }
  29777. } else {
  29778. cert_no = his.Certno
  29779. }
  29780. //江苏地区国家医保医疗类别
  29781. //职工透析:医疗类别选特殊情况门诊9933
  29782. //居民血透门慢: 医疗类别选门诊慢病1402
  29783. //var med_type string
  29784. //if his.Insutype == "310" {
  29785. // if reg_type == 14 {
  29786. // med_type = "9933"
  29787. // } else if reg_type == 11 {
  29788. // med_type = "11"
  29789. //
  29790. // }
  29791. //} else if his.Insutype == "390" {
  29792. // if reg_type == 14 {
  29793. // med_type = "1402"
  29794. // } else if reg_type == 11 {
  29795. // med_type = "11"
  29796. // }
  29797. //}
  29798. var api string
  29799. if miConfig.MdtrtareaAdmvs == "320921" {
  29800. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29801. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29802. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29803. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29804. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29805. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29806. "&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
  29807. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29808. } else {
  29809. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29810. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29811. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29812. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29813. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29814. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29815. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29816. "&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
  29817. }
  29818. resp, requestErr := http.Get(api)
  29819. if requestErr != nil {
  29820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29821. return
  29822. }
  29823. body, ioErr := ioutil.ReadAll(resp.Body)
  29824. if ioErr != nil {
  29825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29827. return
  29828. }
  29829. var respJSON map[string]interface{}
  29830. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29833. return
  29834. }
  29835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29836. result, _ := json.Marshal(respJSON)
  29837. fmt.Println("log")
  29838. fmt.Println(string(result))
  29839. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29840. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29841. utils.ErrorLog("解析失败:%v", err)
  29842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29843. return
  29844. }
  29845. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29846. res.Output = resSeven10265.Output
  29847. res.ErrMsg = resSeven10265.ErrMsg
  29848. res.Cainfo = resSeven10265.Cainfo
  29849. res.WarnMsg = resSeven10265.WarnMsg
  29850. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29851. res.Infcode = infocode
  29852. } else {
  29853. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29854. utils.ErrorLog("解析失败:%v", err)
  29855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29856. return
  29857. }
  29858. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29859. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29860. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29861. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29862. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29863. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29864. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29865. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29866. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29867. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29868. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29869. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29870. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29871. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29872. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29873. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29874. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29875. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29876. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29877. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29878. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29879. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29880. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29881. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29882. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29883. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29884. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29885. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29886. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29887. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29888. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29889. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29890. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29891. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29892. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29893. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29894. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29895. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29896. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29897. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29898. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29899. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29900. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29901. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29902. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29903. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29904. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29905. res.ErrMsg = resSeven10265Two.ErrMsg
  29906. res.Cainfo = resSeven10265Two.Cainfo
  29907. res.WarnMsg = resSeven10265Two.WarnMsg
  29908. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29909. res.Infcode = infocode
  29910. }
  29911. }
  29912. }
  29913. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29914. psn_info, _ := service.GetPsnByPatientId(id)
  29915. var verify_number string
  29916. if psn_info.IdCardType == 4 {
  29917. verify_number = psn_info.VerifyNumber
  29918. } else if psn_info.IdCardType == 1 {
  29919. bas := strings.Split(psn_info.CardInfo, "|")
  29920. cardNumber := bas[2]
  29921. verify_number = cardNumber
  29922. } else {
  29923. psn_info.IdCardType = 2
  29924. verify_number = psn_info.Certno
  29925. }
  29926. var api string
  29927. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29928. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  29929. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29930. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29931. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29932. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29933. "&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
  29934. resp, requestErr := http.Get(api)
  29935. if requestErr != nil {
  29936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29937. return
  29938. }
  29939. body, ioErr := ioutil.ReadAll(resp.Body)
  29940. if ioErr != nil {
  29941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29943. return
  29944. }
  29945. var respJSON map[string]interface{}
  29946. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29949. return
  29950. }
  29951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29952. result, _ := json.Marshal(respJSON)
  29953. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29954. utils.ErrorLog("解析失败:%v", err)
  29955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29956. return
  29957. }
  29958. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29959. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  29960. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  29961. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29962. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  29963. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  29964. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  29965. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  29966. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  29967. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  29968. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  29969. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  29970. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  29971. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29972. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  29973. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  29974. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  29975. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  29976. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  29977. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  29978. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29979. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  29980. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  29981. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  29982. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  29983. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  29984. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  29985. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  29986. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  29987. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  29988. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  29989. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  29990. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  29991. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  29992. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29993. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  29994. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  29995. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  29996. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  29997. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  29998. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  29999. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30000. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30001. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30002. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30003. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30004. res.ErrMsg = resSeven10265.ErrMsg
  30005. res.Cainfo = resSeven10265.Cainfo
  30006. res.WarnMsg = resSeven10265.WarnMsg
  30007. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30008. res.Infcode = infocode
  30009. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30010. acct_used_flag := "1"
  30011. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30012. var result string
  30013. var request_log string
  30014. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30015. 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)
  30016. } else {
  30017. 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)
  30018. }
  30019. var dat map[string]interface{}
  30020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30021. fmt.Println(dat)
  30022. } else {
  30023. fmt.Println(err)
  30024. }
  30025. saveLog(result, request_log, "2206", "预结算")
  30026. userJSONBytes, _ := json.Marshal(dat)
  30027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30028. utils.ErrorLog("解析失败:%v", err)
  30029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30030. return
  30031. }
  30032. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30033. var result string
  30034. var request_log string
  30035. if his.IdCardType == 2 {
  30036. insutype = strconv.FormatInt(his.SocialType, 10)
  30037. 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, "")
  30038. } else if his.IdCardType == 1 {
  30039. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30040. bas := strings.Split(psn_info.CardInfo, "|")
  30041. basNumber := bas[2]
  30042. card_sn := bas[3]
  30043. var rf []*ResultFive
  30044. json.Unmarshal([]byte(his.Iinfo), &rf)
  30045. var psn_type string
  30046. for _, item := range rf {
  30047. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30048. psn_type = item.PsnType
  30049. }
  30050. }
  30051. insutype = strconv.FormatInt(his.SocialType, 10)
  30052. 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)
  30053. } else {
  30054. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30055. //bas := strings.Split(psn_info.CardInfo, "|")
  30056. //basNumber := bas[2]
  30057. //card_sn := bas[3]
  30058. var rf []*ResultFive
  30059. json.Unmarshal([]byte(his.Iinfo), &rf)
  30060. var psn_type string
  30061. for _, item := range rf {
  30062. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30063. psn_type = item.PsnType
  30064. }
  30065. }
  30066. insutype = strconv.FormatInt(his.SocialType, 10)
  30067. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30068. 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)
  30069. }
  30070. var dat map[string]interface{}
  30071. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30072. fmt.Println(dat)
  30073. } else {
  30074. fmt.Println(err)
  30075. }
  30076. saveLog(result, request_log, "2206", "预结算")
  30077. userJSONBytes, _ := json.Marshal(dat)
  30078. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30079. utils.ErrorLog("解析失败:%v", err)
  30080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30081. return
  30082. }
  30083. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30084. var result string
  30085. var request_log string
  30086. if his.IdCardType == 2 {
  30087. insutype = strconv.FormatInt(his.SocialType, 10)
  30088. 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, "")
  30089. } else if his.IdCardType == 1 {
  30090. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30091. bas := strings.Split(psn_info.CardInfo, "|")
  30092. basNumber := bas[0]
  30093. card_sn := ""
  30094. var rf []*ResultFive
  30095. json.Unmarshal([]byte(his.Iinfo), &rf)
  30096. var psn_type string
  30097. for _, item := range rf {
  30098. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30099. psn_type = item.PsnType
  30100. }
  30101. }
  30102. insutype = strconv.FormatInt(his.SocialType, 10)
  30103. 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)
  30104. } else {
  30105. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30106. //bas := strings.Split(psn_info.CardInfo, "|")
  30107. //basNumber := bas[2]
  30108. //card_sn := bas[3]
  30109. var rf []*ResultFive
  30110. json.Unmarshal([]byte(his.Iinfo), &rf)
  30111. var psn_type string
  30112. for _, item := range rf {
  30113. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30114. psn_type = item.PsnType
  30115. }
  30116. }
  30117. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30118. 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)
  30119. }
  30120. var dat map[string]interface{}
  30121. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30122. fmt.Println(dat)
  30123. } else {
  30124. fmt.Println(err)
  30125. }
  30126. saveLog(result, request_log, "2206", "预结算")
  30127. userJSONBytes, _ := json.Marshal(dat)
  30128. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30129. utils.ErrorLog("解析失败:%v", err)
  30130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30131. return
  30132. }
  30133. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30134. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30135. if his.IdCardType == 4 {
  30136. psn_info.VerifyNumber = psn_info.VerifyNumber
  30137. cert_no = psn_info.VerifyNumber
  30138. } else if his.IdCardType == 2 {
  30139. cert_no = psn_info.Certno
  30140. psn_info.VerifyNumber = psn_info.Certno
  30141. } else {
  30142. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30143. bas := strings.Split(psn_info.CardInfo, "|")
  30144. if his.IdCardType == 1 {
  30145. cert_no = bas[2]
  30146. } else {
  30147. cert_no = bas[1]
  30148. }
  30149. }
  30150. var api string
  30151. var med_type string
  30152. if his.Insutype == "390" {
  30153. if reg_type == 992102 {
  30154. med_type = "992102"
  30155. }
  30156. if reg_type == 140104 {
  30157. med_type = "140104"
  30158. }
  30159. if reg_type == 140201 {
  30160. med_type = "140201"
  30161. }
  30162. if reg_type == 14 {
  30163. med_type = "140104"
  30164. }
  30165. } else if his.Insutype == "310" {
  30166. if reg_type == 992102 {
  30167. med_type = "992102"
  30168. }
  30169. if reg_type == 140104 {
  30170. med_type = "140104"
  30171. }
  30172. if reg_type == 140201 {
  30173. med_type = "140201"
  30174. }
  30175. if reg_type == 14 {
  30176. med_type = "140104"
  30177. }
  30178. }
  30179. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30180. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30181. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30182. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30183. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30184. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30185. "&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
  30186. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30187. resp, requestErr := http.Get(api)
  30188. if requestErr != nil {
  30189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30190. return
  30191. }
  30192. body, ioErr := ioutil.ReadAll(resp.Body)
  30193. if ioErr != nil {
  30194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30196. return
  30197. }
  30198. var respJSON map[string]interface{}
  30199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30202. return
  30203. }
  30204. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30205. if status == "0" {
  30206. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30207. c.ServeSuccessJSON(map[string]interface{}{
  30208. "failed_code": -10,
  30209. "msg": err_msg,
  30210. })
  30211. return
  30212. }
  30213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30214. result, _ := json.Marshal(respJSON)
  30215. fmt.Println("log")
  30216. fmt.Println(string(result))
  30217. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30218. utils.ErrorLog("解析失败:%v", err)
  30219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30220. return
  30221. }
  30222. res.InfRefmsgid = ahres.InfRefmsgid
  30223. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30224. // 创建对应的Time类型
  30225. t := time.UnixMilli(timestamp)
  30226. // 格式化成指定的日期字符串
  30227. str := t.Format("2006-01-02 15:04:05")
  30228. res.Output.Setlinfo.SetlTime = str
  30229. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30230. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30231. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30232. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30233. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30234. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30235. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30236. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30237. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30238. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30239. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30240. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30241. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30242. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30243. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30244. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30245. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30246. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30247. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30248. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30249. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30250. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30251. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30252. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30253. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30254. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30255. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30256. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30257. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30258. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30259. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30260. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30261. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30262. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30263. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30264. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30265. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30266. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30267. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30268. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30269. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30270. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30271. //res.Output.Setldetail = ahres.Output.Setldetail
  30272. res.ErrMsg = ahres.ErrMsg
  30273. res.Cainfo = ahres.Cainfo
  30274. res.WarnMsg = ahres.WarnMsg
  30275. res.Infcode = ahres.Infcode
  30276. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30277. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30278. if his.IdCardType == 4 {
  30279. psn_info.VerifyNumber = psn_info.VerifyNumber
  30280. cert_no = psn_info.Certno
  30281. } else if his.IdCardType == 2 {
  30282. cert_no = psn_info.Certno
  30283. psn_info.VerifyNumber = psn_info.Certno
  30284. } else {
  30285. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30286. bas := strings.Split(psn_info.CardInfo, "|")
  30287. if his.IdCardType == 1 {
  30288. cert_no = bas[2]
  30289. } else {
  30290. cert_no = bas[1]
  30291. }
  30292. }
  30293. var api string
  30294. var med_type string
  30295. if his.Insutype == "390" {
  30296. if reg_type == 992102 {
  30297. med_type = "992102"
  30298. }
  30299. if reg_type == 140104 {
  30300. med_type = "140104"
  30301. }
  30302. if reg_type == 140201 {
  30303. med_type = "140201"
  30304. }
  30305. if reg_type == 14 {
  30306. med_type = "14"
  30307. }
  30308. } else if his.Insutype == "310" {
  30309. if reg_type == 992102 {
  30310. med_type = "992102"
  30311. }
  30312. if reg_type == 140104 {
  30313. med_type = "140104"
  30314. }
  30315. if reg_type == 140201 {
  30316. med_type = "140201"
  30317. }
  30318. if reg_type == 14 {
  30319. med_type = "14"
  30320. }
  30321. }
  30322. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30323. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30324. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30325. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30326. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30327. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30328. "&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
  30329. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30330. resp, requestErr := http.Get(api)
  30331. if requestErr != nil {
  30332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30333. return
  30334. }
  30335. body, ioErr := ioutil.ReadAll(resp.Body)
  30336. if ioErr != nil {
  30337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30339. return
  30340. }
  30341. var respJSON map[string]interface{}
  30342. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30345. return
  30346. }
  30347. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30348. if status == "0" {
  30349. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30350. c.ServeSuccessJSON(map[string]interface{}{
  30351. "failed_code": -10,
  30352. "msg": err_msg,
  30353. })
  30354. return
  30355. }
  30356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30357. result, _ := json.Marshal(respJSON)
  30358. fmt.Println("log")
  30359. fmt.Println(string(result))
  30360. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30361. utils.ErrorLog("解析失败:%v", err)
  30362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30363. return
  30364. }
  30365. res.InfRefmsgid = ahres.InfRefmsgid
  30366. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30367. // 创建对应的Time类型
  30368. t := time.UnixMilli(timestamp)
  30369. // 格式化成指定的日期字符串
  30370. str := t.Format("2006-01-02 15:04:05")
  30371. res.Output.Setlinfo.SetlTime = str
  30372. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30373. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30374. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30375. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30376. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30377. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30378. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30379. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30380. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30381. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30382. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30383. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30384. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30385. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30386. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30387. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30388. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30389. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30390. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30391. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30392. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30393. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30394. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30395. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30396. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30397. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30398. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30399. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30400. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30401. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30402. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30403. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30404. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30405. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30406. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30407. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30408. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30409. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30410. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30411. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30412. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30413. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30414. //res.Output.Setldetail = ahres.Output.Setldetail
  30415. res.ErrMsg = ahres.ErrMsg
  30416. res.Cainfo = ahres.Cainfo
  30417. res.WarnMsg = ahres.WarnMsg
  30418. res.Infcode = ahres.Infcode
  30419. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30420. var result string
  30421. var request_log string
  30422. if his.IdCardType == 2 {
  30423. 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")
  30424. } else if his.IdCardType == 1 {
  30425. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30426. bas := strings.Split(psn_info.CardInfo, "|")
  30427. basNumber := bas[2]
  30428. card_sn := bas[3]
  30429. 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")
  30430. } else {
  30431. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30432. 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")
  30433. }
  30434. var dat map[string]interface{}
  30435. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30436. fmt.Println(dat)
  30437. } else {
  30438. fmt.Println(err)
  30439. }
  30440. saveLog(result, request_log, "2206", "预结算")
  30441. userJSONBytes, _ := json.Marshal(dat)
  30442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30443. utils.ErrorLog("解析失败:%v", err)
  30444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30445. return
  30446. }
  30447. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30448. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30449. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30450. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30451. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30452. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30453. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30454. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30455. resp, requestErr := http.Get(api)
  30456. if requestErr != nil {
  30457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30458. return
  30459. }
  30460. body, ioErr := ioutil.ReadAll(resp.Body)
  30461. if ioErr != nil {
  30462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30464. return
  30465. }
  30466. var respJSON map[string]interface{}
  30467. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30470. return
  30471. }
  30472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30473. result, _ := json.Marshal(respJSON)
  30474. fmt.Println("log")
  30475. fmt.Println(string(result))
  30476. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30477. utils.ErrorLog("解析失败:%v", err)
  30478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30479. return
  30480. }
  30481. } else {
  30482. if miConfig.MdtrtareaAdmvs == "441202" {
  30483. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30484. if result3101.Infcode == 0 {
  30485. if len(result3101.Output.Result) > 0 {
  30486. var errMsgs []string
  30487. for _, item := range result3101.Output.Result {
  30488. errMsgs = append(errMsgs, item.VolaCont)
  30489. }
  30490. c.ServeSuccessJSON(map[string]interface{}{
  30491. "failed_code": -10,
  30492. "msg": errMsgs,
  30493. })
  30494. return
  30495. } else {
  30496. var result string
  30497. var request_log string
  30498. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30499. allTotal = fmt.Sprintf("%.2f", total_two)
  30500. if his.IdCardType == 4 {
  30501. 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)
  30502. } else {
  30503. 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)
  30504. }
  30505. var dat map[string]interface{}
  30506. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30507. fmt.Println(dat)
  30508. } else {
  30509. fmt.Println(err)
  30510. }
  30511. saveLog(result, request_log, "2206", "预结算")
  30512. //userJSONBytes, _ := json.Marshal(dat)
  30513. //
  30514. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30515. // utils.ErrorLog("解析失败:%v", err)
  30516. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30517. // return
  30518. //}
  30519. userJSONBytes, _ := json.Marshal(dat)
  30520. if miConfig.Code == "H15049901371" {
  30521. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30522. utils.ErrorLog("解析失败:%v", err)
  30523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30524. return
  30525. }
  30526. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30527. res.Output = resSeven10265.Output
  30528. res.ErrMsg = resSeven10265.ErrMsg
  30529. res.Cainfo = resSeven10265.Cainfo
  30530. res.WarnMsg = resSeven10265.WarnMsg
  30531. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30532. res.Infcode = infocode
  30533. } else {
  30534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30535. utils.ErrorLog("解析失败:%v", err)
  30536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30537. return
  30538. }
  30539. }
  30540. }
  30541. } else {
  30542. c.ServeSuccessJSON(map[string]interface{}{
  30543. "failed_code": -10,
  30544. "msg": result3101.ErrMsg,
  30545. })
  30546. return
  30547. }
  30548. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30549. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30550. if result3101.Infcode == 0 {
  30551. if len(result3101.Output.Result) > 0 {
  30552. var errMsgs []string
  30553. for _, item := range result3101.Output.Result {
  30554. errMsgs = append(errMsgs, item.VolaCont)
  30555. }
  30556. c.ServeSuccessJSON(map[string]interface{}{
  30557. "failed_code": -10,
  30558. "msg": errMsgs,
  30559. })
  30560. return
  30561. } else {
  30562. var result string
  30563. var request_log string
  30564. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30565. allTotal = fmt.Sprintf("%.2f", total_two)
  30566. if his.IdCardType == 4 {
  30567. 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)
  30568. } else {
  30569. 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)
  30570. }
  30571. var dat map[string]interface{}
  30572. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30573. fmt.Println(dat)
  30574. } else {
  30575. fmt.Println(err)
  30576. }
  30577. saveLog(result, request_log, "2206", "预结算")
  30578. //userJSONBytes, _ := json.Marshal(dat)
  30579. //
  30580. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30581. // utils.ErrorLog("解析失败:%v", err)
  30582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30583. // return
  30584. //}
  30585. userJSONBytes, _ := json.Marshal(dat)
  30586. if miConfig.Code == "H15049901371" {
  30587. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30588. utils.ErrorLog("解析失败:%v", err)
  30589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30590. return
  30591. }
  30592. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30593. res.Output = resSeven10265.Output
  30594. res.ErrMsg = resSeven10265.ErrMsg
  30595. res.Cainfo = resSeven10265.Cainfo
  30596. res.WarnMsg = resSeven10265.WarnMsg
  30597. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30598. res.Infcode = infocode
  30599. } else {
  30600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30601. utils.ErrorLog("解析失败:%v", err)
  30602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30603. return
  30604. }
  30605. }
  30606. }
  30607. } else {
  30608. c.ServeSuccessJSON(map[string]interface{}{
  30609. "failed_code": -10,
  30610. "msg": result3101.ErrMsg,
  30611. })
  30612. return
  30613. }
  30614. } else {
  30615. var result string
  30616. var request_log string
  30617. var dat map[string]interface{}
  30618. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30619. allTotal = fmt.Sprintf("%.2f", total_two)
  30620. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  30621. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30622. if result3101.Infcode == 0 {
  30623. if len(result3101.Output.Result) > 0 {
  30624. var errMsgs []string
  30625. for _, item := range result3101.Output.Result {
  30626. errMsgs = append(errMsgs, item.VolaCont)
  30627. }
  30628. c.ServeSuccessJSON(map[string]interface{}{
  30629. "failed_code": -10,
  30630. "msg": errMsgs,
  30631. })
  30632. return
  30633. } else {
  30634. var result string
  30635. var request_log string
  30636. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30637. allTotal = fmt.Sprintf("%.2f", total_two)
  30638. if his.IdCardType == 4 {
  30639. 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)
  30640. } else {
  30641. if his.IdCardType == 2 {
  30642. cert_no = psn_info.Certno
  30643. psn_info.VerifyNumber = psn_info.Certno
  30644. } else {
  30645. bas := strings.Split(psn_info.CardInfo, "|")
  30646. cert_no = bas[2]
  30647. }
  30648. 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)
  30649. }
  30650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30651. fmt.Println(dat)
  30652. } else {
  30653. fmt.Println(err)
  30654. }
  30655. saveLog(result, request_log, "2206", "预结算")
  30656. }
  30657. } else {
  30658. c.ServeSuccessJSON(map[string]interface{}{
  30659. "failed_code": -10,
  30660. "msg": result3101.ErrMsg,
  30661. })
  30662. return
  30663. }
  30664. } else {
  30665. if his.IdCardType == 4 {
  30666. 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)
  30667. } else {
  30668. if his.IdCardType == 2 {
  30669. cert_no = psn_info.Certno
  30670. psn_info.VerifyNumber = psn_info.Certno
  30671. } else {
  30672. bas := strings.Split(psn_info.CardInfo, "|")
  30673. cert_no = bas[2]
  30674. }
  30675. 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)
  30676. }
  30677. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30678. fmt.Println(dat)
  30679. } else {
  30680. fmt.Println(err)
  30681. }
  30682. saveLog(result, request_log, "2206", "预结算")
  30683. }
  30684. //userJSONBytes, _ := json.Marshal(dat)
  30685. //
  30686. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30687. // utils.ErrorLog("解析失败:%v", err)
  30688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30689. // return
  30690. //}
  30691. userJSONBytes, _ := json.Marshal(dat)
  30692. if miConfig.Code == "H15049901371" {
  30693. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30694. utils.ErrorLog("解析失败:%v", err)
  30695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30696. return
  30697. }
  30698. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30699. res.Output = resSeven10265.Output
  30700. res.ErrMsg = resSeven10265.ErrMsg
  30701. res.Cainfo = resSeven10265.Cainfo
  30702. res.WarnMsg = resSeven10265.WarnMsg
  30703. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30704. res.Infcode = infocode
  30705. } else {
  30706. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30707. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30708. utils.ErrorLog("解析失败:%v", err)
  30709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30710. return
  30711. }
  30712. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30713. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30714. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30715. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30716. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30717. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30718. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30719. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30720. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30721. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30722. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30723. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30724. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30725. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30726. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30727. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30728. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30729. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30730. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30731. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30732. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30733. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30734. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30735. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30736. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30737. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30738. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30739. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30740. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30741. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30742. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30743. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30744. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30745. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30746. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30747. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30748. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30749. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30750. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30751. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30752. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30753. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30754. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30755. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30756. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30757. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30758. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30759. res.Cainfo = gzresSeven10265Two.Cainfo
  30760. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30761. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30762. //res.Infcode = infocode
  30763. } else {
  30764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30765. utils.ErrorLog("解析失败:%v", err)
  30766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30767. return
  30768. }
  30769. }
  30770. }
  30771. }
  30772. }
  30773. utils.ErrorLog("解析失败:%v", res.Infcode)
  30774. if res.Infcode == -1 {
  30775. errlog := &models.HisOrderError{
  30776. UserOrgId: adminUser.CurrentOrgId,
  30777. Ctime: time.Now().Unix(),
  30778. Mtime: time.Now().Unix(),
  30779. Number: chrg_bchno,
  30780. ErrMsg: res.ErrMsg,
  30781. Status: 1,
  30782. PatientId: id,
  30783. RecordTime: recordDateTime,
  30784. Stage: 20,
  30785. }
  30786. service.CreateErrMsgLog(errlog)
  30787. c.ServeSuccessJSON(map[string]interface{}{
  30788. "failed_code": -10,
  30789. "msg": res.ErrMsg,
  30790. })
  30791. return
  30792. }
  30793. if res.Infcode != 0 {
  30794. errlog := &models.HisOrderError{
  30795. UserOrgId: adminUser.CurrentOrgId,
  30796. Ctime: time.Now().Unix(),
  30797. Mtime: time.Now().Unix(),
  30798. Number: chrg_bchno,
  30799. ErrMsg: res.ErrMsg,
  30800. Status: 1,
  30801. PatientId: id,
  30802. RecordTime: recordDateTime,
  30803. Stage: 20,
  30804. }
  30805. service.CreateErrMsgLog(errlog)
  30806. c.ServeSuccessJSON(map[string]interface{}{
  30807. "failed_code": -10,
  30808. "msg": res.ErrMsg,
  30809. })
  30810. return
  30811. } else {
  30812. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30813. order.OrderStatus = 1
  30814. order.IsPre = 1
  30815. order.Status = 1
  30816. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30817. order.SetlId = res.Output.Setlinfo.SetlID
  30818. order.PsnNo = res.Output.Setlinfo.PsnNo
  30819. order.PsnName = res.Output.Setlinfo.PsnName
  30820. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30821. order.Certno = res.Output.Setlinfo.Certno
  30822. order.Gend = res.Output.Setlinfo.Gend
  30823. order.Naty = res.Output.Setlinfo.Naty
  30824. order.Age = res.Output.Setlinfo.Age
  30825. order.Insutype = res.Output.Setlinfo.Insutype
  30826. order.PsnType = res.Output.Setlinfo.PsnType
  30827. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30828. order.SetlTime = res.Output.Setlinfo.SetlTime
  30829. order.AcctUsedFlag = acct_used_flag
  30830. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30831. if res.Output.Setlinfo.MedType == "140101" {
  30832. order.MedType = "14"
  30833. } else {
  30834. if res.Output.Setlinfo.MedType == "110104" {
  30835. order.MedType = "11"
  30836. } else {
  30837. order.MedType = res.Output.Setlinfo.MedType
  30838. }
  30839. }
  30840. if res.Output.Setlinfo.MedType == "992102" {
  30841. order.MedType = "992102"
  30842. }
  30843. if res.Output.Setlinfo.MedType == "140104" {
  30844. order.MedType = "140104"
  30845. }
  30846. if res.Output.Setlinfo.MedType == "140201" {
  30847. order.MedType = "140201"
  30848. }
  30849. if res.Output.Setlinfo.MedType == "14" {
  30850. order.MedType = "14"
  30851. }
  30852. if reg_type == 1112 {
  30853. order.MedType = "1112"
  30854. }
  30855. if reg_type == 1111 {
  30856. order.MedType = "1111"
  30857. }
  30858. order.ClrType = res.Output.Setlinfo.ClrType
  30859. if adminUser.CurrentOrgId == 10480 {
  30860. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30861. order.ClrType = "11"
  30862. } else {
  30863. order.ClrType = "9903"
  30864. }
  30865. }
  30866. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30867. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30868. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30869. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30870. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30871. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30872. order.HifpPay = res.Output.Setlinfo.HifpPay
  30873. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30874. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30875. order.HifesPay = res.Output.Setlinfo.HifesPay
  30876. order.HifobPay = res.Output.Setlinfo.HifobPay
  30877. order.MafPay = res.Output.Setlinfo.MafPay
  30878. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30879. order.OthPay = res.Output.Setlinfo.OthPay
  30880. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30881. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30882. order.AcctPay = res.Output.Setlinfo.AcctPay
  30883. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30884. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30885. order.Balc = res.Output.Setlinfo.Balc
  30886. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30887. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30888. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30889. order.ClrWay = res.Output.Setlinfo.ClrWay
  30890. order.Creator = order.Creator
  30891. order.Modify = roles.AdminUserId
  30892. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30893. //detailStr := string(setlDetail)
  30894. //order.SetlDetail = detailStr
  30895. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30896. err = service.UpDateOrder(order)
  30897. if err == nil {
  30898. c.ServeSuccessJSON(map[string]interface{}{
  30899. "msg": "预结算成功",
  30900. })
  30901. } else {
  30902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30903. return
  30904. }
  30905. }
  30906. } else {
  30907. adminUser := c.GetAdminUserInfo()
  30908. errlog := &models.HisOrderError{
  30909. UserOrgId: adminUser.CurrentOrgId,
  30910. Ctime: time.Now().Unix(),
  30911. Mtime: time.Now().Unix(),
  30912. ErrMsg: res.ErrMsg,
  30913. Status: 1,
  30914. PatientId: id,
  30915. RecordTime: recordDateTime,
  30916. Stage: 4,
  30917. }
  30918. service.CreateErrMsgLog(errlog)
  30919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  30920. return
  30921. }
  30922. } else {
  30923. if miConfig.MdtrtareaAdmvs == "150499" {
  30924. order := &models.HisOrder{
  30925. UserOrgId: adminUser.CurrentOrgId,
  30926. HisPatientId: his.ID,
  30927. PatientId: his.PatientId,
  30928. SettleAccountsDate: recordDateTime,
  30929. Ctime: time.Now().Unix(),
  30930. Mtime: time.Now().Unix(),
  30931. MdtrtId: his.Number,
  30932. PsnNo: his.PsnNo,
  30933. MedType: strconv.FormatInt(reg_type, 10),
  30934. Status: 1,
  30935. Number: chrg_bchno,
  30936. Infcode: res.Infcode,
  30937. WarnMsg: res.WarnMsg,
  30938. Cainfo: res.Cainfo,
  30939. ErrMsg: res.ErrMsg,
  30940. RespondTime: res.RefmsgTime,
  30941. InfRefmsgid: res.InfRefmsgid,
  30942. OrderStatus: 1,
  30943. IsMedicineInsurance: 1,
  30944. SettleType: settle_accounts_type,
  30945. SettleStartTime: start_time,
  30946. SettleEndTime: end_time,
  30947. Creator: roles.AdminUserId,
  30948. Modify: roles.AdminUserId,
  30949. PType: 2,
  30950. Diagnosis: diagnosis_id,
  30951. }
  30952. err = service.CreateOrder(order)
  30953. if err != nil {
  30954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30955. return
  30956. }
  30957. }
  30958. adminUser := c.GetAdminUserInfo()
  30959. errlog := &models.HisOrderError{
  30960. UserOrgId: adminUser.CurrentOrgId,
  30961. Ctime: time.Now().Unix(),
  30962. Mtime: time.Now().Unix(),
  30963. ErrMsg: res.ErrMsg,
  30964. Status: 1,
  30965. PatientId: id,
  30966. RecordTime: recordDateTime,
  30967. Stage: 4,
  30968. }
  30969. service.CreateErrMsgLog(errlog)
  30970. c.ServeSuccessJSON(map[string]interface{}{
  30971. "failed_code": -10,
  30972. "msg": res.ErrMsg,
  30973. })
  30974. return
  30975. }
  30976. }
  30977. }
  30978. }
  30979. // 退款
  30980. func (c *HisApiController) Refund() {
  30981. order_id, _ := c.GetInt64("order_id")
  30982. admin_user_id, _ := c.GetInt64("admin_user_id")
  30983. adminUser := c.GetAdminUserInfo()
  30984. var order models.HisOrder
  30985. order, _ = service.GetHisOrderByID(order_id)
  30986. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  30987. if fapiao.ID > 0 {
  30988. c.ServeSuccessJSON(map[string]interface{}{
  30989. "failed_code": -10,
  30990. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  30991. })
  30992. return
  30993. }
  30994. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30995. if order.ID == 0 {
  30996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30997. return
  30998. }
  30999. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31000. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31001. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31002. if config.IsOpen == 1 { //对接了医保,走医保流程
  31003. var res ResultSixteen
  31004. var ahres ResultSevenAH
  31005. var resSixteen10265 ResultSixteen10265
  31006. var resSixteen10265Two ResultSixteen10265Two
  31007. var gz ResultgzSixteen10265Two
  31008. var src_resquest string
  31009. var result string
  31010. if miConfig.MdtrtareaAdmvs == "421300" {
  31011. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31012. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31013. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31014. resp3, requestErr3 := http.Get(api3)
  31015. if requestErr3 != nil {
  31016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31017. return
  31018. }
  31019. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31020. if ioErr3 != nil {
  31021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31023. return
  31024. }
  31025. var respJSON3 map[string]interface{}
  31026. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31029. return
  31030. }
  31031. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31032. userJSONBytes3, _ := json.Marshal(respJSON3)
  31033. fmt.Println("log")
  31034. fmt.Println(string(userJSONBytes3))
  31035. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31036. utils.ErrorLog("解析失败:%v", err)
  31037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31038. return
  31039. }
  31040. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31041. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31042. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31043. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31044. resp3, requestErr3 := http.Get(api3)
  31045. if requestErr3 != nil {
  31046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31047. return
  31048. }
  31049. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31050. if ioErr3 != nil {
  31051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31053. return
  31054. }
  31055. var respJSON3 map[string]interface{}
  31056. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31059. return
  31060. }
  31061. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31062. userJSONBytes3, _ := json.Marshal(respJSON3)
  31063. fmt.Println("log")
  31064. fmt.Println(string(userJSONBytes3))
  31065. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31066. utils.ErrorLog("解析失败:%v", err)
  31067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31068. return
  31069. }
  31070. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31071. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31072. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31073. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31074. resp3, requestErr3 := http.Get(api3)
  31075. if requestErr3 != nil {
  31076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31077. return
  31078. }
  31079. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31080. if ioErr3 != nil {
  31081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31083. return
  31084. }
  31085. var respJSON3 map[string]interface{}
  31086. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31089. return
  31090. }
  31091. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31092. userJSONBytes3, _ := json.Marshal(respJSON3)
  31093. fmt.Println("log")
  31094. fmt.Println(string(userJSONBytes3))
  31095. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31096. utils.ErrorLog("解析失败:%v", err)
  31097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31098. return
  31099. }
  31100. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31101. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31102. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31103. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31104. resp3, requestErr3 := http.Get(api3)
  31105. if requestErr3 != nil {
  31106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31107. return
  31108. }
  31109. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31110. if ioErr3 != nil {
  31111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31113. return
  31114. }
  31115. var respJSON3 map[string]interface{}
  31116. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31119. return
  31120. }
  31121. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31122. userJSONBytes3, _ := json.Marshal(respJSON3)
  31123. fmt.Println("log")
  31124. fmt.Println(string(userJSONBytes3))
  31125. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31126. utils.ErrorLog("解析失败:%v", err)
  31127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31128. return
  31129. }
  31130. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31131. var api3 string
  31132. if miConfig.MdtrtareaAdmvs == "320921" {
  31133. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31134. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31135. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31136. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31137. } else {
  31138. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31139. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31140. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31141. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31142. }
  31143. resp3, requestErr3 := http.Get(api3)
  31144. if requestErr3 != nil {
  31145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31146. return
  31147. }
  31148. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31149. if ioErr3 != nil {
  31150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31152. return
  31153. }
  31154. var respJSON3 map[string]interface{}
  31155. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31158. return
  31159. }
  31160. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31161. userJSONBytes3, _ := json.Marshal(respJSON3)
  31162. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31163. utils.ErrorLog("解析失败:%v", err)
  31164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31165. return
  31166. }
  31167. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31168. res.Output = resSixteen10265.Output
  31169. res.ErrMsg = resSixteen10265.ErrMsg
  31170. res.Cainfo = resSixteen10265.Cainfo
  31171. res.WarnMsg = resSixteen10265.WarnMsg
  31172. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31173. res.Infcode = infocode
  31174. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31175. var api3 string
  31176. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31177. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31178. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31179. resp3, requestErr3 := http.Get(api3)
  31180. if requestErr3 != nil {
  31181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31182. return
  31183. }
  31184. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31185. if ioErr3 != nil {
  31186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31188. return
  31189. }
  31190. var respJSON3 map[string]interface{}
  31191. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31194. return
  31195. }
  31196. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31197. userJSONBytes3, _ := json.Marshal(respJSON3)
  31198. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31199. utils.ErrorLog("解析失败:%v", err)
  31200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31201. return
  31202. }
  31203. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31204. res.Output = resSixteen10265.Output
  31205. res.ErrMsg = resSixteen10265.ErrMsg
  31206. res.Cainfo = resSixteen10265.Cainfo
  31207. res.WarnMsg = resSixteen10265.WarnMsg
  31208. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31209. res.Infcode = infocode
  31210. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31211. 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)
  31212. var dat map[string]interface{}
  31213. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31214. fmt.Println(dat)
  31215. } else {
  31216. fmt.Println(err)
  31217. }
  31218. saveLog(result, src_resquest, "2208", "退费")
  31219. userJSONBytes, _ := json.Marshal(dat)
  31220. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31221. utils.ErrorLog("解析失败:%v", err)
  31222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31223. return
  31224. }
  31225. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31226. 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, "")
  31227. var dat map[string]interface{}
  31228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31229. fmt.Println(dat)
  31230. } else {
  31231. fmt.Println(err)
  31232. }
  31233. saveLog(result, src_resquest, "2208", "退费")
  31234. userJSONBytes, _ := json.Marshal(dat)
  31235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31236. utils.ErrorLog("解析失败:%v", err)
  31237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31238. return
  31239. }
  31240. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31241. 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, "")
  31242. var dat map[string]interface{}
  31243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31244. fmt.Println(dat)
  31245. } else {
  31246. fmt.Println(err)
  31247. }
  31248. saveLog(result, src_resquest, "2208", "退费")
  31249. userJSONBytes, _ := json.Marshal(dat)
  31250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31251. utils.ErrorLog("解析失败:%v", err)
  31252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31253. return
  31254. }
  31255. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31256. var api3 string
  31257. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31258. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31259. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31260. resp3, requestErr3 := http.Get(api3)
  31261. if requestErr3 != nil {
  31262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31263. return
  31264. }
  31265. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31266. if ioErr3 != nil {
  31267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31269. return
  31270. }
  31271. var respJSON3 map[string]interface{}
  31272. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31275. return
  31276. }
  31277. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31278. if status == "0" {
  31279. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31280. c.ServeSuccessJSON(map[string]interface{}{
  31281. "failed_code": -10,
  31282. "msg": err_msg,
  31283. })
  31284. return
  31285. }
  31286. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31287. userJSONBytes3, _ := json.Marshal(respJSON3)
  31288. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31289. // utils.ErrorLog("解析失败:%v", err)
  31290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31291. // return
  31292. //}
  31293. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31294. utils.ErrorLog("解析失败:%v", err)
  31295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31296. return
  31297. }
  31298. res.InfRefmsgid = ahres.InfRefmsgid
  31299. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31300. // 创建对应的Time类型
  31301. t := time.UnixMilli(timestamp)
  31302. // 格式化成指定的日期字符串
  31303. str := t.Format("2006-01-02 15:04:05")
  31304. res.Output.Setlinfo.SetlTime = str
  31305. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31306. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31307. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31308. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31309. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31310. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31311. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31312. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31313. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31314. //
  31315. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31316. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31317. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31318. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31319. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31320. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31321. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31322. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31323. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31324. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31325. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31326. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31327. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31328. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31329. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31330. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31331. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31332. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31333. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31334. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31335. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31336. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31337. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31338. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31339. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31340. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31341. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31342. //res.Output.Setldetail = ahres.Output.Setldetail
  31343. res.ErrMsg = ahres.ErrMsg
  31344. res.Cainfo = ahres.Cainfo
  31345. res.WarnMsg = ahres.WarnMsg
  31346. res.Infcode = ahres.Infcode
  31347. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31348. var api3 string
  31349. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31350. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31351. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31352. resp3, requestErr3 := http.Get(api3)
  31353. if requestErr3 != nil {
  31354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31355. return
  31356. }
  31357. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31358. if ioErr3 != nil {
  31359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31361. return
  31362. }
  31363. var respJSON3 map[string]interface{}
  31364. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31367. return
  31368. }
  31369. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31370. if status == "0" {
  31371. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31372. c.ServeSuccessJSON(map[string]interface{}{
  31373. "failed_code": -10,
  31374. "msg": err_msg,
  31375. })
  31376. return
  31377. }
  31378. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31379. userJSONBytes3, _ := json.Marshal(respJSON3)
  31380. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31381. // utils.ErrorLog("解析失败:%v", err)
  31382. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31383. // return
  31384. //}
  31385. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31386. utils.ErrorLog("解析失败:%v", err)
  31387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31388. return
  31389. }
  31390. res.InfRefmsgid = ahres.InfRefmsgid
  31391. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31392. // 创建对应的Time类型
  31393. t := time.UnixMilli(timestamp)
  31394. // 格式化成指定的日期字符串
  31395. str := t.Format("2006-01-02 15:04:05")
  31396. res.Output.Setlinfo.SetlTime = str
  31397. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31398. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31399. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31400. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31401. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31402. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31403. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31404. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31405. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31406. //
  31407. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31408. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31409. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31410. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31411. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31412. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31413. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31414. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31415. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31416. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31417. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31418. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31419. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31420. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31421. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31422. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31423. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31424. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31425. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31426. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31427. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31428. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31429. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31430. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31431. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31432. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31433. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31434. //res.Output.Setldetail = ahres.Output.Setldetail
  31435. res.ErrMsg = ahres.ErrMsg
  31436. res.Cainfo = ahres.Cainfo
  31437. res.WarnMsg = ahres.WarnMsg
  31438. res.Infcode = ahres.Infcode
  31439. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31440. 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, "")
  31441. var dat map[string]interface{}
  31442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31443. fmt.Println(dat)
  31444. } else {
  31445. fmt.Println(err)
  31446. }
  31447. saveLog(result, src_resquest, "2208", "退费")
  31448. userJSONBytes, _ := json.Marshal(dat)
  31449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31450. utils.ErrorLog("解析失败:%v", err)
  31451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31452. return
  31453. }
  31454. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31455. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31456. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31457. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31458. resp3, requestErr3 := http.Get(api3)
  31459. if requestErr3 != nil {
  31460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31461. return
  31462. }
  31463. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31464. if ioErr3 != nil {
  31465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31467. return
  31468. }
  31469. var respJSON3 map[string]interface{}
  31470. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31473. return
  31474. }
  31475. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31476. userJSONBytes3, _ := json.Marshal(respJSON3)
  31477. fmt.Println("log")
  31478. fmt.Println(string(userJSONBytes3))
  31479. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31480. utils.ErrorLog("解析失败:%v", err)
  31481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31482. return
  31483. }
  31484. } else {
  31485. if miConfig.Code == "H15049901371" {
  31486. 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)
  31487. var dat map[string]interface{}
  31488. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31489. fmt.Println(dat)
  31490. } else {
  31491. fmt.Println(err)
  31492. }
  31493. saveLog(result, src_resquest, "2208", "退费")
  31494. if strings.Contains(result, "Post") {
  31495. res.Infcode = -1
  31496. res.ErrMsg = result
  31497. }
  31498. userJSONBytes, _ := json.Marshal(dat)
  31499. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31500. utils.ErrorLog("解析失败:%v", err)
  31501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31502. return
  31503. }
  31504. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31505. res.Output = resSixteen10265.Output
  31506. res.ErrMsg = resSixteen10265.ErrMsg
  31507. res.Cainfo = resSixteen10265.Cainfo
  31508. res.WarnMsg = resSixteen10265.WarnMsg
  31509. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31510. res.Infcode = infocode
  31511. } else {
  31512. 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)
  31513. var dat map[string]interface{}
  31514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31515. fmt.Println(dat)
  31516. } else {
  31517. fmt.Println(err)
  31518. }
  31519. saveLog(result, src_resquest, "2208", "退费")
  31520. userJSONBytes, _ := json.Marshal(dat)
  31521. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31522. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31523. utils.ErrorLog("解析失败:%v", err)
  31524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31525. return
  31526. }
  31527. res.Infcode = gz.Infcode
  31528. } else {
  31529. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31530. utils.ErrorLog("解析失败:%v", err)
  31531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31532. return
  31533. }
  31534. }
  31535. if strings.Contains(result, "Post") {
  31536. res.Infcode = -1
  31537. res.ErrMsg = result
  31538. }
  31539. }
  31540. }
  31541. if res.Infcode == -1 {
  31542. c.ServeSuccessJSON(map[string]interface{}{
  31543. "failed_code": -10,
  31544. "msg": res.ErrMsg,
  31545. })
  31546. return
  31547. }
  31548. if res.Infcode != -1 {
  31549. var res2 ResultSix
  31550. var resSix10265 ResultSix10265
  31551. if miConfig.MdtrtareaAdmvs == "421300" {
  31552. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31553. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31554. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31555. resp3, requestErr3 := http.Get(api3)
  31556. if requestErr3 != nil {
  31557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31558. return
  31559. }
  31560. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31561. if ioErr3 != nil {
  31562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31564. return
  31565. }
  31566. var respJSON3 map[string]interface{}
  31567. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31570. return
  31571. }
  31572. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31573. userJSONBytes3, _ := json.Marshal(respJSON3)
  31574. fmt.Println("log")
  31575. fmt.Println(string(userJSONBytes3))
  31576. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31577. utils.ErrorLog("解析失败:%v", err)
  31578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31579. return
  31580. }
  31581. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31582. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31583. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31584. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31585. resp3, requestErr3 := http.Get(api3)
  31586. if requestErr3 != nil {
  31587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31588. return
  31589. }
  31590. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31591. if ioErr3 != nil {
  31592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31594. return
  31595. }
  31596. var respJSON3 map[string]interface{}
  31597. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31600. return
  31601. }
  31602. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31603. userJSONBytes3, _ := json.Marshal(respJSON3)
  31604. fmt.Println("log")
  31605. fmt.Println(string(userJSONBytes3))
  31606. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31607. utils.ErrorLog("解析失败:%v", err)
  31608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31609. return
  31610. }
  31611. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31612. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31613. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31614. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31615. resp3, requestErr3 := http.Get(api3)
  31616. if requestErr3 != nil {
  31617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31618. return
  31619. }
  31620. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31621. if ioErr3 != nil {
  31622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31624. return
  31625. }
  31626. var respJSON3 map[string]interface{}
  31627. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31630. return
  31631. }
  31632. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31633. userJSONBytes3, _ := json.Marshal(respJSON3)
  31634. fmt.Println("log")
  31635. fmt.Println(string(userJSONBytes3))
  31636. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31637. utils.ErrorLog("解析失败:%v", err)
  31638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31639. return
  31640. }
  31641. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31642. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31643. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31644. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31645. resp3, requestErr3 := http.Get(api3)
  31646. if requestErr3 != nil {
  31647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31648. return
  31649. }
  31650. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31651. if ioErr3 != nil {
  31652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31654. return
  31655. }
  31656. var respJSON3 map[string]interface{}
  31657. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31660. return
  31661. }
  31662. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31663. userJSONBytes3, _ := json.Marshal(respJSON3)
  31664. fmt.Println("log")
  31665. fmt.Println(string(userJSONBytes3))
  31666. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31667. utils.ErrorLog("解析失败:%v", err)
  31668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31669. return
  31670. }
  31671. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31672. var api3 string
  31673. if miConfig.MdtrtareaAdmvs == "320921" {
  31674. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31675. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31676. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31677. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31678. } else {
  31679. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31680. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31681. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31682. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31683. }
  31684. resp3, requestErr3 := http.Get(api3)
  31685. if requestErr3 != nil {
  31686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31687. return
  31688. }
  31689. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31690. if ioErr3 != nil {
  31691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31693. return
  31694. }
  31695. var respJSON3 map[string]interface{}
  31696. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31699. return
  31700. }
  31701. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31702. userJSONBytes3, _ := json.Marshal(respJSON3)
  31703. fmt.Println("log")
  31704. fmt.Println(string(userJSONBytes3))
  31705. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31706. utils.ErrorLog("解析失败:%v", err)
  31707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31708. return
  31709. }
  31710. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31711. res2.Output = resSix10265.Output
  31712. res2.ErrMsg = resSix10265.ErrMsg
  31713. res2.Cainfo = resSix10265.Cainfo
  31714. res2.WarnMsg = resSix10265.WarnMsg
  31715. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31716. res2.Infcode = infocode
  31717. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31718. var api3 string
  31719. new_chrg_bchno := order.Number
  31720. if adminUser.CurrentOrgId == 10265 {
  31721. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31722. new_chrg_bchno = "0000"
  31723. }
  31724. }
  31725. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31726. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31727. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31728. resp3, requestErr3 := http.Get(api3)
  31729. if requestErr3 != nil {
  31730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31731. return
  31732. }
  31733. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31734. if ioErr3 != nil {
  31735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31737. return
  31738. }
  31739. var respJSON3 map[string]interface{}
  31740. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31743. return
  31744. }
  31745. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31746. userJSONBytes3, _ := json.Marshal(respJSON3)
  31747. fmt.Println("log")
  31748. fmt.Println(string(userJSONBytes3))
  31749. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31750. utils.ErrorLog("解析失败:%v", err)
  31751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31752. return
  31753. }
  31754. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31755. res2.Output = resSix10265.Output
  31756. res2.ErrMsg = resSix10265.ErrMsg
  31757. res2.Cainfo = resSix10265.Cainfo
  31758. res2.WarnMsg = resSix10265.WarnMsg
  31759. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31760. res2.Infcode = infocode
  31761. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31762. 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)
  31763. var dat map[string]interface{}
  31764. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31765. fmt.Println(dat)
  31766. } else {
  31767. fmt.Println(err)
  31768. }
  31769. saveLog(result2, src_request, "2205", "撤销明细")
  31770. userJSONBytes, _ := json.Marshal(dat)
  31771. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31772. utils.ErrorLog("解析失败:%v", err)
  31773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31774. return
  31775. }
  31776. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31777. 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, "")
  31778. var dat map[string]interface{}
  31779. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31780. fmt.Println(dat)
  31781. } else {
  31782. fmt.Println(err)
  31783. }
  31784. saveLog(result2, src_request, "2205", "撤销明细")
  31785. userJSONBytes, _ := json.Marshal(dat)
  31786. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31787. utils.ErrorLog("解析失败:%v", err)
  31788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31789. return
  31790. }
  31791. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31792. 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, "")
  31793. var dat map[string]interface{}
  31794. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31795. fmt.Println(dat)
  31796. } else {
  31797. fmt.Println(err)
  31798. }
  31799. saveLog(result2, src_request, "2205", "撤销明细")
  31800. userJSONBytes, _ := json.Marshal(dat)
  31801. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31802. utils.ErrorLog("解析失败:%v", err)
  31803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31804. return
  31805. }
  31806. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31807. var api3 string
  31808. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31809. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31810. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31811. resp3, requestErr3 := http.Get(api3)
  31812. if requestErr3 != nil {
  31813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31814. return
  31815. }
  31816. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31817. if ioErr3 != nil {
  31818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31820. return
  31821. }
  31822. var respJSON3 map[string]interface{}
  31823. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31826. return
  31827. }
  31828. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31829. if status == "0" {
  31830. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31831. c.ServeSuccessJSON(map[string]interface{}{
  31832. "failed_code": -10,
  31833. "msg": err_msg,
  31834. })
  31835. return
  31836. }
  31837. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31838. userJSONBytes3, _ := json.Marshal(respJSON3)
  31839. fmt.Println("log")
  31840. fmt.Println(string(userJSONBytes3))
  31841. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31842. utils.ErrorLog("解析失败:%v", err)
  31843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31844. return
  31845. }
  31846. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31847. 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, "")
  31848. var dat map[string]interface{}
  31849. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31850. fmt.Println(dat)
  31851. } else {
  31852. fmt.Println(err)
  31853. }
  31854. saveLog(result2, src_request, "2205", "撤销明细")
  31855. userJSONBytes, _ := json.Marshal(dat)
  31856. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31857. utils.ErrorLog("解析失败:%v", err)
  31858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31859. return
  31860. }
  31861. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31862. 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, "")
  31863. var dat map[string]interface{}
  31864. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31865. fmt.Println(dat)
  31866. } else {
  31867. fmt.Println(err)
  31868. }
  31869. saveLog(result2, src_request, "2205", "撤销明细")
  31870. userJSONBytes, _ := json.Marshal(dat)
  31871. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31872. utils.ErrorLog("解析失败:%v", err)
  31873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31874. return
  31875. }
  31876. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31877. var api3 string
  31878. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31879. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31880. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31881. resp3, requestErr3 := http.Get(api3)
  31882. if requestErr3 != nil {
  31883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31884. return
  31885. }
  31886. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31887. if ioErr3 != nil {
  31888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31890. return
  31891. }
  31892. var respJSON3 map[string]interface{}
  31893. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31896. return
  31897. }
  31898. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31899. if status == "0" {
  31900. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31901. c.ServeSuccessJSON(map[string]interface{}{
  31902. "failed_code": -10,
  31903. "msg": err_msg,
  31904. })
  31905. return
  31906. }
  31907. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31908. userJSONBytes3, _ := json.Marshal(respJSON3)
  31909. fmt.Println("log")
  31910. fmt.Println(string(userJSONBytes3))
  31911. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31912. utils.ErrorLog("解析失败:%v", err)
  31913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31914. return
  31915. }
  31916. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31917. 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, "")
  31918. var dat map[string]interface{}
  31919. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31920. fmt.Println(dat)
  31921. } else {
  31922. fmt.Println(err)
  31923. }
  31924. saveLog(result2, src_request, "2205", "撤销明细")
  31925. userJSONBytes, _ := json.Marshal(dat)
  31926. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31927. utils.ErrorLog("解析失败:%v", err)
  31928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31929. return
  31930. }
  31931. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31932. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  31933. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31934. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31935. resp3, requestErr3 := http.Get(api3)
  31936. if requestErr3 != nil {
  31937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31938. return
  31939. }
  31940. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31941. if ioErr3 != nil {
  31942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31944. return
  31945. }
  31946. var respJSON3 map[string]interface{}
  31947. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31950. return
  31951. }
  31952. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31953. userJSONBytes3, _ := json.Marshal(respJSON3)
  31954. fmt.Println("log")
  31955. fmt.Println(string(userJSONBytes3))
  31956. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31957. utils.ErrorLog("解析失败:%v", err)
  31958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31959. return
  31960. }
  31961. } else {
  31962. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31963. res2.Infcode = 0
  31964. } else {
  31965. 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)
  31966. var dat map[string]interface{}
  31967. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31968. fmt.Println(dat)
  31969. } else {
  31970. fmt.Println(err)
  31971. }
  31972. saveLog(result2, src_request, "2205", "撤销明细")
  31973. userJSONBytes, _ := json.Marshal(dat)
  31974. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31975. utils.ErrorLog("解析失败:%v", err)
  31976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31977. return
  31978. }
  31979. }
  31980. }
  31981. if res2.Infcode == -1 {
  31982. c.ServeSuccessJSON(map[string]interface{}{
  31983. "failed_code": -10,
  31984. "msg": res2.ErrMsg,
  31985. })
  31986. return
  31987. }
  31988. if res2.Infcode == 0 {
  31989. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  31990. if err == nil {
  31991. //当押金不为零时产生退费记录
  31992. if order.Decimal != 0 {
  31993. tmp := strconv.FormatInt(order.ID, 10)
  31994. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  31995. if err != nil {
  31996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31997. return
  31998. }
  31999. }
  32000. c.ServeSuccessJSON(map[string]interface{}{
  32001. "msg": "退费成功",
  32002. })
  32003. } else {
  32004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32005. return
  32006. }
  32007. } else {
  32008. c.ServeSuccessJSON(map[string]interface{}{
  32009. "failed_code": -10,
  32010. "msg": res2.ErrMsg,
  32011. })
  32012. }
  32013. } else {
  32014. c.ServeSuccessJSON(map[string]interface{}{
  32015. "failed_code": -10,
  32016. "msg": res.ErrMsg,
  32017. })
  32018. }
  32019. }
  32020. }
  32021. func (c *HisApiController) RefundNumber() {
  32022. record_time := c.GetString("record_time")
  32023. //patient_id, _ := c.GetInt64("patient_id")
  32024. admin_user_id, _ := c.GetInt64("admin_user_id")
  32025. his_patient_id, _ := c.GetInt64("id")
  32026. timeLayout := "2006-01-02"
  32027. loc, _ := time.LoadLocation("Local")
  32028. adminUser := c.GetAdminUserInfo()
  32029. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32030. fmt.Println(err)
  32031. if err != nil {
  32032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32033. return
  32034. }
  32035. recordDateTime := theTime.Unix()
  32036. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32037. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32038. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32039. //order, _ := service.GetHisOrderByID(order_id)
  32040. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32041. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32042. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32043. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32044. if count > 0 {
  32045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32046. return
  32047. }
  32048. if config.IsOpen == 1 { //对接了医保,走医保流程
  32049. var res2 ResultSix
  32050. var res3 GZResultSix
  32051. var resSix10265 ResultSix10265
  32052. if miConfig.MdtrtareaAdmvs == "421300" {
  32053. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32054. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32055. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32056. resp3, requestErr3 := http.Get(api3)
  32057. if requestErr3 != nil {
  32058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32059. return
  32060. }
  32061. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32062. if ioErr3 != nil {
  32063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32065. return
  32066. }
  32067. var respJSON3 map[string]interface{}
  32068. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32071. return
  32072. }
  32073. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32074. userJSONBytes3, _ := json.Marshal(respJSON3)
  32075. fmt.Println("log")
  32076. fmt.Println(string(userJSONBytes3))
  32077. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32078. utils.ErrorLog("解析失败:%v", err)
  32079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32080. return
  32081. }
  32082. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32083. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32084. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32085. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32086. resp3, requestErr3 := http.Get(api3)
  32087. if requestErr3 != nil {
  32088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32089. return
  32090. }
  32091. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32092. if ioErr3 != nil {
  32093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32095. return
  32096. }
  32097. var respJSON3 map[string]interface{}
  32098. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32101. return
  32102. }
  32103. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32104. userJSONBytes3, _ := json.Marshal(respJSON3)
  32105. fmt.Println("log")
  32106. fmt.Println(string(userJSONBytes3))
  32107. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32108. utils.ErrorLog("解析失败:%v", err)
  32109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32110. return
  32111. }
  32112. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32113. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32114. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32115. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32116. resp3, requestErr3 := http.Get(api3)
  32117. if requestErr3 != nil {
  32118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32119. return
  32120. }
  32121. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32122. if ioErr3 != nil {
  32123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32125. return
  32126. }
  32127. var respJSON3 map[string]interface{}
  32128. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32131. return
  32132. }
  32133. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32134. userJSONBytes3, _ := json.Marshal(respJSON3)
  32135. fmt.Println("log")
  32136. fmt.Println(string(userJSONBytes3))
  32137. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32138. utils.ErrorLog("解析失败:%v", err)
  32139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32140. return
  32141. }
  32142. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32143. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32144. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32145. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32146. resp3, requestErr3 := http.Get(api3)
  32147. if requestErr3 != nil {
  32148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32149. return
  32150. }
  32151. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32152. if ioErr3 != nil {
  32153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32155. return
  32156. }
  32157. var respJSON3 map[string]interface{}
  32158. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32161. return
  32162. }
  32163. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32164. userJSONBytes3, _ := json.Marshal(respJSON3)
  32165. fmt.Println("log")
  32166. fmt.Println(string(userJSONBytes3))
  32167. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32168. utils.ErrorLog("解析失败:%v", err)
  32169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32170. return
  32171. }
  32172. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32173. var api3 string
  32174. if miConfig.MdtrtareaAdmvs == "320921" {
  32175. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32176. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32177. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32178. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32179. } else {
  32180. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32181. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32182. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32183. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32184. }
  32185. resp3, requestErr3 := http.Get(api3)
  32186. if requestErr3 != nil {
  32187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32188. return
  32189. }
  32190. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32191. if ioErr3 != nil {
  32192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32194. return
  32195. }
  32196. var respJSON3 map[string]interface{}
  32197. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32200. return
  32201. }
  32202. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32203. userJSONBytes3, _ := json.Marshal(respJSON3)
  32204. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32205. utils.ErrorLog("解析失败:%v", err)
  32206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32207. return
  32208. }
  32209. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32210. res2.Output = resSix10265.Output
  32211. res2.ErrMsg = resSix10265.ErrMsg
  32212. res2.Cainfo = resSix10265.Cainfo
  32213. res2.WarnMsg = resSix10265.WarnMsg
  32214. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32215. res2.Infcode = infocode
  32216. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32217. var api3 string
  32218. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32219. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32220. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32221. resp3, requestErr3 := http.Get(api3)
  32222. if requestErr3 != nil {
  32223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32224. return
  32225. }
  32226. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32227. if ioErr3 != nil {
  32228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32230. return
  32231. }
  32232. var respJSON3 map[string]interface{}
  32233. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32236. return
  32237. }
  32238. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32239. userJSONBytes3, _ := json.Marshal(respJSON3)
  32240. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32241. utils.ErrorLog("解析失败:%v", err)
  32242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32243. return
  32244. }
  32245. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32246. res2.Output = resSix10265.Output
  32247. res2.ErrMsg = resSix10265.ErrMsg
  32248. res2.Cainfo = resSix10265.Cainfo
  32249. res2.WarnMsg = resSix10265.WarnMsg
  32250. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32251. res2.Infcode = infocode
  32252. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32253. 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)
  32254. var dat map[string]interface{}
  32255. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32256. fmt.Println(dat)
  32257. } else {
  32258. fmt.Println(err)
  32259. }
  32260. saveLog(result, request, "2202", "退号")
  32261. userJSONBytes, _ := json.Marshal(dat)
  32262. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32263. utils.ErrorLog("解析失败:%v", err)
  32264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32265. return
  32266. }
  32267. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32268. 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, "")
  32269. var dat map[string]interface{}
  32270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32271. fmt.Println(dat)
  32272. } else {
  32273. fmt.Println(err)
  32274. }
  32275. saveLog(result, request, "2202", "退号")
  32276. userJSONBytes, _ := json.Marshal(dat)
  32277. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32278. utils.ErrorLog("解析失败:%v", err)
  32279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32280. return
  32281. }
  32282. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32283. 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, "")
  32284. var dat map[string]interface{}
  32285. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32286. fmt.Println(dat)
  32287. } else {
  32288. fmt.Println(err)
  32289. }
  32290. saveLog(result, request, "2202", "退号")
  32291. userJSONBytes, _ := json.Marshal(dat)
  32292. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32293. utils.ErrorLog("解析失败:%v", err)
  32294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32295. return
  32296. }
  32297. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32298. var api3 string
  32299. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32300. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32301. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32302. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32303. resp3, requestErr3 := http.Get(api3)
  32304. if requestErr3 != nil {
  32305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32306. return
  32307. }
  32308. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32309. if ioErr3 != nil {
  32310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32312. return
  32313. }
  32314. var respJSON3 map[string]interface{}
  32315. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32318. return
  32319. }
  32320. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32321. if status == "0" {
  32322. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32323. c.ServeSuccessJSON(map[string]interface{}{
  32324. "failed_code": -10,
  32325. "msg": err_msg,
  32326. })
  32327. return
  32328. }
  32329. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32330. userJSONBytes3, _ := json.Marshal(respJSON3)
  32331. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32332. utils.ErrorLog("解析失败:%v", err)
  32333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32334. return
  32335. }
  32336. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32337. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32338. var api3 string
  32339. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32340. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32341. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32342. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32343. resp3, requestErr3 := http.Get(api3)
  32344. if requestErr3 != nil {
  32345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32346. return
  32347. }
  32348. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32349. if ioErr3 != nil {
  32350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32352. return
  32353. }
  32354. var respJSON3 map[string]interface{}
  32355. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32358. return
  32359. }
  32360. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32361. if status == "0" {
  32362. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32363. c.ServeSuccessJSON(map[string]interface{}{
  32364. "failed_code": -10,
  32365. "msg": err_msg,
  32366. })
  32367. return
  32368. }
  32369. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32370. userJSONBytes3, _ := json.Marshal(respJSON3)
  32371. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32372. utils.ErrorLog("解析失败:%v", err)
  32373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32374. return
  32375. }
  32376. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32377. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32378. 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, "")
  32379. var dat map[string]interface{}
  32380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32381. fmt.Println(dat)
  32382. } else {
  32383. fmt.Println(err)
  32384. }
  32385. saveLog(result, request, "2202", "退号")
  32386. userJSONBytes, _ := json.Marshal(dat)
  32387. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32388. utils.ErrorLog("解析失败:%v", err)
  32389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32390. return
  32391. }
  32392. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32393. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32394. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32395. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32396. resp3, requestErr3 := http.Get(api3)
  32397. if requestErr3 != nil {
  32398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32399. return
  32400. }
  32401. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32402. if ioErr3 != nil {
  32403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32405. return
  32406. }
  32407. var respJSON3 map[string]interface{}
  32408. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32411. return
  32412. }
  32413. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32414. userJSONBytes3, _ := json.Marshal(respJSON3)
  32415. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32416. utils.ErrorLog("解析失败:%v", err)
  32417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32418. return
  32419. }
  32420. } else {
  32421. var api3 string
  32422. if miConfig.Code == "H15049901371" {
  32423. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32424. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32425. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32426. } else {
  32427. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32428. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32429. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32430. }
  32431. resp3, requestErr3 := http.Get(api3)
  32432. if requestErr3 != nil {
  32433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32434. return
  32435. }
  32436. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32437. if ioErr3 != nil {
  32438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32440. return
  32441. }
  32442. var respJSON3 map[string]interface{}
  32443. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32446. return
  32447. }
  32448. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32449. userJSONBytes3, _ := json.Marshal(respJSON3)
  32450. if miConfig.Code == "H15049901371" {
  32451. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32452. utils.ErrorLog("解析失败:%v", err)
  32453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32454. return
  32455. }
  32456. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32457. res2.Output = resSix10265.Output
  32458. res2.ErrMsg = resSix10265.ErrMsg
  32459. res2.Cainfo = resSix10265.Cainfo
  32460. res2.WarnMsg = resSix10265.WarnMsg
  32461. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32462. res2.Infcode = infocode
  32463. } else {
  32464. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32465. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32466. utils.ErrorLog("解析失败:%v", err)
  32467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32468. return
  32469. }
  32470. res2.Infcode = res3.Infcode
  32471. } else {
  32472. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32473. utils.ErrorLog("解析失败:%v", err)
  32474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32475. return
  32476. }
  32477. }
  32478. }
  32479. }
  32480. if res2.Infcode == -1 {
  32481. c.ServeSuccessJSON(map[string]interface{}{
  32482. "failed_code": -10,
  32483. "msg": res2.ErrMsg,
  32484. })
  32485. return
  32486. }
  32487. if res2.Infcode == 0 {
  32488. if err == nil {
  32489. c.ServeSuccessJSON(map[string]interface{}{
  32490. "msg": "退号成功",
  32491. })
  32492. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32493. } else {
  32494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32495. return
  32496. }
  32497. }
  32498. } else {
  32499. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32500. //if err == nil {
  32501. // c.ServeSuccessJSON(map[string]interface{}{
  32502. // "msg": "退费成功",
  32503. // })
  32504. //} else {
  32505. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32506. // return
  32507. //}
  32508. }
  32509. }
  32510. func (c *HisApiController) RefundDetail() {
  32511. order_id, _ := c.GetInt64("order_id")
  32512. admin_user_id, _ := c.GetInt64("admin_user_id")
  32513. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32514. number := c.GetString("number")
  32515. record_time := c.GetString("record_time")
  32516. patient_id, _ := c.GetInt64("patient_id")
  32517. //med_type, _ := c.GetInt64("med_type")
  32518. timeLayout := "2006-01-02"
  32519. loc, _ := time.LoadLocation("Local")
  32520. adminUser := c.GetAdminUserInfo()
  32521. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32522. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32523. fmt.Println(err)
  32524. if err != nil {
  32525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32526. return
  32527. }
  32528. recordDateTime := theTime.Unix()
  32529. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32530. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32531. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32532. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32533. var order models.HisOrder
  32534. order, _ = service.GetHisOrderByID(order_id)
  32535. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32536. if config.IsOpen == 1 { //对接了医保,走医保流程
  32537. var res2 ResultSix
  32538. if miConfig.MdtrtareaAdmvs == "421300" {
  32539. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32540. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32541. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32542. resp3, requestErr3 := http.Get(api3)
  32543. if requestErr3 != nil {
  32544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32545. return
  32546. }
  32547. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32548. if ioErr3 != nil {
  32549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32551. return
  32552. }
  32553. var respJSON3 map[string]interface{}
  32554. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32557. return
  32558. }
  32559. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32560. userJSONBytes3, _ := json.Marshal(respJSON3)
  32561. fmt.Println("log")
  32562. fmt.Println(string(userJSONBytes3))
  32563. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32564. utils.ErrorLog("解析失败:%v", err)
  32565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32566. return
  32567. }
  32568. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32569. if err == nil {
  32570. c.ServeSuccessJSON(map[string]interface{}{
  32571. "msg": "撤销明细成功",
  32572. })
  32573. return
  32574. } else {
  32575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32576. return
  32577. }
  32578. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32579. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32580. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32581. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32582. resp3, requestErr3 := http.Get(api3)
  32583. if requestErr3 != nil {
  32584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32585. return
  32586. }
  32587. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32588. if ioErr3 != nil {
  32589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32591. return
  32592. }
  32593. var respJSON3 map[string]interface{}
  32594. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32597. return
  32598. }
  32599. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32600. userJSONBytes3, _ := json.Marshal(respJSON3)
  32601. fmt.Println("log")
  32602. fmt.Println(string(userJSONBytes3))
  32603. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32604. utils.ErrorLog("解析失败:%v", err)
  32605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32606. return
  32607. }
  32608. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32609. if err == nil {
  32610. c.ServeSuccessJSON(map[string]interface{}{
  32611. "msg": "撤销明细成功",
  32612. })
  32613. return
  32614. } else {
  32615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32616. return
  32617. }
  32618. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32619. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32620. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32621. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32622. resp3, requestErr3 := http.Get(api3)
  32623. if requestErr3 != nil {
  32624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32625. return
  32626. }
  32627. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32628. if ioErr3 != nil {
  32629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32631. return
  32632. }
  32633. var respJSON3 map[string]interface{}
  32634. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32637. return
  32638. }
  32639. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32640. userJSONBytes3, _ := json.Marshal(respJSON3)
  32641. fmt.Println("log")
  32642. fmt.Println(string(userJSONBytes3))
  32643. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32644. utils.ErrorLog("解析失败:%v", err)
  32645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32646. return
  32647. }
  32648. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32649. if err == nil {
  32650. c.ServeSuccessJSON(map[string]interface{}{
  32651. "msg": "撤销明细成功",
  32652. })
  32653. return
  32654. } else {
  32655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32656. return
  32657. }
  32658. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32659. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32660. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32661. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32662. resp3, requestErr3 := http.Get(api3)
  32663. if requestErr3 != nil {
  32664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32665. return
  32666. }
  32667. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32668. if ioErr3 != nil {
  32669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32671. return
  32672. }
  32673. var respJSON3 map[string]interface{}
  32674. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32677. return
  32678. }
  32679. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32680. userJSONBytes3, _ := json.Marshal(respJSON3)
  32681. fmt.Println("log")
  32682. fmt.Println(string(userJSONBytes3))
  32683. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32684. utils.ErrorLog("解析失败:%v", err)
  32685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32686. return
  32687. }
  32688. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32689. if err == nil {
  32690. c.ServeSuccessJSON(map[string]interface{}{
  32691. "msg": "撤销明细成功",
  32692. })
  32693. return
  32694. } else {
  32695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32696. return
  32697. }
  32698. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32699. var resSix10265 ResultSix10265
  32700. var api3 string
  32701. if miConfig.MdtrtareaAdmvs == "320921" {
  32702. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32703. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32704. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32705. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32706. } else {
  32707. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32708. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32709. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32710. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32711. }
  32712. resp3, requestErr3 := http.Get(api3)
  32713. utils.ErrorLog("接口: %v", requestErr3)
  32714. if requestErr3 != nil {
  32715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32716. return
  32717. }
  32718. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32719. if ioErr3 != nil {
  32720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32722. return
  32723. }
  32724. var respJSON3 map[string]interface{}
  32725. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32728. return
  32729. }
  32730. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32731. userJSONBytes3, _ := json.Marshal(respJSON3)
  32732. fmt.Println("log")
  32733. fmt.Println(string(userJSONBytes3))
  32734. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32735. utils.ErrorLog("解析失败:%v", err)
  32736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32737. return
  32738. }
  32739. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32740. res2.Output = resSix10265.Output
  32741. res2.ErrMsg = resSix10265.ErrMsg
  32742. res2.Cainfo = resSix10265.Cainfo
  32743. res2.WarnMsg = resSix10265.WarnMsg
  32744. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32745. res2.Infcode = infocode
  32746. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32747. if err == nil {
  32748. c.ServeSuccessJSON(map[string]interface{}{
  32749. "msg": "撤销明细成功",
  32750. })
  32751. return
  32752. } else {
  32753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32754. return
  32755. }
  32756. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32757. var api3 string
  32758. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32759. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32760. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32761. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32762. resp3, requestErr3 := http.Get(api3)
  32763. utils.ErrorLog("接口: %v", requestErr3)
  32764. if requestErr3 != nil {
  32765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32766. return
  32767. }
  32768. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32769. if ioErr3 != nil {
  32770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32772. return
  32773. }
  32774. var respJSON3 map[string]interface{}
  32775. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32778. return
  32779. }
  32780. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32781. if status == "0" {
  32782. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32783. c.ServeSuccessJSON(map[string]interface{}{
  32784. "failed_code": -10,
  32785. "msg": err_msg,
  32786. })
  32787. return
  32788. }
  32789. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32790. userJSONBytes3, _ := json.Marshal(respJSON3)
  32791. fmt.Println("log")
  32792. fmt.Println(string(userJSONBytes3))
  32793. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32794. utils.ErrorLog("解析失败:%v", err)
  32795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32796. return
  32797. }
  32798. fmt.Println(res2.Infcode)
  32799. if res2.Infcode == -1 {
  32800. c.ServeSuccessJSON(map[string]interface{}{
  32801. "failed_code": -10,
  32802. "msg": res2.ErrMsg,
  32803. })
  32804. return
  32805. }
  32806. if res2.Infcode == 0 {
  32807. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32808. if err == nil {
  32809. c.ServeSuccessJSON(map[string]interface{}{
  32810. "msg": "撤销明细成功",
  32811. })
  32812. return
  32813. } else {
  32814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32815. return
  32816. }
  32817. } else {
  32818. c.ServeSuccessJSON(map[string]interface{}{
  32819. "failed_code": -10,
  32820. "msg": res2.ErrMsg,
  32821. })
  32822. }
  32823. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32824. if err == nil {
  32825. c.ServeSuccessJSON(map[string]interface{}{
  32826. "msg": "撤销明细成功",
  32827. })
  32828. return
  32829. } else {
  32830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32831. return
  32832. }
  32833. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32834. var api3 string
  32835. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32836. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32837. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32838. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32839. resp3, requestErr3 := http.Get(api3)
  32840. utils.ErrorLog("接口: %v", requestErr3)
  32841. if requestErr3 != nil {
  32842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32843. return
  32844. }
  32845. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32846. if ioErr3 != nil {
  32847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32849. return
  32850. }
  32851. var respJSON3 map[string]interface{}
  32852. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32855. return
  32856. }
  32857. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32858. if status == "0" {
  32859. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32860. c.ServeSuccessJSON(map[string]interface{}{
  32861. "failed_code": -10,
  32862. "msg": err_msg,
  32863. })
  32864. return
  32865. }
  32866. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32867. userJSONBytes3, _ := json.Marshal(respJSON3)
  32868. fmt.Println("log")
  32869. fmt.Println(string(userJSONBytes3))
  32870. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32871. utils.ErrorLog("解析失败:%v", err)
  32872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32873. return
  32874. }
  32875. fmt.Println(res2.Infcode)
  32876. if res2.Infcode == -1 {
  32877. c.ServeSuccessJSON(map[string]interface{}{
  32878. "failed_code": -10,
  32879. "msg": res2.ErrMsg,
  32880. })
  32881. return
  32882. }
  32883. if res2.Infcode == 0 {
  32884. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32885. if err == nil {
  32886. c.ServeSuccessJSON(map[string]interface{}{
  32887. "msg": "撤销明细成功",
  32888. })
  32889. return
  32890. } else {
  32891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32892. return
  32893. }
  32894. } else {
  32895. c.ServeSuccessJSON(map[string]interface{}{
  32896. "failed_code": -10,
  32897. "msg": res2.ErrMsg,
  32898. })
  32899. }
  32900. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32901. if err == nil {
  32902. c.ServeSuccessJSON(map[string]interface{}{
  32903. "msg": "撤销明细成功",
  32904. })
  32905. return
  32906. } else {
  32907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32908. return
  32909. }
  32910. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32911. var resSix10265 ResultSix10265
  32912. new_chrg_bchno := order.Number
  32913. if adminUser.CurrentOrgId == 10265 {
  32914. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32915. new_chrg_bchno = "0000"
  32916. }
  32917. }
  32918. var api3 string
  32919. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32920. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32921. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32922. resp3, requestErr3 := http.Get(api3)
  32923. if requestErr3 != nil {
  32924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32925. return
  32926. }
  32927. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32928. if ioErr3 != nil {
  32929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32931. return
  32932. }
  32933. var respJSON3 map[string]interface{}
  32934. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32937. return
  32938. }
  32939. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32940. userJSONBytes3, _ := json.Marshal(respJSON3)
  32941. fmt.Println("log")
  32942. fmt.Println(string(userJSONBytes3))
  32943. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32944. utils.ErrorLog("解析失败:%v", err)
  32945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32946. return
  32947. }
  32948. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32949. res2.Output = resSix10265.Output
  32950. res2.ErrMsg = resSix10265.ErrMsg
  32951. res2.Cainfo = resSix10265.Cainfo
  32952. res2.WarnMsg = resSix10265.WarnMsg
  32953. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32954. res2.Infcode = infocode
  32955. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32956. if err == nil {
  32957. c.ServeSuccessJSON(map[string]interface{}{
  32958. "msg": "撤销明细成功",
  32959. })
  32960. return
  32961. } else {
  32962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32963. return
  32964. }
  32965. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32966. 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)
  32967. var dat map[string]interface{}
  32968. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32969. fmt.Println(dat)
  32970. } else {
  32971. fmt.Println(err)
  32972. }
  32973. saveLog(result2, src_request, "2205", "撤销明细")
  32974. userJSONBytes, _ := json.Marshal(dat)
  32975. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32976. utils.ErrorLog("解析失败:%v", err)
  32977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32978. return
  32979. }
  32980. if res2.Infcode == 0 {
  32981. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32982. if err == nil {
  32983. c.ServeSuccessJSON(map[string]interface{}{
  32984. "msg": "撤销明细成功",
  32985. })
  32986. return
  32987. } else {
  32988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32989. return
  32990. }
  32991. } else {
  32992. c.ServeSuccessJSON(map[string]interface{}{
  32993. "failed_code": -10,
  32994. "msg": res2.ErrMsg,
  32995. })
  32996. }
  32997. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32998. 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, "")
  32999. var dat map[string]interface{}
  33000. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33001. fmt.Println(dat)
  33002. } else {
  33003. fmt.Println(err)
  33004. }
  33005. saveLog(result2, src_request, "2205", "撤销明细")
  33006. userJSONBytes, _ := json.Marshal(dat)
  33007. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33008. utils.ErrorLog("解析失败:%v", err)
  33009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33010. return
  33011. }
  33012. if res2.Infcode == 0 {
  33013. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33014. if err == nil {
  33015. c.ServeSuccessJSON(map[string]interface{}{
  33016. "msg": "撤销明细成功",
  33017. })
  33018. return
  33019. } else {
  33020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33021. return
  33022. }
  33023. } else {
  33024. c.ServeSuccessJSON(map[string]interface{}{
  33025. "failed_code": -10,
  33026. "msg": res2.ErrMsg,
  33027. })
  33028. }
  33029. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33030. 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, "")
  33031. var dat map[string]interface{}
  33032. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33033. fmt.Println(dat)
  33034. } else {
  33035. fmt.Println(err)
  33036. }
  33037. saveLog(result2, src_request, "2205", "撤销明细")
  33038. userJSONBytes, _ := json.Marshal(dat)
  33039. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33040. utils.ErrorLog("解析失败:%v", err)
  33041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33042. return
  33043. }
  33044. if res2.Infcode == 0 {
  33045. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33046. if err == nil {
  33047. c.ServeSuccessJSON(map[string]interface{}{
  33048. "msg": "撤销明细成功",
  33049. })
  33050. return
  33051. } else {
  33052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33053. return
  33054. }
  33055. } else {
  33056. c.ServeSuccessJSON(map[string]interface{}{
  33057. "failed_code": -10,
  33058. "msg": res2.ErrMsg,
  33059. })
  33060. }
  33061. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33062. 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, "")
  33063. var dat map[string]interface{}
  33064. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33065. fmt.Println(dat)
  33066. } else {
  33067. fmt.Println(err)
  33068. }
  33069. saveLog(result2, src_request, "2205", "撤销明细")
  33070. userJSONBytes, _ := json.Marshal(dat)
  33071. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33072. utils.ErrorLog("解析失败:%v", err)
  33073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33074. return
  33075. }
  33076. if res2.Infcode == 0 {
  33077. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33078. if err == nil {
  33079. c.ServeSuccessJSON(map[string]interface{}{
  33080. "msg": "撤销明细成功",
  33081. })
  33082. return
  33083. } else {
  33084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33085. return
  33086. }
  33087. } else {
  33088. c.ServeSuccessJSON(map[string]interface{}{
  33089. "failed_code": -10,
  33090. "msg": res2.ErrMsg,
  33091. })
  33092. }
  33093. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33094. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33095. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33096. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33097. resp2, requestErr2 := http.Get(api2)
  33098. if requestErr2 != nil {
  33099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33100. return
  33101. }
  33102. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33103. if ioErr2 != nil {
  33104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33106. return
  33107. }
  33108. var respJSON2 map[string]interface{}
  33109. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33112. return
  33113. }
  33114. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33115. userJSONBytes3, _ := json.Marshal(respJSON2)
  33116. fmt.Println("log")
  33117. fmt.Println(string(userJSONBytes3))
  33118. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33119. utils.ErrorLog("解析失败:%v", err)
  33120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33121. return
  33122. }
  33123. if res2.Infcode == 0 {
  33124. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33125. if err == nil {
  33126. c.ServeSuccessJSON(map[string]interface{}{
  33127. "msg": "撤销明细成功",
  33128. })
  33129. return
  33130. } else {
  33131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33132. return
  33133. }
  33134. } else {
  33135. c.ServeSuccessJSON(map[string]interface{}{
  33136. "failed_code": -10,
  33137. "msg": res2.ErrMsg,
  33138. })
  33139. }
  33140. } else {
  33141. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33142. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33143. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33144. resp2, requestErr2 := http.Get(api2)
  33145. if requestErr2 != nil {
  33146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33147. return
  33148. }
  33149. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33150. if ioErr2 != nil {
  33151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33153. return
  33154. }
  33155. var respJSON2 map[string]interface{}
  33156. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33159. return
  33160. }
  33161. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33162. userJSONBytes3, _ := json.Marshal(respJSON2)
  33163. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33164. utils.ErrorLog("解析失败:%v", err)
  33165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33166. return
  33167. }
  33168. if res2.Infcode == -1 {
  33169. c.ServeSuccessJSON(map[string]interface{}{
  33170. "failed_code": -10,
  33171. "msg": res2.ErrMsg,
  33172. })
  33173. return
  33174. } else {
  33175. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33176. if err == nil {
  33177. c.ServeSuccessJSON(map[string]interface{}{
  33178. "msg": "撤销明细成功",
  33179. })
  33180. return
  33181. } else {
  33182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33183. return
  33184. }
  33185. }
  33186. }
  33187. } else {
  33188. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33189. if err == nil {
  33190. c.ServeSuccessJSON(map[string]interface{}{
  33191. "msg": "退费成功",
  33192. })
  33193. } else {
  33194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33195. return
  33196. }
  33197. }
  33198. }
  33199. // 对账
  33200. func (c *HisApiController) GetCheckAccount() {
  33201. start_time := c.GetString("start_time")
  33202. end_time := c.GetString("end_time")
  33203. insutype := c.GetString("insutype")
  33204. clr_type := c.GetString("clr_type")
  33205. clr_org := c.GetString("clr_optins")
  33206. admin_user_id, _ := c.GetInt64("admin_user_id")
  33207. adminUser := c.GetAdminUserInfo()
  33208. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33209. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33210. if len(clr_org) == 0 {
  33211. clr_org = miConfig.InsuplcAdmdvs
  33212. }
  33213. timeLayout := "2006-01-02"
  33214. loc, _ := time.LoadLocation("Local")
  33215. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33216. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33217. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33218. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33219. fixmedins_setl_cnt := int64(len(orders))
  33220. var medfee_sumamt float64
  33221. var acct_pay float64
  33222. var fund_pay_sumamt float64
  33223. for _, item := range orders {
  33224. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33225. acct_pay = acct_pay + item.AcctPay
  33226. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33227. }
  33228. var user_name string
  33229. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33230. if role.ID == 0 {
  33231. user_name = "xxx"
  33232. } else {
  33233. user_name = role.UserName
  33234. }
  33235. var res ResultEight
  33236. var res10188 ResultEightFor10188
  33237. if config.IsOpen == 1 {
  33238. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33239. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33240. "insutype=" + insutype +
  33241. "&clr_type=" + clr_type +
  33242. "&setl_optins=" + clr_org +
  33243. "&stmt_begndate=" + start_time +
  33244. "&stm_enddate=" + end_time +
  33245. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33246. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33247. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33248. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33249. "&fixmedins_code=" + miConfig.Code +
  33250. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33251. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33252. "&secret_key=" + miConfig.SecretKey +
  33253. "&org_name=" + miConfig.OrgName +
  33254. "&doctor=" + user_name +
  33255. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33256. fmt.Println(api)
  33257. resp, requestErr := http.Get(api)
  33258. if requestErr != nil {
  33259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33260. return
  33261. }
  33262. body, ioErr := ioutil.ReadAll(resp.Body)
  33263. fmt.Println(body)
  33264. if ioErr != nil {
  33265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33267. return
  33268. }
  33269. var respJSON map[string]interface{}
  33270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33273. return
  33274. }
  33275. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33276. userJSONBytes, _ := json.Marshal(respJSON)
  33277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33278. utils.ErrorLog("解析失败:%v", err)
  33279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33280. return
  33281. }
  33282. res.InfRefmsgid = res10188.InfRefmsgid
  33283. res.Output = res10188.Output
  33284. res.ErrMsg = res10188.ErrMsg
  33285. res.Cainfo = res10188.Cainfo
  33286. res.WarnMsg = res10188.WarnMsg
  33287. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33288. res.Infcode = infocode
  33289. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33290. if clr_type != "9903" {
  33291. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33292. }
  33293. if clr_type == "9903" {
  33294. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33295. }
  33296. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33297. "insutype=" + insutype +
  33298. "&clr_type=" + clr_type +
  33299. "&setl_optins=" + clr_org +
  33300. "&stmt_begndate=" + start_time +
  33301. "&stm_enddate=" + end_time +
  33302. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33303. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33304. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33305. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33306. "&fixmedins_code=" + miConfig.Code +
  33307. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33308. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33309. "&secret_key=" + miConfig.SecretKey +
  33310. "&org_name=" + miConfig.OrgName +
  33311. "&doctor=" + user_name
  33312. resp, requestErr := http.Get(api)
  33313. if requestErr != nil {
  33314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33315. return
  33316. }
  33317. body, ioErr := ioutil.ReadAll(resp.Body)
  33318. if ioErr != nil {
  33319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33321. return
  33322. }
  33323. var respJSON map[string]interface{}
  33324. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33327. return
  33328. }
  33329. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33330. result, _ := json.Marshal(respJSON)
  33331. fmt.Println("log")
  33332. fmt.Println(string(result))
  33333. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33334. utils.ErrorLog("解析失败:%v", err)
  33335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33336. return
  33337. }
  33338. res.InfRefmsgid = res10188.InfRefmsgid
  33339. res.Output = res10188.Output
  33340. res.ErrMsg = res10188.ErrMsg
  33341. res.Cainfo = res10188.Cainfo
  33342. res.WarnMsg = res10188.WarnMsg
  33343. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33344. res.Infcode = infocode
  33345. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33346. var baseParams models.BaseParams
  33347. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33348. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33349. baseParams.SecretKey = miConfig.SecretKey
  33350. baseParams.OrgName = miConfig.OrgName
  33351. baseParams.FixmedinsCode = miConfig.Code
  33352. baseParams.EncKey = miConfig.EncKey
  33353. baseParams.AppSecret = miConfig.AppSecret
  33354. baseParams.SignKey = miConfig.SignKey
  33355. baseParams.AppID = miConfig.Code
  33356. baseParams.Doctor = role.UserName
  33357. baseParams.RequestUrl = miConfig.Url
  33358. businessParams := models.BusinessParams{
  33359. Insutype: insutype,
  33360. ClrType: clr_type,
  33361. SetlOptins: clr_org,
  33362. StmtBegndate: start_time,
  33363. StmtEnddate: end_time,
  33364. MedfeeSumamt: medfee_sumamt,
  33365. FundPaySumamt: fund_pay_sumamt,
  33366. AcctPay: acct_pay,
  33367. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33368. }
  33369. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33370. fmt.Println(requestLog)
  33371. fmt.Println(result)
  33372. fmt.Println(err_msg)
  33373. var dat map[string]interface{}
  33374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33375. fmt.Println(dat)
  33376. } else {
  33377. fmt.Println(err)
  33378. }
  33379. userJSONBytes, _ := json.Marshal(dat)
  33380. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33381. utils.ErrorLog("解析失败:%v", err)
  33382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33383. return
  33384. }
  33385. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33386. var baseParams models.BaseParams
  33387. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33388. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33389. baseParams.SecretKey = miConfig.SecretKey
  33390. baseParams.OrgName = miConfig.OrgName
  33391. baseParams.FixmedinsCode = miConfig.Code
  33392. baseParams.EncKey = miConfig.EncKey
  33393. baseParams.AppSecret = miConfig.AppSecret
  33394. baseParams.SignKey = miConfig.SignKey
  33395. baseParams.AppID = miConfig.Code
  33396. baseParams.Doctor = role.UserName
  33397. baseParams.RequestUrl = miConfig.Url
  33398. baseParams.AccessKey = miConfig.AccessKey
  33399. businessParams := models.BusinessParams{
  33400. Insutype: insutype,
  33401. ClrType: clr_type,
  33402. SetlOptins: "430822",
  33403. StmtBegndate: start_time,
  33404. StmtEnddate: end_time,
  33405. MedfeeSumamt: medfee_sumamt,
  33406. FundPaySumamt: fund_pay_sumamt,
  33407. AcctPay: acct_pay,
  33408. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33409. }
  33410. 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)
  33411. fmt.Println(requestLog)
  33412. fmt.Println(result)
  33413. var dat map[string]interface{}
  33414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33415. fmt.Println(dat)
  33416. } else {
  33417. fmt.Println(err)
  33418. }
  33419. userJSONBytes, _ := json.Marshal(dat)
  33420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33421. utils.ErrorLog("解析失败:%v", err)
  33422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33423. return
  33424. }
  33425. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33426. var baseParams models.BaseParams
  33427. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33428. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33429. baseParams.SecretKey = miConfig.SecretKey
  33430. baseParams.OrgName = miConfig.OrgName
  33431. baseParams.FixmedinsCode = miConfig.Code
  33432. baseParams.EncKey = miConfig.EncKey
  33433. baseParams.AppSecret = miConfig.AppSecret
  33434. baseParams.SignKey = miConfig.SignKey
  33435. baseParams.AppID = miConfig.Code
  33436. baseParams.Doctor = role.UserName
  33437. baseParams.RequestUrl = miConfig.Url
  33438. businessParams := models.BusinessParams{
  33439. Insutype: insutype,
  33440. ClrType: clr_type,
  33441. SetlOptins: clr_org,
  33442. StmtBegndate: start_time,
  33443. StmtEnddate: end_time,
  33444. MedfeeSumamt: medfee_sumamt,
  33445. FundPaySumamt: fund_pay_sumamt,
  33446. AcctPay: acct_pay,
  33447. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33448. }
  33449. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33450. fmt.Println(requestLog)
  33451. fmt.Println(result)
  33452. fmt.Println(err_msg)
  33453. var dat map[string]interface{}
  33454. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33455. fmt.Println(dat)
  33456. } else {
  33457. fmt.Println(err)
  33458. }
  33459. userJSONBytes, _ := json.Marshal(dat)
  33460. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33461. utils.ErrorLog("解析失败:%v", err)
  33462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33463. return
  33464. }
  33465. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33466. if len(clr_type) == 0 {
  33467. clr_type = "11"
  33468. }
  33469. api := miConfig.Url + "gdyb/ten?" +
  33470. "insutype=" + insutype +
  33471. "&clr_type=" + clr_type +
  33472. "&setl_optins=" + clr_org +
  33473. "&stmt_begndate=" + start_time +
  33474. "&stm_enddate=" + end_time +
  33475. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33476. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33477. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33478. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33479. "&fixmedins_code=" + miConfig.Code +
  33480. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33481. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33482. "&secret_key=" + miConfig.SecretKey +
  33483. "&org_name=" + miConfig.OrgName +
  33484. "&doctor=" + user_name
  33485. fmt.Println(api)
  33486. resp, requestErr := http.Get(api)
  33487. if requestErr != nil {
  33488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33489. return
  33490. }
  33491. body, ioErr := ioutil.ReadAll(resp.Body)
  33492. fmt.Println(body)
  33493. if ioErr != nil {
  33494. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33496. return
  33497. }
  33498. var respJSON map[string]interface{}
  33499. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33500. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33502. return
  33503. }
  33504. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33505. userJSONBytes, _ := json.Marshal(respJSON)
  33506. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33507. utils.ErrorLog("解析失败:%v", err)
  33508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33509. return
  33510. }
  33511. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33512. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33513. //fixmedins_setl_cnt := int64(len(orders_two))
  33514. //var medfee_sumamt float64
  33515. //var acct_pay float64
  33516. //var fund_pay_sumamt float64
  33517. //for _, item := range orders_two {
  33518. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33519. // acct_pay = acct_pay + item.AcctPay
  33520. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33521. //}
  33522. var baseParams models.BaseParams
  33523. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33524. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33525. baseParams.SecretKey = miConfig.SecretKey
  33526. baseParams.OrgName = miConfig.OrgName
  33527. baseParams.FixmedinsCode = miConfig.Code
  33528. baseParams.EncKey = miConfig.EncKey
  33529. baseParams.AppSecret = miConfig.AppSecret
  33530. baseParams.SignKey = miConfig.SignKey
  33531. baseParams.AppID = miConfig.Code
  33532. baseParams.Doctor = role.UserName
  33533. baseParams.RequestUrl = miConfig.Url
  33534. if clr_type == "9903" {
  33535. clr_type = "9994"
  33536. }
  33537. businessParams := models.BusinessParams{
  33538. Insutype: insutype,
  33539. ClrType: clr_type,
  33540. SetlOptins: "360302",
  33541. StmtBegndate: start_time,
  33542. StmtEnddate: end_time,
  33543. MedfeeSumamt: 0,
  33544. FundPaySumamt: 0,
  33545. AcctPay: 0,
  33546. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33547. }
  33548. 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))
  33549. fmt.Println(requestLog)
  33550. fmt.Println(result)
  33551. var dat map[string]interface{}
  33552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33553. fmt.Println(dat)
  33554. } else {
  33555. fmt.Println(err)
  33556. }
  33557. userJSONBytes, _ := json.Marshal(dat)
  33558. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33559. utils.ErrorLog("解析失败:%v", err)
  33560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33561. return
  33562. }
  33563. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33564. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33565. fixmedins_setl_cnt := int64(len(orders_two))
  33566. var medfee_sumamt float64
  33567. var acct_pay float64
  33568. var fund_pay_sumamt float64
  33569. for _, item := range orders_two {
  33570. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33571. acct_pay = acct_pay + item.AcctPay
  33572. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33573. }
  33574. var baseParams models.BaseParams
  33575. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33576. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33577. baseParams.SecretKey = miConfig.SecretKey
  33578. baseParams.OrgName = miConfig.OrgName
  33579. baseParams.FixmedinsCode = miConfig.Code
  33580. baseParams.EncKey = miConfig.EncKey
  33581. baseParams.AppSecret = miConfig.AppSecret
  33582. baseParams.SignKey = miConfig.SignKey
  33583. baseParams.AppID = miConfig.Code
  33584. baseParams.Doctor = role.UserName
  33585. baseParams.RequestUrl = miConfig.Url
  33586. if clr_type == "9903" {
  33587. clr_type = "9994"
  33588. }
  33589. businessParams := models.BusinessParams{
  33590. Insutype: insutype,
  33591. ClrType: clr_type,
  33592. SetlOptins: "361025",
  33593. StmtBegndate: start_time,
  33594. StmtEnddate: end_time,
  33595. MedfeeSumamt: 0,
  33596. FundPaySumamt: 0,
  33597. AcctPay: 0,
  33598. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33599. }
  33600. 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))
  33601. fmt.Println(requestLog)
  33602. fmt.Println(result)
  33603. var dat map[string]interface{}
  33604. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33605. fmt.Println(dat)
  33606. } else {
  33607. fmt.Println(err)
  33608. }
  33609. userJSONBytes, _ := json.Marshal(dat)
  33610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33611. utils.ErrorLog("解析失败:%v", err)
  33612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33613. return
  33614. }
  33615. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33616. var api string
  33617. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33618. "&clr_type=" + clr_type +
  33619. "&setl_optins=" + clr_org +
  33620. "&stmt_begndate=" + start_time +
  33621. "&stm_enddate=" + end_time +
  33622. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33623. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33624. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33625. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33626. "&fixmedins_code=" + miConfig.Code +
  33627. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33628. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33629. "&secret_key=" + miConfig.SecretKey +
  33630. "&org_name=" + miConfig.OrgName +
  33631. "&doctor=" + user_name + "&url=" + miConfig.Url
  33632. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33633. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33634. resp, requestErr := http.Get(api)
  33635. if requestErr != nil {
  33636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33637. return
  33638. }
  33639. body, ioErr := ioutil.ReadAll(resp.Body)
  33640. if ioErr != nil {
  33641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33643. return
  33644. }
  33645. var respJSON map[string]interface{}
  33646. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33649. return
  33650. }
  33651. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33652. if status == "0" {
  33653. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33654. c.ServeSuccessJSON(map[string]interface{}{
  33655. "failed_code": -10,
  33656. "msg": err_msg,
  33657. })
  33658. return
  33659. }
  33660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33661. userJSONBytes, _ := json.Marshal(respJSON)
  33662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33663. utils.ErrorLog("解析失败:%v", err)
  33664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33665. return
  33666. }
  33667. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33668. var api string
  33669. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33670. "&clr_type=" + clr_type +
  33671. "&setl_optins=" + clr_org +
  33672. "&stmt_begndate=" + start_time +
  33673. "&stm_enddate=" + end_time +
  33674. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33675. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33676. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33677. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33678. "&fixmedins_code=" + miConfig.Code +
  33679. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33680. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33681. "&secret_key=" + miConfig.SecretKey +
  33682. "&org_name=" + miConfig.OrgName +
  33683. "&doctor=" + user_name + "&url=" + miConfig.Url
  33684. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33685. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33686. resp, requestErr := http.Get(api)
  33687. if requestErr != nil {
  33688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33689. return
  33690. }
  33691. body, ioErr := ioutil.ReadAll(resp.Body)
  33692. if ioErr != nil {
  33693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33695. return
  33696. }
  33697. var respJSON map[string]interface{}
  33698. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33701. return
  33702. }
  33703. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33704. if status == "0" {
  33705. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33706. c.ServeSuccessJSON(map[string]interface{}{
  33707. "failed_code": -10,
  33708. "msg": err_msg,
  33709. })
  33710. return
  33711. }
  33712. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33713. userJSONBytes, _ := json.Marshal(respJSON)
  33714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33715. utils.ErrorLog("解析失败:%v", err)
  33716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33717. return
  33718. }
  33719. } else {
  33720. if len(clr_type) == 0 {
  33721. clr_type = "11"
  33722. }
  33723. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33724. "insutype=" + insutype +
  33725. "&clr_type=" + clr_type +
  33726. "&setl_optins=" + clr_org +
  33727. "&stmt_begndate=" + start_time +
  33728. "&stm_enddate=" + end_time +
  33729. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33730. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33731. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33732. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33733. "&fixmedins_code=" + miConfig.Code +
  33734. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33735. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33736. "&secret_key=" + miConfig.SecretKey +
  33737. "&org_name=" + miConfig.OrgName +
  33738. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33739. fmt.Println(api)
  33740. resp, requestErr := http.Get(api)
  33741. if requestErr != nil {
  33742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33743. return
  33744. }
  33745. body, ioErr := ioutil.ReadAll(resp.Body)
  33746. fmt.Println(body)
  33747. if ioErr != nil {
  33748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33750. return
  33751. }
  33752. var respJSON map[string]interface{}
  33753. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33756. return
  33757. }
  33758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33759. userJSONBytes, _ := json.Marshal(respJSON)
  33760. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33761. utils.ErrorLog("解析失败:%v", err)
  33762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33763. return
  33764. }
  33765. }
  33766. if res.Infcode == 0 {
  33767. if res.Output.Stmtinfo.StmtRslt == "0" {
  33768. micc := &models.MedicalInsuranceCostCompare{
  33769. StartTime: startime.Unix(),
  33770. EndTime: endtime.Unix(),
  33771. Insutype: insutype,
  33772. CheckType: 1,
  33773. Num: fixmedins_setl_cnt,
  33774. Mtime: time.Now().Unix(),
  33775. Status: 1,
  33776. UserOrgId: adminUser.CurrentOrgId,
  33777. CostTotal: medfee_sumamt,
  33778. FuncTotal: fund_pay_sumamt,
  33779. PsnPay: acct_pay,
  33780. Creator: admin_user_id,
  33781. Ctime: time.Now().Unix(),
  33782. ClrType: clr_type,
  33783. }
  33784. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33785. if err == nil {
  33786. c.ServeSuccessJSON(map[string]interface{}{
  33787. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33788. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33789. })
  33790. } else {
  33791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33792. }
  33793. } else {
  33794. c.ServeSuccessJSON(map[string]interface{}{
  33795. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33796. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33797. })
  33798. }
  33799. } else {
  33800. c.ServeSuccessJSON(map[string]interface{}{
  33801. "failed_code": -10,
  33802. "msg": res.ErrMsg,
  33803. })
  33804. }
  33805. }
  33806. }
  33807. func (c *HisApiController) Check310() {
  33808. adminUser := c.GetAdminUserInfo()
  33809. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33810. var user_name string
  33811. user_name = "高慧裕"
  33812. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33813. "insutype=" + "310" +
  33814. "&clr_type=" + "" +
  33815. "&setl_optins=" + "441202" +
  33816. "&stmt_begndate=" + "2022-03-01" +
  33817. "&stm_enddate=" + "2022-03-31" +
  33818. "&medfee_sumamt=" + "194930.12" +
  33819. "&fund_pay_sumamt=" + "188741.46" +
  33820. "&acct_pay=" + "0" +
  33821. "&fixmedins_setl_cnt=" + "452" +
  33822. "&fixmedins_code=" + miConfig.Code +
  33823. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33824. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33825. "&secret_key=" + miConfig.SecretKey +
  33826. "&org_name=" + miConfig.OrgName +
  33827. "&doctor=" + user_name
  33828. fmt.Println(api)
  33829. resp, requestErr := http.Get(api)
  33830. if requestErr != nil {
  33831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33832. return
  33833. }
  33834. body, ioErr := ioutil.ReadAll(resp.Body)
  33835. fmt.Println(body)
  33836. if ioErr != nil {
  33837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33839. return
  33840. }
  33841. var respJSON map[string]interface{}
  33842. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33845. return
  33846. }
  33847. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33848. userJSONBytes, _ := json.Marshal(respJSON)
  33849. var res ResultEight
  33850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33851. utils.ErrorLog("解析失败:%v", err)
  33852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33853. return
  33854. }
  33855. }
  33856. func (c *HisApiController) Check390() {
  33857. adminUser := c.GetAdminUserInfo()
  33858. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33859. var user_name string
  33860. user_name = "高慧裕"
  33861. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33862. "insutype=" + "390" +
  33863. "&clr_type=" + "" +
  33864. "&setl_optins=" + "441202" +
  33865. "&stmt_begndate=" + "2022-03-01" +
  33866. "&stm_enddate=" + "2022-03-31" +
  33867. "&medfee_sumamt=" + "1068448.89" +
  33868. "&fund_pay_sumamt=" + "1014677.62" +
  33869. "&acct_pay=" + "0" +
  33870. "&fixmedins_setl_cnt=" + "1950" +
  33871. "&fixmedins_code=" + miConfig.Code +
  33872. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33873. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33874. "&secret_key=" + miConfig.SecretKey +
  33875. "&org_name=" + miConfig.OrgName +
  33876. "&doctor=" + user_name
  33877. fmt.Println(api)
  33878. resp, requestErr := http.Get(api)
  33879. if requestErr != nil {
  33880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33881. return
  33882. }
  33883. body, ioErr := ioutil.ReadAll(resp.Body)
  33884. fmt.Println(body)
  33885. if ioErr != nil {
  33886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33888. return
  33889. }
  33890. var respJSON map[string]interface{}
  33891. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33894. return
  33895. }
  33896. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33897. userJSONBytes, _ := json.Marshal(respJSON)
  33898. var res ResultEight
  33899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33900. utils.ErrorLog("解析失败:%v", err)
  33901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33902. return
  33903. }
  33904. }
  33905. // 对账明细
  33906. func (c *HisApiController) GetCheckDetailAccount() {
  33907. start_time := c.GetString("start_time")
  33908. end_time := c.GetString("end_time")
  33909. admin_user_id, _ := c.GetInt64("admin_user_id")
  33910. adminUser := c.GetAdminUserInfo()
  33911. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33912. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33913. timeLayout := "2006-01-02"
  33914. loc, _ := time.LoadLocation("Local")
  33915. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33916. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33917. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33918. rand.Seed(time.Now().UnixNano())
  33919. num := rand.Intn(30000)
  33920. Mkdir(miConfig.OrgName)
  33921. file := strconv.FormatInt(int64(num), 10)
  33922. file_name := file + ".txt"
  33923. zip_name := file + ".zip"
  33924. zip_path := miConfig.OrgName + "/" + zip_name
  33925. file_path := miConfig.OrgName + "/" + file_name
  33926. decimal.DivisionPrecision = 2
  33927. var medfee_sumamt float64
  33928. var psn_cash_pay float64
  33929. var fund_pay_sumamt float64
  33930. fixmedins_setl_cnt := int64(len(orders))
  33931. for _, item := range orders {
  33932. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33933. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  33934. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33935. }
  33936. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  33937. defer f.Close()
  33938. if err != nil {
  33939. fmt.Println(err.Error())
  33940. } else {
  33941. for _, item := range orders {
  33942. var refd_setl_flag string
  33943. if item.OrderStatus == 2 {
  33944. refd_setl_flag = "0"
  33945. var str string
  33946. str = item.SetlId + " " +
  33947. item.MdtrtId + " " +
  33948. item.PsnNo + " " +
  33949. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33950. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33951. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  33952. _, err = f.Write([]byte(str))
  33953. }
  33954. if item.OrderStatus == 3 {
  33955. var str string
  33956. str = item.SetlId + " " +
  33957. item.MdtrtId + " " +
  33958. item.PsnNo + " " +
  33959. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33960. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33961. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  33962. _, err = f.Write([]byte(str))
  33963. var str2 string
  33964. str2 = item.SetlId + " " +
  33965. item.MdtrtId + " " +
  33966. item.PsnNo + " " +
  33967. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  33968. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  33969. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  33970. _, err = f.Write([]byte(str2))
  33971. }
  33972. }
  33973. }
  33974. Zip(file_path, zip_path)
  33975. fmt.Println(ReadFile(zip_path))
  33976. fmt.Println(string(ReadFile(zip_path)))
  33977. if config.IsOpen == 1 {
  33978. var user_name string
  33979. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33980. if role.ID == 0 {
  33981. user_name = "管理员"
  33982. } else {
  33983. user_name = role.UserName
  33984. }
  33985. baseParams := models.BaseParams{
  33986. SecretKey: miConfig.SecretKey,
  33987. FixmedinsCode: miConfig.Code,
  33988. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33989. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33990. OrgName: miConfig.OrgName,
  33991. Doctor: user_name,
  33992. }
  33993. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  33994. var dat map[string]interface{}
  33995. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33996. fmt.Println(dat)
  33997. } else {
  33998. fmt.Println(err)
  33999. }
  34000. userJSONBytes, _ := json.Marshal(dat)
  34001. var res ResultNine
  34002. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34003. utils.ErrorLog("解析失败:%v", err)
  34004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34005. return
  34006. }
  34007. if res.Infcode == 0 {
  34008. fileNo := res.Output.FileQuryNo
  34009. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34010. "file_qury_no=" + fileNo +
  34011. "&setl_optins=" + "定点医保中心" +
  34012. "&stmt_begndate=" + start_time +
  34013. "&stm_enddate=" + end_time +
  34014. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34015. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34016. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34017. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34018. "&fixmedins_code=" + miConfig.Code +
  34019. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34020. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34021. "&secret_key=" + miConfig.SecretKey +
  34022. "&org_name=" + miConfig.OrgName +
  34023. "&doctor=" + user_name
  34024. resp, requestErr := http.Get(api)
  34025. if requestErr != nil {
  34026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34027. return
  34028. }
  34029. body, ioErr := ioutil.ReadAll(resp.Body)
  34030. if ioErr != nil {
  34031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34033. return
  34034. }
  34035. var respJSON map[string]interface{}
  34036. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34039. return
  34040. }
  34041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34042. userJSONBytes, _ := json.Marshal(respJSON)
  34043. var res ResultTen
  34044. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34045. utils.ErrorLog("解析失败:%v", err)
  34046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34047. return
  34048. }
  34049. if res.Infcode == 0 {
  34050. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34051. micc := &models.MedicalInsuranceCostCompare{
  34052. StartTime: startime.Unix(),
  34053. EndTime: endtime.Unix(),
  34054. Insutype: "0",
  34055. CheckType: 2,
  34056. Num: fixmedins_setl_cnt,
  34057. Mtime: time.Now().Unix(),
  34058. Status: 1,
  34059. UserOrgId: adminUser.CurrentOrgId,
  34060. CostTotal: medfee_sumamt,
  34061. FuncTotal: fund_pay_sumamt,
  34062. PsnPay: psn_cash_pay,
  34063. Creator: admin_user_id,
  34064. Ctime: time.Now().Unix(),
  34065. }
  34066. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34067. c.ServeSuccessJSON(map[string]interface{}{
  34068. "msg": "明细对账成功",
  34069. })
  34070. }
  34071. } else {
  34072. }
  34073. }
  34074. }
  34075. type CustomOrderInfo struct {
  34076. Name string
  34077. Spec string
  34078. Unit string
  34079. Count float64
  34080. Price float64
  34081. Total float64
  34082. }
  34083. func (c *HisApiController) GetBatchSettleAccounts() {
  34084. admin_user_id, _ := c.GetInt64("admin_user_id")
  34085. order_ids := c.GetString("order_ids")
  34086. order_ids_arr := strings.Split(order_ids, ",")
  34087. data3 := []map[string]interface{}{}
  34088. for _, item := range order_ids_arr {
  34089. id, _ := strconv.ParseInt(item, 10, 64)
  34090. order_id := id
  34091. adminUser := c.GetAdminUserInfo()
  34092. order, _ := service.GetHisOrderByID(order_id)
  34093. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34094. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34095. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34096. orderInfos = append(orderInfos, orderInfos_two...)
  34097. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34098. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34099. var diagnosis_ids []string
  34100. if his.ID > 0 {
  34101. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34102. } else {
  34103. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34104. }
  34105. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34106. var dia_config []*models.HisXtDiagnoseConfig
  34107. var name string
  34108. for _, item := range diagnosis_ids {
  34109. id, _ := strconv.ParseInt(item, 10, 64)
  34110. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34111. dia_config = append(dia_config, &diagnosisConfig)
  34112. if len(name) == 0 {
  34113. name = diagnosisConfig.ClassName
  34114. }
  34115. //} else {
  34116. // name = name + "," + diagnosisConfig.ClassName
  34117. //}
  34118. }
  34119. var bedCostTotal float64 = 0 //床位总费
  34120. var bedCostSelfTotal float64 = 0 //床位自费
  34121. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34122. var bedSelfTotal float64 = 0 //床位部分项目自费
  34123. var bedInscpTotal float64 = 0 //床位部分项目自费
  34124. var operationCostTotal float64 = 0 //手术费
  34125. var operationCostSelfTotal float64 = 0 //手术费
  34126. var operationCostPartSelfTotal float64 = 0 //手术费
  34127. var operationSelfTotal float64 = 0 //床位部分项目自费
  34128. var operationInscpTotal float64 = 0 //床位部分项目自费
  34129. var otherCostTotal float64 = 0 //其他费用
  34130. var otherCostSelfTotal float64 = 0 //其他费用
  34131. var otherCostPartSelfTotal float64 = 0 //其他费用
  34132. var otherSelfTotal float64 = 0 //床位部分项目自费
  34133. var otherInscpTotal float64 = 0 //床位部分项目自费
  34134. var materialCostTotal float64 = 0 //材料费
  34135. var materialCostSelfTotal float64 = 0 //材料费
  34136. var materialCostPartSelfTotal float64 = 0 //材料费
  34137. var materialSelfTotal float64 = 0 //床位部分项目自费
  34138. var materialInscpTotal float64 = 0 //床位部分项目自费
  34139. var westernMedicineCostTotal float64 = 0 //西药费
  34140. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34141. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34142. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34143. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34144. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34145. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34146. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34147. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34148. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34149. var checkCostTotal float64 = 0 //检查费
  34150. var checkCostSelfTotal float64 = 0 //检查费
  34151. var checkCostPartSelfTotal float64 = 0 //检查费
  34152. var checkSelfTotal float64 = 0 //床位部分项目自费
  34153. var checkInscpTotal float64 = 0 //床位部分项目自费
  34154. var laboratoryCostTotal float64 = 0 //化验费
  34155. var laboratoryCostSelfTotal float64 = 0 //化验费
  34156. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34157. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34158. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34159. var treatCostTotal float64 = 0 //治疗费用
  34160. var treatCostSelfTotal float64 = 0 //治疗费用
  34161. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34162. var treatSelfTotal float64 = 0 //床位部分项目自费
  34163. var treatInscpTotal float64 = 0 //床位部分项目自费
  34164. decimal.DivisionPrecision = 2
  34165. for _, item := range orderInfos {
  34166. if item.MedChrgitmType == "01" { //床位费
  34167. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34168. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34169. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34170. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34171. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34172. }
  34173. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34174. if item.MedChrgitmType == "03" { //检查费
  34175. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34176. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34177. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34178. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34179. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34180. }
  34181. } else {
  34182. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34183. fmt.Println("------------")
  34184. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34185. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34186. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34187. }
  34188. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34189. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34190. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34191. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34192. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34193. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34194. }
  34195. }
  34196. if item.MedChrgitmType == "04" { //化验费
  34197. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34198. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34199. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34200. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34201. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34202. }
  34203. if item.MedChrgitmType == "05" { //治疗费
  34204. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34205. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34206. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34207. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34208. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34209. }
  34210. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34211. fmt.Println("------------")
  34212. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34213. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34214. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34215. }
  34216. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34217. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34218. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34219. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34220. }
  34221. //if item.MedChrgitmType == "06" { //手术费
  34222. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34223. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34224. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34225. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34226. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34227. //
  34228. //}
  34229. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34230. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34231. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34232. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34233. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34234. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34235. }
  34236. if item.MedChrgitmType == "09" { //西药费
  34237. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34238. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34239. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34240. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34241. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34242. }
  34243. if item.MedChrgitmType == "11" { //中成费
  34244. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34245. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34246. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34247. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34248. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34249. }
  34250. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34251. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34252. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34253. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34254. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34255. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34256. }
  34257. }
  34258. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34259. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34260. var user_name string
  34261. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34262. if role.ID == 0 {
  34263. user_name = "管理员"
  34264. } else {
  34265. user_name = role.UserName
  34266. }
  34267. baseParams := models.BaseParams{
  34268. SecretKey: miConfig.SecretKey,
  34269. FixmedinsCode: miConfig.Code,
  34270. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34271. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34272. OrgName: miConfig.OrgName,
  34273. Doctor: user_name,
  34274. RequestUrl: miConfig.Url,
  34275. AccessKey: miConfig.AccessKey,
  34276. }
  34277. businessParams := models.BusinessParams{
  34278. PsnNo: order.PsnNo,
  34279. MdtrtId: order.MdtrtId,
  34280. SetlId: order.SetlId,
  34281. }
  34282. var res ResultEleven
  34283. var resEleven10265 ResultEleven10265
  34284. if config.IsOpen == 1 {
  34285. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34286. result := service.Gdyb5203(baseParams, businessParams)
  34287. service.Gdyb5204(baseParams, businessParams)
  34288. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34289. var dat map[string]interface{}
  34290. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34291. fmt.Println(dat)
  34292. } else {
  34293. fmt.Println(err)
  34294. }
  34295. userJSONBytes, _ := json.Marshal(dat)
  34296. if miConfig.Code == "H15049901371" {
  34297. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34298. utils.ErrorLog("解析失败:%v", err)
  34299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34300. return
  34301. }
  34302. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34303. res.Output = resEleven10265.Output
  34304. res.ErrMsg = resEleven10265.ErrMsg
  34305. res.Cainfo = resEleven10265.Cainfo
  34306. res.WarnMsg = resEleven10265.WarnMsg
  34307. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34308. res.Infcode = infocode
  34309. } else {
  34310. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34311. utils.ErrorLog("解析失败:%v", err)
  34312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34313. return
  34314. }
  34315. }
  34316. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34317. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34318. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34319. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34320. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34321. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34322. var doctor_name string
  34323. if roles.ID == 0 {
  34324. doctor_name = "管理员"
  34325. } else {
  34326. doctor_name = roles.UserName
  34327. }
  34328. yiliao_leibie := ""
  34329. switch order.MedType {
  34330. case "11":
  34331. yiliao_leibie = "普通门诊"
  34332. break
  34333. case "12":
  34334. yiliao_leibie = "门诊挂号"
  34335. break
  34336. case "13":
  34337. yiliao_leibie = "急诊"
  34338. break
  34339. case "14":
  34340. yiliao_leibie = "门诊特殊病"
  34341. break
  34342. case "15":
  34343. yiliao_leibie = "门诊统筹"
  34344. break
  34345. case "16":
  34346. yiliao_leibie = "门诊慢性病"
  34347. break
  34348. case "21":
  34349. yiliao_leibie = "普通住院"
  34350. break
  34351. }
  34352. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34353. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34354. if res.Infcode == 0 {
  34355. data2 := map[string]interface{}{
  34356. "diagnosis": name,
  34357. "order_infos": orderInfos,
  34358. "number": order.MdtrtId,
  34359. "date": order.SettleAccountsDate,
  34360. "charge_admin": charge_admin,
  34361. "printor_admin": printor_admin,
  34362. "info": res.Output.Setlinfo,
  34363. "order": order,
  34364. "bedCostTotal": bedCostTotal,
  34365. "bedCostSelfTotal": bedCostSelfTotal,
  34366. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34367. "bedSelfTotal": bedSelfTotal,
  34368. "bedInscpTotal": bedInscpTotal,
  34369. "operationCostTotal": operationCostTotal,
  34370. "operationCostSelfTotal": operationCostSelfTotal,
  34371. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34372. "operationSelfTotal": operationSelfTotal,
  34373. "operationInscpTotal": operationInscpTotal,
  34374. "otherCostTotal": otherCostTotal,
  34375. "otherCostSelfTotal": otherCostSelfTotal,
  34376. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34377. "otherSelfTotal": otherSelfTotal,
  34378. "otherInscpTotal": otherInscpTotal,
  34379. "materialCostTotal": materialCostTotal,
  34380. "materialCostSelfTotal": materialCostSelfTotal,
  34381. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34382. "materialSelfTotal": materialSelfTotal,
  34383. "materialInscpTotal": materialInscpTotal,
  34384. "westernMedicineCostTotal": westernMedicineCostTotal,
  34385. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34386. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34387. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34388. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34389. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34390. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34391. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34392. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34393. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34394. "checkCostTotal": checkCostTotal,
  34395. "checkCostSelfTotal": checkCostSelfTotal,
  34396. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34397. "checkSelfTotal": checkSelfTotal,
  34398. "checkInscpTotal": checkInscpTotal,
  34399. "laboratoryCostTotal": laboratoryCostTotal,
  34400. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34401. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34402. "laboratorySelfTotal": laboratorySelfTotal,
  34403. "laboratoryInscpTotal": laboratoryInscpTotal,
  34404. "treatCostTotal": treatCostTotal,
  34405. "treatCostSelfTotal": treatCostSelfTotal,
  34406. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34407. "treatSelfTotal": treatSelfTotal,
  34408. "treatInscpTotal": treatInscpTotal,
  34409. "doctor_info": doctor_info,
  34410. "doctor_code": adminRole_two.DoctorCode,
  34411. "doctor_name": doctor_name,
  34412. "health_card_no": order.PsnNo,
  34413. "department": departments.Name,
  34414. "yiliao_leibie": yiliao_leibie,
  34415. "after_money": order.AccountPrice,
  34416. "patient": patient,
  34417. "org_name": miConfig.OrgName,
  34418. "org_code": miConfig.Code,
  34419. "order_number": order.Number,
  34420. "his_hospital": his_hospital,
  34421. "his": his,
  34422. "dia_config": dia_config,
  34423. "psn_cash_pay": order.PsnCashPay,
  34424. //"check_order_info": cus_slice,
  34425. }
  34426. data3 = append(data3, data2)
  34427. }
  34428. }
  34429. }
  34430. c.ServeSuccessJSON(map[string]interface{}{
  34431. "infos": data3,
  34432. })
  34433. }
  34434. func (c *HisApiController) GetSettleAccounts() {
  34435. //id, _ := c.GetInt64("id")
  34436. //record_time := c.GetString("record_time")
  34437. order_id, _ := c.GetInt64("order_id")
  34438. admin_user_id, _ := c.GetInt64("admin_user_id")
  34439. //timeLayout := "2006-01-02"
  34440. //loc, _ := time.LoadLocation("Local")
  34441. //
  34442. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34443. //if err != nil {
  34444. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34445. // return
  34446. //}Hbyb5203
  34447. //recordDateTime := theTime.Unix()
  34448. adminUser := c.GetAdminUserInfo()
  34449. order, _ := service.GetHisOrderByID(order_id)
  34450. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34451. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34452. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34453. orderInfos = append(orderInfos, orderInfos_two...)
  34454. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34455. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34456. var diagnosis_ids []string
  34457. if his.ID > 0 {
  34458. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34459. } else {
  34460. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34461. }
  34462. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34463. var dia_config []*models.HisXtDiagnoseConfig
  34464. var name string
  34465. for _, item := range diagnosis_ids {
  34466. id, _ := strconv.ParseInt(item, 10, 64)
  34467. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34468. dia_config = append(dia_config, &diagnosisConfig)
  34469. if len(name) == 0 {
  34470. name = diagnosisConfig.ClassName
  34471. } else {
  34472. name = name + "," + diagnosisConfig.ClassName
  34473. }
  34474. }
  34475. if patient.UserOrgId == 10215 {
  34476. name = "慢性肾功能不全(血透治疗)"
  34477. }
  34478. var bedCostTotal float64 = 0 //床位总费
  34479. var bedCostSelfTotal float64 = 0 //床位自费
  34480. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34481. var bedSelfTotal float64 = 0 //床位部分项目自费
  34482. var bedInscpTotal float64 = 0 //床位部分项目自费
  34483. var operationCostTotal float64 = 0 //手术费
  34484. var operationCostSelfTotal float64 = 0 //手术费
  34485. var operationCostPartSelfTotal float64 = 0 //手术费
  34486. var operationSelfTotal float64 = 0 //床位部分项目自费
  34487. var operationInscpTotal float64 = 0 //床位部分项目自费
  34488. var otherCostTotal float64 = 0 //其他费用
  34489. var otherCostSelfTotal float64 = 0 //其他费用
  34490. var otherCostPartSelfTotal float64 = 0 //其他费用
  34491. var otherSelfTotal float64 = 0 //床位部分项目自费
  34492. var otherInscpTotal float64 = 0 //床位部分项目自费
  34493. var materialCostTotal float64 = 0 //材料费
  34494. var materialCostSelfTotal float64 = 0 //材料费
  34495. var materialCostPartSelfTotal float64 = 0 //材料费
  34496. var materialSelfTotal float64 = 0 //床位部分项目自费
  34497. var materialInscpTotal float64 = 0 //床位部分项目自费
  34498. var westernMedicineCostTotal float64 = 0 //西药费
  34499. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34500. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34501. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34502. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34503. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34504. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34505. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34506. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34507. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34508. var checkCostTotal float64 = 0 //检查费
  34509. var checkCostSelfTotal float64 = 0 //检查费
  34510. var checkCostPartSelfTotal float64 = 0 //检查费
  34511. var checkSelfTotal float64 = 0 //床位部分项目自费
  34512. var checkInscpTotal float64 = 0 //床位部分项目自费
  34513. var laboratoryCostTotal float64 = 0 //化验费
  34514. var laboratoryCostSelfTotal float64 = 0 //化验费
  34515. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34516. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34517. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34518. var treatCostTotal float64 = 0 //治疗费用
  34519. var treatCostSelfTotal float64 = 0 //治疗费用
  34520. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34521. var treatSelfTotal float64 = 0 //床位部分项目自费
  34522. var treatInscpTotal float64 = 0 //床位部分项目自费
  34523. var zcCostTotal float64 = 0 //治疗费用
  34524. var zcCostSelfTotal float64 = 0 //治疗费用
  34525. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34526. var zcSelfTotal float64 = 0 //床位部分项目自费
  34527. var zcInscpTotal float64 = 0 //床位部分项目自费
  34528. var huliCostTotal float64 = 0 //治疗费用
  34529. var huliCostSelfTotal float64 = 0 //治疗费用
  34530. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34531. var huliSelfTotal float64 = 0 //床位部分项目自费
  34532. var huliInscpTotal float64 = 0 //床位部分项目自费
  34533. decimal.DivisionPrecision = 2
  34534. for _, item := range orderInfos {
  34535. if item.MedChrgitmType == "01" { //床位费
  34536. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34537. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34538. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34539. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34540. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34541. }
  34542. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34543. if item.MedChrgitmType == "03" { //检查费
  34544. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34545. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34546. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34547. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34548. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34549. }
  34550. } else {
  34551. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34552. fmt.Println("------------")
  34553. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34554. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34555. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34556. }
  34557. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34558. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34559. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34560. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34561. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34562. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34563. }
  34564. }
  34565. if item.MedChrgitmType == "04" { //化验费
  34566. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34567. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34568. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34569. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34570. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34571. }
  34572. if item.MedChrgitmType == "05" { //治疗费
  34573. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34574. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34575. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34576. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34577. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34578. }
  34579. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34580. fmt.Println("------------")
  34581. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34582. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34583. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34584. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34585. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34586. }
  34587. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34588. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34589. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34590. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34591. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34592. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34593. }
  34594. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34595. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34596. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34597. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34598. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34599. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34600. }
  34601. if item.MedChrgitmType == "09" { //西药费
  34602. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34603. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34604. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34605. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34606. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34607. }
  34608. if item.MedChrgitmType == "11" { //中成费
  34609. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34610. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34611. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34612. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34613. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34614. }
  34615. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34616. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34617. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34618. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34619. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34620. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34621. }
  34622. if item.MedChrgitmType == "02" { //其他费
  34623. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34624. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34625. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34626. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34627. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34628. }
  34629. if item.MedChrgitmType == "07" { //其他费
  34630. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34631. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34632. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34633. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34634. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34635. }
  34636. }
  34637. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34638. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34639. var user_name string
  34640. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34641. if role.ID == 0 {
  34642. user_name = "管理员"
  34643. } else {
  34644. user_name = role.UserName
  34645. }
  34646. baseParams := models.BaseParams{
  34647. SecretKey: miConfig.SecretKey,
  34648. FixmedinsCode: miConfig.Code,
  34649. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34650. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34651. OrgName: miConfig.OrgName,
  34652. Doctor: user_name,
  34653. RequestUrl: miConfig.Url,
  34654. AccessKey: miConfig.AccessKey,
  34655. }
  34656. businessParams := models.BusinessParams{
  34657. PsnNo: order.PsnNo,
  34658. MdtrtId: order.MdtrtId,
  34659. SetlId: order.SetlId,
  34660. }
  34661. var res ResultEleven
  34662. var resah ResultElevenah
  34663. var resEleven10265 ResultEleven10265
  34664. if config.IsOpen == 1 {
  34665. if miConfig.MdtrtareaAdmvs == "421300" {
  34666. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34667. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34668. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34669. resp, requestErr := http.Get(api)
  34670. if requestErr != nil {
  34671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34672. return
  34673. }
  34674. body, ioErr := ioutil.ReadAll(resp.Body)
  34675. if ioErr != nil {
  34676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34678. return
  34679. }
  34680. var respJSON map[string]interface{}
  34681. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34684. return
  34685. }
  34686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34687. result, _ := json.Marshal(respJSON)
  34688. fmt.Println("log")
  34689. fmt.Println(string(result))
  34690. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34691. utils.ErrorLog("解析失败:%v", err)
  34692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34693. return
  34694. }
  34695. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34696. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34697. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34698. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34699. resp, requestErr := http.Get(api)
  34700. if requestErr != nil {
  34701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34702. return
  34703. }
  34704. body, ioErr := ioutil.ReadAll(resp.Body)
  34705. if ioErr != nil {
  34706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34708. return
  34709. }
  34710. var respJSON map[string]interface{}
  34711. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34714. return
  34715. }
  34716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34717. result, _ := json.Marshal(respJSON)
  34718. fmt.Println("log")
  34719. fmt.Println(string(result))
  34720. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34721. utils.ErrorLog("解析失败:%v", err)
  34722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34723. return
  34724. }
  34725. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34726. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34727. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34728. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34729. resp, requestErr := http.Get(api)
  34730. if requestErr != nil {
  34731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34732. return
  34733. }
  34734. body, ioErr := ioutil.ReadAll(resp.Body)
  34735. if ioErr != nil {
  34736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34738. return
  34739. }
  34740. var respJSON map[string]interface{}
  34741. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34744. return
  34745. }
  34746. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34747. result, _ := json.Marshal(respJSON)
  34748. fmt.Println("log")
  34749. fmt.Println(string(result))
  34750. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34751. utils.ErrorLog("解析失败:%v", err)
  34752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34753. return
  34754. }
  34755. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34756. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34757. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34758. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34759. resp, requestErr := http.Get(api)
  34760. if requestErr != nil {
  34761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34762. return
  34763. }
  34764. body, ioErr := ioutil.ReadAll(resp.Body)
  34765. if ioErr != nil {
  34766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34768. return
  34769. }
  34770. var respJSON map[string]interface{}
  34771. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34774. return
  34775. }
  34776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34777. result, _ := json.Marshal(respJSON)
  34778. fmt.Println("log")
  34779. fmt.Println(string(result))
  34780. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34781. utils.ErrorLog("解析失败:%v", err)
  34782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34783. return
  34784. }
  34785. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34786. var api string
  34787. if miConfig.MdtrtareaAdmvs == "320921" {
  34788. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34789. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34790. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34791. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34792. } else {
  34793. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34794. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34795. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34796. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34797. }
  34798. resp, requestErr := http.Get(api)
  34799. if requestErr != nil {
  34800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34801. return
  34802. }
  34803. body, ioErr := ioutil.ReadAll(resp.Body)
  34804. if ioErr != nil {
  34805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34807. return
  34808. }
  34809. var respJSON map[string]interface{}
  34810. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34813. return
  34814. }
  34815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34816. result, _ := json.Marshal(respJSON)
  34817. fmt.Println("log")
  34818. fmt.Println(string(result))
  34819. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34820. utils.ErrorLog("解析失败:%v", err)
  34821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34822. return
  34823. }
  34824. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34825. res.Output = resEleven10265.Output
  34826. res.ErrMsg = resEleven10265.ErrMsg
  34827. res.Cainfo = resEleven10265.Cainfo
  34828. res.WarnMsg = resEleven10265.WarnMsg
  34829. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34830. res.Infcode = infocode
  34831. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34832. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34833. saveLog(result, requestLog, "5203", "结算单")
  34834. var dat map[string]interface{}
  34835. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34836. fmt.Println(dat)
  34837. } else {
  34838. fmt.Println(err)
  34839. }
  34840. userJSONBytes, _ := json.Marshal(dat)
  34841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34842. utils.ErrorLog("解析失败:%v", err)
  34843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34844. return
  34845. }
  34846. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34847. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34848. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34849. saveLog(result, requestLog, "5203", "结算单")
  34850. var dat map[string]interface{}
  34851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34852. fmt.Println(dat)
  34853. } else {
  34854. fmt.Println(err)
  34855. }
  34856. userJSONBytes, _ := json.Marshal(dat)
  34857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34858. utils.ErrorLog("解析失败:%v", err)
  34859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34860. return
  34861. }
  34862. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34863. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34864. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34865. saveLog(result, requestLog, "5203", "结算单")
  34866. var dat map[string]interface{}
  34867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34868. fmt.Println(dat)
  34869. } else {
  34870. fmt.Println(err)
  34871. }
  34872. userJSONBytes, _ := json.Marshal(dat)
  34873. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34874. utils.ErrorLog("解析失败:%v", err)
  34875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34876. return
  34877. }
  34878. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34879. var api string
  34880. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34881. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34882. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34883. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34884. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34885. resp, requestErr := http.Get(api)
  34886. if requestErr != nil {
  34887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34888. return
  34889. }
  34890. body, ioErr := ioutil.ReadAll(resp.Body)
  34891. if ioErr != nil {
  34892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34894. return
  34895. }
  34896. var respJSON map[string]interface{}
  34897. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34900. return
  34901. }
  34902. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34903. if status == "0" {
  34904. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34905. c.ServeSuccessJSON(map[string]interface{}{
  34906. "failed_code": -10,
  34907. "msg": err_msg,
  34908. })
  34909. return
  34910. }
  34911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34912. result, _ := json.Marshal(respJSON)
  34913. fmt.Println("log")
  34914. fmt.Println(string(result))
  34915. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34916. utils.ErrorLog("解析失败:%v", err)
  34917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34918. return
  34919. }
  34920. res.InfRefmsgid = resah.InfRefmsgid
  34921. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34922. // 创建对应的Time类型
  34923. t := time.UnixMilli(timestamp)
  34924. // 格式化成指定的日期字符串
  34925. str := t.Format("2006-01-02 15:04:05")
  34926. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34927. // 创建对应的Time类型
  34928. t3 := time.UnixMilli(timestamp2)
  34929. // 格式化成指定的日期字符串
  34930. str2 := t3.Format("2006-01-02 15:04:05")
  34931. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34932. // 创建对应的Time类型
  34933. t4 := time.UnixMilli(timestamp3)
  34934. // 格式化成指定的日期字符串
  34935. str3 := t4.Format("2006-01-02 15:04:05")
  34936. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34937. // 创建对应的Time类型
  34938. t5 := time.UnixMilli(timestamp4)
  34939. // 格式化成指定的日期字符串
  34940. str5 := t5.Format("2006-01-02 15:04:05")
  34941. res.Output.Setlinfo.Brdy = str2
  34942. res.Output.Setlinfo.SetlTime = str
  34943. res.Output.Setlinfo.Begndate = str3
  34944. res.Output.Setlinfo.Enddate = str5
  34945. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34946. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34947. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34948. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34949. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34950. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34951. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34952. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34953. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34954. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34955. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34956. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34957. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34958. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34959. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34960. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34961. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34962. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34963. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34964. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34965. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34966. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34967. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34968. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34969. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34970. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34971. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34972. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34973. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34974. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34975. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34976. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34977. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34978. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34979. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34980. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34981. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34982. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34983. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34984. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34985. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34986. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34987. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34988. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34989. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34990. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34991. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34992. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34993. //res.Output.Setldetail = resah.Output.Setldetail
  34994. res.ErrMsg = resah.ErrMsg
  34995. res.Cainfo = resah.Cainfo
  34996. res.WarnMsg = resah.WarnMsg
  34997. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34998. var api string
  34999. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35000. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35001. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35002. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35003. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35004. resp, requestErr := http.Get(api)
  35005. if requestErr != nil {
  35006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35007. return
  35008. }
  35009. body, ioErr := ioutil.ReadAll(resp.Body)
  35010. if ioErr != nil {
  35011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35013. return
  35014. }
  35015. var respJSON map[string]interface{}
  35016. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35019. return
  35020. }
  35021. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35022. if status == "0" {
  35023. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35024. c.ServeSuccessJSON(map[string]interface{}{
  35025. "failed_code": -10,
  35026. "msg": err_msg,
  35027. })
  35028. return
  35029. }
  35030. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35031. result, _ := json.Marshal(respJSON)
  35032. fmt.Println("log")
  35033. fmt.Println(string(result))
  35034. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35035. utils.ErrorLog("解析失败:%v", err)
  35036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35037. return
  35038. }
  35039. res.InfRefmsgid = resah.InfRefmsgid
  35040. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35041. // 创建对应的Time类型
  35042. t := time.UnixMilli(timestamp)
  35043. // 格式化成指定的日期字符串
  35044. str := t.Format("2006-01-02 15:04:05")
  35045. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35046. // 创建对应的Time类型
  35047. t3 := time.UnixMilli(timestamp2)
  35048. // 格式化成指定的日期字符串
  35049. str2 := t3.Format("2006-01-02 15:04:05")
  35050. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35051. // 创建对应的Time类型
  35052. t4 := time.UnixMilli(timestamp3)
  35053. // 格式化成指定的日期字符串
  35054. str3 := t4.Format("2006-01-02 15:04:05")
  35055. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35056. // 创建对应的Time类型
  35057. t5 := time.UnixMilli(timestamp4)
  35058. // 格式化成指定的日期字符串
  35059. str5 := t5.Format("2006-01-02 15:04:05")
  35060. res.Output.Setlinfo.Brdy = str2
  35061. res.Output.Setlinfo.SetlTime = str
  35062. res.Output.Setlinfo.Begndate = str3
  35063. res.Output.Setlinfo.Enddate = str5
  35064. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35065. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35066. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35067. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35068. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35069. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35070. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35071. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35072. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35073. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35074. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35075. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35076. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35077. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35078. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35079. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35080. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35081. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35082. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35083. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35084. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35085. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35086. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35087. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35088. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35089. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35090. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35091. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35092. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35093. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35094. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35095. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35096. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35097. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35098. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35099. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35100. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35101. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35102. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35103. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35104. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35105. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35106. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35107. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35108. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35109. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35110. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35111. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35112. //res.Output.Setldetail = resah.Output.Setldetail
  35113. res.ErrMsg = resah.ErrMsg
  35114. res.Cainfo = resah.Cainfo
  35115. res.WarnMsg = resah.WarnMsg
  35116. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35117. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35118. saveLog(result, requestLog, "5203", "结算单")
  35119. var dat map[string]interface{}
  35120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35121. fmt.Println(dat)
  35122. } else {
  35123. fmt.Println(err)
  35124. }
  35125. userJSONBytes, _ := json.Marshal(dat)
  35126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35127. utils.ErrorLog("解析失败:%v", err)
  35128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35129. return
  35130. }
  35131. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35132. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35133. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35134. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35135. resp, requestErr := http.Get(api)
  35136. if requestErr != nil {
  35137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35138. return
  35139. }
  35140. body, ioErr := ioutil.ReadAll(resp.Body)
  35141. if ioErr != nil {
  35142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35144. return
  35145. }
  35146. var respJSON map[string]interface{}
  35147. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35150. return
  35151. }
  35152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35153. result, _ := json.Marshal(respJSON)
  35154. fmt.Println("log")
  35155. fmt.Println(string(result))
  35156. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35157. utils.ErrorLog("解析失败:%v", err)
  35158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35159. return
  35160. }
  35161. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35162. res.Output = resEleven10265.Output
  35163. res.ErrMsg = resEleven10265.ErrMsg
  35164. res.Cainfo = resEleven10265.Cainfo
  35165. res.WarnMsg = resEleven10265.WarnMsg
  35166. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35167. res.Infcode = infocode
  35168. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35169. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35170. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35171. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35172. resp, requestErr := http.Get(api)
  35173. if requestErr != nil {
  35174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35175. return
  35176. }
  35177. body, ioErr := ioutil.ReadAll(resp.Body)
  35178. if ioErr != nil {
  35179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35181. return
  35182. }
  35183. var respJSON map[string]interface{}
  35184. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35187. return
  35188. }
  35189. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35190. result, _ := json.Marshal(respJSON)
  35191. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35192. utils.ErrorLog("解析失败:%v", err)
  35193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35194. return
  35195. }
  35196. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35197. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35198. //return
  35199. } else {
  35200. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35201. if len(his.InsuplcAdmdvs) == 0 {
  35202. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35203. } else {
  35204. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35205. }
  35206. result := service.Gdyb5203(baseParams, businessParams)
  35207. //service.Gdyb5204(baseParams, businessParams)
  35208. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35209. var dat map[string]interface{}
  35210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35211. fmt.Println(dat)
  35212. } else {
  35213. fmt.Println(err)
  35214. }
  35215. userJSONBytes, _ := json.Marshal(dat)
  35216. if miConfig.Code == "H15049901371" {
  35217. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35218. utils.ErrorLog("解析失败:%v", err)
  35219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35220. return
  35221. }
  35222. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35223. res.Output = resEleven10265.Output
  35224. res.ErrMsg = resEleven10265.ErrMsg
  35225. res.Cainfo = resEleven10265.Cainfo
  35226. res.WarnMsg = resEleven10265.WarnMsg
  35227. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35228. res.Infcode = infocode
  35229. } else {
  35230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35231. utils.ErrorLog("解析失败:%v", err)
  35232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35233. return
  35234. }
  35235. }
  35236. }
  35237. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35238. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35239. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35240. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35241. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35242. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35243. var doctor_name string
  35244. if roles.ID == 0 {
  35245. doctor_name = "管理员"
  35246. } else {
  35247. doctor_name = roles.UserName
  35248. }
  35249. yiliao_leibie := ""
  35250. switch order.MedType {
  35251. case "11":
  35252. yiliao_leibie = "普通门诊"
  35253. break
  35254. case "12":
  35255. yiliao_leibie = "门诊挂号"
  35256. break
  35257. case "13":
  35258. yiliao_leibie = "急诊"
  35259. break
  35260. case "14":
  35261. yiliao_leibie = "门诊特殊病"
  35262. break
  35263. case "15":
  35264. yiliao_leibie = "门诊统筹"
  35265. break
  35266. case "16":
  35267. yiliao_leibie = "门诊慢性病"
  35268. break
  35269. case "21":
  35270. yiliao_leibie = "普通住院"
  35271. break
  35272. }
  35273. //var rf []CustomFundPay
  35274. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35275. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35276. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35277. if res.Infcode == 0 {
  35278. 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 {
  35279. c.ServeSuccessJSON(map[string]interface{}{
  35280. "diagnosis": name,
  35281. "order_infos": orderInfos,
  35282. "number": order.MdtrtId,
  35283. "date": order.SettleAccountsDate,
  35284. "charge_admin": charge_admin,
  35285. "printor_admin": printor_admin,
  35286. "info": res.Output.Setlinfo,
  35287. "order": order,
  35288. "bedCostTotal": bedCostTotal,
  35289. "bedCostSelfTotal": bedCostSelfTotal,
  35290. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35291. "bedSelfTotal": bedSelfTotal,
  35292. "bedInscpTotal": bedInscpTotal,
  35293. "operationCostTotal": operationCostTotal,
  35294. "operationCostSelfTotal": operationCostSelfTotal,
  35295. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35296. "operationSelfTotal": operationSelfTotal,
  35297. "operationInscpTotal": operationInscpTotal,
  35298. "otherCostTotal": otherCostTotal,
  35299. "otherCostSelfTotal": otherCostSelfTotal,
  35300. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35301. "otherSelfTotal": otherSelfTotal,
  35302. "otherInscpTotal": otherInscpTotal,
  35303. "materialCostTotal": materialCostTotal,
  35304. "materialCostSelfTotal": materialCostSelfTotal,
  35305. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35306. "materialSelfTotal": materialSelfTotal,
  35307. "materialInscpTotal": materialInscpTotal,
  35308. "westernMedicineCostTotal": westernMedicineCostTotal,
  35309. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35310. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35311. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35312. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35313. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35314. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35315. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35316. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35317. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35318. "checkCostTotal": checkCostTotal,
  35319. "checkCostSelfTotal": checkCostSelfTotal,
  35320. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35321. "checkSelfTotal": checkSelfTotal,
  35322. "checkInscpTotal": checkInscpTotal,
  35323. "laboratoryCostTotal": laboratoryCostTotal,
  35324. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35325. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35326. "laboratorySelfTotal": laboratorySelfTotal,
  35327. "laboratoryInscpTotal": laboratoryInscpTotal,
  35328. "treatCostTotal": treatCostTotal,
  35329. "treatCostSelfTotal": treatCostSelfTotal,
  35330. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35331. "treatSelfTotal": treatSelfTotal,
  35332. "treatInscpTotal": treatInscpTotal,
  35333. "doctor_info": doctor_info,
  35334. "doctor_code": adminRole_two.DoctorCode,
  35335. "doctor_name": doctor_name,
  35336. "health_card_no": order.PsnNo,
  35337. "department": departments.Name,
  35338. "yiliao_leibie": yiliao_leibie,
  35339. "after_money": order.AccountPrice,
  35340. "patient": patient,
  35341. "org_name": miConfig.OrgName,
  35342. "org_code": miConfig.Code,
  35343. "order_number": order.Number,
  35344. "his_hospital": his_hospital,
  35345. "his": his,
  35346. "dia_config": dia_config,
  35347. "psn_cash_pay": order.PsnCashPay,
  35348. "zcCostTotal": zcCostTotal,
  35349. "zcCostSelfTotal": zcCostSelfTotal,
  35350. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35351. "zcSelfTotal": zcSelfTotal,
  35352. "zcInscpTotal": zcInscpTotal,
  35353. "huliCostTotal": huliCostTotal,
  35354. "huliCostSelfTotal": huliCostSelfTotal,
  35355. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35356. "huliSelfTotal": huliSelfTotal,
  35357. "huliInscpTotal": huliInscpTotal,
  35358. //"funds": rf,
  35359. //"check_order_info": cus_slice,
  35360. })
  35361. } else {
  35362. c.ServeSuccessJSON(map[string]interface{}{
  35363. "diagnosis": name,
  35364. "order_infos": orderInfos,
  35365. "number": order.MdtrtId,
  35366. "date": order.SettleAccountsDate,
  35367. "charge_admin": charge_admin,
  35368. "printor_admin": printor_admin,
  35369. "info": order,
  35370. "order": order,
  35371. "bedCostTotal": bedCostTotal,
  35372. "bedCostSelfTotal": bedCostSelfTotal,
  35373. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35374. "bedSelfTotal": bedSelfTotal,
  35375. "bedInscpTotal": bedInscpTotal,
  35376. "operationCostTotal": operationCostTotal,
  35377. "operationCostSelfTotal": operationCostSelfTotal,
  35378. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35379. "operationSelfTotal": operationSelfTotal,
  35380. "operationInscpTotal": operationInscpTotal,
  35381. "otherCostTotal": otherCostTotal,
  35382. "otherCostSelfTotal": otherCostSelfTotal,
  35383. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35384. "otherSelfTotal": otherSelfTotal,
  35385. "otherInscpTotal": otherInscpTotal,
  35386. "materialCostTotal": materialCostTotal,
  35387. "materialCostSelfTotal": materialCostSelfTotal,
  35388. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35389. "materialSelfTotal": materialSelfTotal,
  35390. "materialInscpTotal": materialInscpTotal,
  35391. "westernMedicineCostTotal": westernMedicineCostTotal,
  35392. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35393. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35394. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35395. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35396. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35397. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35398. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35399. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35400. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35401. "checkCostTotal": checkCostTotal,
  35402. "checkCostSelfTotal": checkCostSelfTotal,
  35403. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35404. "checkSelfTotal": checkSelfTotal,
  35405. "checkInscpTotal": checkInscpTotal,
  35406. "laboratoryCostTotal": laboratoryCostTotal,
  35407. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35408. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35409. "laboratorySelfTotal": laboratorySelfTotal,
  35410. "laboratoryInscpTotal": laboratoryInscpTotal,
  35411. "treatCostTotal": treatCostTotal,
  35412. "treatCostSelfTotal": treatCostSelfTotal,
  35413. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35414. "treatSelfTotal": treatSelfTotal,
  35415. "treatInscpTotal": treatInscpTotal,
  35416. "doctor_info": doctor_info,
  35417. "doctor_code": adminRole_two.DoctorCode,
  35418. "doctor_name": doctor_name,
  35419. "health_card_no": order.PsnNo,
  35420. "department": departments.Name,
  35421. "yiliao_leibie": yiliao_leibie,
  35422. "after_money": order.AccountPrice,
  35423. "patient": patient,
  35424. "org_name": miConfig.OrgName,
  35425. "org_code": miConfig.Code,
  35426. "order_number": order.Number,
  35427. "his_hospital": his_hospital,
  35428. "his": his,
  35429. "dia_config": dia_config,
  35430. "psn_cash_pay": order.PsnCashPay,
  35431. "zcCostTotal": zcCostTotal,
  35432. "zcCostSelfTotal": zcCostSelfTotal,
  35433. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35434. "zcSelfTotal": zcSelfTotal,
  35435. "zcInscpTotal": zcInscpTotal,
  35436. "huliCostTotal": huliCostTotal,
  35437. "huliCostSelfTotal": huliCostSelfTotal,
  35438. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35439. "huliSelfTotal": huliSelfTotal,
  35440. "huliInscpTotal": huliInscpTotal,
  35441. //"funds": rf,
  35442. //"check_order_info": cus_slice,
  35443. })
  35444. }
  35445. }
  35446. }
  35447. }
  35448. //func (c *HisApiController) CheckTreatment() {
  35449. // patient_id, _ := c.GetInt64("patient_id")
  35450. // id_card_no := c.GetString("id_card_no")
  35451. // insutype := c.GetString("insutype")
  35452. // med_type := c.GetString("med_type")
  35453. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35454. //
  35455. // adminUser := c.GetAdminUserInfo()
  35456. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35457. //
  35458. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35459. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35460. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35461. //
  35462. // if miConfig.MdtrtareaAdmvs == "421300" {
  35463. // var res ResultTwo
  35464. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35465. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35466. // "&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)
  35467. // resp, requestErr := http.Get(api)
  35468. // if requestErr != nil {
  35469. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35470. // return
  35471. // }
  35472. //
  35473. // body, ioErr := ioutil.ReadAll(resp.Body)
  35474. // if ioErr != nil {
  35475. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35477. // return
  35478. // }
  35479. // var respJSON map[string]interface{}
  35480. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35481. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35483. // return
  35484. // }
  35485. //
  35486. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35487. // result, _ := json.Marshal(respJSON)
  35488. //
  35489. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35490. // utils.ErrorLog("解析失败:%v", err)
  35491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35492. // return
  35493. // }
  35494. //
  35495. // if res.Infcode == 0 {
  35496. //
  35497. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35498. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35499. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35500. // resp, requestErr := http.Get(api)
  35501. // if requestErr != nil {
  35502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35503. // return
  35504. // }
  35505. //
  35506. // body, ioErr := ioutil.ReadAll(resp.Body)
  35507. // if ioErr != nil {
  35508. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35510. // return
  35511. // }
  35512. // var respJSON map[string]interface{}
  35513. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35514. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35516. // return
  35517. // }
  35518. // var res Result2001
  35519. //
  35520. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35521. // result2, _ := json.Marshal(respJSON)
  35522. //
  35523. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35524. // utils.ErrorLog("解析失败:%v", err)
  35525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35526. // return
  35527. // }
  35528. //
  35529. // if res.Infcode == 0 {
  35530. // c.ServeSuccessJSON(map[string]interface{}{
  35531. // "msg": res.Output.Trtinfo,
  35532. // })
  35533. // }
  35534. //
  35535. // } else {
  35536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35537. // return
  35538. // }
  35539. //
  35540. // } else {
  35541. //
  35542. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35543. // var dat map[string]interface{}
  35544. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35545. // fmt.Println(dat)
  35546. // } else {
  35547. // fmt.Println(err)
  35548. // }
  35549. // userJSONBytes, _ := json.Marshal(dat)
  35550. // var res ResultTwo
  35551. // var res10265 ResultTwo10265
  35552. // if miConfig.Code == "H15049901371" {
  35553. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35554. // utils.ErrorLog("解析失败:%v", err)
  35555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35556. // return
  35557. // }
  35558. // res.ErrMsg = res10265.ErrMsg
  35559. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35560. // res.Infcode = infocode
  35561. // res.Output = res10265.Output
  35562. // res.InfRefmsgid = res10265.InfRefmsgid
  35563. // } else {
  35564. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35565. // utils.ErrorLog("解析失败:%v", err)
  35566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35567. // return
  35568. // }
  35569. // }
  35570. //
  35571. // var user_name string
  35572. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35573. // if role.ID == 0 {
  35574. // user_name = "xxx"
  35575. // } else {
  35576. // user_name = role.UserName
  35577. // }
  35578. //
  35579. // baseParams := models.BaseParams{
  35580. // SecretKey: miConfig.SecretKey,
  35581. // FixmedinsCode: miConfig.Code,
  35582. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35583. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35584. // OrgName: miConfig.OrgName,
  35585. // Doctor: user_name,
  35586. // }
  35587. //
  35588. // if config.IsOpen == 1 {
  35589. // if miConfig.Code == "H15049901371" {
  35590. // if med_type == "14" {
  35591. // if insutype == "390" {
  35592. // med_type = "9933"
  35593. // } else if insutype == "310" {
  35594. // med_type = "990502"
  35595. // }
  35596. // } else if med_type == "11" {
  35597. // med_type = "11"
  35598. // }
  35599. // }
  35600. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35601. // var dat map[string]interface{}
  35602. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35603. // fmt.Println(dat)
  35604. // } else {
  35605. // fmt.Println(err)
  35606. // }
  35607. // var res Result2001
  35608. // var res10265 Result2001Org10265
  35609. // if miConfig.Code == "H15049901371" {
  35610. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35611. // utils.ErrorLog("解析失败:%v", err)
  35612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35613. // return
  35614. // }
  35615. // res.ErrMsg = res10265.ErrMsg
  35616. // res.Output = res10265.Output
  35617. // res.InfRefmsgid = res10265.InfRefmsgid
  35618. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35619. // res.Infcode = infocode
  35620. // } else {
  35621. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35622. // utils.ErrorLog("解析失败:%v", err)
  35623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35624. // return
  35625. // }
  35626. // }
  35627. // if res.Infcode == 0 {
  35628. // c.ServeSuccessJSON(map[string]interface{}{
  35629. // "msg": res.Output.Trtinfo,
  35630. // })
  35631. // }
  35632. // }
  35633. // }
  35634. //}
  35635. //func (c *HisApiController) PutRecord() {
  35636. // id, _ := c.GetInt64("id")
  35637. // record_time := c.GetString("record_time")
  35638. // timeLayout := "2006-01-02"
  35639. // loc, _ := time.LoadLocation("Local")
  35640. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35641. // if err != nil {
  35642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35643. // return
  35644. // }
  35645. // recordDateTime := theTime.Unix()
  35646. //
  35647. // adminInfo := c.GetAdminUserInfo()
  35648. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35649. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35650. //
  35651. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35652. //
  35653. // fmt.Println(miConfig.SecretKey)
  35654. //
  35655. // if patient == nil {
  35656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35657. // return
  35658. // }
  35659. // if len(patient.IdCardNo) == 0 {
  35660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35661. // return
  35662. // }
  35663. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35664. // if config.IsOpen == 1 {
  35665. // 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
  35666. // resp, requestErr := http.Get(api)
  35667. // if requestErr != nil {
  35668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35669. // return
  35670. // }
  35671. // defer resp.Body.Close()
  35672. // body, ioErr := ioutil.ReadAll(resp.Body)
  35673. // if ioErr != nil {
  35674. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35676. // return
  35677. // }
  35678. // var respJSON map[string]interface{}
  35679. //
  35680. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35681. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35682. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35683. // return
  35684. // }
  35685. //
  35686. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35687. // userJSONBytes, _ := json.Marshal(userJSON)
  35688. // var res ResultTwo
  35689. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35690. // utils.ErrorLog("解析失败:%v", err)
  35691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35692. // return
  35693. // }
  35694. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35695. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35696. // infoStr := string(Iinfos)
  35697. // idetinfoStr := string(Idetinfos)
  35698. //
  35699. // if res.Infcode == 0 {
  35700. // his := models.VMHisPatient{
  35701. // Status: 1,
  35702. // Ctime: time.Now().Unix(),
  35703. // Mtime: time.Now().Unix(),
  35704. // PsnNo: res.Output.Baseinfo.PsnNo,
  35705. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35706. // Certno: res.Output.Baseinfo.Certno,
  35707. // PsnName: res.Output.Baseinfo.PsnName,
  35708. // Gend: res.Output.Baseinfo.Gend,
  35709. // Naty: res.Output.Baseinfo.Naty,
  35710. // Brdy: res.Output.Baseinfo.Brdy,
  35711. // Age: res.Output.Baseinfo.Age,
  35712. // Iinfo: infoStr,
  35713. // Idetinfo: idetinfoStr,
  35714. // PatientId: patient.ID,
  35715. // RecordDate: theTime.Unix(),
  35716. // UserOrgId: adminInfo.CurrentOrgId,
  35717. // AdminUserId: adminInfo.AdminUser.Id,
  35718. // IsReturn: 1,
  35719. // }
  35720. //
  35721. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35722. // //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")
  35723. // //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")
  35724. //
  35725. // //var dat map[string]interface{}
  35726. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35727. // // fmt.Println(dat)
  35728. // //} else {
  35729. // // fmt.Println(err)
  35730. // //}
  35731. //
  35732. // var dat2 map[string]interface{}
  35733. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35734. // fmt.Println(dat2)
  35735. // } else {
  35736. // fmt.Println(err)
  35737. // }
  35738. //
  35739. // } else {
  35740. // adminUser := c.GetAdminUserInfo()
  35741. // errlog := &models.HisOrderError{
  35742. // UserOrgId: adminUser.CurrentOrgId,
  35743. // Ctime: time.Now().Unix(),
  35744. // Mtime: time.Now().Unix(),
  35745. // ErrMsg: res.ErrMsg,
  35746. // Status: 1,
  35747. // PatientId: id,
  35748. // RecordTime: recordDateTime,
  35749. // Stage: 1,
  35750. // }
  35751. // service.CreateErrMsgLog(errlog)
  35752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35753. // return
  35754. // }
  35755. // }
  35756. //
  35757. //}
  35758. //func (c *HisApiController) GetUploadDiag() {
  35759. // id, _ := c.GetInt64("id")
  35760. // record_time := c.GetString("record_time")
  35761. //
  35762. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35763. // sick_type, _ := c.GetInt64("sick_type")
  35764. // reg_type, _ := c.GetInt64("reg_type")
  35765. //
  35766. // timeLayout := "2006-01-02"
  35767. // loc, _ := time.LoadLocation("Local")
  35768. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35769. // if err != nil {
  35770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35771. // return
  35772. // }
  35773. //
  35774. // var patientPrescription models.HisPrescriptionInfo
  35775. // recordDateTime := theTime.Unix()
  35776. // adminInfo := c.GetAdminUserInfo()
  35777. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35778. //
  35779. // if patientPrescription.ID == 0 {
  35780. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35781. // }
  35782. //
  35783. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35784. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35785. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35786. // sickConfig, _ := service.FindSickById(sick_type)
  35787. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35788. //
  35789. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35790. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35791. // "&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 +
  35792. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35793. // resp2, requestErr2 := http.Get(api2)
  35794. // if requestErr2 != nil {
  35795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35796. // return
  35797. // }
  35798. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35799. // if ioErr2 != nil {
  35800. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35801. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35802. // return
  35803. // }
  35804. // var respJSON2 map[string]interface{}
  35805. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35806. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35808. // return
  35809. // }
  35810. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35811. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35812. //
  35813. // var res2 ResultSix
  35814. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35815. // utils.ErrorLog("解析失败:%v", err)
  35816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35817. // return
  35818. // }
  35819. // if res2.Infcode != 0 {
  35820. // adminUser := c.GetAdminUserInfo()
  35821. // errlog := &models.HisOrderError{
  35822. // UserOrgId: adminUser.CurrentOrgId,
  35823. // Ctime: time.Now().Unix(),
  35824. // Mtime: time.Now().Unix(),
  35825. // ErrMsg: res2.ErrMsg,
  35826. // Status: 1,
  35827. // PatientId: id,
  35828. // RecordTime: recordDateTime,
  35829. // Stage: 3,
  35830. // }
  35831. // service.CreateErrMsgLog(errlog)
  35832. //
  35833. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35834. // return
  35835. // }
  35836. //
  35837. // c.ServeSuccessJSON(map[string]interface{}{
  35838. // "msg": "上传成功",
  35839. // })
  35840. //
  35841. //}
  35842. type QueryResult struct {
  35843. ID int64
  35844. Name string
  35845. Code string
  35846. List_type_code string
  35847. }
  35848. func (c *HisApiController) GetCheckCode() {
  35849. ids_str := c.GetString("ids")
  35850. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35851. ids_arr := strings.Split(ids_str, ",")
  35852. var queryResult []QueryResult
  35853. ids := make([]int64, 0)
  35854. for _, item := range ids_arr {
  35855. id, _ := strconv.ParseInt(item, 10, 64)
  35856. ids = append(ids, id)
  35857. }
  35858. if record_type == 1 {
  35859. drugs, _ := service.GetBatchDrugList(ids)
  35860. for _, item := range drugs {
  35861. result := QueryResult{
  35862. ID: item.ID,
  35863. Name: item.DrugName,
  35864. Code: item.MedicalInsuranceNumber,
  35865. List_type_code: "101",
  35866. }
  35867. queryResult = append(queryResult, result)
  35868. }
  35869. } else if record_type == 2 {
  35870. goods, _ := service.GetBatchGoodInformationList(ids)
  35871. fmt.Println(goods)
  35872. for _, item := range goods {
  35873. result := QueryResult{
  35874. ID: item.ID,
  35875. Name: item.GoodName,
  35876. Code: item.SocialSecurityDirectoryCode,
  35877. List_type_code: "301",
  35878. }
  35879. queryResult = append(queryResult, result)
  35880. }
  35881. } else if record_type == 3 {
  35882. projects, _ := service.GetBathchMyPorjecgList(ids)
  35883. for _, item := range projects {
  35884. result := QueryResult{
  35885. ID: item.ID,
  35886. Name: item.ProjectName,
  35887. Code: item.MedicalCode,
  35888. List_type_code: "201",
  35889. }
  35890. queryResult = append(queryResult, result)
  35891. }
  35892. }
  35893. admin_user_id, _ := c.GetInt64("admin_user_id")
  35894. adminUser := c.GetAdminUserInfo()
  35895. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35896. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35897. var user_name string
  35898. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35899. if role.ID == 0 {
  35900. user_name = "管理员"
  35901. } else {
  35902. user_name = role.UserName
  35903. }
  35904. baseParams := models.BaseParams{
  35905. SecretKey: miConfig.SecretKey,
  35906. FixmedinsCode: miConfig.Code,
  35907. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35908. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35909. OrgName: miConfig.OrgName,
  35910. Doctor: user_name,
  35911. }
  35912. var result string
  35913. if miConfig.MdtrtareaAdmvs == "430800" {
  35914. for _, item := range queryResult {
  35915. if record_type == 1 {
  35916. 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)
  35917. } else if record_type == 2 {
  35918. fmt.Println(item.Code)
  35919. 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)
  35920. } else if record_type == 3 {
  35921. 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)
  35922. }
  35923. var dat map[string]interface{}
  35924. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35925. fmt.Println(dat)
  35926. } else {
  35927. fmt.Println(err)
  35928. }
  35929. userJSONBytes, _ := json.Marshal(dat)
  35930. var res ResultSix
  35931. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35932. utils.ErrorLog("解析失败:%v", err)
  35933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35934. return
  35935. }
  35936. if res.Infcode == 0 {
  35937. if record_type == 1 {
  35938. service.UpdateBaseDrugById(item.ID)
  35939. } else if record_type == 2 {
  35940. service.UpdateGoodInformaitonByDetail(item.ID)
  35941. } else if record_type == 3 {
  35942. service.UpdateProjectById(item.ID)
  35943. }
  35944. c.ServeSuccessJSON(map[string]interface{}{
  35945. "failed_code": 0,
  35946. "msg": "目录对照成功",
  35947. })
  35948. } else {
  35949. c.ServeSuccessJSON(map[string]interface{}{
  35950. "failed_code": -10,
  35951. "msg": res.ErrMsg,
  35952. })
  35953. }
  35954. }
  35955. } else {
  35956. for _, item := range queryResult {
  35957. var result string
  35958. if record_type == 1 {
  35959. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35960. } else if record_type == 2 {
  35961. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35962. } else if record_type == 3 {
  35963. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35964. }
  35965. var dat map[string]interface{}
  35966. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35967. fmt.Println(dat)
  35968. } else {
  35969. fmt.Println(err)
  35970. }
  35971. userJSONBytes, _ := json.Marshal(dat)
  35972. var res ResultSix
  35973. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35974. utils.ErrorLog("解析失败:%v", err)
  35975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35976. return
  35977. }
  35978. if res.Infcode == 0 {
  35979. if record_type == 1 {
  35980. service.UpdateBaseDrugById(item.ID)
  35981. } else if record_type == 2 {
  35982. service.UpdateGoodInformaitonByDetail(item.ID)
  35983. } else if record_type == 3 {
  35984. service.UpdateProjectById(item.ID)
  35985. }
  35986. c.ServeSuccessJSON(map[string]interface{}{
  35987. "failed_code": 0,
  35988. "msg": "目录对照成功",
  35989. })
  35990. } else {
  35991. c.ServeSuccessJSON(map[string]interface{}{
  35992. "failed_code": -10,
  35993. "msg": res.ErrMsg,
  35994. })
  35995. }
  35996. }
  35997. }
  35998. }
  35999. func (c *HisApiController) UnCheckCode() {
  36000. ids_str := c.GetString("ids")
  36001. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36002. admin_user_id, _ := c.GetInt64("admin_user_id")
  36003. ids_arr := strings.Split(ids_str, ",")
  36004. var queryResult []QueryResult
  36005. ids := make([]int64, 0)
  36006. for _, item := range ids_arr {
  36007. id, _ := strconv.ParseInt(item, 10, 64)
  36008. ids = append(ids, id)
  36009. }
  36010. if record_type == 1 {
  36011. drugs, _ := service.GetBatchDrugList(ids)
  36012. for _, item := range drugs {
  36013. result := QueryResult{
  36014. ID: item.ID,
  36015. Name: item.DrugName,
  36016. Code: item.MedicalInsuranceNumber,
  36017. List_type_code: "101",
  36018. }
  36019. queryResult = append(queryResult, result)
  36020. }
  36021. } else if record_type == 2 {
  36022. goods, _ := service.GetBatchGoodInformationList(ids)
  36023. for _, item := range goods {
  36024. result := QueryResult{
  36025. ID: item.ID,
  36026. Name: item.GoodName,
  36027. Code: item.SocialSecurityDirectoryCode,
  36028. List_type_code: "301",
  36029. }
  36030. queryResult = append(queryResult, result)
  36031. }
  36032. } else if record_type == 3 {
  36033. projects, _ := service.GetBathchMyPorjecgList(ids)
  36034. for _, item := range projects {
  36035. result := QueryResult{
  36036. ID: item.ID,
  36037. Name: item.ProjectName,
  36038. Code: item.MedicalCode,
  36039. List_type_code: "201",
  36040. }
  36041. queryResult = append(queryResult, result)
  36042. }
  36043. }
  36044. adminUser := c.GetAdminUserInfo()
  36045. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36046. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36047. var user_name string
  36048. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36049. if role.ID == 0 {
  36050. user_name = "xxx"
  36051. } else {
  36052. user_name = role.UserName
  36053. }
  36054. baseParams := &models.BaseParams{
  36055. SecretKey: miConfig.SecretKey,
  36056. FixmedinsCode: miConfig.Code,
  36057. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36058. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36059. OrgName: miConfig.OrgName,
  36060. Doctor: user_name,
  36061. }
  36062. if config.IsOpen == 1 {
  36063. if miConfig.MdtrtareaAdmvs == "430800" {
  36064. for _, item := range queryResult {
  36065. var result string
  36066. if record_type == 1 {
  36067. 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)
  36068. } else if record_type == 2 {
  36069. fmt.Println(item.Code)
  36070. 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)
  36071. } else if record_type == 3 {
  36072. 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)
  36073. }
  36074. var dat map[string]interface{}
  36075. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36076. fmt.Println(dat)
  36077. } else {
  36078. fmt.Println(err)
  36079. }
  36080. userJSONBytes, _ := json.Marshal(dat)
  36081. var res ResultSix
  36082. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36083. utils.ErrorLog("解析失败:%v", err)
  36084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36085. return
  36086. }
  36087. if res.Infcode == 0 {
  36088. if record_type == 1 {
  36089. service.UpdateBaseDrugById(item.ID)
  36090. } else if record_type == 2 {
  36091. service.UpdateGoodInformaitonByDetail(item.ID)
  36092. } else if record_type == 3 {
  36093. service.UpdateProjectById(item.ID)
  36094. }
  36095. c.ServeSuccessJSON(map[string]interface{}{
  36096. "failed_code": 0,
  36097. "msg": "目录对照成功",
  36098. })
  36099. } else {
  36100. c.ServeSuccessJSON(map[string]interface{}{
  36101. "failed_code": -10,
  36102. "msg": res.ErrMsg,
  36103. })
  36104. }
  36105. }
  36106. } else {
  36107. for _, item := range queryResult {
  36108. var result string
  36109. if record_type == 1 {
  36110. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36111. } else if record_type == 2 {
  36112. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36113. } else if record_type == 3 {
  36114. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36115. }
  36116. var dat2 map[string]interface{}
  36117. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36118. fmt.Println(dat2)
  36119. } else {
  36120. fmt.Println(err)
  36121. }
  36122. userJSONBytes, _ := json.Marshal(dat2)
  36123. var res ResultSix
  36124. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36125. utils.ErrorLog("解析失败:%v", err)
  36126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36127. return
  36128. }
  36129. if res.Infcode == 0 {
  36130. if record_type == 1 {
  36131. service.UpdateDrugByIdDetail(item.ID)
  36132. } else if record_type == 2 {
  36133. service.UpdateGoodInfoById(item.ID)
  36134. } else if record_type == 3 {
  36135. service.UpdateMyProjectById(item.ID)
  36136. }
  36137. c.ServeSuccessJSON(map[string]interface{}{
  36138. "failed_code": 0,
  36139. "msg": "撤销目录对照成功",
  36140. })
  36141. } else {
  36142. c.ServeSuccessJSON(map[string]interface{}{
  36143. "failed_code": -10,
  36144. "msg": res.ErrMsg,
  36145. })
  36146. }
  36147. }
  36148. }
  36149. }
  36150. }
  36151. func (c *HisApiController) GetPatientInfo() {
  36152. id_card_no := c.GetString("id_card_no")
  36153. admin_user_id, _ := c.GetInt64("admin_user_id")
  36154. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36155. if patient.ID == 0 {
  36156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36157. return
  36158. }
  36159. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36160. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36161. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36162. var res ResultTwo
  36163. var res10265 ResultTwo10265
  36164. if config.IsOpen == 1 {
  36165. if miConfig.MdtrtareaAdmvs == "150499" {
  36166. //请求内网数据
  36167. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36168. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36169. "&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
  36170. resp, requestErr := http.Get(api)
  36171. if requestErr != nil {
  36172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36173. return
  36174. }
  36175. body, ioErr := ioutil.ReadAll(resp.Body)
  36176. if ioErr != nil {
  36177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36179. return
  36180. }
  36181. var respJSON map[string]interface{}
  36182. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36185. return
  36186. }
  36187. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36188. result_byte, _ := json.Marshal(respJSON)
  36189. result := string(result_byte)
  36190. var dat map[string]interface{}
  36191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36192. fmt.Println(dat)
  36193. } else {
  36194. fmt.Println(err)
  36195. }
  36196. userJSONBytes, _ := json.Marshal(dat)
  36197. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36198. utils.ErrorLog("解析失败:%v", err)
  36199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36200. return
  36201. }
  36202. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36203. res.Infcode = Infcode
  36204. res.ErrMsg = res10265.ErrMsg
  36205. res.Output = res10265.Output
  36206. res.InfRefmsgid = res10265.InfRefmsgid
  36207. res.RespondTime = res10265.RespondTime
  36208. res.WarnInfo = res10265.WarnInfo
  36209. } else {
  36210. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36211. var dat map[string]interface{}
  36212. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36213. fmt.Println(dat)
  36214. } else {
  36215. fmt.Println(err)
  36216. }
  36217. userJSONBytes, _ := json.Marshal(dat)
  36218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36219. utils.ErrorLog("解析失败:%v", err)
  36220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36221. return
  36222. }
  36223. }
  36224. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36225. // utils.ErrorLog("解析失败:%v", err)
  36226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36227. // return
  36228. //}
  36229. for index, item := range res.Output.Iinfo {
  36230. if item.PsnInsuStas == "2" {
  36231. fmt.Println("--------")
  36232. res.Output.Iinfo[index].Insutype = "300"
  36233. res.Output.Iinfo[index].PsnInsuStas = "1"
  36234. }
  36235. }
  36236. fmt.Println(res.Output.Iinfo)
  36237. if res.Infcode != 0 {
  36238. c.ServeSuccessJSON(map[string]interface{}{
  36239. "failed_code": -10,
  36240. "msg": res.ErrMsg,
  36241. })
  36242. } else {
  36243. c.ServeSuccessJSON(map[string]interface{}{
  36244. "failed_code": 0,
  36245. "info": res,
  36246. })
  36247. }
  36248. }
  36249. }
  36250. func (c *HisApiController) PsnPutOnRecord() {
  36251. record_type, _ := c.GetInt64("type")
  36252. patient_id, _ := c.GetInt64("patient_id")
  36253. admin_user_id, _ := c.GetInt64("admin_user_id")
  36254. start_time := c.GetString("start_time")
  36255. end_time := c.GetString("end_time")
  36256. adminUser := c.GetAdminUserInfo()
  36257. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36258. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36259. var patients []*models.Patients
  36260. if record_type == 1 { //全部备案
  36261. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36262. patients = append(patients, patient...)
  36263. } else { //单个备案
  36264. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36265. patients = append(patients, patient)
  36266. }
  36267. var user_name string
  36268. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36269. if role.ID == 0 {
  36270. user_name = "xxx"
  36271. } else {
  36272. user_name = role.UserName
  36273. }
  36274. if config.IsOpen == 1 {
  36275. for _, item := range patients {
  36276. 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
  36277. resp, requestErr := http.Get(api)
  36278. if requestErr != nil {
  36279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36280. return
  36281. }
  36282. defer resp.Body.Close()
  36283. body, ioErr := ioutil.ReadAll(resp.Body)
  36284. if ioErr != nil {
  36285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36287. return
  36288. }
  36289. var respJSON map[string]interface{}
  36290. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36293. return
  36294. }
  36295. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36296. userJSONBytes, _ := json.Marshal(userJSON)
  36297. var res ResultTwo
  36298. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36299. utils.ErrorLog("解析失败:%v", err)
  36300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36301. return
  36302. }
  36303. if res.Infcode == 0 {
  36304. 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)
  36305. var dat map[string]interface{}
  36306. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36307. fmt.Println(dat)
  36308. } else {
  36309. fmt.Println(err)
  36310. }
  36311. userJSONBytes, _ := json.Marshal(dat)
  36312. var res2 ResultThirteen
  36313. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36314. utils.ErrorLog("解析失败:%v", err)
  36315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36316. return
  36317. }
  36318. if res2.Infcode == 0 {
  36319. psnResult := &models.GdybPsnRecord{
  36320. UserOrgId: adminUser.CurrentOrgId,
  36321. PatientId: item.ID,
  36322. PsnNo: res.Output.Baseinfo.PsnNo,
  36323. Ctime: time.Now().Unix(),
  36324. Mtime: time.Now().Unix(),
  36325. Status: 1,
  36326. IsCancel: 1,
  36327. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36328. }
  36329. service.CreatePsnRecord(psnResult)
  36330. } else {
  36331. c.ServeSuccessJSON(map[string]interface{}{
  36332. "failed_code": -10,
  36333. "msg": res2.ErrMsg,
  36334. })
  36335. return
  36336. }
  36337. }
  36338. }
  36339. }
  36340. }
  36341. func (c *HisApiController) PsnUnPutOnRecord() {
  36342. id, _ := c.GetInt64("id")
  36343. //record_type, _ := c.GetInt64("type")
  36344. admin_user_id, _ := c.GetInt64("admin_user_id")
  36345. adminUser := c.GetAdminUserInfo()
  36346. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36347. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36348. var user_name string
  36349. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36350. if role.ID == 0 {
  36351. user_name = "xxx"
  36352. } else {
  36353. user_name = role.UserName
  36354. }
  36355. psn_record, _ := service.GetPsnRecordById(id)
  36356. if psn_record.ID == 0 {
  36357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36358. return
  36359. }
  36360. if config.IsOpen == 1 {
  36361. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36362. var dat map[string]interface{}
  36363. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36364. fmt.Println(dat)
  36365. } else {
  36366. fmt.Println(err)
  36367. }
  36368. userJSONBytes, _ := json.Marshal(dat)
  36369. var res ResultFourteen
  36370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36371. utils.ErrorLog("解析失败:%v", err)
  36372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36373. return
  36374. }
  36375. if res.Infcode == 0 {
  36376. psn_record.IsCancel = 2
  36377. service.CreatePsnRecord(&psn_record)
  36378. } else {
  36379. c.ServeSuccessJSON(map[string]interface{}{
  36380. "failed_code": -10,
  36381. "msg": res.ErrMsg,
  36382. })
  36383. return
  36384. }
  36385. }
  36386. }
  36387. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36388. patient_id, _ := c.GetInt64("patient_id")
  36389. insutype_two := c.GetString("insutype")
  36390. psn_no := c.GetString("psn_no")
  36391. doctor_id, _ := c.GetInt64("doctor_id")
  36392. sick_id, _ := c.GetInt64("sick_id")
  36393. department_id, _ := c.GetInt64("department_id")
  36394. start_time := c.GetString("start_time")
  36395. end_time := c.GetString("end_time")
  36396. check_time := c.GetString("check_time")
  36397. hospital_code := c.GetString("hospital_code")
  36398. hospital_name := c.GetString("hospital_name")
  36399. adminUser := c.GetAdminUserInfo()
  36400. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36401. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36402. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36403. sick, _ := service.FindSickById(sick_id)
  36404. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36405. if len(hospital_code) == 0 {
  36406. hospital_code = miConfig.Code
  36407. }
  36408. if len(hospital_name) == 0 {
  36409. hospital_name = miConfig.OrgName
  36410. }
  36411. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36412. var res ResultTwo
  36413. var res10265 ResultTwo10265
  36414. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36415. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36416. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36417. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36418. "&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
  36419. resp, requestErr := http.Get(api)
  36420. if requestErr != nil {
  36421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36422. return
  36423. }
  36424. body, ioErr := ioutil.ReadAll(resp.Body)
  36425. if ioErr != nil {
  36426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36428. return
  36429. }
  36430. var respJSON map[string]interface{}
  36431. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36434. return
  36435. }
  36436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36437. result, _ := json.Marshal(respJSON)
  36438. fmt.Println("log")
  36439. fmt.Println(string(result))
  36440. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36441. utils.ErrorLog("解析失败:%v", err)
  36442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36443. return
  36444. }
  36445. res.ErrMsg = res10265.ErrMsg
  36446. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36447. res.Infcode = infocode
  36448. res.Output = res10265.Output
  36449. res.InfRefmsgid = res10265.InfRefmsgid
  36450. } else {
  36451. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36452. if miConfig.Code == "H15049901371" {
  36453. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36454. utils.ErrorLog("解析失败:%v", err)
  36455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36456. return
  36457. }
  36458. res.ErrMsg = res10265.ErrMsg
  36459. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36460. res.Infcode = infocode
  36461. res.Output = res10265.Output
  36462. res.InfRefmsgid = res10265.InfRefmsgid
  36463. } else {
  36464. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36465. utils.ErrorLog("解析失败:%v", err)
  36466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36467. return
  36468. }
  36469. }
  36470. }
  36471. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36472. infoStr := string(Iinfos)
  36473. var rf []*ResultFive
  36474. json.Unmarshal([]byte(infoStr), &rf)
  36475. var insuplc_admdvs string
  36476. var insutype string
  36477. var is390 int = 0
  36478. var is310 int = 0
  36479. var insutypes []*ResultFive
  36480. for _, item := range rf {
  36481. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36482. insutypes = append(insutypes, item)
  36483. }
  36484. }
  36485. if len(insutypes) == 1 {
  36486. insutype = insutypes[0].Insutype
  36487. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36488. } else {
  36489. for _, i := range insutypes {
  36490. if i.Insutype == "390" {
  36491. is390 = 1
  36492. }
  36493. if i.Insutype == "310" {
  36494. is310 = 1
  36495. }
  36496. }
  36497. }
  36498. if is390 == 1 {
  36499. insutype = "390"
  36500. }
  36501. if is310 == 1 {
  36502. insutype = "310"
  36503. }
  36504. if len(insutypes) == 2 {
  36505. insutype = insutype_two
  36506. }
  36507. if len(insutypes) == 0 {
  36508. insutype = "310"
  36509. }
  36510. insutype = insutype_two
  36511. fmt.Println(insutype)
  36512. for _, item := range rf {
  36513. fmt.Println(item.Insutype)
  36514. fmt.Println(insutype)
  36515. if item.Insutype == insutype {
  36516. fmt.Println(item.Insutype)
  36517. fmt.Println(insutype)
  36518. insuplc_admdvs = item.InsuplcAdmdvs
  36519. }
  36520. }
  36521. fmt.Println(insuplc_admdvs)
  36522. var res2 ResultThirteen
  36523. var res10265_2 ResultThirteen10265
  36524. if config.IsOpen == 1 {
  36525. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36526. } else {
  36527. if miConfig.MdtrtareaAdmvs == "150499" {
  36528. //
  36529. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36530. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36531. // "&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
  36532. //resp, requestErr := http.Get(api)
  36533. //if requestErr != nil {
  36534. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36535. // return
  36536. //}
  36537. //
  36538. //body, ioErr := ioutil.ReadAll(resp.Body)
  36539. //if ioErr != nil {
  36540. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36541. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36542. // return
  36543. //}
  36544. //var respJSON map[string]interface{}
  36545. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36546. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36548. // return
  36549. //}
  36550. //
  36551. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36552. //result, _ := json.Marshal(respJSON)
  36553. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36554. // utils.ErrorLog("解析失败:%v", err)
  36555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36556. // return
  36557. //}
  36558. //infocode = resThree.Infcode
  36559. //result, _ := json.Marshal(respJSON)
  36560. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36561. // utils.ErrorLog("解析失败:%v", err)
  36562. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36563. // return
  36564. //}
  36565. //
  36566. //resThree.ErrMsg = resThree10265.ErrMsg
  36567. //
  36568. //resThree.Output = resThree10265.Output
  36569. //
  36570. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36571. //
  36572. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36573. //
  36574. } else {
  36575. 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)
  36576. var dat map[string]interface{}
  36577. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36578. fmt.Println(dat)
  36579. } else {
  36580. fmt.Println(err)
  36581. }
  36582. userJSONBytes, _ := json.Marshal(dat)
  36583. if miConfig.Code == "H15049901371" {
  36584. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36585. utils.ErrorLog("解析失败:%v", err)
  36586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36587. return
  36588. }
  36589. res2.ErrMsg = res10265_2.ErrMsg
  36590. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36591. res2.Infcode = infocode
  36592. res2.Output = res10265_2.Output
  36593. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36594. } else {
  36595. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36596. utils.ErrorLog("解析失败:%v", err)
  36597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36598. return
  36599. }
  36600. }
  36601. }
  36602. }
  36603. if res2.Infcode == 0 {
  36604. psnResult := &models.GdybPsnNcdsRecord{
  36605. UserOrgId: adminUser.CurrentOrgId,
  36606. PatientId: patient.ID,
  36607. PsnNo: psn_no,
  36608. DoctorId: doctor.AdminUserId,
  36609. DepartmentId: department_id,
  36610. SickType: sick_id,
  36611. Insutype: insutype,
  36612. Ctime: time.Now().Unix(),
  36613. Mtime: time.Now().Unix(),
  36614. Status: 1,
  36615. IsCancel: 1,
  36616. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36617. }
  36618. service.CreatePsnNCDSRecord(psnResult)
  36619. c.ServeSuccessJSON(map[string]interface{}{
  36620. "failed_code": 0,
  36621. "msg": "备案成功",
  36622. "result": psnResult,
  36623. })
  36624. } else {
  36625. c.ServeSuccessJSON(map[string]interface{}{
  36626. "failed_code": -10,
  36627. "msg": res2.ErrMsg,
  36628. })
  36629. return
  36630. }
  36631. }
  36632. }
  36633. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36634. id, _ := c.GetInt64("id")
  36635. admin_user_id, _ := c.GetInt64("admin_user_id")
  36636. adminUser := c.GetAdminUserInfo()
  36637. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36638. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36639. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36640. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36641. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36642. //var user_name string
  36643. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36644. //if role.ID == 0 {
  36645. // user_name = "xxx"
  36646. //} else {
  36647. // user_name = role.UserName
  36648. //}
  36649. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36650. if psn_record.ID == 0 {
  36651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36652. return
  36653. }
  36654. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36655. var res ResultTwo
  36656. var res10265 ResultTwo10265
  36657. if miConfig.Code == "H15049901371" {
  36658. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36659. utils.ErrorLog("解析失败:%v", err)
  36660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36661. return
  36662. }
  36663. res.ErrMsg = res10265.ErrMsg
  36664. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36665. res.Infcode = infocode
  36666. res.Output = res10265.Output
  36667. res.InfRefmsgid = res10265.InfRefmsgid
  36668. } else {
  36669. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36670. utils.ErrorLog("解析失败:%v", err)
  36671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36672. return
  36673. }
  36674. }
  36675. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36676. infoStr := string(Iinfos)
  36677. var rf []*ResultFive
  36678. json.Unmarshal([]byte(infoStr), &rf)
  36679. var insuplc_admdvs string
  36680. var insutype string
  36681. var is390 int = 0
  36682. var is310 int = 0
  36683. var insutypes []*ResultFive
  36684. for _, item := range rf {
  36685. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36686. insutypes = append(insutypes, item)
  36687. }
  36688. }
  36689. if len(insutypes) == 1 {
  36690. insutype = insutypes[0].Insutype
  36691. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36692. } else {
  36693. for _, i := range insutypes {
  36694. if i.Insutype == "390" {
  36695. is390 = 1
  36696. }
  36697. if i.Insutype == "310" {
  36698. is310 = 1
  36699. }
  36700. }
  36701. }
  36702. if is390 == 1 {
  36703. insutype = "390"
  36704. }
  36705. if is310 == 1 {
  36706. insutype = "310"
  36707. }
  36708. if len(insutypes) == 0 {
  36709. insutype = "310"
  36710. }
  36711. insutype = psn_record.Insutype
  36712. for _, item := range rf {
  36713. if item.Insutype == insutype {
  36714. insuplc_admdvs = item.InsuplcAdmdvs
  36715. }
  36716. }
  36717. if config.IsOpen == 1 {
  36718. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36719. var dat map[string]interface{}
  36720. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36721. fmt.Println(dat)
  36722. } else {
  36723. fmt.Println(err)
  36724. }
  36725. userJSONBytes, _ := json.Marshal(dat)
  36726. var res ResultFourteen
  36727. var res10265 ResultFourteen10265
  36728. if miConfig.Code == "H15049901371" {
  36729. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36730. utils.ErrorLog("解析失败:%v", err)
  36731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36732. return
  36733. }
  36734. res.ErrMsg = res10265.ErrMsg
  36735. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36736. res.Infcode = infocode
  36737. res.Output = res10265.Output
  36738. res.InfRefmsgid = res10265.InfRefmsgid
  36739. } else {
  36740. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36741. utils.ErrorLog("解析失败:%v", err)
  36742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36743. return
  36744. }
  36745. }
  36746. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36747. // utils.ErrorLog("解析失败:%v", err)
  36748. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36749. // return
  36750. //}
  36751. if res.Infcode == 0 {
  36752. psn_record.IsCancel = 2
  36753. service.CreatePsnNCDSRecord(&psn_record)
  36754. c.ServeSuccessJSON(map[string]interface{}{
  36755. "failed_code": 0,
  36756. "msg": "撤销备案成功",
  36757. })
  36758. } else {
  36759. c.ServeSuccessJSON(map[string]interface{}{
  36760. "failed_code": -10,
  36761. "msg": res.ErrMsg,
  36762. })
  36763. return
  36764. }
  36765. }
  36766. }
  36767. func (c *HisApiController) TestTest() {
  36768. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36769. fmt.Println(patient.Iinfo)
  36770. }
  36771. type CustomData struct {
  36772. MsgId string
  36773. PsnNo string
  36774. Info string
  36775. }
  36776. func (c *HisApiController) ReversalData() {
  36777. var customData []*CustomData
  36778. custom := &CustomData{
  36779. MsgId: "H44022900158202103301714472004",
  36780. PsnNo: "44020000001101329945",
  36781. Info: "2207",
  36782. }
  36783. customData = append(customData, custom)
  36784. custom1 := &CustomData{
  36785. MsgId: "H4402290015820210330172057803",
  36786. PsnNo: "44020000001101161813",
  36787. Info: "2207",
  36788. }
  36789. customData = append(customData, custom1)
  36790. custom2 := &CustomData{
  36791. MsgId: "H44022900158202103301705198813",
  36792. PsnNo: "44190000133097375417",
  36793. Info: "2207",
  36794. }
  36795. customData = append(customData, custom2)
  36796. custom3 := &CustomData{
  36797. MsgId: "H44022900158202103301715524756",
  36798. PsnNo: "44020000001100187221",
  36799. Info: "2207",
  36800. }
  36801. customData = append(customData, custom3)
  36802. custom4 := &CustomData{
  36803. MsgId: "H44022900158202103301730376224",
  36804. PsnNo: "44020000001101959155",
  36805. Info: "2207",
  36806. }
  36807. customData = append(customData, custom4)
  36808. custom5 := &CustomData{
  36809. MsgId: "H44022900158202103301748008725",
  36810. PsnNo: "44020000001104246641",
  36811. Info: "2207",
  36812. }
  36813. customData = append(customData, custom5)
  36814. custom6 := &CustomData{
  36815. MsgId: "H44022900158202103301718096755",
  36816. PsnNo: "44020000001102211860",
  36817. Info: "2207",
  36818. }
  36819. customData = append(customData, custom6)
  36820. custom7 := &CustomData{
  36821. MsgId: "H44022900158202103301736551640",
  36822. PsnNo: "44020000001102687718",
  36823. Info: "2207",
  36824. }
  36825. customData = append(customData, custom7)
  36826. custom8 := &CustomData{
  36827. MsgId: "H44022900158202103301743097676",
  36828. PsnNo: "44020000001102127785",
  36829. Info: "2207",
  36830. }
  36831. customData = append(customData, custom8)
  36832. custom9 := &CustomData{
  36833. MsgId: "H44022900158202103301712304203",
  36834. PsnNo: "44020000001101518097",
  36835. Info: "2207",
  36836. }
  36837. customData = append(customData, custom9)
  36838. custom10 := &CustomData{
  36839. MsgId: "H44022900158202103301738448785",
  36840. PsnNo: "44020000001100500813",
  36841. Info: "2207",
  36842. }
  36843. customData = append(customData, custom10)
  36844. custom11 := &CustomData{
  36845. MsgId: "H44022900158202103301732455843",
  36846. PsnNo: "44020000001102690557",
  36847. Info: "2207",
  36848. }
  36849. customData = append(customData, custom11)
  36850. custom12 := &CustomData{
  36851. MsgId: "H44022900158202103301745421708",
  36852. PsnNo: "44020000001102211928",
  36853. Info: "2207",
  36854. }
  36855. customData = append(customData, custom12)
  36856. custom1212 := &CustomData{
  36857. MsgId: "H440229001582021033017351627",
  36858. PsnNo: "44020000001102481733",
  36859. Info: "2207",
  36860. }
  36861. customData = append(customData, custom1212)
  36862. custom13 := &CustomData{
  36863. MsgId: "H44022900158202103301740327951",
  36864. PsnNo: "44020000001103174866",
  36865. Info: "2207",
  36866. }
  36867. customData = append(customData, custom13)
  36868. custom14 := &CustomData{
  36869. MsgId: "H4402290015820210330174922668",
  36870. PsnNo: "44020000001102927272",
  36871. Info: "2207",
  36872. }
  36873. customData = append(customData, custom14)
  36874. custom15 := &CustomData{
  36875. MsgId: "H44022900158202103301752362273",
  36876. PsnNo: "44020000001102942890",
  36877. Info: "2207",
  36878. }
  36879. customData = append(customData, custom15)
  36880. custom16 := &CustomData{
  36881. MsgId: "H44022900158202103301751082917",
  36882. PsnNo: "44020000001101662162",
  36883. Info: "2207",
  36884. }
  36885. customData = append(customData, custom16)
  36886. custom17 := &CustomData{
  36887. MsgId: "H44022900158202103301754147728",
  36888. PsnNo: "44020000000229014511",
  36889. Info: "2207",
  36890. }
  36891. customData = append(customData, custom17)
  36892. adminUser := c.GetAdminUserInfo()
  36893. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36894. for _, item := range customData {
  36895. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36896. fmt.Println(result)
  36897. }
  36898. }
  36899. func (c *HisApiController) GetAllopatry() {
  36900. year := c.GetString("year")
  36901. month := c.GetString("month")
  36902. admin_user_id, _ := c.GetInt64("admin_user_id")
  36903. adminUser := c.GetAdminUserInfo()
  36904. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36905. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36906. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36907. var dat map[string]interface{}
  36908. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36909. fmt.Println(dat)
  36910. } else {
  36911. fmt.Println(err)
  36912. }
  36913. userJSONBytes, _ := json.Marshal(dat)
  36914. var res models.Result9001
  36915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36916. utils.ErrorLog("解析失败:%v", err)
  36917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36918. return
  36919. }
  36920. fmt.Println(res.Output.Signinoutb)
  36921. fmt.Println(res.Output.Signinoutb.SignNo)
  36922. fmt.Println(string(userJSONBytes))
  36923. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36924. var dat3 map[string]interface{}
  36925. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  36926. fmt.Println(dat3)
  36927. } else {
  36928. fmt.Println(err)
  36929. }
  36930. userJSONBytes3, _ := json.Marshal(dat3)
  36931. var res3 models.Result3260
  36932. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  36933. utils.ErrorLog("解析失败:%v", err)
  36934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36935. return
  36936. }
  36937. var curpage int
  36938. var pagesize int = 100
  36939. var start int = 1
  36940. //var stop int
  36941. //pagecount := 10
  36942. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  36943. var res22 []models.Result3260
  36944. for curpage = 1; curpage <= pagecount; curpage++ {
  36945. if curpage == 1 {
  36946. start = 0
  36947. } else {
  36948. start = (curpage-1)*pagesize + 1
  36949. }
  36950. fmt.Println(start)
  36951. //stop = curpage * pagesize
  36952. //if stop > int(res3.Output.Totalrow) {
  36953. // stop =int(res3.Output.Totalrow)
  36954. //}
  36955. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  36956. var dat2 map[string]interface{}
  36957. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36958. fmt.Println(dat)
  36959. } else {
  36960. fmt.Println(err)
  36961. }
  36962. userJSONBytes2, _ := json.Marshal(dat2)
  36963. var res2 models.Result3260
  36964. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36965. utils.ErrorLog("解析失败:%v", err)
  36966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36967. return
  36968. }
  36969. if res2.Infcode == 0 {
  36970. res22 = append(res22, res2)
  36971. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36972. //var dat2 map[string]interface{}
  36973. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36974. // fmt.Println(dat)
  36975. //} else {
  36976. // fmt.Println(err)
  36977. //}
  36978. //c.ServeSuccessJSON(map[string]interface{}{
  36979. // "list": res2.Output.Data,
  36980. //})
  36981. //continue
  36982. }
  36983. }
  36984. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36985. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36986. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  36987. //var dat2 map[string]interface{}
  36988. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36989. // fmt.Println(dat)
  36990. //} else {
  36991. // fmt.Println(err)
  36992. //}
  36993. //userJSONBytes2, _ := json.Marshal(dat2)
  36994. //var res2 models.Result3260
  36995. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36996. // utils.ErrorLog("解析失败:%v", err)
  36997. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36998. // return
  36999. //}
  37000. //if res2.Infcode == 0 {
  37001. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37002. // var dat2 map[string]interface{}
  37003. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37004. // fmt.Println(dat)
  37005. // } else {
  37006. // fmt.Println(err)
  37007. // }
  37008. // c.ServeSuccessJSON(map[string]interface{}{
  37009. // "list": res2.Output.Data,
  37010. // })
  37011. //}
  37012. }
  37013. func (c *HisApiController) ComfirmAllopatry() {
  37014. year := c.GetString("year")
  37015. month := c.GetString("month")
  37016. admin_user_id, _ := c.GetInt64("admin_user_id")
  37017. adminUser := c.GetAdminUserInfo()
  37018. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37019. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37020. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37021. var dat map[string]interface{}
  37022. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37023. fmt.Println(dat)
  37024. } else {
  37025. fmt.Println(err)
  37026. }
  37027. userJSONBytes, _ := json.Marshal(dat)
  37028. var res models.Result9001
  37029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37030. utils.ErrorLog("解析失败:%v", err)
  37031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37032. return
  37033. }
  37034. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37035. var dat2 map[string]interface{}
  37036. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37037. fmt.Println(dat)
  37038. } else {
  37039. fmt.Println(err)
  37040. }
  37041. userJSONBytes2, _ := json.Marshal(dat2)
  37042. var res2 models.Result3260
  37043. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37044. utils.ErrorLog("解析失败:%v", err)
  37045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37046. return
  37047. }
  37048. //if res2.Infcode == 0 {
  37049. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37050. // var dat map[string]interface{}
  37051. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37052. // fmt.Println(dat)
  37053. // } else {
  37054. // fmt.Println(err)
  37055. // }
  37056. // userJSONBytes, _ := json.Marshal(dat)
  37057. // var res3 models.Result3261
  37058. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37059. // utils.ErrorLog("解析失败:%v", err)
  37060. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37061. // return
  37062. // }
  37063. //
  37064. // if res3.Infcode == 0 {
  37065. // record := &models.HisYidiClearRecord{
  37066. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37067. // Ctime: time.Now().Unix(),
  37068. // Mtime: time.Now().Unix(),
  37069. // Status: 1,
  37070. // MsgId: msgId,
  37071. // }
  37072. // service.SaveClearRecord(record)
  37073. // c.ServeSuccessJSON(map[string]interface{}{
  37074. // "msg": "提取成功",
  37075. // })
  37076. // }
  37077. //}
  37078. }
  37079. func (c *HisApiController) RefundAllopatry() {
  37080. year := c.GetString("year")
  37081. month := c.GetString("month")
  37082. //id, _ := c.GetInt64("id")
  37083. admin_user_id, _ := c.GetInt64("admin_user_id")
  37084. adminUser := c.GetAdminUserInfo()
  37085. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37086. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37087. //record, _ := service.GetClearRecordById(id)
  37088. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37089. var dat map[string]interface{}
  37090. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37091. fmt.Println(dat)
  37092. } else {
  37093. fmt.Println(err)
  37094. }
  37095. userJSONBytes, _ := json.Marshal(dat)
  37096. var res models.Result9001
  37097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37098. utils.ErrorLog("解析失败:%v", err)
  37099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37100. return
  37101. }
  37102. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37103. var dat2 map[string]interface{}
  37104. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37105. fmt.Println(dat)
  37106. } else {
  37107. fmt.Println(err)
  37108. }
  37109. userJSONBytes2, _ := json.Marshal(dat2)
  37110. var empty ResultFourteen
  37111. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37112. utils.ErrorLog("解析失败:%v", err)
  37113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37114. return
  37115. }
  37116. if empty.Infcode == 0 {
  37117. c.ServeSuccessJSON(map[string]interface{}{
  37118. "msg": "撤销成功",
  37119. })
  37120. return
  37121. }
  37122. }
  37123. func (c *HisApiController) ReversalOtherData() {
  37124. var customData []*CustomData
  37125. custom := &CustomData{
  37126. MsgId: "H44022900158202103301714472004",
  37127. PsnNo: "44020000001101329945",
  37128. Info: "2208",
  37129. }
  37130. customData = append(customData, custom)
  37131. custom1 := &CustomData{
  37132. MsgId: "H4402290015820210330172057803",
  37133. PsnNo: "44020000001101161813",
  37134. Info: "2208",
  37135. }
  37136. customData = append(customData, custom1)
  37137. custom2 := &CustomData{
  37138. MsgId: "H44022900158202103301705198813",
  37139. PsnNo: "44190000133097375417",
  37140. Info: "2208",
  37141. }
  37142. customData = append(customData, custom2)
  37143. custom3 := &CustomData{
  37144. MsgId: "H44022900158202103301715524756",
  37145. PsnNo: "44020000001100187221",
  37146. Info: "2208",
  37147. }
  37148. customData = append(customData, custom3)
  37149. custom4 := &CustomData{
  37150. MsgId: "H44022900158202103301730376224",
  37151. PsnNo: "44020000001101959155",
  37152. Info: "2208",
  37153. }
  37154. customData = append(customData, custom4)
  37155. custom5 := &CustomData{
  37156. MsgId: "H44022900158202103301748008725",
  37157. PsnNo: "44020000001104246641",
  37158. Info: "2208",
  37159. }
  37160. customData = append(customData, custom5)
  37161. custom6 := &CustomData{
  37162. MsgId: "H44022900158202103301718096755",
  37163. PsnNo: "44020000001102211860",
  37164. Info: "2208",
  37165. }
  37166. customData = append(customData, custom6)
  37167. custom7 := &CustomData{
  37168. MsgId: "H44022900158202103301736551640",
  37169. PsnNo: "44020000001102687718",
  37170. Info: "2208",
  37171. }
  37172. customData = append(customData, custom7)
  37173. custom8 := &CustomData{
  37174. MsgId: "H44022900158202103301743097676",
  37175. PsnNo: "44020000001102127785",
  37176. Info: "2208",
  37177. }
  37178. customData = append(customData, custom8)
  37179. custom9 := &CustomData{
  37180. MsgId: "H44022900158202103301712304203",
  37181. PsnNo: "44020000001101518097",
  37182. Info: "2208",
  37183. }
  37184. customData = append(customData, custom9)
  37185. custom10 := &CustomData{
  37186. MsgId: "H44022900158202103301738448785",
  37187. PsnNo: "44020000001100500813",
  37188. Info: "2208",
  37189. }
  37190. customData = append(customData, custom10)
  37191. custom11 := &CustomData{
  37192. MsgId: "H44022900158202103301732455843",
  37193. PsnNo: "44020000001102690557",
  37194. Info: "2208",
  37195. }
  37196. customData = append(customData, custom11)
  37197. custom12 := &CustomData{
  37198. MsgId: "H44022900158202103301745421708",
  37199. PsnNo: "44020000001102211928",
  37200. Info: "2208",
  37201. }
  37202. customData = append(customData, custom12)
  37203. custom1212 := &CustomData{
  37204. MsgId: "H440229001582021033017351627",
  37205. PsnNo: "44020000001102481733",
  37206. Info: "2208",
  37207. }
  37208. customData = append(customData, custom1212)
  37209. custom13 := &CustomData{
  37210. MsgId: "H44022900158202103301740327951",
  37211. PsnNo: "44020000001103174866",
  37212. Info: "2208",
  37213. }
  37214. customData = append(customData, custom13)
  37215. custom14 := &CustomData{
  37216. MsgId: "H4402290015820210330174922668",
  37217. PsnNo: "44020000001102927272",
  37218. Info: "2208",
  37219. }
  37220. customData = append(customData, custom14)
  37221. custom15 := &CustomData{
  37222. MsgId: "H44022900158202103301752362273",
  37223. PsnNo: "44020000001102942890",
  37224. Info: "2208",
  37225. }
  37226. customData = append(customData, custom15)
  37227. custom16 := &CustomData{
  37228. MsgId: "H44022900158202103301751082917",
  37229. PsnNo: "44020000001101662162",
  37230. Info: "2208",
  37231. }
  37232. customData = append(customData, custom16)
  37233. custom17 := &CustomData{
  37234. MsgId: "H44022900158202103301754147728",
  37235. PsnNo: "44020000000229014511",
  37236. Info: "2208",
  37237. }
  37238. customData = append(customData, custom17)
  37239. adminUser := c.GetAdminUserInfo()
  37240. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37241. for _, item := range customData {
  37242. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37243. fmt.Println(result)
  37244. }
  37245. }
  37246. func PathExists(path string) (bool, error) {
  37247. _, err := os.Stat(path)
  37248. if err == nil {
  37249. return true, nil
  37250. }
  37251. if os.IsNotExist(err) {
  37252. return false, nil
  37253. }
  37254. return false, err
  37255. }
  37256. // 创建文件夹
  37257. func Mkdir(dir string) {
  37258. // 创建文件夹
  37259. exist, err := PathExists(dir)
  37260. if err != nil {
  37261. fmt.Println(err.Error())
  37262. } else {
  37263. if exist {
  37264. fmt.Println(dir + "文件夹已存在!")
  37265. } else {
  37266. // 文件夹名称,权限
  37267. err := os.Mkdir(dir, os.ModePerm)
  37268. if err != nil {
  37269. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37270. } else {
  37271. fmt.Println(dir + "文件夹创建成功!")
  37272. }
  37273. }
  37274. }
  37275. }
  37276. // 压缩文件
  37277. func Zip(srcFile string, destZip string) error {
  37278. zipfile, err := os.Create(destZip)
  37279. if err != nil {
  37280. return err
  37281. }
  37282. defer zipfile.Close()
  37283. archive := zip.NewWriter(zipfile)
  37284. defer archive.Close()
  37285. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37286. if err != nil {
  37287. return err
  37288. }
  37289. header, err := zip.FileInfoHeader(info)
  37290. if err != nil {
  37291. return err
  37292. }
  37293. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37294. // header.Name = path
  37295. if info.IsDir() {
  37296. header.Name += "/"
  37297. } else {
  37298. header.Method = zip.Deflate
  37299. }
  37300. writer, err := archive.CreateHeader(header)
  37301. if err != nil {
  37302. return err
  37303. }
  37304. if !info.IsDir() {
  37305. file, err := os.Open(path)
  37306. if err != nil {
  37307. return err
  37308. }
  37309. defer file.Close()
  37310. _, err = io.Copy(writer, file)
  37311. }
  37312. return err
  37313. })
  37314. return err
  37315. }
  37316. func ReadFile(filePath string) []byte {
  37317. f, err := os.Open(filePath)
  37318. if err != nil {
  37319. fmt.Println("read file fail", err)
  37320. return nil
  37321. }
  37322. defer f.Close()
  37323. fd, err := ioutil.ReadAll(f)
  37324. if err != nil {
  37325. fmt.Println("read to fd fail", err)
  37326. return nil
  37327. }
  37328. return fd
  37329. }
  37330. func saveLogq(result string, request string, infno string, desc string) {
  37331. dir := "日志"
  37332. utils.Mkdir(dir)
  37333. month := time.Unix(1557042972, 0).Format("1")
  37334. year := time.Now().Format("2006")
  37335. month = time.Now().Format("01")
  37336. day := time.Now().Format("02")
  37337. hour := time.Now().Format("15")
  37338. min := time.Now().Format("04")
  37339. sec := time.Now().Format("05")
  37340. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37341. file := year + month + day + "_log"
  37342. file_name := file + ".txt"
  37343. file_path := "日志" + "/" + file_name
  37344. exist, _ := utils.PathExists(file_path)
  37345. if exist { //存在
  37346. fmt.Println("存在")
  37347. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37348. if err != nil {
  37349. fmt.Println("read fail")
  37350. }
  37351. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37352. n, _ := f.Seek(0, 2)
  37353. _, err = f.WriteAt([]byte(content), n)
  37354. } else { //不存在
  37355. fmt.Println("文件不存在,创建文件")
  37356. f, err := os.Create("日志" + "/" + file_name)
  37357. defer f.Close()
  37358. if err != nil {
  37359. } else {
  37360. _, err = f.Write([]byte("记录日志"))
  37361. }
  37362. }
  37363. }
  37364. func saveLog(result string, request string, infno string, desc string) {
  37365. org_id, _ := beego.AppConfig.Int64("org_id")
  37366. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37367. dir := miConfig.OrgName + "日志"
  37368. utils.Mkdir(dir)
  37369. month := time.Unix(1557042972, 0).Format("1")
  37370. year := time.Now().Format("2006")
  37371. month = time.Now().Format("01")
  37372. day := time.Now().Format("02")
  37373. hour := time.Now().Format("15")
  37374. min := time.Now().Format("04")
  37375. sec := time.Now().Format("05")
  37376. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37377. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37378. file_name := file + ".txt"
  37379. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37380. exist, _ := utils.PathExists(file_path)
  37381. if exist { //存在
  37382. fmt.Println("存在")
  37383. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37384. if err != nil {
  37385. fmt.Println("read fail")
  37386. }
  37387. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37388. n, _ := f.Seek(0, 2)
  37389. _, err = f.WriteAt([]byte(content), n)
  37390. } else { //不存在
  37391. fmt.Println("文件不存在,创建文件")
  37392. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37393. defer f.Close()
  37394. if err != nil {
  37395. } else {
  37396. _, err = f.Write([]byte("记录日志"))
  37397. }
  37398. }
  37399. }
  37400. type Charset string
  37401. const (
  37402. UTF8 = Charset("UTF-8")
  37403. GB18030 = Charset("GB18030")
  37404. )
  37405. func ConvertToString(src string, srcCode string, tagCode string) string {
  37406. srcCoder := mahonia.NewDecoder(srcCode)
  37407. srcResult := srcCoder.ConvertString(src)
  37408. tagCoder := mahonia.NewDecoder(tagCode)
  37409. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37410. result := string(cdata)
  37411. return result
  37412. }
  37413. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37414. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37415. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37416. var token string
  37417. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37418. var api string
  37419. if miConfig.MdtrtareaAdmvs == "320921" {
  37420. 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 +
  37421. "&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
  37422. fmt.Println(api)
  37423. } else {
  37424. 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 +
  37425. "&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
  37426. }
  37427. resp, requestErr := http.Get(api)
  37428. if requestErr != nil {
  37429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37430. return ""
  37431. }
  37432. body, ioErr := ioutil.ReadAll(resp.Body)
  37433. if ioErr != nil {
  37434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37436. return ""
  37437. }
  37438. var respJSON map[string]interface{}
  37439. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37442. return ""
  37443. }
  37444. var status string
  37445. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37446. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37447. var res ResultTwo //1101结果
  37448. var res10265 ResultTwo10265 //1101结果
  37449. if status == "0" { //读卡成功
  37450. var card_info string //卡信息
  37451. var busi_card_info string
  37452. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37453. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37454. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37455. fmt.Println(card_info)
  37456. fmt.Println(busi_card_info)
  37457. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37458. result, _ := json.Marshal(respJSON)
  37459. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37460. utils.ErrorLog("解析失败:%v", err)
  37461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37462. return ""
  37463. }
  37464. res.ErrMsg = res10265.ErrMsg
  37465. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37466. res.Infcode = infocode
  37467. res.Output = res10265.Output
  37468. res.InfRefmsgid = res10265.InfRefmsgid
  37469. if res.Infcode == 0 {
  37470. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37471. if err == gorm.ErrRecordNotFound {
  37472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37473. return ""
  37474. } else if err != nil {
  37475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37476. return ""
  37477. } else {
  37478. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37479. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37480. infoStr := string(Iinfos)
  37481. idetinfoStr := string(Idetinfos)
  37482. psn := &models.HisPsn{
  37483. PsnNo: res.Output.Baseinfo.PsnNo,
  37484. PatientId: patient.ID,
  37485. Certno: res.Output.Baseinfo.Certno,
  37486. Gend: res.Output.Baseinfo.Gend,
  37487. Naty: res.Output.Baseinfo.Naty,
  37488. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37489. PsnName: res.Output.Baseinfo.PsnName,
  37490. Idetinfo: idetinfoStr,
  37491. Insuinfo: infoStr,
  37492. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37493. CardInfo: card_info,
  37494. VerifyNumber: token,
  37495. }
  37496. service.CreateHisPsn(psn)
  37497. return token
  37498. }
  37499. }
  37500. } else {
  37501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37502. return ""
  37503. }
  37504. } else { //读卡失败
  37505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37506. return ""
  37507. }
  37508. return token
  37509. }
  37510. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37511. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37512. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37513. var token string
  37514. var api string
  37515. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37516. "&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
  37517. fmt.Println(api)
  37518. resp, requestErr := http.Get(api)
  37519. if requestErr != nil {
  37520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37521. return ""
  37522. }
  37523. body, ioErr := ioutil.ReadAll(resp.Body)
  37524. if ioErr != nil {
  37525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37527. return ""
  37528. }
  37529. var respJSON map[string]interface{}
  37530. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37533. return ""
  37534. }
  37535. var status string
  37536. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37537. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37538. var res ResultTwo //1101结果
  37539. if status == "1" { //读卡成功
  37540. var card_info string //卡信息
  37541. var busi_card_info string
  37542. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37543. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37544. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37545. fmt.Println(card_info)
  37546. fmt.Println(busi_card_info)
  37547. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37548. result, _ := json.Marshal(respJSON)
  37549. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37550. utils.ErrorLog("解析失败:%v", err)
  37551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37552. return ""
  37553. }
  37554. if res.Infcode == 0 {
  37555. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37556. if err == gorm.ErrRecordNotFound {
  37557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37558. return ""
  37559. } else if err != nil {
  37560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37561. return ""
  37562. } else {
  37563. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37564. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37565. infoStr := string(Iinfos)
  37566. idetinfoStr := string(Idetinfos)
  37567. psn := &models.HisPsn{
  37568. PsnNo: res.Output.Baseinfo.PsnNo,
  37569. PatientId: patient.ID,
  37570. Certno: res.Output.Baseinfo.Certno,
  37571. Gend: res.Output.Baseinfo.Gend,
  37572. Naty: res.Output.Baseinfo.Naty,
  37573. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37574. PsnName: res.Output.Baseinfo.PsnName,
  37575. Idetinfo: idetinfoStr,
  37576. Insuinfo: infoStr,
  37577. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37578. CardInfo: card_info,
  37579. VerifyNumber: token,
  37580. }
  37581. service.CreateHisPsn(psn)
  37582. return token
  37583. }
  37584. }
  37585. } else {
  37586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37587. return ""
  37588. }
  37589. return token
  37590. }
  37591. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37592. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37593. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37594. var token string
  37595. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37596. var api string
  37597. if miConfig.MdtrtareaAdmvs == "320921" {
  37598. 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 +
  37599. "&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
  37600. fmt.Println(api)
  37601. } else {
  37602. 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 +
  37603. "&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
  37604. }
  37605. resp, requestErr := http.Get(api)
  37606. if requestErr != nil {
  37607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37608. return ""
  37609. }
  37610. body, ioErr := ioutil.ReadAll(resp.Body)
  37611. if ioErr != nil {
  37612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37614. return ""
  37615. }
  37616. var respJSON map[string]interface{}
  37617. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37620. return ""
  37621. }
  37622. var status string
  37623. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37624. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37625. var res ResultTwo //1101结果
  37626. var res10265 ResultTwo10265 //1101结果
  37627. if status == "0" { //读卡成功
  37628. var card_info string //卡信息
  37629. var busi_card_info string
  37630. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37631. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37632. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37633. fmt.Println(card_info)
  37634. fmt.Println(busi_card_info)
  37635. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37636. result, _ := json.Marshal(respJSON)
  37637. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37638. utils.ErrorLog("解析失败:%v", err)
  37639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37640. return ""
  37641. }
  37642. res.ErrMsg = res10265.ErrMsg
  37643. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37644. res.Infcode = infocode
  37645. res.Output = res10265.Output
  37646. res.InfRefmsgid = res10265.InfRefmsgid
  37647. if res.Infcode == 0 {
  37648. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37649. if err == gorm.ErrRecordNotFound {
  37650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37651. return ""
  37652. } else if err != nil {
  37653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37654. return ""
  37655. } else {
  37656. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37657. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37658. infoStr := string(Iinfos)
  37659. idetinfoStr := string(Idetinfos)
  37660. psn := &models.HisPsn{
  37661. PsnNo: res.Output.Baseinfo.PsnNo,
  37662. PatientId: patient.ID,
  37663. Certno: res.Output.Baseinfo.Certno,
  37664. Gend: res.Output.Baseinfo.Gend,
  37665. Naty: res.Output.Baseinfo.Naty,
  37666. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37667. PsnName: res.Output.Baseinfo.PsnName,
  37668. Idetinfo: idetinfoStr,
  37669. Insuinfo: infoStr,
  37670. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37671. CardInfo: card_info,
  37672. VerifyNumber: token,
  37673. }
  37674. service.CreateHisPsn(psn)
  37675. return token
  37676. }
  37677. }
  37678. } else {
  37679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37680. return ""
  37681. }
  37682. } else { //读卡失败
  37683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37684. return ""
  37685. }
  37686. return token
  37687. }
  37688. func DeleteExtraSpaceTwo(s string) string {
  37689. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37690. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37691. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37692. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37693. s2 := make([]byte, len(s1)) //定义字符数组切片
  37694. copy(s2, s1) //将字符串复制到切片
  37695. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37696. for len(spc_index) > 0 { //找到适配项
  37697. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37698. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37699. }
  37700. return string(s2)
  37701. }
  37702. func Remove0000(s string) string {
  37703. str := make([]rune, 0, len(s))
  37704. for _, v := range []rune(s) {
  37705. if v == 0 {
  37706. continue
  37707. }
  37708. str = append(str, v)
  37709. }
  37710. return string(str)
  37711. }
  37712. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37713. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37714. readCard := DllDef.MustFindProc("EcQuery")
  37715. pCardInfo := make([]byte, 8192)
  37716. pBusiCardInfo := make([]byte, 8192)
  37717. data := make(map[string]interface{})
  37718. //pData := make(map[string]interface{})
  37719. inputData := make(map[string]interface{})
  37720. inputData["orgId"] = code
  37721. inputData["businessType"] = "01101"
  37722. inputData["operatorId"] = operator_id
  37723. inputData["operatorName"] = operator_name
  37724. inputData["officeId"] = "001"
  37725. inputData["officeName"] = "血透室"
  37726. //
  37727. data["data"] = inputData
  37728. data["transType"] = "ec.query"
  37729. data["orgId"] = code
  37730. bytesData, _ := json.Marshal(data)
  37731. pCardInfo = bytesData
  37732. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37733. fmt.Println(ret2)
  37734. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37735. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37736. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37737. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37738. if ret2 != 0 {
  37739. return "", ""
  37740. }
  37741. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37742. }
  37743. func DeleteExtraSpace(s string) string {
  37744. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37745. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37746. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37747. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37748. s2 := make([]byte, len(s1)) //定义字符数组切片
  37749. copy(s2, s1) //将字符串复制到切片
  37750. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37751. for len(spc_index) > 0 { //找到适配项
  37752. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37753. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37754. }
  37755. return string(s2)
  37756. }
  37757. // 对账
  37758. func (c *HisApiController) Post3202() {
  37759. start_time := c.GetString("start_time")
  37760. end_time := c.GetString("end_time")
  37761. //insutype := c.GetString("insutype")
  37762. clr_type := c.GetString("clr_type")
  37763. clr_org := c.GetString("clr_optins")
  37764. admin_user_id, _ := c.GetInt64("admin_user_id")
  37765. adminUser := c.GetAdminUserInfo()
  37766. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37767. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37768. if len(clr_org) == 0 {
  37769. clr_org = miConfig.MdtrtareaAdmvs
  37770. }
  37771. timeLayout := "2006-01-02"
  37772. loc, _ := time.LoadLocation("Local")
  37773. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37774. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37775. var orders []*models.HisOrder
  37776. if clr_org == "421300" {
  37777. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37778. } else if clr_org == "420902" {
  37779. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37780. } else {
  37781. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37782. }
  37783. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37784. //fixmedins_setl_cnt := int64(len(orders))
  37785. var medfee_sumamt float64
  37786. var acct_pay float64
  37787. var fund_pay_sumamt float64
  37788. for _, item := range orders {
  37789. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37790. acct_pay = acct_pay + item.AcctPay
  37791. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37792. }
  37793. //var medfee_sumamt_two float64
  37794. //var acct_pay_two float64
  37795. //var fund_pay_sumamt_two float64
  37796. //for _, item := range orders_two {
  37797. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37798. // acct_pay_two = acct_pay_two + item.AcctPay
  37799. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37800. //}
  37801. //var user_name string
  37802. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37803. //if role.ID == 0 {
  37804. // user_name = "xxx"
  37805. //} else {
  37806. // user_name = role.UserName
  37807. //}
  37808. var res ResultSix
  37809. if config.IsOpen == 1 {
  37810. var bps []*models.BusinessParamsTwo
  37811. var bp models.BusinessParamsTwo
  37812. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37813. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37814. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37815. bp.MedfeeSumamt = medfee_sumamt_str
  37816. bp.AcctPay = acct_pay_str
  37817. bp.FundPaySumamt = fund_pay_sumamt_str
  37818. bp.Insutype = ""
  37819. bp.StmtBegndate = start_time
  37820. bp.ClrType = clr_type
  37821. bp.SetlOptins = clr_org
  37822. bp.StmtEnddate = end_time
  37823. bps = append(bps, &bp)
  37824. data := make(map[string]interface{})
  37825. data["bps"] = bps
  37826. data["org_name"] = miConfig.OrgName
  37827. data["doctor"] = role.UserName
  37828. data["fixmedins_code"] = miConfig.Code
  37829. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37830. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37831. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37832. if miConfig.MdtrtareaAdmvs == "421300" {
  37833. client := &http.Client{}
  37834. bytesData, _ := json.Marshal(data)
  37835. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37836. resp, _ := client.Do(req)
  37837. defer resp.Body.Close()
  37838. body, ioErr := ioutil.ReadAll(resp.Body)
  37839. if ioErr != nil {
  37840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37842. return
  37843. }
  37844. var respJSON map[string]interface{}
  37845. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37848. return
  37849. }
  37850. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37851. userJSONBytes, _ := json.Marshal(respJSON)
  37852. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37853. utils.ErrorLog("解析失败:%v", err)
  37854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37855. return
  37856. }
  37857. }
  37858. if miConfig.MdtrtareaAdmvs == "420200" {
  37859. client := &http.Client{}
  37860. bytesData, _ := json.Marshal(data)
  37861. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37862. resp, _ := client.Do(req)
  37863. defer resp.Body.Close()
  37864. body, ioErr := ioutil.ReadAll(resp.Body)
  37865. if ioErr != nil {
  37866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37868. return
  37869. }
  37870. var respJSON map[string]interface{}
  37871. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37874. return
  37875. }
  37876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37877. userJSONBytes, _ := json.Marshal(respJSON)
  37878. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37879. utils.ErrorLog("解析失败:%v", err)
  37880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37881. return
  37882. }
  37883. }
  37884. if miConfig.MdtrtareaAdmvs == "421182" {
  37885. client := &http.Client{}
  37886. bytesData, _ := json.Marshal(data)
  37887. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37888. resp, _ := client.Do(req)
  37889. defer resp.Body.Close()
  37890. body, ioErr := ioutil.ReadAll(resp.Body)
  37891. if ioErr != nil {
  37892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37894. return
  37895. }
  37896. var respJSON map[string]interface{}
  37897. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37900. return
  37901. }
  37902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37903. userJSONBytes, _ := json.Marshal(respJSON)
  37904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37905. utils.ErrorLog("解析失败:%v", err)
  37906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37907. return
  37908. }
  37909. }
  37910. if miConfig.MdtrtareaAdmvs == "420902" {
  37911. client := &http.Client{}
  37912. bytesData, _ := json.Marshal(data)
  37913. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37914. resp, _ := client.Do(req)
  37915. defer resp.Body.Close()
  37916. body, ioErr := ioutil.ReadAll(resp.Body)
  37917. if ioErr != nil {
  37918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37920. return
  37921. }
  37922. var respJSON map[string]interface{}
  37923. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37926. return
  37927. }
  37928. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37929. userJSONBytes, _ := json.Marshal(respJSON)
  37930. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37931. utils.ErrorLog("解析失败:%v", err)
  37932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37933. return
  37934. }
  37935. }
  37936. if res.Infcode == 0 {
  37937. c.ServeSuccessJSON(map[string]interface{}{
  37938. "msg": "发起成功",
  37939. })
  37940. } else {
  37941. c.ServeSuccessJSON(map[string]interface{}{
  37942. "failed_code": -10,
  37943. "msg": res.ErrMsg,
  37944. })
  37945. }
  37946. }
  37947. }
  37948. func (c *HisApiController) Post3204a() {
  37949. start_time := c.GetString("start_time")
  37950. end_time := c.GetString("end_time")
  37951. //insutype := c.GetString("insutype")
  37952. clr_type := c.GetString("clr_type")
  37953. clr_org := c.GetString("clr_optins")
  37954. admin_user_id, _ := c.GetInt64("admin_user_id")
  37955. adminUser := c.GetAdminUserInfo()
  37956. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37957. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37958. if len(clr_org) == 0 {
  37959. clr_org = miConfig.MdtrtareaAdmvs
  37960. }
  37961. timeLayout := "2006-01-02"
  37962. loc, _ := time.LoadLocation("Local")
  37963. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37964. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37965. var orders []*models.HisOrder
  37966. if clr_org == "421300" {
  37967. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37968. } else if clr_org == "420902" {
  37969. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37970. } else {
  37971. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37972. }
  37973. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37974. //fixmedins_setl_cnt := int64(len(orders))
  37975. var medfee_sumamt float64
  37976. var acct_pay float64
  37977. var fund_pay_sumamt float64
  37978. for _, item := range orders {
  37979. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37980. acct_pay = acct_pay + item.AcctPay
  37981. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37982. }
  37983. //var medfee_sumamt_two float64
  37984. //var acct_pay_two float64
  37985. //var fund_pay_sumamt_two float64
  37986. //for _, item := range orders_two {
  37987. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37988. // acct_pay_two = acct_pay_two + item.AcctPay
  37989. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37990. //}
  37991. //var user_name string
  37992. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37993. //if role.ID == 0 {
  37994. // user_name = "xxx"
  37995. //} else {
  37996. // user_name = role.UserName
  37997. //}
  37998. var res ResultSix
  37999. if config.IsOpen == 1 {
  38000. var bps []*models.BusinessParamsTwo
  38001. var bp models.BusinessParamsTwo
  38002. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38003. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38004. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38005. bp.MedfeeSumamt = medfee_sumamt_str
  38006. bp.AcctPay = acct_pay_str
  38007. bp.FundPaySumamt = fund_pay_sumamt_str
  38008. bp.Insutype = ""
  38009. bp.StmtBegndate = start_time
  38010. bp.ClrType = clr_type
  38011. bp.SetlOptins = clr_org
  38012. bp.StmtEnddate = end_time
  38013. bps = append(bps, &bp)
  38014. data := make(map[string]interface{})
  38015. data["bps"] = bps
  38016. data["org_name"] = miConfig.OrgName
  38017. data["doctor"] = role.UserName
  38018. data["fixmedins_code"] = miConfig.Code
  38019. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38020. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38021. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38022. if miConfig.MdtrtareaAdmvs == "421300" {
  38023. client := &http.Client{}
  38024. bytesData, _ := json.Marshal(data)
  38025. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38026. resp, _ := client.Do(req)
  38027. defer resp.Body.Close()
  38028. body, ioErr := ioutil.ReadAll(resp.Body)
  38029. if ioErr != nil {
  38030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38032. return
  38033. }
  38034. var respJSON map[string]interface{}
  38035. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38038. return
  38039. }
  38040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38041. userJSONBytes, _ := json.Marshal(respJSON)
  38042. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38043. utils.ErrorLog("解析失败:%v", err)
  38044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38045. return
  38046. }
  38047. }
  38048. if miConfig.MdtrtareaAdmvs == "420200" {
  38049. client := &http.Client{}
  38050. bytesData, _ := json.Marshal(data)
  38051. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38052. resp, _ := client.Do(req)
  38053. defer resp.Body.Close()
  38054. body, ioErr := ioutil.ReadAll(resp.Body)
  38055. if ioErr != nil {
  38056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38058. return
  38059. }
  38060. var respJSON map[string]interface{}
  38061. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38064. return
  38065. }
  38066. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38067. userJSONBytes, _ := json.Marshal(respJSON)
  38068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38069. utils.ErrorLog("解析失败:%v", err)
  38070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38071. return
  38072. }
  38073. }
  38074. if miConfig.MdtrtareaAdmvs == "421182" {
  38075. client := &http.Client{}
  38076. bytesData, _ := json.Marshal(data)
  38077. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38078. resp, _ := client.Do(req)
  38079. defer resp.Body.Close()
  38080. body, ioErr := ioutil.ReadAll(resp.Body)
  38081. if ioErr != nil {
  38082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38084. return
  38085. }
  38086. var respJSON map[string]interface{}
  38087. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38090. return
  38091. }
  38092. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38093. userJSONBytes, _ := json.Marshal(respJSON)
  38094. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38095. utils.ErrorLog("解析失败:%v", err)
  38096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38097. return
  38098. }
  38099. }
  38100. if miConfig.MdtrtareaAdmvs == "420902" {
  38101. client := &http.Client{}
  38102. bytesData, _ := json.Marshal(data)
  38103. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38104. resp, _ := client.Do(req)
  38105. defer resp.Body.Close()
  38106. body, ioErr := ioutil.ReadAll(resp.Body)
  38107. if ioErr != nil {
  38108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38110. return
  38111. }
  38112. var respJSON map[string]interface{}
  38113. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38116. return
  38117. }
  38118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38119. userJSONBytes, _ := json.Marshal(respJSON)
  38120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38121. utils.ErrorLog("解析失败:%v", err)
  38122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38123. return
  38124. }
  38125. }
  38126. if res.Infcode == 0 {
  38127. c.ServeSuccessJSON(map[string]interface{}{
  38128. "msg": "撤销成功",
  38129. })
  38130. } else {
  38131. c.ServeSuccessJSON(map[string]interface{}{
  38132. "failed_code": -10,
  38133. "msg": res.ErrMsg,
  38134. })
  38135. }
  38136. }
  38137. }
  38138. func (c *HisApiController) Post3204() {
  38139. admin_user_id, _ := c.GetInt64("admin_user_id")
  38140. id := c.GetString("id")
  38141. adminUser := c.GetAdminUserInfo()
  38142. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38143. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38144. //clr_org := miConfig.MdtrtareaAdmvs
  38145. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38146. var res ResultSix
  38147. if config.IsOpen == 1 {
  38148. data := make(map[string]interface{})
  38149. data["id"] = id
  38150. data["org_name"] = miConfig.OrgName
  38151. data["doctor"] = role.UserName
  38152. data["fixmedins_code"] = miConfig.Code
  38153. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38154. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38155. client := &http.Client{}
  38156. bytesData, _ := json.Marshal(data)
  38157. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38158. resp, _ := client.Do(req)
  38159. defer resp.Body.Close()
  38160. body, ioErr := ioutil.ReadAll(resp.Body)
  38161. if ioErr != nil {
  38162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38164. return
  38165. }
  38166. var respJSON map[string]interface{}
  38167. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38170. return
  38171. }
  38172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38173. userJSONBytes, _ := json.Marshal(respJSON)
  38174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38175. utils.ErrorLog("解析失败:%v", err)
  38176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38177. return
  38178. }
  38179. if res.Infcode == 0 {
  38180. c.ServeSuccessJSON(map[string]interface{}{
  38181. "msg": "发起成功",
  38182. })
  38183. } else {
  38184. c.ServeSuccessJSON(map[string]interface{}{
  38185. "failed_code": -10,
  38186. "msg": res.ErrMsg,
  38187. })
  38188. }
  38189. }
  38190. }
  38191. func (c *HisApiController) Post8404() {
  38192. admin_user_id, _ := c.GetInt64("admin_user_id")
  38193. month := c.GetString("month")
  38194. adminUser := c.GetAdminUserInfo()
  38195. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38196. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38197. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38198. var res ResultSix
  38199. if config.IsOpen == 1 {
  38200. data := make(map[string]interface{})
  38201. data["month"] = month
  38202. data["org_name"] = miConfig.OrgName
  38203. data["doctor"] = role.UserName
  38204. data["fixmedins_code"] = miConfig.Code
  38205. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38206. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38207. client := &http.Client{}
  38208. bytesData, _ := json.Marshal(data)
  38209. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38210. resp, _ := client.Do(req)
  38211. defer resp.Body.Close()
  38212. body, ioErr := ioutil.ReadAll(resp.Body)
  38213. if ioErr != nil {
  38214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38216. return
  38217. }
  38218. var respJSON map[string]interface{}
  38219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38222. return
  38223. }
  38224. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38225. userJSONBytes, _ := json.Marshal(respJSON)
  38226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38227. utils.ErrorLog("解析失败:%v", err)
  38228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38229. return
  38230. }
  38231. if res.Infcode == 0 {
  38232. c.ServeSuccessJSON(map[string]interface{}{
  38233. "msg": "查询成功",
  38234. })
  38235. } else {
  38236. c.ServeSuccessJSON(map[string]interface{}{
  38237. "failed_code": -10,
  38238. "msg": res.ErrMsg,
  38239. })
  38240. }
  38241. }
  38242. }
  38243. func (c *HisApiController) Post3202b() {
  38244. start_time := c.GetString("start_time")
  38245. end_time := c.GetString("end_time")
  38246. //insutype := c.GetString("insutype")
  38247. clr_type := c.GetString("clr_type")
  38248. clr_org := c.GetString("clr_optins")
  38249. admin_user_id, _ := c.GetInt64("admin_user_id")
  38250. adminUser := c.GetAdminUserInfo()
  38251. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38252. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38253. if len(clr_org) == 0 {
  38254. clr_org = miConfig.MdtrtareaAdmvs
  38255. }
  38256. timeLayout := "2006-01-02"
  38257. loc, _ := time.LoadLocation("Local")
  38258. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38259. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38260. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38261. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38262. //fixmedins_setl_cnt := int64(len(orders))
  38263. var medfee_sumamt float64
  38264. var acct_pay float64
  38265. var fund_pay_sumamt float64
  38266. for _, item := range orders {
  38267. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38268. acct_pay = acct_pay + item.AcctPay
  38269. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38270. }
  38271. //var medfee_sumamt_two float64
  38272. //var acct_pay_two float64
  38273. //var fund_pay_sumamt_two float64
  38274. //for _, item := range orders_two {
  38275. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38276. // acct_pay_two = acct_pay_two + item.AcctPay
  38277. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38278. //}
  38279. //var user_name string
  38280. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38281. //if role.ID == 0 {
  38282. // user_name = "xxx"
  38283. //} else {
  38284. // user_name = role.UserName
  38285. //}
  38286. var res ResultSix
  38287. if config.IsOpen == 1 {
  38288. var bps []*models.BusinessParamsTwo
  38289. var bp models.BusinessParamsTwo
  38290. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38291. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38292. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38293. bp.MedfeeSumamt = medfee_sumamt_str
  38294. bp.AcctPay = acct_pay_str
  38295. bp.FundPaySumamt = fund_pay_sumamt_str
  38296. bp.Insutype = "390"
  38297. bp.StmtBegndate = start_time
  38298. bp.ClrType = clr_type
  38299. bp.SetlOptins = clr_org
  38300. bp.StmtEnddate = end_time
  38301. bps = append(bps, &bp)
  38302. data := make(map[string]interface{})
  38303. data["bps"] = bps
  38304. data["org_name"] = miConfig.OrgName
  38305. data["doctor"] = role.UserName
  38306. data["fixmedins_code"] = miConfig.Code
  38307. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38308. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38309. if miConfig.MdtrtareaAdmvs == "421300" {
  38310. client := &http.Client{}
  38311. bytesData, _ := json.Marshal(data)
  38312. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38313. resp, _ := client.Do(req)
  38314. defer resp.Body.Close()
  38315. body, ioErr := ioutil.ReadAll(resp.Body)
  38316. if ioErr != nil {
  38317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38319. return
  38320. }
  38321. var respJSON map[string]interface{}
  38322. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38325. return
  38326. }
  38327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38328. userJSONBytes, _ := json.Marshal(respJSON)
  38329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38330. utils.ErrorLog("解析失败:%v", err)
  38331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38332. return
  38333. }
  38334. }
  38335. if miConfig.MdtrtareaAdmvs == "420200" {
  38336. client := &http.Client{}
  38337. bytesData, _ := json.Marshal(data)
  38338. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38339. resp, _ := client.Do(req)
  38340. defer resp.Body.Close()
  38341. body, ioErr := ioutil.ReadAll(resp.Body)
  38342. if ioErr != nil {
  38343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38345. return
  38346. }
  38347. var respJSON map[string]interface{}
  38348. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38351. return
  38352. }
  38353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38354. userJSONBytes, _ := json.Marshal(respJSON)
  38355. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38356. utils.ErrorLog("解析失败:%v", err)
  38357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38358. return
  38359. }
  38360. }
  38361. if miConfig.MdtrtareaAdmvs == "421182" {
  38362. client := &http.Client{}
  38363. bytesData, _ := json.Marshal(data)
  38364. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38365. resp, _ := client.Do(req)
  38366. defer resp.Body.Close()
  38367. body, ioErr := ioutil.ReadAll(resp.Body)
  38368. if ioErr != nil {
  38369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38371. return
  38372. }
  38373. var respJSON map[string]interface{}
  38374. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38377. return
  38378. }
  38379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38380. userJSONBytes, _ := json.Marshal(respJSON)
  38381. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38382. utils.ErrorLog("解析失败:%v", err)
  38383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38384. return
  38385. }
  38386. }
  38387. if res.Infcode == 0 {
  38388. c.ServeSuccessJSON(map[string]interface{}{
  38389. "msg": "发起成功",
  38390. })
  38391. } else {
  38392. c.ServeSuccessJSON(map[string]interface{}{
  38393. "failed_code": -10,
  38394. "msg": res.ErrMsg,
  38395. })
  38396. }
  38397. }
  38398. }
  38399. func (c *HisApiController) Post1608() {
  38400. start_time := c.GetString("start_time")
  38401. end_time := c.GetString("end_time")
  38402. admin_user_id, _ := c.GetInt64("admin_user_id")
  38403. adminUser := c.GetAdminUserInfo()
  38404. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38405. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38406. timeLayout := "2006-01-02"
  38407. loc, _ := time.LoadLocation("Local")
  38408. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38409. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38410. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38411. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38412. fixmedins_setl_cnt := int64(len(orders))
  38413. var medfee_sumamt float64
  38414. var func_smamt float64
  38415. for _, item := range orders {
  38416. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38417. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38418. }
  38419. times := strings.Split(start_time, "-")
  38420. time_tows := strings.Split(end_time, "-")
  38421. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38422. var res ResultSix
  38423. if config.IsOpen == 1 {
  38424. //var bps []*models.BusinessParamsTwo
  38425. //var bp models.BusinessParamsTwo
  38426. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38427. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38428. data := make(map[string]interface{})
  38429. data["org_name"] = miConfig.OrgName
  38430. data["doctor"] = role.UserName
  38431. data["func_smamt"] = func_smamt_str
  38432. data["fixmedins_code"] = miConfig.Code
  38433. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38434. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38435. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38436. data["medfee_sumamt"] = medfee_sumamt_str
  38437. data["start_time"] = times[0] + times[1] + times[2]
  38438. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38439. if miConfig.MdtrtareaAdmvs == "421300" {
  38440. client := &http.Client{}
  38441. bytesData, _ := json.Marshal(data)
  38442. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38443. resp, _ := client.Do(req)
  38444. defer resp.Body.Close()
  38445. body, ioErr := ioutil.ReadAll(resp.Body)
  38446. if ioErr != nil {
  38447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38449. return
  38450. }
  38451. var respJSON map[string]interface{}
  38452. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38455. return
  38456. }
  38457. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38458. userJSONBytes, _ := json.Marshal(respJSON)
  38459. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38460. utils.ErrorLog("解析失败:%v", err)
  38461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38462. return
  38463. }
  38464. }
  38465. if miConfig.MdtrtareaAdmvs == "420200" {
  38466. client := &http.Client{}
  38467. bytesData, _ := json.Marshal(data)
  38468. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38469. resp, _ := client.Do(req)
  38470. defer resp.Body.Close()
  38471. body, ioErr := ioutil.ReadAll(resp.Body)
  38472. if ioErr != nil {
  38473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38475. return
  38476. }
  38477. var respJSON map[string]interface{}
  38478. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38481. return
  38482. }
  38483. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38484. userJSONBytes, _ := json.Marshal(respJSON)
  38485. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38486. utils.ErrorLog("解析失败:%v", err)
  38487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38488. return
  38489. }
  38490. }
  38491. if miConfig.MdtrtareaAdmvs == "421182" {
  38492. client := &http.Client{}
  38493. bytesData, _ := json.Marshal(data)
  38494. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38495. resp, _ := client.Do(req)
  38496. defer resp.Body.Close()
  38497. body, ioErr := ioutil.ReadAll(resp.Body)
  38498. if ioErr != nil {
  38499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38501. return
  38502. }
  38503. var respJSON map[string]interface{}
  38504. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38507. return
  38508. }
  38509. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38510. userJSONBytes, _ := json.Marshal(respJSON)
  38511. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38512. utils.ErrorLog("解析失败:%v", err)
  38513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38514. return
  38515. }
  38516. }
  38517. if res.Infcode == 0 {
  38518. c.ServeSuccessJSON(map[string]interface{}{
  38519. "msg": "发起成功",
  38520. })
  38521. } else {
  38522. c.ServeSuccessJSON(map[string]interface{}{
  38523. "failed_code": -10,
  38524. "msg": res.ErrMsg,
  38525. })
  38526. }
  38527. }
  38528. }
  38529. // 5.11.1.1【5262】结算信息按时间段查询
  38530. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38531. admin_user_id, _ := c.GetInt64("admin_user_id")
  38532. adminUser := c.GetAdminUserInfo()
  38533. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38534. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38535. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38536. var res Result5262
  38537. if config.IsOpen == 1 {
  38538. if miConfig.MdtrtareaAdmvs == "421300" {
  38539. data := make(map[string]interface{})
  38540. data["bps"] = bp
  38541. data["org_name"] = miConfig.OrgName
  38542. data["doctor"] = role.UserName
  38543. data["fixmedins_code"] = miConfig.Code
  38544. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38545. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38546. data["page"] = strconv.FormatInt(page, 10)
  38547. data["limit"] = strconv.FormatInt(limit, 10)
  38548. fmt.Println(data)
  38549. client := &http.Client{}
  38550. bytesData, _ := json.Marshal(data)
  38551. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38552. resp, _ := client.Do(req)
  38553. defer resp.Body.Close()
  38554. body, ioErr := ioutil.ReadAll(resp.Body)
  38555. if ioErr != nil {
  38556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38558. return
  38559. }
  38560. var respJSON map[string]interface{}
  38561. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38564. return
  38565. }
  38566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38567. userJSONBytes, _ := json.Marshal(respJSON)
  38568. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38569. utils.ErrorLog("解析失败:%v", err)
  38570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38571. return
  38572. }
  38573. }
  38574. if miConfig.MdtrtareaAdmvs == "420200" {
  38575. data := make(map[string]interface{})
  38576. data["bps"] = bp
  38577. data["org_name"] = miConfig.OrgName
  38578. data["doctor"] = role.UserName
  38579. data["fixmedins_code"] = miConfig.Code
  38580. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38581. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38582. data["page"] = strconv.FormatInt(page, 10)
  38583. data["limit"] = strconv.FormatInt(limit, 10)
  38584. fmt.Println(data)
  38585. client := &http.Client{}
  38586. bytesData, _ := json.Marshal(data)
  38587. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38588. resp, _ := client.Do(req)
  38589. defer resp.Body.Close()
  38590. body, ioErr := ioutil.ReadAll(resp.Body)
  38591. if ioErr != nil {
  38592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38594. return
  38595. }
  38596. var respJSON map[string]interface{}
  38597. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38600. return
  38601. }
  38602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38603. userJSONBytes, _ := json.Marshal(respJSON)
  38604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38605. utils.ErrorLog("解析失败:%v", err)
  38606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38607. return
  38608. }
  38609. }
  38610. if miConfig.MdtrtareaAdmvs == "421182" {
  38611. data := make(map[string]interface{})
  38612. data["bps"] = bp
  38613. data["org_name"] = miConfig.OrgName
  38614. data["doctor"] = role.UserName
  38615. data["fixmedins_code"] = miConfig.Code
  38616. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38617. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38618. data["page"] = strconv.FormatInt(page, 10)
  38619. data["limit"] = strconv.FormatInt(limit, 10)
  38620. fmt.Println(data)
  38621. client := &http.Client{}
  38622. bytesData, _ := json.Marshal(data)
  38623. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38624. resp, _ := client.Do(req)
  38625. defer resp.Body.Close()
  38626. body, ioErr := ioutil.ReadAll(resp.Body)
  38627. if ioErr != nil {
  38628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38630. return
  38631. }
  38632. var respJSON map[string]interface{}
  38633. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38636. return
  38637. }
  38638. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38639. userJSONBytes, _ := json.Marshal(respJSON)
  38640. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38641. utils.ErrorLog("解析失败:%v", err)
  38642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38643. return
  38644. }
  38645. }
  38646. if miConfig.MdtrtareaAdmvs == "420902" {
  38647. data := make(map[string]interface{})
  38648. data["bps"] = bp
  38649. data["org_name"] = miConfig.OrgName
  38650. data["doctor"] = role.UserName
  38651. data["fixmedins_code"] = miConfig.Code
  38652. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38653. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38654. data["page"] = strconv.FormatInt(page, 10)
  38655. data["limit"] = strconv.FormatInt(limit, 10)
  38656. fmt.Println(data)
  38657. client := &http.Client{}
  38658. bytesData, _ := json.Marshal(data)
  38659. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38660. resp, _ := client.Do(req)
  38661. defer resp.Body.Close()
  38662. body, ioErr := ioutil.ReadAll(resp.Body)
  38663. if ioErr != nil {
  38664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38666. return
  38667. }
  38668. var respJSON map[string]interface{}
  38669. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38672. return
  38673. }
  38674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38675. userJSONBytes, _ := json.Marshal(respJSON)
  38676. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38677. utils.ErrorLog("解析失败:%v", err)
  38678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38679. return
  38680. }
  38681. }
  38682. if res.Infcode == 0 {
  38683. c.ServeSuccessJSON(map[string]interface{}{
  38684. "order": res.Output.Result,
  38685. "total": res.Output.PageInfo.RecordCounts,
  38686. })
  38687. } else {
  38688. c.ServeSuccessJSON(map[string]interface{}{
  38689. "failed_code": -10,
  38690. "msg": res.ErrMsg,
  38691. })
  38692. }
  38693. }
  38694. }
  38695. // 5.11.1.2【5267】异地结算信息时间段查询
  38696. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38697. admin_user_id, _ := c.GetInt64("admin_user_id")
  38698. adminUser := c.GetAdminUserInfo()
  38699. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38700. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38701. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38702. var res Result5267
  38703. if config.IsOpen == 1 {
  38704. if miConfig.MdtrtareaAdmvs == "421300" {
  38705. data := make(map[string]interface{})
  38706. data["bps"] = bp
  38707. data["org_name"] = miConfig.OrgName
  38708. data["doctor"] = role.UserName
  38709. data["fixmedins_code"] = miConfig.Code
  38710. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38711. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38712. data["page"] = page
  38713. data["limit"] = limit
  38714. fmt.Println(data)
  38715. client := &http.Client{}
  38716. bytesData, _ := json.Marshal(data)
  38717. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38718. resp, _ := client.Do(req)
  38719. defer resp.Body.Close()
  38720. body, ioErr := ioutil.ReadAll(resp.Body)
  38721. if ioErr != nil {
  38722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38724. return
  38725. }
  38726. var respJSON map[string]interface{}
  38727. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38730. return
  38731. }
  38732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38733. userJSONBytes, _ := json.Marshal(respJSON)
  38734. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38735. utils.ErrorLog("解析失败:%v", err)
  38736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38737. return
  38738. }
  38739. }
  38740. if miConfig.MdtrtareaAdmvs == "420200" {
  38741. data := make(map[string]interface{})
  38742. data["bps"] = bp
  38743. data["org_name"] = miConfig.OrgName
  38744. data["doctor"] = role.UserName
  38745. data["fixmedins_code"] = miConfig.Code
  38746. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38747. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38748. data["page"] = page
  38749. data["limit"] = limit
  38750. fmt.Println(data)
  38751. client := &http.Client{}
  38752. bytesData, _ := json.Marshal(data)
  38753. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38754. resp, _ := client.Do(req)
  38755. defer resp.Body.Close()
  38756. body, ioErr := ioutil.ReadAll(resp.Body)
  38757. if ioErr != nil {
  38758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38760. return
  38761. }
  38762. var respJSON map[string]interface{}
  38763. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38766. return
  38767. }
  38768. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38769. userJSONBytes, _ := json.Marshal(respJSON)
  38770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38771. utils.ErrorLog("解析失败:%v", err)
  38772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38773. return
  38774. }
  38775. }
  38776. if miConfig.MdtrtareaAdmvs == "421182" {
  38777. data := make(map[string]interface{})
  38778. data["bps"] = bp
  38779. data["org_name"] = miConfig.OrgName
  38780. data["doctor"] = role.UserName
  38781. data["fixmedins_code"] = miConfig.Code
  38782. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38783. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38784. data["page"] = page
  38785. data["limit"] = limit
  38786. fmt.Println(data)
  38787. client := &http.Client{}
  38788. bytesData, _ := json.Marshal(data)
  38789. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38790. resp, _ := client.Do(req)
  38791. defer resp.Body.Close()
  38792. body, ioErr := ioutil.ReadAll(resp.Body)
  38793. if ioErr != nil {
  38794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38796. return
  38797. }
  38798. var respJSON map[string]interface{}
  38799. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38802. return
  38803. }
  38804. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38805. userJSONBytes, _ := json.Marshal(respJSON)
  38806. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38807. utils.ErrorLog("解析失败:%v", err)
  38808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38809. return
  38810. }
  38811. }
  38812. if res.Infcode == 0 {
  38813. c.ServeSuccessJSON(map[string]interface{}{
  38814. "order": res.Output.Result,
  38815. "total": res.Output.PageInfo.RecordCounts,
  38816. })
  38817. } else {
  38818. c.ServeSuccessJSON(map[string]interface{}{
  38819. "failed_code": -10,
  38820. "msg": res.ErrMsg,
  38821. })
  38822. }
  38823. }
  38824. }
  38825. func (c *HisApiController) Post3501() {
  38826. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38827. data := make(map[string]interface{})
  38828. var struct3501s []models.Struct3501
  38829. var struct3501 models.Struct3501
  38830. struct3501.OrgName = miConfig.OrgName
  38831. struct3501.AccessKey = miConfig.AccessKey
  38832. struct3501.RequestUrl = miConfig.Url
  38833. struct3501.SecretKey = miConfig.SecretKey
  38834. struct3501.ManuDate = "2022-08-17"
  38835. struct3501.FixmedinsBchno = ""
  38836. struct3501.ManuLotnum = ""
  38837. struct3501.RxFlag = "0"
  38838. struct3501.ExpyEnd = "2022-08-17"
  38839. struct3501.Invdate = "2022-08-17"
  38840. struct3501.InvCnt = "20.25"
  38841. struct3501.Memo = ""
  38842. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38843. struct3501.FixmedinsHilistId = miConfig.Code
  38844. struct3501.FixmedinsHilistName = miConfig.OrgName
  38845. struct3501s = append(struct3501s, struct3501)
  38846. data["struct_3501s"] = struct3501s
  38847. client := &http.Client{}
  38848. bytesData, _ := json.Marshal(data)
  38849. var req *http.Request
  38850. if miConfig.MdtrtareaAdmvs == "320921" {
  38851. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38852. } else {
  38853. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38854. }
  38855. resp, _ := client.Do(req)
  38856. defer resp.Body.Close()
  38857. body, ioErr := ioutil.ReadAll(resp.Body)
  38858. if ioErr != nil {
  38859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38861. return
  38862. }
  38863. var respJSON map[string]interface{}
  38864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38867. return
  38868. }
  38869. var res ResultSix
  38870. var resSix10265 ResultSix10265 //1101结果
  38871. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38872. result, _ := json.Marshal(respJSON)
  38873. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38874. utils.ErrorLog("解析失败:%v", err)
  38875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38876. return
  38877. }
  38878. res.InfRefmsgid = resSix10265.InfRefmsgid
  38879. res.Output = resSix10265.Output
  38880. res.ErrMsg = resSix10265.ErrMsg
  38881. res.Cainfo = resSix10265.Cainfo
  38882. res.WarnMsg = resSix10265.WarnMsg
  38883. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38884. res.Infcode = infocode
  38885. if infocode == 0 {
  38886. c.ServeSuccessJSON(map[string]interface{}{
  38887. "msg": "上传成功",
  38888. })
  38889. return
  38890. } else {
  38891. c.ServeSuccessJSON(map[string]interface{}{
  38892. "failed_code": -10,
  38893. "msg": res.ErrMsg,
  38894. })
  38895. return
  38896. }
  38897. }
  38898. func (c *HisApiController) Post3502() {
  38899. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38900. data := make(map[string]interface{})
  38901. var struct3502s []models.Struct3502
  38902. var struct3502 models.Struct3502
  38903. struct3502.OrgName = miConfig.OrgName
  38904. struct3502.AccessKey = miConfig.AccessKey
  38905. struct3502.RequestUrl = miConfig.Url
  38906. struct3502.SecretKey = miConfig.SecretKey
  38907. struct3502.ManuDate = "2022-08-15"
  38908. struct3502.FixmedinsBchno = ""
  38909. struct3502.ManuLotnum = ""
  38910. struct3502.RxFlag = "0"
  38911. struct3502.ExpyEnd = "2022-08-15"
  38912. struct3502.Invdate = "2022-08-15"
  38913. struct3502.InvCnt = "20.25"
  38914. struct3502.Memo = ""
  38915. struct3502.MedListCodg = "XB01ABD056B002020200517"
  38916. struct3502.FixmedinsHilistId = miConfig.Code
  38917. struct3502.FixmedinsHilistName = miConfig.OrgName
  38918. struct3502s = append(struct3502s, struct3502)
  38919. data["struct_3502s"] = struct3502s
  38920. client := &http.Client{}
  38921. bytesData, _ := json.Marshal(data)
  38922. var req *http.Request
  38923. if miConfig.MdtrtareaAdmvs == "320921" {
  38924. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38925. } else {
  38926. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38927. }
  38928. resp, _ := client.Do(req)
  38929. defer resp.Body.Close()
  38930. body, ioErr := ioutil.ReadAll(resp.Body)
  38931. if ioErr != nil {
  38932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38934. return
  38935. }
  38936. var respJSON map[string]interface{}
  38937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38940. return
  38941. }
  38942. var res ResultSix
  38943. var resSix10265 ResultSix10265 //1101结果
  38944. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38945. result, _ := json.Marshal(respJSON)
  38946. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38947. utils.ErrorLog("解析失败:%v", err)
  38948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38949. return
  38950. }
  38951. res.InfRefmsgid = resSix10265.InfRefmsgid
  38952. res.Output = resSix10265.Output
  38953. res.ErrMsg = resSix10265.ErrMsg
  38954. res.Cainfo = resSix10265.Cainfo
  38955. res.WarnMsg = resSix10265.WarnMsg
  38956. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38957. res.Infcode = infocode
  38958. if infocode == 0 {
  38959. c.ServeSuccessJSON(map[string]interface{}{
  38960. "msg": "上传成功",
  38961. })
  38962. return
  38963. } else {
  38964. c.ServeSuccessJSON(map[string]interface{}{
  38965. "failed_code": -10,
  38966. "msg": res.ErrMsg,
  38967. })
  38968. return
  38969. }
  38970. }
  38971. func (c *HisApiController) Post3503() {
  38972. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38973. data := make(map[string]interface{})
  38974. var struct3501s []models.Struct3501
  38975. var struct3501 models.Struct3501
  38976. struct3501.OrgName = miConfig.OrgName
  38977. struct3501.AccessKey = miConfig.AccessKey
  38978. struct3501.RequestUrl = miConfig.Url
  38979. struct3501.SecretKey = miConfig.SecretKey
  38980. struct3501.ManuDate = "2022-08-15"
  38981. struct3501.FixmedinsBchno = ""
  38982. struct3501.ManuLotnum = ""
  38983. struct3501.RxFlag = "0"
  38984. struct3501.ExpyEnd = "2022-08-15"
  38985. struct3501.Invdate = "2022-08-15"
  38986. struct3501.InvCnt = "20.25"
  38987. struct3501.Memo = ""
  38988. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38989. struct3501.FixmedinsHilistId = miConfig.Code
  38990. struct3501.FixmedinsHilistName = miConfig.OrgName
  38991. struct3501s = append(struct3501s, struct3501)
  38992. data["struct_3501s"] = struct3501s
  38993. client := &http.Client{}
  38994. bytesData, _ := json.Marshal(data)
  38995. var req *http.Request
  38996. if miConfig.MdtrtareaAdmvs == "320921" {
  38997. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38998. } else {
  38999. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39000. }
  39001. resp, _ := client.Do(req)
  39002. defer resp.Body.Close()
  39003. body, ioErr := ioutil.ReadAll(resp.Body)
  39004. if ioErr != nil {
  39005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39007. return
  39008. }
  39009. var respJSON map[string]interface{}
  39010. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39013. return
  39014. }
  39015. var res ResultSix
  39016. var resSix10265 ResultSix10265 //1101结果
  39017. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39018. result, _ := json.Marshal(respJSON)
  39019. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39020. utils.ErrorLog("解析失败:%v", err)
  39021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39022. return
  39023. }
  39024. res.InfRefmsgid = resSix10265.InfRefmsgid
  39025. res.Output = resSix10265.Output
  39026. res.ErrMsg = resSix10265.ErrMsg
  39027. res.Cainfo = resSix10265.Cainfo
  39028. res.WarnMsg = resSix10265.WarnMsg
  39029. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39030. res.Infcode = infocode
  39031. if infocode == 0 {
  39032. c.ServeSuccessJSON(map[string]interface{}{
  39033. "msg": "上传成功",
  39034. })
  39035. return
  39036. } else {
  39037. c.ServeSuccessJSON(map[string]interface{}{
  39038. "failed_code": -10,
  39039. "msg": res.ErrMsg,
  39040. })
  39041. return
  39042. }
  39043. }
  39044. func (c *HisApiController) Post3504() {
  39045. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39046. data := make(map[string]interface{})
  39047. var struct3501s []models.Struct3501
  39048. var struct3501 models.Struct3501
  39049. struct3501.OrgName = miConfig.OrgName
  39050. struct3501.AccessKey = miConfig.AccessKey
  39051. struct3501.RequestUrl = miConfig.Url
  39052. struct3501.SecretKey = miConfig.SecretKey
  39053. struct3501.ManuDate = "2022-08-15"
  39054. struct3501.FixmedinsBchno = ""
  39055. struct3501.ManuLotnum = ""
  39056. struct3501.RxFlag = "0"
  39057. struct3501.ExpyEnd = "2022-08-15"
  39058. struct3501.Invdate = "2022-08-15"
  39059. struct3501.InvCnt = "20.25"
  39060. struct3501.Memo = ""
  39061. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39062. struct3501.FixmedinsHilistId = miConfig.Code
  39063. struct3501.FixmedinsHilistName = miConfig.OrgName
  39064. struct3501s = append(struct3501s, struct3501)
  39065. data["struct_3501s"] = struct3501s
  39066. client := &http.Client{}
  39067. bytesData, _ := json.Marshal(data)
  39068. var req *http.Request
  39069. if miConfig.MdtrtareaAdmvs == "320921" {
  39070. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39071. } else {
  39072. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39073. }
  39074. resp, _ := client.Do(req)
  39075. defer resp.Body.Close()
  39076. body, ioErr := ioutil.ReadAll(resp.Body)
  39077. if ioErr != nil {
  39078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39080. return
  39081. }
  39082. var respJSON map[string]interface{}
  39083. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39086. return
  39087. }
  39088. var res ResultSix
  39089. var resSix10265 ResultSix10265 //1101结果
  39090. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39091. result, _ := json.Marshal(respJSON)
  39092. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39093. utils.ErrorLog("解析失败:%v", err)
  39094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39095. return
  39096. }
  39097. res.InfRefmsgid = resSix10265.InfRefmsgid
  39098. res.Output = resSix10265.Output
  39099. res.ErrMsg = resSix10265.ErrMsg
  39100. res.Cainfo = resSix10265.Cainfo
  39101. res.WarnMsg = resSix10265.WarnMsg
  39102. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39103. res.Infcode = infocode
  39104. if infocode == 0 {
  39105. c.ServeSuccessJSON(map[string]interface{}{
  39106. "msg": "上传成功",
  39107. })
  39108. return
  39109. } else {
  39110. c.ServeSuccessJSON(map[string]interface{}{
  39111. "failed_code": -10,
  39112. "msg": res.ErrMsg,
  39113. })
  39114. return
  39115. }
  39116. }
  39117. func (c *HisApiController) Post3505() {
  39118. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39119. data := make(map[string]interface{})
  39120. var struct3501s []models.Struct3501
  39121. var struct3501 models.Struct3501
  39122. struct3501.OrgName = miConfig.OrgName
  39123. struct3501.AccessKey = miConfig.AccessKey
  39124. struct3501.RequestUrl = miConfig.Url
  39125. struct3501.SecretKey = miConfig.SecretKey
  39126. struct3501.ManuDate = "2022-08-15"
  39127. struct3501.FixmedinsBchno = ""
  39128. struct3501.ManuLotnum = ""
  39129. struct3501.RxFlag = "0"
  39130. struct3501.ExpyEnd = "2022-08-15"
  39131. struct3501.Invdate = "2022-08-15"
  39132. struct3501.InvCnt = "20.25"
  39133. struct3501.Memo = ""
  39134. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39135. struct3501.FixmedinsHilistId = miConfig.Code
  39136. struct3501.FixmedinsHilistName = miConfig.OrgName
  39137. struct3501s = append(struct3501s, struct3501)
  39138. data["struct_3501s"] = struct3501s
  39139. client := &http.Client{}
  39140. bytesData, _ := json.Marshal(data)
  39141. var req *http.Request
  39142. if miConfig.MdtrtareaAdmvs == "320921" {
  39143. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39144. } else {
  39145. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39146. }
  39147. resp, _ := client.Do(req)
  39148. defer resp.Body.Close()
  39149. body, ioErr := ioutil.ReadAll(resp.Body)
  39150. if ioErr != nil {
  39151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39153. return
  39154. }
  39155. var respJSON map[string]interface{}
  39156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39159. return
  39160. }
  39161. var res ResultSix
  39162. var resSix10265 ResultSix10265 //1101结果
  39163. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39164. result, _ := json.Marshal(respJSON)
  39165. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39166. utils.ErrorLog("解析失败:%v", err)
  39167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39168. return
  39169. }
  39170. res.InfRefmsgid = resSix10265.InfRefmsgid
  39171. res.Output = resSix10265.Output
  39172. res.ErrMsg = resSix10265.ErrMsg
  39173. res.Cainfo = resSix10265.Cainfo
  39174. res.WarnMsg = resSix10265.WarnMsg
  39175. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39176. res.Infcode = infocode
  39177. if infocode == 0 {
  39178. c.ServeSuccessJSON(map[string]interface{}{
  39179. "msg": "上传成功",
  39180. })
  39181. return
  39182. } else {
  39183. c.ServeSuccessJSON(map[string]interface{}{
  39184. "failed_code": -10,
  39185. "msg": res.ErrMsg,
  39186. })
  39187. return
  39188. }
  39189. }
  39190. func (c *HisApiController) Post3506() {
  39191. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39192. data := make(map[string]interface{})
  39193. var struct3501s []models.Struct3501
  39194. var struct3501 models.Struct3501
  39195. struct3501.OrgName = miConfig.OrgName
  39196. struct3501.AccessKey = miConfig.AccessKey
  39197. struct3501.RequestUrl = miConfig.Url
  39198. struct3501.SecretKey = miConfig.SecretKey
  39199. struct3501.ManuDate = "2022-08-15"
  39200. struct3501.FixmedinsBchno = ""
  39201. struct3501.ManuLotnum = ""
  39202. struct3501.RxFlag = "0"
  39203. struct3501.ExpyEnd = "2022-08-15"
  39204. struct3501.Invdate = "2022-08-15"
  39205. struct3501.InvCnt = "20.25"
  39206. struct3501.Memo = ""
  39207. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39208. struct3501.FixmedinsHilistId = miConfig.Code
  39209. struct3501.FixmedinsHilistName = miConfig.OrgName
  39210. struct3501s = append(struct3501s, struct3501)
  39211. data["struct_3501s"] = struct3501s
  39212. client := &http.Client{}
  39213. bytesData, _ := json.Marshal(data)
  39214. var req *http.Request
  39215. if miConfig.MdtrtareaAdmvs == "320921" {
  39216. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39217. } else {
  39218. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39219. }
  39220. resp, _ := client.Do(req)
  39221. defer resp.Body.Close()
  39222. body, ioErr := ioutil.ReadAll(resp.Body)
  39223. if ioErr != nil {
  39224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39226. return
  39227. }
  39228. var respJSON map[string]interface{}
  39229. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39232. return
  39233. }
  39234. var res ResultSix
  39235. var resSix10265 ResultSix10265 //1101结果
  39236. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39237. result, _ := json.Marshal(respJSON)
  39238. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39239. utils.ErrorLog("解析失败:%v", err)
  39240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39241. return
  39242. }
  39243. res.InfRefmsgid = resSix10265.InfRefmsgid
  39244. res.Output = resSix10265.Output
  39245. res.ErrMsg = resSix10265.ErrMsg
  39246. res.Cainfo = resSix10265.Cainfo
  39247. res.WarnMsg = resSix10265.WarnMsg
  39248. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39249. res.Infcode = infocode
  39250. if infocode == 0 {
  39251. c.ServeSuccessJSON(map[string]interface{}{
  39252. "msg": "上传成功",
  39253. })
  39254. return
  39255. } else {
  39256. c.ServeSuccessJSON(map[string]interface{}{
  39257. "failed_code": -10,
  39258. "msg": res.ErrMsg,
  39259. })
  39260. return
  39261. }
  39262. }
  39263. func (c *HisApiController) Post3507() {
  39264. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39265. data := make(map[string]interface{})
  39266. var struct3501s []models.Struct3501
  39267. var struct3501 models.Struct3501
  39268. struct3501.OrgName = miConfig.OrgName
  39269. struct3501.AccessKey = miConfig.AccessKey
  39270. struct3501.RequestUrl = miConfig.Url
  39271. struct3501.SecretKey = miConfig.SecretKey
  39272. struct3501.ManuDate = "2022-08-15"
  39273. struct3501.FixmedinsBchno = ""
  39274. struct3501.ManuLotnum = ""
  39275. struct3501.RxFlag = "0"
  39276. struct3501.ExpyEnd = "2022-08-15"
  39277. struct3501.Invdate = "2022-08-15"
  39278. struct3501.InvCnt = "20.25"
  39279. struct3501.Memo = ""
  39280. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39281. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39282. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39283. struct3501s = append(struct3501s, struct3501)
  39284. data["struct_3501s"] = struct3501s
  39285. client := &http.Client{}
  39286. bytesData, _ := json.Marshal(data)
  39287. var req *http.Request
  39288. if miConfig.MdtrtareaAdmvs == "320921" {
  39289. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39290. } else {
  39291. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39292. }
  39293. resp, _ := client.Do(req)
  39294. defer resp.Body.Close()
  39295. body, ioErr := ioutil.ReadAll(resp.Body)
  39296. if ioErr != nil {
  39297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39299. return
  39300. }
  39301. var respJSON map[string]interface{}
  39302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39305. return
  39306. }
  39307. var res ResultSix
  39308. var resSix10265 ResultSix10265 //1101结果
  39309. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39310. result, _ := json.Marshal(respJSON)
  39311. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39312. utils.ErrorLog("解析失败:%v", err)
  39313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39314. return
  39315. }
  39316. res.InfRefmsgid = resSix10265.InfRefmsgid
  39317. res.Output = resSix10265.Output
  39318. res.ErrMsg = resSix10265.ErrMsg
  39319. res.Cainfo = resSix10265.Cainfo
  39320. res.WarnMsg = resSix10265.WarnMsg
  39321. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39322. res.Infcode = infocode
  39323. if infocode == 0 {
  39324. c.ServeSuccessJSON(map[string]interface{}{
  39325. "msg": "上传成功",
  39326. })
  39327. return
  39328. } else {
  39329. c.ServeSuccessJSON(map[string]interface{}{
  39330. "failed_code": -10,
  39331. "msg": res.ErrMsg,
  39332. })
  39333. return
  39334. }
  39335. }
  39336. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39337. // WebSocket服务器地址
  39338. serverURL := "ws://127.0.0.1:8899"
  39339. // 解析WebSocket服务器地址
  39340. u, err := url.Parse(serverURL)
  39341. if err != nil {
  39342. }
  39343. // 建立WebSocket连接
  39344. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39345. if err != nil {
  39346. }
  39347. defer conn.Close()
  39348. input2 := make(map[string]interface{})
  39349. input := make(map[string]interface{})
  39350. inputData := make(map[string]interface{})
  39351. inputData["orgId"] = code
  39352. inputData["businessType"] = "01101"
  39353. inputData["operatorId"] = operator_id
  39354. inputData["operatorName"] = operator_name
  39355. inputData["officeId"] = "001"
  39356. inputData["officeName"] = "血透室"
  39357. inputData["deviceType"] = ""
  39358. input["data"] = inputData
  39359. input["orgId"] = code
  39360. input["transType"] = "ec.query"
  39361. //if md == ""
  39362. if md[:4] == "4403" {
  39363. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39364. } else if md[:4] == "4401" {
  39365. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39366. } else {
  39367. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39368. }
  39369. input2["indata"] = input
  39370. fmt.Println(input2)
  39371. bytesData, _ := json.Marshal(input2)
  39372. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39373. if err != nil {
  39374. fmt.Println(err)
  39375. }
  39376. // 接收消息
  39377. _, receivedMessage, err := conn.ReadMessage()
  39378. if err != nil {
  39379. fmt.Println(err)
  39380. }
  39381. return "", string(receivedMessage)
  39382. }
  39383. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39384. // WebSocket服务器地址
  39385. serverURL := "ws://127.0.0.1:8899"
  39386. // 解析WebSocket服务器地址
  39387. u, err := url.Parse(serverURL)
  39388. if err != nil {
  39389. }
  39390. // 建立WebSocket连接
  39391. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39392. if err != nil {
  39393. }
  39394. defer conn.Close()
  39395. input2 := make(map[string]interface{})
  39396. input := make(map[string]interface{})
  39397. inputData := make(map[string]interface{})
  39398. inputData["orgId"] = code
  39399. inputData["businessType"] = "01101"
  39400. inputData["operatorId"] = operator_id
  39401. inputData["operatorName"] = operator_name
  39402. inputData["officeId"] = "001"
  39403. inputData["officeName"] = "血透室"
  39404. inputData["deviceType"] = ""
  39405. input["data"] = inputData
  39406. input["orgId"] = code
  39407. input["transType"] = "ec.query"
  39408. //if md == ""
  39409. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39410. input2["indata"] = input
  39411. fmt.Println(input2)
  39412. bytesData, _ := json.Marshal(input2)
  39413. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39414. if err != nil {
  39415. fmt.Println(err)
  39416. }
  39417. // 接收消息
  39418. _, receivedMessage, err := conn.ReadMessage()
  39419. if err != nil {
  39420. fmt.Println(err)
  39421. }
  39422. return "", string(receivedMessage)
  39423. }
  39424. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39425. // WebSocket服务器地址
  39426. serverURL := "ws://127.0.0.1:8899"
  39427. // 解析WebSocket服务器地址
  39428. u, err := url.Parse(serverURL)
  39429. if err != nil {
  39430. }
  39431. // 建立WebSocket连接
  39432. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39433. if err != nil {
  39434. }
  39435. defer conn.Close()
  39436. input2 := make(map[string]interface{})
  39437. input := make(map[string]interface{})
  39438. inputData := make(map[string]interface{})
  39439. inputData["orgId"] = code
  39440. inputData["businessType"] = "01301"
  39441. inputData["operatorId"] = operator_id
  39442. inputData["operatorName"] = operator_name
  39443. inputData["officeId"] = "001"
  39444. inputData["officeName"] = "血透室"
  39445. inputData["deviceType"] = ""
  39446. input["data"] = inputData
  39447. input["orgId"] = code
  39448. input["transType"] = "ec.query"
  39449. //if md == ""
  39450. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39451. input2["indata"] = input
  39452. fmt.Println(input2)
  39453. bytesData, _ := json.Marshal(input2)
  39454. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39455. if err != nil {
  39456. fmt.Println(err)
  39457. }
  39458. // 接收消息
  39459. _, receivedMessage, err := conn.ReadMessage()
  39460. if err != nil {
  39461. fmt.Println(err)
  39462. }
  39463. return "", string(receivedMessage)
  39464. }
  39465. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39466. // WebSocket服务器地址
  39467. serverURL := "ws://127.0.0.1:8899"
  39468. // 解析WebSocket服务器地址
  39469. u, err := url.Parse(serverURL)
  39470. if err != nil {
  39471. }
  39472. // 建立WebSocket连接
  39473. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39474. if err != nil {
  39475. }
  39476. defer conn.Close()
  39477. input2 := make(map[string]interface{})
  39478. input := make(map[string]interface{})
  39479. inputData := make(map[string]interface{})
  39480. inputData["orgId"] = code
  39481. inputData["businessType"] = "01103"
  39482. inputData["operatorId"] = operator_id
  39483. inputData["operatorName"] = operator_name
  39484. inputData["officeId"] = "001"
  39485. inputData["officeName"] = "血透室"
  39486. inputData["deviceType"] = ""
  39487. input["data"] = inputData
  39488. input["orgId"] = code
  39489. input["transType"] = "ec.query"
  39490. //if md ==
  39491. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39492. input2["indata"] = input
  39493. fmt.Println(input2)
  39494. bytesData, _ := json.Marshal(input2)
  39495. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39496. if err != nil {
  39497. fmt.Println(err)
  39498. }
  39499. // 接收消息
  39500. _, receivedMessage, err := conn.ReadMessage()
  39501. if err != nil {
  39502. fmt.Println(err)
  39503. }
  39504. return "", string(receivedMessage)
  39505. }
  39506. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39507. // WebSocket服务器地址
  39508. serverURL := "ws://127.0.0.1:8899"
  39509. // 解析WebSocket服务器地址
  39510. u, err := url.Parse(serverURL)
  39511. if err != nil {
  39512. }
  39513. // 建立WebSocket连接
  39514. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39515. if err != nil {
  39516. }
  39517. defer conn.Close()
  39518. input2 := make(map[string]interface{})
  39519. input := make(map[string]interface{})
  39520. inputData := make(map[string]interface{})
  39521. inputData["orgId"] = code
  39522. inputData["businessType"] = "01101"
  39523. inputData["operatorId"] = operator_id
  39524. inputData["operatorName"] = operator_name
  39525. inputData["officeId"] = "001"
  39526. inputData["officeName"] = "血透室"
  39527. inputData["deviceType"] = ""
  39528. input["data"] = inputData
  39529. input["orgId"] = code
  39530. input["transType"] = "ec.query"
  39531. //if md == ""
  39532. if md[:4] == "4403" {
  39533. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39534. } else if md[:4] == "4401" {
  39535. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39536. } else {
  39537. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39538. }
  39539. input2["indata"] = input
  39540. fmt.Println(input2)
  39541. bytesData, _ := json.Marshal(input2)
  39542. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39543. if err != nil {
  39544. fmt.Println(err)
  39545. }
  39546. // 接收消息
  39547. _, receivedMessage, err := conn.ReadMessage()
  39548. if err != nil {
  39549. fmt.Println(err)
  39550. }
  39551. return "", string(receivedMessage)
  39552. }
  39553. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39554. // WebSocket服务器地址
  39555. serverURL := "ws://127.0.0.1:8899"
  39556. // 解析WebSocket服务器地址
  39557. u, err := url.Parse(serverURL)
  39558. if err != nil {
  39559. }
  39560. // 建立WebSocket连接
  39561. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39562. if err != nil {
  39563. }
  39564. defer conn.Close()
  39565. input2 := make(map[string]interface{})
  39566. input := make(map[string]interface{})
  39567. inputData := make(map[string]interface{})
  39568. inputData["orgId"] = code
  39569. inputData["businessType"] = "01301"
  39570. inputData["operatorId"] = operator_id
  39571. inputData["operatorName"] = operator_name
  39572. inputData["officeId"] = "001"
  39573. inputData["officeName"] = "血透室"
  39574. inputData["deviceType"] = ""
  39575. input["data"] = inputData
  39576. input["orgId"] = code
  39577. input["transType"] = "ec.query"
  39578. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39579. input2["indata"] = input
  39580. bytesData, _ := json.Marshal(input2)
  39581. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39582. if err != nil {
  39583. fmt.Println(err)
  39584. }
  39585. // 接收消息
  39586. _, receivedMessage, err := conn.ReadMessage()
  39587. if err != nil {
  39588. fmt.Println(err)
  39589. }
  39590. return "", string(receivedMessage)
  39591. }
  39592. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39593. newArr = make([]string, 0)
  39594. for i := 0; i < len(arr); i++ {
  39595. repeat := false
  39596. for j := i + 1; j < len(arr); j++ {
  39597. if arr[i] == arr[j] {
  39598. repeat = true
  39599. break
  39600. }
  39601. }
  39602. if !repeat {
  39603. newArr = append(newArr, arr[i])
  39604. }
  39605. }
  39606. return
  39607. }
  39608. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39609. if len(idNumber) != 18 {
  39610. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39611. }
  39612. // 提取出生日期
  39613. year, err := strconv.Atoi(idNumber[6:10])
  39614. if err != nil {
  39615. return "", 0, err
  39616. }
  39617. month, err := strconv.Atoi(idNumber[10:12])
  39618. if err != nil {
  39619. return "", 0, err
  39620. }
  39621. day, err := strconv.Atoi(idNumber[12:14])
  39622. if err != nil {
  39623. return "", 0, err
  39624. }
  39625. // 格式化生日字符串
  39626. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39627. birthdateFormatted := birthdate.Format("2006-01-02")
  39628. // 计算年龄
  39629. today := time.Now()
  39630. age := today.Year() - birthdate.Year()
  39631. if today.YearDay() < birthdate.YearDay() {
  39632. age--
  39633. }
  39634. return birthdateFormatted, age, nil
  39635. }
  39636. // 从身份证号码中提取出生年月日
  39637. func getBirthDateFromIDCard(idCard string) (string, error) {
  39638. // 身份证号码长度应为18位
  39639. if len(idCard) != 18 {
  39640. return "", fmt.Errorf("身份证号码长度应为18位")
  39641. }
  39642. // 提取出生日期部分 (YYYYMMDD)
  39643. birthDateStr := idCard[6:14]
  39644. // 解析出生日期
  39645. birthDate, err := time.Parse("20060102", birthDateStr)
  39646. if err != nil {
  39647. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39648. }
  39649. // 格式化出生日期为 YYYY-MM-DD
  39650. formattedDate := birthDate.Format("2006-01-02")
  39651. return formattedDate, nil
  39652. }