his_api_controller.go 1.6MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816
  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. )
  35. type HisApiController struct {
  36. controllers.BaseAuthAPIController
  37. }
  38. func HisManagerApiRegistRouters() {
  39. //挂号
  40. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  77. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  78. beego.Router("/api/check", &HisApiController{}, "get:Check")
  79. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  80. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  81. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  82. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  83. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  84. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  85. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  86. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  87. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  88. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  89. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  90. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  91. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  92. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  93. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  94. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  95. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  96. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  97. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  98. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  99. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  100. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  101. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  102. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  103. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  106. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  107. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  108. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  109. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  110. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  111. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  112. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  113. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  114. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  115. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  116. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  117. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  118. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  119. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  120. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  121. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  122. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  123. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  124. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  125. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  126. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  127. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  128. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  129. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  130. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  131. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  132. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  133. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  134. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  135. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  136. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  137. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  138. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  139. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  140. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  141. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  142. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  143. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  144. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  145. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  146. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  147. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  148. //库盘和变更
  149. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  150. //删除库盘和变更
  151. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  152. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  153. //药品变更
  154. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  155. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  156. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  157. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  158. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  159. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  160. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  161. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  162. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  163. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  164. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  165. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  166. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  167. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  168. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  169. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  170. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  171. }
  172. func (c *HisApiController) Get3201() {
  173. adminUser := c.GetAdminUserInfo()
  174. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  175. 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)
  176. var response Response
  177. if err := json.Unmarshal([]byte(result), &response); err != nil {
  178. fmt.Println("Error decoding JSON:", err)
  179. return
  180. }
  181. }
  182. func (c *HisApiController) TestNet() {
  183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  184. return
  185. //c.ServeSuccessJSON(map[string]interface{}{
  186. // "msg": "成功",
  187. //})
  188. }
  189. func (c *HisApiController) Get3508() {
  190. admin_user_id, _ := c.GetInt64("admin_user_id")
  191. drug_id, _ := c.GetInt64("id")
  192. start_time := c.GetString("start_time")
  193. end_time := c.GetString("end_time")
  194. adminUser := c.GetAdminUserInfo()
  195. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  196. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  197. drug, _ := service.GetDrugByID(drug_id)
  198. var struct3508 models.Struct3508
  199. struct3508.OrgName = miConfig.OrgName
  200. struct3508.FixmedinsCode = miConfig.Code
  201. struct3508.AccessKey = miConfig.AccessKey
  202. struct3508.Opter = curRoles.UserName
  203. struct3508.RequestUrl = miConfig.Url
  204. struct3508.Url = miConfig.Url
  205. struct3508.AppId = miConfig.Cainfo
  206. struct3508.AppSecret = miConfig.AppSecret
  207. struct3508.Enckey = miConfig.EncKey
  208. struct3508.SignKey = miConfig.SignKey
  209. struct3508.SecretKey = miConfig.SecretKey
  210. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  211. struct3508.Begndate = start_time
  212. struct3508.Enddate = end_time
  213. result1, result2, _ := service.FJyb3508(struct3508)
  214. saveLog(result1, result2, "3508", "3508")
  215. var res models.Result3508
  216. var respJSON2 map[string]interface{}
  217. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. userJSONBytes2, _ := json.Marshal(respJSON2)
  223. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  224. utils.ErrorLog("解析失败:%v", err)
  225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  226. return
  227. }
  228. if res.Infcode == -1 {
  229. c.ServeSuccessJSON(map[string]interface{}{
  230. "failed_code": -10,
  231. "msg": res.ErrMsg,
  232. })
  233. } else {
  234. c.ServeSuccessJSON(map[string]interface{}{
  235. "info": res.Output,
  236. })
  237. }
  238. }
  239. func (c *HisApiController) Get3509() {
  240. admin_user_id, _ := c.GetInt64("admin_user_id")
  241. drug_id, _ := c.GetInt64("id")
  242. start_time := c.GetString("start_time")
  243. end_time := c.GetString("end_time")
  244. adminUser := c.GetAdminUserInfo()
  245. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  246. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  247. drug, _ := service.GetDrugByID(drug_id)
  248. var struct3508 models.Struct3509
  249. struct3508.OrgName = miConfig.OrgName
  250. struct3508.FixmedinsCode = miConfig.Code
  251. struct3508.AccessKey = miConfig.AccessKey
  252. struct3508.Opter = curRoles.UserName
  253. struct3508.RequestUrl = miConfig.Url
  254. struct3508.Url = miConfig.Url
  255. struct3508.AppId = miConfig.Cainfo
  256. struct3508.AppSecret = miConfig.AppSecret
  257. struct3508.Enckey = miConfig.EncKey
  258. struct3508.SignKey = miConfig.SignKey
  259. struct3508.SecretKey = miConfig.SecretKey
  260. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  261. struct3508.Begndate = start_time
  262. struct3508.Enddate = end_time
  263. result1, result2, _ := service.FJyb3509(struct3508)
  264. saveLog(result1, result2, "3509", "3509")
  265. var res models.Result3509
  266. var respJSON2 map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. userJSONBytes2, _ := json.Marshal(respJSON2)
  273. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  274. utils.ErrorLog("解析失败:%v", err)
  275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  276. return
  277. }
  278. if res.Infcode == -1 {
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "failed_code": -10,
  281. "msg": res.ErrMsg,
  282. })
  283. } else {
  284. c.ServeSuccessJSON(map[string]interface{}{
  285. "info": res.Output,
  286. })
  287. }
  288. }
  289. func (c *HisApiController) Get3510() {
  290. admin_user_id, _ := c.GetInt64("admin_user_id")
  291. drug_id, _ := c.GetInt64("id")
  292. start_time := c.GetString("start_time")
  293. end_time := c.GetString("end_time")
  294. adminUser := c.GetAdminUserInfo()
  295. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  296. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  297. drug, _ := service.GetDrugByID(drug_id)
  298. var struct3508 models.Struct3510
  299. struct3508.FixmedinsCode = miConfig.Code
  300. struct3508.OrgName = miConfig.OrgName
  301. struct3508.AccessKey = miConfig.AccessKey
  302. struct3508.Opter = curRoles.UserName
  303. struct3508.RequestUrl = miConfig.Url
  304. struct3508.Url = miConfig.Url
  305. struct3508.AppId = miConfig.Cainfo
  306. struct3508.AppSecret = miConfig.AppSecret
  307. struct3508.Enckey = miConfig.EncKey
  308. struct3508.SignKey = miConfig.SignKey
  309. struct3508.SecretKey = miConfig.SecretKey
  310. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  311. struct3508.Begndate = start_time
  312. struct3508.Enddate = end_time
  313. result1, result2, _ := service.FJyb3510(struct3508)
  314. saveLog(result1, result2, "3510", "3510")
  315. var res models.Result3510
  316. var respJSON2 map[string]interface{}
  317. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  320. return
  321. }
  322. userJSONBytes2, _ := json.Marshal(respJSON2)
  323. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  324. utils.ErrorLog("解析失败:%v", err)
  325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  326. return
  327. }
  328. if res.Infcode == -1 {
  329. c.ServeSuccessJSON(map[string]interface{}{
  330. "failed_code": -10,
  331. "msg": res.ErrMsg,
  332. })
  333. } else {
  334. c.ServeSuccessJSON(map[string]interface{}{
  335. "info": res.Output,
  336. })
  337. }
  338. }
  339. func (c *HisApiController) Get3511() {
  340. admin_user_id, _ := c.GetInt64("admin_user_id")
  341. drug_id, _ := c.GetInt64("id")
  342. start_time := c.GetString("start_time")
  343. end_time := c.GetString("end_time")
  344. adminUser := c.GetAdminUserInfo()
  345. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  346. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  347. drug, _ := service.GetDrugByID(drug_id)
  348. var struct3508 models.Struct3511
  349. struct3508.FixmedinsCode = miConfig.Code
  350. struct3508.OrgName = miConfig.OrgName
  351. struct3508.AccessKey = miConfig.AccessKey
  352. struct3508.Opter = curRoles.UserName
  353. struct3508.RequestUrl = miConfig.Url
  354. struct3508.Url = miConfig.Url
  355. struct3508.AppId = miConfig.Cainfo
  356. struct3508.AppSecret = miConfig.AppSecret
  357. struct3508.Enckey = miConfig.EncKey
  358. struct3508.SignKey = miConfig.SignKey
  359. struct3508.SecretKey = miConfig.SecretKey
  360. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  361. struct3508.Begndate = start_time
  362. struct3508.Enddate = end_time
  363. result1, result2, _ := service.FJyb3511(struct3508)
  364. saveLog(result1, result2, "3511", "3511")
  365. var res models.Result3511
  366. var respJSON2 map[string]interface{}
  367. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  370. return
  371. }
  372. userJSONBytes2, _ := json.Marshal(respJSON2)
  373. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  374. utils.ErrorLog("解析失败:%v", err)
  375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  376. return
  377. }
  378. if res.Infcode == -1 {
  379. c.ServeSuccessJSON(map[string]interface{}{
  380. "failed_code": -10,
  381. "msg": res.ErrMsg,
  382. })
  383. } else {
  384. c.ServeSuccessJSON(map[string]interface{}{
  385. "info": res.Output,
  386. })
  387. }
  388. }
  389. func (c *HisApiController) Get3512() {
  390. admin_user_id, _ := c.GetInt64("admin_user_id")
  391. drug_id, _ := c.GetInt64("id")
  392. start_time := c.GetString("start_time")
  393. end_time := c.GetString("end_time")
  394. adminUser := c.GetAdminUserInfo()
  395. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  396. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  397. drug, _ := service.GetDrugByID(drug_id)
  398. var struct3508 models.Struct3512
  399. struct3508.FixmedinsCode = miConfig.Code
  400. struct3508.OrgName = miConfig.OrgName
  401. struct3508.AccessKey = miConfig.AccessKey
  402. struct3508.Opter = curRoles.UserName
  403. struct3508.RequestUrl = miConfig.Url
  404. struct3508.Url = miConfig.Url
  405. struct3508.AppId = miConfig.Cainfo
  406. struct3508.AppSecret = miConfig.AppSecret
  407. struct3508.Enckey = miConfig.EncKey
  408. struct3508.SignKey = miConfig.SignKey
  409. struct3508.SecretKey = miConfig.SecretKey
  410. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  411. struct3508.Begndate = start_time
  412. struct3508.Enddate = end_time
  413. result1, result2, _ := service.FJyb3512(struct3508)
  414. saveLog(result1, result2, "3512", "3512")
  415. var res models.Result3512
  416. var respJSON2 map[string]interface{}
  417. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  420. return
  421. }
  422. userJSONBytes2, _ := json.Marshal(respJSON2)
  423. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  424. utils.ErrorLog("解析失败:%v", err)
  425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  426. return
  427. }
  428. if res.Infcode == -1 {
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "failed_code": -10,
  431. "msg": res.ErrMsg,
  432. })
  433. } else {
  434. c.ServeSuccessJSON(map[string]interface{}{
  435. "info": res.Output,
  436. })
  437. }
  438. }
  439. func (c *HisApiController) Get3513() {
  440. admin_user_id, _ := c.GetInt64("admin_user_id")
  441. drug_id, _ := c.GetInt64("id")
  442. start_time := c.GetString("start_time")
  443. end_time := c.GetString("end_time")
  444. adminUser := c.GetAdminUserInfo()
  445. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  446. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  447. drug, _ := service.GetDrugByID(drug_id)
  448. var struct3508 models.Struct3513
  449. struct3508.FixmedinsCode = miConfig.Code
  450. struct3508.OrgName = miConfig.OrgName
  451. struct3508.AccessKey = miConfig.AccessKey
  452. struct3508.Opter = curRoles.UserName
  453. struct3508.RequestUrl = miConfig.Url
  454. struct3508.Url = miConfig.Url
  455. struct3508.AppId = miConfig.Cainfo
  456. struct3508.AppSecret = miConfig.AppSecret
  457. struct3508.Enckey = miConfig.EncKey
  458. struct3508.SignKey = miConfig.SignKey
  459. struct3508.SecretKey = miConfig.SecretKey
  460. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  461. struct3508.Begndate = start_time
  462. struct3508.Enddate = end_time
  463. result1, result2, _ := service.FJyb3513(struct3508)
  464. saveLog(result1, result2, "3513", "3513")
  465. var res models.Result3513
  466. var respJSON2 map[string]interface{}
  467. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  470. return
  471. }
  472. userJSONBytes2, _ := json.Marshal(respJSON2)
  473. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  474. utils.ErrorLog("解析失败:%v", err)
  475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  476. return
  477. }
  478. if res.Infcode == -1 {
  479. c.ServeSuccessJSON(map[string]interface{}{
  480. "failed_code": -10,
  481. "msg": res.ErrMsg,
  482. })
  483. } else {
  484. c.ServeSuccessJSON(map[string]interface{}{
  485. "info": res.Output,
  486. })
  487. }
  488. }
  489. func (c *HisApiController) Get35081() {
  490. admin_user_id, _ := c.GetInt64("admin_user_id")
  491. drug_id, _ := c.GetInt64("id")
  492. //start_time := c.GetString("start_time")
  493. //end_time := c.GetString("end_time")
  494. page, _ := c.GetInt("page")
  495. adminUser := c.GetAdminUserInfo()
  496. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  497. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  498. drug, _ := service.GetDrugByID(drug_id)
  499. var struct3508 models.Struct35081
  500. struct3508.FixmedinsCode = miConfig.Code
  501. struct3508.OrgName = miConfig.OrgName
  502. struct3508.AccessKey = miConfig.AccessKey
  503. struct3508.Opter = curRoles.UserName
  504. struct3508.RequestUrl = miConfig.Url
  505. struct3508.Url = miConfig.Url
  506. struct3508.AppId = miConfig.Cainfo
  507. struct3508.AppSecret = miConfig.AppSecret
  508. struct3508.Enckey = miConfig.EncKey
  509. struct3508.SignKey = miConfig.SignKey
  510. struct3508.SecretKey = miConfig.SecretKey
  511. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  512. struct3508.PageNum = page
  513. struct3508.PageSize = 10
  514. result1, result2, _ := service.FJyb35081(struct3508)
  515. saveLog(result1, result2, "35081", "35081")
  516. var res models.Result35081
  517. var respJSON2 map[string]interface{}
  518. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  521. return
  522. }
  523. userJSONBytes2, _ := json.Marshal(respJSON2)
  524. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  525. utils.ErrorLog("解析失败:%v", err)
  526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  527. return
  528. }
  529. if res.Infcode == -1 {
  530. c.ServeSuccessJSON(map[string]interface{}{
  531. "failed_code": -10,
  532. "msg": res.ErrMsg,
  533. })
  534. } else {
  535. c.ServeSuccessJSON(map[string]interface{}{
  536. "info": res.Output,
  537. })
  538. }
  539. }
  540. func (c *HisApiController) Get35082() {
  541. admin_user_id, _ := c.GetInt64("admin_user_id")
  542. drug_id, _ := c.GetInt64("id")
  543. //start_time := c.GetString("start_time")
  544. //end_time := c.GetString("end_time")
  545. page, _ := c.GetInt("page")
  546. adminUser := c.GetAdminUserInfo()
  547. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  549. drug, _ := service.GetDrugByID(drug_id)
  550. var struct3508 models.Struct35082
  551. struct3508.FixmedinsCode = miConfig.Code
  552. struct3508.OrgName = miConfig.OrgName
  553. struct3508.AccessKey = miConfig.AccessKey
  554. struct3508.Opter = curRoles.UserName
  555. struct3508.RequestUrl = miConfig.Url
  556. struct3508.Url = miConfig.Url
  557. struct3508.AppId = miConfig.Cainfo
  558. struct3508.AppSecret = miConfig.AppSecret
  559. struct3508.Enckey = miConfig.EncKey
  560. struct3508.SignKey = miConfig.SignKey
  561. struct3508.SecretKey = miConfig.SecretKey
  562. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  563. struct3508.PageNum = page
  564. struct3508.PageSize = 10
  565. result1, result2, _ := service.FJyb35082(struct3508)
  566. saveLog(result1, result2, "35082", "35082")
  567. var res models.Result35082
  568. var respJSON2 map[string]interface{}
  569. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  572. return
  573. }
  574. userJSONBytes2, _ := json.Marshal(respJSON2)
  575. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  576. utils.ErrorLog("解析失败:%v", err)
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  578. return
  579. }
  580. if res.Infcode == -1 {
  581. c.ServeSuccessJSON(map[string]interface{}{
  582. "failed_code": -10,
  583. "msg": res.ErrMsg,
  584. })
  585. } else {
  586. c.ServeSuccessJSON(map[string]interface{}{
  587. "info": res.Output,
  588. })
  589. }
  590. }
  591. func (c *HisApiController) FJ3501AND3502() {
  592. ids := c.GetString("ids")
  593. admin_user_id, _ := c.GetInt64("admin_user_id")
  594. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  595. id_arr := strings.Split(ids, ",")
  596. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  597. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  598. //库盘
  599. var errs []string
  600. for _, drug := range drugs {
  601. if drug.IsPc == 0 {
  602. var res2 ResultSix
  603. var res3 ResultSix
  604. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  605. var struct3501 models.Struct3501
  606. struct3501.Code = miConfig.Code
  607. struct3501.OrgName = miConfig.OrgName
  608. struct3501.AccessKey = miConfig.AccessKey
  609. struct3501.Opter = roles.UserName
  610. struct3501.RequestUrl = miConfig.Url
  611. struct3501.Url = miConfig.Url
  612. struct3501.AppId = miConfig.Cainfo
  613. struct3501.AppSecret = miConfig.AppSecret
  614. struct3501.Enckey = miConfig.EncKey
  615. struct3501.SignKey = miConfig.SignKey
  616. struct3501.SecretKey = miConfig.SecretKey
  617. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  618. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  620. struct3501.RxFlag = "1"
  621. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  622. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  623. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  624. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  625. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  626. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  627. struct3501.FixmedinsBchno = number
  628. struct3501.DrugTracCodg = drug.DrugCode
  629. memo := make(map[string]interface{})
  630. memo["pric"] = drug.Price
  631. bytesData, _ := json.Marshal(memo)
  632. struct3501.Memo = string(bytesData)
  633. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  634. result1, result2, _ := service.FJyb3501(struct3501)
  635. saveLog(result1, result2, "3501", "3501")
  636. //saveLog(result, requestLog, "2201", "挂号")
  637. var respJSON2 map[string]interface{}
  638. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  641. return
  642. }
  643. userJSONBytes2, _ := json.Marshal(respJSON2)
  644. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  645. utils.ErrorLog("解析失败:%v", err)
  646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  647. return
  648. }
  649. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  650. data := make(map[string]interface{})
  651. data["struct_3501s"] = struct3501
  652. client := &http.Client{}
  653. bytesData, _ := json.Marshal(data)
  654. var req *http.Request
  655. if miConfig.MdtrtareaAdmvs == "320921" {
  656. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  657. } else {
  658. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  659. }
  660. resp, _ := client.Do(req)
  661. defer resp.Body.Close()
  662. body, ioErr := ioutil.ReadAll(resp.Body)
  663. if ioErr != nil {
  664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  665. }
  666. var respJSON map[string]interface{}
  667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. var resSix10265 ResultSix10265 //1101结果
  673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  674. result, _ := json.Marshal(respJSON)
  675. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  676. utils.ErrorLog("解析失败:%v", err)
  677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  678. return
  679. }
  680. res2.InfRefmsgid = resSix10265.InfRefmsgid
  681. res2.Output = resSix10265.Output
  682. res2.ErrMsg = resSix10265.ErrMsg
  683. res2.Cainfo = resSix10265.Cainfo
  684. res2.WarnMsg = resSix10265.WarnMsg
  685. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  686. res2.Infcode = infocode
  687. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  688. data := make(map[string]interface{})
  689. data["struct_3501s"] = struct3501
  690. client := &http.Client{}
  691. bytesData, _ := json.Marshal(data)
  692. var req *http.Request
  693. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  694. resp, _ := client.Do(req)
  695. defer resp.Body.Close()
  696. body, ioErr := ioutil.ReadAll(resp.Body)
  697. if ioErr != nil {
  698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. var resSix10265 ResultSix10265 //1101结果
  707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  708. result, _ := json.Marshal(respJSON)
  709. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  710. utils.ErrorLog("解析失败:%v", err)
  711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  712. return
  713. }
  714. res2.InfRefmsgid = resSix10265.InfRefmsgid
  715. res2.Output = resSix10265.Output
  716. res2.ErrMsg = resSix10265.ErrMsg
  717. res2.Cainfo = resSix10265.Cainfo
  718. res2.WarnMsg = resSix10265.WarnMsg
  719. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  720. res2.Infcode = infocode
  721. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  722. data := make(map[string]interface{})
  723. data["struct_3501s"] = struct3501
  724. client := &http.Client{}
  725. bytesData, _ := json.Marshal(data)
  726. var req *http.Request
  727. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  728. resp, _ := client.Do(req)
  729. defer resp.Body.Close()
  730. body, ioErr := ioutil.ReadAll(resp.Body)
  731. if ioErr != nil {
  732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  733. }
  734. var respJSON map[string]interface{}
  735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  738. return
  739. }
  740. var resSix10265 ResultSix10265 //1101结果
  741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  742. result, _ := json.Marshal(respJSON)
  743. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  744. utils.ErrorLog("解析失败:%v", err)
  745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  746. return
  747. }
  748. res2.InfRefmsgid = resSix10265.InfRefmsgid
  749. res2.Output = resSix10265.Output
  750. res2.ErrMsg = resSix10265.ErrMsg
  751. res2.Cainfo = resSix10265.Cainfo
  752. res2.WarnMsg = resSix10265.WarnMsg
  753. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  754. res2.Infcode = infocode
  755. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  756. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  757. saveLog(result1, result2, "3501", "3501")
  758. //saveLog(result, requestLog, "2201", "挂号")
  759. var respJSON2 map[string]interface{}
  760. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  763. return
  764. }
  765. userJSONBytes2, _ := json.Marshal(respJSON2)
  766. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  767. utils.ErrorLog("解析失败:%v", err)
  768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  769. return
  770. }
  771. }
  772. if res2.Infcode != -1 {
  773. drug.IsPc = 1
  774. drug.Bchno = number
  775. drug.PcDate = time.Now().Unix()
  776. err := service.SaveW(drug)
  777. if err == nil {
  778. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  779. var struct3502 models.Struct3502
  780. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  781. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  783. struct3502.FixmedinsCode = miConfig.Code
  784. struct3502.Code = miConfig.Code
  785. struct3502.RxFlag = "0"
  786. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  787. struct3502.OrgName = miConfig.OrgName
  788. struct3502.Opter = roles.UserName
  789. struct3502.AccessKey = miConfig.AccessKey
  790. struct3502.RequestUrl = miConfig.Url
  791. struct3502.SecretKey = miConfig.SecretKey
  792. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  793. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  794. struct3502.Url = miConfig.Url
  795. struct3502.AppId = miConfig.Cainfo
  796. struct3502.AppSecret = miConfig.AppSecret
  797. struct3502.Enckey = miConfig.EncKey
  798. struct3502.SignKey = miConfig.SignKey
  799. struct3502.SecretKey = miConfig.SecretKey
  800. struct3502.DrugTracCodg = drug.DrugCode
  801. struct3502.Memo = ""
  802. struct3502.InvChgType = "108"
  803. struct3502.FixmedinsBchno = bg_number
  804. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  805. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  806. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  807. result11, result22, _ := service.FJyb3502(struct3502)
  808. saveLog(result11, result22, "3502", "3502")
  809. var respJSON3 map[string]interface{}
  810. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  813. return
  814. }
  815. userJSONBytes3, _ := json.Marshal(respJSON3)
  816. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  817. utils.ErrorLog("解析失败:%v", err)
  818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  819. return
  820. }
  821. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  822. data := make(map[string]interface{})
  823. data["struct_3502s"] = struct3502
  824. client := &http.Client{}
  825. bytesData, _ := json.Marshal(data)
  826. var req *http.Request
  827. if miConfig.MdtrtareaAdmvs == "320921" {
  828. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  829. } else {
  830. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  831. }
  832. resp, _ := client.Do(req)
  833. defer resp.Body.Close()
  834. body, ioErr := ioutil.ReadAll(resp.Body)
  835. if ioErr != nil {
  836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  837. }
  838. var respJSON map[string]interface{}
  839. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  842. return
  843. }
  844. var resSix10265 ResultSix10265 //1101结果
  845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  846. result, _ := json.Marshal(respJSON)
  847. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  848. utils.ErrorLog("解析失败:%v", err)
  849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  850. return
  851. }
  852. res3.InfRefmsgid = resSix10265.InfRefmsgid
  853. res3.Output = resSix10265.Output
  854. res3.ErrMsg = resSix10265.ErrMsg
  855. res3.Cainfo = resSix10265.Cainfo
  856. res3.WarnMsg = resSix10265.WarnMsg
  857. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  858. res3.Infcode = infocode
  859. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  860. data := make(map[string]interface{})
  861. data["struct_3502s"] = struct3502
  862. client := &http.Client{}
  863. bytesData, _ := json.Marshal(data)
  864. var req *http.Request
  865. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  866. resp, _ := client.Do(req)
  867. defer resp.Body.Close()
  868. body, ioErr := ioutil.ReadAll(resp.Body)
  869. if ioErr != nil {
  870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  871. }
  872. var respJSON map[string]interface{}
  873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  876. return
  877. }
  878. var resSix10265 ResultSix10265 //1101结果
  879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  880. result, _ := json.Marshal(respJSON)
  881. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  882. utils.ErrorLog("解析失败:%v", err)
  883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  884. return
  885. }
  886. res3.InfRefmsgid = resSix10265.InfRefmsgid
  887. res3.Output = resSix10265.Output
  888. res3.ErrMsg = resSix10265.ErrMsg
  889. res3.Cainfo = resSix10265.Cainfo
  890. res3.WarnMsg = resSix10265.WarnMsg
  891. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  892. res3.Infcode = infocode
  893. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  894. data := make(map[string]interface{})
  895. data["struct_3501s"] = struct3501
  896. client := &http.Client{}
  897. bytesData, _ := json.Marshal(data)
  898. var req *http.Request
  899. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  900. resp, _ := client.Do(req)
  901. defer resp.Body.Close()
  902. body, ioErr := ioutil.ReadAll(resp.Body)
  903. if ioErr != nil {
  904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  905. }
  906. var respJSON map[string]interface{}
  907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  910. return
  911. }
  912. var resSix10265 ResultSix10265 //1101结果
  913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  914. result, _ := json.Marshal(respJSON)
  915. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  916. utils.ErrorLog("解析失败:%v", err)
  917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  918. return
  919. }
  920. res2.InfRefmsgid = resSix10265.InfRefmsgid
  921. res2.Output = resSix10265.Output
  922. res2.ErrMsg = resSix10265.ErrMsg
  923. res2.Cainfo = resSix10265.Cainfo
  924. res2.WarnMsg = resSix10265.WarnMsg
  925. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  926. res2.Infcode = infocode
  927. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  928. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  929. saveLog(result11, result22, "3502", "3502")
  930. var respJSON3 map[string]interface{}
  931. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  934. return
  935. }
  936. userJSONBytes3, _ := json.Marshal(respJSON3)
  937. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  938. utils.ErrorLog("解析失败:%v", err)
  939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  940. return
  941. }
  942. }
  943. if res3.Infcode == -1 {
  944. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res3.ErrMsg,
  948. })
  949. } else {
  950. drug.IsBg = 1
  951. drug.BgBchno = bg_number
  952. service.SaveW(drug)
  953. }
  954. }
  955. } else {
  956. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  957. }
  958. }
  959. //变更
  960. }
  961. if len(errs) == 0 {
  962. c.ServeSuccessJSON(map[string]interface{}{
  963. "msg": "盘存变更成功",
  964. })
  965. } else {
  966. c.ServeSuccessJSON(map[string]interface{}{
  967. "failed_code": -10,
  968. "msg": errs,
  969. })
  970. }
  971. }
  972. func (c *HisApiController) DeletePCandBG() {
  973. ids := c.GetString("ids")
  974. id_arr := strings.Split(ids, ",")
  975. admin_user_id, _ := c.GetInt64("admin_user_id")
  976. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  977. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  978. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  979. var err []string
  980. for _, item := range drugs {
  981. if item.IsPc == 1 && item.IsBg == 1 {
  982. var res FJ3507Result
  983. var res2 FJ3507Result
  984. var struct3507 models.Struct3507
  985. struct3507.FixmedinsBchno = item.Bchno
  986. struct3507.InvDataType = "1"
  987. struct3507.Opter = roles.UserName
  988. struct3507.OrgName = miConfig.OrgName
  989. struct3507.AccessKey = miConfig.AccessKey
  990. struct3507.RequestUrl = miConfig.Url
  991. struct3507.FixmedinsCode = miConfig.Code
  992. struct3507.Code = miConfig.Code
  993. struct3507.SecretKey = miConfig.SecretKey
  994. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  995. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  996. struct3507.Url = miConfig.Url
  997. struct3507.AppId = miConfig.Cainfo
  998. struct3507.AppSecret = miConfig.AppSecret
  999. struct3507.Enckey = miConfig.EncKey
  1000. struct3507.SignKey = miConfig.SignKey
  1001. struct3507.SecretKey = miConfig.SecretKey
  1002. if miConfig.MdtrtareaAdmvs == "350500" {
  1003. result, result1, _ := service.FJyb3507(struct3507)
  1004. saveLog(result, result1, "3507", "3507")
  1005. var respJSON2 map[string]interface{}
  1006. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1009. return
  1010. }
  1011. userJSONBytes2, _ := json.Marshal(respJSON2)
  1012. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1013. utils.ErrorLog("解析失败:%v", err)
  1014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1015. return
  1016. }
  1017. } else {
  1018. data := make(map[string]interface{})
  1019. data["struct_3507s"] = struct3507
  1020. client := &http.Client{}
  1021. bytesData, _ := json.Marshal(data)
  1022. var req *http.Request
  1023. if miConfig.MdtrtareaAdmvs == "320921" {
  1024. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1025. } else {
  1026. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1027. }
  1028. resp, _ := client.Do(req)
  1029. defer resp.Body.Close()
  1030. body, ioErr := ioutil.ReadAll(resp.Body)
  1031. if ioErr != nil {
  1032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1033. }
  1034. var respJSON map[string]interface{}
  1035. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. return
  1039. }
  1040. var resSix10265 ResultSix10265 //1101结果
  1041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1042. result, _ := json.Marshal(respJSON)
  1043. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1044. utils.ErrorLog("解析失败:%v", err)
  1045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1046. return
  1047. }
  1048. res.InfRefmsgid = resSix10265.InfRefmsgid
  1049. //res.Output = resSix10265.Output
  1050. res.ErrMsg = resSix10265.ErrMsg
  1051. res.Cainfo = resSix10265.Cainfo
  1052. res.WarnMsg = resSix10265.WarnMsg
  1053. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1054. res.Infcode = infocode
  1055. }
  1056. if res.Infcode == 0 {
  1057. item.IsPc = 0
  1058. err2 := service.SaveW(item)
  1059. if err2 == nil {
  1060. var struct3507_2 models.Struct3507
  1061. struct3507_2.OrgName = miConfig.OrgName
  1062. struct3507_2.AccessKey = miConfig.AccessKey
  1063. struct3507_2.RequestUrl = miConfig.Url
  1064. struct3507_2.Opter = roles.UserName
  1065. struct3507_2.FixmedinsCode = miConfig.Code
  1066. struct3507_2.Code = miConfig.Code
  1067. struct3507_2.SecretKey = miConfig.SecretKey
  1068. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1069. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1070. struct3507_2.Url = miConfig.Url
  1071. struct3507_2.AppId = miConfig.Cainfo
  1072. struct3507_2.AppSecret = miConfig.AppSecret
  1073. struct3507_2.Enckey = miConfig.EncKey
  1074. struct3507_2.SignKey = miConfig.SignKey
  1075. struct3507_2.SecretKey = miConfig.SecretKey
  1076. struct3507_2.FixmedinsBchno = item.BgBchno
  1077. struct3507_2.InvDataType = "2"
  1078. if miConfig.MdtrtareaAdmvs == "350500" {
  1079. result11, result22, _ := service.FJyb3507(struct3507_2)
  1080. saveLog(result11, result22, "3507", "3507")
  1081. var respJSON3 map[string]interface{}
  1082. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1085. return
  1086. }
  1087. userJSONBytes3, _ := json.Marshal(respJSON3)
  1088. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1089. utils.ErrorLog("解析失败:%v", err)
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. } else {
  1094. data := make(map[string]interface{})
  1095. data["struct_3507s"] = struct3507_2
  1096. client := &http.Client{}
  1097. bytesData, _ := json.Marshal(data)
  1098. var req *http.Request
  1099. if miConfig.MdtrtareaAdmvs == "320921" {
  1100. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1101. } else {
  1102. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1103. }
  1104. resp, _ := client.Do(req)
  1105. defer resp.Body.Close()
  1106. body, ioErr := ioutil.ReadAll(resp.Body)
  1107. if ioErr != nil {
  1108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1109. }
  1110. var respJSON map[string]interface{}
  1111. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1114. return
  1115. }
  1116. var resSix10265 ResultSix10265 //1101结果
  1117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1118. result, _ := json.Marshal(respJSON)
  1119. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1120. utils.ErrorLog("解析失败:%v", err)
  1121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1122. return
  1123. }
  1124. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1125. //res2.Output = resSix10265.Output
  1126. res2.ErrMsg = resSix10265.ErrMsg
  1127. res2.Cainfo = resSix10265.Cainfo
  1128. res2.WarnMsg = resSix10265.WarnMsg
  1129. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1130. res2.Infcode = infocode
  1131. }
  1132. if res2.Infcode != -1 {
  1133. item.IsBg = 0
  1134. item.Bchno = ""
  1135. item.BgBchno = ""
  1136. item.PcDate = 0
  1137. service.SaveW(item)
  1138. } else {
  1139. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1140. }
  1141. }
  1142. } else {
  1143. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1144. }
  1145. }
  1146. if item.IsPc == 1 && item.IsBg == 0 {
  1147. var res FJ3507Result
  1148. var struct3507 models.Struct3507
  1149. struct3507.FixmedinsBchno = item.Bchno
  1150. struct3507.InvDataType = "1"
  1151. struct3507.Opter = roles.UserName
  1152. struct3507.FixmedinsCode = miConfig.Code
  1153. struct3507.Code = miConfig.Code
  1154. struct3507.OrgName = miConfig.OrgName
  1155. struct3507.AccessKey = miConfig.AccessKey
  1156. struct3507.RequestUrl = miConfig.Url
  1157. struct3507.SecretKey = miConfig.SecretKey
  1158. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1159. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1160. struct3507.Url = miConfig.Url
  1161. struct3507.AppId = miConfig.Cainfo
  1162. struct3507.AppSecret = miConfig.AppSecret
  1163. struct3507.Enckey = miConfig.EncKey
  1164. struct3507.SignKey = miConfig.SignKey
  1165. struct3507.SecretKey = miConfig.SecretKey
  1166. //result, result1, _ := service.FJyb3507(struct3507)
  1167. //saveLog(result, result1, "3507", "3507")
  1168. if miConfig.MdtrtareaAdmvs == "350500" {
  1169. result, result1, _ := service.FJyb3507(struct3507)
  1170. saveLog(result, result1, "3507", "3507")
  1171. var respJSON2 map[string]interface{}
  1172. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1175. return
  1176. }
  1177. userJSONBytes2, _ := json.Marshal(respJSON2)
  1178. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1179. utils.ErrorLog("解析失败:%v", err)
  1180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1181. return
  1182. }
  1183. } else {
  1184. data := make(map[string]interface{})
  1185. data["struct_3507s"] = struct3507
  1186. client := &http.Client{}
  1187. bytesData, _ := json.Marshal(data)
  1188. var req *http.Request
  1189. if miConfig.MdtrtareaAdmvs == "320921" {
  1190. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1191. } else {
  1192. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1193. }
  1194. resp, _ := client.Do(req)
  1195. defer resp.Body.Close()
  1196. body, ioErr := ioutil.ReadAll(resp.Body)
  1197. if ioErr != nil {
  1198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1199. }
  1200. var respJSON map[string]interface{}
  1201. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1204. return
  1205. }
  1206. var resSix10265 ResultSix10265 //1101结果
  1207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1208. result, _ := json.Marshal(respJSON)
  1209. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1210. utils.ErrorLog("解析失败:%v", err)
  1211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1212. return
  1213. }
  1214. res.InfRefmsgid = resSix10265.InfRefmsgid
  1215. //res.Output = resSix10265.Output
  1216. res.ErrMsg = resSix10265.ErrMsg
  1217. res.Cainfo = resSix10265.Cainfo
  1218. res.WarnMsg = resSix10265.WarnMsg
  1219. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1220. res.Infcode = infocode
  1221. }
  1222. if res.Infcode == 0 {
  1223. item.IsPc = 0
  1224. item.Bchno = ""
  1225. item.BgBchno = ""
  1226. item.PcDate = 0
  1227. service.SaveW(item)
  1228. } else {
  1229. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1230. }
  1231. }
  1232. if item.IsPc == 0 && item.IsBg == 1 {
  1233. var res FJ3507Result
  1234. var struct3507 models.Struct3507
  1235. struct3507.FixmedinsBchno = item.BgBchno
  1236. struct3507.InvDataType = "2"
  1237. struct3507.Opter = roles.UserName
  1238. struct3507.FixmedinsCode = miConfig.Code
  1239. struct3507.OrgName = miConfig.OrgName
  1240. struct3507.AccessKey = miConfig.AccessKey
  1241. struct3507.RequestUrl = miConfig.Url
  1242. struct3507.SecretKey = miConfig.SecretKey
  1243. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1244. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1245. struct3507.Url = miConfig.Url
  1246. struct3507.AppId = miConfig.Cainfo
  1247. struct3507.AppSecret = miConfig.AppSecret
  1248. struct3507.Enckey = miConfig.EncKey
  1249. struct3507.SignKey = miConfig.SignKey
  1250. struct3507.SecretKey = miConfig.SecretKey
  1251. //result, result1, _ := service.FJyb3507(struct3507)
  1252. //saveLog(result, result1, "3507", "3507")
  1253. if miConfig.MdtrtareaAdmvs == "350500" {
  1254. result, result1, _ := service.FJyb3507(struct3507)
  1255. saveLog(result, result1, "3507", "3507")
  1256. var respJSON2 map[string]interface{}
  1257. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1260. return
  1261. }
  1262. userJSONBytes2, _ := json.Marshal(respJSON2)
  1263. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1264. utils.ErrorLog("解析失败:%v", err)
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1266. return
  1267. }
  1268. } else {
  1269. data := make(map[string]interface{})
  1270. data["struct_3507s"] = struct3507
  1271. client := &http.Client{}
  1272. bytesData, _ := json.Marshal(data)
  1273. var req *http.Request
  1274. if miConfig.MdtrtareaAdmvs == "320921" {
  1275. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1276. } else {
  1277. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1278. }
  1279. resp, _ := client.Do(req)
  1280. defer resp.Body.Close()
  1281. body, ioErr := ioutil.ReadAll(resp.Body)
  1282. if ioErr != nil {
  1283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1284. }
  1285. var respJSON map[string]interface{}
  1286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1289. return
  1290. }
  1291. var resSix10265 ResultSix10265 //1101结果
  1292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1293. result, _ := json.Marshal(respJSON)
  1294. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1295. utils.ErrorLog("解析失败:%v", err)
  1296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1297. return
  1298. }
  1299. res.InfRefmsgid = resSix10265.InfRefmsgid
  1300. //res.Output = resSix10265.Output
  1301. res.ErrMsg = resSix10265.ErrMsg
  1302. res.Cainfo = resSix10265.Cainfo
  1303. res.WarnMsg = resSix10265.WarnMsg
  1304. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1305. res.Infcode = infocode
  1306. }
  1307. if res.Infcode == 0 {
  1308. item.IsBg = 0
  1309. item.Bchno = ""
  1310. item.BgBchno = ""
  1311. item.PcDate = 0
  1312. service.SaveW(item)
  1313. } else {
  1314. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1315. }
  1316. }
  1317. }
  1318. if len(err) == 0 {
  1319. c.ServeSuccessJSON(map[string]interface{}{
  1320. "msg": "删除盘存变更成功",
  1321. })
  1322. } else {
  1323. c.ServeSuccessJSON(map[string]interface{}{
  1324. "failed_code": -10,
  1325. "msg": err,
  1326. })
  1327. }
  1328. }
  1329. func (c *HisApiController) DeleteXSandBG() {
  1330. ids := c.GetString("ids")
  1331. id_arr := strings.Split(ids, ",")
  1332. admin_user_id, _ := c.GetInt64("admin_user_id")
  1333. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1334. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1335. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1336. var err []string
  1337. for _, item := range flows {
  1338. if item.IsSale == 1 && item.IsChange == 1 {
  1339. var res FJ3507Result
  1340. var res2 FJ3507Result
  1341. var struct3507 models.Struct3507
  1342. struct3507.FixmedinsBchno = item.Bchno
  1343. struct3507.InvDataType = "4"
  1344. struct3507.Opter = roles.UserName
  1345. struct3507.OrgName = miConfig.OrgName
  1346. struct3507.AccessKey = miConfig.AccessKey
  1347. struct3507.RequestUrl = miConfig.Url
  1348. struct3507.FixmedinsCode = miConfig.Code
  1349. struct3507.SecretKey = miConfig.SecretKey
  1350. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1351. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1352. struct3507.Url = miConfig.Url
  1353. struct3507.AppId = miConfig.Cainfo
  1354. struct3507.AppSecret = miConfig.AppSecret
  1355. struct3507.Enckey = miConfig.EncKey
  1356. struct3507.SignKey = miConfig.SignKey
  1357. struct3507.SecretKey = miConfig.SecretKey
  1358. //result, result1, _ := service.FJyb3507(struct3507)
  1359. //saveLog(result, result1, "3507", "3507")
  1360. if miConfig.MdtrtareaAdmvs == "350500" {
  1361. result, result1, _ := service.FJyb3507(struct3507)
  1362. saveLog(result, result1, "3507", "3507")
  1363. var respJSON2 map[string]interface{}
  1364. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1367. return
  1368. }
  1369. userJSONBytes2, _ := json.Marshal(respJSON2)
  1370. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1371. utils.ErrorLog("解析失败:%v", err)
  1372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1373. return
  1374. }
  1375. } else {
  1376. data := make(map[string]interface{})
  1377. data["struct_3507s"] = struct3507
  1378. client := &http.Client{}
  1379. bytesData, _ := json.Marshal(data)
  1380. var req *http.Request
  1381. if miConfig.MdtrtareaAdmvs == "320921" {
  1382. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1383. } else {
  1384. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1385. }
  1386. resp, _ := client.Do(req)
  1387. defer resp.Body.Close()
  1388. body, ioErr := ioutil.ReadAll(resp.Body)
  1389. if ioErr != nil {
  1390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1391. }
  1392. var respJSON map[string]interface{}
  1393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1396. return
  1397. }
  1398. var resSix10265 ResultSix10265 //1101结果
  1399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1400. result, _ := json.Marshal(respJSON)
  1401. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1402. utils.ErrorLog("解析失败:%v", err)
  1403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1404. return
  1405. }
  1406. res.InfRefmsgid = resSix10265.InfRefmsgid
  1407. //res.Output = resSix10265.Output
  1408. res.ErrMsg = resSix10265.ErrMsg
  1409. res.Cainfo = resSix10265.Cainfo
  1410. res.WarnMsg = resSix10265.WarnMsg
  1411. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1412. res.Infcode = infocode
  1413. }
  1414. if res.Infcode == 0 {
  1415. item.IsSale = 0
  1416. item.SaleDate = ""
  1417. item.Bchno = ""
  1418. err2 := service.SaveDF(item)
  1419. if err2 == nil {
  1420. var struct3507_2 models.Struct3507
  1421. struct3507_2.OrgName = miConfig.OrgName
  1422. struct3507_2.AccessKey = miConfig.AccessKey
  1423. struct3507_2.RequestUrl = miConfig.Url
  1424. struct3507_2.Opter = roles.UserName
  1425. struct3507_2.FixmedinsCode = miConfig.Code
  1426. struct3507_2.Code = miConfig.Code
  1427. struct3507_2.SecretKey = miConfig.SecretKey
  1428. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1429. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1430. struct3507_2.Url = miConfig.Url
  1431. struct3507_2.AppId = miConfig.Cainfo
  1432. struct3507_2.AppSecret = miConfig.AppSecret
  1433. struct3507_2.Enckey = miConfig.EncKey
  1434. struct3507_2.SignKey = miConfig.SignKey
  1435. struct3507_2.SecretKey = miConfig.SecretKey
  1436. struct3507_2.FixmedinsBchno = item.BgBchno
  1437. struct3507_2.InvDataType = "2"
  1438. if miConfig.MdtrtareaAdmvs == "350500" {
  1439. result11, result22, _ := service.FJyb3507(struct3507_2)
  1440. saveLog(result11, result22, "3507", "3507")
  1441. var respJSON3 map[string]interface{}
  1442. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1445. return
  1446. }
  1447. userJSONBytes3, _ := json.Marshal(respJSON3)
  1448. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1449. utils.ErrorLog("解析失败:%v", err)
  1450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1451. return
  1452. }
  1453. } else {
  1454. data := make(map[string]interface{})
  1455. data["struct_3507s"] = struct3507_2
  1456. client := &http.Client{}
  1457. bytesData, _ := json.Marshal(data)
  1458. var req *http.Request
  1459. if miConfig.MdtrtareaAdmvs == "320921" {
  1460. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1461. } else {
  1462. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1463. }
  1464. resp, _ := client.Do(req)
  1465. defer resp.Body.Close()
  1466. body, ioErr := ioutil.ReadAll(resp.Body)
  1467. if ioErr != nil {
  1468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1469. }
  1470. var respJSON map[string]interface{}
  1471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1474. return
  1475. }
  1476. var resSix10265 ResultSix10265 //1101结果
  1477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1478. result, _ := json.Marshal(respJSON)
  1479. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1480. utils.ErrorLog("解析失败:%v", err)
  1481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1482. return
  1483. }
  1484. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1485. //res.Output = resSix10265.Output
  1486. res2.ErrMsg = resSix10265.ErrMsg
  1487. res2.Cainfo = resSix10265.Cainfo
  1488. res2.WarnMsg = resSix10265.WarnMsg
  1489. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1490. res2.Infcode = infocode
  1491. }
  1492. if res2.Infcode == 0 {
  1493. item.IsChange = 0
  1494. item.BgBchno = ""
  1495. service.SaveDF2(item)
  1496. } else {
  1497. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1498. }
  1499. }
  1500. } else {
  1501. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1502. }
  1503. }
  1504. if item.IsSale == 2 && item.IsChange == 1 {
  1505. var res FJ3507Result
  1506. var res2 FJ3507Result
  1507. var struct3507 models.Struct3507
  1508. struct3507.FixmedinsBchno = item.Bchno
  1509. struct3507.InvDataType = "4"
  1510. struct3507.Opter = roles.UserName
  1511. struct3507.OrgName = miConfig.OrgName
  1512. struct3507.AccessKey = miConfig.AccessKey
  1513. struct3507.RequestUrl = miConfig.Url
  1514. struct3507.FixmedinsCode = miConfig.Code
  1515. struct3507.Code = miConfig.Code
  1516. struct3507.SecretKey = miConfig.SecretKey
  1517. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1518. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1519. struct3507.Url = miConfig.Url
  1520. struct3507.AppId = miConfig.Cainfo
  1521. struct3507.AppSecret = miConfig.AppSecret
  1522. struct3507.Enckey = miConfig.EncKey
  1523. struct3507.SignKey = miConfig.SignKey
  1524. struct3507.SecretKey = miConfig.SecretKey
  1525. //result, result1, _ := service.FJyb3507(struct3507)
  1526. //saveLog(result, result1, "3507", "3507")
  1527. //
  1528. //var respJSON2 map[string]interface{}
  1529. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1530. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. // return
  1533. //}
  1534. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1535. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1536. // utils.ErrorLog("解析失败:%v", err)
  1537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1538. // return
  1539. //}
  1540. if miConfig.MdtrtareaAdmvs == "350500" {
  1541. result, result1, _ := service.FJyb3507(struct3507)
  1542. saveLog(result, result1, "3507", "3507")
  1543. var respJSON2 map[string]interface{}
  1544. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1547. return
  1548. }
  1549. userJSONBytes2, _ := json.Marshal(respJSON2)
  1550. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1551. utils.ErrorLog("解析失败:%v", err)
  1552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1553. return
  1554. }
  1555. } else {
  1556. data := make(map[string]interface{})
  1557. data["struct_3507s"] = struct3507
  1558. client := &http.Client{}
  1559. bytesData, _ := json.Marshal(data)
  1560. var req *http.Request
  1561. if miConfig.MdtrtareaAdmvs == "320921" {
  1562. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1563. } else {
  1564. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1565. }
  1566. resp, _ := client.Do(req)
  1567. defer resp.Body.Close()
  1568. body, ioErr := ioutil.ReadAll(resp.Body)
  1569. if ioErr != nil {
  1570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1571. }
  1572. var respJSON map[string]interface{}
  1573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1576. return
  1577. }
  1578. var resSix10265 ResultSix10265 //1101结果
  1579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1580. result, _ := json.Marshal(respJSON)
  1581. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1582. utils.ErrorLog("解析失败:%v", err)
  1583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1584. return
  1585. }
  1586. res.InfRefmsgid = resSix10265.InfRefmsgid
  1587. //res.Output = resSix10265.Output
  1588. res.ErrMsg = resSix10265.ErrMsg
  1589. res.Cainfo = resSix10265.Cainfo
  1590. res.WarnMsg = resSix10265.WarnMsg
  1591. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1592. res.Infcode = infocode
  1593. }
  1594. if res.Infcode == 0 {
  1595. item.IsSale = 0
  1596. item.SaleDate = ""
  1597. item.Bchno = ""
  1598. err2 := service.SaveDF(item)
  1599. if err2 == nil {
  1600. var struct3507_2 models.Struct3507
  1601. struct3507_2.OrgName = miConfig.OrgName
  1602. struct3507_2.AccessKey = miConfig.AccessKey
  1603. struct3507_2.RequestUrl = miConfig.Url
  1604. struct3507_2.Opter = roles.UserName
  1605. struct3507_2.FixmedinsCode = miConfig.Code
  1606. struct3507_2.Code = miConfig.Code
  1607. struct3507_2.SecretKey = miConfig.SecretKey
  1608. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1609. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1610. struct3507_2.Url = miConfig.Url
  1611. struct3507_2.AppId = miConfig.Cainfo
  1612. struct3507_2.AppSecret = miConfig.AppSecret
  1613. struct3507_2.Enckey = miConfig.EncKey
  1614. struct3507_2.SignKey = miConfig.SignKey
  1615. struct3507_2.SecretKey = miConfig.SecretKey
  1616. struct3507_2.FixmedinsBchno = item.BgBchno
  1617. struct3507_2.InvDataType = "2"
  1618. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1619. //saveLog(result11, result22, "3507", "3507")
  1620. //var respJSON3 map[string]interface{}
  1621. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1622. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1624. // return
  1625. //}
  1626. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1627. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1628. // utils.ErrorLog("解析失败:%v", err)
  1629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. // return
  1631. //}
  1632. if miConfig.MdtrtareaAdmvs == "350500" {
  1633. result11, result22, _ := service.FJyb3507(struct3507_2)
  1634. saveLog(result11, result22, "3507", "3507")
  1635. var respJSON3 map[string]interface{}
  1636. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1639. return
  1640. }
  1641. userJSONBytes3, _ := json.Marshal(respJSON3)
  1642. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1643. utils.ErrorLog("解析失败:%v", err)
  1644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1645. return
  1646. }
  1647. } else {
  1648. data := make(map[string]interface{})
  1649. data["struct_3507s"] = struct3507_2
  1650. client := &http.Client{}
  1651. bytesData, _ := json.Marshal(data)
  1652. var req *http.Request
  1653. if miConfig.MdtrtareaAdmvs == "320921" {
  1654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1655. } else {
  1656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1657. }
  1658. resp, _ := client.Do(req)
  1659. defer resp.Body.Close()
  1660. body, ioErr := ioutil.ReadAll(resp.Body)
  1661. if ioErr != nil {
  1662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1663. }
  1664. var respJSON map[string]interface{}
  1665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1668. return
  1669. }
  1670. var resSix10265 ResultSix10265 //1101结果
  1671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1672. result, _ := json.Marshal(respJSON)
  1673. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1674. utils.ErrorLog("解析失败:%v", err)
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1676. return
  1677. }
  1678. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1679. //res.Output = resSix10265.Output
  1680. res2.ErrMsg = resSix10265.ErrMsg
  1681. res2.Cainfo = resSix10265.Cainfo
  1682. res2.WarnMsg = resSix10265.WarnMsg
  1683. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1684. res2.Infcode = infocode
  1685. }
  1686. if res2.Infcode == 0 {
  1687. item.IsChange = 0
  1688. item.BgBchno = ""
  1689. service.SaveDF2(item)
  1690. } else {
  1691. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1692. }
  1693. }
  1694. } else {
  1695. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1696. }
  1697. }
  1698. if item.IsSale == 1 && item.IsChange == 0 {
  1699. var res FJ3507Result
  1700. var struct3507 models.Struct3507
  1701. struct3507.FixmedinsBchno = item.Bchno
  1702. struct3507.InvDataType = "4"
  1703. struct3507.Opter = roles.UserName
  1704. struct3507.FixmedinsCode = miConfig.Code
  1705. struct3507.Code = miConfig.Code
  1706. struct3507.OrgName = miConfig.OrgName
  1707. struct3507.AccessKey = miConfig.AccessKey
  1708. struct3507.RequestUrl = miConfig.Url
  1709. struct3507.SecretKey = miConfig.SecretKey
  1710. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1711. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1712. struct3507.Url = miConfig.Url
  1713. struct3507.AppId = miConfig.Cainfo
  1714. struct3507.AppSecret = miConfig.AppSecret
  1715. struct3507.Enckey = miConfig.EncKey
  1716. struct3507.SignKey = miConfig.SignKey
  1717. struct3507.SecretKey = miConfig.SecretKey
  1718. //result, result1, _ := service.FJyb3507(struct3507)
  1719. //saveLog(result, result1, "3507", "3507")
  1720. //
  1721. //var respJSON3 map[string]interface{}
  1722. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1723. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1724. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1725. // return
  1726. //}
  1727. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1728. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1729. // utils.ErrorLog("解析失败:%v", err)
  1730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1731. // return
  1732. //}
  1733. if miConfig.MdtrtareaAdmvs == "350500" {
  1734. result, result1, _ := service.FJyb3507(struct3507)
  1735. saveLog(result, result1, "3507", "3507")
  1736. var respJSON2 map[string]interface{}
  1737. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1740. return
  1741. }
  1742. userJSONBytes2, _ := json.Marshal(respJSON2)
  1743. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1744. utils.ErrorLog("解析失败:%v", err)
  1745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1746. return
  1747. }
  1748. } else {
  1749. data := make(map[string]interface{})
  1750. data["struct_3507s"] = struct3507
  1751. client := &http.Client{}
  1752. bytesData, _ := json.Marshal(data)
  1753. var req *http.Request
  1754. if miConfig.MdtrtareaAdmvs == "320921" {
  1755. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1756. } else {
  1757. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1758. }
  1759. resp, _ := client.Do(req)
  1760. defer resp.Body.Close()
  1761. body, ioErr := ioutil.ReadAll(resp.Body)
  1762. if ioErr != nil {
  1763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1764. }
  1765. var respJSON map[string]interface{}
  1766. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1769. return
  1770. }
  1771. var resSix10265 ResultSix10265 //1101结果
  1772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1773. result, _ := json.Marshal(respJSON)
  1774. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1775. utils.ErrorLog("解析失败:%v", err)
  1776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1777. return
  1778. }
  1779. res.InfRefmsgid = resSix10265.InfRefmsgid
  1780. //res.Output = resSix10265.Output
  1781. res.ErrMsg = resSix10265.ErrMsg
  1782. res.Cainfo = resSix10265.Cainfo
  1783. res.WarnMsg = resSix10265.WarnMsg
  1784. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1785. res.Infcode = infocode
  1786. }
  1787. if res.Infcode == 0 {
  1788. item.IsSale = 0
  1789. item.SaleDate = ""
  1790. service.SaveDF(item)
  1791. } else {
  1792. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1793. }
  1794. }
  1795. if item.IsSale == 2 && item.IsChange == 0 {
  1796. var res FJ3507Result
  1797. var struct3507 models.Struct3507
  1798. struct3507.FixmedinsBchno = item.Bchno
  1799. struct3507.InvDataType = "4"
  1800. struct3507.Opter = roles.UserName
  1801. struct3507.FixmedinsCode = miConfig.Code
  1802. struct3507.Code = miConfig.Code
  1803. struct3507.OrgName = miConfig.OrgName
  1804. struct3507.AccessKey = miConfig.AccessKey
  1805. struct3507.RequestUrl = miConfig.Url
  1806. struct3507.SecretKey = miConfig.SecretKey
  1807. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1808. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1809. struct3507.Url = miConfig.Url
  1810. struct3507.AppId = miConfig.Cainfo
  1811. struct3507.AppSecret = miConfig.AppSecret
  1812. struct3507.Enckey = miConfig.EncKey
  1813. struct3507.SignKey = miConfig.SignKey
  1814. struct3507.SecretKey = miConfig.SecretKey
  1815. //result, result1, _ := service.FJyb3507(struct3507)
  1816. //saveLog(result, result1, "3507", "3507")
  1817. //
  1818. //var respJSON3 map[string]interface{}
  1819. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1820. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1822. // return
  1823. //}
  1824. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1825. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1826. // utils.ErrorLog("解析失败:%v", err)
  1827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1828. // return
  1829. //}
  1830. if miConfig.MdtrtareaAdmvs == "350500" {
  1831. result, result1, _ := service.FJyb3507(struct3507)
  1832. saveLog(result, result1, "3507", "3507")
  1833. var respJSON2 map[string]interface{}
  1834. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1837. return
  1838. }
  1839. userJSONBytes2, _ := json.Marshal(respJSON2)
  1840. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1841. utils.ErrorLog("解析失败:%v", err)
  1842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1843. return
  1844. }
  1845. } else {
  1846. data := make(map[string]interface{})
  1847. data["struct_3507s"] = struct3507
  1848. client := &http.Client{}
  1849. bytesData, _ := json.Marshal(data)
  1850. var req *http.Request
  1851. if miConfig.MdtrtareaAdmvs == "320921" {
  1852. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1853. } else {
  1854. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1855. }
  1856. resp, _ := client.Do(req)
  1857. defer resp.Body.Close()
  1858. body, ioErr := ioutil.ReadAll(resp.Body)
  1859. if ioErr != nil {
  1860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1861. }
  1862. var respJSON map[string]interface{}
  1863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1866. return
  1867. }
  1868. var resSix10265 ResultSix10265 //1101结果
  1869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1870. result, _ := json.Marshal(respJSON)
  1871. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1872. utils.ErrorLog("解析失败:%v", err)
  1873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1874. return
  1875. }
  1876. res.InfRefmsgid = resSix10265.InfRefmsgid
  1877. //res.Output = resSix10265.Output
  1878. res.ErrMsg = resSix10265.ErrMsg
  1879. res.Cainfo = resSix10265.Cainfo
  1880. res.WarnMsg = resSix10265.WarnMsg
  1881. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1882. res.Infcode = infocode
  1883. }
  1884. if res.Infcode == 0 {
  1885. item.IsSale = 0
  1886. item.SaleDate = ""
  1887. item.Bchno = ""
  1888. service.SaveDF(item)
  1889. } else {
  1890. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1891. }
  1892. }
  1893. if item.IsSale == 0 && item.IsChange == 1 {
  1894. var res FJ3507Result
  1895. var struct3507 models.Struct3507
  1896. struct3507.FixmedinsBchno = item.BgBchno
  1897. struct3507.InvDataType = "2"
  1898. struct3507.Opter = roles.UserName
  1899. struct3507.FixmedinsCode = miConfig.Code
  1900. struct3507.Code = miConfig.Code
  1901. struct3507.OrgName = miConfig.OrgName
  1902. struct3507.AccessKey = miConfig.AccessKey
  1903. struct3507.RequestUrl = miConfig.Url
  1904. struct3507.SecretKey = miConfig.SecretKey
  1905. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1906. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1907. struct3507.Url = miConfig.Url
  1908. struct3507.AppId = miConfig.Cainfo
  1909. struct3507.AppSecret = miConfig.AppSecret
  1910. struct3507.Enckey = miConfig.EncKey
  1911. struct3507.SignKey = miConfig.SignKey
  1912. struct3507.SecretKey = miConfig.SecretKey
  1913. //result, result1, _ := service.FJyb3507(struct3507)
  1914. //saveLog(result, result1, "3507", "3507")
  1915. //
  1916. //var respJSON3 map[string]interface{}
  1917. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1918. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1920. // return
  1921. //}
  1922. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1923. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1924. // utils.ErrorLog("解析失败:%v", err)
  1925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. // return
  1927. //}
  1928. if miConfig.MdtrtareaAdmvs == "350500" {
  1929. result, result1, _ := service.FJyb3507(struct3507)
  1930. saveLog(result, result1, "3507", "3507")
  1931. var respJSON2 map[string]interface{}
  1932. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1935. return
  1936. }
  1937. userJSONBytes2, _ := json.Marshal(respJSON2)
  1938. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1939. utils.ErrorLog("解析失败:%v", err)
  1940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1941. return
  1942. }
  1943. } else {
  1944. data := make(map[string]interface{})
  1945. data["struct_3507s"] = struct3507
  1946. client := &http.Client{}
  1947. bytesData, _ := json.Marshal(data)
  1948. var req *http.Request
  1949. if miConfig.MdtrtareaAdmvs == "320921" {
  1950. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1951. } else {
  1952. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1953. }
  1954. resp, _ := client.Do(req)
  1955. defer resp.Body.Close()
  1956. body, ioErr := ioutil.ReadAll(resp.Body)
  1957. if ioErr != nil {
  1958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1959. }
  1960. var respJSON map[string]interface{}
  1961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1964. return
  1965. }
  1966. var resSix10265 ResultSix10265 //1101结果
  1967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1968. result, _ := json.Marshal(respJSON)
  1969. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1970. utils.ErrorLog("解析失败:%v", err)
  1971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1972. return
  1973. }
  1974. res.InfRefmsgid = resSix10265.InfRefmsgid
  1975. //res.Output = resSix10265.Output
  1976. res.ErrMsg = resSix10265.ErrMsg
  1977. res.Cainfo = resSix10265.Cainfo
  1978. res.WarnMsg = resSix10265.WarnMsg
  1979. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1980. res.Infcode = infocode
  1981. }
  1982. if res.Infcode == 0 {
  1983. item.IsChange = 0
  1984. item.BgBchno = ""
  1985. service.SaveDF2(item)
  1986. } else {
  1987. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1988. }
  1989. }
  1990. }
  1991. if len(err) == 0 {
  1992. c.ServeSuccessJSON(map[string]interface{}{
  1993. "msg": "删除销售变更成功",
  1994. })
  1995. } else {
  1996. c.ServeSuccessJSON(map[string]interface{}{
  1997. "failed_code": -10,
  1998. "msg": err,
  1999. })
  2000. }
  2001. }
  2002. //func (c *HisApiController) BatchFJ3501AND3502() {
  2003. // //ids := c.GetString("ids")
  2004. // start_time := c.GetString("start_time")
  2005. // end_time := c.GetString("end_time")
  2006. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2007. //
  2008. //
  2009. // timeLayout := "2006-01-02"
  2010. // loc, _ := time.LoadLocation("Local")
  2011. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2012. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2013. //
  2014. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2015. // //id_arr := strings.Split(ids, ",")
  2016. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2017. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2018. // //库盘
  2019. // var errs []string
  2020. // for _, drug := range drugs {
  2021. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2022. // var res2 ResultSix
  2023. // var res3 ResultSix
  2024. //
  2025. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2026. // var struct3501 models.Struct3501
  2027. // struct3501.Code = miConfig.Code
  2028. // struct3501.OrgName = miConfig.OrgName
  2029. // struct3501.AccessKey = miConfig.AccessKey
  2030. // struct3501.Opter = roles.UserName
  2031. // struct3501.RequestUrl = miConfig.Url
  2032. // struct3501.Url = miConfig.Url
  2033. // struct3501.AppId = miConfig.Cainfo
  2034. // struct3501.AppSecret = miConfig.AppSecret
  2035. // struct3501.Enckey = miConfig.EncKey
  2036. // struct3501.SignKey = miConfig.SignKey
  2037. // struct3501.SecretKey = miConfig.SecretKey
  2038. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2039. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2041. // struct3501.RxFlag = "1"
  2042. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2043. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2044. //
  2045. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2046. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2047. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2048. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2049. // struct3501.FixmedinsBchno = number
  2050. // struct3501.DrugTracCodg = drug.DrugCode
  2051. // memo := make(map[string]interface{})
  2052. // memo["pric"] = drug.Price
  2053. // bytesData, _ := json.Marshal(memo)
  2054. // struct3501.Memo = string(bytesData)
  2055. //
  2056. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2057. //
  2058. // result1, result2, _ := service.FJyb3501(struct3501)
  2059. // saveLog(result1, result2, "3501", "3501")
  2060. // //saveLog(result, requestLog, "2201", "挂号")
  2061. //
  2062. // var respJSON2 map[string]interface{}
  2063. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2064. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2066. // return
  2067. // }
  2068. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2069. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2070. // utils.ErrorLog("解析失败:%v", err)
  2071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2072. // return
  2073. // }
  2074. //
  2075. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2076. // data := make(map[string]interface{})
  2077. // data["struct_3501s"] = struct3501
  2078. // client := &http.Client{}
  2079. // bytesData, _ := json.Marshal(data)
  2080. // var req *http.Request
  2081. // if miConfig.MdtrtareaAdmvs == "320921" {
  2082. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2083. // } else {
  2084. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2085. // }
  2086. //
  2087. // resp, _ := client.Do(req)
  2088. // defer resp.Body.Close()
  2089. // body, ioErr := ioutil.ReadAll(resp.Body)
  2090. // if ioErr != nil {
  2091. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2092. // }
  2093. // var respJSON map[string]interface{}
  2094. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2095. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2097. // return
  2098. // }
  2099. // var resSix10265 ResultSix10265 //1101结果
  2100. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2101. // result, _ := json.Marshal(respJSON)
  2102. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2103. // utils.ErrorLog("解析失败:%v", err)
  2104. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2105. // return
  2106. // }
  2107. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2108. // res2.Output = resSix10265.Output
  2109. // res2.ErrMsg = resSix10265.ErrMsg
  2110. // res2.Cainfo = resSix10265.Cainfo
  2111. // res2.WarnMsg = resSix10265.WarnMsg
  2112. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2113. // res2.Infcode = infocode
  2114. //
  2115. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2116. // data := make(map[string]interface{})
  2117. // data["struct_3501s"] = struct3501
  2118. // client := &http.Client{}
  2119. // bytesData, _ := json.Marshal(data)
  2120. // var req *http.Request
  2121. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2122. // resp, _ := client.Do(req)
  2123. // defer resp.Body.Close()
  2124. // body, ioErr := ioutil.ReadAll(resp.Body)
  2125. // if ioErr != nil {
  2126. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2127. // }
  2128. // var respJSON map[string]interface{}
  2129. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2130. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2132. // return
  2133. // }
  2134. // var resSix10265 ResultSix10265 //1101结果
  2135. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2136. // result, _ := json.Marshal(respJSON)
  2137. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2138. // utils.ErrorLog("解析失败:%v", err)
  2139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2140. // return
  2141. // }
  2142. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2143. // res2.Output = resSix10265.Output
  2144. // res2.ErrMsg = resSix10265.ErrMsg
  2145. // res2.Cainfo = resSix10265.Cainfo
  2146. // res2.WarnMsg = resSix10265.WarnMsg
  2147. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2148. // res2.Infcode = infocode
  2149. //
  2150. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2151. // data := make(map[string]interface{})
  2152. // data["struct_3501s"] = struct3501
  2153. // client := &http.Client{}
  2154. // bytesData, _ := json.Marshal(data)
  2155. // var req *http.Request
  2156. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2157. // resp, _ := client.Do(req)
  2158. // defer resp.Body.Close()
  2159. // body, ioErr := ioutil.ReadAll(resp.Body)
  2160. // if ioErr != nil {
  2161. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2162. // }
  2163. // var respJSON map[string]interface{}
  2164. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2165. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2167. // return
  2168. // }
  2169. // var resSix10265 ResultSix10265 //1101结果
  2170. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2171. // result, _ := json.Marshal(respJSON)
  2172. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2173. // utils.ErrorLog("解析失败:%v", err)
  2174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2175. // return
  2176. // }
  2177. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2178. // res2.Output = resSix10265.Output
  2179. // res2.ErrMsg = resSix10265.ErrMsg
  2180. // res2.Cainfo = resSix10265.Cainfo
  2181. // res2.WarnMsg = resSix10265.WarnMsg
  2182. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2183. // res2.Infcode = infocode
  2184. //
  2185. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2186. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2187. // saveLog(result1, result2, "3501", "3501")
  2188. // //saveLog(result, requestLog, "2201", "挂号")
  2189. //
  2190. // var respJSON2 map[string]interface{}
  2191. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2192. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2194. // return
  2195. // }
  2196. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2197. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2198. // utils.ErrorLog("解析失败:%v", err)
  2199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2200. // return
  2201. // }
  2202. //
  2203. // }
  2204. //
  2205. // if res2.Infcode != -1 {
  2206. // drug.IsPc = 1
  2207. // drug.Bchno = number
  2208. // drug.PcDate = time.Now().Unix()
  2209. // err := service.SaveW(drug)
  2210. // if err == nil {
  2211. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2212. // var struct3502 models.Struct3502
  2213. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2214. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2216. // struct3502.FixmedinsCode = miConfig.Code
  2217. // struct3502.Code = miConfig.Code
  2218. //
  2219. // struct3502.RxFlag = "0"
  2220. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2221. // struct3502.OrgName = miConfig.OrgName
  2222. // struct3502.Opter = roles.UserName
  2223. // struct3502.AccessKey = miConfig.AccessKey
  2224. // struct3502.RequestUrl = miConfig.Url
  2225. // struct3502.SecretKey = miConfig.SecretKey
  2226. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2227. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2228. // struct3502.Url = miConfig.Url
  2229. // struct3502.AppId = miConfig.Cainfo
  2230. // struct3502.AppSecret = miConfig.AppSecret
  2231. // struct3502.Enckey = miConfig.EncKey
  2232. // struct3502.SignKey = miConfig.SignKey
  2233. // struct3502.SecretKey = miConfig.SecretKey
  2234. // struct3502.DrugTracCodg = drug.DrugCode
  2235. //
  2236. // struct3502.Memo = ""
  2237. // struct3502.InvChgType = "108"
  2238. // struct3502.FixmedinsBchno = bg_number
  2239. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2240. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2241. //
  2242. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2243. // result11, result22, _ := service.FJyb3502(struct3502)
  2244. // saveLog(result11, result22, "3502", "3502")
  2245. //
  2246. // var respJSON3 map[string]interface{}
  2247. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2248. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2250. // return
  2251. // }
  2252. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2253. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2254. // utils.ErrorLog("解析失败:%v", err)
  2255. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2256. // return
  2257. // }
  2258. //
  2259. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2260. // data := make(map[string]interface{})
  2261. // data["struct_3502s"] = struct3502
  2262. // client := &http.Client{}
  2263. // bytesData, _ := json.Marshal(data)
  2264. // var req *http.Request
  2265. // if miConfig.MdtrtareaAdmvs == "320921" {
  2266. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2267. // } else {
  2268. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2269. // }
  2270. //
  2271. // resp, _ := client.Do(req)
  2272. // defer resp.Body.Close()
  2273. // body, ioErr := ioutil.ReadAll(resp.Body)
  2274. // if ioErr != nil {
  2275. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2276. // }
  2277. // var respJSON map[string]interface{}
  2278. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2279. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2281. // return
  2282. // }
  2283. // var resSix10265 ResultSix10265 //1101结果
  2284. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2285. // result, _ := json.Marshal(respJSON)
  2286. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2287. // utils.ErrorLog("解析失败:%v", err)
  2288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2289. // return
  2290. // }
  2291. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2292. // res3.Output = resSix10265.Output
  2293. // res3.ErrMsg = resSix10265.ErrMsg
  2294. // res3.Cainfo = resSix10265.Cainfo
  2295. // res3.WarnMsg = resSix10265.WarnMsg
  2296. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2297. // res3.Infcode = infocode
  2298. //
  2299. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2300. //
  2301. // data := make(map[string]interface{})
  2302. // data["struct_3502s"] = struct3502
  2303. // client := &http.Client{}
  2304. // bytesData, _ := json.Marshal(data)
  2305. // var req *http.Request
  2306. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2307. // resp, _ := client.Do(req)
  2308. // defer resp.Body.Close()
  2309. // body, ioErr := ioutil.ReadAll(resp.Body)
  2310. // if ioErr != nil {
  2311. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2312. // }
  2313. // var respJSON map[string]interface{}
  2314. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2315. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2316. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2317. // return
  2318. // }
  2319. // var resSix10265 ResultSix10265 //1101结果
  2320. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2321. // result, _ := json.Marshal(respJSON)
  2322. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2323. // utils.ErrorLog("解析失败:%v", err)
  2324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2325. // return
  2326. // }
  2327. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2328. // res3.Output = resSix10265.Output
  2329. // res3.ErrMsg = resSix10265.ErrMsg
  2330. // res3.Cainfo = resSix10265.Cainfo
  2331. // res3.WarnMsg = resSix10265.WarnMsg
  2332. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2333. // res3.Infcode = infocode
  2334. //
  2335. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2336. //
  2337. // data := make(map[string]interface{})
  2338. // data["struct_3501s"] = struct3501
  2339. // client := &http.Client{}
  2340. // bytesData, _ := json.Marshal(data)
  2341. // var req *http.Request
  2342. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2343. // resp, _ := client.Do(req)
  2344. // defer resp.Body.Close()
  2345. // body, ioErr := ioutil.ReadAll(resp.Body)
  2346. // if ioErr != nil {
  2347. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2348. // }
  2349. // var respJSON map[string]interface{}
  2350. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2351. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2353. // return
  2354. // }
  2355. // var resSix10265 ResultSix10265 //1101结果
  2356. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2357. // result, _ := json.Marshal(respJSON)
  2358. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2359. // utils.ErrorLog("解析失败:%v", err)
  2360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2361. // return
  2362. // }
  2363. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2364. // res2.Output = resSix10265.Output
  2365. // res2.ErrMsg = resSix10265.ErrMsg
  2366. // res2.Cainfo = resSix10265.Cainfo
  2367. // res2.WarnMsg = resSix10265.WarnMsg
  2368. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2369. // res2.Infcode = infocode
  2370. //
  2371. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2372. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2373. // saveLog(result11, result22, "3502", "3502")
  2374. //
  2375. // var respJSON3 map[string]interface{}
  2376. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2377. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2379. // return
  2380. // }
  2381. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2382. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2383. // utils.ErrorLog("解析失败:%v", err)
  2384. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2385. // return
  2386. // }
  2387. // }
  2388. // if res3.Infcode == -1 {
  2389. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2390. // c.ServeSuccessJSON(map[string]interface{}{
  2391. // "failed_code": -10,
  2392. // "msg": res3.ErrMsg,
  2393. // })
  2394. // } else {
  2395. // drug.IsBg = 1
  2396. // drug.BgBchno = bg_number
  2397. // service.SaveW(drug)
  2398. // }
  2399. // }
  2400. // } else {
  2401. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2402. // }
  2403. // }
  2404. // //变更
  2405. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2406. // var res3 ResultSix
  2407. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2408. //
  2409. // var struct3502 models.Struct3502
  2410. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2411. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2413. // struct3502.FixmedinsCode = miConfig.Code
  2414. // struct3502.Code = miConfig.Code
  2415. //
  2416. // struct3502.Opter = roles.UserName
  2417. // struct3502.RxFlag = "0"
  2418. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2419. // struct3502.OrgName = miConfig.OrgName
  2420. // struct3502.AccessKey = miConfig.AccessKey
  2421. // struct3502.RequestUrl = miConfig.Url
  2422. // struct3502.SecretKey = miConfig.SecretKey
  2423. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2424. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2425. // struct3502.InvChgType = "108"
  2426. // struct3502.DrugTracCodg = drug.DrugCode
  2427. //
  2428. // struct3502.Url = miConfig.Url
  2429. // struct3502.AppId = miConfig.Cainfo
  2430. // struct3502.AppSecret = miConfig.AppSecret
  2431. // struct3502.Enckey = miConfig.EncKey
  2432. // struct3502.SignKey = miConfig.SignKey
  2433. // struct3502.SecretKey = miConfig.SecretKey
  2434. //
  2435. // struct3502.FixmedinsBchno = bg_number
  2436. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2437. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2438. //
  2439. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2440. // result1, result2, _ := service.FJyb3502(struct3502)
  2441. // saveLog(result1, result2, "3502", "3502")
  2442. // var respJSON3 map[string]interface{}
  2443. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2444. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2446. // return
  2447. // }
  2448. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2449. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2450. // utils.ErrorLog("解析失败:%v", err)
  2451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2452. // return
  2453. // }
  2454. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2455. // data := make(map[string]interface{})
  2456. // data["struct_3502s"] = struct3502
  2457. // client := &http.Client{}
  2458. // bytesData, _ := json.Marshal(data)
  2459. // var req *http.Request
  2460. // if miConfig.MdtrtareaAdmvs == "320921" {
  2461. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2462. // } else {
  2463. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2464. // }
  2465. // resp, _ := client.Do(req)
  2466. // defer resp.Body.Close()
  2467. // body, ioErr := ioutil.ReadAll(resp.Body)
  2468. // if ioErr != nil {
  2469. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2470. // }
  2471. // var respJSON map[string]interface{}
  2472. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2473. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2475. // return
  2476. // }
  2477. // var resSix10265 ResultSix10265 //1101结果
  2478. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2479. // result, _ := json.Marshal(respJSON)
  2480. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2481. // utils.ErrorLog("解析失败:%v", err)
  2482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2483. // return
  2484. // }
  2485. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2486. // res3.Output = resSix10265.Output
  2487. // res3.ErrMsg = resSix10265.ErrMsg
  2488. // res3.Cainfo = resSix10265.Cainfo
  2489. // res3.WarnMsg = resSix10265.WarnMsg
  2490. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2491. // res3.Infcode = infocode
  2492. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2493. //
  2494. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2495. //
  2496. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2497. //
  2498. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2499. //
  2500. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2501. // saveLog(result1, result2, "3501", "3501")
  2502. // //saveLog(result, requestLog, "2201", "挂号")
  2503. //
  2504. // var respJSON2 map[string]interface{}
  2505. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2506. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2508. // return
  2509. // }
  2510. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2511. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2512. // utils.ErrorLog("解析失败:%v", err)
  2513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2514. // return
  2515. // }
  2516. //
  2517. // }
  2518. // if res3.Infcode == -1 {
  2519. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2520. // } else {
  2521. // drug.IsBg = 1
  2522. // drug.BgBchno = bg_number
  2523. // service.SaveW(drug)
  2524. // }
  2525. // }
  2526. // }
  2527. //
  2528. // if len(errs) == 0 {
  2529. // c.ServeSuccessJSON(map[string]interface{}{
  2530. // "msg": "盘存变更成功",
  2531. // })
  2532. // } else {
  2533. // c.ServeSuccessJSON(map[string]interface{}{
  2534. // "failed_code": -10,
  2535. // "msg": errs,
  2536. // })
  2537. // }
  2538. //}
  2539. func (c *HisApiController) DeleteXSandBGTwo() {
  2540. patient_id, _ := c.GetInt64("patient_id")
  2541. admin_user_id, _ := c.GetInt64("admin_user_id")
  2542. times := c.GetString("time", "")
  2543. timeLayout := "2006-01-02"
  2544. loc, _ := time.LoadLocation("Local")
  2545. var stime, etime int64
  2546. if times == "" {
  2547. stime, etime = GetNowTime()
  2548. } else {
  2549. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2550. stime = stmp.Unix()
  2551. etime = stime + 86399
  2552. }
  2553. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2554. var flows []*models.DrugFlow
  2555. for _, item := range advicelist {
  2556. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2557. flows = append(flows, flow...)
  2558. }
  2559. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2560. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2561. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2562. var err []string
  2563. for _, item := range flows {
  2564. if item.IsSale == 1 {
  2565. var res FJ3507Result
  2566. var struct3507 models.Struct3507
  2567. struct3507.FixmedinsBchno = item.Bchno
  2568. struct3507.InvDataType = "4"
  2569. struct3507.Opter = roles.UserName
  2570. struct3507.OrgName = miConfig.OrgName
  2571. struct3507.AccessKey = miConfig.AccessKey
  2572. struct3507.RequestUrl = miConfig.Url
  2573. struct3507.FixmedinsCode = miConfig.Code
  2574. struct3507.SecretKey = miConfig.SecretKey
  2575. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2576. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2577. struct3507.Url = miConfig.Url
  2578. struct3507.AppId = miConfig.Cainfo
  2579. struct3507.AppSecret = miConfig.AppSecret
  2580. struct3507.Enckey = miConfig.EncKey
  2581. struct3507.SignKey = miConfig.SignKey
  2582. struct3507.SecretKey = miConfig.SecretKey
  2583. if miConfig.MdtrtareaAdmvs == "350500" {
  2584. result, result1, _ := service.FJyb3507(struct3507)
  2585. saveLog(result, result1, "3507", "3507")
  2586. var respJSON2 map[string]interface{}
  2587. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2590. return
  2591. }
  2592. userJSONBytes2, _ := json.Marshal(respJSON2)
  2593. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2594. utils.ErrorLog("解析失败:%v", err)
  2595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2596. return
  2597. }
  2598. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2599. data := make(map[string]interface{})
  2600. data["struct_3507s"] = struct3507
  2601. client := &http.Client{}
  2602. bytesData, _ := json.Marshal(data)
  2603. var req *http.Request
  2604. if miConfig.MdtrtareaAdmvs == "320921" {
  2605. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2606. } else {
  2607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2608. }
  2609. resp, _ := client.Do(req)
  2610. defer resp.Body.Close()
  2611. body, ioErr := ioutil.ReadAll(resp.Body)
  2612. if ioErr != nil {
  2613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2614. }
  2615. var respJSON map[string]interface{}
  2616. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2619. return
  2620. }
  2621. var resSix10265 ResultSix10265 //1101结果
  2622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2623. result, _ := json.Marshal(respJSON)
  2624. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2625. utils.ErrorLog("解析失败:%v", err)
  2626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2627. return
  2628. }
  2629. res.InfRefmsgid = resSix10265.InfRefmsgid
  2630. //res.Output = resSix10265.Output
  2631. res.ErrMsg = resSix10265.ErrMsg
  2632. res.Cainfo = resSix10265.Cainfo
  2633. res.WarnMsg = resSix10265.WarnMsg
  2634. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2635. res.Infcode = infocode
  2636. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2637. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2638. saveLog(result2, result1, "3507", "3507")
  2639. var respJSON2 map[string]interface{}
  2640. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2643. return
  2644. }
  2645. userJSONBytes2, _ := json.Marshal(respJSON2)
  2646. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2647. utils.ErrorLog("解析失败:%v", err)
  2648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2649. return
  2650. }
  2651. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2652. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2653. saveLog(result2, result1, "3507", "3507")
  2654. var respJSON2 map[string]interface{}
  2655. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2658. return
  2659. }
  2660. userJSONBytes2, _ := json.Marshal(respJSON2)
  2661. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2662. utils.ErrorLog("解析失败:%v", err)
  2663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2664. return
  2665. }
  2666. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2667. result1, result2 := service.Jxyb3507(struct3507)
  2668. saveLog(result2, result1, "3507", "3507")
  2669. var respJSON2 map[string]interface{}
  2670. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. return
  2674. }
  2675. userJSONBytes2, _ := json.Marshal(respJSON2)
  2676. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2677. utils.ErrorLog("解析失败:%v", err)
  2678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2679. return
  2680. }
  2681. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2682. result1, result2 := service.AHyb3507(struct3507)
  2683. saveLog(result2, result1, "3507", "3507")
  2684. var respJSON2 map[string]interface{}
  2685. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2688. return
  2689. }
  2690. userJSONBytes2, _ := json.Marshal(respJSON2)
  2691. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2692. utils.ErrorLog("解析失败:%v", err)
  2693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2694. return
  2695. }
  2696. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2697. data := make(map[string]interface{})
  2698. data["struct_3507s"] = struct3507
  2699. client := &http.Client{}
  2700. bytesData, _ := json.Marshal(data)
  2701. var req *http.Request
  2702. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2703. resp, _ := client.Do(req)
  2704. defer resp.Body.Close()
  2705. body, ioErr := ioutil.ReadAll(resp.Body)
  2706. if ioErr != nil {
  2707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2708. }
  2709. var respJSON map[string]interface{}
  2710. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2712. }
  2713. var resSix10265 ResultSix10265 //1101结果
  2714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2715. result, _ := json.Marshal(respJSON)
  2716. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2717. utils.ErrorLog("解析失败:%v", err)
  2718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2719. return
  2720. }
  2721. res.InfRefmsgid = resSix10265.InfRefmsgid
  2722. res.ErrMsg = resSix10265.ErrMsg
  2723. res.Cainfo = resSix10265.Cainfo
  2724. res.WarnMsg = resSix10265.WarnMsg
  2725. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2726. res.Infcode = infocode
  2727. }
  2728. if res.Infcode == 0 {
  2729. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2730. item.IsSale = 0
  2731. item.SaleDate = ""
  2732. item.Bchno = ""
  2733. service.SaveDF(item)
  2734. } else {
  2735. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2736. }
  2737. }
  2738. }
  2739. c.ServeSuccessJSON(map[string]interface{}{
  2740. "msg": "删除销售数据成功",
  2741. })
  2742. }
  2743. func (c *HisApiController) DeleteXSandBGThree() {
  2744. id, _ := c.GetInt64("id")
  2745. admin_user_id, _ := c.GetInt64("admin_user_id")
  2746. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2747. var flows []*models.DrugFlow
  2748. for _, item := range advicelist {
  2749. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2750. flows = append(flows, flow...)
  2751. }
  2752. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2753. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2754. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2755. var err []string
  2756. for _, item := range flows {
  2757. if item.IsSale == 1 {
  2758. var res FJ3507Result
  2759. var struct3507 models.Struct3507
  2760. struct3507.FixmedinsBchno = item.Bchno
  2761. struct3507.InvDataType = "4"
  2762. struct3507.Opter = roles.UserName
  2763. struct3507.OrgName = miConfig.OrgName
  2764. struct3507.AccessKey = miConfig.AccessKey
  2765. struct3507.RequestUrl = miConfig.Url
  2766. struct3507.FixmedinsCode = miConfig.Code
  2767. struct3507.SecretKey = miConfig.SecretKey
  2768. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2769. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2770. struct3507.Url = miConfig.Url
  2771. struct3507.AppId = miConfig.Cainfo
  2772. struct3507.AppSecret = miConfig.AppSecret
  2773. struct3507.Enckey = miConfig.EncKey
  2774. struct3507.SignKey = miConfig.SignKey
  2775. struct3507.SecretKey = miConfig.SecretKey
  2776. if miConfig.MdtrtareaAdmvs == "350500" {
  2777. result, result1, _ := service.FJyb3507(struct3507)
  2778. saveLog(result, result1, "3507", "3507")
  2779. var respJSON2 map[string]interface{}
  2780. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2783. return
  2784. }
  2785. userJSONBytes2, _ := json.Marshal(respJSON2)
  2786. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2787. utils.ErrorLog("解析失败:%v", err)
  2788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2789. return
  2790. }
  2791. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2792. data := make(map[string]interface{})
  2793. data["struct_3507s"] = struct3507
  2794. client := &http.Client{}
  2795. bytesData, _ := json.Marshal(data)
  2796. var req *http.Request
  2797. if miConfig.MdtrtareaAdmvs == "320921" {
  2798. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2799. } else {
  2800. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2801. }
  2802. resp, _ := client.Do(req)
  2803. defer resp.Body.Close()
  2804. body, ioErr := ioutil.ReadAll(resp.Body)
  2805. if ioErr != nil {
  2806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2807. }
  2808. var respJSON map[string]interface{}
  2809. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2812. return
  2813. }
  2814. var resSix10265 ResultSix10265 //1101结果
  2815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2816. result, _ := json.Marshal(respJSON)
  2817. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2818. utils.ErrorLog("解析失败:%v", err)
  2819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2820. return
  2821. }
  2822. res.InfRefmsgid = resSix10265.InfRefmsgid
  2823. //res.Output = resSix10265.Output
  2824. res.ErrMsg = resSix10265.ErrMsg
  2825. res.Cainfo = resSix10265.Cainfo
  2826. res.WarnMsg = resSix10265.WarnMsg
  2827. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2828. res.Infcode = infocode
  2829. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2830. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2831. saveLog(result2, result1, "3507", "3507")
  2832. var respJSON2 map[string]interface{}
  2833. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2836. return
  2837. }
  2838. userJSONBytes2, _ := json.Marshal(respJSON2)
  2839. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2840. utils.ErrorLog("解析失败:%v", err)
  2841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2842. return
  2843. }
  2844. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2845. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2846. saveLog(result2, result1, "3507", "3507")
  2847. var respJSON2 map[string]interface{}
  2848. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2851. return
  2852. }
  2853. userJSONBytes2, _ := json.Marshal(respJSON2)
  2854. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2855. utils.ErrorLog("解析失败:%v", err)
  2856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2857. return
  2858. }
  2859. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2860. result1, result2 := service.Jxyb3507(struct3507)
  2861. saveLog(result2, result1, "3507", "3507")
  2862. var respJSON2 map[string]interface{}
  2863. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2866. return
  2867. }
  2868. userJSONBytes2, _ := json.Marshal(respJSON2)
  2869. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2870. utils.ErrorLog("解析失败:%v", err)
  2871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2872. return
  2873. }
  2874. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2875. result1, result2 := service.AHyb3507(struct3507)
  2876. saveLog(result2, result1, "3507", "3507")
  2877. var respJSON2 map[string]interface{}
  2878. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2881. return
  2882. }
  2883. userJSONBytes2, _ := json.Marshal(respJSON2)
  2884. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2885. utils.ErrorLog("解析失败:%v", err)
  2886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2887. return
  2888. }
  2889. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2890. data := make(map[string]interface{})
  2891. data["struct_3507s"] = struct3507
  2892. client := &http.Client{}
  2893. bytesData, _ := json.Marshal(data)
  2894. var req *http.Request
  2895. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2896. resp, _ := client.Do(req)
  2897. defer resp.Body.Close()
  2898. body, ioErr := ioutil.ReadAll(resp.Body)
  2899. if ioErr != nil {
  2900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2901. }
  2902. var respJSON map[string]interface{}
  2903. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2905. }
  2906. var resSix10265 ResultSix10265 //1101结果
  2907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2908. result, _ := json.Marshal(respJSON)
  2909. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2910. utils.ErrorLog("解析失败:%v", err)
  2911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2912. return
  2913. }
  2914. res.InfRefmsgid = resSix10265.InfRefmsgid
  2915. res.ErrMsg = resSix10265.ErrMsg
  2916. res.Cainfo = resSix10265.Cainfo
  2917. res.WarnMsg = resSix10265.WarnMsg
  2918. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2919. res.Infcode = infocode
  2920. }
  2921. if res.Infcode == 0 {
  2922. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2923. item.IsSale = 0
  2924. item.SaleDate = ""
  2925. item.Bchno = ""
  2926. service.SaveDF(item)
  2927. } else {
  2928. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2929. }
  2930. }
  2931. }
  2932. c.ServeSuccessJSON(map[string]interface{}{
  2933. "msg": "删除销售数据成功",
  2934. })
  2935. }
  2936. // 获取当天起止时间戳
  2937. func GetNowTime() (int64, int64) {
  2938. t := time.Now()
  2939. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2940. timesamp := addTime.Unix()
  2941. return timesamp, timesamp + 86399
  2942. }
  2943. func (c *HisApiController) ChangeDrugfour() {
  2944. patient_id, _ := c.GetInt64("patient_id")
  2945. admin_user_id, _ := c.GetInt64("admin_user_id")
  2946. times := c.GetString("time", "")
  2947. timeLayout := "2006-01-02"
  2948. loc, _ := time.LoadLocation("Local")
  2949. var stime, etime int64
  2950. if times == "" {
  2951. stime, etime = GetNowTime()
  2952. } else {
  2953. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2954. stime = stmp.Unix()
  2955. etime = stime + 86399
  2956. }
  2957. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2958. var flows []*models.DrugFlow
  2959. for _, item := range advicelist {
  2960. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2961. flows = append(flows, flow...)
  2962. }
  2963. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2964. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2965. var err []string
  2966. for _, item := range flows {
  2967. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2968. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2969. if prescription.OrderStatus == 2 {
  2970. if item.IsSale == 0 {
  2971. var res FJ3507Result
  2972. var res3507for10188 FJ3507ResultFor10188
  2973. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2974. //进行商品销售接口
  2975. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2976. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2977. var respJSON3 map[string]interface{}
  2978. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2981. return
  2982. }
  2983. userJSONBytes3, _ := json.Marshal(respJSON3)
  2984. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2985. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2986. utils.ErrorLog("解析失败:%v", err)
  2987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2988. return
  2989. }
  2990. //if res3507for10188.Infcode
  2991. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2992. //res.Output = resSix10265.Output
  2993. res.ErrMsg = res3507for10188.ErrMsg
  2994. res.Cainfo = res3507for10188.Cainfo
  2995. res.WarnMsg = res3507for10188.WarnMsg
  2996. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2997. res.Infcode = infocode
  2998. } else {
  2999. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3000. utils.ErrorLog("解析失败:%v", err)
  3001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3002. return
  3003. }
  3004. }
  3005. if res.Infcode == 0 {
  3006. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3007. item.IsSale = 1
  3008. item.Bchno = number
  3009. item.SaleDate = time.Now().Format("2006-01-02")
  3010. service.SaveDF(item)
  3011. } else {
  3012. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3013. }
  3014. }
  3015. } else { //还没结,提示用户去结算,并药品追溯上传
  3016. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3017. }
  3018. }
  3019. }
  3020. str := strings.Join(err, " ")
  3021. saveLog(str, str, "3505", "3505自动上传日志")
  3022. c.ServeSuccessJSON(map[string]interface{}{
  3023. "status": "1",
  3024. "msg": err,
  3025. })
  3026. }
  3027. func (c *HisApiController) ChangeDrugFive() {
  3028. id, _ := c.GetInt64("id")
  3029. admin_user_id, _ := c.GetInt64("admin_user_id")
  3030. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3031. var flows []*models.DrugFlow
  3032. for _, item := range advicelist {
  3033. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3034. flows = append(flows, flow...)
  3035. }
  3036. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3037. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3038. var err []string
  3039. for _, item := range flows {
  3040. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3041. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3042. if prescription.OrderStatus == 2 {
  3043. if item.IsSale == 0 {
  3044. var res FJ3507Result
  3045. var res3507for10188 FJ3507ResultFor10188
  3046. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3047. //进行商品销售接口
  3048. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3049. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3050. var respJSON3 map[string]interface{}
  3051. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3054. return
  3055. }
  3056. userJSONBytes3, _ := json.Marshal(respJSON3)
  3057. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3058. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3059. utils.ErrorLog("解析失败:%v", err)
  3060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3061. return
  3062. }
  3063. //if res3507for10188.Infcode
  3064. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3065. //res.Output = resSix10265.Output
  3066. res.ErrMsg = res3507for10188.ErrMsg
  3067. res.Cainfo = res3507for10188.Cainfo
  3068. res.WarnMsg = res3507for10188.WarnMsg
  3069. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3070. res.Infcode = infocode
  3071. } else {
  3072. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3073. utils.ErrorLog("解析失败:%v", err)
  3074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3075. return
  3076. }
  3077. }
  3078. if res.Infcode == 0 {
  3079. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3080. item.IsSale = 1
  3081. item.Bchno = number
  3082. item.SaleDate = time.Now().Format("2006-01-02")
  3083. service.SaveDF(item)
  3084. } else {
  3085. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3086. }
  3087. }
  3088. } else { //还没结,提示用户去结算,并药品追溯上传
  3089. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3090. }
  3091. }
  3092. }
  3093. str := strings.Join(err, " ")
  3094. saveLog(str, str, "3505", "3505自动上传日志")
  3095. c.ServeSuccessJSON(map[string]interface{}{
  3096. "status": "1",
  3097. "msg": err,
  3098. })
  3099. }
  3100. //func (c *HisApiController) ChangeDrugfour() {
  3101. // patient_id, _ := c.GetInt64("patient_id")
  3102. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3103. // //id_arr := strings.Split(ids, ",")
  3104. // times := c.GetString("time", "")
  3105. // timeLayout := "2006-01-02"
  3106. // loc, _ := time.LoadLocation("Local")
  3107. // var stime, etime int64
  3108. // if times == "" {
  3109. // stime, etime = GetNowTime()
  3110. // } else {
  3111. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3112. // stime = stmp.Unix()
  3113. // etime = stime + 86399
  3114. // }
  3115. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3116. // var flows []*models.DrugFlow
  3117. // for _, item := range advicelist {
  3118. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3119. // flows = append(flows, flow...)
  3120. // }
  3121. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3122. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3123. // var err []string
  3124. //
  3125. // for _, item := range flows {
  3126. // var res3 ResultSix
  3127. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3128. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3129. // if prescription.OrderStatus == 2 {
  3130. // //已经结算
  3131. // //判断是否已经销售
  3132. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3133. // //是否已经变更 1是 0否
  3134. // if item.IsChange == 0 { //没变更,进行变更操作
  3135. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3136. //
  3137. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3138. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3139. // var respJSON3 map[string]interface{}
  3140. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3141. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3142. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3143. // return
  3144. // }
  3145. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3146. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3147. // utils.ErrorLog("解析失败:%v", err)
  3148. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3149. // return
  3150. // }
  3151. // if res3.Infcode == 0 {
  3152. // item.IsChange = 1
  3153. // item.BgBchno = bg_number
  3154. // service.SaveDF2(item)
  3155. // } else {
  3156. //
  3157. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3158. // }
  3159. // }
  3160. // } else { //没销售,
  3161. // var res FJ3507Result
  3162. // var res3507for10188 FJ3507ResultFor10188
  3163. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3164. //
  3165. // //进行商品销售接口
  3166. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3167. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3168. // var respJSON3 map[string]interface{}
  3169. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3170. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3171. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3172. // return
  3173. // }
  3174. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3175. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3176. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3177. // utils.ErrorLog("解析失败:%v", err)
  3178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3179. // return
  3180. // }
  3181. // //if res3507for10188.Infcode
  3182. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3183. // //res.Output = resSix10265.Output
  3184. // res.ErrMsg = res3507for10188.ErrMsg
  3185. // res.Cainfo = res3507for10188.Cainfo
  3186. // res.WarnMsg = res3507for10188.WarnMsg
  3187. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3188. // res.Infcode = infocode
  3189. // } else {
  3190. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3191. // utils.ErrorLog("解析失败:%v", err)
  3192. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3193. // return
  3194. // }
  3195. //
  3196. // }
  3197. // if res.Infcode == 0 {
  3198. // item.IsSale = 1
  3199. // item.Bchno = number
  3200. // item.SaleDate = time.Now().Format("2006-01-02")
  3201. //
  3202. // err5 := service.SaveDF(item)
  3203. // if err5 == nil {
  3204. // if item.IsChange == 0 { //没变更,进行变更操作
  3205. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3206. //
  3207. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3208. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3209. //
  3210. // var respJSON3 map[string]interface{}
  3211. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3212. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3214. // return
  3215. // }
  3216. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3217. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3218. // utils.ErrorLog("解析失败:%v", err)
  3219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3220. // return
  3221. // }
  3222. // //if res3507for10188.Infcode
  3223. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3224. // //res.Output = resSix10265.Output
  3225. // res3.ErrMsg = res3507for10188.ErrMsg
  3226. // res3.Cainfo = res3507for10188.Cainfo
  3227. // res3.WarnMsg = res3507for10188.WarnMsg
  3228. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3229. // res3.Infcode = infocode
  3230. // } else {
  3231. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3232. // utils.ErrorLog("解析失败:%v", err)
  3233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3234. // return
  3235. // }
  3236. // }
  3237. // if res3.Infcode == 0 {
  3238. // item.IsChange = 1
  3239. // item.BgBchno = bg_number
  3240. // service.SaveDF2(item)
  3241. // } else {
  3242. //
  3243. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3244. // }
  3245. // }
  3246. // }
  3247. // } else {
  3248. //
  3249. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3250. // }
  3251. // }
  3252. //
  3253. // } else { //还没结,提示用户去结算,并药品追溯上传
  3254. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3255. // }
  3256. // }
  3257. // }
  3258. // if len(err) == 0 {
  3259. // c.ServeSuccessJSON(map[string]interface{}{
  3260. // "msg": "销售变更成功",
  3261. // })
  3262. // } else {
  3263. // c.ServeSuccessJSON(map[string]interface{}{
  3264. // "failed_code": -10,
  3265. // "msg": err,
  3266. // })
  3267. // }
  3268. //}
  3269. func (c *HisApiController) ChangeDrug() {
  3270. ids := c.GetString("ids")
  3271. id_arr := strings.Split(ids, ",")
  3272. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3273. admin_user_id, _ := c.GetInt64("admin_user_id")
  3274. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3275. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3276. var err []string
  3277. for _, item := range flows {
  3278. var res3 ResultSix
  3279. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3280. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3281. if prescription.OrderStatus == 2 {
  3282. //已经结算
  3283. //判断是否已经销售
  3284. if item.IsSale == 1 { //是否已经销售,1是 0否
  3285. //是否已经变更 1是 0否
  3286. if item.IsChange == 0 { //没变更,进行变更操作
  3287. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3288. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3289. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3290. var respJSON3 map[string]interface{}
  3291. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3294. return
  3295. }
  3296. userJSONBytes3, _ := json.Marshal(respJSON3)
  3297. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3298. utils.ErrorLog("解析失败:%v", err)
  3299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3300. return
  3301. }
  3302. if res3.Infcode == 0 {
  3303. item.IsChange = 1
  3304. item.BgBchno = bg_number
  3305. service.SaveDF2(item)
  3306. } else {
  3307. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3308. }
  3309. }
  3310. } else { //没销售,
  3311. var res FJ3507Result
  3312. var res3507for10188 FJ3507ResultFor10188
  3313. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3314. //进行商品销售接口
  3315. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3316. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3317. var respJSON3 map[string]interface{}
  3318. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3321. return
  3322. }
  3323. userJSONBytes3, _ := json.Marshal(respJSON3)
  3324. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3325. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3326. utils.ErrorLog("解析失败:%v", err)
  3327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3328. return
  3329. }
  3330. //if res3507for10188.Infcode
  3331. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3332. //res.Output = resSix10265.Output
  3333. res.ErrMsg = res3507for10188.ErrMsg
  3334. res.Cainfo = res3507for10188.Cainfo
  3335. res.WarnMsg = res3507for10188.WarnMsg
  3336. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3337. res.Infcode = infocode
  3338. } else {
  3339. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3340. utils.ErrorLog("解析失败:%v", err)
  3341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3342. return
  3343. }
  3344. }
  3345. if res.Infcode == 0 {
  3346. item.IsSale = 1
  3347. item.Bchno = number
  3348. item.SaleDate = time.Now().Format("2006-01-02")
  3349. err5 := service.SaveDF(item)
  3350. if err5 == nil {
  3351. if item.IsChange == 0 { //没变更,进行变更操作
  3352. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3353. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3354. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3355. var respJSON3 map[string]interface{}
  3356. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3359. return
  3360. }
  3361. userJSONBytes3, _ := json.Marshal(respJSON3)
  3362. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3363. utils.ErrorLog("解析失败:%v", err)
  3364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3365. return
  3366. }
  3367. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3368. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3369. utils.ErrorLog("解析失败:%v", err)
  3370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3371. return
  3372. }
  3373. //if res3507for10188.Infcode
  3374. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3375. //res.Output = resSix10265.Output
  3376. res3.ErrMsg = res3507for10188.ErrMsg
  3377. res3.Cainfo = res3507for10188.Cainfo
  3378. res3.WarnMsg = res3507for10188.WarnMsg
  3379. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3380. res3.Infcode = infocode
  3381. } else {
  3382. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3383. utils.ErrorLog("解析失败:%v", err)
  3384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3385. return
  3386. }
  3387. }
  3388. if res3.Infcode == 0 {
  3389. item.IsChange = 1
  3390. item.BgBchno = bg_number
  3391. service.SaveDF2(item)
  3392. } else {
  3393. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3394. }
  3395. }
  3396. }
  3397. } else {
  3398. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3399. }
  3400. }
  3401. } else { //还没结算
  3402. var res3507for10188 FJ3507ResultFor10188
  3403. if item.IsChange == 0 { //没变更,进行变更操作
  3404. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3405. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3406. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3407. var respJSON3 map[string]interface{}
  3408. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3411. return
  3412. }
  3413. userJSONBytes3, _ := json.Marshal(respJSON3)
  3414. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3415. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3416. utils.ErrorLog("解析失败:%v", err)
  3417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3418. return
  3419. }
  3420. //if res3507for10188.Infcode
  3421. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3422. //res.Output = resSix10265.Output
  3423. res3.ErrMsg = res3507for10188.ErrMsg
  3424. res3.Cainfo = res3507for10188.Cainfo
  3425. res3.WarnMsg = res3507for10188.WarnMsg
  3426. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3427. res3.Infcode = infocode
  3428. } else {
  3429. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3430. utils.ErrorLog("解析失败:%v", err)
  3431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3432. return
  3433. }
  3434. }
  3435. if res3.Infcode == 0 {
  3436. item.IsChange = 1
  3437. item.BgBchno = bg_number
  3438. service.SaveDF2(item)
  3439. } else {
  3440. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3441. }
  3442. }
  3443. }
  3444. } else if item.ConsumableType == 7 {
  3445. var res3507for10188 FJ3507ResultFor10188
  3446. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3447. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3448. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3449. //判断是否已经销售
  3450. if item.IsSale == 2 { //是否已经销售,1是 0否
  3451. //是否已经变更 1是 0否
  3452. if item.IsChange == 0 { //没变更,进行变更操作
  3453. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3454. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3455. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3456. var respJSON3 map[string]interface{}
  3457. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3460. return
  3461. }
  3462. userJSONBytes3, _ := json.Marshal(respJSON3)
  3463. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3464. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3465. utils.ErrorLog("解析失败:%v", err)
  3466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3467. return
  3468. }
  3469. //if res3507for10188.Infcode
  3470. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3471. //res.Output = resSix10265.Output
  3472. res3.ErrMsg = res3507for10188.ErrMsg
  3473. res3.Cainfo = res3507for10188.Cainfo
  3474. res3.WarnMsg = res3507for10188.WarnMsg
  3475. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3476. res3.Infcode = infocode
  3477. } else {
  3478. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3479. utils.ErrorLog("解析失败:%v", err)
  3480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3481. return
  3482. }
  3483. }
  3484. if res3.Infcode == 0 {
  3485. item.IsChange = 1
  3486. item.BgBchno = bg_number
  3487. service.SaveDF2(item)
  3488. } else {
  3489. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3490. }
  3491. }
  3492. } else { //没销售,
  3493. //进行商品销售退货接口
  3494. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3495. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3496. saveLog(result111, result222, "3506", "销售退货")
  3497. var res7 FJ3507Result
  3498. //进行商品销售接口
  3499. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3500. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3501. var respJSON3 map[string]interface{}
  3502. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3505. return
  3506. }
  3507. userJSONBytes3, _ := json.Marshal(respJSON3)
  3508. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3509. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3510. utils.ErrorLog("解析失败:%v", err)
  3511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3512. return
  3513. }
  3514. //if res3507for10188.Infcode
  3515. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3516. //res.Output = resSix10265.Output
  3517. res7.ErrMsg = res3507for10188.ErrMsg
  3518. res7.Cainfo = res3507for10188.Cainfo
  3519. res7.WarnMsg = res3507for10188.WarnMsg
  3520. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3521. res7.Infcode = infocode
  3522. } else {
  3523. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3524. utils.ErrorLog("解析失败:%v", err)
  3525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3526. return
  3527. }
  3528. }
  3529. if res7.Infcode == 0 {
  3530. item.IsSale = 2
  3531. item.SaleDate = item.SaleDate
  3532. item.Bchno = number
  3533. service.SaveDF(item)
  3534. if item.IsChange == 0 { //没变更,进行变更操作
  3535. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3536. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3537. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3538. var respJSON3 map[string]interface{}
  3539. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3542. return
  3543. }
  3544. userJSONBytes3, _ := json.Marshal(respJSON3)
  3545. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3546. // utils.ErrorLog("解析失败:%v", err)
  3547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3548. // return
  3549. //}
  3550. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3551. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3552. utils.ErrorLog("解析失败:%v", err)
  3553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3554. return
  3555. }
  3556. //if res3507for10188.Infcode
  3557. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3558. //res.Output = resSix10265.Output
  3559. res3.ErrMsg = res3507for10188.ErrMsg
  3560. res3.Cainfo = res3507for10188.Cainfo
  3561. res3.WarnMsg = res3507for10188.WarnMsg
  3562. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3563. res3.Infcode = infocode
  3564. } else {
  3565. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3566. utils.ErrorLog("解析失败:%v", err)
  3567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3568. return
  3569. }
  3570. }
  3571. if res3.Infcode == 0 {
  3572. item.IsChange = 1
  3573. item.BgBchno = bg_number
  3574. service.SaveDF2(item)
  3575. } else {
  3576. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3577. }
  3578. }
  3579. } else {
  3580. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3581. }
  3582. }
  3583. } else { //还没结算
  3584. if item.IsChange == 0 { //没变更,进行变更操作
  3585. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3586. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3587. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3588. var respJSON3 map[string]interface{}
  3589. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3592. return
  3593. }
  3594. userJSONBytes3, _ := json.Marshal(respJSON3)
  3595. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3596. // utils.ErrorLog("解析失败:%v", err)
  3597. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3598. // return
  3599. //}
  3600. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3601. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3602. utils.ErrorLog("解析失败:%v", err)
  3603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3604. return
  3605. }
  3606. //if res3507for10188.Infcode
  3607. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3608. //res.Output = resSix10265.Output
  3609. res3.ErrMsg = res3507for10188.ErrMsg
  3610. res3.Cainfo = res3507for10188.Cainfo
  3611. res3.WarnMsg = res3507for10188.WarnMsg
  3612. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3613. res3.Infcode = infocode
  3614. } else {
  3615. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3616. utils.ErrorLog("解析失败:%v", err)
  3617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3618. return
  3619. }
  3620. }
  3621. if res3.Infcode == 0 {
  3622. item.IsChange = 1
  3623. item.BgBchno = bg_number
  3624. service.SaveDF2(item)
  3625. } else {
  3626. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3627. }
  3628. }
  3629. }
  3630. }
  3631. }
  3632. if len(err) == 0 {
  3633. c.ServeSuccessJSON(map[string]interface{}{
  3634. "msg": "销售变更成功",
  3635. })
  3636. } else {
  3637. c.ServeSuccessJSON(map[string]interface{}{
  3638. "failed_code": -10,
  3639. "msg": err,
  3640. })
  3641. }
  3642. }
  3643. func (c *HisApiController) ChangeDrugtwo() {
  3644. //ids := c.GetString("ids")
  3645. //id_arr := strings.Split(ids, ",")
  3646. flows, _ := service.GetNewDrugFlowInfothree123()
  3647. admin_user_id, _ := c.GetInt64("admin_user_id")
  3648. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3649. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3650. var err []string
  3651. for _, item := range flows {
  3652. var res3 ResultSix
  3653. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3654. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3655. if prescription.OrderStatus == 2 {
  3656. //已经结算
  3657. //判断是否已经销售
  3658. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3659. // //是否已经变更 1是 0否
  3660. // if item.IsChange == 0 { //没变更,进行变更操作
  3661. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3662. //
  3663. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3664. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3665. // var respJSON3 map[string]interface{}
  3666. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3667. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3669. // return
  3670. // }
  3671. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3672. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3673. // utils.ErrorLog("解析失败:%v", err)
  3674. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3675. // return
  3676. // }
  3677. // if res3.Infcode == 0 {
  3678. // item.IsChange = 1
  3679. // item.BgBchno = bg_number
  3680. // service.SaveDF2(item)
  3681. // } else {
  3682. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3683. // }
  3684. // }
  3685. //}
  3686. //else
  3687. { //没销售,
  3688. var res FJ3507Result
  3689. var res3507for10188 FJ3507ResultFor10188
  3690. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3691. //进行商品销售接口
  3692. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3693. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3694. var respJSON3 map[string]interface{}
  3695. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3698. return
  3699. }
  3700. userJSONBytes3, _ := json.Marshal(respJSON3)
  3701. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3702. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3703. utils.ErrorLog("解析失败:%v", err)
  3704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3705. return
  3706. }
  3707. //if res3507for10188.Infcode
  3708. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3709. //res.Output = resSix10265.Output
  3710. res.ErrMsg = res3507for10188.ErrMsg
  3711. res.Cainfo = res3507for10188.Cainfo
  3712. res.WarnMsg = res3507for10188.WarnMsg
  3713. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3714. res.Infcode = infocode
  3715. } else {
  3716. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3717. utils.ErrorLog("解析失败:%v", err)
  3718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3719. return
  3720. }
  3721. }
  3722. if res.Infcode == 0 {
  3723. item.IsSale = 1
  3724. item.Bchno = number
  3725. item.SaleDate = time.Now().Format("2006-01-02")
  3726. service.SaveDF(item)
  3727. //if err5 == nil {
  3728. // if item.IsChange == 0 { //没变更,进行变更操作
  3729. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3730. //
  3731. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3732. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3733. //
  3734. // var respJSON3 map[string]interface{}
  3735. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3736. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3737. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3738. // return
  3739. // }
  3740. //
  3741. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3742. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3743. // utils.ErrorLog("解析失败:%v", err)
  3744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3745. // return
  3746. // }
  3747. // //if res3507for10188.Infcode
  3748. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3749. // //res.Output = resSix10265.Output
  3750. // res3.ErrMsg = res3507for10188.ErrMsg
  3751. // res3.Cainfo = res3507for10188.Cainfo
  3752. // res3.WarnMsg = res3507for10188.WarnMsg
  3753. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3754. // res3.Infcode = infocode
  3755. // } else {
  3756. //
  3757. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3758. // utils.ErrorLog("解析失败:%v", err)
  3759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3760. // return
  3761. // }
  3762. //
  3763. // }
  3764. //
  3765. // if res3.Infcode == 0 {
  3766. // item.IsChange = 1
  3767. // item.BgBchno = bg_number
  3768. // service.SaveDF2(item)
  3769. // } else {
  3770. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3771. // }
  3772. // }
  3773. //}
  3774. } else {
  3775. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3776. }
  3777. }
  3778. } else { //还没结算
  3779. var res3507for10188 FJ3507ResultFor10188
  3780. if item.IsChange == 0 { //没变更,进行变更操作
  3781. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3782. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3783. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3784. var respJSON3 map[string]interface{}
  3785. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3788. return
  3789. }
  3790. userJSONBytes3, _ := json.Marshal(respJSON3)
  3791. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3792. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3793. utils.ErrorLog("解析失败:%v", err)
  3794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3795. return
  3796. }
  3797. //if res3507for10188.Infcode
  3798. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3799. //res.Output = resSix10265.Output
  3800. res3.ErrMsg = res3507for10188.ErrMsg
  3801. res3.Cainfo = res3507for10188.Cainfo
  3802. res3.WarnMsg = res3507for10188.WarnMsg
  3803. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3804. res3.Infcode = infocode
  3805. } else {
  3806. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3807. utils.ErrorLog("解析失败:%v", err)
  3808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3809. return
  3810. }
  3811. }
  3812. if res3.Infcode == 0 {
  3813. item.IsChange = 1
  3814. item.BgBchno = bg_number
  3815. service.SaveDF2(item)
  3816. } else {
  3817. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3818. }
  3819. }
  3820. }
  3821. }
  3822. //if item.ConsumableType == 7 {
  3823. // var res3507for10188 FJ3507ResultFor10188
  3824. //
  3825. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3826. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3827. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3828. // //判断是否已经销售
  3829. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3830. // //是否已经变更 1是 0否
  3831. // if item.IsChange == 0 { //没变更,进行变更操作
  3832. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3833. //
  3834. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3835. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3836. //
  3837. // var respJSON3 map[string]interface{}
  3838. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3839. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3840. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3841. // return
  3842. // }
  3843. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3844. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3845. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3846. // utils.ErrorLog("解析失败:%v", err)
  3847. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3848. // return
  3849. // }
  3850. // //if res3507for10188.Infcode
  3851. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3852. // //res.Output = resSix10265.Output
  3853. // res3.ErrMsg = res3507for10188.ErrMsg
  3854. // res3.Cainfo = res3507for10188.Cainfo
  3855. // res3.WarnMsg = res3507for10188.WarnMsg
  3856. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3857. // res3.Infcode = infocode
  3858. // } else {
  3859. //
  3860. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3861. // utils.ErrorLog("解析失败:%v", err)
  3862. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3863. // return
  3864. // }
  3865. //
  3866. // }
  3867. // if res3.Infcode == 0 {
  3868. // item.IsChange = 1
  3869. // item.BgBchno = bg_number
  3870. // service.SaveDF2(item)
  3871. // } else {
  3872. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3873. // }
  3874. // }
  3875. // } else { //没销售,
  3876. // //进行商品销售退货接口
  3877. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3878. //
  3879. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3880. // saveLog(result111, result222, "3506", "销售退货")
  3881. // var res7 FJ3507Result
  3882. //
  3883. // //进行商品销售接口
  3884. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3885. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3886. // var respJSON3 map[string]interface{}
  3887. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3888. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3890. // return
  3891. // }
  3892. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3893. //
  3894. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3895. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3896. // utils.ErrorLog("解析失败:%v", err)
  3897. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3898. // return
  3899. // }
  3900. // //if res3507for10188.Infcode
  3901. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3902. // //res.Output = resSix10265.Output
  3903. // res7.ErrMsg = res3507for10188.ErrMsg
  3904. // res7.Cainfo = res3507for10188.Cainfo
  3905. // res7.WarnMsg = res3507for10188.WarnMsg
  3906. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3907. // res7.Infcode = infocode
  3908. // } else {
  3909. //
  3910. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3911. // utils.ErrorLog("解析失败:%v", err)
  3912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3913. // return
  3914. // }
  3915. //
  3916. // }
  3917. // if res7.Infcode == 0 {
  3918. // item.IsSale = 2
  3919. // item.SaleDate = item.SaleDate
  3920. // item.Bchno = number
  3921. // service.SaveDF(item)
  3922. // if item.IsChange == 0 { //没变更,进行变更操作
  3923. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3924. //
  3925. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3926. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3927. //
  3928. // var respJSON3 map[string]interface{}
  3929. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3930. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3931. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3932. // return
  3933. // }
  3934. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3935. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3936. // // utils.ErrorLog("解析失败:%v", err)
  3937. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3938. // // return
  3939. // //}
  3940. //
  3941. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3942. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3943. // utils.ErrorLog("解析失败:%v", err)
  3944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3945. // return
  3946. // }
  3947. // //if res3507for10188.Infcode
  3948. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3949. // //res.Output = resSix10265.Output
  3950. // res3.ErrMsg = res3507for10188.ErrMsg
  3951. // res3.Cainfo = res3507for10188.Cainfo
  3952. // res3.WarnMsg = res3507for10188.WarnMsg
  3953. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3954. // res3.Infcode = infocode
  3955. // } else {
  3956. //
  3957. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3958. // utils.ErrorLog("解析失败:%v", err)
  3959. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3960. // return
  3961. // }
  3962. //
  3963. // }
  3964. // if res3.Infcode == 0 {
  3965. // item.IsChange = 1
  3966. // item.BgBchno = bg_number
  3967. // service.SaveDF2(item)
  3968. // } else {
  3969. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3970. // }
  3971. // }
  3972. // } else {
  3973. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3974. // }
  3975. // }
  3976. // } else { //还没结算
  3977. // if item.IsChange == 0 { //没变更,进行变更操作
  3978. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3979. //
  3980. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3981. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3982. //
  3983. // var respJSON3 map[string]interface{}
  3984. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3985. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3986. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3987. // return
  3988. // }
  3989. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3990. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3991. // // utils.ErrorLog("解析失败:%v", err)
  3992. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3993. // // return
  3994. // //}
  3995. //
  3996. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3997. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3998. // utils.ErrorLog("解析失败:%v", err)
  3999. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4000. // return
  4001. // }
  4002. // //if res3507for10188.Infcode
  4003. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4004. // //res.Output = resSix10265.Output
  4005. // res3.ErrMsg = res3507for10188.ErrMsg
  4006. // res3.Cainfo = res3507for10188.Cainfo
  4007. // res3.WarnMsg = res3507for10188.WarnMsg
  4008. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4009. // res3.Infcode = infocode
  4010. // } else {
  4011. //
  4012. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4013. // utils.ErrorLog("解析失败:%v", err)
  4014. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4015. // return
  4016. // }
  4017. //
  4018. // }
  4019. // if res3.Infcode == 0 {
  4020. // item.IsChange = 1
  4021. // item.BgBchno = bg_number
  4022. // service.SaveDF2(item)
  4023. // } else {
  4024. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4025. // }
  4026. // }
  4027. // }
  4028. //}
  4029. }
  4030. if len(err) == 0 {
  4031. c.ServeSuccessJSON(map[string]interface{}{
  4032. "msg": "销售变更成功",
  4033. })
  4034. } else {
  4035. c.ServeSuccessJSON(map[string]interface{}{
  4036. "failed_code": -10,
  4037. "msg": err,
  4038. })
  4039. }
  4040. }
  4041. func (c *HisApiController) ChangeDrugthree() {
  4042. //ids := c.GetString("ids")
  4043. //id_arr := strings.Split(ids, ",")
  4044. flows, _ := service.GetNewDrugFlowInfothree()
  4045. admin_user_id, _ := c.GetInt64("admin_user_id")
  4046. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4047. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4048. var err []string
  4049. for _, item := range flows {
  4050. var res3 ResultSix
  4051. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4052. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4053. if prescription.OrderStatus == 2 {
  4054. //已经结算
  4055. //判断是否已经销售
  4056. if item.IsSale == 1 { //是否已经销售,1是 0否
  4057. //是否已经变更 1是 0否
  4058. if item.IsChange == 0 { //没变更,进行变更操作
  4059. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4060. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4061. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4062. var respJSON3 map[string]interface{}
  4063. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4066. return
  4067. }
  4068. userJSONBytes3, _ := json.Marshal(respJSON3)
  4069. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4070. utils.ErrorLog("解析失败:%v", err)
  4071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4072. return
  4073. }
  4074. if res3.Infcode == 0 {
  4075. item.IsChange = 1
  4076. item.BgBchno = bg_number
  4077. service.SaveDF2(item)
  4078. } else {
  4079. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4080. }
  4081. }
  4082. } else { //没销售,
  4083. var res FJ3507Result
  4084. var res3507for10188 FJ3507ResultFor10188
  4085. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4086. //进行商品销售接口
  4087. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4088. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4089. var respJSON3 map[string]interface{}
  4090. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4093. return
  4094. }
  4095. userJSONBytes3, _ := json.Marshal(respJSON3)
  4096. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4097. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4098. utils.ErrorLog("解析失败:%v", err)
  4099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4100. return
  4101. }
  4102. //if res3507for10188.Infcode
  4103. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4104. //res.Output = resSix10265.Output
  4105. res.ErrMsg = res3507for10188.ErrMsg
  4106. res.Cainfo = res3507for10188.Cainfo
  4107. res.WarnMsg = res3507for10188.WarnMsg
  4108. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4109. res.Infcode = infocode
  4110. } else {
  4111. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4112. utils.ErrorLog("解析失败:%v", err)
  4113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4114. return
  4115. }
  4116. }
  4117. if res.Infcode == 0 {
  4118. item.IsSale = 1
  4119. item.Bchno = number
  4120. item.SaleDate = time.Now().Format("2006-01-02")
  4121. err5 := service.SaveDF(item)
  4122. if err5 == nil {
  4123. if item.IsChange == 0 { //没变更,进行变更操作
  4124. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4125. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4126. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4127. var respJSON3 map[string]interface{}
  4128. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4131. return
  4132. }
  4133. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4134. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4135. utils.ErrorLog("解析失败:%v", err)
  4136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4137. return
  4138. }
  4139. //if res3507for10188.Infcode
  4140. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4141. //res.Output = resSix10265.Output
  4142. res3.ErrMsg = res3507for10188.ErrMsg
  4143. res3.Cainfo = res3507for10188.Cainfo
  4144. res3.WarnMsg = res3507for10188.WarnMsg
  4145. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4146. res3.Infcode = infocode
  4147. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4148. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4149. utils.ErrorLog("解析失败:%v", err)
  4150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4151. return
  4152. }
  4153. //if res3507for10188.Infcode
  4154. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4155. //res.Output = resSix10265.Output
  4156. res3.ErrMsg = res3507for10188.ErrMsg
  4157. res3.Cainfo = res3507for10188.Cainfo
  4158. res3.WarnMsg = res3507for10188.WarnMsg
  4159. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4160. res3.Infcode = infocode
  4161. } else {
  4162. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4163. utils.ErrorLog("解析失败:%v", err)
  4164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4165. return
  4166. }
  4167. }
  4168. if res3.Infcode == 0 {
  4169. item.IsChange = 1
  4170. item.BgBchno = bg_number
  4171. service.SaveDF2(item)
  4172. } else {
  4173. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4174. }
  4175. }
  4176. }
  4177. } else {
  4178. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4179. }
  4180. }
  4181. } else { //还没结算
  4182. var res3507for10188 FJ3507ResultFor10188
  4183. if item.IsChange == 0 { //没变更,进行变更操作
  4184. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4185. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4186. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4187. var respJSON3 map[string]interface{}
  4188. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4191. return
  4192. }
  4193. userJSONBytes3, _ := json.Marshal(respJSON3)
  4194. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4195. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4196. utils.ErrorLog("解析失败:%v", err)
  4197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4198. return
  4199. }
  4200. //if res3507for10188.Infcode
  4201. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4202. //res.Output = resSix10265.Output
  4203. res3.ErrMsg = res3507for10188.ErrMsg
  4204. res3.Cainfo = res3507for10188.Cainfo
  4205. res3.WarnMsg = res3507for10188.WarnMsg
  4206. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4207. res3.Infcode = infocode
  4208. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4209. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4210. utils.ErrorLog("解析失败:%v", err)
  4211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4212. return
  4213. }
  4214. //if res3507for10188.Infcode
  4215. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4216. //res.Output = resSix10265.Output
  4217. res3.ErrMsg = res3507for10188.ErrMsg
  4218. res3.Cainfo = res3507for10188.Cainfo
  4219. res3.WarnMsg = res3507for10188.WarnMsg
  4220. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4221. res3.Infcode = infocode
  4222. } else {
  4223. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4224. utils.ErrorLog("解析失败:%v", err)
  4225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4226. return
  4227. }
  4228. }
  4229. if res3.Infcode == 0 {
  4230. item.IsChange = 1
  4231. item.BgBchno = bg_number
  4232. service.SaveDF2(item)
  4233. } else {
  4234. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4235. }
  4236. }
  4237. }
  4238. } else if item.ConsumableType == 7 {
  4239. var res3507for10188 FJ3507ResultFor10188
  4240. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4241. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4242. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4243. //判断是否已经销售
  4244. if item.IsSale == 2 { //是否已经销售,1是 0否
  4245. //是否已经变更 1是 0否
  4246. if item.IsChange == 0 { //没变更,进行变更操作
  4247. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4248. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4249. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4250. var respJSON3 map[string]interface{}
  4251. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4254. return
  4255. }
  4256. userJSONBytes3, _ := json.Marshal(respJSON3)
  4257. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4258. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4259. utils.ErrorLog("解析失败:%v", err)
  4260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4261. return
  4262. }
  4263. //if res3507for10188.Infcode
  4264. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4265. //res.Output = resSix10265.Output
  4266. res3.ErrMsg = res3507for10188.ErrMsg
  4267. res3.Cainfo = res3507for10188.Cainfo
  4268. res3.WarnMsg = res3507for10188.WarnMsg
  4269. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4270. res3.Infcode = infocode
  4271. } else {
  4272. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4273. utils.ErrorLog("解析失败:%v", err)
  4274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4275. return
  4276. }
  4277. }
  4278. if res3.Infcode == 0 {
  4279. item.IsChange = 1
  4280. item.BgBchno = bg_number
  4281. service.SaveDF2(item)
  4282. } else {
  4283. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4284. }
  4285. }
  4286. } else { //没销售,
  4287. //进行商品销售退货接口
  4288. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4289. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4290. saveLog(result111, result222, "3506", "销售退货")
  4291. var res7 FJ3507Result
  4292. //进行商品销售接口
  4293. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4294. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4295. var respJSON3 map[string]interface{}
  4296. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4299. return
  4300. }
  4301. userJSONBytes3, _ := json.Marshal(respJSON3)
  4302. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4303. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4304. utils.ErrorLog("解析失败:%v", err)
  4305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4306. return
  4307. }
  4308. //if res3507for10188.Infcode
  4309. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4310. //res.Output = resSix10265.Output
  4311. res7.ErrMsg = res3507for10188.ErrMsg
  4312. res7.Cainfo = res3507for10188.Cainfo
  4313. res7.WarnMsg = res3507for10188.WarnMsg
  4314. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4315. res7.Infcode = infocode
  4316. } else {
  4317. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4318. utils.ErrorLog("解析失败:%v", err)
  4319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4320. return
  4321. }
  4322. }
  4323. if res7.Infcode == 0 {
  4324. item.IsSale = 2
  4325. item.SaleDate = item.SaleDate
  4326. item.Bchno = number
  4327. service.SaveDF(item)
  4328. if item.IsChange == 0 { //没变更,进行变更操作
  4329. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4330. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4331. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4332. var respJSON3 map[string]interface{}
  4333. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4336. return
  4337. }
  4338. userJSONBytes3, _ := json.Marshal(respJSON3)
  4339. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4340. // utils.ErrorLog("解析失败:%v", err)
  4341. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4342. // return
  4343. //}
  4344. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4345. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4346. utils.ErrorLog("解析失败:%v", err)
  4347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4348. return
  4349. }
  4350. //if res3507for10188.Infcode
  4351. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4352. //res.Output = resSix10265.Output
  4353. res3.ErrMsg = res3507for10188.ErrMsg
  4354. res3.Cainfo = res3507for10188.Cainfo
  4355. res3.WarnMsg = res3507for10188.WarnMsg
  4356. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4357. res3.Infcode = infocode
  4358. } else {
  4359. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4360. utils.ErrorLog("解析失败:%v", err)
  4361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4362. return
  4363. }
  4364. }
  4365. if res3.Infcode == 0 {
  4366. item.IsChange = 1
  4367. item.BgBchno = bg_number
  4368. service.SaveDF2(item)
  4369. } else {
  4370. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4371. }
  4372. }
  4373. } else {
  4374. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4375. }
  4376. }
  4377. } else { //还没结算
  4378. if item.IsChange == 0 { //没变更,进行变更操作
  4379. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4380. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4381. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4382. var respJSON3 map[string]interface{}
  4383. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4386. return
  4387. }
  4388. userJSONBytes3, _ := json.Marshal(respJSON3)
  4389. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4390. // utils.ErrorLog("解析失败:%v", err)
  4391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4392. // return
  4393. //}
  4394. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4395. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4396. utils.ErrorLog("解析失败:%v", err)
  4397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4398. return
  4399. }
  4400. //if res3507for10188.Infcode
  4401. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4402. //res.Output = resSix10265.Output
  4403. res3.ErrMsg = res3507for10188.ErrMsg
  4404. res3.Cainfo = res3507for10188.Cainfo
  4405. res3.WarnMsg = res3507for10188.WarnMsg
  4406. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4407. res3.Infcode = infocode
  4408. } else {
  4409. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4410. utils.ErrorLog("解析失败:%v", err)
  4411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4412. return
  4413. }
  4414. }
  4415. if res3.Infcode == 0 {
  4416. item.IsChange = 1
  4417. item.BgBchno = bg_number
  4418. service.SaveDF2(item)
  4419. } else {
  4420. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4421. }
  4422. }
  4423. }
  4424. }
  4425. }
  4426. if len(err) == 0 {
  4427. c.ServeSuccessJSON(map[string]interface{}{
  4428. "msg": "销售变更成功",
  4429. })
  4430. } else {
  4431. c.ServeSuccessJSON(map[string]interface{}{
  4432. "failed_code": -10,
  4433. "msg": err,
  4434. })
  4435. }
  4436. }
  4437. func (c *HisApiController) ChangeDrugTen() {
  4438. start_time_str := c.GetString("start_time")
  4439. end_time_str := c.GetString("end_time")
  4440. //ids := c.GetString("ids")
  4441. //id_arr := strings.Split(ids, ",")
  4442. timeLayout := "2006-01-02"
  4443. loc, _ := time.LoadLocation("Local")
  4444. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4445. recordStartTime := theStartTime.Unix()
  4446. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4447. recordEndTime := theEndTime.Unix()
  4448. //timestamp := int64(1729612800)
  4449. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4450. admin_user_id, _ := c.GetInt64("admin_user_id")
  4451. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4452. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4453. var err []string
  4454. for _, item := range flows {
  4455. var res3 ResultSix
  4456. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4457. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4458. continue
  4459. }
  4460. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4461. continue
  4462. }
  4463. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4464. if prescription.OrderStatus == 2 {
  4465. //已经结算
  4466. //判断 是否已经销售
  4467. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4468. ////是否已经变更 1是 0否
  4469. //if item.IsChange == 0 { //没变更,进行变更操作
  4470. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4471. //
  4472. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4473. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4474. // var respJSON3 map[string]interface{}
  4475. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4476. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4478. // return
  4479. // }
  4480. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4481. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4482. // utils.ErrorLog("解析失败:%v", err)
  4483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4484. // return
  4485. // }
  4486. // if res3.Infcode == 0 {
  4487. // item.IsChange = 1
  4488. // item.BgBchno = bg_number
  4489. // service.SaveDF2(item)
  4490. // } else {
  4491. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4492. // }
  4493. //}
  4494. //} else
  4495. if item.IsSale == 0 { //没销售,
  4496. var res FJ3507Result
  4497. var res3507for10188 FJ3507ResultFor10188
  4498. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4499. //进行商品销售接口
  4500. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4501. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4502. var respJSON3 map[string]interface{}
  4503. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4506. return
  4507. }
  4508. userJSONBytes3, _ := json.Marshal(respJSON3)
  4509. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4510. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4511. utils.ErrorLog("解析失败:%v", err)
  4512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4513. return
  4514. }
  4515. //if res3507for10188.Infcode
  4516. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4517. //res.Output = resSix10265.Output
  4518. res.ErrMsg = res3507for10188.ErrMsg
  4519. res.Cainfo = res3507for10188.Cainfo
  4520. res.WarnMsg = res3507for10188.WarnMsg
  4521. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4522. res.Infcode = infocode
  4523. } else {
  4524. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4525. utils.ErrorLog("解析失败:%v", err)
  4526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4527. return
  4528. }
  4529. }
  4530. if res.Infcode == 0 {
  4531. item.IsSale = 1
  4532. item.Bchno = number
  4533. item.SaleDate = time.Now().Format("2006-01-02")
  4534. err5 := service.SaveDF(item)
  4535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4536. //if err5 == nil {
  4537. //
  4538. // if item.IsChange == 1 { //没变更,进行变更操作
  4539. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4540. //
  4541. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4542. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4543. //
  4544. // var respJSON3 map[string]interface{}
  4545. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4546. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4548. // return
  4549. // }
  4550. //
  4551. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4552. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4553. // utils.ErrorLog("解析失败:%v", err)
  4554. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4555. // return
  4556. // }
  4557. // //if res3507for10188.Infcode
  4558. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4559. // //res.Output = resSix10265.Output
  4560. // res3.ErrMsg = res3507for10188.ErrMsg
  4561. // res3.Cainfo = res3507for10188.Cainfo
  4562. // res3.WarnMsg = res3507for10188.WarnMsg
  4563. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4564. // res3.Infcode = infocode
  4565. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4566. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4567. // utils.ErrorLog("解析失败:%v", err)
  4568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4569. // return
  4570. // }
  4571. // //if res3507for10188.Infcode
  4572. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4573. // //res.Output = resSix10265.Output
  4574. // res3.ErrMsg = res3507for10188.ErrMsg
  4575. // res3.Cainfo = res3507for10188.Cainfo
  4576. // res3.WarnMsg = res3507for10188.WarnMsg
  4577. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4578. // res3.Infcode = infocode
  4579. //
  4580. // } else {
  4581. //
  4582. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4583. // utils.ErrorLog("解析失败:%v", err)
  4584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4585. // return
  4586. // }
  4587. //
  4588. // }
  4589. //
  4590. // if res3.Infcode == 0 {
  4591. // item.IsChange = 1
  4592. // item.BgBchno = bg_number
  4593. // service.SaveDF2(item)
  4594. // return
  4595. // } else {
  4596. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4597. // }
  4598. // }
  4599. //}
  4600. } else {
  4601. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4602. }
  4603. }
  4604. }
  4605. } else if item.ConsumableType == 7 {
  4606. var res3507for10188 FJ3507ResultFor10188
  4607. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4608. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4609. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4610. //判断是否已经销售
  4611. if item.IsSale == 2 { //是否已经销售,1是 0否
  4612. //是否已经变更 1是 0否
  4613. if item.IsChange == 0 { //没变更,进行变更操作
  4614. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4615. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4616. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4617. var respJSON3 map[string]interface{}
  4618. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4621. return
  4622. }
  4623. userJSONBytes3, _ := json.Marshal(respJSON3)
  4624. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4625. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4626. utils.ErrorLog("解析失败:%v", err)
  4627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4628. return
  4629. }
  4630. //if res3507for10188.Infcode
  4631. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4632. //res.Output = resSix10265.Output
  4633. res3.ErrMsg = res3507for10188.ErrMsg
  4634. res3.Cainfo = res3507for10188.Cainfo
  4635. res3.WarnMsg = res3507for10188.WarnMsg
  4636. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4637. res3.Infcode = infocode
  4638. } else {
  4639. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4640. utils.ErrorLog("解析失败:%v", err)
  4641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4642. return
  4643. }
  4644. }
  4645. if res3.Infcode == 0 {
  4646. item.IsChange = 1
  4647. item.BgBchno = bg_number
  4648. service.SaveDF2(item)
  4649. } else {
  4650. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4651. }
  4652. }
  4653. } else { //没销售,
  4654. //进行商品销售退货接口
  4655. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4656. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4657. saveLog(result111, result222, "3506", "销售退货")
  4658. var res7 FJ3507Result
  4659. //进行商品销售接口
  4660. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4661. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4662. var respJSON3 map[string]interface{}
  4663. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4664. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4666. return
  4667. }
  4668. userJSONBytes3, _ := json.Marshal(respJSON3)
  4669. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4670. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4671. utils.ErrorLog("解析失败:%v", err)
  4672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4673. return
  4674. }
  4675. //if res3507for10188.Infcode
  4676. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4677. //res.Output = resSix10265.Output
  4678. res7.ErrMsg = res3507for10188.ErrMsg
  4679. res7.Cainfo = res3507for10188.Cainfo
  4680. res7.WarnMsg = res3507for10188.WarnMsg
  4681. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4682. res7.Infcode = infocode
  4683. } else {
  4684. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4685. utils.ErrorLog("解析失败:%v", err)
  4686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4687. return
  4688. }
  4689. }
  4690. if res7.Infcode == 0 {
  4691. item.IsSale = 2
  4692. item.SaleDate = item.SaleDate
  4693. item.Bchno = number
  4694. service.SaveDF(item)
  4695. if item.IsChange == 0 { //没变更,进行变更操作
  4696. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4697. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4698. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4699. var respJSON3 map[string]interface{}
  4700. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4703. return
  4704. }
  4705. userJSONBytes3, _ := json.Marshal(respJSON3)
  4706. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4707. // utils.ErrorLog("解析失败:%v", err)
  4708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4709. // return
  4710. //}
  4711. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4712. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4713. utils.ErrorLog("解析失败:%v", err)
  4714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4715. return
  4716. }
  4717. //if res3507for10188.Infcode
  4718. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4719. //res.Output = resSix10265.Output
  4720. res3.ErrMsg = res3507for10188.ErrMsg
  4721. res3.Cainfo = res3507for10188.Cainfo
  4722. res3.WarnMsg = res3507for10188.WarnMsg
  4723. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4724. res3.Infcode = infocode
  4725. } else {
  4726. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4727. utils.ErrorLog("解析失败:%v", err)
  4728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4729. return
  4730. }
  4731. }
  4732. if res3.Infcode == 0 {
  4733. item.IsChange = 1
  4734. item.BgBchno = bg_number
  4735. service.SaveDF2(item)
  4736. } else {
  4737. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4738. }
  4739. }
  4740. } else {
  4741. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4742. }
  4743. }
  4744. } else { //还没结算
  4745. if item.IsChange == 0 { //没变更,进行变更操作
  4746. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4747. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4748. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4749. var respJSON3 map[string]interface{}
  4750. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4753. return
  4754. }
  4755. userJSONBytes3, _ := json.Marshal(respJSON3)
  4756. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4757. // utils.ErrorLog("解析失败:%v", err)
  4758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4759. // return
  4760. //}
  4761. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4762. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4763. utils.ErrorLog("解析失败:%v", err)
  4764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4765. return
  4766. }
  4767. //if res3507for10188.Infcode
  4768. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4769. //res.Output = resSix10265.Output
  4770. res3.ErrMsg = res3507for10188.ErrMsg
  4771. res3.Cainfo = res3507for10188.Cainfo
  4772. res3.WarnMsg = res3507for10188.WarnMsg
  4773. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4774. res3.Infcode = infocode
  4775. } else {
  4776. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4777. utils.ErrorLog("解析失败:%v", err)
  4778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4779. return
  4780. }
  4781. }
  4782. if res3.Infcode == 0 {
  4783. item.IsChange = 1
  4784. item.BgBchno = bg_number
  4785. service.SaveDF2(item)
  4786. } else {
  4787. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4788. }
  4789. }
  4790. }
  4791. }
  4792. }
  4793. if len(err) == 0 {
  4794. c.ServeSuccessJSON(map[string]interface{}{
  4795. "msg": "销售变更成功",
  4796. })
  4797. } else {
  4798. c.ServeSuccessJSON(map[string]interface{}{
  4799. "failed_code": -10,
  4800. "msg": err,
  4801. })
  4802. }
  4803. }
  4804. func ChangeDrugTenone() {
  4805. //ids := c.GetString("ids")
  4806. //id_arr := strings.Split(ids, ",")
  4807. now := time.Now()
  4808. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4809. //timestamp := int64(1729612800)
  4810. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4811. admin_user_id := int64(2463)
  4812. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4813. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4814. var err []string
  4815. for _, item := range flows {
  4816. var res3 ResultSix
  4817. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4818. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4819. continue
  4820. }
  4821. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4822. continue
  4823. }
  4824. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4825. if prescription.OrderStatus == 2 {
  4826. //已经结算
  4827. //判断是否已经销售
  4828. if item.IsSale == 1 { //是否已经销售,1是 0否
  4829. //是否已经变更 1是 0否
  4830. if item.IsChange == 0 { //没变更,进行变更操作
  4831. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4832. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4833. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4834. var respJSON3 map[string]interface{}
  4835. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4837. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4838. return
  4839. }
  4840. userJSONBytes3, _ := json.Marshal(respJSON3)
  4841. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4842. utils.ErrorLog("解析失败:%v", err)
  4843. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4844. return
  4845. }
  4846. if res3.Infcode == 0 {
  4847. item.IsChange = 1
  4848. item.BgBchno = bg_number
  4849. service.SaveDF2(item)
  4850. } else {
  4851. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4852. }
  4853. }
  4854. } else { //没销售,
  4855. var res FJ3507Result
  4856. var res3507for10188 FJ3507ResultFor10188
  4857. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4858. //进行商品销售接口
  4859. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4860. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4861. var respJSON3 map[string]interface{}
  4862. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4864. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4865. return
  4866. }
  4867. userJSONBytes3, _ := json.Marshal(respJSON3)
  4868. {
  4869. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4870. utils.ErrorLog("解析失败:%v", err)
  4871. return
  4872. }
  4873. //if res3507for10188.Infcode
  4874. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4875. //res.Output = resSix10265.Output
  4876. res.ErrMsg = res3507for10188.ErrMsg
  4877. res.Cainfo = res3507for10188.Cainfo
  4878. res.WarnMsg = res3507for10188.WarnMsg
  4879. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4880. res.Infcode = infocode
  4881. }
  4882. if res.Infcode == 0 {
  4883. item.IsSale = 1
  4884. item.Bchno = number
  4885. item.SaleDate = time.Now().Format("2006-01-02")
  4886. err5 := service.SaveDF(item)
  4887. if err5 == nil {
  4888. if item.IsChange == 1 { //没变更,进行变更操作
  4889. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4890. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4891. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4892. var respJSON3 map[string]interface{}
  4893. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4895. return
  4896. }
  4897. {
  4898. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4899. utils.ErrorLog("解析失败:%v", err)
  4900. return
  4901. }
  4902. //if res3507for10188.Infcode
  4903. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4904. //res.Output = resSix10265.Output
  4905. res3.ErrMsg = res3507for10188.ErrMsg
  4906. res3.Cainfo = res3507for10188.Cainfo
  4907. res3.WarnMsg = res3507for10188.WarnMsg
  4908. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4909. res3.Infcode = infocode
  4910. }
  4911. if res3.Infcode == 0 {
  4912. item.IsChange = 1
  4913. item.BgBchno = bg_number
  4914. service.SaveDF2(item)
  4915. } else {
  4916. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4917. }
  4918. }
  4919. }
  4920. } else {
  4921. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4922. }
  4923. }
  4924. }
  4925. }
  4926. }
  4927. }
  4928. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4929. var struct3502 models.Struct3502
  4930. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4931. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4932. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4933. struct3502.FixmedinsCode = miConfig.Code
  4934. struct3502.Code = miConfig.Code
  4935. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4936. struct3502.Opter = role.UserName
  4937. struct3502.RxFlag = "1"
  4938. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4939. struct3502.OrgName = miConfig.OrgName
  4940. struct3502.AccessKey = miConfig.AccessKey
  4941. struct3502.RequestUrl = miConfig.Url
  4942. struct3502.SecretKey = miConfig.SecretKey
  4943. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4944. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4945. struct3502.Url = miConfig.Url
  4946. struct3502.AppId = miConfig.Cainfo
  4947. struct3502.AppSecret = miConfig.AppSecret
  4948. struct3502.Enckey = miConfig.EncKey
  4949. struct3502.SignKey = miConfig.SignKey
  4950. struct3502.SecretKey = miConfig.SecretKey
  4951. struct3502.InvChgType = chgType
  4952. struct3502.FixmedinsBchno = number
  4953. struct3502.Cnt = strconv.FormatInt(count, 10)
  4954. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4955. //result1, result2, _ := service.FJyb3502(struct3502)
  4956. if miConfig.MdtrtareaAdmvs == "350500" {
  4957. result1, result2, _ := service.FJyb3502(struct3502)
  4958. //saveLog(result1, result2, "3502", "3502")
  4959. return result1, result2
  4960. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4961. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4962. return result1, result2
  4963. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4964. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4965. return result1, result2
  4966. } else {
  4967. data := make(map[string]interface{})
  4968. data["struct_3502s"] = struct3502
  4969. client := &http.Client{}
  4970. bytesData, _ := json.Marshal(data)
  4971. var req *http.Request
  4972. if miConfig.MdtrtareaAdmvs == "320921" {
  4973. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4974. } else {
  4975. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4976. }
  4977. resp, _ := client.Do(req)
  4978. defer resp.Body.Close()
  4979. body, ioErr := ioutil.ReadAll(resp.Body)
  4980. if ioErr != nil {
  4981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4982. }
  4983. var respJSON map[string]interface{}
  4984. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4986. }
  4987. //var resSix10265 ResultSix10265 //1101结果
  4988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4989. result, _ := json.Marshal(respJSON)
  4990. return string(result), ""
  4991. }
  4992. }
  4993. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4994. var struct3505 models.Struct3505
  4995. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4996. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4997. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4998. struct3505.FixmedinsBchno = number
  4999. struct3505.Opter = role.UserName
  5000. struct3505.Bchno = "---"
  5001. struct3505.FixmedinsCode = miConfig.Code
  5002. struct3505.Code = miConfig.Code
  5003. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5004. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5005. struct3505.PrscDrName = roles.UserName
  5006. if org_id == 10191 {
  5007. struct3505.PharName = "刘水山"
  5008. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5009. }
  5010. if org_id == 10188 {
  5011. struct3505.PharName = "李汉清"
  5012. struct3505.PharPracCertNo = "30220200932022010034"
  5013. }
  5014. if org_id == 10217 {
  5015. struct3505.PharName = "张敏"
  5016. struct3505.PharPracCertNo = "30220230432090100108"
  5017. }
  5018. if org_id == 10318 {
  5019. struct3505.PharName = "邹刘阳"
  5020. struct3505.PharPracCertNo = "210441200001378"
  5021. }
  5022. if org_id == 10402 {
  5023. struct3505.PharName = "刘韶健"
  5024. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5025. }
  5026. if org_id == 9919 {
  5027. struct3505.PharName = "周君权"
  5028. struct3505.PharPracCertNo = "089644396094401375"
  5029. }
  5030. if org_id == 10644 {
  5031. struct3505.PharName = "陈金娣"
  5032. struct3505.PharPracCertNo = "20181441500320100066"
  5033. }
  5034. if org_id == 10567 {
  5035. struct3505.PharName = "范小兰"
  5036. struct3505.PharPracCertNo = "0200102079485"
  5037. }
  5038. if org_id == 10721 {
  5039. struct3505.PharName = "孙莉侠"
  5040. struct3505.PharPracCertNo = "060399"
  5041. }
  5042. if org_id == 10726 {
  5043. struct3505.PharName = "彭建福"
  5044. struct3505.PharPracCertNo = "D445281006261"
  5045. }
  5046. if org_id == 10265 {
  5047. struct3505.PharName = "李彩星"
  5048. struct3505.PharPracCertNo = "20171110600110100019"
  5049. }
  5050. if org_id == 10028 {
  5051. struct3505.PharName = "曾细平"
  5052. struct3505.PharPracCertNo = "D440307022134"
  5053. }
  5054. if org_id == 10138 {
  5055. struct3505.PharName = "彭斯遥"
  5056. struct3505.PharPracCertNo = "30220200943042010052"
  5057. }
  5058. if org_id == 10278 {
  5059. struct3505.PharName = "彭斯遥"
  5060. struct3505.PharPracCertNo = "30220200943042010052"
  5061. }
  5062. if org_id == 10610 {
  5063. struct3505.PharName = "彭斯遥"
  5064. struct3505.PharPracCertNo = "30220200943042010052"
  5065. }
  5066. if org_id == 10537 {
  5067. struct3505.PharName = "彭斯遥"
  5068. struct3505.PharPracCertNo = "30220200943042010052"
  5069. }
  5070. if org_id == 9504 {
  5071. struct3505.PharName = "资美红"
  5072. struct3505.PharPracCertNo = "D440904006635"
  5073. }
  5074. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5075. struct3505.SetlId = order.SetlId
  5076. struct3505.MdtrtSn = order.MdtrtId
  5077. struct3505.ManuLotnum = drug.BatchNumber
  5078. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5079. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5080. struct3505.RxFlag = "1"
  5081. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5082. struct3505.TrdnFlag = "0"
  5083. } else {
  5084. struct3505.TrdnFlag = "1"
  5085. }
  5086. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5087. struct3505.TrdnFlag = "1"
  5088. }
  5089. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5090. struct3505.TrdnFlag = "0"
  5091. }
  5092. struct3505.RtalDocno = order.Number
  5093. struct3505.PsnCertType = "01"
  5094. struct3505.CertNo = order.Certno
  5095. struct3505.PsnNo = order.PsnNo
  5096. struct3505.PsnName = order.PsnName
  5097. struct3505.Url = miConfig.Url
  5098. struct3505.AppId = miConfig.Cainfo
  5099. struct3505.AppSecret = miConfig.AppSecret
  5100. struct3505.Enckey = miConfig.EncKey
  5101. struct3505.SignKey = miConfig.SignKey
  5102. struct3505.SecretKey = miConfig.SecretKey
  5103. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5104. struct3505.SelRetnCnt = strValue
  5105. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5106. struct3505.SelRetnOpterName = role.UserName
  5107. if order.IsMedicineInsurance == 1 {
  5108. struct3505.MdtrtSetlType = "1"
  5109. } else {
  5110. struct3505.MdtrtSetlType = "2"
  5111. }
  5112. struct3505.OrgName = miConfig.OrgName
  5113. struct3505.AccessKey = miConfig.AccessKey
  5114. struct3505.RequestUrl = miConfig.Url
  5115. struct3505.SecretKey = miConfig.SecretKey
  5116. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5117. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5118. struct3505.Cainfo = miConfig.Cainfo
  5119. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5120. if miConfig.MdtrtareaAdmvs == "350500" {
  5121. result1, result2, _ := service.FJyb3505(struct3505)
  5122. return result1, result2
  5123. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5124. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5125. return result1, result2
  5126. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5127. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5128. return result1, result2
  5129. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5130. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5131. return result1, result2
  5132. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5133. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5134. return result1, result2
  5135. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5136. data := make(map[string]interface{})
  5137. data["struct_3505s"] = struct3505
  5138. client := &http.Client{}
  5139. bytesData, _ := json.Marshal(data)
  5140. var req *http.Request
  5141. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5142. resp, _ := client.Do(req)
  5143. defer resp.Body.Close()
  5144. body, ioErr := ioutil.ReadAll(resp.Body)
  5145. if ioErr != nil {
  5146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5147. }
  5148. var respJSON map[string]interface{}
  5149. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5151. }
  5152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5153. result, _ := json.Marshal(respJSON)
  5154. return string(result), ""
  5155. } else {
  5156. data := make(map[string]interface{})
  5157. data["struct_3505s"] = struct3505
  5158. client := &http.Client{}
  5159. bytesData, _ := json.Marshal(data)
  5160. var req *http.Request
  5161. if miConfig.MdtrtareaAdmvs == "320921" {
  5162. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5163. } else {
  5164. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5165. }
  5166. resp, _ := client.Do(req)
  5167. defer resp.Body.Close()
  5168. body, ioErr := ioutil.ReadAll(resp.Body)
  5169. if ioErr != nil {
  5170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5171. }
  5172. var respJSON map[string]interface{}
  5173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5175. }
  5176. //var resSix10265 ResultSix10265 //1101结果
  5177. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5178. result, _ := json.Marshal(respJSON)
  5179. return string(result), ""
  5180. }
  5181. }
  5182. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5183. var struct3505 models.Struct3505
  5184. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5185. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5186. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5187. struct3505.FixmedinsBchno = number
  5188. struct3505.Opter = role.UserName
  5189. struct3505.FixmedinsCode = miConfig.Code
  5190. struct3505.Code = miConfig.Code
  5191. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5192. struct3505.PrscDrName = roles.UserName
  5193. if org_id == 10191 {
  5194. struct3505.PharName = "刘水山"
  5195. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5196. }
  5197. if org_id == 10188 {
  5198. struct3505.PharName = "李汉清"
  5199. struct3505.PharPracCertNo = "30220200932022010034"
  5200. }
  5201. if org_id == 10217 {
  5202. struct3505.PharName = "张敏"
  5203. struct3505.PharPracCertNo = "30220230432090100108"
  5204. }
  5205. if org_id == 10318 {
  5206. struct3505.PharName = "邹刘阳"
  5207. struct3505.PharPracCertNo = "210441200001378"
  5208. }
  5209. if org_id == 10402 {
  5210. struct3505.PharName = "刘韶健"
  5211. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5212. }
  5213. if org_id == 9919 {
  5214. struct3505.PharName = "周君权"
  5215. struct3505.PharPracCertNo = "089644396094401375"
  5216. }
  5217. if org_id == 10644 {
  5218. struct3505.PharName = "陈金娣"
  5219. struct3505.PharPracCertNo = "20181441500320100066"
  5220. }
  5221. if org_id == 10567 {
  5222. struct3505.PharName = "范小兰"
  5223. struct3505.PharPracCertNo = "0200102079485"
  5224. }
  5225. if org_id == 10721 {
  5226. struct3505.PharName = "孙莉侠"
  5227. struct3505.PharPracCertNo = "060399"
  5228. }
  5229. if org_id == 10726 {
  5230. struct3505.PharName = "彭建福"
  5231. struct3505.PharPracCertNo = "D445281006261"
  5232. }
  5233. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5234. struct3505.SetlId = order.SetlId
  5235. struct3505.MdtrtSn = order.MdtrtId
  5236. struct3505.ManuLotnum = drug.Number
  5237. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5238. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5239. struct3505.RxFlag = "1"
  5240. struct3505.TrdnFlag = "0"
  5241. struct3505.RtalDocno = order.Number
  5242. struct3505.PsnCertType = "01"
  5243. struct3505.CertNo = order.Certno
  5244. struct3505.PsnNo = order.PsnNo
  5245. struct3505.PsnName = order.PsnName
  5246. struct3505.Url = miConfig.Url
  5247. struct3505.AppId = miConfig.Cainfo
  5248. struct3505.AppSecret = miConfig.AppSecret
  5249. struct3505.Enckey = miConfig.EncKey
  5250. struct3505.SignKey = miConfig.SignKey
  5251. struct3505.SecretKey = miConfig.SecretKey
  5252. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5253. struct3505.SelRetnCnt = strValue
  5254. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5255. struct3505.SelRetnOpterName = role.UserName
  5256. if order.IsMedicineInsurance == 1 {
  5257. struct3505.MdtrtSetlType = "1"
  5258. } else {
  5259. struct3505.MdtrtSetlType = "2"
  5260. }
  5261. struct3505.OrgName = miConfig.OrgName
  5262. struct3505.AccessKey = miConfig.AccessKey
  5263. struct3505.RequestUrl = miConfig.Url
  5264. struct3505.SecretKey = miConfig.SecretKey
  5265. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5266. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5267. struct3505.Cainfo = miConfig.Cainfo
  5268. struct3505.DrugTracCodg = drug.DrugCode
  5269. if miConfig.MdtrtareaAdmvs == "350500" {
  5270. result1, result2, _ := service.FJyb3505(struct3505)
  5271. return result1, result2
  5272. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5273. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5274. return result1, result2
  5275. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5276. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5277. return result1, result2
  5278. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5279. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5280. return result1, result2
  5281. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5282. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5283. return result1, result2
  5284. } else {
  5285. data := make(map[string]interface{})
  5286. data["struct_3505s"] = struct3505
  5287. client := &http.Client{}
  5288. bytesData, _ := json.Marshal(data)
  5289. var req *http.Request
  5290. if miConfig.MdtrtareaAdmvs == "320921" {
  5291. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5292. } else {
  5293. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5294. }
  5295. resp, _ := client.Do(req)
  5296. defer resp.Body.Close()
  5297. body, ioErr := ioutil.ReadAll(resp.Body)
  5298. if ioErr != nil {
  5299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5300. }
  5301. var respJSON map[string]interface{}
  5302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5304. }
  5305. //var resSix10265 ResultSix10265 //1101结果
  5306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5307. result, _ := json.Marshal(respJSON)
  5308. return string(result), ""
  5309. }
  5310. }
  5311. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5312. var struct3506 models.Struct3506
  5313. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5314. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5315. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5316. struct3506.FixmedinsCode = miConfig.Code
  5317. struct3506.Code = miConfig.Code
  5318. struct3506.FixmedinsBchno = number
  5319. struct3506.Opter = role.UserName
  5320. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5321. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5322. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5323. struct3506.MdtrtSn = order.MdtrtId
  5324. struct3506.ExpyEnd = ""
  5325. struct3506.RxFlag = "0"
  5326. struct3506.TrdnFlag = "1"
  5327. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5328. struct3506.SelRetnCnt = strValue
  5329. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5330. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5331. struct3506.SelRetnOpterName = role.UserName
  5332. struct3506.OrgName = miConfig.OrgName
  5333. struct3506.AccessKey = miConfig.AccessKey
  5334. struct3506.RequestUrl = miConfig.Url
  5335. struct3506.SecretKey = miConfig.SecretKey
  5336. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5337. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5338. struct3506.Url = miConfig.Url
  5339. struct3506.AppId = miConfig.Cainfo
  5340. struct3506.AppSecret = miConfig.AppSecret
  5341. struct3506.Enckey = miConfig.EncKey
  5342. struct3506.SignKey = miConfig.SignKey
  5343. struct3506.SecretKey = miConfig.SecretKey
  5344. struct3506.DrugTracCodg = drug.DrugCode
  5345. if miConfig.MdtrtareaAdmvs == "350500" {
  5346. result1, result2, _ := service.FJyb3506(struct3506)
  5347. return result1, result2
  5348. } else {
  5349. data := make(map[string]interface{})
  5350. data["struct_3506s"] = struct3506
  5351. client := &http.Client{}
  5352. bytesData, _ := json.Marshal(data)
  5353. var req *http.Request
  5354. if miConfig.MdtrtareaAdmvs == "320921" {
  5355. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5356. } else {
  5357. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5358. }
  5359. resp, _ := client.Do(req)
  5360. defer resp.Body.Close()
  5361. body, ioErr := ioutil.ReadAll(resp.Body)
  5362. if ioErr != nil {
  5363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5364. }
  5365. var respJSON map[string]interface{}
  5366. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5368. }
  5369. //var resSix10265 ResultSix10265 //1101结果
  5370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5371. result, _ := json.Marshal(respJSON)
  5372. return string(result), ""
  5373. }
  5374. }
  5375. func (c *HisApiController) Get1318() {
  5376. adminUser := c.GetAdminUserInfo()
  5377. admin_user_id, _ := c.GetInt64("admin_user_id")
  5378. code := c.GetString("code")
  5379. code = ""
  5380. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5381. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5382. api := ""
  5383. if miConfig.MdtrtareaAdmvs == "320921" {
  5384. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5385. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5386. } else {
  5387. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5388. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5389. }
  5390. resp, requestErr := http.Get(api)
  5391. if requestErr != nil {
  5392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5393. return
  5394. }
  5395. body, ioErr := ioutil.ReadAll(resp.Body)
  5396. if ioErr != nil {
  5397. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5399. return
  5400. }
  5401. var respJSON map[string]interface{}
  5402. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5405. return
  5406. }
  5407. //var res Result2406
  5408. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5409. result, _ := json.Marshal(respJSON)
  5410. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5411. utils.ErrorLog("解析失败:%v", err)
  5412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5413. return
  5414. }
  5415. if res.Infcode == "0" {
  5416. c.ServeSuccessJSON(map[string]interface{}{
  5417. "result": "",
  5418. })
  5419. } else {
  5420. c.ServeSuccessJSON(map[string]interface{}{
  5421. "failed_code": -10,
  5422. "msg": res.ErrMsg,
  5423. })
  5424. */return
  5425. //}
  5426. }
  5427. func (c *HisApiController) Get2503() {
  5428. adminUser := c.GetAdminUserInfo()
  5429. admin_user_id, _ := c.GetInt64("admin_user_id")
  5430. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5431. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5432. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5433. }
  5434. func (c *HisApiController) Get2406() {
  5435. id, _ := c.GetInt64("id")
  5436. record_time := c.GetString("record_time")
  5437. his_patient_id, _ := c.GetInt64("his_patient_id")
  5438. admin_user_id, _ := c.GetInt64("admin_user_id")
  5439. diagnosis_id := c.GetString("diagnosis")
  5440. timeLayout := "2006-01-02"
  5441. loc, _ := time.LoadLocation("Local")
  5442. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5443. if err != nil {
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5445. return
  5446. }
  5447. recordDateTime := theTime.Unix()
  5448. adminUser := c.GetAdminUserInfo()
  5449. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5450. var config []*models.HisXtDiagnoseConfig
  5451. for _, item := range diagnosis_ids {
  5452. id, _ := strconv.ParseInt(item, 10, 64)
  5453. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5454. config = append(config, &diagnosisConfig)
  5455. }
  5456. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5457. fmt.Println(his_patient_id)
  5458. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5459. //timestamp := time.Now().Unix()
  5460. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5461. var patientPrescription models.HisPrescriptionInfo
  5462. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5463. if patientPrescription.ID == 0 {
  5464. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5465. }
  5466. var res2 Result2406
  5467. if miConfig.MdtrtareaAdmvs == "341203" {
  5468. data := make(map[string]interface{})
  5469. client := &http.Client{}
  5470. data["psn_no"] = his.PsnNo
  5471. data["mdtrt_id"] = his.Number
  5472. data["operator"] = roles.UserName
  5473. data["cert_no"] = his.IdCardNo
  5474. data["org_name"] = miConfig.OrgName
  5475. data["psn_name"] = his.Name
  5476. data["ipt_otp_no"] = his.IptOtpNo
  5477. data["ipt_psn_sp_flag_type"] = "0901"
  5478. data["ipt_psn_sp_flag"] = "1"
  5479. data["fixmedins_code"] = miConfig.Code
  5480. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5481. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5482. data["url"] = miConfig.Url
  5483. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5484. bytesData, _ := json.Marshal(data)
  5485. var req *http.Request
  5486. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5487. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5488. resp, _ := client.Do(req)
  5489. defer resp.Body.Close()
  5490. body, ioErr := ioutil.ReadAll(resp.Body)
  5491. if ioErr != nil {
  5492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5494. return
  5495. }
  5496. var respJSON map[string]interface{}
  5497. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5500. return
  5501. }
  5502. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5503. if status == "0" {
  5504. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5505. c.ServeSuccessJSON(map[string]interface{}{
  5506. "failed_code": -10,
  5507. "msg": err_msg,
  5508. })
  5509. return
  5510. }
  5511. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5512. userJSONBytes, _ := json.Marshal(respJSON)
  5513. fmt.Println("log")
  5514. fmt.Println(string(userJSONBytes))
  5515. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5516. utils.ErrorLog("解析失败:%v", err)
  5517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5518. return
  5519. }
  5520. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5521. data := make(map[string]interface{})
  5522. client := &http.Client{}
  5523. data["psn_no"] = his.PsnNo
  5524. data["mdtrt_id"] = his.Number
  5525. data["operator"] = roles.UserName
  5526. data["cert_no"] = his.IdCardNo
  5527. data["org_name"] = miConfig.OrgName
  5528. data["psn_name"] = his.Name
  5529. data["ipt_otp_no"] = his.IptOtpNo
  5530. data["ipt_psn_sp_flag_type"] = "0901"
  5531. data["ipt_psn_sp_flag"] = "1"
  5532. data["fixmedins_code"] = miConfig.Code
  5533. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5534. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5535. data["url"] = miConfig.Url
  5536. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5537. bytesData, _ := json.Marshal(data)
  5538. var req *http.Request
  5539. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5540. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5541. resp, _ := client.Do(req)
  5542. defer resp.Body.Close()
  5543. body, ioErr := ioutil.ReadAll(resp.Body)
  5544. if ioErr != nil {
  5545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5547. return
  5548. }
  5549. var respJSON map[string]interface{}
  5550. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5553. return
  5554. }
  5555. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5556. if status == "0" {
  5557. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5558. c.ServeSuccessJSON(map[string]interface{}{
  5559. "failed_code": -10,
  5560. "msg": err_msg,
  5561. })
  5562. return
  5563. }
  5564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5565. userJSONBytes, _ := json.Marshal(respJSON)
  5566. fmt.Println("log")
  5567. fmt.Println(string(userJSONBytes))
  5568. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5569. utils.ErrorLog("解析失败:%v", err)
  5570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5571. return
  5572. }
  5573. }
  5574. if res2.Infcode != 0 {
  5575. adminUser := c.GetAdminUserInfo()
  5576. errlog := &models.HisOrderError{
  5577. UserOrgId: adminUser.CurrentOrgId,
  5578. Ctime: time.Now().Unix(),
  5579. Mtime: time.Now().Unix(),
  5580. ErrMsg: res2.ErrMsg,
  5581. Status: 1,
  5582. PatientId: id,
  5583. RecordTime: recordDateTime,
  5584. Stage: 3,
  5585. }
  5586. service.CreateErrMsgLog(errlog)
  5587. c.ServeSuccessJSON(map[string]interface{}{
  5588. "failed_code": -10,
  5589. "msg": res2.ErrMsg,
  5590. })
  5591. return
  5592. } else {
  5593. c.ServeSuccessJSON(map[string]interface{}{
  5594. "msg": "上传成功",
  5595. })
  5596. return
  5597. }
  5598. }
  5599. func (c *HisApiController) Get4105() {
  5600. }
  5601. func (c *HisApiController) Post5302() {
  5602. patient_id, _ := c.GetInt64("id")
  5603. admin_user_id, _ := c.GetInt64("admin_user_id")
  5604. p, _ := service.GetHisPatientById(patient_id)
  5605. adminUser := c.GetAdminUserInfo()
  5606. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5607. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5608. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5609. }
  5610. func (c *HisApiController) Get4104() {
  5611. }
  5612. type Output struct {
  5613. CertNo string `json:"certno"`
  5614. PsnName string `json:"psn_name"`
  5615. CardNo string `json:"card_no"`
  5616. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5617. CardSN string `json:"card_sn"`
  5618. PsnCertType string `json:"psn_cert_type"`
  5619. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5620. MdtrtCertType string `json:"mdtrt_cert_type"`
  5621. QRCode string `json:"qrCode"`
  5622. EcToken string `json:"ecToken"`
  5623. }
  5624. type AHResponse struct {
  5625. Body AHBody `json:"body"`
  5626. Code int `json:"code"`
  5627. CSBCode int `json:"csbCode"`
  5628. Message string `json:"message"`
  5629. RequestID string `json:"requestId"`
  5630. State struct{} `json:"state"`
  5631. }
  5632. type AHBody struct {
  5633. ErrMsg string `json:"err_msg"`
  5634. InfRefMsgID string `json:"inf_refmsgid"`
  5635. InfCode int `json:"infcode"`
  5636. Output struct {
  5637. Result []struct {
  5638. BasMednFlag string `json:"bas_medn_flag"`
  5639. ChldMedcFlag string `json:"chld_medc_flag"`
  5640. ChrgitmLv string `json:"chrgitm_lv"`
  5641. Cnt float64 `json:"cnt"`
  5642. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5643. DrtReimFlag string `json:"drt_reim_flag"`
  5644. FeedetlSn string `json:"feedetl_sn"`
  5645. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5646. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5647. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5648. ListSpItemFlag string `json:"list_sp_item_flag"`
  5649. LmtUsedFlag string `json:"lmt_used_flag"`
  5650. MedChrgitmType string `json:"med_chrgitm_type"`
  5651. Memo string `json:"memo"`
  5652. OverlmtAmt float64 `json:"overlmt_amt"`
  5653. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5654. Pric float64 `json:"pric"`
  5655. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5656. SelfpayProp float64 `json:"selfpay_prop"`
  5657. } `json:"result"`
  5658. } `json:"output"`
  5659. }
  5660. type Response struct {
  5661. Output Output `json:"output"`
  5662. Infcode int `json:"infcode"`
  5663. InfRefMsgID string `json:"inf_refmsgid"`
  5664. RefMsgTime string `json:"refmsg_time"`
  5665. RespondTime string `json:"respond_time"`
  5666. ErrMsg string `json:"err_msg"`
  5667. WarnMsg string `json:"warn_msg"`
  5668. SignType string `json:"signtype"`
  5669. CAInfo string `json:"cainfo"`
  5670. }
  5671. func (c *HisApiController) Getquerydata() {
  5672. query_type, _ := c.GetInt64("type")
  5673. refd_setl_flag := c.GetString("refd_setl_flag")
  5674. med_type := c.GetString("med_type")
  5675. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5676. cert_no := c.GetString("cert_no")
  5677. psn_no := c.GetString("psn_no")
  5678. start_time := c.GetString("start_time")
  5679. end_time := c.GetString("end_time")
  5680. page, _ := c.GetInt64("page")
  5681. limit, _ := c.GetInt64("limit")
  5682. var bp models.BusinessParams5262
  5683. bp.RefdSetlFlag = refd_setl_flag
  5684. bp.MedType = med_type
  5685. bp.Certno = cert_no
  5686. bp.Psnno = psn_no
  5687. bp.QBegntime = start_time
  5688. bp.QEndtime = end_time
  5689. if query_type == 1 { //本地
  5690. Post5262(c, bp, page, limit)
  5691. } else { //异地
  5692. Post5267(c, bp, page, limit)
  5693. }
  5694. }
  5695. func (c *HisApiController) Drugscheck() {
  5696. admin_user_id, _ := c.GetInt64("admin_user_id")
  5697. adminUser := c.GetAdminUserInfo()
  5698. var queryResult []QueryResult
  5699. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5700. for _, item := range drugs {
  5701. result := QueryResult{
  5702. ID: item.ID,
  5703. Name: item.DrugName,
  5704. Code: item.MedicalInsuranceNumber,
  5705. List_type_code: "101",
  5706. }
  5707. queryResult = append(queryResult, result)
  5708. }
  5709. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5710. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5711. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5712. for _, item := range queryResult {
  5713. 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)
  5714. }
  5715. }
  5716. func (c *HisApiController) Goodcheck() {
  5717. admin_user_id, _ := c.GetInt64("admin_user_id")
  5718. adminUser := c.GetAdminUserInfo()
  5719. var queryResult []QueryResult
  5720. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5721. for _, item := range goods {
  5722. result := QueryResult{
  5723. ID: item.ID,
  5724. Name: item.GoodName,
  5725. Code: item.SocialSecurityDirectoryCode,
  5726. List_type_code: "301",
  5727. }
  5728. queryResult = append(queryResult, result)
  5729. }
  5730. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5731. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5732. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5733. for _, item := range queryResult {
  5734. 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)
  5735. //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)
  5736. }
  5737. }
  5738. func (c *HisApiController) Projectcheck() {
  5739. admin_user_id, _ := c.GetInt64("admin_user_id")
  5740. adminUser := c.GetAdminUserInfo()
  5741. var queryResult []QueryResult
  5742. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5743. for _, item := range projects {
  5744. result := QueryResult{
  5745. ID: item.ID,
  5746. Name: item.ProjectName,
  5747. Code: item.MedicalCode,
  5748. List_type_code: "201",
  5749. }
  5750. queryResult = append(queryResult, result)
  5751. }
  5752. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5753. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5754. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5755. for _, item := range queryResult {
  5756. 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)
  5757. }
  5758. }
  5759. //func (c *HisApiController)CancleDia(){
  5760. //
  5761. // id, _ := c.GetInt64("id")
  5762. // record_time := c.GetString("record_time")
  5763. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5764. //
  5765. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5766. //
  5767. // diagnosis_id := c.GetString("diagnosis")
  5768. // sick_type, _ := c.GetInt64("sick_type")
  5769. // reg_type, _ := c.GetInt64("p_type")
  5770. // begin_time := c.GetString("begin_time")
  5771. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5772. //
  5773. //
  5774. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5775. //
  5776. // fmt.Println(acct_used_flag)
  5777. //
  5778. //
  5779. // timeLayout := "2006-01-02"
  5780. // loc, _ := time.LoadLocation("Local")
  5781. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5782. // if err != nil {
  5783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5784. // return
  5785. // }
  5786. // recordDateTime := theTime.Unix()
  5787. // adminUser := c.GetAdminUserInfo()
  5788. //
  5789. //
  5790. //
  5791. //
  5792. //
  5793. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5794. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5795. // var patientPrescription models.HisPrescriptionInfo
  5796. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5797. // if patientPrescription.ID == 0 {
  5798. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5799. // }
  5800. // //if patientPrescription.Do
  5801. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5802. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5803. //
  5804. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5805. //
  5806. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5807. //
  5808. // var config []*models.HisXtDiagnoseConfig
  5809. // for _, item := range diagnosis_ids {
  5810. // id, _ := strconv.ParseInt(item, 10, 64)
  5811. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5812. // config = append(config, &diagnosisConfig)
  5813. // }
  5814. //
  5815. // sickConfig, _ := service.FindSickById(sick_type)
  5816. //
  5817. //
  5818. // data := make(map[string]interface{})
  5819. // client := &http.Client{}
  5820. // data["psn_no"] = his.PsnNo
  5821. // data["mdtrt_id"] = his.Number
  5822. // data["doctor"] = roles.UserName
  5823. // data["department"] = department.Name
  5824. // data["org_name"] = miConfig.OrgName
  5825. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5826. // data["doctor_id"] = doctor_info.DoctorNumber
  5827. // data["new_doctor_name"] = doctor_info.UserName
  5828. // data["fixmedins_code"] = miConfig.Code
  5829. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5830. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5831. // data["secret_key"] = miConfig.SecretKey
  5832. // data["sick_code"] = sickConfig.CountryCode
  5833. // data["sick_name"] = sickConfig.ClassName
  5834. // data["url"] = miConfig.Url
  5835. // data["ak"] = miConfig.AccessKey
  5836. // data["begin_time"] = begin_time
  5837. // data["cainfo"] = miConfig.Cainfo
  5838. // data["is_vaild"] = "0"
  5839. //
  5840. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5841. // data["config"] = config
  5842. // bytesData, _ := json.Marshal(data)
  5843. //
  5844. // var req *http.Request
  5845. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5846. // resp, _ := client.Do(req)
  5847. // defer resp.Body.Close()
  5848. // body, ioErr := ioutil.ReadAll(resp.Body)
  5849. // if ioErr != nil {
  5850. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5851. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5852. // return
  5853. // }
  5854. // var respJSON map[string]interface{}
  5855. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5856. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5857. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5858. // return
  5859. // }
  5860. //
  5861. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5862. // userJSONBytes, _ := json.Marshal(respJSON)
  5863. // fmt.Println("log")
  5864. // fmt.Println(string(userJSONBytes))
  5865. //
  5866. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5867. // utils.ErrorLog("解析失败:%v", err)
  5868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5869. // return
  5870. // }
  5871. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5872. // res2.Output = ressix10265.Output
  5873. // res2.ErrMsg = ressix10265.ErrMsg
  5874. // res2.Cainfo = ressix10265.Cainfo
  5875. // res2.WarnMsg = ressix10265.WarnMsg
  5876. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5877. // res2.Infcode = infocode
  5878. //
  5879. //}
  5880. func (c *HisApiController) Get4102() {
  5881. order_id, _ := c.GetInt64("order_id")
  5882. admin_user_id, _ := c.GetInt64("admin_user_id")
  5883. stas_type := c.GetString("stas_type")
  5884. order, _ := service.GetHisOrderByIDTwo(order_id)
  5885. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5886. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5887. var pp models.PublicParams
  5888. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5889. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5890. pp.FixmedinsName = miConfig.OrgName
  5891. pp.FixmedinsCode = miConfig.Code
  5892. pp.RequestUrl = miConfig.Url
  5893. pp.Cainfo = miConfig.Cainfo
  5894. pp.SecretKey = miConfig.SecretKey
  5895. pp.AccessKey = miConfig.AccessKey
  5896. pp.OpterName = curRoles.UserName
  5897. if miConfig.MdtrtareaAdmvs == "350500" {
  5898. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5899. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5900. saveLog(result, request, "4102", "清单确认")
  5901. var dat map[string]interface{}
  5902. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5903. fmt.Println(dat)
  5904. } else {
  5905. fmt.Println(err)
  5906. }
  5907. var empty ResultFourteen
  5908. userJSONBytes, _ := json.Marshal(dat)
  5909. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5910. utils.ErrorLog("解析失败:%v", err)
  5911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5912. return
  5913. }
  5914. if empty.Infcode == 0 {
  5915. c.ServeSuccessJSON(map[string]interface{}{
  5916. "msg": "确认成功",
  5917. })
  5918. return
  5919. }
  5920. } else {
  5921. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5922. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5923. result3, request3 := service.Jxyb4105(pp)
  5924. saveLog(result, request, "4102", "清单确认")
  5925. saveLog(result2, request2, "4103", "清单确认")
  5926. saveLog(result3, request3, "4105", "清单统计")
  5927. var dat map[string]interface{}
  5928. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5929. fmt.Println(dat)
  5930. } else {
  5931. fmt.Println(err)
  5932. }
  5933. var empty ResultFourteen
  5934. userJSONBytes, _ := json.Marshal(dat)
  5935. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5936. utils.ErrorLog("解析失败:%v", err)
  5937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5938. return
  5939. }
  5940. if empty.Infcode == 0 {
  5941. c.ServeSuccessJSON(map[string]interface{}{
  5942. "msg": "确认成功",
  5943. })
  5944. return
  5945. }
  5946. }
  5947. }
  5948. // 对账权限查询
  5949. func (c *HisApiController) Get3260() {
  5950. admin_user_id, _ := c.GetInt64("admin_user_id")
  5951. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5952. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5953. var api string
  5954. var res models.JSResult3260
  5955. if miConfig.MdtrtareaAdmvs == "320921" {
  5956. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5957. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5958. } else {
  5959. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5960. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5961. }
  5962. resp, requestErr := http.Get(api)
  5963. if requestErr != nil {
  5964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5965. return
  5966. }
  5967. body, ioErr := ioutil.ReadAll(resp.Body)
  5968. if ioErr != nil {
  5969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5971. return
  5972. }
  5973. var respJSON map[string]interface{}
  5974. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5977. return
  5978. }
  5979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5980. result, _ := json.Marshal(respJSON)
  5981. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5982. utils.ErrorLog("解析失败:%v", err)
  5983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5984. return
  5985. }
  5986. if res.Infcode == "0" {
  5987. c.ServeSuccessJSON(map[string]interface{}{
  5988. "result": res.Output.Data,
  5989. })
  5990. } else {
  5991. c.ServeSuccessJSON(map[string]interface{}{
  5992. "failed_code": -10,
  5993. "msg": res.ErrMsg,
  5994. })
  5995. return
  5996. }
  5997. }
  5998. func (c *HisApiController) Get3261() {
  5999. admin_user_id, _ := c.GetInt64("admin_user_id")
  6000. //month := c.GetString("month")
  6001. startTime := c.GetString("start_time")
  6002. //endTime, _ := c.GetString("end_time")
  6003. times := strings.Split(startTime, "-")
  6004. stmt_mon := times[0] + times[1]
  6005. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6006. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6007. var api string
  6008. var res models.JSResult3261
  6009. //var res10265 Result5301For10265
  6010. if miConfig.MdtrtareaAdmvs == "320921" {
  6011. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6012. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6013. } else {
  6014. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6015. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6016. }
  6017. resp, requestErr := http.Get(api)
  6018. if requestErr != nil {
  6019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6020. return
  6021. }
  6022. body, ioErr := ioutil.ReadAll(resp.Body)
  6023. if ioErr != nil {
  6024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6026. return
  6027. }
  6028. var respJSON map[string]interface{}
  6029. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6032. return
  6033. }
  6034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6035. result, _ := json.Marshal(respJSON)
  6036. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6037. utils.ErrorLog("解析失败:%v", err)
  6038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6039. return
  6040. }
  6041. if res.Infcode == "0" {
  6042. c.ServeSuccessJSON(map[string]interface{}{
  6043. "result": res.Output,
  6044. })
  6045. } else {
  6046. c.ServeSuccessJSON(map[string]interface{}{
  6047. "failed_code": -10,
  6048. "msg": res.ErrMsg,
  6049. })
  6050. return
  6051. }
  6052. }
  6053. type TempFun struct {
  6054. FundKey string
  6055. FundCode string
  6056. }
  6057. func (c *HisApiController) Get3262() {
  6058. admin_user_id, _ := c.GetInt64("admin_user_id")
  6059. startTime := c.GetString("start_time")
  6060. endTime := c.GetString("end_time")
  6061. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6062. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6063. //timeLayout := "2006-01-02"
  6064. //loc, _ := time.LoadLocation("Local")
  6065. //var theStartTIme int64
  6066. //if len(startTime) > 0 {
  6067. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6068. // if err != nil {
  6069. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6070. // return
  6071. // }
  6072. // theStartTIme = theTime.Unix()
  6073. //}
  6074. //var theEndtTIme int64
  6075. //if len(endTime) > 0 {
  6076. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6077. // if err != nil {
  6078. // utils.ErrorLog(err.Error())
  6079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6080. // return
  6081. // }
  6082. // theEndtTIme = theTime.Unix()
  6083. //}
  6084. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6085. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6086. for _, team := range datas {
  6087. fmt.Println(team.PsnTime)
  6088. for _, team_two := range datas_two {
  6089. fmt.Println(team_two.PsnTime)
  6090. if team.FundKey == team_two.FundKey {
  6091. fmt.Println(team_two.PsnTime)
  6092. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6093. fmt.Println(team.PsnTime)
  6094. }
  6095. }
  6096. }
  6097. fmt.Println("1111")
  6098. fmt.Println(datas)
  6099. fmt.Println("1111")
  6100. var twos []models.FixMonRecDetailFileInTwo
  6101. for _, team := range datas {
  6102. var two models.FixMonRecDetailFileInTwo
  6103. two.MedType = team.MedType
  6104. two.Insutype = team.Insutype
  6105. two.PsnType = team.PsnType
  6106. two.MedType = team.MedType
  6107. two.FixBlngAdmdvs = "999999"
  6108. two.InsuAdmdvs = "555555"
  6109. two.PsnTime = team.PsnTime
  6110. two.PsnCnt = team.PsnCnt
  6111. two.FundKey = team.FundKey
  6112. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6113. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6114. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6115. two.MedfeeSumAmt = ms
  6116. two.InscpAmt = ia
  6117. two.FundPaySumAmt = fps
  6118. twos = append(twos, two)
  6119. }
  6120. //startTime := c.GetString("start_time")
  6121. //endTime, _ := c.GetString("end_time")
  6122. times := strings.Split(startTime, "-")
  6123. stmt_mon := times[0] + times[1]
  6124. var funs []models.FundDetail
  6125. for _, item := range datas {
  6126. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6127. funs = append(funs, fun...)
  6128. }
  6129. var funInfos []models.Fund
  6130. //for _, item := range funs {
  6131. // var rf []models.FundInfo
  6132. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6133. // for _, subitem := range rf {
  6134. // var fund models.Fund
  6135. // fund.FundCode = subitem.FundPayType
  6136. // fund.FundName = subitem.FundPayTypeName
  6137. // fund.FundAmt = subitem.FundPayAmt
  6138. // fund.FundKey = item.FundKey
  6139. // fund.InsuAdmdvs = "555555"
  6140. // fund.FixBlngAdmdvs = "999999"
  6141. // funInfos = append(funInfos, fund)
  6142. // }
  6143. //}
  6144. var tempFuns []TempFun
  6145. for _, funInfo := range funInfos {
  6146. var tempFun TempFun
  6147. tempFun.FundKey = funInfo.FundKey
  6148. tempFun.FundCode = funInfo.FundCode
  6149. tempFuns = append(tempFuns, tempFun)
  6150. }
  6151. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6152. fmt.Println(tempFuns)
  6153. var funInfosTwo []models.Fund
  6154. decimal.DivisionPrecision = 2
  6155. for _, item := range tempFuns {
  6156. var fund models.Fund
  6157. for _, subItem := range funInfos {
  6158. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6159. fund.FundKey = subItem.FundKey
  6160. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6161. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6162. fund.FundName = subItem.FundName
  6163. fund.FundCode = subItem.FundCode
  6164. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6165. }
  6166. }
  6167. funInfosTwo = append(funInfosTwo, fund)
  6168. }
  6169. fmt.Println("funInfosTwo")
  6170. fmt.Println(funInfosTwo)
  6171. var upld_btch string
  6172. var empty models.JSResultEmpty
  6173. data := make(map[string]interface{})
  6174. data["org_name"] = miConfig.OrgName
  6175. data["doctor"] = curRoles.UserName
  6176. data["doctor_name"] = curRoles.UserName
  6177. data["fixmedins_code"] = miConfig.Code
  6178. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6179. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6180. data["secret_key"] = miConfig.SecretKey
  6181. data["url"] = miConfig.Url
  6182. data["ak"] = miConfig.AccessKey
  6183. data["cainfo"] = miConfig.Cainfo
  6184. data["datas"] = twos
  6185. data["fund"] = funInfosTwo
  6186. fmt.Println(twos)
  6187. month := time.Unix(1557042972, 0).Format("1")
  6188. year := time.Now().Format("2006")
  6189. month = time.Now().Format("01")
  6190. day := time.Now().Format("02")
  6191. hour := time.Now().Format("15")
  6192. min := time.Now().Format("04")
  6193. sec := time.Now().Format("05")
  6194. fix_fill_date := year + month + day + hour + min + sec
  6195. data["fix_fill_dept"] = miConfig.OrgName
  6196. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6197. data["fix_fill_psn"] = curRoles.UserName
  6198. data["fix_fill_date"] = fix_fill_date
  6199. data["stmt_loc"] = "2"
  6200. data["setl_mon"] = stmt_mon
  6201. upld_btch = "0"
  6202. data["upld_btch"] = upld_btch
  6203. //fmt.Println(data)
  6204. client := &http.Client{}
  6205. bytesData, _ := json.Marshal(data)
  6206. var req *http.Request
  6207. if miConfig.MdtrtareaAdmvs == "320921" {
  6208. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6209. } else {
  6210. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6211. }
  6212. resp, _ := client.Do(req)
  6213. defer resp.Body.Close()
  6214. body, ioErr := ioutil.ReadAll(resp.Body)
  6215. if ioErr != nil {
  6216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6218. }
  6219. var respJSON map[string]interface{}
  6220. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6223. }
  6224. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6225. //fmt.Println(respJSON)
  6226. result, _ := json.Marshal(respJSON)
  6227. //fmt.Println(result)
  6228. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6229. utils.ErrorLog("解析失败:%v", err)
  6230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6231. }
  6232. if empty.Infcode != "0" {
  6233. c.ServeSuccessJSON(map[string]interface{}{
  6234. "failed_code": -10,
  6235. "msg": empty.ErrMsg,
  6236. })
  6237. return
  6238. } else {
  6239. c.ServeSuccessJSON(map[string]interface{}{
  6240. "msg": "上传成功",
  6241. })
  6242. return
  6243. }
  6244. }
  6245. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6246. newArr = make([]TempFun, 0)
  6247. for i := 0; i < len(arr); i++ {
  6248. repeat := false
  6249. for j := i + 1; j < len(arr); j++ {
  6250. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6251. repeat = true
  6252. break
  6253. }
  6254. }
  6255. if !repeat {
  6256. newArr = append(newArr, arr[i])
  6257. }
  6258. }
  6259. return
  6260. }
  6261. func (c *HisApiController) Get3263() {
  6262. admin_user_id, _ := c.GetInt64("admin_user_id")
  6263. startTime := c.GetString("start_time")
  6264. //endTime, _ := c.GetString("end_time")
  6265. times := strings.Split(startTime, "-")
  6266. setl_mon := times[0] + times[1]
  6267. upld_btch := "0"
  6268. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6269. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6270. var result3263 models.JSResult3263
  6271. data := make(map[string]interface{})
  6272. data["org_name"] = miConfig.OrgName
  6273. data["doctor"] = curRoles.UserName
  6274. data["doctor_name"] = curRoles.UserName
  6275. data["fixmedins_code"] = miConfig.Code
  6276. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6277. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6278. data["secret_key"] = miConfig.SecretKey
  6279. data["url"] = miConfig.Url
  6280. data["ak"] = miConfig.AccessKey
  6281. data["cainfo"] = miConfig.Cainfo
  6282. data["setl_mon"] = setl_mon
  6283. data["stmt_loc"] = "2"
  6284. data["upld_btch"] = upld_btch
  6285. client := &http.Client{}
  6286. bytesData, _ := json.Marshal(data)
  6287. var req *http.Request
  6288. if miConfig.MdtrtareaAdmvs == "320921" {
  6289. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6290. } else {
  6291. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6292. }
  6293. resp, _ := client.Do(req)
  6294. defer resp.Body.Close()
  6295. body, ioErr := ioutil.ReadAll(resp.Body)
  6296. if ioErr != nil {
  6297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6299. }
  6300. var respJSON map[string]interface{}
  6301. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6304. }
  6305. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6306. fmt.Println(respJSON)
  6307. result, _ := json.Marshal(respJSON)
  6308. fmt.Println(result)
  6309. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6310. utils.ErrorLog("解析失败:%v", err)
  6311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6312. }
  6313. if result3263.Infcode != "0" {
  6314. c.ServeSuccessJSON(map[string]interface{}{
  6315. "failed_code": -10,
  6316. "msg": result3263.ErrMsg,
  6317. })
  6318. return
  6319. } else {
  6320. c.ServeSuccessJSON(map[string]interface{}{
  6321. "list": result3263.Output,
  6322. })
  6323. return
  6324. }
  6325. }
  6326. func (c *HisApiController) Get3264() {
  6327. admin_user_id, _ := c.GetInt64("admin_user_id")
  6328. startTime := c.GetString("start_time")
  6329. //endTime, _ := c.GetString("end_time")
  6330. times := strings.Split(startTime, "-")
  6331. setl_mon := times[0] + times[1]
  6332. upld_btch := "0"
  6333. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6334. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6335. //solidify_id := []
  6336. var result3263 models.JSResult3263
  6337. data := make(map[string]interface{})
  6338. data["org_name"] = miConfig.OrgName
  6339. data["doctor"] = curRoles.UserName
  6340. data["doctor_name"] = curRoles.UserName
  6341. data["fixmedins_code"] = miConfig.Code
  6342. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6343. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6344. data["secret_key"] = miConfig.SecretKey
  6345. data["url"] = miConfig.Url
  6346. data["ak"] = miConfig.AccessKey
  6347. data["cainfo"] = miConfig.Cainfo
  6348. data["setl_mon"] = setl_mon
  6349. data["stmt_loc"] = "2"
  6350. data["upld_btch"] = upld_btch
  6351. client := &http.Client{}
  6352. bytesData, _ := json.Marshal(data)
  6353. var req3263 *http.Request
  6354. if miConfig.MdtrtareaAdmvs == "320921" {
  6355. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6356. } else {
  6357. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6358. }
  6359. resp, _ := client.Do(req3263)
  6360. defer resp.Body.Close()
  6361. body, ioErr := ioutil.ReadAll(resp.Body)
  6362. if ioErr != nil {
  6363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6365. }
  6366. var respJSON3263 map[string]interface{}
  6367. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6370. }
  6371. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6372. fmt.Println(respJSON3263)
  6373. result, _ := json.Marshal(respJSON3263)
  6374. fmt.Println(result)
  6375. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6376. utils.ErrorLog("解析失败:%v", err)
  6377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6378. }
  6379. var ids []string
  6380. for _, item := range result3263.Output {
  6381. ids = append(ids, item.SolidifyID)
  6382. }
  6383. var empty models.JSResultEmpty
  6384. data2 := make(map[string]interface{})
  6385. data2["org_name"] = miConfig.OrgName
  6386. data2["doctor"] = curRoles.UserName
  6387. data2["doctor_name"] = curRoles.UserName
  6388. data2["fixmedins_code"] = miConfig.Code
  6389. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6390. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6391. data2["secret_key"] = miConfig.SecretKey
  6392. data2["url"] = miConfig.Url
  6393. data2["ak"] = miConfig.AccessKey
  6394. data2["cainfo"] = miConfig.Cainfo
  6395. data2["setl_mon"] = setl_mon
  6396. data2["stmt_loc"] = "2"
  6397. data2["upld_btch"] = upld_btch
  6398. data2["solidify_id"] = ids
  6399. client2 := &http.Client{}
  6400. bytesData2, _ := json.Marshal(data2)
  6401. var req *http.Request
  6402. if miConfig.MdtrtareaAdmvs == "320921" {
  6403. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6404. } else {
  6405. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6406. }
  6407. resp2, _ := client2.Do(req)
  6408. defer resp.Body.Close()
  6409. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6410. if ioErr2 != nil {
  6411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6413. }
  6414. var respJSON map[string]interface{}
  6415. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6418. }
  6419. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6420. fmt.Println(respJSON)
  6421. result2, _ := json.Marshal(respJSON)
  6422. fmt.Println(result2)
  6423. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6424. utils.ErrorLog("解析失败:%v", err)
  6425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6426. }
  6427. if empty.Infcode != "0" {
  6428. c.ServeSuccessJSON(map[string]interface{}{
  6429. "failed_code": -10,
  6430. "msg": empty.ErrMsg,
  6431. })
  6432. return
  6433. } else {
  6434. c.ServeSuccessJSON(map[string]interface{}{
  6435. "msg": "",
  6436. })
  6437. return
  6438. }
  6439. }
  6440. func (c *HisApiController) Get3265() {
  6441. admin_user_id, _ := c.GetInt64("admin_user_id")
  6442. startTime := c.GetString("start_time")
  6443. //endTime, _ := c.GetString("end_time")
  6444. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6445. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6446. times := strings.Split(startTime, "-")
  6447. setl_mon := times[0] + times[1]
  6448. var upld_btch string
  6449. upld_btch = "0"
  6450. //var empty models.JSResultEmpty
  6451. var result3265 models.JSResult3264
  6452. var result3263 models.JSResult3263
  6453. data2 := make(map[string]interface{})
  6454. data2["org_name"] = miConfig.OrgName
  6455. data2["doctor"] = curRoles.UserName
  6456. data2["doctor_name"] = curRoles.UserName
  6457. data2["fixmedins_code"] = miConfig.Code
  6458. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6459. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6460. data2["secret_key"] = miConfig.SecretKey
  6461. data2["url"] = miConfig.Url
  6462. data2["ak"] = miConfig.AccessKey
  6463. data2["cainfo"] = miConfig.Cainfo
  6464. data2["setl_mon"] = setl_mon
  6465. data2["stmt_loc"] = "2"
  6466. data2["upld_btch"] = upld_btch
  6467. client2 := &http.Client{}
  6468. bytesData2, _ := json.Marshal(data2)
  6469. var req3263 *http.Request
  6470. if miConfig.MdtrtareaAdmvs == "320921" {
  6471. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6472. } else {
  6473. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6474. }
  6475. resp2, _ := client2.Do(req3263)
  6476. defer resp2.Body.Close()
  6477. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6478. if ioErr2 != nil {
  6479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6481. }
  6482. var respJSON3263 map[string]interface{}
  6483. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6486. }
  6487. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6488. fmt.Println(respJSON3263)
  6489. result2, _ := json.Marshal(respJSON3263)
  6490. fmt.Println(result2)
  6491. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6492. utils.ErrorLog("解析失败:%v", err)
  6493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6494. }
  6495. var ids []string
  6496. for _, item := range result3263.Output {
  6497. ids = append(ids, item.SolidifyID)
  6498. }
  6499. data := make(map[string]interface{})
  6500. data["org_name"] = miConfig.OrgName
  6501. data["doctor"] = curRoles.UserName
  6502. data["doctor_name"] = curRoles.UserName
  6503. data["fixmedins_code"] = miConfig.Code
  6504. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6505. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6506. data["secret_key"] = miConfig.SecretKey
  6507. data["url"] = miConfig.Url
  6508. data["ak"] = miConfig.AccessKey
  6509. data["cainfo"] = miConfig.Cainfo
  6510. data["setl_mon"] = setl_mon
  6511. data["solidify_id"] = ids
  6512. month := time.Unix(1557042972, 0).Format("1")
  6513. year := time.Now().Format("2006")
  6514. month = time.Now().Format("01")
  6515. day := time.Now().Format("02")
  6516. hour := time.Now().Format("15")
  6517. min := time.Now().Format("04")
  6518. sec := time.Now().Format("05")
  6519. fix_fill_date := year + month + day + hour + min + sec
  6520. data["fix_fill_dept"] = miConfig.OrgName
  6521. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6522. data["fix_fill_psn"] = curRoles.UserName
  6523. data["fix_fill_date"] = fix_fill_date
  6524. data["stmt_loc"] = "2"
  6525. data["upld_btch"] = upld_btch
  6526. client := &http.Client{}
  6527. bytesData, _ := json.Marshal(data)
  6528. var req *http.Request
  6529. if miConfig.MdtrtareaAdmvs == "320921" {
  6530. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6531. } else {
  6532. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6533. }
  6534. resp, _ := client.Do(req)
  6535. defer resp.Body.Close()
  6536. body, ioErr := ioutil.ReadAll(resp.Body)
  6537. if ioErr != nil {
  6538. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6540. }
  6541. var respJSON map[string]interface{}
  6542. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6545. }
  6546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6547. fmt.Println(respJSON)
  6548. result, _ := json.Marshal(respJSON)
  6549. fmt.Println(result)
  6550. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6551. utils.ErrorLog("解析失败:%v", err)
  6552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6553. }
  6554. if result3265.Infcode != "0" {
  6555. c.ServeSuccessJSON(map[string]interface{}{
  6556. "failed_code": -10,
  6557. "msg": result3265.ErrMsg,
  6558. })
  6559. return
  6560. } else {
  6561. c.ServeSuccessJSON(map[string]interface{}{
  6562. "info": result3265.Output,
  6563. })
  6564. return
  6565. }
  6566. }
  6567. func (c *HisApiController) Get3266() {
  6568. admin_user_id, _ := c.GetInt64("admin_user_id")
  6569. startTime := c.GetString("start_time")
  6570. //endTime, _ := c.GetString("end_time")
  6571. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6572. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6573. times := strings.Split(startTime, "-")
  6574. stmt_mon := times[0] + times[1]
  6575. var upld_btch string
  6576. //var empty models.JSResultEmpty
  6577. var result3265 models.JSResult3264
  6578. data := make(map[string]interface{})
  6579. data["org_name"] = miConfig.OrgName
  6580. data["doctor"] = curRoles.UserName
  6581. data["doctor_name"] = curRoles.UserName
  6582. data["fixmedins_code"] = miConfig.Code
  6583. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6584. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6585. data["secret_key"] = miConfig.SecretKey
  6586. data["url"] = miConfig.Url
  6587. data["ak"] = miConfig.AccessKey
  6588. data["cainfo"] = miConfig.Cainfo
  6589. data["setl_mon"] = stmt_mon
  6590. month := time.Unix(1557042972, 0).Format("1")
  6591. year := time.Now().Format("2006")
  6592. month = time.Now().Format("01")
  6593. day := time.Now().Format("02")
  6594. hour := time.Now().Format("15")
  6595. min := time.Now().Format("04")
  6596. sec := time.Now().Format("05")
  6597. fix_fill_date := year + month + day + hour + min + sec
  6598. data["fix_fill_dept"] = miConfig.OrgName
  6599. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6600. data["fix_fill_psn"] = curRoles.UserName
  6601. data["fix_fill_date"] = fix_fill_date
  6602. data["stmt_loc"] = "2"
  6603. upld_btch = "0"
  6604. data["upld_btch"] = upld_btch
  6605. client := &http.Client{}
  6606. bytesData, _ := json.Marshal(data)
  6607. var req *http.Request
  6608. if miConfig.MdtrtareaAdmvs == "320921" {
  6609. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6610. } else {
  6611. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6612. }
  6613. resp, _ := client.Do(req)
  6614. defer resp.Body.Close()
  6615. body, ioErr := ioutil.ReadAll(resp.Body)
  6616. if ioErr != nil {
  6617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6619. }
  6620. var respJSON map[string]interface{}
  6621. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6624. }
  6625. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6626. fmt.Println(respJSON)
  6627. result, _ := json.Marshal(respJSON)
  6628. fmt.Println(result)
  6629. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6630. utils.ErrorLog("解析失败:%v", err)
  6631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6632. }
  6633. if result3265.Infcode != "0" {
  6634. c.ServeSuccessJSON(map[string]interface{}{
  6635. "failed_code": -10,
  6636. "msg": result3265.ErrMsg,
  6637. })
  6638. return
  6639. } else {
  6640. c.ServeSuccessJSON(map[string]interface{}{
  6641. "info": result3265.Output,
  6642. })
  6643. return
  6644. }
  6645. }
  6646. func (c *HisApiController) Get3267() {
  6647. admin_user_id, _ := c.GetInt64("admin_user_id")
  6648. startTime := c.GetString("start_time")
  6649. //endTime, _ := c.GetString("end_time")
  6650. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6651. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6652. times := strings.Split(startTime, "-")
  6653. setl_mon := times[0] + times[1]
  6654. var upld_btch string
  6655. //var empty models.JSResultEmpty
  6656. var result3265 models.JSResult3264
  6657. upld_btch = "0"
  6658. data := make(map[string]interface{})
  6659. data["org_name"] = miConfig.OrgName
  6660. data["doctor"] = curRoles.UserName
  6661. data["doctor_name"] = curRoles.UserName
  6662. data["fixmedins_code"] = miConfig.Code
  6663. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6664. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6665. data["secret_key"] = miConfig.SecretKey
  6666. data["url"] = miConfig.Url
  6667. data["ak"] = miConfig.AccessKey
  6668. data["cainfo"] = miConfig.Cainfo
  6669. data["setl_mon"] = setl_mon
  6670. data["stmt_loc"] = "2"
  6671. data["upld_btch"] = upld_btch
  6672. client := &http.Client{}
  6673. bytesData, _ := json.Marshal(data)
  6674. var req *http.Request
  6675. if miConfig.MdtrtareaAdmvs == "320921" {
  6676. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6677. } else {
  6678. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6679. }
  6680. resp, _ := client.Do(req)
  6681. defer resp.Body.Close()
  6682. body, ioErr := ioutil.ReadAll(resp.Body)
  6683. if ioErr != nil {
  6684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6686. }
  6687. var respJSON map[string]interface{}
  6688. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6691. }
  6692. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6693. fmt.Println(respJSON)
  6694. result, _ := json.Marshal(respJSON)
  6695. fmt.Println(result)
  6696. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6697. utils.ErrorLog("解析失败:%v", err)
  6698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6699. }
  6700. if result3265.Infcode != "0" {
  6701. c.ServeSuccessJSON(map[string]interface{}{
  6702. "failed_code": -10,
  6703. "msg": result3265.ErrMsg,
  6704. })
  6705. return
  6706. } else {
  6707. c.ServeSuccessJSON(map[string]interface{}{
  6708. "info": result3265.Output.Data,
  6709. })
  6710. return
  6711. }
  6712. }
  6713. func (c *HisApiController) Get3268() {
  6714. admin_user_id, _ := c.GetInt64("admin_user_id")
  6715. startTime := c.GetString("start_time")
  6716. endTime := c.GetString("end_time")
  6717. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6718. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6719. times := strings.Split(startTime, "-")
  6720. setl_mon := times[0] + times[1]
  6721. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6722. var twos []models.FixMonRecDetailFileInTwo
  6723. var funs []models.FundDetail
  6724. for _, item := range datas {
  6725. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6726. funs = append(funs, fun...)
  6727. }
  6728. var funInfos []models.Fund
  6729. //for _, item := range funs {
  6730. // var rf []models.FundInfo
  6731. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6732. // for _, subitem := range rf {
  6733. // var fund models.Fund
  6734. // fund.FundCode = subitem.FundPayType
  6735. // fund.FundName = subitem.FundPayTypeName
  6736. // fund.FundAmt = subitem.FundPayAmt
  6737. // fund.FundKey = item.FundKey
  6738. // fund.InsuAdmdvs = "555555"
  6739. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6740. // funInfos = append(funInfos, fund)
  6741. // }
  6742. //}
  6743. for _, team := range datas {
  6744. var two models.FixMonRecDetailFileInTwo
  6745. two.SetlDate = time.Now().Format("2006-01-02")
  6746. two.MedType = team.MedType
  6747. two.Insutype = team.Insutype
  6748. two.PsnType = team.PsnType
  6749. two.MedType = team.MedType
  6750. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6751. two.InsuAdmdvs = team.InsuAdmdvs
  6752. two.PsnTime = team.PsnTime
  6753. two.PsnCnt = team.PsnCnt
  6754. two.FundKey = team.FundKey
  6755. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6756. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6757. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6758. two.MedfeeSumAmt = ms
  6759. two.InscpAmt = ia
  6760. two.FundPaySumAmt = fps
  6761. twos = append(twos, two)
  6762. }
  6763. var upld_btch string
  6764. upld_btch = "0"
  6765. var empty models.JSResultEmpty
  6766. data := make(map[string]interface{})
  6767. data["org_name"] = miConfig.OrgName
  6768. data["doctor"] = curRoles.UserName
  6769. data["doctor_name"] = curRoles.UserName
  6770. data["fixmedins_code"] = miConfig.Code
  6771. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6772. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6773. data["secret_key"] = miConfig.SecretKey
  6774. data["url"] = miConfig.Url
  6775. data["ak"] = miConfig.AccessKey
  6776. data["cainfo"] = miConfig.Cainfo
  6777. data["datas"] = twos
  6778. data["fund"] = funInfos
  6779. data["setl_mon"] = setl_mon
  6780. month := time.Unix(1557042972, 0).Format("1")
  6781. year := time.Now().Format("2006")
  6782. month = time.Now().Format("01")
  6783. day := time.Now().Format("02")
  6784. hour := time.Now().Format("15")
  6785. min := time.Now().Format("04")
  6786. sec := time.Now().Format("05")
  6787. fix_fill_date := year + month + day + hour + min + sec
  6788. data["fix_fill_dept"] = miConfig.OrgName
  6789. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6790. data["fix_fill_psn"] = curRoles.UserName
  6791. data["fix_fill_date"] = fix_fill_date
  6792. data["stmt_loc"] = "2"
  6793. data["upld_btch"] = upld_btch
  6794. client := &http.Client{}
  6795. bytesData, _ := json.Marshal(data)
  6796. var req *http.Request
  6797. if miConfig.MdtrtareaAdmvs == "320921" {
  6798. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6799. } else {
  6800. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6801. }
  6802. resp, _ := client.Do(req)
  6803. defer resp.Body.Close()
  6804. body, ioErr := ioutil.ReadAll(resp.Body)
  6805. if ioErr != nil {
  6806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6808. }
  6809. var respJSON map[string]interface{}
  6810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6813. }
  6814. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6815. fmt.Println(respJSON)
  6816. result, _ := json.Marshal(respJSON)
  6817. fmt.Println(result)
  6818. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6819. utils.ErrorLog("解析失败:%v", err)
  6820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6821. }
  6822. if empty.Infcode != "0" {
  6823. c.ServeSuccessJSON(map[string]interface{}{
  6824. "failed_code": -10,
  6825. "msg": empty.ErrMsg,
  6826. })
  6827. return
  6828. } else {
  6829. c.ServeSuccessJSON(map[string]interface{}{
  6830. "msg": "上传成功",
  6831. })
  6832. return
  6833. }
  6834. }
  6835. func (c *HisApiController) Get3269() {
  6836. admin_user_id, _ := c.GetInt64("admin_user_id")
  6837. startTime := c.GetString("start_time")
  6838. //endTime, _ := c.GetString("end_time")
  6839. times := strings.Split(startTime, "-")
  6840. setl_mon := times[0] + times[1]
  6841. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6842. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6843. var result3263 models.JSResult3263
  6844. data := make(map[string]interface{})
  6845. data["org_name"] = miConfig.OrgName
  6846. data["doctor"] = curRoles.UserName
  6847. data["doctor_name"] = curRoles.UserName
  6848. data["fixmedins_code"] = miConfig.Code
  6849. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6850. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6851. data["secret_key"] = miConfig.SecretKey
  6852. data["url"] = miConfig.Url
  6853. data["ak"] = miConfig.AccessKey
  6854. data["cainfo"] = miConfig.Cainfo
  6855. data["setl_mon"] = setl_mon
  6856. data["stmt_loc"] = "2"
  6857. client := &http.Client{}
  6858. bytesData, _ := json.Marshal(data)
  6859. var req *http.Request
  6860. if miConfig.MdtrtareaAdmvs == "320921" {
  6861. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6862. } else {
  6863. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6864. }
  6865. resp, _ := client.Do(req)
  6866. defer resp.Body.Close()
  6867. body, ioErr := ioutil.ReadAll(resp.Body)
  6868. if ioErr != nil {
  6869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6871. }
  6872. var respJSON map[string]interface{}
  6873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6876. }
  6877. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6878. fmt.Println(respJSON)
  6879. result, _ := json.Marshal(respJSON)
  6880. fmt.Println(result)
  6881. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6882. utils.ErrorLog("解析失败:%v", err)
  6883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6884. }
  6885. if result3263.Infcode != "0" {
  6886. c.ServeSuccessJSON(map[string]interface{}{
  6887. "failed_code": -10,
  6888. "msg": result3263.ErrMsg,
  6889. })
  6890. return
  6891. } else {
  6892. c.ServeSuccessJSON(map[string]interface{}{
  6893. "msg": "上传成功",
  6894. })
  6895. return
  6896. }
  6897. }
  6898. func (c *HisApiController) Get3270() {
  6899. admin_user_id, _ := c.GetInt64("admin_user_id")
  6900. startTime := c.GetString("start_time")
  6901. //endTime, _ := c.GetString("end_time")
  6902. times := strings.Split(startTime, "-")
  6903. setl_mon := times[0] + times[1]
  6904. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6905. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6906. var result3263 models.JSResult3263
  6907. data2 := make(map[string]interface{})
  6908. data2["org_name"] = miConfig.OrgName
  6909. data2["doctor"] = curRoles.UserName
  6910. data2["doctor_name"] = curRoles.UserName
  6911. data2["fixmedins_code"] = miConfig.Code
  6912. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6913. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6914. data2["secret_key"] = miConfig.SecretKey
  6915. data2["url"] = miConfig.Url
  6916. data2["ak"] = miConfig.AccessKey
  6917. data2["cainfo"] = miConfig.Cainfo
  6918. data2["setl_mon"] = setl_mon
  6919. data2["stmt_loc"] = "2"
  6920. client2 := &http.Client{}
  6921. bytesData2, _ := json.Marshal(data2)
  6922. var req3263 *http.Request
  6923. if miConfig.MdtrtareaAdmvs == "320921" {
  6924. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6925. } else {
  6926. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6927. }
  6928. resp2, _ := client2.Do(req3263)
  6929. defer resp2.Body.Close()
  6930. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6931. if ioErr2 != nil {
  6932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6934. }
  6935. var respJSON3263 map[string]interface{}
  6936. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6939. }
  6940. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6941. fmt.Println(respJSON3263)
  6942. result2, _ := json.Marshal(respJSON3263)
  6943. fmt.Println(result2)
  6944. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6945. utils.ErrorLog("解析失败:%v", err)
  6946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6947. }
  6948. var ids []string
  6949. for _, item := range result3263.Output {
  6950. ids = append(ids, item.SolidifyID)
  6951. }
  6952. var result3264 models.JSResult3264
  6953. data := make(map[string]interface{})
  6954. data["org_name"] = miConfig.OrgName
  6955. data["doctor"] = curRoles.UserName
  6956. data["doctor_name"] = curRoles.UserName
  6957. data["fixmedins_code"] = miConfig.Code
  6958. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6959. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6960. data["secret_key"] = miConfig.SecretKey
  6961. data["url"] = miConfig.Url
  6962. data["ak"] = miConfig.AccessKey
  6963. data["cainfo"] = miConfig.Cainfo
  6964. data["setl_mon"] = setl_mon
  6965. data["stmt_loc"] = "2"
  6966. data["solidify_id"] = ids
  6967. client := &http.Client{}
  6968. bytesData, _ := json.Marshal(data)
  6969. var req *http.Request
  6970. if miConfig.MdtrtareaAdmvs == "320921" {
  6971. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6972. } else {
  6973. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6974. }
  6975. resp, _ := client.Do(req)
  6976. defer resp.Body.Close()
  6977. body, ioErr := ioutil.ReadAll(resp.Body)
  6978. if ioErr != nil {
  6979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6981. }
  6982. var respJSON map[string]interface{}
  6983. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6986. }
  6987. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6988. fmt.Println(respJSON)
  6989. result, _ := json.Marshal(respJSON)
  6990. fmt.Println(result)
  6991. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  6992. utils.ErrorLog("解析失败:%v", err)
  6993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6994. }
  6995. if result3264.Infcode != "0" {
  6996. c.ServeSuccessJSON(map[string]interface{}{
  6997. "failed_code": -10,
  6998. "msg": result3264.ErrMsg,
  6999. })
  7000. return
  7001. } else {
  7002. c.ServeSuccessJSON(map[string]interface{}{
  7003. "info": result3264.Output,
  7004. })
  7005. return
  7006. }
  7007. }
  7008. func (c *HisApiController) Get3271() {
  7009. admin_user_id, _ := c.GetInt64("admin_user_id")
  7010. startTime := c.GetString("start_time")
  7011. //endTime, _ := c.GetString("end_time")
  7012. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7013. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7014. times := strings.Split(startTime, "-")
  7015. setl_mon := times[0] + times[1]
  7016. //var empty models.JSResultEmpty
  7017. var result3265 models.JSResult3264
  7018. var result3263 models.JSResult3263
  7019. data2 := make(map[string]interface{})
  7020. data2["org_name"] = miConfig.OrgName
  7021. data2["doctor"] = curRoles.UserName
  7022. data2["doctor_name"] = curRoles.UserName
  7023. data2["fixmedins_code"] = miConfig.Code
  7024. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7025. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7026. data2["secret_key"] = miConfig.SecretKey
  7027. data2["url"] = miConfig.Url
  7028. data2["ak"] = miConfig.AccessKey
  7029. data2["cainfo"] = miConfig.Cainfo
  7030. data2["setl_mon"] = setl_mon
  7031. data2["stmt_loc"] = "2"
  7032. client2 := &http.Client{}
  7033. bytesData2, _ := json.Marshal(data2)
  7034. var req3263 *http.Request
  7035. if miConfig.MdtrtareaAdmvs == "320921" {
  7036. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7037. } else {
  7038. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7039. }
  7040. resp2, _ := client2.Do(req3263)
  7041. defer resp2.Body.Close()
  7042. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7043. if ioErr2 != nil {
  7044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7046. }
  7047. var respJSON3263 map[string]interface{}
  7048. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7051. }
  7052. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7053. fmt.Println(respJSON3263)
  7054. result2, _ := json.Marshal(respJSON3263)
  7055. fmt.Println(result2)
  7056. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7057. utils.ErrorLog("解析失败:%v", err)
  7058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7059. }
  7060. var ids []string
  7061. for _, item := range result3263.Output {
  7062. ids = append(ids, item.SolidifyID)
  7063. }
  7064. data := make(map[string]interface{})
  7065. data["org_name"] = miConfig.OrgName
  7066. data["doctor"] = curRoles.UserName
  7067. data["doctor_name"] = curRoles.UserName
  7068. data["fixmedins_code"] = miConfig.Code
  7069. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7070. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7071. data["secret_key"] = miConfig.SecretKey
  7072. data["url"] = miConfig.Url
  7073. data["ak"] = miConfig.AccessKey
  7074. data["cainfo"] = miConfig.Cainfo
  7075. data["setl_mon"] = setl_mon
  7076. data["solidify_id"] = ids
  7077. month := time.Unix(1557042972, 0).Format("1")
  7078. year := time.Now().Format("2006")
  7079. month = time.Now().Format("01")
  7080. day := time.Now().Format("02")
  7081. hour := time.Now().Format("15")
  7082. min := time.Now().Format("04")
  7083. sec := time.Now().Format("05")
  7084. fix_fill_date := year + month + day + hour + min + sec
  7085. data["fix_fill_dept"] = miConfig.OrgName
  7086. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7087. data["fix_fill_psn"] = curRoles.UserName
  7088. data["fix_fill_date"] = fix_fill_date
  7089. data["stmt_loc"] = "2"
  7090. client := &http.Client{}
  7091. bytesData, _ := json.Marshal(data)
  7092. var req *http.Request
  7093. if miConfig.MdtrtareaAdmvs == "320921" {
  7094. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7095. } else {
  7096. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7097. }
  7098. resp, _ := client.Do(req)
  7099. defer resp.Body.Close()
  7100. body, ioErr := ioutil.ReadAll(resp.Body)
  7101. if ioErr != nil {
  7102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7104. }
  7105. var respJSON map[string]interface{}
  7106. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7109. }
  7110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7111. fmt.Println(respJSON)
  7112. result, _ := json.Marshal(respJSON)
  7113. fmt.Println(result)
  7114. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7115. utils.ErrorLog("解析失败:%v", err)
  7116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7117. }
  7118. if result3265.Infcode != "0" {
  7119. c.ServeSuccessJSON(map[string]interface{}{
  7120. "failed_code": -10,
  7121. "msg": result3265.ErrMsg,
  7122. })
  7123. return
  7124. } else {
  7125. c.ServeSuccessJSON(map[string]interface{}{
  7126. "info": result3265.Output.Data,
  7127. })
  7128. return
  7129. }
  7130. }
  7131. func (c *HisApiController) Get3272() {
  7132. admin_user_id, _ := c.GetInt64("admin_user_id")
  7133. startTime := c.GetString("start_time")
  7134. //endTime, _ := c.GetString("end_time")
  7135. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7136. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7137. times := strings.Split(startTime, "-")
  7138. setl_mon := times[0] + times[1]
  7139. var upld_btch string
  7140. //var empty models.JSResultEmpty
  7141. var result3265 models.JSResult3264
  7142. data := make(map[string]interface{})
  7143. data["org_name"] = miConfig.OrgName
  7144. data["doctor"] = curRoles.UserName
  7145. data["doctor_name"] = curRoles.UserName
  7146. data["fixmedins_code"] = miConfig.Code
  7147. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7148. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7149. data["secret_key"] = miConfig.SecretKey
  7150. data["url"] = miConfig.Url
  7151. data["ak"] = miConfig.AccessKey
  7152. data["cainfo"] = miConfig.Cainfo
  7153. data["setl_mon"] = setl_mon
  7154. month := time.Unix(1557042972, 0).Format("1")
  7155. year := time.Now().Format("2006")
  7156. month = time.Now().Format("01")
  7157. day := time.Now().Format("02")
  7158. hour := time.Now().Format("15")
  7159. min := time.Now().Format("04")
  7160. sec := time.Now().Format("05")
  7161. fix_fill_date := year + month + day + hour + min + sec
  7162. data["fix_fill_dept"] = miConfig.OrgName
  7163. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7164. data["fix_fill_psn"] = curRoles.UserName
  7165. data["fix_fill_date"] = fix_fill_date
  7166. data["stmt_loc"] = "2"
  7167. data["upld_btch"] = upld_btch
  7168. client := &http.Client{}
  7169. bytesData, _ := json.Marshal(data)
  7170. var req *http.Request
  7171. if miConfig.MdtrtareaAdmvs == "320921" {
  7172. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7173. } else {
  7174. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7175. }
  7176. resp, _ := client.Do(req)
  7177. defer resp.Body.Close()
  7178. body, ioErr := ioutil.ReadAll(resp.Body)
  7179. if ioErr != nil {
  7180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7182. }
  7183. var respJSON map[string]interface{}
  7184. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7187. }
  7188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7189. fmt.Println(respJSON)
  7190. result, _ := json.Marshal(respJSON)
  7191. fmt.Println(result)
  7192. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7193. utils.ErrorLog("解析失败:%v", err)
  7194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7195. }
  7196. if result3265.Infcode != "0" {
  7197. c.ServeSuccessJSON(map[string]interface{}{
  7198. "failed_code": -10,
  7199. "msg": result3265.ErrMsg,
  7200. })
  7201. return
  7202. } else {
  7203. c.ServeSuccessJSON(map[string]interface{}{
  7204. "info": result3265.Output,
  7205. })
  7206. return
  7207. }
  7208. }
  7209. func (c *HisApiController) Get3273() {
  7210. admin_user_id, _ := c.GetInt64("admin_user_id")
  7211. startTime := c.GetString("start_time")
  7212. //endTime, _ := c.GetString("end_time")
  7213. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7214. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7215. times := strings.Split(startTime, "-")
  7216. setl_mon := times[0] + times[1]
  7217. var result3265 models.JSResult3264
  7218. data := make(map[string]interface{})
  7219. data["org_name"] = miConfig.OrgName
  7220. data["doctor"] = curRoles.UserName
  7221. data["doctor_name"] = curRoles.UserName
  7222. data["fixmedins_code"] = miConfig.Code
  7223. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7224. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7225. data["secret_key"] = miConfig.SecretKey
  7226. data["url"] = miConfig.Url
  7227. data["ak"] = miConfig.AccessKey
  7228. data["cainfo"] = miConfig.Cainfo
  7229. data["setl_mon"] = setl_mon
  7230. data["stmt_loc"] = "2"
  7231. client := &http.Client{}
  7232. bytesData, _ := json.Marshal(data)
  7233. var req *http.Request
  7234. if miConfig.MdtrtareaAdmvs == "320921" {
  7235. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7236. } else {
  7237. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7238. }
  7239. resp, _ := client.Do(req)
  7240. defer resp.Body.Close()
  7241. body, ioErr := ioutil.ReadAll(resp.Body)
  7242. if ioErr != nil {
  7243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7245. }
  7246. var respJSON map[string]interface{}
  7247. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7250. }
  7251. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7252. fmt.Println(respJSON)
  7253. result, _ := json.Marshal(respJSON)
  7254. fmt.Println(result)
  7255. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7256. utils.ErrorLog("解析失败:%v", err)
  7257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7258. }
  7259. if result3265.Infcode != "0" {
  7260. c.ServeSuccessJSON(map[string]interface{}{
  7261. "failed_code": -10,
  7262. "msg": result3265.ErrMsg,
  7263. })
  7264. return
  7265. } else {
  7266. c.ServeSuccessJSON(map[string]interface{}{
  7267. "info": result3265.Output.Data,
  7268. })
  7269. return
  7270. }
  7271. }
  7272. func (c *HisApiController) Get3274() {
  7273. //if miConfig.MdtrtareaAdmvs == "320921" {
  7274. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7275. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7276. // "&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
  7277. //
  7278. //} else {
  7279. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7280. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7281. // "&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
  7282. //
  7283. //}
  7284. }
  7285. func (c *HisApiController) Get3275() {
  7286. //if miConfig.MdtrtareaAdmvs == "320921" {
  7287. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7288. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7289. // "&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
  7290. //
  7291. //} else {
  7292. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7293. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7294. // "&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
  7295. //
  7296. //}
  7297. }
  7298. func (c *HisApiController) Get3276() {
  7299. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7300. //month := c.GetString("month")
  7301. //
  7302. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7303. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7304. //var api string
  7305. //var res Result5301
  7306. //
  7307. //if miConfig.MdtrtareaAdmvs == "320921" {
  7308. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7309. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7310. //} else {
  7311. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7312. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7313. //}
  7314. //
  7315. //resp, requestErr := http.Get(api)
  7316. //if requestErr != nil {
  7317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7318. // return
  7319. //}
  7320. //
  7321. //body, ioErr := ioutil.ReadAll(resp.Body)
  7322. //if ioErr != nil {
  7323. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7325. // return
  7326. //}
  7327. //var respJSON map[string]interface{}
  7328. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7329. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7331. // return
  7332. //}
  7333. //
  7334. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7335. //result, _ := json.Marshal(respJSON)
  7336. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7337. // utils.ErrorLog("解析失败:%v", err)
  7338. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7339. // return
  7340. //}
  7341. }
  7342. func (c *HisApiController) Get3277() {
  7343. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7344. //month := c.GetString("month")
  7345. //
  7346. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7347. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7348. //var api string
  7349. //var res Result5301
  7350. //
  7351. //if miConfig.MdtrtareaAdmvs == "320921" {
  7352. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7353. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7354. //} else {
  7355. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7356. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7357. //}
  7358. //
  7359. //resp, requestErr := http.Get(api)
  7360. //if requestErr != nil {
  7361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7362. // return
  7363. //}
  7364. //
  7365. //body, ioErr := ioutil.ReadAll(resp.Body)
  7366. //if ioErr != nil {
  7367. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7369. // return
  7370. //}
  7371. //var respJSON map[string]interface{}
  7372. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7373. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7374. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7375. // return
  7376. //}
  7377. //
  7378. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7379. //result, _ := json.Marshal(respJSON)
  7380. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7381. // utils.ErrorLog("解析失败:%v", err)
  7382. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7383. // return
  7384. //}
  7385. }
  7386. func (c *HisApiController) GetCFYLJG001() {
  7387. admin_user_id, _ := c.GetInt64("admin_user_id")
  7388. patient_id, _ := c.GetInt64("patient_id")
  7389. his_patient_id, _ := c.GetInt64("his_patient_id")
  7390. record_time := c.GetString("record_time")
  7391. admin_user_id = 3626
  7392. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7393. psn, _ := service.GetPsnByPatientId(patient_id)
  7394. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7395. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7396. var cFYLJG001 models.CFYLJG001
  7397. timeLayout := "2006-01-02"
  7398. loc, _ := time.LoadLocation("Local")
  7399. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7400. if err != nil {
  7401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7402. return
  7403. }
  7404. recordDateTime := theTime.Unix()
  7405. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7406. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7407. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7408. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7409. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7410. for _, item := range prescriptions {
  7411. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7412. if his.IdCardType == 1 {
  7413. bas := strings.Split(psn.CardInfo, "|")
  7414. basNumber := bas[1]
  7415. fmt.Println(basNumber)
  7416. card_sn := bas[3]
  7417. card_no := bas[2]
  7418. cFYLJG001.MdtrtCertType = "03"
  7419. cFYLJG001.CardSn = card_sn
  7420. cFYLJG001.MdtrtCertNo = card_no
  7421. cFYLJG001.EcToken = ""
  7422. cFYLJG001.AuthNo = ""
  7423. } else if his.IdCardType == 2 {
  7424. cFYLJG001.MdtrtCertType = "02"
  7425. cFYLJG001.CardSn = ""
  7426. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7427. cFYLJG001.EcToken = ""
  7428. cFYLJG001.AuthNo = ""
  7429. } else if his.IdCardType == 4 {
  7430. cFYLJG001.MdtrtCertType = "01"
  7431. cFYLJG001.CardSn = ""
  7432. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7433. cFYLJG001.EcToken = psn.VerifyNumber
  7434. cFYLJG001.AuthNo = ""
  7435. }
  7436. cFYLJG001.BizTypeCode = "01"
  7437. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7438. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7439. cFYLJG001.RxTypeCode = "1"
  7440. tempTime := time.Unix(item.PreTime, 0)
  7441. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7442. cFYLJG001.PrscTime = timeFormatOne
  7443. var count float64
  7444. if item.Type == 1 {
  7445. for _, sumItem := range item.HisDoctorAdviceInfo {
  7446. count = count + sumItem.PrescribingNumber
  7447. }
  7448. }
  7449. cFYLJG001.RxDrugCnt = count
  7450. cFYLJG001.ValiDays = "5"
  7451. ts := time.Unix(item.PreTime, 0)
  7452. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7453. tempTime3 := time.Unix(record_time2, 0)
  7454. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7455. cFYLJG001.ValiEndTime = timeFormat3
  7456. cFYLJG001.RxCotnFlag = "0"
  7457. for _, subItem := range item.HisDoctorAdviceInfo {
  7458. var drug models.RxDrug
  7459. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7460. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7461. drug.RxItemTypeCode = "11"
  7462. drug.DrugDosform = "乳膏剂" //TODO
  7463. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7464. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7465. }
  7466. drug.MedcWayDscr = subItem.DeliveryWay
  7467. tempTime2 := time.Unix(subItem.StartTime, 0)
  7468. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7469. drug.MedcBegntime = timeFormatTwo
  7470. if subItem.Day > 0 {
  7471. ts := time.Unix(subItem.StartTime, 0)
  7472. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7473. tempTime4 := time.Unix(record_time, 0)
  7474. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7475. drug.MedcEndtime = timeFormat5
  7476. } else {
  7477. tempTime2 := time.Unix(subItem.StartTime, 0)
  7478. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7479. drug.MedcEndtime = timeFormatTwo
  7480. }
  7481. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7482. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7483. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7484. drug.DrugCnt = subItem.PrescribingNumber
  7485. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7486. drug.DrugGenname = subItem.AdviceName
  7487. drug.MedcWayCodg = subItem.DeliveryWay
  7488. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7489. drug.SinDoscnt = subItem.SingleDose
  7490. drug.SinDosunt = subItem.SingleDoseUnit
  7491. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7492. drug.UsedFrquName = subItem.ExecutionFrequency
  7493. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7494. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7495. drug.HospApprFlag = "1"
  7496. cFYLJG001.List = append(cFYLJG001.List, drug)
  7497. }
  7498. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7499. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7500. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7501. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7502. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7503. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7504. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7505. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7506. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7507. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7508. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7509. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7510. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7511. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7512. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7513. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7514. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7515. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7516. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7517. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7518. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7519. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7520. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7521. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7522. tempTime2 := time.Now().Unix()
  7523. tempTime6 := time.Unix(tempTime2, 0)
  7524. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7525. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7526. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7527. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7528. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7529. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7530. //memo := make(map[string]interface{})
  7531. //inputData := make(map[string]interface{}, 0)
  7532. //type MyData struct {
  7533. // Insutype string `json:"insutype"`
  7534. //}
  7535. //
  7536. // data := MyData{
  7537. // Insutype: his.Insutype,
  7538. //}
  7539. //
  7540. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7541. var config []*models.HisXtDiagnoseConfig
  7542. for _, item := range diagnosis_ids {
  7543. id, _ := strconv.ParseInt(item, 10, 64)
  7544. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7545. config = append(config, &diagnosisConfig)
  7546. }
  7547. for index, subitem := range config {
  7548. if index == 0 {
  7549. var dia models.DiseInfo
  7550. dia.DiagType = "1"
  7551. dia.MaindiagFlag = "1"
  7552. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7553. dia.DiagCode = subitem.CountryCode
  7554. dia.DiagName = subitem.ClassName
  7555. dia.DiagDept = "肾内科"
  7556. dia.DiagDrNo = doctor.DoctorNumber
  7557. dia.DiagDrName = doctor.UserName
  7558. tempTime3 := time.Unix(item.PreTime, 0)
  7559. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7560. dia.DiagTime = timeFormatTwo
  7561. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7562. } else {
  7563. var dia models.DiseInfo
  7564. dia.DiagType = "1"
  7565. dia.MaindiagFlag = "0"
  7566. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7567. dia.DiagCode = subitem.CountryCode
  7568. dia.DiagName = subitem.ClassName
  7569. dia.DiagDept = "肾内科"
  7570. dia.DiagDrNo = doctor.DoctorNumber
  7571. dia.DiagDrName = doctor.UserName
  7572. tempTime3 := time.Unix(item.PreTime, 0)
  7573. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7574. dia.DiagTime = timeFormatTwo
  7575. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7576. }
  7577. }
  7578. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7579. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7580. var res ResultCFYLJG001
  7581. var respJSON2 map[string]interface{}
  7582. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7585. return
  7586. }
  7587. userJSONBytes2, _ := json.Marshal(respJSON2)
  7588. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7589. utils.ErrorLog("解析失败:%v", err)
  7590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7591. return
  7592. }
  7593. if res.Infcode == -1 {
  7594. c.ServeSuccessJSON(map[string]interface{}{
  7595. "failed_code": -10,
  7596. "msg": res.ErrMsg,
  7597. })
  7598. return
  7599. } else {
  7600. var flow models.HisPrescriptionFlow
  7601. flow.Ctime = time.Now().Unix()
  7602. flow.SignDigest = ""
  7603. flow.RxTraceCode = res.Output.RxTraceCode
  7604. flow.HiRxno = res.Output.HiRxno
  7605. flow.MID = his.Number
  7606. flow.Status = 1
  7607. flow.DCode = doctor_info.DoctorNumber
  7608. flow.OriginalRxFile = ""
  7609. flow.OriginalValue = ""
  7610. flow.SignCertDn = ""
  7611. flow.UserOrgId = 10454
  7612. flow.SignCertSn = ""
  7613. flow.Mtime = time.Now().Unix()
  7614. service.Createflow(&flow)
  7615. c.ServeSuccessJSON(map[string]interface{}{
  7616. "msg": "上传成功",
  7617. })
  7618. }
  7619. }
  7620. }
  7621. func (c *HisApiController) GetCFYLJG002() {
  7622. admin_user_id, _ := c.GetInt64("admin_user_id")
  7623. his_patient_id, _ := c.GetInt64("his_patient_id")
  7624. record_time := c.GetString("record_time")
  7625. admin_user_id = 3626
  7626. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7627. //id, _ := c.GetInt64("id")
  7628. admin_user_id = 3626
  7629. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7630. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7631. flow, _ := service.Getflowtwo(his.Number)
  7632. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7633. //record_time := c.GetString("record_time")
  7634. patient_id, _ := c.GetInt64("patient_id")
  7635. //patient_id = 23834
  7636. //record_time = "2023-09-18"
  7637. timeLayout := "2006-01-02"
  7638. loc, _ := time.LoadLocation("Local")
  7639. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7640. if err != nil {
  7641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7642. return
  7643. }
  7644. recordDateTime := theTime.Unix()
  7645. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7646. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7647. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7648. dept, _ := service.GetDepartMentDetail(info.Departments)
  7649. inputData := make(map[string]interface{})
  7650. inputData["rxTraceCode"] = flow.RxTraceCode
  7651. inputData["hiRxno"] = flow.HiRxno
  7652. inputData["mdtrtId"] = flow.MID
  7653. inputData["patnName"] = his.PsnName
  7654. inputData["psnCertType"] = his.PsnCertType
  7655. inputData["certno"] = his.Certno
  7656. inputData["fixmedinsName"] = miConfig.OrgName
  7657. inputData["fixmedinsCode"] = miConfig.Code
  7658. inputData["drCode"] = doctor_info.DoctorNumber
  7659. inputData["prscDrName"] = doctor_info.UserName
  7660. inputData["pharDeptName"] = dept.Name
  7661. inputData["pharDeptCode"] = dept.Number
  7662. inputData["pharProfttlCodg"] = dept.Name
  7663. inputData["pharProfttlName"] = ""
  7664. inputData["pharCode"] = "HY440309002107"
  7665. inputData["pharCertType"] = "01"
  7666. inputData["pharCertno"] = "430482199408260023"
  7667. inputData["pharName"] = "彭斯遥"
  7668. inputData["pharPracCertNo"] = ""
  7669. tempTime2 := time.Unix(info.Ctime, 0)
  7670. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7671. inputData["pharChkTime"] = timeFormatTwo
  7672. bytesData, _ := json.Marshal(inputData)
  7673. fmt.Println(string(bytesData))
  7674. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7675. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7676. if err != nil {
  7677. fmt.Println("Error reading PDF file:", err)
  7678. return
  7679. }
  7680. // 将 PDF 文件内容进行 Base64 编码
  7681. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7682. fmt.Println(err)
  7683. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7684. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7685. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7686. var res2 Result002
  7687. var respJSON2 map[string]interface{}
  7688. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7691. return
  7692. }
  7693. userJSONBytes2, _ := json.Marshal(respJSON2)
  7694. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7695. utils.ErrorLog("解析失败:%v", err)
  7696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7697. return
  7698. }
  7699. if res2.Infcode == 0 {
  7700. flow.Ctime = time.Now().Unix()
  7701. flow.SignDigest = res2.Output.SignDigest
  7702. flow.RxFile = res2.Output.RxFile
  7703. flow.MID = his.Number
  7704. flow.Status = 1
  7705. flow.DCode = doctor_info.DoctorNumber
  7706. flow.OriginalRxFile = rx_encoded
  7707. flow.OriginalValue = encoded
  7708. flow.SignCertDn = res2.Output.SignCertDn
  7709. flow.SignCertSn = res2.Output.SignCertSn
  7710. flow.Mtime = time.Now().Unix()
  7711. service.Saveflow(flow)
  7712. c.ServeSuccessJSON(map[string]interface{}{
  7713. "msg": "预签名成功",
  7714. })
  7715. } else {
  7716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7717. return
  7718. }
  7719. }
  7720. func (c *HisApiController) GetCFYLJG003() {
  7721. admin_user_id, _ := c.GetInt64("admin_user_id")
  7722. his_patient_id, _ := c.GetInt64("his_patient_id")
  7723. record_time := c.GetString("record_time")
  7724. admin_user_id = 3626
  7725. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7726. //id, _ := c.GetInt64("id")
  7727. admin_user_id = 3626
  7728. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7729. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7730. flow, _ := service.Getflowtwo(his.Number)
  7731. //id = 3
  7732. patient_id, _ := c.GetInt64("patient_id")
  7733. //patient_id = 23834
  7734. //record_time = "2023-09-18"
  7735. timeLayout := "2006-01-02"
  7736. loc, _ := time.LoadLocation("Local")
  7737. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7738. if err != nil {
  7739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7740. return
  7741. }
  7742. recordDateTime := theTime.Unix()
  7743. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7744. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7745. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7746. dept, _ := service.GetDepartMentDetail(info.Departments)
  7747. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7748. var cFYLJG003 models.CFYLJG003
  7749. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7750. cFYLJG003.HiRxno = flow.HiRxno
  7751. cFYLJG003.MdtrtID = flow.MID
  7752. cFYLJG003.PatnName = his.Name
  7753. cFYLJG003.Certno = his.Certno
  7754. cFYLJG003.FixmedinsName = miConfig.OrgName
  7755. cFYLJG003.FixmedinsCode = miConfig.Code
  7756. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7757. cFYLJG003.PrscDrName = doctor_info.UserName
  7758. cFYLJG003.PharDeptName = dept.Name
  7759. cFYLJG003.PharDeptCode = dept.Number
  7760. cFYLJG003.PharCode = "HY440309002107"
  7761. cFYLJG003.PharCertType = "01"
  7762. cFYLJG003.PharCertno = "430482199408260023"
  7763. cFYLJG003.PharName = "彭斯遥"
  7764. cFYLJG003.PsnCertType = "01"
  7765. cFYLJG003.RxFile = flow.RxFile
  7766. cFYLJG003.SignDigest = flow.SignDigest
  7767. cFYLJG003.FixmedinsCode = miConfig.Code
  7768. cFYLJG003.PsnCertType = "01"
  7769. cFYLJG003.PharProfttlCodg = dept.Name
  7770. //inputData["pharProfttlCodg"] =dept.Name
  7771. tempTime2 := time.Unix(info.Ctime, 0)
  7772. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7773. cFYLJG003.PharChkTime = timeFormatTwo
  7774. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7775. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7776. var res ResultCFYLJG003
  7777. var respJSON2 map[string]interface{}
  7778. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7781. return
  7782. }
  7783. userJSONBytes2, _ := json.Marshal(respJSON2)
  7784. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7785. utils.ErrorLog("解析失败:%v", err)
  7786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7787. return
  7788. }
  7789. if res.Infcode == -1 {
  7790. c.ServeSuccessJSON(map[string]interface{}{
  7791. "failed_code": -10,
  7792. "msg": res.ErrMsg,
  7793. })
  7794. return
  7795. } else {
  7796. c.ServeSuccessJSON(map[string]interface{}{
  7797. "info": res.Output,
  7798. })
  7799. }
  7800. }
  7801. func (c *HisApiController) GetCFYLJG004() {
  7802. admin_user_id, _ := c.GetInt64("admin_user_id")
  7803. his_patient_id, _ := c.GetInt64("his_patient_id")
  7804. record_time := c.GetString("record_time")
  7805. admin_user_id = 3626
  7806. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7807. //id, _ := c.GetInt64("id")
  7808. admin_user_id = 3626
  7809. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7810. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7811. flow, _ := service.Getflowtwo(his.Number)
  7812. //id = 3
  7813. patient_id, _ := c.GetInt64("patient_id")
  7814. //patient_id = 23834
  7815. //record_time = "2023-09-18"
  7816. timeLayout := "2006-01-02"
  7817. loc, _ := time.LoadLocation("Local")
  7818. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7819. if err != nil {
  7820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7821. return
  7822. }
  7823. recordDateTime := theTime.Unix()
  7824. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7825. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7826. var cFYLJG004 models.CFYLJG004
  7827. cFYLJG004.HiRxno = flow.HiRxno
  7828. cFYLJG004.FixmedinsCode = miConfig.Code
  7829. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7830. cFYLJG004.UndoDrCertType = "01"
  7831. cFYLJG004.UndoRea = "撤销处方"
  7832. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7833. cFYLJG004.UndoDrName = doctor_info.UserName
  7834. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7835. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7836. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7837. var res ResultCFYLJG004
  7838. var respJSON2 map[string]interface{}
  7839. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7842. return
  7843. }
  7844. userJSONBytes2, _ := json.Marshal(respJSON2)
  7845. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7846. utils.ErrorLog("解析失败:%v", err)
  7847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7848. return
  7849. }
  7850. if res.Infcode == -1 {
  7851. c.ServeSuccessJSON(map[string]interface{}{
  7852. "failed_code": -10,
  7853. "msg": res.ErrMsg,
  7854. })
  7855. return
  7856. } else {
  7857. flow.Status = 0
  7858. service.Saveflow(flow)
  7859. c.ServeSuccessJSON(map[string]interface{}{
  7860. "msg": "撤销成功",
  7861. })
  7862. return
  7863. }
  7864. }
  7865. func (c *HisApiController) GetCFYLJG005() {
  7866. admin_user_id, _ := c.GetInt64("admin_user_id")
  7867. his_patient_id, _ := c.GetInt64("his_patient_id")
  7868. //record_time := c.GetString("record_time")
  7869. admin_user_id = 3626
  7870. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7871. //id, _ := c.GetInt64("id")
  7872. admin_user_id = 3626
  7873. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7874. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7875. flow, _ := service.Getflowtwo(his.Number)
  7876. //id = 3
  7877. var cFYLJG005 models.CFYLJG005
  7878. //patient_id, _ := c.GetInt64("patient_id")
  7879. cFYLJG005.HiRxno = flow.HiRxno
  7880. cFYLJG005.MdtrtID = flow.MID
  7881. cFYLJG005.EcToken = ""
  7882. cFYLJG005.PsnName = his.Name
  7883. cFYLJG005.PsnCertType = "01"
  7884. cFYLJG005.Certno = his.IdCardNo
  7885. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7886. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7887. var res ResultCFYLJG005
  7888. var respJSON2 map[string]interface{}
  7889. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7892. return
  7893. }
  7894. userJSONBytes2, _ := json.Marshal(respJSON2)
  7895. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7896. utils.ErrorLog("解析失败:%v", err)
  7897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7898. return
  7899. }
  7900. if res.Infcode == -1 {
  7901. c.ServeSuccessJSON(map[string]interface{}{
  7902. "failed_code": -10,
  7903. "msg": res.ErrMsg,
  7904. })
  7905. return
  7906. } else {
  7907. c.ServeSuccessJSON(map[string]interface{}{
  7908. "info": res.Output,
  7909. })
  7910. return
  7911. }
  7912. }
  7913. func (c *HisApiController) GetCFYLJG006() {
  7914. admin_user_id, _ := c.GetInt64("admin_user_id")
  7915. his_patient_id, _ := c.GetInt64("his_patient_id")
  7916. admin_user_id = 3626
  7917. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7918. //id, _ := c.GetInt64("id")
  7919. admin_user_id = 3626
  7920. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7921. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7922. flow, _ := service.Getflowtwo(his.Number)
  7923. //id = 3
  7924. patient_id, _ := c.GetInt64("patient_id")
  7925. var cFYLJG006 models.CFYLJG006
  7926. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7927. cFYLJG006.HiRxno = flow.HiRxno
  7928. cFYLJG006.MdtrtID = flow.MID
  7929. cFYLJG006.PsnName = patient.Name
  7930. cFYLJG006.PsnCertType = "01"
  7931. cFYLJG006.Certno = patient.IdCardNo
  7932. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7933. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7934. var res ResultCFYLJG006
  7935. var respJSON2 map[string]interface{}
  7936. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7939. return
  7940. }
  7941. userJSONBytes2, _ := json.Marshal(respJSON2)
  7942. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7943. utils.ErrorLog("解析失败:%v", err)
  7944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7945. return
  7946. }
  7947. if res.Infcode == -1 {
  7948. c.ServeSuccessJSON(map[string]interface{}{
  7949. "failed_code": -10,
  7950. "msg": res.ErrMsg,
  7951. })
  7952. return
  7953. } else {
  7954. c.ServeSuccessJSON(map[string]interface{}{
  7955. "info": res.Output,
  7956. })
  7957. return
  7958. }
  7959. }
  7960. func (c *HisApiController) GetCFYLJG007() {
  7961. admin_user_id, _ := c.GetInt64("admin_user_id")
  7962. his_patient_id, _ := c.GetInt64("his_patient_id")
  7963. admin_user_id = 3626
  7964. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7965. //id, _ := c.GetInt64("id")
  7966. admin_user_id = 3626
  7967. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7968. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7969. flow, _ := service.Getflowtwo(his.Number)
  7970. //id = 3
  7971. patient_id, _ := c.GetInt64("patient_id")
  7972. var cFYLJG007 models.CFYLJG007
  7973. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7974. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7975. cFYLJG007.HiRxno = flow.HiRxno
  7976. cFYLJG007.MdtrtID = flow.MID
  7977. cFYLJG007.PsnNo = his.PsnNo
  7978. cFYLJG007.PsnCertType = "01"
  7979. cFYLJG007.Certno = patient.IdCardNo
  7980. cFYLJG007.PsnName = patient.Name
  7981. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7982. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7983. var res ResultCFYLJG007
  7984. var respJSON2 map[string]interface{}
  7985. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. userJSONBytes2, _ := json.Marshal(respJSON2)
  7991. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7992. utils.ErrorLog("解析失败:%v", err)
  7993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7994. return
  7995. }
  7996. if res.Infcode == -1 {
  7997. c.ServeSuccessJSON(map[string]interface{}{
  7998. "failed_code": -10,
  7999. "msg": res.ErrMsg,
  8000. })
  8001. return
  8002. } else {
  8003. c.ServeSuccessJSON(map[string]interface{}{
  8004. "info": res,
  8005. })
  8006. return
  8007. }
  8008. }
  8009. func (c *HisApiController) GetCFYLJG008() {
  8010. admin_user_id, _ := c.GetInt64("admin_user_id")
  8011. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8012. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8013. var cFYLJG008 models.CFYLJG008
  8014. //id, _ := c.GetInt64("id")
  8015. patient_id, _ := c.GetInt64("patient_id")
  8016. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8017. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8018. //id = 3
  8019. //flow, _ := service.Getflow(id)
  8020. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8021. //
  8022. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8023. //patient_id, _ := c.GetInt64("patient_id")
  8024. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8025. record_time := c.GetString("record_time")
  8026. admin_user_id = 3626
  8027. patient_id = 19424
  8028. //his_patient_id = 263947
  8029. record_time = "2023-08-29"
  8030. timeLayout := "2006-01-02"
  8031. loc, _ := time.LoadLocation("Local")
  8032. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8033. if err != nil {
  8034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8035. return
  8036. }
  8037. recordDateTime := theTime.Unix()
  8038. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8039. cFYLJG008.FixmedinsName = ""
  8040. cFYLJG008.Lat = ""
  8041. cFYLJG008.Lng = ""
  8042. cFYLJG008.OrderType = "1"
  8043. cFYLJG008.PoolareaNo = ""
  8044. cFYLJG008.Lng = ""
  8045. cFYLJG008.PageNum = 1
  8046. cFYLJG008.PageSize = 10
  8047. var MPI models.MedinsProdInvChgDDTO
  8048. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8049. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8050. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8051. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8052. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8053. var res ResultCFYLJG008
  8054. var respJSON2 map[string]interface{}
  8055. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8058. return
  8059. }
  8060. userJSONBytes2, _ := json.Marshal(respJSON2)
  8061. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8062. utils.ErrorLog("解析失败:%v", err)
  8063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8064. return
  8065. }
  8066. if res.Infcode == -1 {
  8067. c.ServeSuccessJSON(map[string]interface{}{
  8068. "failed_code": -10,
  8069. "msg": res.ErrMsg,
  8070. })
  8071. return
  8072. } else {
  8073. c.ServeSuccessJSON(map[string]interface{}{
  8074. "info": res.Output,
  8075. })
  8076. return
  8077. }
  8078. }
  8079. func (c *HisApiController) GetBL4201A() {
  8080. order_id, _ := c.GetInt64("order_id")
  8081. admin_user_id, _ := c.GetInt64("admin_user_id")
  8082. order, _ := service.GetHisOrderByIDTwo(order_id)
  8083. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8084. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8085. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8086. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8087. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8088. department, _ := service.GetDepartMentDetail(his.Departments)
  8089. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8090. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8091. if order.ID == 0 {
  8092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8093. return
  8094. }
  8095. var struct4201A models.Struct4201A
  8096. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8097. for _, items := range order_info {
  8098. memo := make(map[string]interface{})
  8099. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8100. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8101. fsiOPFLD.MedType = "14"
  8102. fsiOPFLD.BkkpSn = items.FeedetlSn
  8103. fsiOPFLD.FixmedinsCode = miConfig.Code
  8104. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8105. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8106. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8107. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8108. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8109. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8110. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8111. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8112. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8113. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8114. fsiOPFLD.BilgDeptName = department.Name
  8115. fsiOPFLD.BilgDeptCodg = department.Number
  8116. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8117. fsiOPFLD.BilgDrName = doctor.UserName
  8118. fsiOPFLD.MedChrgitmType = "09"
  8119. memo["hosp_appr_flag"] = "1"
  8120. memo["invoice_no"] = order.MdtrtId
  8121. memo["memo"] = "自费"
  8122. bytesData, _ := json.Marshal(memo)
  8123. fsiOPFLD.Memo = string(bytesData)
  8124. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8125. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8126. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8127. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8128. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8129. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8130. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8131. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8132. fsiOPFLD.BilgDeptName = department.Name
  8133. fsiOPFLD.BilgDeptCodg = department.Number
  8134. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8135. fsiOPFLD.BilgDrName = doctor.UserName
  8136. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8137. case 0:
  8138. break
  8139. case 1:
  8140. fsiOPFLD.MedChrgitmType = "14"
  8141. break
  8142. case 2:
  8143. fsiOPFLD.MedChrgitmType = "05"
  8144. break
  8145. case 3:
  8146. fsiOPFLD.MedChrgitmType = "03"
  8147. break
  8148. case 4:
  8149. fsiOPFLD.MedChrgitmType = "03"
  8150. break
  8151. case 5:
  8152. fsiOPFLD.MedChrgitmType = "08"
  8153. break
  8154. case 6:
  8155. fsiOPFLD.MedChrgitmType = "14"
  8156. break
  8157. case 7:
  8158. fsiOPFLD.MedChrgitmType = "14"
  8159. break
  8160. case 8:
  8161. fsiOPFLD.MedChrgitmType = "03"
  8162. break
  8163. case 9:
  8164. fsiOPFLD.MedChrgitmType = "14"
  8165. break
  8166. case 10:
  8167. fsiOPFLD.MedChrgitmType = "14"
  8168. break
  8169. case 11:
  8170. fsiOPFLD.MedChrgitmType = "06"
  8171. break
  8172. case 12:
  8173. fsiOPFLD.MedChrgitmType = "12"
  8174. break
  8175. case 13:
  8176. fsiOPFLD.MedChrgitmType = "01"
  8177. break
  8178. case 14:
  8179. fsiOPFLD.MedChrgitmType = "04"
  8180. break
  8181. case 15:
  8182. fsiOPFLD.MedChrgitmType = "14"
  8183. break
  8184. }
  8185. memo["hosp_appr_flag"] = "1"
  8186. memo["invoice_no"] = order.MdtrtId
  8187. memo["memo"] = "自费"
  8188. bytesData, _ := json.Marshal(memo)
  8189. fsiOPFLD.Memo = string(bytesData)
  8190. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8191. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8192. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8193. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8194. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8195. fsiOPFLD.BilgDeptName = department.Name
  8196. fsiOPFLD.BilgDeptCodg = department.Number
  8197. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8198. fsiOPFLD.BilgDrName = doctor.UserName
  8199. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8200. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8201. fsiOPFLD.MedChrgitmType = "08"
  8202. memo["hosp_appr_flag"] = "1"
  8203. memo["invoice_no"] = order.MdtrtId
  8204. memo["memo"] = "自费"
  8205. bytesData, _ := json.Marshal(memo)
  8206. fsiOPFLD.Memo = string(bytesData)
  8207. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8208. }
  8209. }
  8210. }
  8211. for _, items := range order_info_two {
  8212. memo := make(map[string]interface{})
  8213. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8214. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8215. fsiOPFLD.MedType = "14"
  8216. fsiOPFLD.BkkpSn = items.FeedetlSn
  8217. fsiOPFLD.FixmedinsCode = miConfig.Code
  8218. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8219. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8220. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8221. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8222. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8223. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8224. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8225. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8226. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8227. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8228. fsiOPFLD.BilgDeptName = department.Name
  8229. fsiOPFLD.BilgDeptCodg = department.Number
  8230. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8231. fsiOPFLD.BilgDrName = doctor.UserName
  8232. fsiOPFLD.MedChrgitmType = "09"
  8233. memo["hosp_appr_flag"] = "1"
  8234. memo["invoice_no"] = order.MdtrtId
  8235. memo["memo"] = "自费"
  8236. bytesData, _ := json.Marshal(memo)
  8237. fsiOPFLD.Memo = string(bytesData)
  8238. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8239. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8240. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8241. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8242. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8243. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8244. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8245. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8246. fsiOPFLD.BilgDeptName = department.Name
  8247. fsiOPFLD.BilgDeptCodg = department.Number
  8248. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8249. fsiOPFLD.BilgDrName = doctor.UserName
  8250. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8251. case 0:
  8252. break
  8253. case 1:
  8254. fsiOPFLD.MedChrgitmType = "14"
  8255. break
  8256. case 2:
  8257. fsiOPFLD.MedChrgitmType = "05"
  8258. break
  8259. case 3:
  8260. fsiOPFLD.MedChrgitmType = "03"
  8261. break
  8262. case 4:
  8263. fsiOPFLD.MedChrgitmType = "03"
  8264. break
  8265. case 5:
  8266. fsiOPFLD.MedChrgitmType = "08"
  8267. break
  8268. case 6:
  8269. fsiOPFLD.MedChrgitmType = "14"
  8270. break
  8271. case 7:
  8272. fsiOPFLD.MedChrgitmType = "14"
  8273. break
  8274. case 8:
  8275. fsiOPFLD.MedChrgitmType = "03"
  8276. break
  8277. case 9:
  8278. fsiOPFLD.MedChrgitmType = "14"
  8279. break
  8280. case 10:
  8281. fsiOPFLD.MedChrgitmType = "14"
  8282. break
  8283. case 11:
  8284. fsiOPFLD.MedChrgitmType = "06"
  8285. break
  8286. case 12:
  8287. fsiOPFLD.MedChrgitmType = "12"
  8288. break
  8289. case 13:
  8290. fsiOPFLD.MedChrgitmType = "01"
  8291. break
  8292. case 14:
  8293. fsiOPFLD.MedChrgitmType = "04"
  8294. break
  8295. case 15:
  8296. fsiOPFLD.MedChrgitmType = "14"
  8297. break
  8298. }
  8299. memo["hosp_appr_flag"] = "1"
  8300. memo["invoice_no"] = order.MdtrtId
  8301. memo["memo"] = "自费"
  8302. bytesData, _ := json.Marshal(memo)
  8303. fsiOPFLD.Memo = string(bytesData)
  8304. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8305. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8306. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8307. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8308. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8309. fsiOPFLD.BilgDeptName = department.Name
  8310. fsiOPFLD.BilgDeptCodg = department.Number
  8311. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8312. fsiOPFLD.BilgDrName = doctor.UserName
  8313. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8314. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8315. fsiOPFLD.MedChrgitmType = "08"
  8316. memo["hosp_appr_flag"] = "1"
  8317. memo["invoice_no"] = order.MdtrtId
  8318. memo["memo"] = "自费"
  8319. bytesData, _ := json.Marshal(memo)
  8320. fsiOPFLD.Memo = string(bytesData)
  8321. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8322. }
  8323. }
  8324. }
  8325. fmt.Println(fsiOPFLDs)
  8326. struct4201A.Fopfd = fsiOPFLDs
  8327. fmt.Println(struct4201A.Fopfd)
  8328. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8329. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8330. var res2 ResultSix
  8331. var respJSON2 map[string]interface{}
  8332. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8335. return
  8336. }
  8337. userJSONBytes2, _ := json.Marshal(respJSON2)
  8338. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8339. utils.ErrorLog("解析失败:%v", err)
  8340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8341. return
  8342. }
  8343. if res2.Infcode != 0 {
  8344. c.ServeSuccessJSON(map[string]interface{}{
  8345. "failed_code": -10,
  8346. "msg": res2.ErrMsg,
  8347. })
  8348. return
  8349. } else {
  8350. order.IsUploadOrderInfo = 1
  8351. service.UpdateOrder(order)
  8352. c.ServeSuccessJSON(map[string]interface{}{
  8353. "msg": "上传成功",
  8354. })
  8355. }
  8356. }
  8357. func (c *HisApiController) Get2505() {
  8358. admin_user_id, _ := c.GetInt64("admin_user_id")
  8359. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8360. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8361. 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)
  8362. }
  8363. func (c *HisApiController) Get4201A() {
  8364. order_id, _ := c.GetInt64("order_id")
  8365. admin_user_id, _ := c.GetInt64("admin_user_id")
  8366. order, _ := service.GetHisOrderByIDTwo(order_id)
  8367. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8368. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8369. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8370. //order_info = append(order_info, order_info_two...)
  8371. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8372. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8373. department, _ := service.GetDepartMentDetail(his.Departments)
  8374. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8375. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8376. if order.ID == 0 {
  8377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8378. return
  8379. }
  8380. var struct4201A models.Struct4201A
  8381. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8382. for _, items := range order_info {
  8383. memo := make(map[string]interface{})
  8384. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8385. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8386. fsiOPFLD.MedType = "14"
  8387. fsiOPFLD.BkkpSn = items.FeedetlSn
  8388. fsiOPFLD.FixmedinsCode = miConfig.Code
  8389. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8390. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8391. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8392. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8393. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8394. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8395. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8396. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8397. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8398. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8399. fsiOPFLD.BilgDeptName = department.Name
  8400. fsiOPFLD.BilgDeptCodg = department.Number
  8401. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8402. fsiOPFLD.BilgDrName = doctor.UserName
  8403. fsiOPFLD.MedChrgitmType = "09"
  8404. memo["hosp_appr_flag"] = "1"
  8405. memo["invoice_no"] = order.MdtrtId
  8406. memo["memo"] = "自费"
  8407. bytesData, _ := json.Marshal(memo)
  8408. fsiOPFLD.Memo = string(bytesData)
  8409. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8410. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8411. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8412. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8413. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8414. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8415. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8416. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8417. fsiOPFLD.BilgDeptName = department.Name
  8418. fsiOPFLD.BilgDeptCodg = department.Number
  8419. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8420. fsiOPFLD.BilgDrName = doctor.UserName
  8421. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8422. case 0:
  8423. break
  8424. case 1:
  8425. fsiOPFLD.MedChrgitmType = "14"
  8426. break
  8427. case 2:
  8428. fsiOPFLD.MedChrgitmType = "05"
  8429. break
  8430. case 3:
  8431. fsiOPFLD.MedChrgitmType = "03"
  8432. break
  8433. case 4:
  8434. fsiOPFLD.MedChrgitmType = "03"
  8435. break
  8436. case 5:
  8437. fsiOPFLD.MedChrgitmType = "08"
  8438. break
  8439. case 6:
  8440. fsiOPFLD.MedChrgitmType = "14"
  8441. break
  8442. case 7:
  8443. fsiOPFLD.MedChrgitmType = "14"
  8444. break
  8445. case 8:
  8446. fsiOPFLD.MedChrgitmType = "03"
  8447. break
  8448. case 9:
  8449. fsiOPFLD.MedChrgitmType = "14"
  8450. break
  8451. case 10:
  8452. fsiOPFLD.MedChrgitmType = "14"
  8453. break
  8454. case 11:
  8455. fsiOPFLD.MedChrgitmType = "06"
  8456. break
  8457. case 12:
  8458. fsiOPFLD.MedChrgitmType = "12"
  8459. break
  8460. case 13:
  8461. fsiOPFLD.MedChrgitmType = "01"
  8462. break
  8463. case 14:
  8464. fsiOPFLD.MedChrgitmType = "04"
  8465. break
  8466. case 15:
  8467. fsiOPFLD.MedChrgitmType = "14"
  8468. break
  8469. }
  8470. memo["hosp_appr_flag"] = "1"
  8471. memo["invoice_no"] = order.MdtrtId
  8472. memo["memo"] = "自费"
  8473. bytesData, _ := json.Marshal(memo)
  8474. fsiOPFLD.Memo = string(bytesData)
  8475. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8476. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8477. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8478. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8479. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8480. fsiOPFLD.BilgDeptName = department.Name
  8481. fsiOPFLD.BilgDeptCodg = department.Number
  8482. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8483. fsiOPFLD.BilgDrName = doctor.UserName
  8484. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8485. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8486. fsiOPFLD.MedChrgitmType = "08"
  8487. memo["hosp_appr_flag"] = "1"
  8488. memo["invoice_no"] = order.MdtrtId
  8489. memo["memo"] = "自费"
  8490. bytesData, _ := json.Marshal(memo)
  8491. fsiOPFLD.Memo = string(bytesData)
  8492. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8493. }
  8494. }
  8495. }
  8496. for _, items := range order_info_two {
  8497. memo := make(map[string]interface{})
  8498. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8499. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8500. fsiOPFLD.MedType = "14"
  8501. fsiOPFLD.BkkpSn = items.FeedetlSn
  8502. fsiOPFLD.FixmedinsCode = miConfig.Code
  8503. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8504. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8505. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8506. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8507. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8508. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8509. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8510. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8511. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8512. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8513. fsiOPFLD.BilgDeptName = department.Name
  8514. fsiOPFLD.BilgDeptCodg = department.Number
  8515. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8516. fsiOPFLD.BilgDrName = doctor.UserName
  8517. fsiOPFLD.MedChrgitmType = "09"
  8518. memo["hosp_appr_flag"] = "1"
  8519. memo["invoice_no"] = order.MdtrtId
  8520. memo["memo"] = "自费"
  8521. bytesData, _ := json.Marshal(memo)
  8522. fsiOPFLD.Memo = string(bytesData)
  8523. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8524. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8525. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8526. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8527. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8528. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8529. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8530. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8531. fsiOPFLD.BilgDeptName = department.Name
  8532. fsiOPFLD.BilgDeptCodg = department.Number
  8533. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8534. fsiOPFLD.BilgDrName = doctor.UserName
  8535. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8536. case 0:
  8537. break
  8538. case 1:
  8539. fsiOPFLD.MedChrgitmType = "14"
  8540. break
  8541. case 2:
  8542. fsiOPFLD.MedChrgitmType = "05"
  8543. break
  8544. case 3:
  8545. fsiOPFLD.MedChrgitmType = "03"
  8546. break
  8547. case 4:
  8548. fsiOPFLD.MedChrgitmType = "03"
  8549. break
  8550. case 5:
  8551. fsiOPFLD.MedChrgitmType = "08"
  8552. break
  8553. case 6:
  8554. fsiOPFLD.MedChrgitmType = "14"
  8555. break
  8556. case 7:
  8557. fsiOPFLD.MedChrgitmType = "14"
  8558. break
  8559. case 8:
  8560. fsiOPFLD.MedChrgitmType = "03"
  8561. break
  8562. case 9:
  8563. fsiOPFLD.MedChrgitmType = "14"
  8564. break
  8565. case 10:
  8566. fsiOPFLD.MedChrgitmType = "14"
  8567. break
  8568. case 11:
  8569. fsiOPFLD.MedChrgitmType = "06"
  8570. break
  8571. case 12:
  8572. fsiOPFLD.MedChrgitmType = "12"
  8573. break
  8574. case 13:
  8575. fsiOPFLD.MedChrgitmType = "01"
  8576. break
  8577. case 14:
  8578. fsiOPFLD.MedChrgitmType = "04"
  8579. break
  8580. case 15:
  8581. fsiOPFLD.MedChrgitmType = "14"
  8582. break
  8583. }
  8584. memo["hosp_appr_flag"] = "1"
  8585. memo["invoice_no"] = order.MdtrtId
  8586. memo["memo"] = "自费"
  8587. bytesData, _ := json.Marshal(memo)
  8588. fsiOPFLD.Memo = string(bytesData)
  8589. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8590. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8591. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8592. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8593. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8594. fsiOPFLD.BilgDeptName = department.Name
  8595. fsiOPFLD.BilgDeptCodg = department.Number
  8596. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8597. fsiOPFLD.BilgDrName = doctor.UserName
  8598. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8599. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8600. fsiOPFLD.MedChrgitmType = "08"
  8601. memo["hosp_appr_flag"] = "1"
  8602. memo["invoice_no"] = order.MdtrtId
  8603. memo["memo"] = "自费"
  8604. bytesData, _ := json.Marshal(memo)
  8605. fsiOPFLD.Memo = string(bytesData)
  8606. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8607. }
  8608. }
  8609. }
  8610. fmt.Println(fsiOPFLDs)
  8611. struct4201A.Fopfd = fsiOPFLDs
  8612. fmt.Println(struct4201A.Fopfd)
  8613. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8614. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8615. var res2 ResultSix
  8616. var respJSON2 map[string]interface{}
  8617. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8620. return
  8621. }
  8622. userJSONBytes2, _ := json.Marshal(respJSON2)
  8623. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8624. utils.ErrorLog("解析失败:%v", err)
  8625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8626. return
  8627. }
  8628. if res2.Infcode != 0 {
  8629. c.ServeSuccessJSON(map[string]interface{}{
  8630. "failed_code": -10,
  8631. "msg": res2.ErrMsg,
  8632. })
  8633. return
  8634. } else {
  8635. order.IsUploadOrderInfo = 1
  8636. service.UpdateOrder(order)
  8637. c.ServeSuccessJSON(map[string]interface{}{
  8638. "msg": "上传成功",
  8639. })
  8640. }
  8641. }
  8642. func (c *HisApiController) Get4202() {
  8643. order_id, _ := c.GetInt64("order_id")
  8644. admin_user_id, _ := c.GetInt64("admin_user_id")
  8645. order, _ := service.GetHisOrderByIDTwo(order_id)
  8646. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8647. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8648. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8649. if order.ID == 0 {
  8650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8651. return
  8652. }
  8653. var struct4202 models.Struct4202
  8654. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8655. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8656. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8657. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8658. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8659. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8660. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8661. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8662. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8663. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8664. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8665. var config []*models.HisXtDiagnoseConfig
  8666. for _, item := range diagnosis_ids {
  8667. id, _ := strconv.ParseInt(item, 10, 64)
  8668. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8669. config = append(config, &diagnosisConfig)
  8670. }
  8671. var tempDiaginfos []models.OwnPayPatnDiagListD
  8672. for index, item := range config {
  8673. if index == 0 {
  8674. var tempDiaginfo models.OwnPayPatnDiagListD
  8675. tempDiaginfo.InoutDiagType = "1"
  8676. tempDiaginfo.DiagCode = item.CountryCode
  8677. tempDiaginfo.DiagName = item.CountryContentName
  8678. tempDiaginfo.DiagType = "1"
  8679. tempDiaginfo.DiagSrtNo = "1"
  8680. tempDiaginfo.MaindiagFlag = "1"
  8681. tempDiaginfo.ValiFlag = "1"
  8682. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8683. } else {
  8684. var tempDiaginfo models.OwnPayPatnDiagListD
  8685. tempDiaginfo.DiagCode = item.CountryCode
  8686. tempDiaginfo.DiagName = item.CountryContentName
  8687. tempDiaginfo.DiagType = "2"
  8688. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8689. tempDiaginfo.MaindiagFlag = "0"
  8690. tempDiaginfo.ValiFlag = "1"
  8691. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8692. }
  8693. }
  8694. struct4202.ODiagListD = tempDiaginfos
  8695. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8696. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8697. var res2 ResultSix
  8698. var respJSON2 map[string]interface{}
  8699. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8702. return
  8703. }
  8704. userJSONBytes2, _ := json.Marshal(respJSON2)
  8705. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8706. utils.ErrorLog("解析失败:%v", err)
  8707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8708. return
  8709. }
  8710. if res2.Infcode != 0 {
  8711. c.ServeSuccessJSON(map[string]interface{}{
  8712. "failed_code": -10,
  8713. "msg": res2.ErrMsg,
  8714. })
  8715. return
  8716. } else {
  8717. order.IsUploadDiagnose = 1
  8718. service.UpdateOrder(order)
  8719. c.ServeSuccessJSON(map[string]interface{}{
  8720. "msg": "上传成功",
  8721. })
  8722. }
  8723. }
  8724. func (c *HisApiController) Get4203() {
  8725. admin_user_id, _ := c.GetInt64("admin_user_id")
  8726. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8727. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8728. order_id, _ := c.GetInt64("order_id")
  8729. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8730. number := ""
  8731. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8732. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8733. if his.ID == 0 {
  8734. number = hospital.Number
  8735. } else {
  8736. number = his.Number
  8737. }
  8738. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8739. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8740. var res2 ResultSix
  8741. var respJSON2 map[string]interface{}
  8742. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8745. return
  8746. }
  8747. userJSONBytes2, _ := json.Marshal(respJSON2)
  8748. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8749. utils.ErrorLog("解析失败:%v", err)
  8750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8751. return
  8752. }
  8753. if res2.Infcode != 0 {
  8754. c.ServeSuccessJSON(map[string]interface{}{
  8755. "failed_code": -10,
  8756. "msg": res2.ErrMsg,
  8757. })
  8758. return
  8759. } else {
  8760. order.IsUploadSuccess = 1
  8761. service.UpdateOrderTwo(order)
  8762. c.ServeSuccessJSON(map[string]interface{}{
  8763. "msg": "上传成功",
  8764. })
  8765. }
  8766. }
  8767. func (c *HisApiController) Get4205() {
  8768. order_id, _ := c.GetInt64("order_id")
  8769. admin_user_id, _ := c.GetInt64("admin_user_id")
  8770. fapiao_code := c.GetString("fapiao_code")
  8771. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8772. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8773. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8774. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8775. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8776. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8777. //order_info = append(order_info, order_info_two...)
  8778. department, _ := service.GetDepartMentDetail(his.Departments)
  8779. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8780. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8781. if order.ID == 0 {
  8782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8783. return
  8784. }
  8785. var struct4201A models.Struct4201A
  8786. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8787. for _, items := range order_info {
  8788. memo := make(map[string]interface{})
  8789. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8790. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8791. fsiOPFLD.MedType = pre.MedType
  8792. fsiOPFLD.FixmedinsCode = miConfig.Code
  8793. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8794. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8795. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8796. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8797. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8798. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8799. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8800. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8801. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8802. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8803. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8804. fsiOPFLD.BilgDeptName = department.Name
  8805. fsiOPFLD.BilgDeptCodg = department.Number
  8806. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8807. fsiOPFLD.BilgDrName = doctor.UserName
  8808. fsiOPFLD.MedChrgitmType = "09"
  8809. memo["hosp_appr_flag"] = "1"
  8810. memo["invoice_no"] = fapiao_code
  8811. memo["memo"] = "自费"
  8812. bytesData, _ := json.Marshal(memo)
  8813. fsiOPFLD.Memo = string(bytesData)
  8814. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8815. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8816. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8817. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8818. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8819. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8820. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8821. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8822. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8823. fsiOPFLD.BilgDeptName = department.Name
  8824. fsiOPFLD.BilgDeptCodg = department.Number
  8825. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8826. fsiOPFLD.BilgDrName = doctor.UserName
  8827. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8828. case 0:
  8829. break
  8830. case 1:
  8831. fsiOPFLD.MedChrgitmType = "14"
  8832. break
  8833. case 2:
  8834. fsiOPFLD.MedChrgitmType = "05"
  8835. break
  8836. case 3:
  8837. fsiOPFLD.MedChrgitmType = "03"
  8838. break
  8839. case 4:
  8840. fsiOPFLD.MedChrgitmType = "03"
  8841. break
  8842. case 5:
  8843. fsiOPFLD.MedChrgitmType = "08"
  8844. break
  8845. case 6:
  8846. fsiOPFLD.MedChrgitmType = "14"
  8847. break
  8848. case 7:
  8849. fsiOPFLD.MedChrgitmType = "14"
  8850. break
  8851. case 8:
  8852. fsiOPFLD.MedChrgitmType = "03"
  8853. break
  8854. case 9:
  8855. fsiOPFLD.MedChrgitmType = "14"
  8856. break
  8857. case 10:
  8858. fsiOPFLD.MedChrgitmType = "14"
  8859. break
  8860. case 11:
  8861. fsiOPFLD.MedChrgitmType = "06"
  8862. break
  8863. case 12:
  8864. fsiOPFLD.MedChrgitmType = "12"
  8865. break
  8866. case 13:
  8867. fsiOPFLD.MedChrgitmType = "01"
  8868. break
  8869. case 14:
  8870. fsiOPFLD.MedChrgitmType = "04"
  8871. break
  8872. case 15:
  8873. fsiOPFLD.MedChrgitmType = "14"
  8874. break
  8875. }
  8876. memo["hosp_appr_flag"] = "1"
  8877. memo["invoice_no"] = fapiao_code
  8878. memo["memo"] = "自费"
  8879. bytesData, _ := json.Marshal(memo)
  8880. fsiOPFLD.Memo = string(bytesData)
  8881. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8882. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8883. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8884. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8885. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8886. fsiOPFLD.BilgDeptName = department.Name
  8887. fsiOPFLD.BilgDeptCodg = department.Number
  8888. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8889. fsiOPFLD.BilgDrName = doctor.UserName
  8890. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8891. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8892. fsiOPFLD.MedChrgitmType = "08"
  8893. memo["hosp_appr_flag"] = "1"
  8894. memo["invoice_no"] = fapiao_code
  8895. memo["memo"] = "自费"
  8896. bytesData, _ := json.Marshal(memo)
  8897. fsiOPFLD.Memo = string(bytesData)
  8898. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8899. }
  8900. }
  8901. }
  8902. for _, items := range order_info_two {
  8903. memo := make(map[string]interface{})
  8904. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8905. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8906. fsiOPFLD.MedType = pre.MedType
  8907. fsiOPFLD.BkkpSn = items.FeedetlSn
  8908. fsiOPFLD.FixmedinsCode = miConfig.Code
  8909. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8910. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8911. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8912. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8913. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8914. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8915. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8916. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8917. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8918. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8919. fsiOPFLD.BilgDeptName = department.Name
  8920. fsiOPFLD.BilgDeptCodg = department.Number
  8921. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8922. fsiOPFLD.BilgDrName = doctor.UserName
  8923. fsiOPFLD.MedChrgitmType = "09"
  8924. memo["hosp_appr_flag"] = "1"
  8925. memo["invoice_no"] = fapiao_code
  8926. memo["memo"] = "自费"
  8927. bytesData, _ := json.Marshal(memo)
  8928. fsiOPFLD.Memo = string(bytesData)
  8929. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8930. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8931. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8932. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8933. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8934. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8935. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8936. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8937. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8938. fsiOPFLD.BilgDeptName = department.Name
  8939. fsiOPFLD.BilgDeptCodg = department.Number
  8940. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8941. fsiOPFLD.BilgDrName = doctor.UserName
  8942. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8943. case 0:
  8944. break
  8945. case 1:
  8946. fsiOPFLD.MedChrgitmType = "14"
  8947. break
  8948. case 2:
  8949. fsiOPFLD.MedChrgitmType = "05"
  8950. break
  8951. case 3:
  8952. fsiOPFLD.MedChrgitmType = "03"
  8953. break
  8954. case 4:
  8955. fsiOPFLD.MedChrgitmType = "03"
  8956. break
  8957. case 5:
  8958. fsiOPFLD.MedChrgitmType = "08"
  8959. break
  8960. case 6:
  8961. fsiOPFLD.MedChrgitmType = "14"
  8962. break
  8963. case 7:
  8964. fsiOPFLD.MedChrgitmType = "14"
  8965. break
  8966. case 8:
  8967. fsiOPFLD.MedChrgitmType = "03"
  8968. break
  8969. case 9:
  8970. fsiOPFLD.MedChrgitmType = "14"
  8971. break
  8972. case 10:
  8973. fsiOPFLD.MedChrgitmType = "14"
  8974. break
  8975. case 11:
  8976. fsiOPFLD.MedChrgitmType = "06"
  8977. break
  8978. case 12:
  8979. fsiOPFLD.MedChrgitmType = "12"
  8980. break
  8981. case 13:
  8982. fsiOPFLD.MedChrgitmType = "01"
  8983. break
  8984. case 14:
  8985. fsiOPFLD.MedChrgitmType = "04"
  8986. break
  8987. case 15:
  8988. fsiOPFLD.MedChrgitmType = "14"
  8989. break
  8990. }
  8991. memo["hosp_appr_flag"] = "1"
  8992. memo["invoice_no"] = fapiao_code
  8993. memo["memo"] = "自费"
  8994. bytesData, _ := json.Marshal(memo)
  8995. fsiOPFLD.Memo = string(bytesData)
  8996. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8997. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8998. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8999. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9000. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9001. fsiOPFLD.BilgDeptName = department.Name
  9002. fsiOPFLD.BilgDeptCodg = department.Number
  9003. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9004. fsiOPFLD.BilgDrName = doctor.UserName
  9005. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9006. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9007. fsiOPFLD.MedChrgitmType = "08"
  9008. memo["hosp_appr_flag"] = "1"
  9009. memo["invoice_no"] = fapiao_code
  9010. memo["memo"] = "自费"
  9011. bytesData, _ := json.Marshal(memo)
  9012. fsiOPFLD.Memo = string(bytesData)
  9013. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9014. }
  9015. }
  9016. }
  9017. fmt.Println(fsiOPFLDs)
  9018. struct4201A.Fopfd = fsiOPFLDs
  9019. fmt.Println(struct4201A.Fopfd)
  9020. var struct4202 models.Struct4202
  9021. timeLayout := "2006-01-02 15:04:05"
  9022. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9023. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9024. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9025. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9026. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9027. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9028. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9029. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9030. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9031. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9032. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9033. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9034. var config []*models.HisXtDiagnoseConfig
  9035. for _, item := range diagnosis_ids {
  9036. id, _ := strconv.ParseInt(item, 10, 64)
  9037. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9038. config = append(config, &diagnosisConfig)
  9039. }
  9040. var tempDiaginfos []models.OwnPayPatnDiagListD
  9041. for index, item := range config {
  9042. if index == 0 {
  9043. var tempDiaginfo models.OwnPayPatnDiagListD
  9044. tempDiaginfo.InoutDiagType = "1"
  9045. tempDiaginfo.DiagCode = item.CountryCode
  9046. tempDiaginfo.DiagName = item.CountryContentName
  9047. tempDiaginfo.DiagType = "1"
  9048. tempDiaginfo.DiagSrtNo = "1"
  9049. tempDiaginfo.MaindiagFlag = "1"
  9050. tempDiaginfo.ValiFlag = "1"
  9051. tempDiaginfo.DiagDrName = doctor.UserName
  9052. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9053. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9054. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9055. } else {
  9056. var tempDiaginfo models.OwnPayPatnDiagListD
  9057. tempDiaginfo.DiagCode = item.CountryCode
  9058. tempDiaginfo.DiagName = item.CountryContentName
  9059. tempDiaginfo.DiagType = "2"
  9060. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9061. tempDiaginfo.MaindiagFlag = "0"
  9062. tempDiaginfo.ValiFlag = "1"
  9063. tempDiaginfo.DiagDrName = doctor.UserName
  9064. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9065. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9066. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9067. }
  9068. }
  9069. struct4202.ODiagListD = tempDiaginfos
  9070. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9071. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9072. var res2 ResultSix
  9073. var respJSON2 map[string]interface{}
  9074. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9077. return
  9078. }
  9079. userJSONBytes2, _ := json.Marshal(respJSON2)
  9080. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9081. utils.ErrorLog("解析失败:%v", err)
  9082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9083. return
  9084. }
  9085. if res2.Infcode != 0 {
  9086. c.ServeSuccessJSON(map[string]interface{}{
  9087. "failed_code": -10,
  9088. "msg": res2.ErrMsg,
  9089. })
  9090. return
  9091. } else {
  9092. order.IsUploadDiagnose = 1
  9093. order.IsUploadOrderInfo = 1
  9094. service.UpdateOrderTwo(order)
  9095. c.ServeSuccessJSON(map[string]interface{}{
  9096. "msg": "上传成功",
  9097. })
  9098. }
  9099. }
  9100. func (c *HisApiController) Get4207() {
  9101. admin_user_id, _ := c.GetInt64("admin_user_id")
  9102. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9103. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9104. order_id, _ := c.GetInt64("order_id")
  9105. order, _ := service.GetHisOrderByIDTwo(order_id)
  9106. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9107. var struct4207 models.Struct4207
  9108. struct4207.PageNum = "1"
  9109. struct4207.PageSize = "1000"
  9110. struct4207.FixmedinsCode = miConfig.Code
  9111. struct4207.FixmedinsMdtrtID = order.Number
  9112. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9113. saveLog(result, requestLog, "4207", "查询")
  9114. var res2 ResultSix
  9115. var respJSON2 map[string]interface{}
  9116. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9119. return
  9120. }
  9121. userJSONBytes2, _ := json.Marshal(respJSON2)
  9122. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9123. utils.ErrorLog("解析失败:%v", err)
  9124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9125. return
  9126. }
  9127. if res2.Infcode != 0 {
  9128. c.ServeSuccessJSON(map[string]interface{}{
  9129. "failed_code": -10,
  9130. "msg": res2.ErrMsg,
  9131. })
  9132. return
  9133. } else {
  9134. c.ServeSuccessJSON(map[string]interface{}{
  9135. "msg": "查询成功",
  9136. })
  9137. }
  9138. }
  9139. func (c *HisApiController) Get4208() {
  9140. admin_user_id, _ := c.GetInt64("admin_user_id")
  9141. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9142. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9143. order_id, _ := c.GetInt64("order_id")
  9144. order, _ := service.GetHisOrderByIDTwo(order_id)
  9145. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9146. var struct4208 models.Struct4208
  9147. struct4208.PageNum = "1"
  9148. struct4208.PageSize = "1000"
  9149. struct4208.PsnCertType = "01"
  9150. struct4208.Certno = his.Certno
  9151. struct4208.MedType = order.MedType
  9152. struct4208.PsnName = his.Name
  9153. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9154. saveLog(result, requestLog, "4208", "查询")
  9155. var res2 ResultSix
  9156. var respJSON2 map[string]interface{}
  9157. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9160. return
  9161. }
  9162. userJSONBytes2, _ := json.Marshal(respJSON2)
  9163. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9164. utils.ErrorLog("解析失败:%v", err)
  9165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9166. return
  9167. }
  9168. if res2.Infcode != 0 {
  9169. c.ServeSuccessJSON(map[string]interface{}{
  9170. "failed_code": -10,
  9171. "msg": res2.ErrMsg,
  9172. })
  9173. return
  9174. } else {
  9175. c.ServeSuccessJSON(map[string]interface{}{
  9176. "msg": "查询成功",
  9177. })
  9178. }
  9179. }
  9180. func (c *HisApiController) Get4209() {
  9181. admin_user_id, _ := c.GetInt64("admin_user_id")
  9182. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9183. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9184. order_id, _ := c.GetInt64("order_id")
  9185. order, _ := service.GetHisOrderByIDTwo(order_id)
  9186. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9187. var struct4209 models.Struct4209
  9188. struct4209.FixmedinsMdtrtID = order.Number
  9189. struct4209.FixmedinsCode = miConfig.Code
  9190. struct4209.PageSize = "1000"
  9191. struct4209.PageNum = "1"
  9192. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9193. saveLog(result, requestLog, "4209", "查询")
  9194. var res2 ResultSix
  9195. var respJSON2 map[string]interface{}
  9196. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9199. return
  9200. }
  9201. userJSONBytes2, _ := json.Marshal(respJSON2)
  9202. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9203. utils.ErrorLog("解析失败:%v", err)
  9204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9205. return
  9206. }
  9207. if res2.Infcode != 0 {
  9208. c.ServeSuccessJSON(map[string]interface{}{
  9209. "failed_code": -10,
  9210. "msg": res2.ErrMsg,
  9211. })
  9212. return
  9213. } else {
  9214. c.ServeSuccessJSON(map[string]interface{}{
  9215. "msg": "查询成功",
  9216. })
  9217. }
  9218. }
  9219. type Result3101 struct {
  9220. Infcode string `json:"infcode"`
  9221. InfRefmsgid string `json:"inf_refmsgid"`
  9222. RefmsgTime string `json:"refmsg_time"`
  9223. RespondTime string `json:"respond_time"`
  9224. Enctype string `json:"enctype"`
  9225. Signtype string `json:"signtype"`
  9226. ErrMsg string `json:"err_msg"`
  9227. Output struct {
  9228. Result []struct {
  9229. JudgeResultDetailDtos []struct {
  9230. VolaItemType string `json:"vola_item_type"`
  9231. MdtrtID string `json:"mdtrt_id"`
  9232. JrdID string `json:"jrd_id"`
  9233. PatnID string `json:"patn_id"`
  9234. RxID string `json:"rx_id"`
  9235. VolaAmt interface{} `json:"vola_amt"`
  9236. } `json:"judge_result_detail_dtos"`
  9237. RuleID string `json:"rule_id"`
  9238. VolaEvid string `json:"vola_evid"`
  9239. MdtrtID string `json:"mdtrt_id"`
  9240. RuleName string `json:"rule_name"`
  9241. VolaAmtStas string `json:"vola_amt_stas"`
  9242. JrID string `json:"jr_id"`
  9243. PatnID string `json:"patn_id"`
  9244. SevDeg string `json:"sev_deg"`
  9245. VolaAmt float64 `json:"vola_amt"`
  9246. VolaBhvrType string `json:"vola_bhvr_type"`
  9247. VolaCont string `json:"vola_cont"`
  9248. } `json:"result"`
  9249. } `json:"output"`
  9250. }
  9251. type Resultgd3101 struct {
  9252. Infcode int64 `json:"infcode"`
  9253. InfRefmsgid string `json:"inf_refmsgid"`
  9254. RefmsgTime string `json:"refmsg_time"`
  9255. RespondTime string `json:"respond_time"`
  9256. Enctype string `json:"enctype"`
  9257. Signtype string `json:"signtype"`
  9258. ErrMsg string `json:"err_msg"`
  9259. Output struct {
  9260. Result []struct {
  9261. JudgeResultDetailDtos []struct {
  9262. VolaItemType string `json:"vola_item_type"`
  9263. MdtrtID string `json:"mdtrt_id"`
  9264. JrdID string `json:"jrd_id"`
  9265. PatnID string `json:"patn_id"`
  9266. RxID string `json:"rx_id"`
  9267. VolaAmt interface{} `json:"vola_amt"`
  9268. } `json:"judge_result_detail_dtos"`
  9269. RuleID string `json:"rule_id"`
  9270. VolaEvid string `json:"vola_evid"`
  9271. MdtrtID string `json:"mdtrt_id"`
  9272. RuleName string `json:"rule_name"`
  9273. VolaAmtStas string `json:"vola_amt_stas"`
  9274. JrID string `json:"jr_id"`
  9275. PatnID string `json:"patn_id"`
  9276. SevDeg string `json:"sev_deg"`
  9277. VolaAmt float64 `json:"vola_amt"`
  9278. VolaBhvrType string `json:"vola_bhvr_type"`
  9279. VolaCont string `json:"vola_cont"`
  9280. } `json:"result"`
  9281. } `json:"output"`
  9282. }
  9283. func (c *HisApiController) ReadEleToken() {
  9284. admin_user_id, _ := c.GetInt64("admin_user_id")
  9285. his_patient_id, _ := c.GetInt64("his_patient_id")
  9286. adminUser := c.GetAdminUserInfo()
  9287. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9288. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9289. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9290. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9291. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9292. if len(tokens) > 0 {
  9293. c.ServeSuccessJSON(map[string]interface{}{
  9294. "msg": "读取成功",
  9295. })
  9296. } else {
  9297. c.ServeSuccessJSON(map[string]interface{}{
  9298. "failed_code": -10,
  9299. "msg": "读取失败",
  9300. })
  9301. }
  9302. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9303. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9304. if len(tokens) > 0 {
  9305. c.ServeSuccessJSON(map[string]interface{}{
  9306. "msg": "读取成功",
  9307. })
  9308. } else {
  9309. c.ServeSuccessJSON(map[string]interface{}{
  9310. "failed_code": -10,
  9311. "msg": "读取失败",
  9312. })
  9313. }
  9314. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9315. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9316. if len(tokens) > 0 {
  9317. c.ServeSuccessJSON(map[string]interface{}{
  9318. "msg": "读取成功",
  9319. })
  9320. } else {
  9321. c.ServeSuccessJSON(map[string]interface{}{
  9322. "failed_code": -10,
  9323. "msg": "读取失败",
  9324. })
  9325. }
  9326. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9327. var api string
  9328. 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 +
  9329. "&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"
  9330. resp, requestErr := http.Get(api)
  9331. if requestErr != nil {
  9332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9333. }
  9334. body, ioErr := ioutil.ReadAll(resp.Body)
  9335. if ioErr != nil {
  9336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9338. }
  9339. var respJSON map[string]interface{}
  9340. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9343. return
  9344. }
  9345. var status string
  9346. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9347. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9348. var token string
  9349. var res ResultTwo //1101结果
  9350. var res10265 ResultTwo10265 //1101结果
  9351. if status == "0" { //读卡成功
  9352. var card_info string //卡信息
  9353. var busi_card_info string
  9354. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9355. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9356. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9357. fmt.Println(card_info)
  9358. fmt.Println(busi_card_info)
  9359. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9360. result, _ := json.Marshal(respJSON)
  9361. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9362. utils.ErrorLog("解析失败:%v", err)
  9363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9364. return
  9365. }
  9366. res.ErrMsg = res10265.ErrMsg
  9367. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9368. res.Infcode = infocode
  9369. res.Output = res10265.Output
  9370. res.InfRefmsgid = res10265.InfRefmsgid
  9371. if res.Infcode == 0 {
  9372. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9373. if err == gorm.ErrRecordNotFound {
  9374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9375. return
  9376. } else if err != nil {
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9378. return
  9379. } else {
  9380. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9381. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9382. infoStr := string(Iinfos)
  9383. idetinfoStr := string(Idetinfos)
  9384. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9385. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9386. psn := &models.HisPsn{
  9387. PsnNo: res.Output.Baseinfo.PsnNo,
  9388. PatientId: patient.ID,
  9389. Certno: res.Output.Baseinfo.Certno,
  9390. Gend: res.Output.Baseinfo.Gend,
  9391. Naty: res.Output.Baseinfo.Naty,
  9392. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9393. PsnName: res.Output.Baseinfo.PsnName,
  9394. Age: float64(age),
  9395. Brdy: b,
  9396. Idetinfo: idetinfoStr,
  9397. Insuinfo: infoStr,
  9398. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9399. CardInfo: card_info,
  9400. VerifyNumber: token,
  9401. IdCardType: 4,
  9402. }
  9403. var rf []*ResultFive
  9404. json.Unmarshal([]byte(infoStr), &rf)
  9405. var insutypes []*ResultFive
  9406. var insutype string
  9407. var is390 int = 0
  9408. var is310 int = 0
  9409. for _, item := range rf {
  9410. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9411. insutypes = append(insutypes, item)
  9412. }
  9413. }
  9414. if len(insutypes) == 1 {
  9415. insutype = insutypes[0].Insutype
  9416. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9417. } else {
  9418. for _, i := range insutypes {
  9419. if i.Insutype == "390" {
  9420. is390 = 1
  9421. }
  9422. if i.Insutype == "310" {
  9423. is310 = 1
  9424. }
  9425. }
  9426. }
  9427. if is390 == 1 {
  9428. insutype = "390"
  9429. }
  9430. if is310 == 1 {
  9431. insutype = "310"
  9432. }
  9433. if len(insutypes) == 0 {
  9434. insutype = "310"
  9435. }
  9436. service.CreateHisPsn(psn)
  9437. c.ServeSuccessJSON(map[string]interface{}{
  9438. "patient": patient,
  9439. "number": token,
  9440. "insutype": insutype,
  9441. })
  9442. }
  9443. } else {
  9444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9445. return
  9446. }
  9447. } else { //读卡失败
  9448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9449. return
  9450. }
  9451. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9452. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9453. if len(errMsg) == 0 {
  9454. type ELeData struct {
  9455. Data struct {
  9456. IdNo string `json:"idNo"`
  9457. IdType string `json:"idType"`
  9458. UserName string `json:"userName"`
  9459. EcToken string `json:"ecToken"`
  9460. InsuOrg string `json:"insuOrg"`
  9461. Gender string `json:"gender"`
  9462. Birthday string `json:"birthday"`
  9463. Nationality string `json:"nationality"`
  9464. Email string `json:"email"`
  9465. Extra string `json:"extra"`
  9466. } `json:"data"`
  9467. Code int `json:"code"`
  9468. Message string `json:"message"`
  9469. }
  9470. var ele ELeData
  9471. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9472. if err != nil {
  9473. utils.ErrorLog("解析失败:%v", err)
  9474. }
  9475. token := ele.Data.EcToken
  9476. if len(token) > 0 {
  9477. psn := &models.HisPsn{
  9478. PsnNo: his.PsnNo,
  9479. Age: 0,
  9480. PatientId: his.PatientId,
  9481. Certno: his.Certno,
  9482. Brdy: his.Brdy,
  9483. Gend: his.Gend,
  9484. Naty: his.Naty,
  9485. PsnCertType: his.PsnCertType,
  9486. PsnName: his.PsnName,
  9487. Idetinfo: his.Idetinfo,
  9488. Insuinfo: his.Iinfo,
  9489. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9490. CardInfo: outPutInfo,
  9491. VerifyNumber: token,
  9492. }
  9493. service.CreateHisPsn(psn)
  9494. }
  9495. if len(token) > 0 {
  9496. c.ServeSuccessJSON(map[string]interface{}{
  9497. "msg": "读取成功",
  9498. })
  9499. } else {
  9500. c.ServeSuccessJSON(map[string]interface{}{
  9501. "failed_code": -10,
  9502. "msg": "读取失败",
  9503. })
  9504. }
  9505. }
  9506. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9507. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9508. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9509. type ELeData struct {
  9510. Data struct {
  9511. IdNo string `json:"idNo"`
  9512. IdType string `json:"idType"`
  9513. UserName string `json:"userName"`
  9514. EcToken string `json:"ecToken"`
  9515. InsuOrg string `json:"insuOrg"`
  9516. Gender string `json:"gender"`
  9517. Birthday string `json:"birthday"`
  9518. Nationality string `json:"nationality"`
  9519. Email string `json:"email"`
  9520. Extra string `json:"extra"`
  9521. } `json:"data"`
  9522. Code int `json:"code"`
  9523. Message string `json:"message"`
  9524. }
  9525. var ele ELeData
  9526. err := json.Unmarshal([]byte(result), &ele)
  9527. if err != nil {
  9528. utils.ErrorLog("解析失败:%v", err)
  9529. }
  9530. token := ele.Data.EcToken
  9531. token = Remove0000(token)
  9532. fmt.Println(ele.Data.UserName)
  9533. 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)
  9534. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9535. var res ResultTwo
  9536. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9537. utils.ErrorLog("解析失败:%v", err)
  9538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9539. return
  9540. }
  9541. if res.Infcode == 0 {
  9542. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9543. if err == gorm.ErrRecordNotFound {
  9544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9545. return
  9546. } else if err != nil {
  9547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9548. return
  9549. } else {
  9550. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9551. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9552. infoStr := string(Iinfos)
  9553. idetinfoStr := string(Idetinfos)
  9554. psn := &models.HisPsn{
  9555. PsnNo: res.Output.Baseinfo.PsnNo,
  9556. PatientId: patient.ID,
  9557. Certno: res.Output.Baseinfo.Certno,
  9558. Gend: res.Output.Baseinfo.Gend,
  9559. Naty: res.Output.Baseinfo.Naty,
  9560. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9561. PsnName: res.Output.Baseinfo.PsnName,
  9562. Idetinfo: idetinfoStr,
  9563. Insuinfo: infoStr,
  9564. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9565. CardInfo: "",
  9566. VerifyNumber: token,
  9567. }
  9568. service.CreateHisPsn(psn)
  9569. c.ServeSuccessJSON(map[string]interface{}{
  9570. "patient": patient,
  9571. "number": token,
  9572. })
  9573. }
  9574. } else {
  9575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9576. return
  9577. }
  9578. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9579. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9580. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9581. type ELeData struct {
  9582. Data struct {
  9583. IdNo string `json:"idNo"`
  9584. IdType string `json:"idType"`
  9585. UserName string `json:"userName"`
  9586. EcToken string `json:"ecToken"`
  9587. InsuOrg string `json:"insuOrg"`
  9588. Gender string `json:"gender"`
  9589. Birthday string `json:"birthday"`
  9590. Nationality string `json:"nationality"`
  9591. Email string `json:"email"`
  9592. Extra string `json:"extra"`
  9593. } `json:"data"`
  9594. Code int `json:"code"`
  9595. Message string `json:"message"`
  9596. }
  9597. var ele ELeData
  9598. err := json.Unmarshal([]byte(result), &ele)
  9599. if err != nil {
  9600. utils.ErrorLog("解析失败:%v", err)
  9601. }
  9602. token := ele.Data.EcToken
  9603. token = Remove0000(token)
  9604. fmt.Println(ele.Data.UserName)
  9605. 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)
  9606. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9607. var res ResultTwo
  9608. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9609. utils.ErrorLog("解析失败:%v", err)
  9610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9611. return
  9612. }
  9613. if res.Infcode == 0 {
  9614. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9615. if err == gorm.ErrRecordNotFound {
  9616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9617. return
  9618. } else if err != nil {
  9619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9620. return
  9621. } else {
  9622. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9623. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9624. infoStr := string(Iinfos)
  9625. idetinfoStr := string(Idetinfos)
  9626. psn := &models.HisPsn{
  9627. PsnNo: res.Output.Baseinfo.PsnNo,
  9628. PatientId: patient.ID,
  9629. Certno: res.Output.Baseinfo.Certno,
  9630. Gend: res.Output.Baseinfo.Gend,
  9631. Naty: res.Output.Baseinfo.Naty,
  9632. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9633. PsnName: res.Output.Baseinfo.PsnName,
  9634. Idetinfo: idetinfoStr,
  9635. Insuinfo: infoStr,
  9636. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9637. CardInfo: "",
  9638. VerifyNumber: token,
  9639. }
  9640. service.CreateHisPsn(psn)
  9641. c.ServeSuccessJSON(map[string]interface{}{
  9642. "patient": patient,
  9643. "number": token,
  9644. })
  9645. }
  9646. } else {
  9647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9648. return
  9649. }
  9650. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9651. //if initFlag == 0 {
  9652. //c.TestGetJiangXiBasBaseInit()
  9653. //}
  9654. //if initEleFlag == 0 {
  9655. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9656. //}
  9657. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9658. utils.ErrorLog("解析失败:%v", json_result)
  9659. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9660. type ELeData struct {
  9661. Data struct {
  9662. IdNo string `json:"idNo"`
  9663. IdType string `json:"idType"`
  9664. UserName string `json:"userName"`
  9665. EcToken string `json:"ecToken"`
  9666. InsuOrg string `json:"insuOrg"`
  9667. Gender string `json:"gender"`
  9668. Birthday string `json:"birthday"`
  9669. Nationality string `json:"nationality"`
  9670. Email string `json:"email"`
  9671. Extra string `json:"extra"`
  9672. } `json:"data"`
  9673. Code int `json:"code"`
  9674. Message string `json:"message"`
  9675. }
  9676. var ele ELeData
  9677. err := json.Unmarshal([]byte(json_result), &ele)
  9678. if err != nil {
  9679. utils.ErrorLog("解析失败:%v", err)
  9680. }
  9681. token := ele.Data.EcToken
  9682. token = Remove0000(token)
  9683. //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)
  9684. 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)
  9685. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9686. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9687. var res ResultTwo
  9688. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9689. utils.ErrorLog("解析失败:%v", err)
  9690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9691. return
  9692. }
  9693. if res.Infcode == 0 {
  9694. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9695. if err == gorm.ErrRecordNotFound {
  9696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9697. return
  9698. } else if err != nil {
  9699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9700. return
  9701. } else {
  9702. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9703. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9704. infoStr := string(Iinfos)
  9705. idetinfoStr := string(Idetinfos)
  9706. psn := &models.HisPsn{
  9707. PsnNo: res.Output.Baseinfo.PsnNo,
  9708. PatientId: patient.ID,
  9709. Certno: res.Output.Baseinfo.Certno,
  9710. Gend: res.Output.Baseinfo.Gend,
  9711. Naty: res.Output.Baseinfo.Naty,
  9712. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9713. PsnName: res.Output.Baseinfo.PsnName,
  9714. Idetinfo: idetinfoStr,
  9715. Insuinfo: infoStr,
  9716. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9717. CardInfo: "",
  9718. VerifyNumber: token,
  9719. InsuplcAdmdvs: ele.Data.InsuOrg,
  9720. }
  9721. service.CreateHisPsn(psn)
  9722. c.ServeSuccessJSON(map[string]interface{}{
  9723. "patient": patient,
  9724. "number": token,
  9725. })
  9726. }
  9727. } else {
  9728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9729. return
  9730. }
  9731. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9732. res := c.GetoleInfo()
  9733. if res.Infcode == 0 {
  9734. var result string
  9735. if res.Output.MdtrtCertType == "01" {
  9736. 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)
  9737. } else if res.Output.MdtrtCertType == "02" {
  9738. 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)
  9739. } else if res.Output.MdtrtCertType == "03" {
  9740. 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)
  9741. }
  9742. var dat map[string]interface{}
  9743. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9744. fmt.Println(dat)
  9745. } else {
  9746. fmt.Println(err)
  9747. }
  9748. userJSONBytes, _ := json.Marshal(dat)
  9749. var res2 ResultTwo
  9750. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9751. utils.ErrorLog("解析失败:%v", err)
  9752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9753. return
  9754. }
  9755. if res2.Infcode == 0 {
  9756. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9757. if err == gorm.ErrRecordNotFound {
  9758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9759. return
  9760. } else if err != nil {
  9761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9762. return
  9763. } else {
  9764. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9765. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9766. infoStr := string(Iinfos)
  9767. idetinfoStr := string(Idetinfos)
  9768. var rf []*ResultFive
  9769. json.Unmarshal([]byte(infoStr), &rf)
  9770. var insutypes []*ResultFive
  9771. var insutype string
  9772. var is390 int = 0
  9773. var is310 int = 0
  9774. //var insuplc_admdvs string
  9775. for _, item := range rf {
  9776. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9777. insutypes = append(insutypes, item)
  9778. }
  9779. }
  9780. if len(insutypes) == 1 {
  9781. insutype = insutypes[0].Insutype
  9782. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9783. } else {
  9784. for _, i := range insutypes {
  9785. if i.Insutype == "390" {
  9786. is390 = 1
  9787. }
  9788. if i.Insutype == "310" {
  9789. is310 = 1
  9790. }
  9791. }
  9792. }
  9793. if is390 == 1 {
  9794. insutype = "390"
  9795. }
  9796. if is310 == 1 {
  9797. insutype = "310"
  9798. }
  9799. if len(insutypes) == 0 {
  9800. insutype = "310"
  9801. }
  9802. psn := &models.HisPsn{
  9803. PsnNo: res2.Output.Baseinfo.PsnNo,
  9804. PatientId: patient.ID,
  9805. Certno: res2.Output.Baseinfo.Certno,
  9806. Gend: res2.Output.Baseinfo.Gend,
  9807. Naty: res2.Output.Baseinfo.Naty,
  9808. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9809. PsnName: res2.Output.Baseinfo.PsnName,
  9810. Idetinfo: idetinfoStr,
  9811. Insuinfo: infoStr,
  9812. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9813. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9814. VerifyNumber: res.Output.EcToken,
  9815. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9816. }
  9817. service.CreateHisPsn(psn)
  9818. c.ServeSuccessJSON(map[string]interface{}{
  9819. "patient": patient,
  9820. "number": res.Output.CardNo,
  9821. "insutype": insutype,
  9822. })
  9823. }
  9824. } else {
  9825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9826. return
  9827. }
  9828. } else {
  9829. c.ServeSuccessJSON(map[string]interface{}{
  9830. "failed_code": -10,
  9831. "msg": res.ErrMsg,
  9832. })
  9833. }
  9834. } else {
  9835. //if initFlag == 0 {
  9836. // c.TestGetBasBaseInit()
  9837. //}
  9838. //token := c.GetEleBaseInfo()
  9839. //token = Remove0000(token)
  9840. type ELeData struct {
  9841. Code string `json:"code"`
  9842. Data struct {
  9843. Aac002 string `json:"aac002"`
  9844. Aaz500 string `json:"aaz500"`
  9845. ActCardNo string `json:"actCardNo"`
  9846. Bab520 string `json:"bab520"`
  9847. Bkz543 string `json:"bkz543"`
  9848. BusinessType string `json:"businessType"`
  9849. CertfCodg string `json:"certfCodg"`
  9850. EcIndexNo string `json:"ecIndexNo"`
  9851. EcToken string `json:"ecToken"`
  9852. ID0000 string `json:"id0000"`
  9853. IDNo string `json:"idNo"`
  9854. IDType string `json:"idType"`
  9855. Idcode string `json:"idcode"`
  9856. IdentityToken string `json:"identity_token"`
  9857. InsuOrg string `json:"insuOrg"`
  9858. OfficeID string `json:"officeId"`
  9859. OfficeName string `json:"officeName"`
  9860. OperatorID string `json:"operatorId"`
  9861. OperatorName string `json:"operatorName"`
  9862. OrgID string `json:"orgId"`
  9863. UserName string `json:"userName"`
  9864. } `json:"data"`
  9865. Infno interface{} `json:"infno"`
  9866. Message string `json:"message"`
  9867. OrgID string `json:"orgId"`
  9868. TransType string `json:"transType"`
  9869. }
  9870. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9871. fmt.Println(result)
  9872. outPutInfo := Remove0000(result)
  9873. fmt.Println(outPutInfo)
  9874. var ele ELeData
  9875. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9876. if err != nil {
  9877. utils.ErrorLog("解析失败:%v", err)
  9878. }
  9879. token := ele.Data.EcToken
  9880. var result2 string
  9881. var requestLog2 string
  9882. if len(token) > 0 {
  9883. if strings.Contains(ele.Data.IDNo, "HKG") {
  9884. 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)
  9885. } else {
  9886. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9887. }
  9888. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9889. var res ResultTwo
  9890. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9891. utils.ErrorLog("解析失败:%v", err)
  9892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9893. return
  9894. }
  9895. if res.Infcode == 0 {
  9896. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9897. if err == gorm.ErrRecordNotFound {
  9898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9899. return
  9900. } else if err != nil {
  9901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9902. return
  9903. } else {
  9904. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9905. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9906. infoStr := string(Iinfos)
  9907. idetinfoStr := string(Idetinfos)
  9908. psn := &models.HisPsn{
  9909. PsnNo: res.Output.Baseinfo.PsnNo,
  9910. PatientId: patient.ID,
  9911. Certno: res.Output.Baseinfo.Certno,
  9912. Gend: res.Output.Baseinfo.Gend,
  9913. Naty: res.Output.Baseinfo.Naty,
  9914. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9915. PsnName: res.Output.Baseinfo.PsnName,
  9916. Idetinfo: idetinfoStr,
  9917. Insuinfo: infoStr,
  9918. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9919. CardInfo: "",
  9920. VerifyNumber: token,
  9921. }
  9922. service.CreateHisPsn(psn)
  9923. c.ServeSuccessJSON(map[string]interface{}{
  9924. "msg": "读取成功",
  9925. })
  9926. }
  9927. } else {
  9928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9929. return
  9930. }
  9931. } else {
  9932. c.ServeSuccessJSON(map[string]interface{}{
  9933. "failed_code": -10,
  9934. "msg": "读取失败",
  9935. })
  9936. }
  9937. }
  9938. }
  9939. func (c *HisApiController) ReadEleFace() {
  9940. admin_user_id, _ := c.GetInt64("admin_user_id")
  9941. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9942. adminUser := c.GetAdminUserInfo()
  9943. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9944. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9945. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9946. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9947. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9948. if len(tokens) > 0 {
  9949. c.ServeSuccessJSON(map[string]interface{}{
  9950. "msg": "读取成功",
  9951. })
  9952. } else {
  9953. c.ServeSuccessJSON(map[string]interface{}{
  9954. "failed_code": -10,
  9955. "msg": "读取失败",
  9956. })
  9957. }
  9958. }
  9959. }
  9960. func (c *HisApiController) Get9001() {
  9961. adminUser := c.GetAdminUserInfo()
  9962. admin_user_id, _ := c.GetInt64("admin_user_id")
  9963. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9964. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9965. if miConfig.MdtrtareaAdmvs == "350500" {
  9966. service.GetFjAuthorizationInfo(miConfig.Code)
  9967. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9968. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9969. var dat map[string]interface{}
  9970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9971. fmt.Println(dat)
  9972. } else {
  9973. fmt.Println(err)
  9974. }
  9975. userJSONBytes, _ := json.Marshal(dat)
  9976. var res models.Result9001
  9977. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9978. utils.ErrorLog("解析失败:%v", err)
  9979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9980. return
  9981. }
  9982. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9983. fmt.Println(miConfig.SecretKey)
  9984. var res models.Result9001Two
  9985. 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 +
  9986. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9987. resp, requestErr := http.Get(api)
  9988. if requestErr != nil {
  9989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9990. return
  9991. }
  9992. body, ioErr := ioutil.ReadAll(resp.Body)
  9993. if ioErr != nil {
  9994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9996. return
  9997. }
  9998. var respJSON map[string]interface{}
  9999. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10002. return
  10003. }
  10004. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10005. if status == "0" {
  10006. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10007. c.ServeSuccessJSON(map[string]interface{}{
  10008. "failed_code": -10,
  10009. "msg": err_msg,
  10010. })
  10011. return
  10012. }
  10013. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10014. result, _ := json.Marshal(respJSON)
  10015. fmt.Println("log")
  10016. fmt.Println(string(result))
  10017. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10018. utils.ErrorLog("解析失败:%v", err)
  10019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10020. return
  10021. }
  10022. if res.Infcode == 0 {
  10023. sign := models.HisSignIn{
  10024. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10025. SignNo: res.Output.Signinoutb.SignNo,
  10026. SignTime: "",
  10027. Ctime: time.Now().Unix(),
  10028. Mtime: time.Now().Unix(),
  10029. Status: 1,
  10030. InputLog: "",
  10031. OutputLog: "",
  10032. FixmedinsCode: miConfig.Code,
  10033. }
  10034. err := service.CreateSignIn(&sign)
  10035. if err == nil {
  10036. c.ServeSuccessJSON(map[string]interface{}{
  10037. "msg": "签到成功",
  10038. })
  10039. }
  10040. } else {
  10041. c.ServeSuccessJSON(map[string]interface{}{
  10042. "failed_code": -10,
  10043. "msg": res.ErrMsg,
  10044. })
  10045. return
  10046. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10047. //return
  10048. }
  10049. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10050. fmt.Println(miConfig.SecretKey)
  10051. var res models.Result9001Two
  10052. 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 +
  10053. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10054. resp, requestErr := http.Get(api)
  10055. if requestErr != nil {
  10056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10057. return
  10058. }
  10059. body, ioErr := ioutil.ReadAll(resp.Body)
  10060. if ioErr != nil {
  10061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10063. return
  10064. }
  10065. var respJSON map[string]interface{}
  10066. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10069. return
  10070. }
  10071. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10072. if status == "0" {
  10073. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10074. c.ServeSuccessJSON(map[string]interface{}{
  10075. "failed_code": -10,
  10076. "msg": err_msg,
  10077. })
  10078. return
  10079. }
  10080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10081. result, _ := json.Marshal(respJSON)
  10082. fmt.Println("log")
  10083. fmt.Println(string(result))
  10084. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10085. utils.ErrorLog("解析失败:%v", err)
  10086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10087. return
  10088. }
  10089. if res.Infcode == 0 {
  10090. sign := models.HisSignIn{
  10091. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10092. SignNo: res.Output.Signinoutb.SignNo,
  10093. SignTime: "",
  10094. Ctime: time.Now().Unix(),
  10095. Mtime: time.Now().Unix(),
  10096. Status: 1,
  10097. InputLog: "",
  10098. OutputLog: "",
  10099. FixmedinsCode: miConfig.Code,
  10100. }
  10101. err := service.CreateSignIn(&sign)
  10102. if err == nil {
  10103. c.ServeSuccessJSON(map[string]interface{}{
  10104. "msg": "签到成功",
  10105. })
  10106. }
  10107. } else {
  10108. c.ServeSuccessJSON(map[string]interface{}{
  10109. "failed_code": -10,
  10110. "msg": res.ErrMsg,
  10111. })
  10112. return
  10113. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10114. //return
  10115. }
  10116. } else {
  10117. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10118. var dat map[string]interface{}
  10119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10120. fmt.Println(dat)
  10121. } else {
  10122. fmt.Println(err)
  10123. }
  10124. userJSONBytes, _ := json.Marshal(dat)
  10125. var res models.Result9001
  10126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10127. utils.ErrorLog("解析失败:%v", err)
  10128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10129. return
  10130. }
  10131. if res.Infcode == 0 {
  10132. sign := models.HisSignIn{
  10133. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10134. SignNo: res.Output.Signinoutb.SignNo,
  10135. SignTime: res.Output.Signinoutb.SignTime,
  10136. Ctime: time.Now().Unix(),
  10137. Mtime: time.Now().Unix(),
  10138. Status: 1,
  10139. InputLog: "",
  10140. OutputLog: "",
  10141. FixmedinsCode: miConfig.Code,
  10142. }
  10143. err := service.CreateSignIn(&sign)
  10144. if err == nil {
  10145. c.ServeSuccessJSON(map[string]interface{}{
  10146. "msg": "签到成功",
  10147. })
  10148. }
  10149. }
  10150. }
  10151. }
  10152. 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) {
  10153. var res Result3101
  10154. adminUser := c.GetAdminUserInfo()
  10155. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10156. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10157. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10158. //record_time := c.GetString("record_time")
  10159. //trig_scen := c.GetString("trig_scen")
  10160. timeLayout := "2006-01-02"
  10161. loc, _ := time.LoadLocation("Local")
  10162. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10163. if err != nil {
  10164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10165. return res
  10166. }
  10167. recordDateTime := theTime.Unix()
  10168. var patientPrescription models.HisPrescriptionInfo
  10169. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10170. //if patientPrescription.ID == 0 {
  10171. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10172. //}
  10173. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10174. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10175. //
  10176. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10177. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10178. var pp models.PublicParams
  10179. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10180. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10181. pp.FixmedinsName = miConfig.OrgName
  10182. pp.FixmedinsCode = miConfig.Code
  10183. pp.RequestUrl = miConfig.Url
  10184. pp.Cainfo = miConfig.Cainfo
  10185. pp.SecretKey = miConfig.SecretKey
  10186. pp.AccessKey = miConfig.AccessKey
  10187. pp.OpterName = roles.UserName
  10188. var config []*models.HisXtDiagnoseConfig
  10189. for _, item := range diagnosis_ids {
  10190. id, _ := strconv.ParseInt(item, 10, 64)
  10191. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10192. config = append(config, &diagnosisConfig)
  10193. }
  10194. var pd models.PatientDtos
  10195. pd.PatnID = his.PsnNo
  10196. pd.PatnName = his.Name
  10197. pd.Gend = his.Gend
  10198. pd.Brdy = his.Brdy
  10199. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10200. pd.CurrMdtrtID = his.Number
  10201. var fed models.FsiEncounterDtos
  10202. fed.MdtrtID = his.Number
  10203. fed.MedinsID = miConfig.Code
  10204. fed.MedinsName = miConfig.OrgName
  10205. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10206. fed.MedMdtrtType = "1"
  10207. fed.MedinsType = "1"
  10208. fed.MedinsLv = "11"
  10209. tm := time.Unix(his.RecordDate, 0)
  10210. s_tm := tm.Format("2006-01-02 15:04:05")
  10211. fed.AdmDate = s_tm
  10212. fed.DscgDate = s_tm
  10213. fed.DscgMainDiseCodg = config[0].CountryCode
  10214. fed.DscgMainDiseName = config[0].CountryContentName
  10215. //诊断信息
  10216. var fdds []*models.FsiDiagnoseDtos
  10217. for index, item := range config {
  10218. if index == 0 {
  10219. var fdd models.FsiDiagnoseDtos
  10220. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10221. fdd.InoutDiseType = "1"
  10222. fdd.MaindiseFlag = "1"
  10223. fdd.DiseDate = s_tm
  10224. fdd.DiasSrtNo = "1"
  10225. fdd.DiseName = item.CountryContentName
  10226. fdd.DiseCodg = item.CountryCode
  10227. fdds = append(fdds, &fdd)
  10228. } else {
  10229. var fdd models.FsiDiagnoseDtos
  10230. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10231. fdd.InoutDiseType = "1"
  10232. fdd.MaindiseFlag = "1"
  10233. fdd.DiseDate = s_tm
  10234. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10235. fdd.DiseName = item.CountryContentName
  10236. fdd.DiseCodg = item.CountryCode
  10237. fdds = append(fdds, &fdd)
  10238. }
  10239. }
  10240. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10241. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10242. fed.AdmDeptName = de.Name
  10243. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10244. fed.DscgDeptName = de.Name
  10245. fed.MedMdtrtType = "1"
  10246. fed.MedType = "11"
  10247. //if his.Insutype == "390" {
  10248. // fed.MedType = "1402"
  10249. //} else {
  10250. // fed.MedType = "9933"
  10251. //}
  10252. var orders []*models.FsiOrderDtos
  10253. if trig_scen == "2" {
  10254. //处方医嘱信息
  10255. for _, item := range prescriptions {
  10256. for _, subItem := range item.HisDoctorAdviceInfo {
  10257. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10258. var order models.FsiOrderDtos
  10259. order.RxID = strconv.FormatInt(item.ID, 10)
  10260. order.Rxno = strconv.FormatInt(item.ID, 10)
  10261. order.LongDrordFlag = "0"
  10262. order.HilistType = "1"
  10263. order.ChrgType = "1"
  10264. order.DrordBhvr = "-"
  10265. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10266. order.HosplistName = subItem.BaseDrugLib.DrugName
  10267. order.HilistLv = "1"
  10268. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10269. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10270. order.HosplistName = subItem.BaseDrugLib.DrugName
  10271. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10272. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10273. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10274. order.OwnpayAmt = ""
  10275. order.SelfpayAmt = ""
  10276. order.Spec = ""
  10277. order.SpecUnt = ""
  10278. order.DrordBegnDate = s_tm
  10279. order.DrordStopDate = ""
  10280. order.DrordDrCodg = doctor_info.DoctorNumber
  10281. order.DrordDeptName = department.Name
  10282. order.DrordDeptCodg = department.Number
  10283. order.DrordDrName = doctor_info.UserName
  10284. order.DrordDrProfttl = "234"
  10285. order.CurrDrordFlag = "1"
  10286. orders = append(orders, &order)
  10287. }
  10288. }
  10289. for _, subItem := range item.HisPrescriptionProject {
  10290. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10291. var order models.FsiOrderDtos
  10292. order.RxID = strconv.FormatInt(item.ID, 10)
  10293. order.Rxno = strconv.FormatInt(item.ID, 10)
  10294. order.LongDrordFlag = "0"
  10295. order.HilistType = "1"
  10296. order.ChrgType = "1"
  10297. order.DrordBhvr = "-"
  10298. order.HilistCode = subItem.HisProject.MedicalCode
  10299. order.HosplistName = subItem.HisProject.ProjectName
  10300. order.HilistLv = "1"
  10301. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10302. order.HosplistCode = subItem.HisProject.MedicalCode
  10303. order.HosplistName = subItem.HisProject.ProjectName
  10304. order.Cnt = subItem.Count
  10305. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10306. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10307. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10308. order.OwnpayAmt = ""
  10309. order.SelfpayAmt = ""
  10310. order.Spec = ""
  10311. order.SpecUnt = ""
  10312. order.DrordBegnDate = s_tm
  10313. order.DrordStopDate = ""
  10314. order.DrordDrCodg = doctor_info.DoctorNumber
  10315. order.DrordDeptName = department.Name
  10316. order.DrordDeptCodg = department.Number
  10317. order.DrordDrName = doctor_info.UserName
  10318. order.DrordDrProfttl = "234"
  10319. order.CurrDrordFlag = "1"
  10320. orders = append(orders, &order)
  10321. }
  10322. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10323. var order models.FsiOrderDtos
  10324. order.RxID = strconv.FormatInt(item.ID, 10)
  10325. order.Rxno = strconv.FormatInt(item.ID, 10)
  10326. order.LongDrordFlag = "0"
  10327. order.HilistType = "1"
  10328. order.ChrgType = "1"
  10329. order.DrordBhvr = "-"
  10330. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10331. order.HosplistName = subItem.GoodInfo.GoodName
  10332. order.HilistLv = "1"
  10333. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10334. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10335. order.HosplistName = subItem.GoodInfo.GoodName
  10336. order.Cnt = subItem.Count
  10337. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10338. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10339. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10340. order.OwnpayAmt = ""
  10341. order.SelfpayAmt = ""
  10342. order.Spec = ""
  10343. order.SpecUnt = ""
  10344. order.DrordBegnDate = s_tm
  10345. order.DrordStopDate = ""
  10346. order.DrordDrCodg = doctor_info.DoctorNumber
  10347. order.DrordDeptName = department.Name
  10348. order.DrordDeptCodg = department.Number
  10349. order.DrordDrName = doctor_info.UserName
  10350. order.DrordDrProfttl = "234"
  10351. order.CurrDrordFlag = "1"
  10352. orders = append(orders, &order)
  10353. }
  10354. }
  10355. }
  10356. //处方医嘱信息
  10357. }
  10358. fed.MatnStas = "0"
  10359. fed.MedfeeSumamt = "0"
  10360. fed.OwnpayAmt = "0"
  10361. fed.SelfpayAmt = "0"
  10362. fed.AcctPayamt = "0"
  10363. fed.MaAmt = "0"
  10364. fed.HifpPayamt = "0"
  10365. fed.SetlTotlnum = "1"
  10366. fed.Insutype = his.Insutype
  10367. fed.ReimFlag = "0"
  10368. fed.OutSetlFlag = "0"
  10369. var fopd []*models.FsiOperationDtosData
  10370. data := make(map[string]interface{})
  10371. data["fed"] = fed
  10372. data["fdd"] = fdds
  10373. data["fod"] = orders
  10374. data["pd"] = pd
  10375. data["pp"] = pp
  10376. data["fopd"] = fopd
  10377. data["trig_scen"] = trig_scen
  10378. fmt.Println(data)
  10379. fmt.Println(fed)
  10380. fmt.Println(fdds)
  10381. fmt.Println(orders)
  10382. fmt.Println(pd)
  10383. fmt.Println(pp)
  10384. fmt.Println(fopd)
  10385. client := &http.Client{}
  10386. bytesData, _ := json.Marshal(data)
  10387. var req *http.Request
  10388. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10389. if miConfig.MdtrtareaAdmvs == "320921" {
  10390. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10391. } else {
  10392. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10393. }
  10394. resp, _ := client.Do(req)
  10395. defer resp.Body.Close()
  10396. body, ioErr := ioutil.ReadAll(resp.Body)
  10397. if ioErr != nil {
  10398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10400. return res
  10401. }
  10402. var respJSON map[string]interface{}
  10403. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10406. return res
  10407. }
  10408. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10409. fmt.Println(respJSON)
  10410. result, _ := json.Marshal(respJSON)
  10411. fmt.Println(result)
  10412. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10413. utils.ErrorLog("解析失败:%v", err)
  10414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10415. return res
  10416. }
  10417. return res
  10418. } else {
  10419. //if miConfig.MdtrtareaAdmvs == "441202" {
  10420. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10421. saveLog(output, input, "3101", "事前")
  10422. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10423. utils.ErrorLog("解析失败:%v", err)
  10424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10425. return
  10426. }
  10427. return res
  10428. //}
  10429. }
  10430. }
  10431. 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) {
  10432. adminUser := c.GetAdminUserInfo()
  10433. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10434. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10435. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10436. //record_time := c.GetString("record_time")
  10437. //trig_scen := c.GetString("trig_scen")
  10438. timeLayout := "2006-01-02"
  10439. loc, _ := time.LoadLocation("Local")
  10440. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10441. if err != nil {
  10442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10443. return res
  10444. }
  10445. recordDateTime := theTime.Unix()
  10446. var patientPrescription models.HisPrescriptionInfo
  10447. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10448. if patientPrescription.ID == 0 {
  10449. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10450. }
  10451. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10452. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10453. //
  10454. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10455. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10456. var pp models.PublicParams
  10457. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10458. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10459. pp.FixmedinsName = miConfig.OrgName
  10460. pp.FixmedinsCode = miConfig.Code
  10461. pp.RequestUrl = miConfig.Url
  10462. pp.Cainfo = miConfig.Cainfo
  10463. pp.SecretKey = miConfig.SecretKey
  10464. pp.AccessKey = miConfig.AccessKey
  10465. pp.OpterName = roles.UserName
  10466. var config []*models.HisXtDiagnoseConfig
  10467. for _, item := range diagnosis_ids {
  10468. id, _ := strconv.ParseInt(item, 10, 64)
  10469. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10470. config = append(config, &diagnosisConfig)
  10471. }
  10472. var pd models.PatientDtos
  10473. pd.PatnID = his.PsnNo
  10474. pd.PatnName = his.Name
  10475. pd.Gend = his.Gend
  10476. pd.Brdy = his.Brdy
  10477. pd.Poolarea = his.InsuplcAdmdvs
  10478. pd.CurrMdtrtID = his.Number
  10479. var fed models.FsiEncounterDtos
  10480. fed.MdtrtID = his.Number
  10481. fed.MedinsID = miConfig.Code
  10482. fed.MedinsName = miConfig.OrgName
  10483. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10484. fed.MedMdtrtType = "1"
  10485. fed.MedinsType = "1"
  10486. fed.MedinsLv = "11"
  10487. tm := time.Unix(his.RecordDate, 0)
  10488. s_tm := tm.Format("2006-01-02 15:04:05")
  10489. fed.AdmDate = s_tm
  10490. fed.DscgDate = s_tm
  10491. fed.DscgMainDiseCodg = config[0].CountryCode
  10492. fed.DscgMainDiseName = config[0].CountryContentName
  10493. //诊断信息
  10494. var fdds []*models.FsiDiagnoseDtos
  10495. for index, item := range config {
  10496. if index == 0 {
  10497. var fdd models.FsiDiagnoseDtos
  10498. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10499. fdd.InoutDiseType = "1"
  10500. fdd.MaindiseFlag = "1"
  10501. fdd.DiseDate = s_tm
  10502. fdd.DiasSrtNo = "1"
  10503. fdd.DiseName = item.CountryContentName
  10504. fdd.DiseCodg = item.CountryCode
  10505. fdds = append(fdds, &fdd)
  10506. } else {
  10507. var fdd models.FsiDiagnoseDtos
  10508. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10509. fdd.InoutDiseType = "1"
  10510. fdd.MaindiseFlag = "1"
  10511. fdd.DiseDate = s_tm
  10512. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10513. fdd.DiseName = item.CountryContentName
  10514. fdd.DiseCodg = item.CountryCode
  10515. fdds = append(fdds, &fdd)
  10516. }
  10517. }
  10518. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10519. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10520. fed.AdmDeptName = department.Name
  10521. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10522. fed.DscgDeptName = department.Name
  10523. fed.MedMdtrtType = "1"
  10524. fed.MedType = "11"
  10525. //if his.Insutype == "390" {
  10526. // fed.MedType = "1402"
  10527. //} else {
  10528. // fed.MedType = "9933"
  10529. //}
  10530. var orders []*models.FsiOrderDtos
  10531. if trig_scen == "2" {
  10532. //处方医嘱信息
  10533. for _, item := range prescriptions {
  10534. for _, subItem := range item.HisDoctorAdviceInfo {
  10535. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10536. var order models.FsiOrderDtos
  10537. order.RxID = strconv.FormatInt(item.ID, 10)
  10538. order.Rxno = strconv.FormatInt(item.ID, 10)
  10539. order.LongDrordFlag = "0"
  10540. order.HilistType = "1"
  10541. order.ChrgType = "1"
  10542. order.DrordBhvr = "-"
  10543. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10544. order.HosplistName = subItem.BaseDrugLib.DrugName
  10545. order.HilistLv = "1"
  10546. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10547. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10548. order.HosplistName = subItem.BaseDrugLib.DrugName
  10549. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10550. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10551. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10552. order.OwnpayAmt = ""
  10553. order.SelfpayAmt = ""
  10554. order.Spec = ""
  10555. order.SpecUnt = ""
  10556. order.DrordBegnDate = s_tm
  10557. order.DrordStopDate = ""
  10558. order.DrordDrCodg = doctor_info.DoctorNumber
  10559. order.DrordDeptName = department.Name
  10560. order.DrordDeptCodg = department.Number
  10561. order.DrordDrName = doctor_info.UserName
  10562. order.DrordDrProfttl = "234"
  10563. order.CurrDrordFlag = "1"
  10564. orders = append(orders, &order)
  10565. }
  10566. }
  10567. for _, subItem := range item.HisPrescriptionProject {
  10568. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10569. var order models.FsiOrderDtos
  10570. order.RxID = strconv.FormatInt(item.ID, 10)
  10571. order.Rxno = strconv.FormatInt(item.ID, 10)
  10572. order.LongDrordFlag = "0"
  10573. order.HilistType = "1"
  10574. order.ChrgType = "1"
  10575. order.DrordBhvr = "-"
  10576. order.HilistCode = subItem.HisProject.MedicalCode
  10577. order.HosplistName = subItem.HisProject.ProjectName
  10578. order.HilistLv = "1"
  10579. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10580. order.HosplistCode = subItem.HisProject.MedicalCode
  10581. order.HosplistName = subItem.HisProject.ProjectName
  10582. order.Cnt = subItem.Count
  10583. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10584. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10585. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10586. order.OwnpayAmt = ""
  10587. order.SelfpayAmt = ""
  10588. order.Spec = ""
  10589. order.SpecUnt = ""
  10590. order.DrordBegnDate = s_tm
  10591. order.DrordStopDate = ""
  10592. order.DrordDrCodg = doctor_info.DoctorNumber
  10593. order.DrordDeptName = department.Name
  10594. order.DrordDeptCodg = department.Number
  10595. order.DrordDrName = doctor_info.UserName
  10596. order.DrordDrProfttl = "234"
  10597. order.CurrDrordFlag = "1"
  10598. orders = append(orders, &order)
  10599. }
  10600. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10601. var order models.FsiOrderDtos
  10602. order.RxID = strconv.FormatInt(item.ID, 10)
  10603. order.Rxno = strconv.FormatInt(item.ID, 10)
  10604. order.LongDrordFlag = "0"
  10605. order.HilistType = "1"
  10606. order.ChrgType = "1"
  10607. order.DrordBhvr = "-"
  10608. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10609. order.HosplistName = subItem.GoodInfo.GoodName
  10610. order.HilistLv = "1"
  10611. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10612. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10613. order.HosplistName = subItem.GoodInfo.GoodName
  10614. order.Cnt = subItem.Count
  10615. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10616. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10617. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10618. order.OwnpayAmt = ""
  10619. order.SelfpayAmt = ""
  10620. order.Spec = ""
  10621. order.SpecUnt = ""
  10622. order.DrordBegnDate = s_tm
  10623. order.DrordStopDate = ""
  10624. order.DrordDrCodg = doctor_info.DoctorNumber
  10625. order.DrordDeptName = department.Name
  10626. order.DrordDeptCodg = department.Number
  10627. order.DrordDrName = doctor_info.UserName
  10628. order.DrordDrProfttl = "234"
  10629. order.CurrDrordFlag = "1"
  10630. orders = append(orders, &order)
  10631. }
  10632. }
  10633. }
  10634. //处方医嘱信息
  10635. }
  10636. fed.MatnStas = "0"
  10637. fed.MedfeeSumamt = "0"
  10638. fed.OwnpayAmt = "0"
  10639. fed.SelfpayAmt = "0"
  10640. fed.AcctPayamt = "0"
  10641. fed.MaAmt = "0"
  10642. fed.HifpPayamt = "0"
  10643. fed.SetlTotlnum = "1"
  10644. fed.Insutype = his.Insutype
  10645. fed.ReimFlag = "0"
  10646. fed.OutSetlFlag = "0"
  10647. var fopd []*models.FsiOperationDtosData
  10648. data := make(map[string]interface{})
  10649. data["fed"] = fed
  10650. data["fdd"] = fdds
  10651. data["fod"] = orders
  10652. data["pd"] = pd
  10653. data["pp"] = pp
  10654. data["fopd"] = fopd
  10655. data["trig_scen"] = trig_scen
  10656. fmt.Println(data)
  10657. fmt.Println(fed)
  10658. fmt.Println(fdds)
  10659. fmt.Println(orders)
  10660. fmt.Println(pd)
  10661. fmt.Println(pp)
  10662. fmt.Println(fopd)
  10663. client := &http.Client{}
  10664. bytesData, _ := json.Marshal(data)
  10665. var req *http.Request
  10666. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10667. if miConfig.MdtrtareaAdmvs == "320921" {
  10668. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10669. } else {
  10670. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10671. }
  10672. resp, _ := client.Do(req)
  10673. defer resp.Body.Close()
  10674. body, ioErr := ioutil.ReadAll(resp.Body)
  10675. if ioErr != nil {
  10676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10678. return res
  10679. }
  10680. var respJSON map[string]interface{}
  10681. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10684. return res
  10685. }
  10686. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10687. fmt.Println(respJSON)
  10688. result, _ := json.Marshal(respJSON)
  10689. fmt.Println(result)
  10690. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10691. utils.ErrorLog("解析失败:%v", err)
  10692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10693. return res
  10694. }
  10695. return res
  10696. } else {
  10697. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10698. saveLog(output, input, "3101", "事前")
  10699. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10700. utils.ErrorLog("解析失败:%v", err)
  10701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10702. return
  10703. }
  10704. return res
  10705. }
  10706. return res
  10707. }
  10708. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10709. ////patient_id, _ := c.GetInt64("patient_id")
  10710. //order_id, _ := c.GetInt64("order_id")
  10711. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10712. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10713. //trig_scen := c.GetString("trig_scen")
  10714. adminUser := c.GetAdminUserInfo()
  10715. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10716. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10717. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10718. record_time := c.GetString("record_time")
  10719. order, _ := service.GetHisOrderByID(order_id)
  10720. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10721. timeLayout := "2006-01-02"
  10722. loc, _ := time.LoadLocation("Local")
  10723. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10724. if err != nil {
  10725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10726. return
  10727. }
  10728. recordDateTime := theTime.Unix()
  10729. var patientPrescription models.HisPrescriptionInfo
  10730. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10731. if patientPrescription.ID == 0 {
  10732. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10733. }
  10734. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10735. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10736. //
  10737. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10738. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10739. var pp models.PublicParams
  10740. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10741. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10742. pp.FixmedinsName = miConfig.OrgName
  10743. pp.FixmedinsCode = miConfig.Code
  10744. pp.RequestUrl = miConfig.Url
  10745. pp.Cainfo = miConfig.Cainfo
  10746. pp.SecretKey = miConfig.SecretKey
  10747. pp.AccessKey = miConfig.AccessKey
  10748. pp.OpterName = roles.UserName
  10749. var config []*models.HisXtDiagnoseConfig
  10750. for _, item := range diagnosis_ids {
  10751. id, _ := strconv.ParseInt(item, 10, 64)
  10752. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10753. config = append(config, &diagnosisConfig)
  10754. }
  10755. var pd models.PatientDtos
  10756. pd.PatnID = his.PsnNo
  10757. pd.PatnName = his.Name
  10758. pd.Gend = his.Gend
  10759. pd.Brdy = psn_info.Brdy
  10760. pd.Poolarea = his.InsuplcAdmdvs
  10761. pd.CurrMdtrtID = his.Number
  10762. var fed models.FsiEncounterDtos
  10763. fed.MdtrtID = his.Number
  10764. fed.MedinsID = miConfig.Code
  10765. fed.MedinsName = miConfig.OrgName
  10766. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10767. fed.MedMdtrtType = "1"
  10768. fed.MedinsType = "1"
  10769. fed.MedinsLv = "11"
  10770. tm := time.Unix(his.RecordDate, 0)
  10771. s_tm := tm.Format("2006-01-02 15:04:05")
  10772. fed.AdmDate = s_tm
  10773. fed.DscgDate = s_tm
  10774. fed.DscgMainDiseCodg = config[0].CountryCode
  10775. fed.DscgMainDiseName = config[0].CountryContentName
  10776. //诊断信息
  10777. var fdds []*models.FsiDiagnoseDtos
  10778. for index, item := range config {
  10779. if index == 0 {
  10780. var fdd models.FsiDiagnoseDtos
  10781. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10782. fdd.InoutDiseType = "1"
  10783. fdd.MaindiseFlag = "1"
  10784. fdd.DiseDate = s_tm
  10785. fdd.DiasSrtNo = "1"
  10786. fdd.DiseName = item.CountryContentName
  10787. fdd.DiseCodg = item.CountryCode
  10788. fdds = append(fdds, &fdd)
  10789. } else {
  10790. var fdd models.FsiDiagnoseDtos
  10791. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10792. fdd.InoutDiseType = "1"
  10793. fdd.MaindiseFlag = "1"
  10794. fdd.DiseDate = s_tm
  10795. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10796. fdd.DiseName = item.CountryContentName
  10797. fdd.DiseCodg = item.CountryCode
  10798. fdds = append(fdds, &fdd)
  10799. }
  10800. }
  10801. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10802. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10803. fed.AdmDeptName = department.Name
  10804. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10805. fed.DscgDeptName = department.Name
  10806. fed.MedType = order.MedType
  10807. //处方医嘱信息
  10808. var orders []*models.FsiOrderDtos
  10809. //for _, item := range prescriptions {
  10810. // for _, subItem := range item.HisDoctorAdviceInfo {
  10811. // var order models.FsiOrderDtos
  10812. // order.RxID = strconv.FormatInt(item.ID, 10)
  10813. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10814. // order.LongDrordFlag = "0"
  10815. // order.HilistType = "1"
  10816. // order.ChrgType = "1"
  10817. // order.DrordBhvr = "-"
  10818. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10819. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10820. // order.HilistLv = "1"
  10821. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10822. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10823. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10824. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10825. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10826. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10827. // order.OwnpayAmt = ""
  10828. // order.SelfpayAmt = ""
  10829. // order.Spec = ""
  10830. // order.SpecUnt = ""
  10831. // order.DrordBegnDate = s_tm
  10832. // order.DrordStopDate = ""
  10833. // order.DrordDrCodg = "1"
  10834. // order.DrordDeptName = department.Name
  10835. // order.DrordDrCodg = "1"
  10836. // order.DrordDrName = doctor_info.UserName
  10837. // order.DrordDrProfttl = ""
  10838. // order.CurrDrordFlag = "1"
  10839. // orders = append(orders, &order)
  10840. // }
  10841. // for _, subItem := range item.HisPrescriptionProject {
  10842. // if subItem.Type == 2 {
  10843. // var order models.FsiOrderDtos
  10844. // order.RxID = strconv.FormatInt(item.ID, 10)
  10845. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10846. // order.LongDrordFlag = "0"
  10847. // order.HilistType = "1"
  10848. // order.ChrgType = "1"
  10849. // order.DrordBhvr = "-"
  10850. // order.HilistCode = subItem.HisProject.MedicalCode
  10851. // order.HosplistName = subItem.HisProject.ProjectName
  10852. // order.HilistLv = "1"
  10853. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10854. // order.HosplistCode = subItem.HisProject.MedicalCode
  10855. // order.HosplistName = subItem.HisProject.ProjectName
  10856. // order.Cnt = subItem.Count
  10857. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10858. //
  10859. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10860. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10861. // order.OwnpayAmt = ""
  10862. // order.SelfpayAmt = ""
  10863. // order.Spec = ""
  10864. // order.SpecUnt = ""
  10865. // order.DrordBegnDate = s_tm
  10866. // order.DrordStopDate = ""
  10867. // order.DrordDrCodg = "1"
  10868. // order.DrordDeptName = department.Name
  10869. // order.DrordDrCodg = "1"
  10870. // order.DrordDrName = doctor_info.UserName
  10871. // order.DrordDrProfttl = ""
  10872. // order.CurrDrordFlag = "1"
  10873. // orders = append(orders, &order)
  10874. //
  10875. // }
  10876. // if subItem.Type == 3 {
  10877. //
  10878. // var order models.FsiOrderDtos
  10879. // order.RxID = strconv.FormatInt(item.ID, 10)
  10880. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10881. // order.LongDrordFlag = "0"
  10882. // order.HilistType = "1"
  10883. // order.ChrgType = "1"
  10884. // order.DrordBhvr = "-"
  10885. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10886. // order.HosplistName = subItem.GoodInfo.GoodName
  10887. // order.HilistLv = "1"
  10888. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10889. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10890. // order.HosplistName = subItem.GoodInfo.GoodName
  10891. // order.Cnt = subItem.Count
  10892. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10893. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10894. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10895. // order.OwnpayAmt = ""
  10896. // order.SelfpayAmt = ""
  10897. // order.Spec = ""
  10898. // order.SpecUnt = ""
  10899. // order.DrordBegnDate = s_tm
  10900. // order.DrordStopDate = ""
  10901. // order.DrordDrCodg = "1"
  10902. // order.DrordDeptName = department.Name
  10903. // order.DrordDrCodg = "1"
  10904. // order.DrordDrName = doctor_info.UserName
  10905. // order.DrordDrProfttl = ""
  10906. // order.CurrDrordFlag = "1"
  10907. // orders = append(orders, &order)
  10908. //
  10909. // }
  10910. // }
  10911. //}
  10912. for _, item := range prescriptions {
  10913. for _, subItem := range item.HisDoctorAdviceInfo {
  10914. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10915. var order models.FsiOrderDtos
  10916. order.RxID = strconv.FormatInt(item.ID, 10)
  10917. order.Rxno = strconv.FormatInt(item.ID, 10)
  10918. order.LongDrordFlag = "0"
  10919. order.HilistType = "1"
  10920. order.ChrgType = "1"
  10921. order.DrordBhvr = "-"
  10922. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10923. order.HosplistName = subItem.BaseDrugLib.DrugName
  10924. order.HilistLv = "1"
  10925. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10926. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10927. order.HosplistName = subItem.BaseDrugLib.DrugName
  10928. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10929. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10930. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10931. order.OwnpayAmt = ""
  10932. order.SelfpayAmt = ""
  10933. order.Spec = ""
  10934. order.SpecUnt = ""
  10935. order.DrordBegnDate = s_tm
  10936. order.DrordStopDate = ""
  10937. order.DrordDrCodg = doctor_info.DoctorNumber
  10938. order.DrordDeptName = department.Name
  10939. order.DrordDeptCodg = department.Number
  10940. order.DrordDrName = doctor_info.UserName
  10941. order.DrordDrProfttl = "234"
  10942. order.CurrDrordFlag = "1"
  10943. orders = append(orders, &order)
  10944. }
  10945. }
  10946. for _, subItem := range item.HisPrescriptionProject {
  10947. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10948. var order models.FsiOrderDtos
  10949. order.RxID = strconv.FormatInt(item.ID, 10)
  10950. order.Rxno = strconv.FormatInt(item.ID, 10)
  10951. order.LongDrordFlag = "0"
  10952. order.HilistType = "1"
  10953. order.ChrgType = "1"
  10954. order.DrordBhvr = "-"
  10955. order.HilistCode = subItem.HisProject.MedicalCode
  10956. order.HosplistName = subItem.HisProject.ProjectName
  10957. order.HilistLv = "1"
  10958. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10959. order.HosplistCode = subItem.HisProject.MedicalCode
  10960. order.HosplistName = subItem.HisProject.ProjectName
  10961. order.Cnt = subItem.Count
  10962. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10963. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10964. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10965. order.OwnpayAmt = ""
  10966. order.SelfpayAmt = ""
  10967. order.Spec = ""
  10968. order.SpecUnt = ""
  10969. order.DrordBegnDate = s_tm
  10970. order.DrordStopDate = ""
  10971. order.DrordDrCodg = doctor_info.DoctorNumber
  10972. order.DrordDeptName = department.Name
  10973. order.DrordDeptCodg = department.Number
  10974. order.DrordDrName = doctor_info.UserName
  10975. order.DrordDrProfttl = "234"
  10976. order.CurrDrordFlag = "1"
  10977. orders = append(orders, &order)
  10978. }
  10979. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10980. var order models.FsiOrderDtos
  10981. order.RxID = strconv.FormatInt(item.ID, 10)
  10982. order.Rxno = strconv.FormatInt(item.ID, 10)
  10983. order.LongDrordFlag = "0"
  10984. order.HilistType = "1"
  10985. order.ChrgType = "1"
  10986. order.DrordBhvr = "0"
  10987. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10988. order.HosplistName = subItem.GoodInfo.GoodName
  10989. order.HilistLv = "1"
  10990. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10991. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10992. order.HosplistName = subItem.GoodInfo.GoodName
  10993. order.Cnt = subItem.Count
  10994. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10995. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10996. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10997. order.OwnpayAmt = ""
  10998. order.SelfpayAmt = ""
  10999. order.Spec = ""
  11000. order.SpecUnt = ""
  11001. order.DrordBegnDate = s_tm
  11002. order.DrordStopDate = ""
  11003. order.DrordDrCodg = doctor_info.DoctorNumber
  11004. order.DrordDeptName = department.Name
  11005. order.DrordDeptCodg = department.Number
  11006. order.DrordDrName = doctor_info.UserName
  11007. order.DrordDrProfttl = "234"
  11008. order.CurrDrordFlag = "1"
  11009. orders = append(orders, &order)
  11010. }
  11011. }
  11012. }
  11013. //处方医嘱信息
  11014. fed.MatnStas = "0"
  11015. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11016. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11017. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11018. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11019. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11020. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11021. fed.SetlTotlnum = "1"
  11022. fed.Insutype = his.Insutype
  11023. fed.ReimFlag = "0"
  11024. fed.OutSetlFlag = "0"
  11025. var fopd []*models.FsiOperationDtosData
  11026. data := make(map[string]interface{})
  11027. data["fed"] = fed
  11028. data["fdd"] = fdds
  11029. data["fod"] = orders
  11030. data["pd"] = pd
  11031. data["pp"] = pp
  11032. data["fopd"] = fopd
  11033. data["trig_scen"] = trig_scen
  11034. client := &http.Client{}
  11035. bytesData, _ := json.Marshal(data)
  11036. var req *http.Request
  11037. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11038. if miConfig.MdtrtareaAdmvs == "320921" {
  11039. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11040. } else {
  11041. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11042. }
  11043. resp, _ := client.Do(req)
  11044. defer resp.Body.Close()
  11045. body, ioErr := ioutil.ReadAll(resp.Body)
  11046. if ioErr != nil {
  11047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11049. return res
  11050. }
  11051. var respJSON map[string]interface{}
  11052. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11055. return res
  11056. }
  11057. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11058. result, _ := json.Marshal(respJSON)
  11059. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11060. utils.ErrorLog("解析失败:%v", err)
  11061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11062. return res
  11063. }
  11064. return res
  11065. } else {
  11066. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11067. saveLog(output, input, "3102", "事中")
  11068. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11069. utils.ErrorLog("解析失败:%v", err)
  11070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11071. return
  11072. }
  11073. return res
  11074. }
  11075. return res
  11076. }
  11077. 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) {
  11078. var res Resultgd3101
  11079. adminUser := c.GetAdminUserInfo()
  11080. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11081. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11082. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11083. //record_time := c.GetString("record_time")
  11084. //trig_scen := c.GetString("trig_scen")
  11085. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11086. //psn_info, _ := service.GetPatientId(patient_id)
  11087. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11088. timeLayout := "2006-01-02"
  11089. loc, _ := time.LoadLocation("Local")
  11090. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11091. if err != nil {
  11092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11093. return res
  11094. }
  11095. recordDateTime := theTime.Unix()
  11096. var patientPrescription models.HisPrescriptionInfo
  11097. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11098. //if patientPrescription.ID == 0 {
  11099. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11100. //}
  11101. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11102. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11103. //
  11104. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11105. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11106. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11107. var pp models.PublicParams
  11108. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11109. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11110. pp.FixmedinsName = miConfig.OrgName
  11111. pp.FixmedinsCode = miConfig.Code
  11112. pp.RequestUrl = miConfig.Url
  11113. pp.Cainfo = miConfig.Cainfo
  11114. pp.SecretKey = miConfig.SecretKey
  11115. pp.AccessKey = miConfig.AccessKey
  11116. pp.OpterName = roles.UserName
  11117. var config []*models.HisXtDiagnoseConfig
  11118. for _, item := range diagnosis_ids {
  11119. id, _ := strconv.ParseInt(item, 10, 64)
  11120. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11121. config = append(config, &diagnosisConfig)
  11122. }
  11123. var pd models.PatientDtos
  11124. pd.PatnID = his.PsnNo
  11125. pd.PatnName = his.Name
  11126. pd.Gend = his.Gend
  11127. pd.Brdy = str
  11128. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11129. pd.CurrMdtrtID = his.Number
  11130. var fed models.FsiEncounterDtos
  11131. fed.MdtrtID = his.Number
  11132. fed.MedinsID = miConfig.Code
  11133. fed.MedinsName = miConfig.OrgName
  11134. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11135. fed.MedMdtrtType = "1"
  11136. fed.MedinsType = "1"
  11137. fed.MedinsLv = "11"
  11138. tm := time.Unix(his.RecordDate, 0)
  11139. s_tm := tm.Format("2006-01-02 15:04:05")
  11140. fed.AdmDate = s_tm
  11141. fed.DscgDate = s_tm
  11142. fed.DscgMainDiseCodg = config[0].CountryCode
  11143. fed.DscgMainDiseName = config[0].CountryContentName
  11144. //诊断信息
  11145. var fdds []*models.FsiDiagnoseDtos
  11146. for index, item := range config {
  11147. if index == 0 {
  11148. var fdd models.FsiDiagnoseDtos
  11149. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11150. fdd.InoutDiseType = "1"
  11151. fdd.MaindiseFlag = "1"
  11152. fdd.DiseDate = s_tm
  11153. fdd.DiasSrtNo = "1"
  11154. fdd.DiseName = item.CountryContentName
  11155. fdd.DiseCodg = item.CountryCode
  11156. fdds = append(fdds, &fdd)
  11157. } else {
  11158. var fdd models.FsiDiagnoseDtos
  11159. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11160. fdd.InoutDiseType = "1"
  11161. fdd.MaindiseFlag = "1"
  11162. fdd.DiseDate = s_tm
  11163. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11164. fdd.DiseName = item.CountryContentName
  11165. fdd.DiseCodg = item.CountryCode
  11166. fdds = append(fdds, &fdd)
  11167. }
  11168. }
  11169. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11170. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11171. fed.AdmDeptName = de.Name
  11172. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11173. fed.DscgDeptName = de.Name
  11174. fed.MedMdtrtType = "1"
  11175. fed.MedType = "11"
  11176. //if his.Insutype == "390" {
  11177. // fed.MedType = "1402"
  11178. //} else {
  11179. // fed.MedType = "9933"
  11180. //}
  11181. var orders []*models.FsiOrderDtos
  11182. if trig_scen == "2" {
  11183. //处方医嘱信息
  11184. for _, item := range prescriptions {
  11185. for _, subItem := range item.HisDoctorAdviceInfo {
  11186. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11187. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11188. var order models.FsiOrderDtos
  11189. order.RxID = strconv.FormatInt(item.ID, 10)
  11190. order.Rxno = strconv.FormatInt(item.ID, 10)
  11191. order.LongDrordFlag = "0"
  11192. order.HilistType = "1"
  11193. order.ChrgType = "1"
  11194. order.DrordBhvr = "0"
  11195. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11196. order.HosplistName = subItem.BaseDrugLib.DrugName
  11197. order.HilistLv = "1"
  11198. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11199. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11200. order.HosplistName = subItem.BaseDrugLib.DrugName
  11201. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11202. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11203. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11204. order.OwnpayAmt = ""
  11205. order.SelfpayAmt = ""
  11206. order.Spec = spec
  11207. order.SpecUnt = subItem.PrescribingNumberUnit
  11208. order.DrordBegnDate = s_tm
  11209. order.DrordStopDate = ""
  11210. order.DrordDrCodg = doctor_info.DoctorNumber
  11211. order.DrordDeptName = department.Name
  11212. order.DrordDeptCodg = department.Number
  11213. order.DrordDrName = doctor_info.UserName
  11214. order.DrordDrProfttl = "234"
  11215. order.CurrDrordFlag = "1"
  11216. orders = append(orders, &order)
  11217. }
  11218. }
  11219. for _, subItem := range item.HisPrescriptionProject {
  11220. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11221. var order models.FsiOrderDtos
  11222. order.RxID = strconv.FormatInt(item.ID, 10)
  11223. order.Rxno = strconv.FormatInt(item.ID, 10)
  11224. order.LongDrordFlag = "0"
  11225. order.HilistType = "1"
  11226. order.ChrgType = "1"
  11227. order.DrordBhvr = "0"
  11228. order.HilistCode = subItem.HisProject.MedicalCode
  11229. order.HosplistName = subItem.HisProject.ProjectName
  11230. order.HilistLv = "1"
  11231. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11232. order.HosplistCode = subItem.HisProject.MedicalCode
  11233. order.HosplistName = subItem.HisProject.ProjectName
  11234. order.Cnt = subItem.Count
  11235. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11236. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11237. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11238. order.OwnpayAmt = ""
  11239. order.SelfpayAmt = ""
  11240. order.Spec = subItem.Unit
  11241. order.SpecUnt = subItem.Unit
  11242. order.DrordBegnDate = s_tm
  11243. order.DrordStopDate = ""
  11244. order.DrordDrCodg = doctor_info.DoctorNumber
  11245. order.DrordDeptName = department.Name
  11246. order.DrordDeptCodg = department.Number
  11247. order.DrordDrName = doctor_info.UserName
  11248. order.DrordDrProfttl = "234"
  11249. order.CurrDrordFlag = "1"
  11250. orders = append(orders, &order)
  11251. }
  11252. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11253. var order models.FsiOrderDtos
  11254. order.RxID = strconv.FormatInt(item.ID, 10)
  11255. order.Rxno = strconv.FormatInt(item.ID, 10)
  11256. order.LongDrordFlag = "0"
  11257. order.HilistType = "1"
  11258. order.ChrgType = "1"
  11259. order.DrordBhvr = "0"
  11260. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11261. order.HosplistName = subItem.GoodInfo.GoodName
  11262. order.HilistLv = "1"
  11263. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11264. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11265. order.HosplistName = subItem.GoodInfo.GoodName
  11266. order.Cnt = subItem.Count
  11267. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11268. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11269. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11270. order.OwnpayAmt = ""
  11271. order.SelfpayAmt = ""
  11272. order.Spec = subItem.GoodInfo.SpecificationName
  11273. order.SpecUnt = subItem.Unit
  11274. order.DrordBegnDate = s_tm
  11275. order.DrordStopDate = ""
  11276. order.DrordDrCodg = doctor_info.DoctorNumber
  11277. order.DrordDeptName = department.Name
  11278. order.DrordDeptCodg = department.Number
  11279. order.DrordDrName = doctor_info.UserName
  11280. order.DrordDrProfttl = "234"
  11281. order.CurrDrordFlag = "1"
  11282. orders = append(orders, &order)
  11283. }
  11284. }
  11285. }
  11286. //处方医嘱信息
  11287. }
  11288. fed.MatnStas = "0"
  11289. fed.MedfeeSumamt = "0"
  11290. fed.OwnpayAmt = "0"
  11291. fed.SelfpayAmt = "0"
  11292. fed.AcctPayamt = "0"
  11293. fed.MaAmt = "0"
  11294. fed.HifpPayamt = "0"
  11295. fed.SetlTotlnum = "1"
  11296. fed.Insutype = his.Insutype
  11297. fed.ReimFlag = "0"
  11298. fed.OutSetlFlag = "0"
  11299. var fopd []*models.FsiOperationDtosData
  11300. data := make(map[string]interface{})
  11301. data["fed"] = fed
  11302. data["fdd"] = fdds
  11303. data["fod"] = orders
  11304. data["pd"] = pd
  11305. data["pp"] = pp
  11306. data["fopd"] = fopd
  11307. data["trig_scen"] = trig_scen
  11308. fmt.Println(data)
  11309. fmt.Println(fed)
  11310. fmt.Println(fdds)
  11311. fmt.Println(orders)
  11312. fmt.Println(pd)
  11313. fmt.Println(pp)
  11314. fmt.Println(fopd)
  11315. client := &http.Client{}
  11316. bytesData, _ := json.Marshal(data)
  11317. var req *http.Request
  11318. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11319. if miConfig.MdtrtareaAdmvs == "320921" {
  11320. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11321. } else {
  11322. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11323. }
  11324. resp, _ := client.Do(req)
  11325. defer resp.Body.Close()
  11326. body, ioErr := ioutil.ReadAll(resp.Body)
  11327. if ioErr != nil {
  11328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11330. return res
  11331. }
  11332. var respJSON map[string]interface{}
  11333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11336. return res
  11337. }
  11338. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11339. fmt.Println(respJSON)
  11340. result, _ := json.Marshal(respJSON)
  11341. fmt.Println(result)
  11342. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11343. utils.ErrorLog("解析失败:%v", err)
  11344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11345. return res
  11346. }
  11347. return res
  11348. } else {
  11349. //if miConfig.MdtrtareaAdmvs == "441202" {
  11350. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11351. saveLog(output, input, "3101", "事前")
  11352. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11353. utils.ErrorLog("解析失败:%v", err)
  11354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11355. return
  11356. }
  11357. return res
  11358. //}
  11359. }
  11360. }
  11361. 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) {
  11362. adminUser := c.GetAdminUserInfo()
  11363. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11364. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11365. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11366. //record_time := c.GetString("record_time")
  11367. //trig_scen := c.GetString("trig_scen")
  11368. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11369. timeLayout := "2006-01-02"
  11370. loc, _ := time.LoadLocation("Local")
  11371. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11372. if err != nil {
  11373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11374. return res
  11375. }
  11376. recordDateTime := theTime.Unix()
  11377. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11378. var patientPrescription models.HisPrescriptionInfo
  11379. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11380. if patientPrescription.ID == 0 {
  11381. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11382. }
  11383. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11384. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11385. //
  11386. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11387. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11388. var pp models.PublicParams
  11389. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11390. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11391. pp.FixmedinsName = miConfig.OrgName
  11392. pp.FixmedinsCode = miConfig.Code
  11393. pp.RequestUrl = miConfig.Url
  11394. pp.Cainfo = miConfig.Cainfo
  11395. pp.SecretKey = miConfig.SecretKey
  11396. pp.AccessKey = miConfig.AccessKey
  11397. pp.OpterName = roles.UserName
  11398. var config []*models.HisXtDiagnoseConfig
  11399. for _, item := range diagnosis_ids {
  11400. id, _ := strconv.ParseInt(item, 10, 64)
  11401. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11402. config = append(config, &diagnosisConfig)
  11403. }
  11404. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11405. var pd models.PatientDtos
  11406. pd.PatnID = his.PsnNo
  11407. pd.PatnName = his.Name
  11408. pd.Gend = his.Gend
  11409. pd.Brdy = str
  11410. pd.Poolarea = his.InsuplcAdmdvs
  11411. pd.CurrMdtrtID = his.Number
  11412. var fed models.FsiEncounterDtos
  11413. fed.MdtrtID = his.Number
  11414. fed.MedinsID = miConfig.Code
  11415. fed.MedinsName = miConfig.OrgName
  11416. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11417. fed.MedMdtrtType = "1"
  11418. fed.MedinsType = "1"
  11419. fed.MedinsLv = "11"
  11420. tm := time.Unix(his.RecordDate, 0)
  11421. s_tm := tm.Format("2006-01-02 15:04:05")
  11422. fed.AdmDate = s_tm
  11423. fed.DscgDate = s_tm
  11424. fed.DscgMainDiseCodg = config[0].CountryCode
  11425. fed.DscgMainDiseName = config[0].CountryContentName
  11426. //诊断信息
  11427. var fdds []*models.FsiDiagnoseDtos
  11428. for index, item := range config {
  11429. if index == 0 {
  11430. var fdd models.FsiDiagnoseDtos
  11431. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11432. fdd.InoutDiseType = "1"
  11433. fdd.MaindiseFlag = "1"
  11434. fdd.DiseDate = s_tm
  11435. fdd.DiasSrtNo = "1"
  11436. fdd.DiseName = item.CountryContentName
  11437. fdd.DiseCodg = item.CountryCode
  11438. fdds = append(fdds, &fdd)
  11439. } else {
  11440. var fdd models.FsiDiagnoseDtos
  11441. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11442. fdd.InoutDiseType = "1"
  11443. fdd.MaindiseFlag = "1"
  11444. fdd.DiseDate = s_tm
  11445. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11446. fdd.DiseName = item.CountryContentName
  11447. fdd.DiseCodg = item.CountryCode
  11448. fdds = append(fdds, &fdd)
  11449. }
  11450. }
  11451. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11452. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11453. fed.AdmDeptName = department.Name
  11454. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11455. fed.DscgDeptName = department.Name
  11456. fed.MedMdtrtType = "1"
  11457. fed.MedType = "11"
  11458. //if his.Insutype == "390" {
  11459. // fed.MedType = "1402"
  11460. //} else {
  11461. // fed.MedType = "9933"
  11462. //}
  11463. var orders []*models.FsiOrderDtos
  11464. if trig_scen == "2" {
  11465. //处方医嘱信息
  11466. for _, item := range prescriptions {
  11467. for _, subItem := range item.HisDoctorAdviceInfo {
  11468. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11469. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11470. var order models.FsiOrderDtos
  11471. order.RxID = strconv.FormatInt(item.ID, 10)
  11472. order.Rxno = strconv.FormatInt(item.ID, 10)
  11473. order.LongDrordFlag = "0"
  11474. order.HilistType = "1"
  11475. order.ChrgType = "1"
  11476. order.DrordBhvr = "0"
  11477. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11478. order.HosplistName = subItem.BaseDrugLib.DrugName
  11479. order.HilistLv = "1"
  11480. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11481. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11482. order.HosplistName = subItem.BaseDrugLib.DrugName
  11483. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11484. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11485. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11486. order.OwnpayAmt = ""
  11487. order.SelfpayAmt = ""
  11488. order.Spec = spec
  11489. order.SpecUnt = subItem.PrescribingNumberUnit
  11490. order.DrordBegnDate = s_tm
  11491. order.DrordStopDate = ""
  11492. order.DrordDrCodg = doctor_info.DoctorNumber
  11493. order.DrordDeptName = department.Name
  11494. order.DrordDeptCodg = department.Number
  11495. order.DrordDrName = doctor_info.UserName
  11496. order.DrordDrProfttl = "234"
  11497. order.CurrDrordFlag = "1"
  11498. orders = append(orders, &order)
  11499. }
  11500. }
  11501. for _, subItem := range item.HisPrescriptionProject {
  11502. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11503. var order models.FsiOrderDtos
  11504. order.RxID = strconv.FormatInt(item.ID, 10)
  11505. order.Rxno = strconv.FormatInt(item.ID, 10)
  11506. order.LongDrordFlag = "0"
  11507. order.HilistType = "1"
  11508. order.ChrgType = "1"
  11509. order.DrordBhvr = "0"
  11510. order.HilistCode = subItem.HisProject.MedicalCode
  11511. order.HosplistName = subItem.HisProject.ProjectName
  11512. order.HilistLv = "1"
  11513. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11514. order.HosplistCode = subItem.HisProject.MedicalCode
  11515. order.HosplistName = subItem.HisProject.ProjectName
  11516. order.Cnt = subItem.Count
  11517. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11518. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11519. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11520. order.OwnpayAmt = ""
  11521. order.SelfpayAmt = ""
  11522. order.Spec = subItem.Unit
  11523. order.SpecUnt = subItem.Unit
  11524. order.DrordBegnDate = s_tm
  11525. order.DrordStopDate = ""
  11526. order.DrordDrCodg = doctor_info.DoctorNumber
  11527. order.DrordDeptName = department.Name
  11528. order.DrordDeptCodg = department.Number
  11529. order.DrordDrName = doctor_info.UserName
  11530. order.DrordDrProfttl = "234"
  11531. order.CurrDrordFlag = "1"
  11532. orders = append(orders, &order)
  11533. }
  11534. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11535. var order models.FsiOrderDtos
  11536. order.RxID = strconv.FormatInt(item.ID, 10)
  11537. order.Rxno = strconv.FormatInt(item.ID, 10)
  11538. order.LongDrordFlag = "0"
  11539. order.HilistType = "1"
  11540. order.ChrgType = "1"
  11541. order.DrordBhvr = "0"
  11542. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11543. order.HosplistName = subItem.GoodInfo.GoodName
  11544. order.HilistLv = "1"
  11545. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11546. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11547. order.HosplistName = subItem.GoodInfo.GoodName
  11548. order.Cnt = subItem.Count
  11549. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11550. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11551. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11552. order.OwnpayAmt = ""
  11553. order.SelfpayAmt = ""
  11554. order.Spec = subItem.GoodInfo.SpecificationName
  11555. order.SpecUnt = subItem.Unit
  11556. order.DrordBegnDate = s_tm
  11557. order.DrordStopDate = ""
  11558. order.DrordDrCodg = doctor_info.DoctorNumber
  11559. order.DrordDeptName = department.Name
  11560. order.DrordDeptCodg = department.Number
  11561. order.DrordDrName = doctor_info.UserName
  11562. order.DrordDrProfttl = "234"
  11563. order.CurrDrordFlag = "1"
  11564. orders = append(orders, &order)
  11565. }
  11566. }
  11567. }
  11568. //处方医嘱信息
  11569. }
  11570. fed.MatnStas = "0"
  11571. fed.MedfeeSumamt = "0"
  11572. fed.OwnpayAmt = "0"
  11573. fed.SelfpayAmt = "0"
  11574. fed.AcctPayamt = "0"
  11575. fed.MaAmt = "0"
  11576. fed.HifpPayamt = "0"
  11577. fed.SetlTotlnum = "1"
  11578. fed.Insutype = his.Insutype
  11579. fed.ReimFlag = "0"
  11580. fed.OutSetlFlag = "0"
  11581. var fopd []*models.FsiOperationDtosData
  11582. data := make(map[string]interface{})
  11583. data["fed"] = fed
  11584. data["fdd"] = fdds
  11585. data["fod"] = orders
  11586. data["pd"] = pd
  11587. data["pp"] = pp
  11588. data["fopd"] = fopd
  11589. data["trig_scen"] = trig_scen
  11590. fmt.Println(data)
  11591. fmt.Println(fed)
  11592. fmt.Println(fdds)
  11593. fmt.Println(orders)
  11594. fmt.Println(pd)
  11595. fmt.Println(pp)
  11596. fmt.Println(fopd)
  11597. client := &http.Client{}
  11598. bytesData, _ := json.Marshal(data)
  11599. var req *http.Request
  11600. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11601. if miConfig.MdtrtareaAdmvs == "320921" {
  11602. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11603. } else {
  11604. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11605. }
  11606. resp, _ := client.Do(req)
  11607. defer resp.Body.Close()
  11608. body, ioErr := ioutil.ReadAll(resp.Body)
  11609. if ioErr != nil {
  11610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11612. return res
  11613. }
  11614. var respJSON map[string]interface{}
  11615. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11618. return res
  11619. }
  11620. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11621. fmt.Println(respJSON)
  11622. result, _ := json.Marshal(respJSON)
  11623. fmt.Println(result)
  11624. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11625. utils.ErrorLog("解析失败:%v", err)
  11626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11627. return res
  11628. }
  11629. return res
  11630. } else {
  11631. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11632. saveLog(output, input, "3101", "事前")
  11633. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11634. utils.ErrorLog("解析失败:%v", err)
  11635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11636. return
  11637. }
  11638. return res
  11639. }
  11640. return res
  11641. }
  11642. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11643. ////patient_id, _ := c.GetInt64("patient_id")
  11644. //order_id, _ := c.GetInt64("order_id")
  11645. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11646. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11647. //trig_scen := c.GetString("trig_scen")
  11648. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11649. //utils.ErrorLog("解析失败:%v", psn_info)
  11650. adminUser := c.GetAdminUserInfo()
  11651. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11652. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11653. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11654. record_time := c.GetString("record_time")
  11655. order, _ := service.GetHisOrderByID(order_id)
  11656. timeLayout := "2006-01-02"
  11657. loc, _ := time.LoadLocation("Local")
  11658. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11659. if err != nil {
  11660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11661. return
  11662. }
  11663. recordDateTime := theTime.Unix()
  11664. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11665. var patientPrescription models.HisPrescriptionInfo
  11666. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11667. if patientPrescription.ID == 0 {
  11668. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11669. }
  11670. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11671. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11672. //
  11673. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11674. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11675. var pp models.PublicParams
  11676. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11677. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11678. pp.FixmedinsName = miConfig.OrgName
  11679. pp.FixmedinsCode = miConfig.Code
  11680. pp.RequestUrl = miConfig.Url
  11681. pp.Cainfo = miConfig.Cainfo
  11682. pp.SecretKey = miConfig.SecretKey
  11683. pp.AccessKey = miConfig.AccessKey
  11684. pp.OpterName = roles.UserName
  11685. var config []*models.HisXtDiagnoseConfig
  11686. for _, item := range diagnosis_ids {
  11687. id, _ := strconv.ParseInt(item, 10, 64)
  11688. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11689. config = append(config, &diagnosisConfig)
  11690. }
  11691. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11692. var pd models.PatientDtos
  11693. pd.PatnID = his.PsnNo
  11694. pd.PatnName = his.Name
  11695. pd.Gend = his.Gend
  11696. pd.Brdy = str
  11697. pd.Poolarea = his.InsuplcAdmdvs
  11698. pd.CurrMdtrtID = his.Number
  11699. var fed models.FsiEncounterDtos
  11700. fed.MdtrtID = his.Number
  11701. fed.MedinsID = miConfig.Code
  11702. fed.MedinsName = miConfig.OrgName
  11703. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11704. fed.MedMdtrtType = "1"
  11705. fed.MedinsType = "1"
  11706. fed.MedinsLv = "11"
  11707. tm := time.Unix(his.RecordDate, 0)
  11708. s_tm := tm.Format("2006-01-02 15:04:05")
  11709. fed.AdmDate = s_tm
  11710. fed.DscgDate = s_tm
  11711. fed.DscgMainDiseCodg = config[0].CountryCode
  11712. fed.DscgMainDiseName = config[0].CountryContentName
  11713. //诊断信息
  11714. var fdds []*models.FsiDiagnoseDtos
  11715. for index, item := range config {
  11716. if index == 0 {
  11717. var fdd models.FsiDiagnoseDtos
  11718. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11719. fdd.InoutDiseType = "1"
  11720. fdd.MaindiseFlag = "1"
  11721. fdd.DiseDate = s_tm
  11722. fdd.DiasSrtNo = "1"
  11723. fdd.DiseName = item.CountryContentName
  11724. fdd.DiseCodg = item.CountryCode
  11725. fdds = append(fdds, &fdd)
  11726. } else {
  11727. var fdd models.FsiDiagnoseDtos
  11728. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11729. fdd.InoutDiseType = "1"
  11730. fdd.MaindiseFlag = "1"
  11731. fdd.DiseDate = s_tm
  11732. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11733. fdd.DiseName = item.CountryContentName
  11734. fdd.DiseCodg = item.CountryCode
  11735. fdds = append(fdds, &fdd)
  11736. }
  11737. }
  11738. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11739. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11740. fed.AdmDeptName = department.Name
  11741. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11742. fed.DscgDeptName = department.Name
  11743. fed.MedType = order.MedType
  11744. //处方医嘱信息
  11745. var orders []*models.FsiOrderDtos
  11746. //for _, item := range prescriptions {
  11747. // for _, subItem := range item.HisDoctorAdviceInfo {
  11748. // var order models.FsiOrderDtos
  11749. // order.RxID = strconv.FormatInt(item.ID, 10)
  11750. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11751. // order.LongDrordFlag = "0"
  11752. // order.HilistType = "1"
  11753. // order.ChrgType = "1"
  11754. // order.DrordBhvr = "-"
  11755. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11756. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11757. // order.HilistLv = "1"
  11758. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11759. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11760. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11761. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11762. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11763. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11764. // order.OwnpayAmt = ""
  11765. // order.SelfpayAmt = ""
  11766. // order.Spec = ""
  11767. // order.SpecUnt = ""
  11768. // order.DrordBegnDate = s_tm
  11769. // order.DrordStopDate = ""
  11770. // order.DrordDrCodg = "1"
  11771. // order.DrordDeptName = department.Name
  11772. // order.DrordDrCodg = "1"
  11773. // order.DrordDrName = doctor_info.UserName
  11774. // order.DrordDrProfttl = ""
  11775. // order.CurrDrordFlag = "1"
  11776. // orders = append(orders, &order)
  11777. // }
  11778. // for _, subItem := range item.HisPrescriptionProject {
  11779. // if subItem.Type == 2 {
  11780. // var order models.FsiOrderDtos
  11781. // order.RxID = strconv.FormatInt(item.ID, 10)
  11782. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11783. // order.LongDrordFlag = "0"
  11784. // order.HilistType = "1"
  11785. // order.ChrgType = "1"
  11786. // order.DrordBhvr = "-"
  11787. // order.HilistCode = subItem.HisProject.MedicalCode
  11788. // order.HosplistName = subItem.HisProject.ProjectName
  11789. // order.HilistLv = "1"
  11790. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11791. // order.HosplistCode = subItem.HisProject.MedicalCode
  11792. // order.HosplistName = subItem.HisProject.ProjectName
  11793. // order.Cnt = subItem.Count
  11794. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11795. //
  11796. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11797. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11798. // order.OwnpayAmt = ""
  11799. // order.SelfpayAmt = ""
  11800. // order.Spec = ""
  11801. // order.SpecUnt = ""
  11802. // order.DrordBegnDate = s_tm
  11803. // order.DrordStopDate = ""
  11804. // order.DrordDrCodg = "1"
  11805. // order.DrordDeptName = department.Name
  11806. // order.DrordDrCodg = "1"
  11807. // order.DrordDrName = doctor_info.UserName
  11808. // order.DrordDrProfttl = ""
  11809. // order.CurrDrordFlag = "1"
  11810. // orders = append(orders, &order)
  11811. //
  11812. // }
  11813. // if subItem.Type == 3 {
  11814. //
  11815. // var order models.FsiOrderDtos
  11816. // order.RxID = strconv.FormatInt(item.ID, 10)
  11817. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11818. // order.LongDrordFlag = "0"
  11819. // order.HilistType = "1"
  11820. // order.ChrgType = "1"
  11821. // order.DrordBhvr = "-"
  11822. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11823. // order.HosplistName = subItem.GoodInfo.GoodName
  11824. // order.HilistLv = "1"
  11825. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11826. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11827. // order.HosplistName = subItem.GoodInfo.GoodName
  11828. // order.Cnt = subItem.Count
  11829. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11830. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11831. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11832. // order.OwnpayAmt = ""
  11833. // order.SelfpayAmt = ""
  11834. // order.Spec = ""
  11835. // order.SpecUnt = ""
  11836. // order.DrordBegnDate = s_tm
  11837. // order.DrordStopDate = ""
  11838. // order.DrordDrCodg = "1"
  11839. // order.DrordDeptName = department.Name
  11840. // order.DrordDrCodg = "1"
  11841. // order.DrordDrName = doctor_info.UserName
  11842. // order.DrordDrProfttl = ""
  11843. // order.CurrDrordFlag = "1"
  11844. // orders = append(orders, &order)
  11845. //
  11846. // }
  11847. // }
  11848. //}
  11849. for _, item := range prescriptions {
  11850. for _, subItem := range item.HisDoctorAdviceInfo {
  11851. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11852. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11853. var order models.FsiOrderDtos
  11854. order.RxID = strconv.FormatInt(item.ID, 10)
  11855. order.Rxno = strconv.FormatInt(item.ID, 10)
  11856. order.LongDrordFlag = "0"
  11857. order.HilistType = "1"
  11858. order.ChrgType = "1"
  11859. order.DrordBhvr = "0"
  11860. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11861. order.HosplistName = subItem.BaseDrugLib.DrugName
  11862. order.HilistLv = "1"
  11863. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11864. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11865. order.HosplistName = subItem.BaseDrugLib.DrugName
  11866. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11867. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11868. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11869. order.OwnpayAmt = ""
  11870. order.SelfpayAmt = ""
  11871. order.Spec = spec
  11872. order.SpecUnt = subItem.PrescribingNumberUnit
  11873. order.DrordBegnDate = s_tm
  11874. order.DrordStopDate = ""
  11875. order.DrordDrCodg = doctor_info.DoctorNumber
  11876. order.DrordDeptName = department.Name
  11877. order.DrordDeptCodg = department.Number
  11878. order.DrordDrName = doctor_info.UserName
  11879. order.DrordDrProfttl = "234"
  11880. order.CurrDrordFlag = "1"
  11881. orders = append(orders, &order)
  11882. }
  11883. }
  11884. for _, subItem := range item.HisPrescriptionProject {
  11885. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11886. var order models.FsiOrderDtos
  11887. order.RxID = strconv.FormatInt(item.ID, 10)
  11888. order.Rxno = strconv.FormatInt(item.ID, 10)
  11889. order.LongDrordFlag = "0"
  11890. order.HilistType = "1"
  11891. order.ChrgType = "1"
  11892. order.DrordBhvr = "0"
  11893. order.HilistCode = subItem.HisProject.MedicalCode
  11894. order.HosplistName = subItem.HisProject.ProjectName
  11895. order.HilistLv = "1"
  11896. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11897. order.HosplistCode = subItem.HisProject.MedicalCode
  11898. order.HosplistName = subItem.HisProject.ProjectName
  11899. order.Cnt = subItem.Count
  11900. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11901. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11902. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11903. order.OwnpayAmt = ""
  11904. order.SelfpayAmt = ""
  11905. order.Spec = subItem.Unit
  11906. order.SpecUnt = subItem.Unit
  11907. order.DrordBegnDate = s_tm
  11908. order.DrordStopDate = ""
  11909. order.DrordDrCodg = doctor_info.DoctorNumber
  11910. order.DrordDeptName = department.Name
  11911. order.DrordDeptCodg = department.Number
  11912. order.DrordDrName = doctor_info.UserName
  11913. order.DrordDrProfttl = "234"
  11914. order.CurrDrordFlag = "1"
  11915. orders = append(orders, &order)
  11916. }
  11917. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11918. var order models.FsiOrderDtos
  11919. order.RxID = strconv.FormatInt(item.ID, 10)
  11920. order.Rxno = strconv.FormatInt(item.ID, 10)
  11921. order.LongDrordFlag = "0"
  11922. order.HilistType = "1"
  11923. order.ChrgType = "1"
  11924. order.DrordBhvr = "0"
  11925. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11926. order.HosplistName = subItem.GoodInfo.GoodName
  11927. order.HilistLv = "1"
  11928. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11929. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11930. order.HosplistName = subItem.GoodInfo.GoodName
  11931. order.Cnt = subItem.Count
  11932. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11933. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11934. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11935. order.OwnpayAmt = ""
  11936. order.SelfpayAmt = ""
  11937. order.Spec = subItem.GoodInfo.SpecificationName
  11938. order.SpecUnt = subItem.Unit
  11939. order.DrordBegnDate = s_tm
  11940. order.DrordStopDate = ""
  11941. order.DrordDrCodg = doctor_info.DoctorNumber
  11942. order.DrordDeptName = department.Name
  11943. order.DrordDeptCodg = department.Number
  11944. order.DrordDrName = doctor_info.UserName
  11945. order.DrordDrProfttl = "234"
  11946. order.CurrDrordFlag = "1"
  11947. orders = append(orders, &order)
  11948. }
  11949. }
  11950. }
  11951. //处方医嘱信息
  11952. fed.MatnStas = "0"
  11953. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11954. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11955. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11956. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11957. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11958. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11959. fed.SetlTotlnum = "1"
  11960. fed.Insutype = his.Insutype
  11961. fed.ReimFlag = "0"
  11962. fed.OutSetlFlag = "0"
  11963. var fopd []*models.FsiOperationDtosData
  11964. data := make(map[string]interface{})
  11965. data["fed"] = fed
  11966. data["fdd"] = fdds
  11967. data["fod"] = orders
  11968. data["pd"] = pd
  11969. data["pp"] = pp
  11970. data["fopd"] = fopd
  11971. data["trig_scen"] = trig_scen
  11972. client := &http.Client{}
  11973. bytesData, _ := json.Marshal(data)
  11974. var req *http.Request
  11975. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11976. if miConfig.MdtrtareaAdmvs == "320921" {
  11977. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11978. } else {
  11979. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11980. }
  11981. resp, _ := client.Do(req)
  11982. defer resp.Body.Close()
  11983. body, ioErr := ioutil.ReadAll(resp.Body)
  11984. if ioErr != nil {
  11985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11987. return res
  11988. }
  11989. var respJSON map[string]interface{}
  11990. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11993. return res
  11994. }
  11995. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11996. result, _ := json.Marshal(respJSON)
  11997. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11998. utils.ErrorLog("解析失败:%v", err)
  11999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12000. return res
  12001. }
  12002. return res
  12003. } else {
  12004. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12005. saveLog(output, input, "3102", "事中")
  12006. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12007. utils.ErrorLog("解析失败:%v", err)
  12008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12009. return
  12010. }
  12011. return res
  12012. }
  12013. return res
  12014. }
  12015. func (c *HisApiController) Check() {
  12016. psn_no := c.GetString("psn_no")
  12017. in := c.GetString("in")
  12018. mt := c.GetString("mt")
  12019. baseParams := models.BaseParams{
  12020. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12021. FixmedinsCode: "H15049901371",
  12022. InsuplcAdmdvs: "150499",
  12023. MdtrtareaAdmvs: "150499",
  12024. OrgName: "赤峰费森血液透析中心",
  12025. Doctor: "1111",
  12026. }
  12027. service.Gdyb2001(baseParams, psn_no, in, mt)
  12028. }
  12029. func (c *HisApiController) GetPsnNcdsInfo() {
  12030. admin_user_id, _ := c.GetInt64("admin_user_id")
  12031. patient_id, _ := c.GetInt64("patient_id")
  12032. //id, _ := c.GetInt64("id")
  12033. adminUser := c.GetAdminUserInfo()
  12034. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12035. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12036. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12037. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12038. //psn_record, _ := service.GetP(id)
  12039. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12040. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12041. //
  12042. //if psn_record.ID == 0 {
  12043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12044. // return
  12045. //}
  12046. var res Result5301
  12047. var res10265 Result5301For10265
  12048. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12049. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12050. var api string
  12051. if miConfig.MdtrtareaAdmvs == "320921" {
  12052. 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 +
  12053. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12054. } else {
  12055. 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 +
  12056. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12057. }
  12058. resp, requestErr := http.Get(api)
  12059. if requestErr != nil {
  12060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12061. return
  12062. }
  12063. body, ioErr := ioutil.ReadAll(resp.Body)
  12064. if ioErr != nil {
  12065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12067. return
  12068. }
  12069. var respJSON map[string]interface{}
  12070. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12073. return
  12074. }
  12075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12076. result, _ := json.Marshal(respJSON)
  12077. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12078. utils.ErrorLog("解析失败:%v", err)
  12079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12080. return
  12081. }
  12082. res.ErrMsg = res10265.ErrMsg
  12083. res.Output = res10265.Output
  12084. res.InfRefmsgid = res10265.InfRefmsgid
  12085. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12086. res.Infcode = infocode
  12087. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12088. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12089. var api string
  12090. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12091. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12092. resp, requestErr := http.Get(api)
  12093. if requestErr != nil {
  12094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12095. return
  12096. }
  12097. body, ioErr := ioutil.ReadAll(resp.Body)
  12098. if ioErr != nil {
  12099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12101. return
  12102. }
  12103. var respJSON map[string]interface{}
  12104. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12107. return
  12108. }
  12109. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12110. if status == "0" {
  12111. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12112. c.ServeSuccessJSON(map[string]interface{}{
  12113. "failed_code": -10,
  12114. "msg": err_msg,
  12115. })
  12116. return
  12117. }
  12118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12119. result, _ := json.Marshal(respJSON)
  12120. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12121. utils.ErrorLog("解析失败:%v", err)
  12122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12123. return
  12124. }
  12125. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12126. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12127. var api string
  12128. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12129. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12130. resp, requestErr := http.Get(api)
  12131. if requestErr != nil {
  12132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12133. return
  12134. }
  12135. body, ioErr := ioutil.ReadAll(resp.Body)
  12136. if ioErr != nil {
  12137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12139. return
  12140. }
  12141. var respJSON map[string]interface{}
  12142. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12145. return
  12146. }
  12147. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12148. if status == "0" {
  12149. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12150. c.ServeSuccessJSON(map[string]interface{}{
  12151. "failed_code": -10,
  12152. "msg": err_msg,
  12153. })
  12154. return
  12155. }
  12156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12157. result, _ := json.Marshal(respJSON)
  12158. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12159. utils.ErrorLog("解析失败:%v", err)
  12160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12161. return
  12162. }
  12163. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12164. p, _ := service.GetHisPatientById(patient_id)
  12165. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12166. var dat map[string]interface{}
  12167. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12168. fmt.Println(dat)
  12169. } else {
  12170. fmt.Println(err)
  12171. }
  12172. userJSONBytes, _ := json.Marshal(dat)
  12173. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12174. utils.ErrorLog("解析失败:%v", err)
  12175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12176. return
  12177. }
  12178. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12179. p, _ := service.GetHisPatientById(patient_id)
  12180. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12181. var dat map[string]interface{}
  12182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12183. fmt.Println(dat)
  12184. } else {
  12185. fmt.Println(err)
  12186. }
  12187. userJSONBytes, _ := json.Marshal(dat)
  12188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12189. utils.ErrorLog("解析失败:%v", err)
  12190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12191. return
  12192. }
  12193. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12194. p, _ := service.GetHisPatientById(patient_id)
  12195. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12196. var dat map[string]interface{}
  12197. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12198. fmt.Println(dat)
  12199. } else {
  12200. fmt.Println(err)
  12201. }
  12202. userJSONBytes, _ := json.Marshal(dat)
  12203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12204. utils.ErrorLog("解析失败:%v", err)
  12205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12206. return
  12207. }
  12208. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12209. p, _ := service.GetHisPatientById(patient_id)
  12210. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12211. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12212. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12213. resp, requestErr := http.Get(api)
  12214. if requestErr != nil {
  12215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12216. return
  12217. }
  12218. body, ioErr := ioutil.ReadAll(resp.Body)
  12219. if ioErr != nil {
  12220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12222. return
  12223. }
  12224. var respJSON map[string]interface{}
  12225. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12228. return
  12229. }
  12230. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12231. result, _ := json.Marshal(respJSON)
  12232. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12233. utils.ErrorLog("解析失败:%v", err)
  12234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12235. return
  12236. }
  12237. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12238. p, _ := service.GetHisPatientById(patient_id)
  12239. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12240. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12241. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12242. resp, requestErr := http.Get(api)
  12243. if requestErr != nil {
  12244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12245. return
  12246. }
  12247. body, ioErr := ioutil.ReadAll(resp.Body)
  12248. if ioErr != nil {
  12249. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12251. return
  12252. }
  12253. var respJSON map[string]interface{}
  12254. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12257. return
  12258. }
  12259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12260. result, _ := json.Marshal(respJSON)
  12261. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12262. utils.ErrorLog("解析失败:%v", err)
  12263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12264. return
  12265. }
  12266. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12267. p, _ := service.GetHisPatientById(patient_id)
  12268. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12269. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12270. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12271. resp, requestErr := http.Get(api)
  12272. if requestErr != nil {
  12273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12274. return
  12275. }
  12276. body, ioErr := ioutil.ReadAll(resp.Body)
  12277. if ioErr != nil {
  12278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12280. return
  12281. }
  12282. var respJSON map[string]interface{}
  12283. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12286. return
  12287. }
  12288. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12289. result, _ := json.Marshal(respJSON)
  12290. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12291. utils.ErrorLog("解析失败:%v", err)
  12292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12293. return
  12294. }
  12295. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12296. p, _ := service.GetHisPatientById(patient_id)
  12297. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12298. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12299. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12300. resp, requestErr := http.Get(api)
  12301. if requestErr != nil {
  12302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12303. return
  12304. }
  12305. body, ioErr := ioutil.ReadAll(resp.Body)
  12306. if ioErr != nil {
  12307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12309. return
  12310. }
  12311. var respJSON map[string]interface{}
  12312. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12315. return
  12316. }
  12317. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12318. result, _ := json.Marshal(respJSON)
  12319. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12320. utils.ErrorLog("解析失败:%v", err)
  12321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12322. return
  12323. }
  12324. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12325. p, _ := service.GetHisPatientById(patient_id)
  12326. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12327. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12328. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12329. resp, requestErr := http.Get(api)
  12330. if requestErr != nil {
  12331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12332. return
  12333. }
  12334. body, ioErr := ioutil.ReadAll(resp.Body)
  12335. if ioErr != nil {
  12336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12338. return
  12339. }
  12340. var respJSON map[string]interface{}
  12341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12344. return
  12345. }
  12346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12347. result, _ := json.Marshal(respJSON)
  12348. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12349. utils.ErrorLog("解析失败:%v", err)
  12350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12351. return
  12352. }
  12353. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12354. p, _ := service.GetHisPatientById(patient_id)
  12355. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12356. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12357. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12358. resp, requestErr := http.Get(api)
  12359. if requestErr != nil {
  12360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12361. return
  12362. }
  12363. body, ioErr := ioutil.ReadAll(resp.Body)
  12364. if ioErr != nil {
  12365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12367. return
  12368. }
  12369. var respJSON map[string]interface{}
  12370. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12373. return
  12374. }
  12375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12376. result, _ := json.Marshal(respJSON)
  12377. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12378. utils.ErrorLog("解析失败:%v", err)
  12379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12380. return
  12381. }
  12382. } else {
  12383. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12384. var dat map[string]interface{}
  12385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12386. fmt.Println(dat)
  12387. } else {
  12388. fmt.Println(err)
  12389. }
  12390. userJSONBytes, _ := json.Marshal(dat)
  12391. if miConfig.Code == "H15049901371" {
  12392. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12393. utils.ErrorLog("解析失败:%v", err)
  12394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12395. return
  12396. }
  12397. res.InfRefmsgid = res10265.InfRefmsgid
  12398. res.Output = res10265.Output
  12399. res.ErrMsg = res10265.ErrMsg
  12400. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12401. res.Infcode = infocode
  12402. } else {
  12403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12404. utils.ErrorLog("解析失败:%v", err)
  12405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12406. return
  12407. }
  12408. }
  12409. }
  12410. if res.Infcode == 0 {
  12411. c.ServeSuccessJSON(map[string]interface{}{
  12412. "result": res.Output.Result,
  12413. })
  12414. }
  12415. }
  12416. func (c *HisApiController) CheckInsutype() {
  12417. his_patient_id, _ := c.GetInt64("his_patient_id")
  12418. admin_user_id, _ := c.GetInt64("admin_user_id")
  12419. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12420. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12421. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12422. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12423. var dat map[string]interface{}
  12424. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12425. fmt.Println(dat)
  12426. } else {
  12427. fmt.Println(err)
  12428. }
  12429. userJSONBytes, _ := json.Marshal(dat)
  12430. var res Result90100
  12431. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12432. utils.ErrorLog("解析失败:%v", err)
  12433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12434. return
  12435. }
  12436. if res.Infcode != 0 {
  12437. c.ServeSuccessJSON(map[string]interface{}{
  12438. "failed_code": -10,
  12439. "msg": res.ErrMsg,
  12440. })
  12441. return
  12442. } else {
  12443. fmt.Println(res)
  12444. }
  12445. }
  12446. func (c *HisApiController) CheckCardPWD() {
  12447. card_pwd := c.GetString("card_pwd")
  12448. his_patient_id, _ := c.GetInt64("his_patient_id")
  12449. admin_user_id, _ := c.GetInt64("admin_user_id")
  12450. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12451. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12452. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12453. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12454. bas := strings.Split(psn.CardInfo, "|")
  12455. basNumber := bas[2]
  12456. if psn.InsuplcAdmdvs[:4] == "4403" {
  12457. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12458. var dat map[string]interface{}
  12459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12460. fmt.Println(dat)
  12461. } else {
  12462. fmt.Println(err)
  12463. }
  12464. userJSONBytes, _ := json.Marshal(dat)
  12465. var res Result90991
  12466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12467. utils.ErrorLog("解析失败:%v", err)
  12468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12469. return
  12470. }
  12471. if res.Infcode != 0 {
  12472. c.ServeSuccessJSON(map[string]interface{}{
  12473. "failed_code": -10,
  12474. "msg": res.ErrMsg,
  12475. })
  12476. return
  12477. } else {
  12478. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12479. var msg string
  12480. switch res.Output.Result.CardStat {
  12481. case "00":
  12482. msg = "未激活"
  12483. break
  12484. case "10":
  12485. msg = "激活"
  12486. break
  12487. case "20":
  12488. msg = "窗口挂失"
  12489. break
  12490. case "21":
  12491. msg = "电话挂失"
  12492. break
  12493. case "22":
  12494. msg = "单位网上申报挂失"
  12495. break
  12496. case "23":
  12497. msg = "保健办挂失"
  12498. break
  12499. case "24":
  12500. msg = "个人网上挂失"
  12501. break
  12502. case "25":
  12503. msg = "网上服务大厅挂失"
  12504. break
  12505. case "30":
  12506. msg = "注销"
  12507. break
  12508. case "40":
  12509. msg = "回收"
  12510. break
  12511. case "99":
  12512. msg = "制卡中(无效卡)"
  12513. break
  12514. }
  12515. c.ServeSuccessJSON(map[string]interface{}{
  12516. "failed_code": -10,
  12517. "msg": msg,
  12518. })
  12519. return
  12520. } else {
  12521. c.ServeSuccessJSON(map[string]interface{}{
  12522. "msg": "校验成功",
  12523. })
  12524. return
  12525. }
  12526. }
  12527. } else {
  12528. c.ServeSuccessJSON(map[string]interface{}{
  12529. "msg": "校验成功",
  12530. })
  12531. return
  12532. }
  12533. }
  12534. func (c *HisApiController) CheckCardPWDTwo() {
  12535. //card_pwd := c.GetString("card_pwd")
  12536. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12537. admin_user_id, _ := c.GetInt64("admin_user_id")
  12538. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12539. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12540. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12541. var dat map[string]interface{}
  12542. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12543. fmt.Println(dat)
  12544. } else {
  12545. fmt.Println(err)
  12546. }
  12547. userJSONBytes, _ := json.Marshal(dat)
  12548. var res Result90991
  12549. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12550. utils.ErrorLog("解析失败:%v", err)
  12551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12552. return
  12553. }
  12554. if res.Infcode != 0 {
  12555. c.ServeSuccessJSON(map[string]interface{}{
  12556. "failed_code": -10,
  12557. "msg": res.ErrMsg,
  12558. })
  12559. return
  12560. } else {
  12561. if res.Output.Result.SscnoCheckStat == "0" {
  12562. var msg string
  12563. switch res.Output.Result.CardStat {
  12564. case "00":
  12565. msg = "未激活"
  12566. break
  12567. case "10":
  12568. msg = "激活"
  12569. break
  12570. case "20":
  12571. msg = "窗口挂失"
  12572. break
  12573. case "21":
  12574. msg = "电话挂失"
  12575. break
  12576. case "22":
  12577. msg = "单位网上申报挂失"
  12578. break
  12579. case "23":
  12580. msg = "保健办挂失"
  12581. break
  12582. case "24":
  12583. msg = "个人网上挂失"
  12584. break
  12585. case "25":
  12586. msg = "网上服务大厅挂失"
  12587. break
  12588. case "30":
  12589. msg = "注销"
  12590. break
  12591. case "40":
  12592. msg = "回收"
  12593. break
  12594. case "99":
  12595. msg = "制卡中(无效卡)"
  12596. break
  12597. }
  12598. c.ServeSuccessJSON(map[string]interface{}{
  12599. "failed_code": -10,
  12600. "msg": msg,
  12601. })
  12602. return
  12603. } else {
  12604. c.ServeSuccessJSON(map[string]interface{}{
  12605. "msg": "校验成功",
  12606. })
  12607. return
  12608. }
  12609. }
  12610. }
  12611. type ELeCertData struct {
  12612. Data struct {
  12613. Extra string `json:"extra"`
  12614. IDNo string `json:"idNo"`
  12615. IDType string `json:"idType"`
  12616. EcToken string `json:"ecToken"`
  12617. InsuOrg string `json:"insuOrg"`
  12618. UserName string `json:"userName"`
  12619. EcIndexNo string `json:"ecIndexNo"`
  12620. Gender string `json:"gender"`
  12621. Birthday string `json:"birthday"`
  12622. Nationality string `json:"nationality"`
  12623. Email string `json:"email"`
  12624. } `json:"OutData"`
  12625. }
  12626. func (c *HisApiController) ReadCard() {
  12627. id_card_type, _ := c.GetInt64("id_card_type")
  12628. admin_user_id, _ := c.GetInt64("admin_user_id")
  12629. certificates, _ := c.GetInt64("certificates")
  12630. //
  12631. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12632. id_card_no := c.GetString("id_card_no")
  12633. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12634. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12635. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12636. switch id_card_type {
  12637. case 1:
  12638. if miConfig.MdtrtareaAdmvs == "421300" {
  12639. var res ResultTwo
  12640. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12641. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12642. "&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)
  12643. resp, requestErr := http.Get(api)
  12644. if requestErr != nil {
  12645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12646. return
  12647. }
  12648. body, ioErr := ioutil.ReadAll(resp.Body)
  12649. if ioErr != nil {
  12650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12652. return
  12653. }
  12654. var respJSON map[string]interface{}
  12655. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12658. return
  12659. }
  12660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12661. result, _ := json.Marshal(respJSON)
  12662. fmt.Println("log")
  12663. fmt.Println(string(result))
  12664. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12665. utils.ErrorLog("解析失败:%v", err)
  12666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12667. return
  12668. }
  12669. if res.Infcode == 0 {
  12670. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12671. if err == gorm.ErrRecordNotFound {
  12672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12673. return
  12674. } else if err != nil {
  12675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12676. return
  12677. } else {
  12678. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12679. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12680. infoStr := string(Iinfos)
  12681. idetinfoStr := string(Idetinfos)
  12682. var rf []*ResultFive
  12683. json.Unmarshal([]byte(infoStr), &rf)
  12684. var insutypes []*ResultFive
  12685. var insutype string
  12686. var is390 int = 0
  12687. var is310 int = 0
  12688. for _, item := range rf {
  12689. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12690. insutypes = append(insutypes, item)
  12691. }
  12692. }
  12693. if len(insutypes) == 1 {
  12694. insutype = insutypes[0].Insutype
  12695. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12696. } else {
  12697. for _, i := range insutypes {
  12698. if i.Insutype == "390" {
  12699. is390 = 1
  12700. }
  12701. if i.Insutype == "310" {
  12702. is310 = 1
  12703. }
  12704. }
  12705. }
  12706. if is390 == 1 {
  12707. insutype = "390"
  12708. }
  12709. if is310 == 1 {
  12710. insutype = "310"
  12711. }
  12712. if len(insutypes) == 0 {
  12713. insutype = "390"
  12714. }
  12715. var insuplc_admdvs string
  12716. for _, item := range rf {
  12717. if item.Insutype == insutype {
  12718. insuplc_admdvs = item.InsuplcAdmdvs
  12719. }
  12720. }
  12721. if strings.Contains(insuplc_admdvs, "4213") {
  12722. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12723. }
  12724. psn := &models.HisPsn{
  12725. PsnNo: res.Output.Baseinfo.PsnNo,
  12726. PatientId: patient.ID,
  12727. Certno: res.Output.Baseinfo.Certno,
  12728. Gend: res.Output.Baseinfo.Gend,
  12729. Naty: res.Output.Baseinfo.Naty,
  12730. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12731. PsnName: res.Output.Baseinfo.PsnName,
  12732. Idetinfo: idetinfoStr,
  12733. Insuinfo: infoStr,
  12734. InsuplcAdmdvs: insuplc_admdvs,
  12735. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12736. }
  12737. service.CreateHisPsn(psn)
  12738. c.ServeSuccessJSON(map[string]interface{}{
  12739. "patient": patient,
  12740. "number": res.Output.Baseinfo.Certno,
  12741. })
  12742. }
  12743. } else {
  12744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12745. return
  12746. }
  12747. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12748. var res ResultTwo
  12749. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12750. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12751. "&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)
  12752. resp, requestErr := http.Get(api)
  12753. if requestErr != nil {
  12754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12755. return
  12756. }
  12757. body, ioErr := ioutil.ReadAll(resp.Body)
  12758. if ioErr != nil {
  12759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12761. return
  12762. }
  12763. var respJSON map[string]interface{}
  12764. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12767. return
  12768. }
  12769. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12770. result, _ := json.Marshal(respJSON)
  12771. fmt.Println("log")
  12772. fmt.Println(string(result))
  12773. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12774. utils.ErrorLog("解析失败:%v", err)
  12775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12776. return
  12777. }
  12778. if res.Infcode == 0 {
  12779. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12780. if err == gorm.ErrRecordNotFound {
  12781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12782. return
  12783. } else if err != nil {
  12784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12785. return
  12786. } else {
  12787. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12788. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12789. infoStr := string(Iinfos)
  12790. idetinfoStr := string(Idetinfos)
  12791. psn := &models.HisPsn{
  12792. PsnNo: res.Output.Baseinfo.PsnNo,
  12793. PatientId: patient.ID,
  12794. Certno: res.Output.Baseinfo.Certno,
  12795. Gend: res.Output.Baseinfo.Gend,
  12796. Naty: res.Output.Baseinfo.Naty,
  12797. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12798. PsnName: res.Output.Baseinfo.PsnName,
  12799. Idetinfo: idetinfoStr,
  12800. Insuinfo: infoStr,
  12801. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12802. }
  12803. service.CreateHisPsn(psn)
  12804. var rf []*ResultFive
  12805. json.Unmarshal([]byte(infoStr), &rf)
  12806. var insutypes []*ResultFive
  12807. var insutype string
  12808. var is390 int = 0
  12809. var is310 int = 0
  12810. for _, item := range rf {
  12811. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12812. insutypes = append(insutypes, item)
  12813. }
  12814. }
  12815. if len(insutypes) == 1 {
  12816. insutype = insutypes[0].Insutype
  12817. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12818. } else {
  12819. for _, i := range insutypes {
  12820. if i.Insutype == "390" {
  12821. is390 = 1
  12822. }
  12823. if i.Insutype == "310" {
  12824. is310 = 1
  12825. }
  12826. }
  12827. }
  12828. if is390 == 1 {
  12829. insutype = "390"
  12830. }
  12831. if is310 == 1 {
  12832. insutype = "310"
  12833. }
  12834. if len(insutypes) == 0 {
  12835. insutype = "310"
  12836. }
  12837. c.ServeSuccessJSON(map[string]interface{}{
  12838. "patient": patient,
  12839. "number": res.Output.Baseinfo.Certno,
  12840. "insutype": insutype,
  12841. })
  12842. }
  12843. } else {
  12844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12845. return
  12846. }
  12847. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12848. var res ResultTwo
  12849. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12850. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12851. "&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)
  12852. resp, requestErr := http.Get(api)
  12853. if requestErr != nil {
  12854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12855. return
  12856. }
  12857. body, ioErr := ioutil.ReadAll(resp.Body)
  12858. if ioErr != nil {
  12859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12861. return
  12862. }
  12863. var respJSON map[string]interface{}
  12864. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12867. return
  12868. }
  12869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12870. result, _ := json.Marshal(respJSON)
  12871. fmt.Println("log")
  12872. fmt.Println(string(result))
  12873. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12874. utils.ErrorLog("解析失败:%v", err)
  12875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12876. return
  12877. }
  12878. if res.Infcode == 0 {
  12879. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12880. if err == gorm.ErrRecordNotFound {
  12881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12882. return
  12883. } else if err != nil {
  12884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12885. return
  12886. } else {
  12887. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12888. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12889. infoStr := string(Iinfos)
  12890. idetinfoStr := string(Idetinfos)
  12891. var rf []*ResultFive
  12892. json.Unmarshal([]byte(infoStr), &rf)
  12893. var insutypes []*ResultFive
  12894. var insutype string
  12895. var is390 int = 0
  12896. var is310 int = 0
  12897. for _, item := range rf {
  12898. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12899. insutypes = append(insutypes, item)
  12900. }
  12901. }
  12902. if len(insutypes) == 1 {
  12903. insutype = insutypes[0].Insutype
  12904. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12905. } else {
  12906. for _, i := range insutypes {
  12907. if i.Insutype == "390" {
  12908. is390 = 1
  12909. }
  12910. if i.Insutype == "310" {
  12911. is310 = 1
  12912. }
  12913. }
  12914. }
  12915. if is390 == 1 {
  12916. insutype = "390"
  12917. }
  12918. if is310 == 1 {
  12919. insutype = "310"
  12920. }
  12921. if len(insutypes) == 0 {
  12922. insutype = "390"
  12923. }
  12924. var insuplc_admdvs string
  12925. for _, item := range rf {
  12926. if item.Insutype == insutype {
  12927. insuplc_admdvs = item.InsuplcAdmdvs
  12928. }
  12929. }
  12930. psn := &models.HisPsn{
  12931. PsnNo: res.Output.Baseinfo.PsnNo,
  12932. PatientId: patient.ID,
  12933. Certno: res.Output.Baseinfo.Certno,
  12934. Gend: res.Output.Baseinfo.Gend,
  12935. Naty: res.Output.Baseinfo.Naty,
  12936. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12937. PsnName: res.Output.Baseinfo.PsnName,
  12938. Idetinfo: idetinfoStr,
  12939. Insuinfo: infoStr,
  12940. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12941. InsuplcAdmdvs: insuplc_admdvs,
  12942. }
  12943. service.CreateHisPsn(psn)
  12944. for _, item := range rf {
  12945. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12946. insutypes = append(insutypes, item)
  12947. }
  12948. }
  12949. if len(insutypes) == 1 {
  12950. insutype = insutypes[0].Insutype
  12951. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12952. } else {
  12953. for _, i := range insutypes {
  12954. if i.Insutype == "390" {
  12955. is390 = 1
  12956. }
  12957. if i.Insutype == "310" {
  12958. is310 = 1
  12959. }
  12960. }
  12961. }
  12962. if is390 == 1 {
  12963. insutype = "390"
  12964. }
  12965. if is310 == 1 {
  12966. insutype = "310"
  12967. }
  12968. if len(insutypes) == 0 {
  12969. insutype = "310"
  12970. }
  12971. c.ServeSuccessJSON(map[string]interface{}{
  12972. "patient": patient,
  12973. "number": res.Output.Baseinfo.Certno,
  12974. "insutype": insutype,
  12975. })
  12976. }
  12977. } else {
  12978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12979. return
  12980. }
  12981. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12982. var res ResultTwo
  12983. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12984. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12985. "&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)
  12986. resp, requestErr := http.Get(api)
  12987. if requestErr != nil {
  12988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12989. return
  12990. }
  12991. body, ioErr := ioutil.ReadAll(resp.Body)
  12992. if ioErr != nil {
  12993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12995. return
  12996. }
  12997. var respJSON map[string]interface{}
  12998. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13001. return
  13002. }
  13003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13004. result, _ := json.Marshal(respJSON)
  13005. fmt.Println("log")
  13006. fmt.Println(string(result))
  13007. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13008. utils.ErrorLog("解析失败:%v", err)
  13009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13010. return
  13011. }
  13012. if res.Infcode == 0 {
  13013. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13014. if err == gorm.ErrRecordNotFound {
  13015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13016. return
  13017. } else if err != nil {
  13018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13019. return
  13020. } else {
  13021. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13022. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13023. infoStr := string(Iinfos)
  13024. idetinfoStr := string(Idetinfos)
  13025. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13026. psn := &models.HisPsn{
  13027. PsnNo: res.Output.Baseinfo.PsnNo,
  13028. PatientId: patient.ID,
  13029. Certno: res.Output.Baseinfo.Certno,
  13030. Brdy: b,
  13031. Age: float64(age),
  13032. Gend: res.Output.Baseinfo.Gend,
  13033. Naty: res.Output.Baseinfo.Naty,
  13034. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13035. PsnName: res.Output.Baseinfo.PsnName,
  13036. Idetinfo: idetinfoStr,
  13037. Insuinfo: infoStr,
  13038. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13039. }
  13040. service.CreateHisPsn(psn)
  13041. var rf []*ResultFive
  13042. json.Unmarshal([]byte(infoStr), &rf)
  13043. var insutypes []*ResultFive
  13044. var insutype string
  13045. var is390 int = 0
  13046. var is310 int = 0
  13047. for _, item := range rf {
  13048. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13049. insutypes = append(insutypes, item)
  13050. }
  13051. }
  13052. if len(insutypes) == 1 {
  13053. insutype = insutypes[0].Insutype
  13054. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13055. } else {
  13056. for _, i := range insutypes {
  13057. if i.Insutype == "390" {
  13058. is390 = 1
  13059. }
  13060. if i.Insutype == "310" {
  13061. is310 = 1
  13062. }
  13063. }
  13064. }
  13065. if is390 == 1 {
  13066. insutype = "390"
  13067. }
  13068. if is310 == 1 {
  13069. insutype = "310"
  13070. }
  13071. if len(insutypes) == 0 {
  13072. insutype = "310"
  13073. }
  13074. c.ServeSuccessJSON(map[string]interface{}{
  13075. "patient": patient,
  13076. "number": res.Output.Baseinfo.Certno,
  13077. "insutype": insutype,
  13078. })
  13079. }
  13080. } else {
  13081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13082. return
  13083. }
  13084. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13085. var api string
  13086. if miConfig.MdtrtareaAdmvs == "320921" {
  13087. 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 +
  13088. "&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
  13089. fmt.Println(api)
  13090. } else {
  13091. 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 +
  13092. "&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)
  13093. }
  13094. resp, requestErr := http.Get(api)
  13095. if requestErr != nil {
  13096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13097. return
  13098. }
  13099. body, ioErr := ioutil.ReadAll(resp.Body)
  13100. if ioErr != nil {
  13101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13103. return
  13104. }
  13105. var respJSON map[string]interface{}
  13106. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13109. return
  13110. }
  13111. var status string
  13112. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13113. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13114. //console.log()
  13115. fmt.Println("type===")
  13116. fmt.Println(card_type)
  13117. var token string
  13118. var res ResultTwo //1101结果
  13119. var res10265 ResultTwo10265 //1101结果
  13120. var card_info string //卡信息
  13121. var busi_card_info string
  13122. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13123. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13124. if status == "0" { //读卡成功
  13125. if card_type == "1" {
  13126. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13127. result, _ := json.Marshal(respJSON)
  13128. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13129. utils.ErrorLog("解析失败:%v", err)
  13130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13131. return
  13132. }
  13133. res.ErrMsg = res10265.ErrMsg
  13134. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13135. res.Infcode = infocode
  13136. res.Output = res10265.Output
  13137. res.InfRefmsgid = res10265.InfRefmsgid
  13138. } else {
  13139. //var card_info string //卡信息
  13140. //var busi_card_info string
  13141. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13142. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13143. //fmt.Println(card_info)
  13144. //fmt.Println(busi_card_info)
  13145. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13146. result, _ := json.Marshal(respJSON)
  13147. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13148. utils.ErrorLog("解析失败:%v", err)
  13149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13150. return
  13151. }
  13152. res.ErrMsg = res10265.ErrMsg
  13153. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13154. res.Infcode = infocode
  13155. res.Output = res10265.Output
  13156. res.InfRefmsgid = res10265.InfRefmsgid
  13157. }
  13158. if res.Infcode == 0 {
  13159. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13160. if err == gorm.ErrRecordNotFound {
  13161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13162. return
  13163. } else if err != nil {
  13164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13165. return
  13166. } else {
  13167. if card_type == "1" {
  13168. bas := strings.Split(card_info, "|")
  13169. basNumber := bas[2]
  13170. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13171. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13172. infoStr := string(Iinfos)
  13173. idetinfoStr := string(Idetinfos)
  13174. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13175. psn := &models.HisPsn{
  13176. PsnNo: res.Output.Baseinfo.PsnNo,
  13177. PatientId: patient.ID,
  13178. Certno: res.Output.Baseinfo.Certno,
  13179. Brdy: b,
  13180. Age: float64(age),
  13181. Gend: res.Output.Baseinfo.Gend,
  13182. Naty: res.Output.Baseinfo.Naty,
  13183. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13184. PsnName: res.Output.Baseinfo.PsnName,
  13185. Idetinfo: idetinfoStr,
  13186. Insuinfo: infoStr,
  13187. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13188. CardInfo: card_info,
  13189. VerifyNumber: busi_card_info,
  13190. }
  13191. service.CreateHisPsn(psn)
  13192. var rf []*ResultFive
  13193. json.Unmarshal([]byte(infoStr), &rf)
  13194. var insutypes []*ResultFive
  13195. var insutype string
  13196. var is390 int = 0
  13197. var is310 int = 0
  13198. for _, item := range rf {
  13199. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13200. insutypes = append(insutypes, item)
  13201. }
  13202. }
  13203. if len(insutypes) == 1 {
  13204. insutype = insutypes[0].Insutype
  13205. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13206. } else {
  13207. for _, i := range insutypes {
  13208. if i.Insutype == "390" {
  13209. is390 = 1
  13210. }
  13211. if i.Insutype == "310" {
  13212. is310 = 1
  13213. }
  13214. }
  13215. }
  13216. if is390 == 1 {
  13217. insutype = "390"
  13218. }
  13219. if is310 == 1 {
  13220. insutype = "310"
  13221. }
  13222. if len(insutypes) == 0 {
  13223. insutype = "310"
  13224. }
  13225. c.ServeSuccessJSON(map[string]interface{}{
  13226. "patient": patient,
  13227. "number": basNumber,
  13228. "insutype": insutype,
  13229. })
  13230. } else {
  13231. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13232. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13233. infoStr := string(Iinfos)
  13234. idetinfoStr := string(Idetinfos)
  13235. psn := &models.HisPsn{
  13236. PsnNo: res.Output.Baseinfo.PsnNo,
  13237. PatientId: patient.ID,
  13238. Certno: res.Output.Baseinfo.Certno,
  13239. Gend: res.Output.Baseinfo.Gend,
  13240. Naty: res.Output.Baseinfo.Naty,
  13241. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13242. PsnName: res.Output.Baseinfo.PsnName,
  13243. Idetinfo: idetinfoStr,
  13244. Insuinfo: infoStr,
  13245. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13246. CardInfo: card_info,
  13247. VerifyNumber: token,
  13248. }
  13249. service.CreateHisPsn(psn)
  13250. c.ServeSuccessJSON(map[string]interface{}{
  13251. "patient": patient,
  13252. "number": token,
  13253. })
  13254. }
  13255. }
  13256. } else {
  13257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13258. return
  13259. }
  13260. } else { //读卡失败
  13261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13262. return
  13263. }
  13264. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13265. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13266. cardnum = DeleteExtraSpaceTwo(cardnum)
  13267. cardCode = DeleteExtraSpaceTwo(cardCode)
  13268. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13269. name = DeleteExtraSpaceTwo(name)
  13270. errmsg = DeleteExtraSpaceTwo(errmsg)
  13271. cardnum = Remove0000(cardnum)
  13272. cardCode = Remove0000(cardCode)
  13273. id_card_no = Remove0000(id_card_no)
  13274. name = Remove0000(name)
  13275. errmsg = Remove0000(errmsg)
  13276. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13277. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13278. //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)
  13279. //fmt.Println(result2)
  13280. //fmt.Println(requestLog2)
  13281. //fmt.Println(errMsgLog2)
  13282. 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)
  13283. saveLog(result, requestLog, "1101", "获取人员信息")
  13284. fmt.Println(errMsgLog)
  13285. if len(errMsgLog) > 0 {
  13286. } else {
  13287. var dat map[string]interface{}
  13288. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13289. fmt.Println(dat)
  13290. } else {
  13291. fmt.Println(err)
  13292. }
  13293. userJSONBytes, _ := json.Marshal(dat)
  13294. var res ResultTwo
  13295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13296. utils.ErrorLog("解析失败:%v", err)
  13297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13298. return
  13299. }
  13300. res.ErrMsg = errMsgLog
  13301. if res.Infcode == 0 {
  13302. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13303. if err == gorm.ErrRecordNotFound {
  13304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13305. return
  13306. } else if err != nil {
  13307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13308. return
  13309. } else {
  13310. fmt.Println(res)
  13311. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13312. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13313. infoStr := string(Iinfos)
  13314. idetinfoStr := string(Idetinfos)
  13315. var rf []*ResultFive
  13316. json.Unmarshal([]byte(infoStr), &rf)
  13317. var insutypes []*ResultFive
  13318. var insutype string
  13319. var is390 int = 0
  13320. var is310 int = 0
  13321. for _, item := range rf {
  13322. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13323. insutypes = append(insutypes, item)
  13324. }
  13325. }
  13326. if len(insutypes) == 1 {
  13327. insutype = insutypes[0].Insutype
  13328. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13329. } else {
  13330. for _, i := range insutypes {
  13331. if i.Insutype == "390" {
  13332. is390 = 1
  13333. }
  13334. if i.Insutype == "310" {
  13335. is310 = 1
  13336. }
  13337. }
  13338. }
  13339. if is390 == 1 {
  13340. insutype = "390"
  13341. }
  13342. if is310 == 1 {
  13343. insutype = "310"
  13344. }
  13345. if len(insutypes) == 0 {
  13346. insutype = "390"
  13347. }
  13348. var insuplc_admdvs string
  13349. for _, item := range rf {
  13350. if item.Insutype == insutype {
  13351. insuplc_admdvs = item.InsuplcAdmdvs
  13352. }
  13353. }
  13354. psn := &models.HisPsn{
  13355. PsnNo: res.Output.Baseinfo.PsnNo,
  13356. PatientId: patient.ID,
  13357. Certno: res.Output.Baseinfo.Certno,
  13358. Gend: res.Output.Baseinfo.Gend,
  13359. Naty: res.Output.Baseinfo.Naty,
  13360. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13361. PsnName: res.Output.Baseinfo.PsnName,
  13362. Idetinfo: idetinfoStr,
  13363. Insuinfo: infoStr,
  13364. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13365. CardInfo: basStr,
  13366. VerifyNumber: "",
  13367. InsuplcAdmdvs: insuplc_admdvs,
  13368. }
  13369. service.CreateHisPsn(psn)
  13370. c.ServeSuccessJSON(map[string]interface{}{
  13371. "patient": patient,
  13372. "number": cardnum,
  13373. "insutype": insutype,
  13374. })
  13375. }
  13376. } else {
  13377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13378. return
  13379. }
  13380. }
  13381. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13382. fmt.Println(initFlag)
  13383. fmt.Println("initFlag")
  13384. if initFlag == 0 {
  13385. c.TestGetJiangXiBasBaseInit()
  13386. }
  13387. basStr := c.GetBasBaseInfo()
  13388. if len(basStr) == 0 {
  13389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13390. return
  13391. }
  13392. fmt.Println(basStr)
  13393. bas := strings.Split(basStr, "|")
  13394. basNumber := bas[1]
  13395. fmt.Println(basNumber)
  13396. card_sn := bas[3]
  13397. fmt.Println(card_sn)
  13398. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13399. 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)
  13400. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13401. var dat map[string]interface{}
  13402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13403. fmt.Println(dat)
  13404. } else {
  13405. fmt.Println(err)
  13406. }
  13407. userJSONBytes, _ := json.Marshal(dat)
  13408. var res ResultTwo
  13409. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13410. utils.ErrorLog("解析失败:%v", err)
  13411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13412. return
  13413. }
  13414. if res.Infcode == 0 {
  13415. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13416. if err == gorm.ErrRecordNotFound {
  13417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13418. return
  13419. } else if err != nil {
  13420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13421. return
  13422. } else {
  13423. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13424. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13425. infoStr := string(Iinfos)
  13426. idetinfoStr := string(Idetinfos)
  13427. var rf []*ResultFive
  13428. json.Unmarshal([]byte(infoStr), &rf)
  13429. var insutypes []*ResultFive
  13430. var insutype string
  13431. var is390 int = 0
  13432. var is310 int = 0
  13433. var insuplc_admdvs string
  13434. for _, item := range rf {
  13435. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13436. insutypes = append(insutypes, item)
  13437. }
  13438. }
  13439. if len(insutypes) == 1 {
  13440. insutype = insutypes[0].Insutype
  13441. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13442. } else {
  13443. for _, i := range insutypes {
  13444. if i.Insutype == "390" {
  13445. is390 = 1
  13446. }
  13447. if i.Insutype == "310" {
  13448. is310 = 1
  13449. }
  13450. }
  13451. }
  13452. if is390 == 1 {
  13453. insutype = "390"
  13454. }
  13455. if is310 == 1 {
  13456. insutype = "310"
  13457. }
  13458. if len(insutypes) == 0 {
  13459. insutype = "310"
  13460. }
  13461. for _, item := range rf {
  13462. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13463. insuplc_admdvs = item.InsuplcAdmdvs
  13464. }
  13465. }
  13466. psn := &models.HisPsn{
  13467. PsnNo: res.Output.Baseinfo.PsnNo,
  13468. PatientId: patient.ID,
  13469. Certno: res.Output.Baseinfo.Certno,
  13470. Gend: res.Output.Baseinfo.Gend,
  13471. Naty: res.Output.Baseinfo.Naty,
  13472. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13473. PsnName: res.Output.Baseinfo.PsnName,
  13474. Idetinfo: idetinfoStr,
  13475. Insuinfo: infoStr,
  13476. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13477. CardInfo: basStr,
  13478. InsuplcAdmdvs: insuplc_admdvs,
  13479. VerifyNumber: "",
  13480. }
  13481. service.CreateHisPsn(psn)
  13482. c.ServeSuccessJSON(map[string]interface{}{
  13483. "patient": patient,
  13484. "number": basNumber,
  13485. "insutype": insutype,
  13486. })
  13487. }
  13488. } else {
  13489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13490. return
  13491. }
  13492. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13493. basStr := c.GetBasBaseInfo22222()
  13494. fmt.Println(basStr)
  13495. if len(basStr) == 0 {
  13496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13497. return
  13498. }
  13499. fmt.Println(basStr)
  13500. bas := strings.Split(basStr, "|")
  13501. basNumber := bas[2] //卡号
  13502. card_sn := bas[3] //
  13503. id_card_No := bas[1] //卡号
  13504. fmt.Println(basNumber)
  13505. fmt.Println(card_sn)
  13506. fmt.Println(id_card_No)
  13507. var patient service.Patients
  13508. if len(id_card_No) == 0 {
  13509. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13510. } else {
  13511. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13512. }
  13513. 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)
  13514. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13515. var dat map[string]interface{}
  13516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13517. fmt.Println(dat)
  13518. } else {
  13519. fmt.Println(err)
  13520. }
  13521. userJSONBytes, _ := json.Marshal(dat)
  13522. var res ResultTwo
  13523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13524. utils.ErrorLog("解析失败:%v", err)
  13525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13526. return
  13527. }
  13528. if res.Infcode == 0 {
  13529. var pateint2 service.Patients
  13530. var err error
  13531. if len(id_card_No) == 0 {
  13532. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13533. } else {
  13534. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13535. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13536. }
  13537. if err == gorm.ErrRecordNotFound {
  13538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13539. return
  13540. } else if err != nil {
  13541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13542. return
  13543. } else {
  13544. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13545. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13546. infoStr := string(Iinfos)
  13547. idetinfoStr := string(Idetinfos)
  13548. var rf []*ResultFive
  13549. json.Unmarshal([]byte(infoStr), &rf)
  13550. var insutypes []*ResultFive
  13551. var insutype string
  13552. var is390 int = 0
  13553. var is310 int = 0
  13554. var insuplc_admdvs string
  13555. for _, item := range rf {
  13556. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13557. insutypes = append(insutypes, item)
  13558. }
  13559. }
  13560. if len(insutypes) == 1 {
  13561. insutype = insutypes[0].Insutype
  13562. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13563. } else {
  13564. for _, i := range insutypes {
  13565. if i.Insutype == "390" {
  13566. is390 = 1
  13567. }
  13568. if i.Insutype == "310" {
  13569. is310 = 1
  13570. }
  13571. }
  13572. }
  13573. if is390 == 1 {
  13574. insutype = "390"
  13575. }
  13576. if is310 == 1 {
  13577. insutype = "310"
  13578. }
  13579. if len(insutypes) == 0 {
  13580. insutype = "310"
  13581. }
  13582. for _, item := range rf {
  13583. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13584. insuplc_admdvs = item.InsuplcAdmdvs
  13585. }
  13586. }
  13587. psn := &models.HisPsn{
  13588. PsnNo: res.Output.Baseinfo.PsnNo,
  13589. PatientId: pateint2.ID,
  13590. Certno: res.Output.Baseinfo.Certno,
  13591. Gend: res.Output.Baseinfo.Gend,
  13592. Naty: res.Output.Baseinfo.Naty,
  13593. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13594. PsnName: res.Output.Baseinfo.PsnName,
  13595. Idetinfo: idetinfoStr,
  13596. Insuinfo: infoStr,
  13597. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13598. CardInfo: basStr,
  13599. InsuplcAdmdvs: insuplc_admdvs,
  13600. VerifyNumber: "",
  13601. }
  13602. service.CreateHisPsn(psn)
  13603. c.ServeSuccessJSON(map[string]interface{}{
  13604. "patient": patient,
  13605. "number": basNumber,
  13606. "insutype": insutype,
  13607. })
  13608. }
  13609. } else {
  13610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13611. return
  13612. }
  13613. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13614. fmt.Println(initFlag)
  13615. fmt.Println("initFlag")
  13616. if initFlag == 0 {
  13617. c.TestGetHnBasBaseInit()
  13618. }
  13619. basStr := c.GetBasBaseInfo()
  13620. if len(basStr) == 0 {
  13621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13622. return
  13623. }
  13624. fmt.Println(basStr)
  13625. bas := strings.Split(basStr, "|")
  13626. basNumber := bas[1]
  13627. fmt.Println(basNumber)
  13628. card_sn := bas[3]
  13629. card_no := bas[2]
  13630. fmt.Println(card_sn)
  13631. name := bas[4]
  13632. name = ConvertToString(name, "gbk", "utf-8")
  13633. 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)
  13634. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13635. var dat map[string]interface{}
  13636. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13637. fmt.Println(dat)
  13638. } else {
  13639. fmt.Println(err)
  13640. }
  13641. userJSONBytes, _ := json.Marshal(dat)
  13642. var res ResultTwo
  13643. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13644. utils.ErrorLog("解析失败:%v", err)
  13645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13646. return
  13647. }
  13648. if res.Infcode == 0 {
  13649. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13650. if err == gorm.ErrRecordNotFound {
  13651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13652. return
  13653. } else if err != nil {
  13654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13655. return
  13656. } else {
  13657. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13658. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13659. infoStr := string(Iinfos)
  13660. idetinfoStr := string(Idetinfos)
  13661. psn := &models.HisPsn{
  13662. PsnNo: res.Output.Baseinfo.PsnNo,
  13663. PatientId: patient.ID,
  13664. Certno: res.Output.Baseinfo.Certno,
  13665. Gend: res.Output.Baseinfo.Gend,
  13666. Naty: res.Output.Baseinfo.Naty,
  13667. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13668. PsnName: res.Output.Baseinfo.PsnName,
  13669. Idetinfo: idetinfoStr,
  13670. Insuinfo: infoStr,
  13671. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13672. CardInfo: basStr,
  13673. VerifyNumber: "",
  13674. }
  13675. service.CreateHisPsn(psn)
  13676. var rf []*ResultFive
  13677. json.Unmarshal([]byte(infoStr), &rf)
  13678. var insutypes []*ResultFive
  13679. var insutype string
  13680. var is390 int = 0
  13681. var is310 int = 0
  13682. for _, item := range rf {
  13683. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13684. insutypes = append(insutypes, item)
  13685. }
  13686. }
  13687. if len(insutypes) == 1 {
  13688. insutype = insutypes[0].Insutype
  13689. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13690. } else {
  13691. for _, i := range insutypes {
  13692. if i.Insutype == "390" {
  13693. is390 = 1
  13694. }
  13695. if i.Insutype == "310" {
  13696. is310 = 1
  13697. }
  13698. }
  13699. }
  13700. if is390 == 1 {
  13701. insutype = "390"
  13702. }
  13703. if is310 == 1 {
  13704. insutype = "310"
  13705. }
  13706. if len(insutypes) == 0 {
  13707. insutype = "310"
  13708. }
  13709. c.ServeSuccessJSON(map[string]interface{}{
  13710. "patient": patient,
  13711. "number": basNumber,
  13712. "insutype": insutype,
  13713. })
  13714. }
  13715. } else {
  13716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13717. return
  13718. }
  13719. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13720. var api string
  13721. 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 +
  13722. "&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
  13723. fmt.Println(api)
  13724. resp, requestErr := http.Get(api)
  13725. if requestErr != nil {
  13726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13727. return
  13728. }
  13729. body, ioErr := ioutil.ReadAll(resp.Body)
  13730. if ioErr != nil {
  13731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13733. return
  13734. }
  13735. var respJSON map[string]interface{}
  13736. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13739. return
  13740. }
  13741. var res ResultTwo //1101结果
  13742. var res10265 ResultTwo10265 //1101结果
  13743. var card_info string //卡信息
  13744. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13745. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13746. result, _ := json.Marshal(respJSON)
  13747. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13748. utils.ErrorLog("解析失败:%v", err)
  13749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13750. return
  13751. }
  13752. res.ErrMsg = res10265.ErrMsg
  13753. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13754. res.Infcode = infocode
  13755. res.Output = res10265.Output
  13756. res.InfRefmsgid = res10265.InfRefmsgid
  13757. if res.Infcode == 0 {
  13758. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13759. if err == gorm.ErrRecordNotFound {
  13760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13761. return
  13762. } else if err != nil {
  13763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13764. return
  13765. } else {
  13766. bas := strings.Split(card_info, "|")
  13767. basNumber := bas[2]
  13768. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13769. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13770. infoStr := string(Iinfos)
  13771. idetinfoStr := string(Idetinfos)
  13772. psn := &models.HisPsn{
  13773. PsnNo: res.Output.Baseinfo.PsnNo,
  13774. PatientId: patient.ID,
  13775. Certno: res.Output.Baseinfo.Certno,
  13776. Gend: res.Output.Baseinfo.Gend,
  13777. Naty: res.Output.Baseinfo.Naty,
  13778. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13779. PsnName: res.Output.Baseinfo.PsnName,
  13780. Idetinfo: idetinfoStr,
  13781. Insuinfo: infoStr,
  13782. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13783. CardInfo: card_info,
  13784. VerifyNumber: token,
  13785. }
  13786. service.CreateHisPsn(psn)
  13787. var rf []*ResultFive
  13788. json.Unmarshal([]byte(infoStr), &rf)
  13789. var insutypes []*ResultFive
  13790. var insutype string
  13791. var is390 int = 0
  13792. var is310 int = 0
  13793. for _, item := range rf {
  13794. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13795. insutypes = append(insutypes, item)
  13796. }
  13797. }
  13798. if len(insutypes) == 1 {
  13799. insutype = insutypes[0].Insutype
  13800. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13801. } else {
  13802. for _, i := range insutypes {
  13803. if i.Insutype == "390" {
  13804. is390 = 1
  13805. }
  13806. if i.Insutype == "310" {
  13807. is310 = 1
  13808. }
  13809. }
  13810. }
  13811. if is390 == 1 {
  13812. insutype = "390"
  13813. }
  13814. if is310 == 1 {
  13815. insutype = "310"
  13816. }
  13817. if len(insutypes) == 0 {
  13818. insutype = "310"
  13819. }
  13820. c.ServeSuccessJSON(map[string]interface{}{
  13821. "patient": patient,
  13822. "number": basNumber,
  13823. "insutype": insutype,
  13824. })
  13825. }
  13826. } else {
  13827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13828. return
  13829. }
  13830. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13831. res := c.GetoleInfo()
  13832. if res.Infcode == 0 {
  13833. var result string
  13834. if res.Output.MdtrtCertType == "01" {
  13835. 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)
  13836. } else if res.Output.MdtrtCertType == "02" {
  13837. 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)
  13838. } else if res.Output.MdtrtCertType == "03" {
  13839. 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)
  13840. }
  13841. var dat map[string]interface{}
  13842. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13843. fmt.Println(dat)
  13844. } else {
  13845. fmt.Println(err)
  13846. }
  13847. userJSONBytes, _ := json.Marshal(dat)
  13848. var res2 ResultTwo
  13849. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13850. utils.ErrorLog("解析失败:%v", err)
  13851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13852. return
  13853. }
  13854. if res2.Infcode == 0 {
  13855. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13856. if err == gorm.ErrRecordNotFound {
  13857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13858. return
  13859. } else if err != nil {
  13860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13861. return
  13862. } else {
  13863. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13864. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13865. infoStr := string(Iinfos)
  13866. idetinfoStr := string(Idetinfos)
  13867. var rf []*ResultFive
  13868. json.Unmarshal([]byte(infoStr), &rf)
  13869. var insutypes []*ResultFive
  13870. var insutype string
  13871. var is390 int = 0
  13872. var is310 int = 0
  13873. //var insuplc_admdvs string
  13874. for _, item := range rf {
  13875. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13876. insutypes = append(insutypes, item)
  13877. }
  13878. }
  13879. if len(insutypes) == 1 {
  13880. insutype = insutypes[0].Insutype
  13881. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13882. } else {
  13883. for _, i := range insutypes {
  13884. if i.Insutype == "390" {
  13885. is390 = 1
  13886. }
  13887. if i.Insutype == "310" {
  13888. is310 = 1
  13889. }
  13890. }
  13891. }
  13892. if is390 == 1 {
  13893. insutype = "390"
  13894. }
  13895. if is310 == 1 {
  13896. insutype = "310"
  13897. }
  13898. if len(insutypes) == 0 {
  13899. insutype = "310"
  13900. }
  13901. psn := &models.HisPsn{
  13902. PsnNo: res2.Output.Baseinfo.PsnNo,
  13903. PatientId: patient.ID,
  13904. Certno: res2.Output.Baseinfo.Certno,
  13905. Gend: res2.Output.Baseinfo.Gend,
  13906. Naty: res2.Output.Baseinfo.Naty,
  13907. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13908. PsnName: res2.Output.Baseinfo.PsnName,
  13909. Idetinfo: idetinfoStr,
  13910. Insuinfo: infoStr,
  13911. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13912. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13913. VerifyNumber: res.Output.EcToken,
  13914. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13915. }
  13916. if res.Output.MdtrtCertType == "01" {
  13917. psn.VerifyNumber = res.Output.EcToken
  13918. //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)
  13919. } else if res.Output.MdtrtCertType == "02" {
  13920. psn.VerifyNumber = res.Output.MdtrtCertNo
  13921. //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)
  13922. } else if res.Output.MdtrtCertType == "03" {
  13923. psn.VerifyNumber = res.Output.MdtrtCertNo
  13924. //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)
  13925. }
  13926. var balc float64
  13927. for _, item := range rf {
  13928. if item.Insutype == insutype {
  13929. balc = item.Balc
  13930. }
  13931. }
  13932. service.CreateHisPsn(psn)
  13933. c.ServeSuccessJSON(map[string]interface{}{
  13934. "patient": patient,
  13935. "number": res.Output.CardNo,
  13936. "insutype": insutype,
  13937. "blac": balc,
  13938. "desc": idetinfoStr,
  13939. })
  13940. }
  13941. } else {
  13942. c.ServeSuccessJSON(map[string]interface{}{
  13943. "failed_code": -10,
  13944. "msg": res2.ErrMsg,
  13945. })
  13946. }
  13947. } else {
  13948. c.ServeSuccessJSON(map[string]interface{}{
  13949. "failed_code": -10,
  13950. "msg": res.ErrMsg,
  13951. })
  13952. }
  13953. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13954. var api string
  13955. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13956. "&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
  13957. fmt.Println(api)
  13958. resp, requestErr := http.Get(api)
  13959. if requestErr != nil {
  13960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13961. return
  13962. }
  13963. body, ioErr := ioutil.ReadAll(resp.Body)
  13964. if ioErr != nil {
  13965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13967. return
  13968. }
  13969. var respJSON map[string]interface{}
  13970. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13973. return
  13974. }
  13975. var status string
  13976. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13977. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13978. //console.log()
  13979. fmt.Println("type===")
  13980. fmt.Println(card_type)
  13981. var token string
  13982. var res ResultTwo //1101结果
  13983. //var res10265 ResultTwoesultTwo10265 //1101结果
  13984. var card_info string //卡信息
  13985. var busi_card_info string
  13986. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13987. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13988. if status == "0" { //读卡成功
  13989. if card_type == "1" {
  13990. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13991. result, _ := json.Marshal(respJSON)
  13992. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13993. utils.ErrorLog("解析失败:%v", err)
  13994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13995. return
  13996. }
  13997. } else {
  13998. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13999. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14000. result, _ := json.Marshal(respJSON)
  14001. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14002. utils.ErrorLog("解析失败:%v", err)
  14003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14004. return
  14005. }
  14006. }
  14007. if res.Infcode == 0 {
  14008. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14009. if err == gorm.ErrRecordNotFound {
  14010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14011. return
  14012. } else if err != nil {
  14013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14014. return
  14015. } else {
  14016. if card_type == "1" {
  14017. bas := strings.Split(card_info, "|")
  14018. basNumber := bas[2]
  14019. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14020. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14021. infoStr := string(Iinfos)
  14022. idetinfoStr := string(Idetinfos)
  14023. psn := &models.HisPsn{
  14024. PsnNo: res.Output.Baseinfo.PsnNo,
  14025. PatientId: patient.ID,
  14026. Certno: res.Output.Baseinfo.Certno,
  14027. Gend: res.Output.Baseinfo.Gend,
  14028. Naty: res.Output.Baseinfo.Naty,
  14029. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14030. PsnName: res.Output.Baseinfo.PsnName,
  14031. Idetinfo: idetinfoStr,
  14032. Insuinfo: infoStr,
  14033. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14034. CardInfo: card_info,
  14035. VerifyNumber: busi_card_info,
  14036. }
  14037. service.CreateHisPsn(psn)
  14038. var rf []*ResultFive
  14039. json.Unmarshal([]byte(infoStr), &rf)
  14040. var insutypes []*ResultFive
  14041. var insutype string
  14042. var is390 int = 0
  14043. var is310 int = 0
  14044. for _, item := range rf {
  14045. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14046. insutypes = append(insutypes, item)
  14047. }
  14048. }
  14049. if len(insutypes) == 1 {
  14050. insutype = insutypes[0].Insutype
  14051. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14052. } else {
  14053. for _, i := range insutypes {
  14054. if i.Insutype == "390" {
  14055. is390 = 1
  14056. }
  14057. if i.Insutype == "310" {
  14058. is310 = 1
  14059. }
  14060. }
  14061. }
  14062. if is390 == 1 {
  14063. insutype = "390"
  14064. }
  14065. if is310 == 1 {
  14066. insutype = "310"
  14067. }
  14068. if len(insutypes) == 0 {
  14069. insutype = "310"
  14070. }
  14071. c.ServeSuccessJSON(map[string]interface{}{
  14072. "patient": patient,
  14073. "number": basNumber,
  14074. "insutype": insutype,
  14075. })
  14076. } else {
  14077. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14078. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14079. infoStr := string(Iinfos)
  14080. idetinfoStr := string(Idetinfos)
  14081. psn := &models.HisPsn{
  14082. PsnNo: res.Output.Baseinfo.PsnNo,
  14083. PatientId: patient.ID,
  14084. Certno: res.Output.Baseinfo.Certno,
  14085. Gend: res.Output.Baseinfo.Gend,
  14086. Naty: res.Output.Baseinfo.Naty,
  14087. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14088. PsnName: res.Output.Baseinfo.PsnName,
  14089. Idetinfo: idetinfoStr,
  14090. Insuinfo: infoStr,
  14091. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14092. CardInfo: card_info,
  14093. VerifyNumber: token,
  14094. }
  14095. service.CreateHisPsn(psn)
  14096. c.ServeSuccessJSON(map[string]interface{}{
  14097. "patient": patient,
  14098. "number": token,
  14099. })
  14100. }
  14101. }
  14102. } else {
  14103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14104. return
  14105. }
  14106. } else { //读卡失败
  14107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14108. return
  14109. }
  14110. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14111. var api string
  14112. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14113. "&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
  14114. fmt.Println(api)
  14115. resp, requestErr := http.Get(api)
  14116. if requestErr != nil {
  14117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14118. return
  14119. }
  14120. body, ioErr := ioutil.ReadAll(resp.Body)
  14121. if ioErr != nil {
  14122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14124. return
  14125. }
  14126. var respJSON map[string]interface{}
  14127. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14130. return
  14131. }
  14132. var status string
  14133. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14134. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14135. //console.log()
  14136. fmt.Println("type===")
  14137. fmt.Println(card_type)
  14138. var token string
  14139. var res ResultTwo //1101结果
  14140. //var res10265 ResultTwoesultTwo10265 //1101结果
  14141. var card_info string //卡信息
  14142. //var busi_card_info string
  14143. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14144. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14145. if status == "0" { //读卡成功
  14146. if card_type == "1" {
  14147. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14148. result, _ := json.Marshal(respJSON)
  14149. fmt.Println(result)
  14150. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14151. utils.ErrorLog("解析失败:%v", err)
  14152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14153. return
  14154. }
  14155. fmt.Println(res)
  14156. } else {
  14157. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14158. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14159. result, _ := json.Marshal(respJSON)
  14160. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14161. utils.ErrorLog("解析失败:%v", err)
  14162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14163. return
  14164. }
  14165. }
  14166. if res.Infcode == 0 {
  14167. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14168. if err == gorm.ErrRecordNotFound {
  14169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14170. return
  14171. } else if err != nil {
  14172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14173. return
  14174. } else {
  14175. if card_type == "1" {
  14176. bas := strings.Split(card_info, "|")
  14177. basNumber := bas[2]
  14178. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14179. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14180. infoStr := string(Iinfos)
  14181. idetinfoStr := string(Idetinfos)
  14182. psn := &models.HisPsn{
  14183. PsnNo: res.Output.Baseinfo.PsnNo,
  14184. PatientId: patient.ID,
  14185. Certno: res.Output.Baseinfo.Certno,
  14186. Gend: res.Output.Baseinfo.Gend,
  14187. Naty: res.Output.Baseinfo.Naty,
  14188. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14189. PsnName: res.Output.Baseinfo.PsnName,
  14190. Idetinfo: idetinfoStr,
  14191. Insuinfo: infoStr,
  14192. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14193. CardInfo: card_info,
  14194. //VerifyNumber: busi_card_info,
  14195. }
  14196. service.CreateHisPsn(psn)
  14197. var rf []*ResultFive
  14198. json.Unmarshal([]byte(infoStr), &rf)
  14199. var insutypes []*ResultFive
  14200. var insutype string
  14201. var is390 int = 0
  14202. var is310 int = 0
  14203. for _, item := range rf {
  14204. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14205. insutypes = append(insutypes, item)
  14206. }
  14207. }
  14208. if len(insutypes) == 1 {
  14209. insutype = insutypes[0].Insutype
  14210. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14211. } else {
  14212. for _, i := range insutypes {
  14213. if i.Insutype == "390" {
  14214. is390 = 1
  14215. }
  14216. if i.Insutype == "310" {
  14217. is310 = 1
  14218. }
  14219. }
  14220. }
  14221. if is390 == 1 {
  14222. insutype = "390"
  14223. }
  14224. if is310 == 1 {
  14225. insutype = "310"
  14226. }
  14227. if len(insutypes) == 0 {
  14228. insutype = "310"
  14229. }
  14230. c.ServeSuccessJSON(map[string]interface{}{
  14231. "patient": patient,
  14232. "number": basNumber,
  14233. "insutype": insutype,
  14234. })
  14235. } else {
  14236. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14237. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14238. infoStr := string(Iinfos)
  14239. idetinfoStr := string(Idetinfos)
  14240. psn := &models.HisPsn{
  14241. PsnNo: res.Output.Baseinfo.PsnNo,
  14242. PatientId: patient.ID,
  14243. Certno: res.Output.Baseinfo.Certno,
  14244. Gend: res.Output.Baseinfo.Gend,
  14245. Naty: res.Output.Baseinfo.Naty,
  14246. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14247. PsnName: res.Output.Baseinfo.PsnName,
  14248. Idetinfo: idetinfoStr,
  14249. Insuinfo: infoStr,
  14250. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14251. CardInfo: card_info,
  14252. VerifyNumber: token,
  14253. }
  14254. service.CreateHisPsn(psn)
  14255. c.ServeSuccessJSON(map[string]interface{}{
  14256. "patient": patient,
  14257. "number": token,
  14258. })
  14259. }
  14260. }
  14261. } else {
  14262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14263. return
  14264. }
  14265. } else { //读卡失败
  14266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14267. return
  14268. }
  14269. } else {
  14270. if initFlag == 0 {
  14271. c.TestGetBasBaseInit()
  14272. }
  14273. basStr := c.GetBasBaseInfo()
  14274. if len(basStr) == 0 {
  14275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14276. return
  14277. }
  14278. fmt.Println(basStr)
  14279. bas := strings.Split(basStr, "|")
  14280. basNumber := bas[1]
  14281. fmt.Println(basNumber)
  14282. card_sn := bas[3]
  14283. fmt.Println(card_sn)
  14284. cardNumber := bas[2]
  14285. fmt.Println(cardNumber)
  14286. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14287. var result string
  14288. if bas[0][:2] == "44" {
  14289. 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)
  14290. } else {
  14291. 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)
  14292. }
  14293. var dat map[string]interface{}
  14294. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14295. fmt.Println(dat)
  14296. } else {
  14297. fmt.Println(err)
  14298. }
  14299. userJSONBytes, _ := json.Marshal(dat)
  14300. var res ResultTwo
  14301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14302. utils.ErrorLog("解析失败:%v", err)
  14303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14304. return
  14305. }
  14306. if res.Infcode == 0 {
  14307. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14308. if err == gorm.ErrRecordNotFound {
  14309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14310. return
  14311. } else if err != nil {
  14312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14313. return
  14314. } else {
  14315. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14316. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14317. infoStr := string(Iinfos)
  14318. idetinfoStr := string(Idetinfos)
  14319. var rf []*ResultFive
  14320. json.Unmarshal([]byte(infoStr), &rf)
  14321. var insutypes []*ResultFive
  14322. var insutype string
  14323. var is390 int = 0
  14324. var is310 int = 0
  14325. var insuplc_admdvs string
  14326. for _, item := range rf {
  14327. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14328. insutypes = append(insutypes, item)
  14329. }
  14330. }
  14331. if len(insutypes) == 1 {
  14332. insutype = insutypes[0].Insutype
  14333. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14334. } else {
  14335. for _, i := range insutypes {
  14336. if i.Insutype == "390" {
  14337. is390 = 1
  14338. }
  14339. if i.Insutype == "310" {
  14340. is310 = 1
  14341. }
  14342. }
  14343. }
  14344. if is390 == 1 {
  14345. insutype = "390"
  14346. }
  14347. if is310 == 1 {
  14348. insutype = "310"
  14349. }
  14350. if len(insutypes) == 0 {
  14351. insutype = "310"
  14352. }
  14353. for _, item := range rf {
  14354. if item.Insutype == insutype {
  14355. insuplc_admdvs = item.InsuplcAdmdvs
  14356. }
  14357. }
  14358. psn := &models.HisPsn{
  14359. PsnNo: res.Output.Baseinfo.PsnNo,
  14360. PatientId: patient.ID,
  14361. Certno: res.Output.Baseinfo.Certno,
  14362. Gend: res.Output.Baseinfo.Gend,
  14363. Naty: res.Output.Baseinfo.Naty,
  14364. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14365. PsnName: res.Output.Baseinfo.PsnName,
  14366. Idetinfo: idetinfoStr,
  14367. Insuinfo: infoStr,
  14368. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14369. CardInfo: basStr,
  14370. VerifyNumber: "",
  14371. InsuplcAdmdvs: insuplc_admdvs,
  14372. }
  14373. service.CreateHisPsn(psn)
  14374. c.ServeSuccessJSON(map[string]interface{}{
  14375. "patient": patient,
  14376. "number": basNumber,
  14377. })
  14378. }
  14379. } else {
  14380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14381. return
  14382. }
  14383. break
  14384. }
  14385. case 2:
  14386. if miConfig.MdtrtareaAdmvs == "430800" {
  14387. if initFlag == 0 {
  14388. c.TestGetHnBasBaseInit()
  14389. }
  14390. SFZStr := c.GetSFZBaseInfo()
  14391. if len(SFZStr) == 0 {
  14392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14393. return
  14394. }
  14395. fmt.Println(SFZStr)
  14396. id_card_str := strings.Split(SFZStr, "^")
  14397. card_no := id_card_str[0]
  14398. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14399. //name := id_card_str[1]
  14400. //name = ConvertToString(name, "gbk", "utf-8")
  14401. 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)
  14402. var dat map[string]interface{}
  14403. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14404. fmt.Println(dat)
  14405. } else {
  14406. fmt.Println(err)
  14407. }
  14408. userJSONBytes, _ := json.Marshal(dat)
  14409. var res ResultTwo
  14410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14411. utils.ErrorLog("解析失败:%v", err)
  14412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14413. return
  14414. }
  14415. if res.Infcode == 0 {
  14416. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14417. if err == gorm.ErrRecordNotFound {
  14418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14419. return
  14420. } else if err != nil {
  14421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14422. return
  14423. } else {
  14424. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14425. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14426. infoStr := string(Iinfos)
  14427. idetinfoStr := string(Idetinfos)
  14428. var rf []*ResultFive
  14429. json.Unmarshal([]byte(infoStr), &rf)
  14430. var insutypes []*ResultFive
  14431. var insutype string
  14432. var is390 int = 0
  14433. var is310 int = 0
  14434. for _, item := range rf {
  14435. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14436. insutypes = append(insutypes, item)
  14437. }
  14438. }
  14439. if len(insutypes) == 1 {
  14440. insutype = insutypes[0].Insutype
  14441. } else {
  14442. for _, i := range insutypes {
  14443. if i.Insutype == "390" {
  14444. is390 = 1
  14445. }
  14446. if i.Insutype == "310" {
  14447. is310 = 1
  14448. }
  14449. }
  14450. }
  14451. if is390 == 1 {
  14452. insutype = "390"
  14453. }
  14454. if is310 == 1 {
  14455. insutype = "310"
  14456. }
  14457. if len(insutypes) == 0 {
  14458. insutype = "310"
  14459. }
  14460. var InsuplcAdmdvs string
  14461. for _, item := range rf {
  14462. if item.Insutype == insutype {
  14463. InsuplcAdmdvs = item.InsuplcAdmdvs
  14464. }
  14465. }
  14466. psn := &models.HisPsn{
  14467. PsnNo: res.Output.Baseinfo.PsnNo,
  14468. PatientId: patient.ID,
  14469. Certno: res.Output.Baseinfo.Certno,
  14470. Gend: res.Output.Baseinfo.Gend,
  14471. Naty: res.Output.Baseinfo.Naty,
  14472. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14473. PsnName: res.Output.Baseinfo.PsnName,
  14474. Idetinfo: idetinfoStr,
  14475. Insuinfo: infoStr,
  14476. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14477. CardInfo: SFZStr,
  14478. VerifyNumber: "",
  14479. InsuplcAdmdvs: InsuplcAdmdvs,
  14480. }
  14481. service.CreateHisPsn(psn)
  14482. c.ServeSuccessJSON(map[string]interface{}{
  14483. "patient": patient,
  14484. "number": card_no,
  14485. "insutype": insutype,
  14486. })
  14487. }
  14488. } else {
  14489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14490. return
  14491. }
  14492. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14493. var res ResultTwo
  14494. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14495. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14496. "&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)
  14497. resp, requestErr := http.Get(api)
  14498. if requestErr != nil {
  14499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14500. return
  14501. }
  14502. body, ioErr := ioutil.ReadAll(resp.Body)
  14503. if ioErr != nil {
  14504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14506. return
  14507. }
  14508. var respJSON map[string]interface{}
  14509. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14512. return
  14513. }
  14514. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14515. result, _ := json.Marshal(respJSON)
  14516. fmt.Println("log")
  14517. fmt.Println(string(result))
  14518. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14519. utils.ErrorLog("解析失败:%v", err)
  14520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14521. return
  14522. }
  14523. if res.Infcode == 0 {
  14524. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14525. if err == gorm.ErrRecordNotFound {
  14526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14527. return
  14528. } else if err != nil {
  14529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14530. return
  14531. } else {
  14532. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14533. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14534. infoStr := string(Iinfos)
  14535. idetinfoStr := string(Idetinfos)
  14536. psn := &models.HisPsn{
  14537. PsnNo: res.Output.Baseinfo.PsnNo,
  14538. PatientId: patient.ID,
  14539. Certno: res.Output.Baseinfo.Certno,
  14540. Gend: res.Output.Baseinfo.Gend,
  14541. Naty: res.Output.Baseinfo.Naty,
  14542. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14543. PsnName: res.Output.Baseinfo.PsnName,
  14544. Idetinfo: idetinfoStr,
  14545. Insuinfo: infoStr,
  14546. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14547. }
  14548. service.CreateHisPsn(psn)
  14549. c.ServeSuccessJSON(map[string]interface{}{
  14550. "patient": patient,
  14551. "number": res.Output.Baseinfo.Certno,
  14552. })
  14553. }
  14554. } else {
  14555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14556. return
  14557. }
  14558. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14559. var res ResultTwo
  14560. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14561. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14562. "&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)
  14563. resp, requestErr := http.Get(api)
  14564. if requestErr != nil {
  14565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14566. return
  14567. }
  14568. body, ioErr := ioutil.ReadAll(resp.Body)
  14569. if ioErr != nil {
  14570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14572. return
  14573. }
  14574. var respJSON map[string]interface{}
  14575. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14578. return
  14579. }
  14580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14581. result, _ := json.Marshal(respJSON)
  14582. fmt.Println("log")
  14583. fmt.Println(string(result))
  14584. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14585. utils.ErrorLog("解析失败:%v", err)
  14586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14587. return
  14588. }
  14589. if res.Infcode == 0 {
  14590. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14591. if err == gorm.ErrRecordNotFound {
  14592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14593. return
  14594. } else if err != nil {
  14595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14596. return
  14597. } else {
  14598. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14599. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14600. infoStr := string(Iinfos)
  14601. idetinfoStr := string(Idetinfos)
  14602. psn := &models.HisPsn{
  14603. PsnNo: res.Output.Baseinfo.PsnNo,
  14604. PatientId: patient.ID,
  14605. Certno: res.Output.Baseinfo.Certno,
  14606. Gend: res.Output.Baseinfo.Gend,
  14607. Naty: res.Output.Baseinfo.Naty,
  14608. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14609. PsnName: res.Output.Baseinfo.PsnName,
  14610. Idetinfo: idetinfoStr,
  14611. Insuinfo: infoStr,
  14612. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14613. }
  14614. service.CreateHisPsn(psn)
  14615. c.ServeSuccessJSON(map[string]interface{}{
  14616. "patient": patient,
  14617. "number": res.Output.Baseinfo.Certno,
  14618. })
  14619. }
  14620. } else {
  14621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14622. return
  14623. }
  14624. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14625. var res ResultTwo
  14626. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14627. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14628. "&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)
  14629. resp, requestErr := http.Get(api)
  14630. if requestErr != nil {
  14631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14632. return
  14633. }
  14634. body, ioErr := ioutil.ReadAll(resp.Body)
  14635. if ioErr != nil {
  14636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14638. return
  14639. }
  14640. var respJSON map[string]interface{}
  14641. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14644. return
  14645. }
  14646. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14647. result, _ := json.Marshal(respJSON)
  14648. fmt.Println("log")
  14649. fmt.Println(string(result))
  14650. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14651. utils.ErrorLog("解析失败:%v", err)
  14652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14653. return
  14654. }
  14655. if res.Infcode == 0 {
  14656. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14657. if err == gorm.ErrRecordNotFound {
  14658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14659. return
  14660. } else if err != nil {
  14661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14662. return
  14663. } else {
  14664. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14665. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14666. infoStr := string(Iinfos)
  14667. idetinfoStr := string(Idetinfos)
  14668. var rf []*ResultFive
  14669. json.Unmarshal([]byte(infoStr), &rf)
  14670. var insutypes []*ResultFive
  14671. var insutype string
  14672. var is390 int = 0
  14673. var is310 int = 0
  14674. for _, item := range rf {
  14675. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14676. insutypes = append(insutypes, item)
  14677. }
  14678. }
  14679. if len(insutypes) == 1 {
  14680. insutype = insutypes[0].Insutype
  14681. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14682. } else {
  14683. for _, i := range insutypes {
  14684. if i.Insutype == "390" {
  14685. is390 = 1
  14686. }
  14687. if i.Insutype == "310" {
  14688. is310 = 1
  14689. }
  14690. }
  14691. }
  14692. if is390 == 1 {
  14693. insutype = "390"
  14694. }
  14695. if is310 == 1 {
  14696. insutype = "310"
  14697. }
  14698. if len(insutypes) == 0 {
  14699. insutype = "390"
  14700. }
  14701. var insuplc_admdvs string
  14702. for _, item := range rf {
  14703. if item.Insutype == insutype {
  14704. insuplc_admdvs = item.InsuplcAdmdvs
  14705. }
  14706. }
  14707. psn := &models.HisPsn{
  14708. PsnNo: res.Output.Baseinfo.PsnNo,
  14709. PatientId: patient.ID,
  14710. Certno: res.Output.Baseinfo.Certno,
  14711. Gend: res.Output.Baseinfo.Gend,
  14712. Naty: res.Output.Baseinfo.Naty,
  14713. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14714. PsnName: res.Output.Baseinfo.PsnName,
  14715. Idetinfo: idetinfoStr,
  14716. Insuinfo: infoStr,
  14717. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14718. InsuplcAdmdvs: insuplc_admdvs,
  14719. }
  14720. service.CreateHisPsn(psn)
  14721. c.ServeSuccessJSON(map[string]interface{}{
  14722. "patient": patient,
  14723. "number": res.Output.Baseinfo.Certno,
  14724. })
  14725. }
  14726. } else {
  14727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14728. return
  14729. }
  14730. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14731. res := c.GetoleInfo()
  14732. if res.Infcode == 0 {
  14733. var result string
  14734. if res.Output.MdtrtCertType == "01" {
  14735. 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)
  14736. } else if res.Output.MdtrtCertType == "02" {
  14737. 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)
  14738. } else if res.Output.MdtrtCertType == "03" {
  14739. 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)
  14740. }
  14741. var dat map[string]interface{}
  14742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14743. fmt.Println(dat)
  14744. } else {
  14745. fmt.Println(err)
  14746. }
  14747. userJSONBytes, _ := json.Marshal(dat)
  14748. var res2 ResultTwo
  14749. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14750. utils.ErrorLog("解析失败:%v", err)
  14751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14752. return
  14753. }
  14754. if res2.Infcode == 0 {
  14755. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14756. if err == gorm.ErrRecordNotFound {
  14757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14758. return
  14759. } else if err != nil {
  14760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14761. return
  14762. } else {
  14763. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14764. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14765. infoStr := string(Iinfos)
  14766. idetinfoStr := string(Idetinfos)
  14767. var rf []*ResultFive
  14768. json.Unmarshal([]byte(infoStr), &rf)
  14769. var insutypes []*ResultFive
  14770. var insutype string
  14771. var is390 int = 0
  14772. var is310 int = 0
  14773. //var insuplc_admdvs string
  14774. for _, item := range rf {
  14775. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14776. insutypes = append(insutypes, item)
  14777. }
  14778. }
  14779. if len(insutypes) == 1 {
  14780. insutype = insutypes[0].Insutype
  14781. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14782. } else {
  14783. for _, i := range insutypes {
  14784. if i.Insutype == "390" {
  14785. is390 = 1
  14786. }
  14787. if i.Insutype == "310" {
  14788. is310 = 1
  14789. }
  14790. }
  14791. }
  14792. if is390 == 1 {
  14793. insutype = "390"
  14794. }
  14795. if is310 == 1 {
  14796. insutype = "310"
  14797. }
  14798. if len(insutypes) == 0 {
  14799. insutype = "310"
  14800. }
  14801. psn := &models.HisPsn{
  14802. PsnNo: res2.Output.Baseinfo.PsnNo,
  14803. PatientId: patient.ID,
  14804. //Brdy: res2.Output.Baseinfo.Brdy,
  14805. Certno: res2.Output.Baseinfo.Certno,
  14806. Gend: res2.Output.Baseinfo.Gend,
  14807. Naty: res2.Output.Baseinfo.Naty,
  14808. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14809. PsnName: res2.Output.Baseinfo.PsnName,
  14810. Idetinfo: idetinfoStr,
  14811. Insuinfo: infoStr,
  14812. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14813. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14814. VerifyNumber: res.Output.EcToken,
  14815. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14816. }
  14817. service.CreateHisPsn(psn)
  14818. var balc float64
  14819. for _, item := range rf {
  14820. if item.Insutype == insutype {
  14821. balc = item.Balc
  14822. }
  14823. }
  14824. c.ServeSuccessJSON(map[string]interface{}{
  14825. "patient": patient,
  14826. "number": res.Output.CardNo,
  14827. "insutype": insutype,
  14828. "blac": balc,
  14829. "desc": idetinfoStr,
  14830. })
  14831. }
  14832. } else {
  14833. c.ServeSuccessJSON(map[string]interface{}{
  14834. "failed_code": -10,
  14835. "msg": res2.ErrMsg,
  14836. })
  14837. }
  14838. } else {
  14839. c.ServeSuccessJSON(map[string]interface{}{
  14840. "failed_code": -10,
  14841. "msg": res.ErrMsg,
  14842. })
  14843. }
  14844. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14845. var insuplc_admdvs string
  14846. if len(patient.InsuplcAdmdvs) > 0 {
  14847. insuplc_admdvs = patient.InsuplcAdmdvs
  14848. } else {
  14849. if len(insuplc_admdvs_str) > 0 {
  14850. insuplc_admdvs = insuplc_admdvs_str
  14851. } else {
  14852. insuplc_admdvs = miConfig.InsuplcAdmdvs
  14853. }
  14854. }
  14855. //请求内网数据
  14856. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  14857. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14858. "&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=" + ""
  14859. resp, requestErr := http.Get(api)
  14860. if requestErr != nil {
  14861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14862. return
  14863. }
  14864. body, ioErr := ioutil.ReadAll(resp.Body)
  14865. if ioErr != nil {
  14866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14868. return
  14869. }
  14870. var respJSON map[string]interface{}
  14871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14874. return
  14875. }
  14876. status := respJSON["data"].(map[string]interface{})["status"].(string)
  14877. if status == "0" {
  14878. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  14879. c.ServeSuccessJSON(map[string]interface{}{
  14880. "failed_code": -10,
  14881. "msg": err_msg,
  14882. })
  14883. return
  14884. }
  14885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14886. var res ResultTwo
  14887. result, _ := json.Marshal(respJSON)
  14888. fmt.Println("log")
  14889. fmt.Println(string(result))
  14890. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14891. utils.ErrorLog("解析失败:%v", err)
  14892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14893. return
  14894. }
  14895. if res.Infcode == 0 {
  14896. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14897. if err == gorm.ErrRecordNotFound {
  14898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14899. return
  14900. } else if err != nil {
  14901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14902. return
  14903. } else {
  14904. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14905. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14906. infoStr := string(Iinfos)
  14907. idetinfoStr := string(Idetinfos)
  14908. psn := &models.HisPsn{
  14909. PsnNo: res.Output.Baseinfo.PsnNo,
  14910. PatientId: patient.ID,
  14911. Certno: res.Output.Baseinfo.Certno,
  14912. Gend: res.Output.Baseinfo.Gend,
  14913. Naty: res.Output.Baseinfo.Naty,
  14914. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14915. PsnName: res.Output.Baseinfo.PsnName,
  14916. Idetinfo: idetinfoStr,
  14917. Insuinfo: infoStr,
  14918. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14919. }
  14920. service.CreateHisPsn(psn)
  14921. var rf []*ResultFive
  14922. json.Unmarshal([]byte(infoStr), &rf)
  14923. var insutypes []*ResultFive
  14924. var is390 int = 0
  14925. var is310 int = 0
  14926. var insutype string
  14927. for _, item := range rf {
  14928. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14929. insutypes = append(insutypes, item)
  14930. }
  14931. }
  14932. if len(insutypes) == 1 {
  14933. insutype = insutypes[0].Insutype
  14934. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14935. } else {
  14936. for _, i := range insutypes {
  14937. if i.Insutype == "390" {
  14938. is390 = 1
  14939. }
  14940. if i.Insutype == "310" {
  14941. is310 = 1
  14942. }
  14943. }
  14944. }
  14945. if is390 == 1 {
  14946. insutype = "390"
  14947. }
  14948. if is310 == 1 {
  14949. insutype = "310"
  14950. }
  14951. if len(insutypes) == 0 {
  14952. insutype = "390"
  14953. }
  14954. c.ServeSuccessJSON(map[string]interface{}{
  14955. "patient": patient,
  14956. "insutype": insutype,
  14957. "number": res.Output.Baseinfo.Certno,
  14958. "info": res,
  14959. })
  14960. }
  14961. } else {
  14962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14963. return
  14964. }
  14965. } else {
  14966. SFZStr := c.GetSFZBaseInfo()
  14967. id_card_str := strings.Split(SFZStr, "^")
  14968. id_card_number := id_card_str[0]
  14969. card_sn := ""
  14970. 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)
  14971. var dat map[string]interface{}
  14972. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14973. fmt.Println(dat)
  14974. } else {
  14975. fmt.Println(err)
  14976. }
  14977. userJSONBytes, _ := json.Marshal(dat)
  14978. var res ResultTwo
  14979. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14980. utils.ErrorLog("解析失败:%v", err)
  14981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14982. return
  14983. }
  14984. if res.Infcode == 0 {
  14985. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  14986. if err == gorm.ErrRecordNotFound {
  14987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14988. return
  14989. } else if err != nil {
  14990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14991. return
  14992. } else {
  14993. c.ServeSuccessJSON(map[string]interface{}{
  14994. "patient": patient,
  14995. "number": id_card_number,
  14996. })
  14997. }
  14998. } else {
  14999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15000. return
  15001. }
  15002. }
  15003. break
  15004. case 3:
  15005. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15006. var api string
  15007. if miConfig.MdtrtareaAdmvs == "320921" {
  15008. 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 +
  15009. "&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
  15010. fmt.Println(api)
  15011. } else {
  15012. 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 +
  15013. "&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)
  15014. }
  15015. resp, requestErr := http.Get(api)
  15016. if requestErr != nil {
  15017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15018. return
  15019. }
  15020. body, ioErr := ioutil.ReadAll(resp.Body)
  15021. if ioErr != nil {
  15022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15024. return
  15025. }
  15026. var respJSON map[string]interface{}
  15027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15030. return
  15031. }
  15032. var status string
  15033. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15034. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15035. var token string
  15036. var res ResultTwo //1101结果
  15037. var res10265 ResultTwo10265 //1101结果
  15038. var card_info string //卡信息
  15039. var busi_card_info string
  15040. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15041. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15042. if status == "0" { //读卡成功
  15043. if card_type == "1" {
  15044. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15045. result, _ := json.Marshal(respJSON)
  15046. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15047. utils.ErrorLog("解析失败:%v", err)
  15048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15049. return
  15050. }
  15051. res.ErrMsg = res10265.ErrMsg
  15052. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15053. res.Infcode = infocode
  15054. res.Output = res10265.Output
  15055. res.InfRefmsgid = res10265.InfRefmsgid
  15056. } else {
  15057. //var card_info string //卡信息
  15058. //var busi_card_info string
  15059. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15060. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15061. //fmt.Println(card_info)
  15062. //fmt.Println(busi_card_info)
  15063. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15064. result, _ := json.Marshal(respJSON)
  15065. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15066. utils.ErrorLog("解析失败:%v", err)
  15067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15068. return
  15069. }
  15070. res.ErrMsg = res10265.ErrMsg
  15071. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15072. res.Infcode = infocode
  15073. res.Output = res10265.Output
  15074. res.InfRefmsgid = res10265.InfRefmsgid
  15075. }
  15076. if res.Infcode == 0 {
  15077. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15078. if err == gorm.ErrRecordNotFound {
  15079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15080. return
  15081. } else if err != nil {
  15082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15083. return
  15084. } else {
  15085. if card_type == "1" {
  15086. bas := strings.Split(card_info, "|")
  15087. basNumber := bas[2]
  15088. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15089. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15090. infoStr := string(Iinfos)
  15091. idetinfoStr := string(Idetinfos)
  15092. psn := &models.HisPsn{
  15093. PsnNo: res.Output.Baseinfo.PsnNo,
  15094. PatientId: patient.ID,
  15095. Certno: res.Output.Baseinfo.Certno,
  15096. //Brdy: res.Output.Baseinfo.Brdy,
  15097. Gend: res.Output.Baseinfo.Gend,
  15098. Naty: res.Output.Baseinfo.Naty,
  15099. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15100. PsnName: res.Output.Baseinfo.PsnName,
  15101. Idetinfo: idetinfoStr,
  15102. Insuinfo: infoStr,
  15103. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15104. CardInfo: card_info,
  15105. VerifyNumber: busi_card_info,
  15106. }
  15107. service.CreateHisPsn(psn)
  15108. c.ServeSuccessJSON(map[string]interface{}{
  15109. "patient": patient,
  15110. "number": basNumber,
  15111. })
  15112. } else {
  15113. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15114. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15115. infoStr := string(Iinfos)
  15116. idetinfoStr := string(Idetinfos)
  15117. psn := &models.HisPsn{
  15118. PsnNo: res.Output.Baseinfo.PsnNo,
  15119. PatientId: patient.ID,
  15120. Certno: res.Output.Baseinfo.Certno,
  15121. Gend: res.Output.Baseinfo.Gend,
  15122. Naty: res.Output.Baseinfo.Naty,
  15123. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15124. PsnName: res.Output.Baseinfo.PsnName,
  15125. Idetinfo: idetinfoStr,
  15126. Insuinfo: infoStr,
  15127. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15128. CardInfo: card_info,
  15129. VerifyNumber: token,
  15130. }
  15131. service.CreateHisPsn(psn)
  15132. var rf []*ResultFive
  15133. json.Unmarshal([]byte(infoStr), &rf)
  15134. var insutypes []*ResultFive
  15135. var insutype string
  15136. var is390 int = 0
  15137. var is310 int = 0
  15138. for _, item := range rf {
  15139. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15140. insutypes = append(insutypes, item)
  15141. }
  15142. }
  15143. if len(insutypes) == 1 {
  15144. insutype = insutypes[0].Insutype
  15145. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15146. } else {
  15147. for _, i := range insutypes {
  15148. if i.Insutype == "390" {
  15149. is390 = 1
  15150. }
  15151. if i.Insutype == "310" {
  15152. is310 = 1
  15153. }
  15154. }
  15155. }
  15156. if is390 == 1 {
  15157. insutype = "390"
  15158. }
  15159. if is310 == 1 {
  15160. insutype = "310"
  15161. }
  15162. if len(insutypes) == 0 {
  15163. insutype = "310"
  15164. }
  15165. c.ServeSuccessJSON(map[string]interface{}{
  15166. "patient": patient,
  15167. "number": token,
  15168. "insutype": insutype,
  15169. })
  15170. }
  15171. }
  15172. } else {
  15173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15174. return
  15175. }
  15176. } else { //读卡失败
  15177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15178. return
  15179. }
  15180. }
  15181. break
  15182. case 4:
  15183. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15184. var api string
  15185. if miConfig.MdtrtareaAdmvs == "320921" {
  15186. 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 +
  15187. "&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
  15188. fmt.Println(api)
  15189. } else {
  15190. 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 +
  15191. "&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)
  15192. }
  15193. resp, requestErr := http.Get(api)
  15194. if requestErr != nil {
  15195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15196. return
  15197. }
  15198. body, ioErr := ioutil.ReadAll(resp.Body)
  15199. if ioErr != nil {
  15200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15202. return
  15203. }
  15204. var respJSON map[string]interface{}
  15205. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15208. return
  15209. }
  15210. var status string
  15211. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15212. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15213. var token string
  15214. var res ResultTwo //1101结果
  15215. var res10265 ResultTwo10265 //1101结果
  15216. if status == "0" { //读卡成功
  15217. var card_info string //卡信息
  15218. var busi_card_info string
  15219. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15220. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15221. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15222. fmt.Println(card_info)
  15223. fmt.Println(busi_card_info)
  15224. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15225. result, _ := json.Marshal(respJSON)
  15226. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15227. utils.ErrorLog("解析失败:%v", err)
  15228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15229. return
  15230. }
  15231. res.ErrMsg = res10265.ErrMsg
  15232. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15233. res.Infcode = infocode
  15234. res.Output = res10265.Output
  15235. res.InfRefmsgid = res10265.InfRefmsgid
  15236. if res.Infcode == 0 {
  15237. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15238. if err == gorm.ErrRecordNotFound {
  15239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15240. return
  15241. } else if err != nil {
  15242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15243. return
  15244. } else {
  15245. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15246. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15247. infoStr := string(Iinfos)
  15248. idetinfoStr := string(Idetinfos)
  15249. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15250. psn := &models.HisPsn{
  15251. PsnNo: res.Output.Baseinfo.PsnNo,
  15252. PatientId: patient.ID,
  15253. Certno: res.Output.Baseinfo.Certno,
  15254. Brdy: b,
  15255. Age: float64(age),
  15256. //Brdy: res.Output.Baseinfo.Brdy,
  15257. Gend: res.Output.Baseinfo.Gend,
  15258. Naty: res.Output.Baseinfo.Naty,
  15259. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15260. PsnName: res.Output.Baseinfo.PsnName,
  15261. Idetinfo: idetinfoStr,
  15262. Insuinfo: infoStr,
  15263. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15264. CardInfo: card_info,
  15265. VerifyNumber: token,
  15266. }
  15267. var rf []*ResultFive
  15268. json.Unmarshal([]byte(infoStr), &rf)
  15269. var insutypes []*ResultFive
  15270. var insutype string
  15271. var is390 int = 0
  15272. var is310 int = 0
  15273. for _, item := range rf {
  15274. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15275. insutypes = append(insutypes, item)
  15276. }
  15277. }
  15278. if len(insutypes) == 1 {
  15279. insutype = insutypes[0].Insutype
  15280. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15281. } else {
  15282. for _, i := range insutypes {
  15283. if i.Insutype == "390" {
  15284. is390 = 1
  15285. }
  15286. if i.Insutype == "310" {
  15287. is310 = 1
  15288. }
  15289. }
  15290. }
  15291. if is390 == 1 {
  15292. insutype = "390"
  15293. }
  15294. if is310 == 1 {
  15295. insutype = "310"
  15296. }
  15297. if len(insutypes) == 0 {
  15298. insutype = "310"
  15299. }
  15300. service.CreateHisPsn(psn)
  15301. c.ServeSuccessJSON(map[string]interface{}{
  15302. "patient": patient,
  15303. "number": token,
  15304. "insutype": insutype,
  15305. })
  15306. }
  15307. } else {
  15308. c.ServeSuccessJSON(map[string]interface{}{
  15309. "failed_code": -10,
  15310. "msg": res.ErrMsg,
  15311. })
  15312. }
  15313. } else { //读卡失败
  15314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15315. return
  15316. }
  15317. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15318. var api string
  15319. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15320. "&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
  15321. resp, requestErr := http.Get(api)
  15322. if requestErr != nil {
  15323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15324. return
  15325. }
  15326. body, ioErr := ioutil.ReadAll(resp.Body)
  15327. if ioErr != nil {
  15328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15330. return
  15331. }
  15332. var respJSON map[string]interface{}
  15333. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15336. return
  15337. }
  15338. var status string
  15339. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15340. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15341. var token string
  15342. var res ResultTwo //1101结果
  15343. if status == "1" { //读卡成功
  15344. var card_info string //卡信息
  15345. var busi_card_info string
  15346. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15347. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15348. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15349. fmt.Println(card_info)
  15350. fmt.Println(busi_card_info)
  15351. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15352. result, _ := json.Marshal(respJSON)
  15353. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15354. utils.ErrorLog("解析失败:%v", err)
  15355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15356. return
  15357. }
  15358. if res.Infcode == 0 {
  15359. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15360. if err == gorm.ErrRecordNotFound {
  15361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15362. return
  15363. } else if err != nil {
  15364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15365. return
  15366. } else {
  15367. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15368. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15369. infoStr := string(Iinfos)
  15370. idetinfoStr := string(Idetinfos)
  15371. psn := &models.HisPsn{
  15372. PsnNo: res.Output.Baseinfo.PsnNo,
  15373. PatientId: patient.ID,
  15374. Certno: res.Output.Baseinfo.Certno,
  15375. Gend: res.Output.Baseinfo.Gend,
  15376. Naty: res.Output.Baseinfo.Naty,
  15377. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15378. PsnName: res.Output.Baseinfo.PsnName,
  15379. Idetinfo: idetinfoStr,
  15380. Insuinfo: infoStr,
  15381. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15382. CardInfo: card_info,
  15383. VerifyNumber: token,
  15384. }
  15385. var rf []*ResultFive
  15386. json.Unmarshal([]byte(infoStr), &rf)
  15387. var insutypes []*ResultFive
  15388. var insutype string
  15389. var is390 int = 0
  15390. var is310 int = 0
  15391. for _, item := range rf {
  15392. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15393. insutypes = append(insutypes, item)
  15394. }
  15395. }
  15396. if len(insutypes) == 1 {
  15397. insutype = insutypes[0].Insutype
  15398. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15399. } else {
  15400. for _, i := range insutypes {
  15401. if i.Insutype == "390" {
  15402. is390 = 1
  15403. }
  15404. if i.Insutype == "310" {
  15405. is310 = 1
  15406. }
  15407. }
  15408. }
  15409. if is390 == 1 {
  15410. insutype = "390"
  15411. }
  15412. if is310 == 1 {
  15413. insutype = "310"
  15414. }
  15415. if len(insutypes) == 0 {
  15416. insutype = "310"
  15417. }
  15418. service.CreateHisPsn(psn)
  15419. c.ServeSuccessJSON(map[string]interface{}{
  15420. "patient": patient,
  15421. "number": token,
  15422. "insutype": insutype,
  15423. })
  15424. }
  15425. } else {
  15426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15427. return
  15428. }
  15429. } else { //读卡失败
  15430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15431. return
  15432. }
  15433. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15434. var api string
  15435. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15436. "&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
  15437. resp, requestErr := http.Get(api)
  15438. if requestErr != nil {
  15439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15440. return
  15441. }
  15442. body, ioErr := ioutil.ReadAll(resp.Body)
  15443. if ioErr != nil {
  15444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15446. return
  15447. }
  15448. var respJSON map[string]interface{}
  15449. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15452. return
  15453. }
  15454. var status string
  15455. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15456. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15457. var token string
  15458. var res ResultTwo //1101结果
  15459. if status == "1" { //读卡成功
  15460. var card_info string //卡信息
  15461. var busi_card_info string
  15462. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15463. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15464. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15465. fmt.Println(card_info)
  15466. fmt.Println(busi_card_info)
  15467. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15468. result, _ := json.Marshal(respJSON)
  15469. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15470. utils.ErrorLog("解析失败:%v", err)
  15471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15472. return
  15473. }
  15474. if res.Infcode == 0 {
  15475. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15476. if err == gorm.ErrRecordNotFound {
  15477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15478. return
  15479. } else if err != nil {
  15480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15481. return
  15482. } else {
  15483. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15484. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15485. infoStr := string(Iinfos)
  15486. idetinfoStr := string(Idetinfos)
  15487. psn := &models.HisPsn{
  15488. PsnNo: res.Output.Baseinfo.PsnNo,
  15489. PatientId: patient.ID,
  15490. Certno: res.Output.Baseinfo.Certno,
  15491. Gend: res.Output.Baseinfo.Gend,
  15492. Naty: res.Output.Baseinfo.Naty,
  15493. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15494. PsnName: res.Output.Baseinfo.PsnName,
  15495. Idetinfo: idetinfoStr,
  15496. Insuinfo: infoStr,
  15497. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15498. CardInfo: card_info,
  15499. VerifyNumber: token,
  15500. }
  15501. var rf []*ResultFive
  15502. json.Unmarshal([]byte(infoStr), &rf)
  15503. var insutypes []*ResultFive
  15504. var insutype string
  15505. var is390 int = 0
  15506. var is310 int = 0
  15507. for _, item := range rf {
  15508. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15509. insutypes = append(insutypes, item)
  15510. }
  15511. }
  15512. if len(insutypes) == 1 {
  15513. insutype = insutypes[0].Insutype
  15514. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15515. } else {
  15516. for _, i := range insutypes {
  15517. if i.Insutype == "390" {
  15518. is390 = 1
  15519. }
  15520. if i.Insutype == "310" {
  15521. is310 = 1
  15522. }
  15523. }
  15524. }
  15525. if is390 == 1 {
  15526. insutype = "390"
  15527. }
  15528. if is310 == 1 {
  15529. insutype = "310"
  15530. }
  15531. if len(insutypes) == 0 {
  15532. insutype = "310"
  15533. }
  15534. service.CreateHisPsn(psn)
  15535. c.ServeSuccessJSON(map[string]interface{}{
  15536. "patient": patient,
  15537. "number": token,
  15538. "insutype": insutype,
  15539. })
  15540. }
  15541. } else {
  15542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15543. return
  15544. }
  15545. } else { //读卡失败
  15546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15547. return
  15548. }
  15549. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15550. //idNo := c.GetString("idNo")
  15551. //userName := c.GetString("userName")
  15552. //ecToken := c.GetString("ecToken")
  15553. //insuOrg := c.GetString("insuOrg")
  15554. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15555. utils.ErrorLog("解析失败:%v", json_result)
  15556. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15557. type ELeData struct {
  15558. Data struct {
  15559. IdNo string `json:"idNo"`
  15560. IdType string `json:"idType"`
  15561. UserName string `json:"userName"`
  15562. EcToken string `json:"ecToken"`
  15563. InsuOrg string `json:"insuOrg"`
  15564. Gender string `json:"gender"`
  15565. Birthday string `json:"birthday"`
  15566. Nationality string `json:"nationality"`
  15567. Email string `json:"email"`
  15568. Extra string `json:"extra"`
  15569. } `json:"data"`
  15570. Code int `json:"code"`
  15571. Message string `json:"message"`
  15572. }
  15573. var ele ELeData
  15574. err := json.Unmarshal([]byte(json_result), &ele)
  15575. if err != nil {
  15576. utils.ErrorLog("解析失败:%v", err)
  15577. }
  15578. token := ele.Data.EcToken
  15579. token = Remove0000(token)
  15580. 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)
  15581. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15582. var res ResultTwo
  15583. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15584. utils.ErrorLog("解析失败:%v", err)
  15585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15586. return
  15587. }
  15588. if res.Infcode == 0 {
  15589. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15590. if err == gorm.ErrRecordNotFound {
  15591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15592. return
  15593. } else if err != nil {
  15594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15595. return
  15596. } else {
  15597. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15598. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15599. infoStr := string(Iinfos)
  15600. idetinfoStr := string(Idetinfos)
  15601. psn := &models.HisPsn{
  15602. PsnNo: res.Output.Baseinfo.PsnNo,
  15603. PatientId: patient.ID,
  15604. Certno: res.Output.Baseinfo.Certno,
  15605. Gend: res.Output.Baseinfo.Gend,
  15606. Naty: res.Output.Baseinfo.Naty,
  15607. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15608. PsnName: res.Output.Baseinfo.PsnName,
  15609. Idetinfo: idetinfoStr,
  15610. Insuinfo: infoStr,
  15611. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15612. CardInfo: "",
  15613. Stage: "1",
  15614. VerifyNumber: token,
  15615. InsuplcAdmdvs: ele.Data.InsuOrg,
  15616. }
  15617. service.CreateHisPsn(psn)
  15618. var rf []*ResultFive
  15619. json.Unmarshal([]byte(infoStr), &rf)
  15620. var insutypes []*ResultFive
  15621. var insutype string
  15622. var is390 int = 0
  15623. var is310 int = 0
  15624. for _, item := range rf {
  15625. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15626. insutypes = append(insutypes, item)
  15627. }
  15628. }
  15629. if len(insutypes) == 1 {
  15630. insutype = insutypes[0].Insutype
  15631. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15632. } else {
  15633. for _, i := range insutypes {
  15634. if i.Insutype == "390" {
  15635. is390 = 1
  15636. }
  15637. if i.Insutype == "310" {
  15638. is310 = 1
  15639. }
  15640. }
  15641. }
  15642. if is390 == 1 {
  15643. insutype = "390"
  15644. }
  15645. if is310 == 1 {
  15646. insutype = "310"
  15647. }
  15648. if len(insutypes) == 0 {
  15649. insutype = "310"
  15650. }
  15651. c.ServeSuccessJSON(map[string]interface{}{
  15652. "patient": patient,
  15653. "number": token,
  15654. "insutype": insutype,
  15655. })
  15656. }
  15657. } else {
  15658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15659. return
  15660. }
  15661. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15662. //if initFlag == 0 {
  15663. //c.TestGetJiangXiBasBaseInit()
  15664. //}
  15665. //if initEleFlag == 0 {
  15666. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15667. //}
  15668. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15669. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15670. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15671. type ELeData struct {
  15672. Data struct {
  15673. IdNo string `json:"idNo"`
  15674. IdType string `json:"idType"`
  15675. UserName string `json:"userName"`
  15676. EcToken string `json:"ecToken"`
  15677. InsuOrg string `json:"insuOrg"`
  15678. Gender string `json:"gender"`
  15679. Birthday string `json:"birthday"`
  15680. Nationality string `json:"nationality"`
  15681. Email string `json:"email"`
  15682. Extra string `json:"extra"`
  15683. } `json:"data"`
  15684. Code int `json:"code"`
  15685. Message string `json:"message"`
  15686. }
  15687. var ele ELeData
  15688. err := json.Unmarshal([]byte(result), &ele)
  15689. if err != nil {
  15690. utils.ErrorLog("解析失败:%v", err)
  15691. }
  15692. token := ele.Data.EcToken
  15693. token = Remove0000(token)
  15694. 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)
  15695. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15696. var res ResultTwo
  15697. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15698. utils.ErrorLog("解析失败:%v", err)
  15699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15700. return
  15701. }
  15702. if res.Infcode == 0 {
  15703. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15704. if err == gorm.ErrRecordNotFound {
  15705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15706. return
  15707. } else if err != nil {
  15708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15709. return
  15710. } else {
  15711. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15712. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15713. infoStr := string(Iinfos)
  15714. idetinfoStr := string(Idetinfos)
  15715. psn := &models.HisPsn{
  15716. PsnNo: res.Output.Baseinfo.PsnNo,
  15717. PatientId: patient.ID,
  15718. Certno: res.Output.Baseinfo.Certno,
  15719. Gend: res.Output.Baseinfo.Gend,
  15720. Naty: res.Output.Baseinfo.Naty,
  15721. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15722. PsnName: res.Output.Baseinfo.PsnName,
  15723. Idetinfo: idetinfoStr,
  15724. Insuinfo: infoStr,
  15725. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15726. CardInfo: "",
  15727. VerifyNumber: token,
  15728. InsuplcAdmdvs: ele.Data.InsuOrg,
  15729. }
  15730. service.CreateHisPsn(psn)
  15731. var rf []*ResultFive
  15732. json.Unmarshal([]byte(infoStr), &rf)
  15733. var insutypes []*ResultFive
  15734. var insutype string
  15735. var is390 int = 0
  15736. var is310 int = 0
  15737. for _, item := range rf {
  15738. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15739. insutypes = append(insutypes, item)
  15740. }
  15741. }
  15742. if len(insutypes) == 1 {
  15743. insutype = insutypes[0].Insutype
  15744. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15745. } else {
  15746. for _, i := range insutypes {
  15747. if i.Insutype == "390" {
  15748. is390 = 1
  15749. }
  15750. if i.Insutype == "310" {
  15751. is310 = 1
  15752. }
  15753. }
  15754. }
  15755. if is390 == 1 {
  15756. insutype = "390"
  15757. }
  15758. if is310 == 1 {
  15759. insutype = "310"
  15760. }
  15761. if len(insutypes) == 0 {
  15762. insutype = "310"
  15763. }
  15764. c.ServeSuccessJSON(map[string]interface{}{
  15765. "patient": patient,
  15766. "number": token,
  15767. "insutype": insutype,
  15768. })
  15769. }
  15770. } else {
  15771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15772. return
  15773. }
  15774. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15775. //if initFlag == 0 {
  15776. //c.TestGetJiangXiBasBaseInit()
  15777. //}
  15778. //if initEleFlag == 0 {
  15779. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15780. //}
  15781. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15782. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15783. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15784. type ELeData struct {
  15785. Data struct {
  15786. IdNo string `json:"idNo"`
  15787. IdType string `json:"idType"`
  15788. UserName string `json:"userName"`
  15789. EcToken string `json:"ecToken"`
  15790. InsuOrg string `json:"insuOrg"`
  15791. Gender string `json:"gender"`
  15792. Birthday string `json:"birthday"`
  15793. Nationality string `json:"nationality"`
  15794. Email string `json:"email"`
  15795. Extra string `json:"extra"`
  15796. } `json:"data"`
  15797. Code int `json:"code"`
  15798. Message string `json:"message"`
  15799. }
  15800. var ele ELeData
  15801. err := json.Unmarshal([]byte(result), &ele)
  15802. if err != nil {
  15803. utils.ErrorLog("解析失败:%v", err)
  15804. }
  15805. token := ele.Data.EcToken
  15806. token = Remove0000(token)
  15807. 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)
  15808. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15809. var res ResultTwo
  15810. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15811. utils.ErrorLog("解析失败:%v", err)
  15812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15813. return
  15814. }
  15815. if res.Infcode == 0 {
  15816. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15817. if err == gorm.ErrRecordNotFound {
  15818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15819. return
  15820. } else if err != nil {
  15821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15822. return
  15823. } else {
  15824. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15825. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15826. infoStr := string(Iinfos)
  15827. idetinfoStr := string(Idetinfos)
  15828. psn := &models.HisPsn{
  15829. PsnNo: res.Output.Baseinfo.PsnNo,
  15830. PatientId: patient.ID,
  15831. Certno: res.Output.Baseinfo.Certno,
  15832. Gend: res.Output.Baseinfo.Gend,
  15833. Naty: res.Output.Baseinfo.Naty,
  15834. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15835. PsnName: res.Output.Baseinfo.PsnName,
  15836. Idetinfo: idetinfoStr,
  15837. Insuinfo: infoStr,
  15838. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15839. CardInfo: "",
  15840. VerifyNumber: token,
  15841. InsuplcAdmdvs: ele.Data.InsuOrg,
  15842. }
  15843. service.CreateHisPsn(psn)
  15844. var rf []*ResultFive
  15845. json.Unmarshal([]byte(infoStr), &rf)
  15846. var insutypes []*ResultFive
  15847. var insutype string
  15848. var is390 int = 0
  15849. var is310 int = 0
  15850. for _, item := range rf {
  15851. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15852. insutypes = append(insutypes, item)
  15853. }
  15854. }
  15855. if len(insutypes) == 1 {
  15856. insutype = insutypes[0].Insutype
  15857. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15858. } else {
  15859. for _, i := range insutypes {
  15860. if i.Insutype == "390" {
  15861. is390 = 1
  15862. }
  15863. if i.Insutype == "310" {
  15864. is310 = 1
  15865. }
  15866. }
  15867. }
  15868. if is390 == 1 {
  15869. insutype = "390"
  15870. }
  15871. if is310 == 1 {
  15872. insutype = "310"
  15873. }
  15874. if len(insutypes) == 0 {
  15875. insutype = "310"
  15876. }
  15877. c.ServeSuccessJSON(map[string]interface{}{
  15878. "patient": patient,
  15879. "number": token,
  15880. "insutype": insutype,
  15881. })
  15882. }
  15883. } else {
  15884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15885. return
  15886. }
  15887. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15888. //if initFlag == 0 {
  15889. c.TestGetJiangXiBasBaseInit()
  15890. //}
  15891. //if initEleFlag == 0 {
  15892. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15893. //}
  15894. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15895. type ELeData struct {
  15896. Data struct {
  15897. IdNo string `json:"idNo"`
  15898. IdType string `json:"idType"`
  15899. UserName string `json:"userName"`
  15900. EcToken string `json:"ecToken"`
  15901. InsuOrg string `json:"insuOrg"`
  15902. Gender string `json:"gender"`
  15903. Birthday string `json:"birthday"`
  15904. Nationality string `json:"nationality"`
  15905. Email string `json:"email"`
  15906. Extra string `json:"extra"`
  15907. } `json:"data"`
  15908. Code int `json:"code"`
  15909. Message string `json:"message"`
  15910. }
  15911. var ele ELeData
  15912. err := json.Unmarshal([]byte(json_result), &ele)
  15913. if err != nil {
  15914. utils.ErrorLog("解析失败:%v", err)
  15915. }
  15916. token := ele.Data.EcToken
  15917. token = Remove0000(token)
  15918. 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)
  15919. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15920. var res ResultTwo
  15921. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15922. utils.ErrorLog("解析失败:%v", err)
  15923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15924. return
  15925. }
  15926. if res.Infcode == 0 {
  15927. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15928. if err == gorm.ErrRecordNotFound {
  15929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15930. return
  15931. } else if err != nil {
  15932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15933. return
  15934. } else {
  15935. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15936. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15937. infoStr := string(Iinfos)
  15938. idetinfoStr := string(Idetinfos)
  15939. psn := &models.HisPsn{
  15940. PsnNo: res.Output.Baseinfo.PsnNo,
  15941. PatientId: patient.ID,
  15942. Certno: res.Output.Baseinfo.Certno,
  15943. Gend: res.Output.Baseinfo.Gend,
  15944. Naty: res.Output.Baseinfo.Naty,
  15945. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15946. PsnName: res.Output.Baseinfo.PsnName,
  15947. Idetinfo: idetinfoStr,
  15948. Insuinfo: infoStr,
  15949. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15950. CardInfo: "",
  15951. VerifyNumber: token,
  15952. }
  15953. service.CreateHisPsn(psn)
  15954. var rf []*ResultFive
  15955. json.Unmarshal([]byte(infoStr), &rf)
  15956. var insutypes []*ResultFive
  15957. var insutype string
  15958. var is390 int = 0
  15959. var is310 int = 0
  15960. for _, item := range rf {
  15961. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15962. insutypes = append(insutypes, item)
  15963. }
  15964. }
  15965. if len(insutypes) == 1 {
  15966. insutype = insutypes[0].Insutype
  15967. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15968. } else {
  15969. for _, i := range insutypes {
  15970. if i.Insutype == "390" {
  15971. is390 = 1
  15972. }
  15973. if i.Insutype == "310" {
  15974. is310 = 1
  15975. }
  15976. }
  15977. }
  15978. if is390 == 1 {
  15979. insutype = "390"
  15980. }
  15981. if is310 == 1 {
  15982. insutype = "310"
  15983. }
  15984. if len(insutypes) == 0 {
  15985. insutype = "310"
  15986. }
  15987. c.ServeSuccessJSON(map[string]interface{}{
  15988. "patient": patient,
  15989. "number": token,
  15990. "insutype": insutype,
  15991. })
  15992. }
  15993. } else {
  15994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15995. return
  15996. }
  15997. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15998. type ELeData struct {
  15999. Code string `json:"code"`
  16000. Data struct {
  16001. Aac002 string `json:"aac002"`
  16002. Aaz500 string `json:"aaz500"`
  16003. ActCardNo string `json:"actCardNo"`
  16004. Bab520 string `json:"bab520"`
  16005. Bkz543 string `json:"bkz543"`
  16006. BusinessType string `json:"businessType"`
  16007. CertfCodg string `json:"certfCodg"`
  16008. EcIndexNo string `json:"ecIndexNo"`
  16009. EcToken string `json:"ecToken"`
  16010. ID0000 string `json:"id0000"`
  16011. IDNo string `json:"idNo"`
  16012. IDType string `json:"idType"`
  16013. Idcode string `json:"idcode"`
  16014. IdentityToken string `json:"identity_token"`
  16015. InsuOrg string `json:"insuOrg"`
  16016. OfficeID string `json:"officeId"`
  16017. OfficeName string `json:"officeName"`
  16018. OperatorID string `json:"operatorId"`
  16019. OperatorName string `json:"operatorName"`
  16020. OrgID string `json:"orgId"`
  16021. UserName string `json:"userName"`
  16022. } `json:"data"`
  16023. Infno interface{} `json:"infno"`
  16024. Message string `json:"message"`
  16025. OrgID string `json:"orgId"`
  16026. TransType string `json:"transType"`
  16027. }
  16028. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16029. outPutInfo = Remove0000(outPutInfo)
  16030. if len(outPutInfo) > 0 {
  16031. var ele ELeData
  16032. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16033. if err != nil {
  16034. utils.ErrorLog("解析失败:%v", err)
  16035. }
  16036. token := ele.Data.EcToken
  16037. fmt.Println(inputInfo)
  16038. fmt.Println(outPutInfo)
  16039. 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)
  16040. saveLog(result, requestLog, "1101", "获取人员信息")
  16041. var dat map[string]interface{}
  16042. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16043. fmt.Println(dat)
  16044. } else {
  16045. fmt.Println(err)
  16046. }
  16047. userJSONBytes, _ := json.Marshal(dat)
  16048. var res ResultTwo
  16049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16050. utils.ErrorLog("解析失败:%v", err)
  16051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16052. return
  16053. }
  16054. res.ErrMsg = errMsgLog
  16055. if res.Infcode == 0 {
  16056. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16057. if err == gorm.ErrRecordNotFound {
  16058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16059. return
  16060. } else if err != nil {
  16061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16062. return
  16063. } else {
  16064. fmt.Println(res)
  16065. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16066. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16067. infoStr := string(Iinfos)
  16068. idetinfoStr := string(Idetinfos)
  16069. psn := &models.HisPsn{
  16070. PsnNo: res.Output.Baseinfo.PsnNo,
  16071. PatientId: patient.ID,
  16072. Certno: res.Output.Baseinfo.Certno,
  16073. Gend: res.Output.Baseinfo.Gend,
  16074. Naty: res.Output.Baseinfo.Naty,
  16075. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16076. PsnName: res.Output.Baseinfo.PsnName,
  16077. Idetinfo: idetinfoStr,
  16078. Insuinfo: infoStr,
  16079. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16080. CardInfo: outPutInfo,
  16081. VerifyNumber: token,
  16082. InsuplcAdmdvs: ele.Data.InsuOrg,
  16083. }
  16084. service.CreateHisPsn(psn)
  16085. var rf []*ResultFive
  16086. json.Unmarshal([]byte(infoStr), &rf)
  16087. var insutypes []*ResultFive
  16088. var insutype string
  16089. var is390 int = 0
  16090. var is310 int = 0
  16091. for _, item := range rf {
  16092. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16093. insutypes = append(insutypes, item)
  16094. }
  16095. }
  16096. if len(insutypes) == 1 {
  16097. insutype = insutypes[0].Insutype
  16098. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16099. } else {
  16100. for _, i := range insutypes {
  16101. if i.Insutype == "390" {
  16102. is390 = 1
  16103. }
  16104. if i.Insutype == "310" {
  16105. is310 = 1
  16106. }
  16107. }
  16108. }
  16109. if is390 == 1 {
  16110. insutype = "390"
  16111. }
  16112. if is310 == 1 {
  16113. insutype = "310"
  16114. }
  16115. if len(insutypes) == 0 {
  16116. insutype = "310"
  16117. }
  16118. c.ServeSuccessJSON(map[string]interface{}{
  16119. "patient": patient,
  16120. "number": token,
  16121. "insutype": insutype,
  16122. })
  16123. }
  16124. } else {
  16125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16126. return
  16127. }
  16128. }
  16129. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16130. var api string
  16131. 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 +
  16132. "&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
  16133. resp, requestErr := http.Get(api)
  16134. if requestErr != nil {
  16135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16136. return
  16137. }
  16138. body, ioErr := ioutil.ReadAll(resp.Body)
  16139. if ioErr != nil {
  16140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16142. return
  16143. }
  16144. var respJSON map[string]interface{}
  16145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16148. return
  16149. }
  16150. var status string
  16151. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16152. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16153. var token string
  16154. var res ResultTwo //1101结果
  16155. var res10265 ResultTwo10265 //1101结果
  16156. if status == "0" { //读卡成功
  16157. var card_info string //卡信息
  16158. var busi_card_info string
  16159. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16160. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16161. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16162. fmt.Println(card_info)
  16163. fmt.Println(busi_card_info)
  16164. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16165. result, _ := json.Marshal(respJSON)
  16166. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16167. utils.ErrorLog("解析失败:%v", err)
  16168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16169. return
  16170. }
  16171. res.ErrMsg = res10265.ErrMsg
  16172. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16173. res.Infcode = infocode
  16174. res.Output = res10265.Output
  16175. res.InfRefmsgid = res10265.InfRefmsgid
  16176. if res.Infcode == 0 {
  16177. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16178. if err == gorm.ErrRecordNotFound {
  16179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16180. return
  16181. } else if err != nil {
  16182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16183. return
  16184. } else {
  16185. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16186. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16187. infoStr := string(Iinfos)
  16188. idetinfoStr := string(Idetinfos)
  16189. psn := &models.HisPsn{
  16190. PsnNo: res.Output.Baseinfo.PsnNo,
  16191. PatientId: patient.ID,
  16192. Certno: res.Output.Baseinfo.Certno,
  16193. Gend: res.Output.Baseinfo.Gend,
  16194. Naty: res.Output.Baseinfo.Naty,
  16195. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16196. PsnName: res.Output.Baseinfo.PsnName,
  16197. Idetinfo: idetinfoStr,
  16198. Insuinfo: infoStr,
  16199. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16200. CardInfo: card_info,
  16201. VerifyNumber: token,
  16202. }
  16203. var rf []*ResultFive
  16204. json.Unmarshal([]byte(infoStr), &rf)
  16205. var insutypes []*ResultFive
  16206. var insutype string
  16207. var is390 int = 0
  16208. var is310 int = 0
  16209. for _, item := range rf {
  16210. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16211. insutypes = append(insutypes, item)
  16212. }
  16213. }
  16214. if len(insutypes) == 1 {
  16215. insutype = insutypes[0].Insutype
  16216. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16217. } else {
  16218. for _, i := range insutypes {
  16219. if i.Insutype == "390" {
  16220. is390 = 1
  16221. }
  16222. if i.Insutype == "310" {
  16223. is310 = 1
  16224. }
  16225. }
  16226. }
  16227. if is390 == 1 {
  16228. insutype = "390"
  16229. }
  16230. if is310 == 1 {
  16231. insutype = "310"
  16232. }
  16233. if len(insutypes) == 0 {
  16234. insutype = "310"
  16235. }
  16236. service.CreateHisPsn(psn)
  16237. c.ServeSuccessJSON(map[string]interface{}{
  16238. "patient": patient,
  16239. "number": token,
  16240. "insutype": insutype,
  16241. })
  16242. }
  16243. } else {
  16244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16245. return
  16246. }
  16247. } else { //读卡失败
  16248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16249. return
  16250. }
  16251. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16252. res := c.GetoleInfo()
  16253. if res.Infcode == 0 {
  16254. var result string
  16255. if res.Output.MdtrtCertType == "01" {
  16256. 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)
  16257. } else if res.Output.MdtrtCertType == "02" {
  16258. 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)
  16259. } else if res.Output.MdtrtCertType == "03" {
  16260. 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)
  16261. }
  16262. var dat map[string]interface{}
  16263. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16264. fmt.Println(dat)
  16265. } else {
  16266. fmt.Println(err)
  16267. }
  16268. userJSONBytes, _ := json.Marshal(dat)
  16269. var res2 ResultTwo
  16270. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16271. utils.ErrorLog("解析失败:%v", err)
  16272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16273. return
  16274. }
  16275. if res2.Infcode == 0 {
  16276. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16277. if err == gorm.ErrRecordNotFound {
  16278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16279. return
  16280. } else if err != nil {
  16281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16282. return
  16283. } else {
  16284. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16285. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16286. infoStr := string(Iinfos)
  16287. idetinfoStr := string(Idetinfos)
  16288. var rf []*ResultFive
  16289. json.Unmarshal([]byte(infoStr), &rf)
  16290. var insutypes []*ResultFive
  16291. var insutype string
  16292. var is390 int = 0
  16293. var is310 int = 0
  16294. //var insuplc_admdvs string
  16295. for _, item := range rf {
  16296. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16297. insutypes = append(insutypes, item)
  16298. }
  16299. }
  16300. if len(insutypes) == 1 {
  16301. insutype = insutypes[0].Insutype
  16302. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16303. } else {
  16304. for _, i := range insutypes {
  16305. if i.Insutype == "390" {
  16306. is390 = 1
  16307. }
  16308. if i.Insutype == "310" {
  16309. is310 = 1
  16310. }
  16311. }
  16312. }
  16313. if is390 == 1 {
  16314. insutype = "390"
  16315. }
  16316. if is310 == 1 {
  16317. insutype = "310"
  16318. }
  16319. if len(insutypes) == 0 {
  16320. insutype = "310"
  16321. }
  16322. psn := &models.HisPsn{
  16323. PsnNo: res2.Output.Baseinfo.PsnNo,
  16324. PatientId: patient.ID,
  16325. Certno: res2.Output.Baseinfo.Certno,
  16326. Gend: res2.Output.Baseinfo.Gend,
  16327. Naty: res2.Output.Baseinfo.Naty,
  16328. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16329. PsnName: res2.Output.Baseinfo.PsnName,
  16330. Idetinfo: idetinfoStr,
  16331. Insuinfo: infoStr,
  16332. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16333. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16334. VerifyNumber: res.Output.EcToken,
  16335. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16336. }
  16337. if res.Output.MdtrtCertType == "01" {
  16338. psn.VerifyNumber = res.Output.EcToken
  16339. //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)
  16340. } else if res.Output.MdtrtCertType == "02" {
  16341. psn.VerifyNumber = res.Output.CardNo
  16342. //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)
  16343. } else if res.Output.MdtrtCertType == "03" {
  16344. psn.VerifyNumber = res.Output.MdtrtCertNo
  16345. //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)
  16346. }
  16347. service.CreateHisPsn(psn)
  16348. var balc float64
  16349. for _, item := range rf {
  16350. if item.Insutype == insutype {
  16351. balc = item.Balc
  16352. }
  16353. }
  16354. c.ServeSuccessJSON(map[string]interface{}{
  16355. "patient": patient,
  16356. "number": res.Output.CardNo,
  16357. "insutype": insutype,
  16358. "blac": balc,
  16359. "desc": idetinfoStr,
  16360. })
  16361. }
  16362. } else {
  16363. c.ServeSuccessJSON(map[string]interface{}{
  16364. "failed_code": -10,
  16365. "msg": res2.ErrMsg,
  16366. })
  16367. }
  16368. } else {
  16369. c.ServeSuccessJSON(map[string]interface{}{
  16370. "failed_code": -10,
  16371. "msg": res.ErrMsg,
  16372. })
  16373. }
  16374. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16375. var res ResultTwo
  16376. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16377. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16378. "&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)
  16379. resp, requestErr := http.Get(api)
  16380. if requestErr != nil {
  16381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16382. return
  16383. }
  16384. body, ioErr := ioutil.ReadAll(resp.Body)
  16385. if ioErr != nil {
  16386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16388. return
  16389. }
  16390. var respJSON map[string]interface{}
  16391. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16394. return
  16395. }
  16396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16397. result, _ := json.Marshal(respJSON)
  16398. fmt.Println("log")
  16399. fmt.Println(string(result))
  16400. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16401. utils.ErrorLog("解析失败:%v", err)
  16402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16403. return
  16404. }
  16405. if res.Infcode == 0 {
  16406. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16407. if err == gorm.ErrRecordNotFound {
  16408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16409. return
  16410. } else if err != nil {
  16411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16412. return
  16413. } else {
  16414. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16415. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16416. infoStr := string(Iinfos)
  16417. idetinfoStr := string(Idetinfos)
  16418. var rf []*ResultFive
  16419. json.Unmarshal([]byte(infoStr), &rf)
  16420. var insutypes []*ResultFive
  16421. var insutype string
  16422. var is390 int = 0
  16423. var is310 int = 0
  16424. for _, item := range rf {
  16425. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16426. insutypes = append(insutypes, item)
  16427. }
  16428. }
  16429. if len(insutypes) == 1 {
  16430. insutype = insutypes[0].Insutype
  16431. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16432. } else {
  16433. for _, i := range insutypes {
  16434. if i.Insutype == "390" {
  16435. is390 = 1
  16436. }
  16437. if i.Insutype == "310" {
  16438. is310 = 1
  16439. }
  16440. }
  16441. }
  16442. if is390 == 1 {
  16443. insutype = "390"
  16444. }
  16445. if is310 == 1 {
  16446. insutype = "310"
  16447. }
  16448. if len(insutypes) == 0 {
  16449. insutype = "390"
  16450. }
  16451. var insuplc_admdvs string
  16452. for _, item := range rf {
  16453. if item.Insutype == insutype {
  16454. insuplc_admdvs = item.InsuplcAdmdvs
  16455. }
  16456. }
  16457. psn := &models.HisPsn{
  16458. PsnNo: res.Output.Baseinfo.PsnNo,
  16459. PatientId: patient.ID,
  16460. Certno: res.Output.Baseinfo.Certno,
  16461. Gend: res.Output.Baseinfo.Gend,
  16462. Naty: res.Output.Baseinfo.Naty,
  16463. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16464. PsnName: res.Output.Baseinfo.PsnName,
  16465. Idetinfo: idetinfoStr,
  16466. Insuinfo: infoStr,
  16467. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16468. InsuplcAdmdvs: insuplc_admdvs,
  16469. }
  16470. service.CreateHisPsn(psn)
  16471. c.ServeSuccessJSON(map[string]interface{}{
  16472. "patient": patient,
  16473. "number": res.Output.Baseinfo.Certno,
  16474. })
  16475. }
  16476. } else {
  16477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16478. return
  16479. }
  16480. } else {
  16481. type ELeData struct {
  16482. Code string `json:"code"`
  16483. Data struct {
  16484. Aac002 string `json:"aac002"`
  16485. Aaz500 string `json:"aaz500"`
  16486. ActCardNo string `json:"actCardNo"`
  16487. Bab520 string `json:"bab520"`
  16488. Bkz543 string `json:"bkz543"`
  16489. BusinessType string `json:"businessType"`
  16490. CertfCodg string `json:"certfCodg"`
  16491. EcIndexNo string `json:"ecIndexNo"`
  16492. EcToken string `json:"ecToken"`
  16493. ID0000 string `json:"id0000"`
  16494. IDNo string `json:"idNo"`
  16495. IDType string `json:"idType"`
  16496. Idcode string `json:"idcode"`
  16497. IdentityToken string `json:"identity_token"`
  16498. InsuOrg string `json:"insuOrg"`
  16499. OfficeID string `json:"officeId"`
  16500. OfficeName string `json:"officeName"`
  16501. OperatorID string `json:"operatorId"`
  16502. OperatorName string `json:"operatorName"`
  16503. OrgID string `json:"orgId"`
  16504. UserName string `json:"userName"`
  16505. } `json:"data"`
  16506. Infno interface{} `json:"infno"`
  16507. Message string `json:"message"`
  16508. OrgID string `json:"orgId"`
  16509. TransType string `json:"transType"`
  16510. }
  16511. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16512. fmt.Println(result)
  16513. outPutInfo := Remove0000(result)
  16514. fmt.Println(outPutInfo)
  16515. if len(outPutInfo) > 0 {
  16516. var ele ELeData
  16517. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16518. if err != nil {
  16519. utils.ErrorLog("解析失败:%v", err)
  16520. }
  16521. token := ele.Data.EcToken
  16522. fmt.Println(outPutInfo)
  16523. 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)
  16524. saveLog(result, requestLog, "1101", "获取人员信息")
  16525. var dat map[string]interface{}
  16526. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16527. fmt.Println(dat)
  16528. } else {
  16529. fmt.Println(err)
  16530. }
  16531. userJSONBytes, _ := json.Marshal(dat)
  16532. var res ResultTwo
  16533. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16534. utils.ErrorLog("解析失败:%v", err)
  16535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16536. return
  16537. }
  16538. if res.Infcode == 0 {
  16539. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16540. if err == gorm.ErrRecordNotFound {
  16541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16542. return
  16543. } else if err != nil {
  16544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16545. return
  16546. } else {
  16547. fmt.Println(res)
  16548. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16549. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16550. infoStr := string(Iinfos)
  16551. idetinfoStr := string(Idetinfos)
  16552. psn := &models.HisPsn{
  16553. PsnNo: res.Output.Baseinfo.PsnNo,
  16554. PatientId: patient.ID,
  16555. Certno: res.Output.Baseinfo.Certno,
  16556. Gend: res.Output.Baseinfo.Gend,
  16557. Naty: res.Output.Baseinfo.Naty,
  16558. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16559. PsnName: res.Output.Baseinfo.PsnName,
  16560. Idetinfo: idetinfoStr,
  16561. Insuinfo: infoStr,
  16562. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16563. CardInfo: outPutInfo,
  16564. VerifyNumber: token,
  16565. InsuplcAdmdvs: ele.Data.InsuOrg,
  16566. }
  16567. service.CreateHisPsn(psn)
  16568. var rf []*ResultFive
  16569. json.Unmarshal([]byte(infoStr), &rf)
  16570. var insutypes []*ResultFive
  16571. var insutype string
  16572. var is390 int = 0
  16573. var is310 int = 0
  16574. for _, item := range rf {
  16575. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16576. insutypes = append(insutypes, item)
  16577. }
  16578. }
  16579. if len(insutypes) == 1 {
  16580. insutype = insutypes[0].Insutype
  16581. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16582. } else {
  16583. for _, i := range insutypes {
  16584. if i.Insutype == "390" {
  16585. is390 = 1
  16586. }
  16587. if i.Insutype == "310" {
  16588. is310 = 1
  16589. }
  16590. }
  16591. }
  16592. if is390 == 1 {
  16593. insutype = "390"
  16594. }
  16595. if is310 == 1 {
  16596. insutype = "310"
  16597. }
  16598. if len(insutypes) == 0 {
  16599. insutype = "310"
  16600. }
  16601. c.ServeSuccessJSON(map[string]interface{}{
  16602. "patient": patient,
  16603. "number": token,
  16604. "insutype": insutype,
  16605. })
  16606. }
  16607. } else {
  16608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16609. return
  16610. }
  16611. }
  16612. //fmt.Println(result)
  16613. //
  16614. //if initFlag == 0 {
  16615. // c.TestGetBasBaseInit()
  16616. //}
  16617. //token := c.GetEleBaseInfo()
  16618. //
  16619. //token = Remove0000(token)
  16620. //
  16621. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16622. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16623. ////
  16624. //var res ResultTwo
  16625. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16626. // utils.ErrorLog("解析失败:%v", err)
  16627. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16628. // return
  16629. //}
  16630. //
  16631. //if res.Infcode == 0 {
  16632. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16633. // if err == gorm.ErrRecordNotFound {
  16634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16635. // return
  16636. // } else if err != nil {
  16637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16638. // return
  16639. //
  16640. // } else {
  16641. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16642. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16643. // infoStr := string(Iinfos)
  16644. // idetinfoStr := string(Idetinfos)
  16645. //
  16646. //
  16647. //
  16648. //
  16649. // var rf []*ResultFive
  16650. // json.Unmarshal([]byte(infoStr), &rf)
  16651. //
  16652. // var insutypes []*ResultFive
  16653. // var insutype string
  16654. // var is390 int = 0
  16655. // var is310 int = 0
  16656. // var insuplc_admdvs string
  16657. //
  16658. // for _, item := range rf {
  16659. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16660. // insutypes = append(insutypes, item)
  16661. // }
  16662. // }
  16663. //
  16664. // if len(insutypes) == 1 {
  16665. // insutype = insutypes[0].Insutype
  16666. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16667. // } else {
  16668. // for _, i := range insutypes {
  16669. // if i.Insutype == "390" {
  16670. // is390 = 1
  16671. // }
  16672. //
  16673. // if i.Insutype == "310" {
  16674. // is310 = 1
  16675. // }
  16676. // }
  16677. // }
  16678. // if is390 == 1 {
  16679. // insutype = "390"
  16680. // }
  16681. //
  16682. // if is310 == 1 {
  16683. // insutype = "310"
  16684. // }
  16685. // if len(insutypes) == 0 {
  16686. // insutype = "310"
  16687. // }
  16688. // for _, item := range rf {
  16689. // if item.Insutype == insutype {
  16690. // insuplc_admdvs = item.InsuplcAdmdvs
  16691. // }
  16692. // }
  16693. // psn := &models.HisPsn{
  16694. // PsnNo: res.Output.Baseinfo.PsnNo,
  16695. // Age: res.Output.Baseinfo.Age,
  16696. // PatientId: patient.ID,
  16697. // Certno: res.Output.Baseinfo.Certno,
  16698. // Brdy: res.Output.Baseinfo.Brdy,
  16699. // Gend: res.Output.Baseinfo.Gend,
  16700. // Naty: res.Output.Baseinfo.Naty,
  16701. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16702. // PsnName: res.Output.Baseinfo.PsnName,
  16703. // Idetinfo: idetinfoStr,
  16704. // Insuinfo: infoStr,
  16705. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16706. // CardInfo: "",
  16707. // VerifyNumber: token,
  16708. // InsuplcAdmdvs: insuplc_admdvs,
  16709. // }
  16710. // service.CreateHisPsn(psn)
  16711. //
  16712. // c.ServeSuccessJSON(map[string]interface{}{
  16713. // "patient": patient,
  16714. // "number": token,
  16715. // })
  16716. // }
  16717. //} else {
  16718. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16719. // return
  16720. //}
  16721. }
  16722. break
  16723. case 5:
  16724. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16725. var api string
  16726. if miConfig.MdtrtareaAdmvs == "320921" {
  16727. 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 +
  16728. "&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
  16729. fmt.Println(api)
  16730. } else {
  16731. 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 +
  16732. "&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)
  16733. }
  16734. resp, requestErr := http.Get(api)
  16735. if requestErr != nil {
  16736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16737. return
  16738. }
  16739. body, ioErr := ioutil.ReadAll(resp.Body)
  16740. if ioErr != nil {
  16741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16743. return
  16744. }
  16745. var respJSON map[string]interface{}
  16746. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16749. return
  16750. }
  16751. var status string
  16752. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16753. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16754. var token string
  16755. var res ResultTwo //1101结果
  16756. var res10265 ResultTwo10265 //1101结果
  16757. if status == "0" { //读卡成功
  16758. var card_info string //卡信息
  16759. //var busi_card_info string
  16760. var auth_info string
  16761. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16762. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16763. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16764. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16765. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16766. result, _ := json.Marshal(respJSON)
  16767. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16768. utils.ErrorLog("解析失败:%v", err)
  16769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16770. return
  16771. }
  16772. res.ErrMsg = res10265.ErrMsg
  16773. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16774. res.Infcode = infocode
  16775. res.Output = res10265.Output
  16776. res.InfRefmsgid = res10265.InfRefmsgid
  16777. if res.Infcode == 0 {
  16778. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16779. if err == gorm.ErrRecordNotFound {
  16780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16781. return
  16782. } else if err != nil {
  16783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16784. return
  16785. } else {
  16786. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16787. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16788. infoStr := string(Iinfos)
  16789. idetinfoStr := string(Idetinfos)
  16790. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16791. psn := &models.HisPsn{
  16792. PsnNo: res.Output.Baseinfo.PsnNo,
  16793. PatientId: patient.ID,
  16794. Certno: res.Output.Baseinfo.Certno,
  16795. Gend: res.Output.Baseinfo.Gend,
  16796. Brdy: b,
  16797. Age: float64(age),
  16798. Naty: res.Output.Baseinfo.Naty,
  16799. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16800. PsnName: res.Output.Baseinfo.PsnName,
  16801. Idetinfo: idetinfoStr,
  16802. Insuinfo: infoStr,
  16803. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16804. CardInfo: card_info,
  16805. VerifyNumber: token,
  16806. AuthInfo: auth_info,
  16807. }
  16808. var rf []*ResultFive
  16809. json.Unmarshal([]byte(infoStr), &rf)
  16810. var insutypes []*ResultFive
  16811. var insutype string
  16812. var is390 int = 0
  16813. var is310 int = 0
  16814. for _, item := range rf {
  16815. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16816. insutypes = append(insutypes, item)
  16817. }
  16818. }
  16819. if len(insutypes) == 1 {
  16820. insutype = insutypes[0].Insutype
  16821. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16822. } else {
  16823. for _, i := range insutypes {
  16824. if i.Insutype == "390" {
  16825. is390 = 1
  16826. }
  16827. if i.Insutype == "310" {
  16828. is310 = 1
  16829. }
  16830. }
  16831. }
  16832. if is390 == 1 {
  16833. insutype = "390"
  16834. }
  16835. if is310 == 1 {
  16836. insutype = "310"
  16837. }
  16838. if len(insutypes) == 0 {
  16839. insutype = "310"
  16840. }
  16841. service.CreateHisPsn(psn)
  16842. c.ServeSuccessJSON(map[string]interface{}{
  16843. "patient": patient,
  16844. "number": token,
  16845. "insutype": insutype,
  16846. })
  16847. }
  16848. } else {
  16849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16850. return
  16851. }
  16852. } else { //读卡失败
  16853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16854. return
  16855. }
  16856. }
  16857. break
  16858. }
  16859. }
  16860. var initFlag int64 = 0
  16861. var initEleFlag int64 = 0
  16862. func (c *HisApiController) TestGetBasBaseInit() {
  16863. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16864. Iinit := DllDef.MustFindProc("Init")
  16865. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16866. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  16867. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  16868. if ret != 0 {
  16869. fmt.Println("SSCard的报错原因:", err)
  16870. fmt.Println("SSCard的运算结果为:", ret)
  16871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16872. return
  16873. }
  16874. result := int(ret)
  16875. fmt.Println("SSCard的运算结果为1:", result)
  16876. initFlag = 1
  16877. return
  16878. }
  16879. func (c *HisApiController) HandleJiangXiReadCard() {
  16880. fmt.Println("~~~~~~")
  16881. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16882. admin_user_id, _ := c.GetInt64("admin_user_id")
  16883. id_card_type, _ := c.GetInt64("id_card_type")
  16884. //certificates, _ := c.GetInt64("certificates")
  16885. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16886. if initFlag == 0 {
  16887. c.TestGetJiangXiBasBaseInit()
  16888. }
  16889. basStr := c.GetBasBaseInfo()
  16890. if len(basStr) == 0 {
  16891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16892. return
  16893. }
  16894. fmt.Println(basStr)
  16895. bas := strings.Split(basStr, "|")
  16896. basNumber := bas[1]
  16897. fmt.Println(basNumber)
  16898. card_sn := bas[3]
  16899. fmt.Println(card_sn)
  16900. 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, "")
  16901. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  16902. var dat map[string]interface{}
  16903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16904. fmt.Println(dat)
  16905. } else {
  16906. fmt.Println(err)
  16907. }
  16908. userJSONBytes, _ := json.Marshal(dat)
  16909. var res ResultTwo
  16910. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16911. utils.ErrorLog("解析失败:%v", err)
  16912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16913. return
  16914. }
  16915. if res.Infcode == 0 {
  16916. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  16917. if err == gorm.ErrRecordNotFound {
  16918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16919. return
  16920. } else if err != nil {
  16921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16922. return
  16923. } else {
  16924. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16925. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16926. infoStr := string(Iinfos)
  16927. idetinfoStr := string(Idetinfos)
  16928. psn := &models.HisPsn{
  16929. PsnNo: res.Output.Baseinfo.PsnNo,
  16930. PatientId: patient.ID,
  16931. Certno: res.Output.Baseinfo.Certno,
  16932. Gend: res.Output.Baseinfo.Gend,
  16933. Naty: res.Output.Baseinfo.Naty,
  16934. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16935. PsnName: res.Output.Baseinfo.PsnName,
  16936. Idetinfo: idetinfoStr,
  16937. Insuinfo: infoStr,
  16938. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16939. CardInfo: basStr,
  16940. VerifyNumber: "",
  16941. }
  16942. service.CreateHisPsn(psn)
  16943. c.ServeSuccessJSON(map[string]interface{}{
  16944. "patient": patient,
  16945. "number": basNumber,
  16946. })
  16947. }
  16948. } else {
  16949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16950. return
  16951. }
  16952. }
  16953. func (c *HisApiController) TestGetHnBasBaseInit() {
  16954. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16955. Iinit := DllDef.MustFindProc("Init")
  16956. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16957. //http://10.77.211.236/CSB/hsa-fsi-1303
  16958. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  16959. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  16960. // 调用 Init 函数
  16961. 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"))))
  16962. //if ret != 0 {
  16963. fmt.Println("SSCard的报错原因:", err)
  16964. fmt.Println("SSCard的运算结果为:", ret)
  16965. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16966. // return
  16967. //}
  16968. result := int(ret)
  16969. fmt.Println("SSCard的运算结果为1:", result)
  16970. initFlag = 1
  16971. return
  16972. }
  16973. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  16974. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16975. Iinit := DllDef.MustFindProc("Init")
  16976. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16977. //http://10.77.211.236/CSB/hsa-fsi-1303
  16978. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  16979. if ret != 0 {
  16980. fmt.Println("SSCard的报错原因:", err)
  16981. fmt.Println("SSCard的运算结果为:", ret)
  16982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16983. return
  16984. }
  16985. result := int(ret)
  16986. fmt.Println("SSCard的运算结果为1:", result)
  16987. initFlag = 1
  16988. return
  16989. }
  16990. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  16991. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16992. Iinit := DllDef.MustFindProc("Init")
  16993. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16994. //http://10.77.211.236/CSB/hsa-fsi-1303
  16995. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  16996. if ret != 0 {
  16997. fmt.Println("SSCard的报错原因:", err)
  16998. fmt.Println("SSCard的运算结果为:", ret)
  16999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17000. return
  17001. }
  17002. result := int(ret)
  17003. fmt.Println("SSCard的运算结果为1:", result)
  17004. initFlag = 1
  17005. return
  17006. }
  17007. func (c *HisApiController) GetSFZBaseInfo() string {
  17008. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17009. readCard := DllDef.MustFindProc("ReadSFZ")
  17010. if readCard == nil {
  17011. fmt.Println("readcard is nil")
  17012. readCard = DllDef.MustFindProc("ReadSFZ")
  17013. }
  17014. str := make([]byte, 8096)
  17015. str1 := make([]byte, 8096)
  17016. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17017. fmt.Println(r)
  17018. return Remove0000(string(str))
  17019. }
  17020. func (c *HisApiController) GetEleBaseInfo() string {
  17021. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17022. readCard := DllDef.MustFindProc("GetQRBase")
  17023. fmt.Println(readCard)
  17024. if readCard == nil {
  17025. fmt.Println("readcard is nil")
  17026. readCard = DllDef.MustFindProc("GetQRBase")
  17027. }
  17028. str := make([]byte, 1024)
  17029. str1 := make([]byte, 1024)
  17030. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17031. fmt.Println(ret2)
  17032. fmt.Println(string(str1))
  17033. fmt.Println(string(str))
  17034. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17035. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17036. if ret2 != 0 {
  17037. return ""
  17038. }
  17039. return string(str)
  17040. }
  17041. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17042. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17043. readCard := DllDef.MustFindProc("NationEcTrans")
  17044. fmt.Println(readCard)
  17045. fmt.Println("!!!!!")
  17046. pBusiCardInfo := make([]byte, 2048)
  17047. input := make(map[string]interface{})
  17048. inputData := make(map[string]interface{})
  17049. inputData["orgId"] = code
  17050. inputData["businessType"] = "01101"
  17051. inputData["operatorId"] = "1"
  17052. inputData["operatorName"] = "admin"
  17053. inputData["officeId"] = "001"
  17054. inputData["officeName"] = "血透室"
  17055. inputData["deviceType"] = ""
  17056. input["data"] = inputData
  17057. input["orgId"] = code
  17058. input["transType"] = "ec.query"
  17059. bytesData, _ := json.Marshal(input)
  17060. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17061. fmt.Println(ret2)
  17062. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17063. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17064. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17065. }
  17066. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17067. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17068. readCard := DllDef.MustFindProc("NationEcTrans")
  17069. fmt.Println(readCard)
  17070. fmt.Println("!!!!!")
  17071. pBusiCardInfo := make([]byte, 2048)
  17072. input := make(map[string]interface{})
  17073. inputData := make(map[string]interface{})
  17074. inputData["orgId"] = code
  17075. inputData["businessType"] = "01101"
  17076. inputData["operatorId"] = "9"
  17077. inputData["operatorName"] = "admin"
  17078. inputData["officeId"] = "001"
  17079. inputData["officeName"] = "血透室"
  17080. inputData["deviceType"] = ""
  17081. input["data"] = inputData
  17082. input["orgId"] = code
  17083. input["transType"] = "ec.query"
  17084. bytesData, _ := json.Marshal(input)
  17085. 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])))
  17086. fmt.Println(ret2)
  17087. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17088. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17089. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17090. }
  17091. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17092. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17093. readCard := DllDef.MustFindProc("NationEcTrans")
  17094. fmt.Println(readCard)
  17095. fmt.Println("!!!!!")
  17096. pBusiCardInfo := make([]byte, 2048)
  17097. input := make(map[string]interface{})
  17098. inputData := make(map[string]interface{})
  17099. inputData["orgId"] = code
  17100. inputData["businessType"] = "01301"
  17101. inputData["operatorId"] = "9"
  17102. inputData["operatorName"] = "admin"
  17103. inputData["officeId"] = "001"
  17104. inputData["officeName"] = "血透室"
  17105. inputData["deviceType"] = ""
  17106. input["data"] = inputData
  17107. input["orgId"] = code
  17108. input["transType"] = "ec.query"
  17109. bytesData, _ := json.Marshal(input)
  17110. 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])))
  17111. fmt.Println(ret2)
  17112. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17113. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17114. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17115. }
  17116. func GetJxEleBaseInfo(org_id int64) string {
  17117. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17118. readCard := DllDef.MustFindProc("NationEcTrans")
  17119. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17120. if readCard == nil {
  17121. fmt.Println("readcard is nil")
  17122. readCard = DllDef.MustFindProc("NationEcTrans")
  17123. }
  17124. str1 := make([]byte, 1024)
  17125. data := make(map[string]interface{})
  17126. inputData := make(map[string]interface{})
  17127. inputData["orgId"] = miConfig.Code
  17128. inputData["businessType"] = "01101"
  17129. inputData["operatorId"] = "test001"
  17130. inputData["operatorName"] = "cn"
  17131. inputData["officeId"] = "32760"
  17132. inputData["officeName"] = "waike"
  17133. inputData["deviceType"] = ""
  17134. data["data"] = inputData
  17135. data["transType"] = "ec.query"
  17136. data["extra "] = ""
  17137. data["orgId"] = miConfig.Code
  17138. bytesData, _ := json.Marshal(data)
  17139. //bytesData, _ := json.Marshal(data)
  17140. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17141. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17142. fmt.Println(ret2)
  17143. fmt.Println(string(str1))
  17144. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17145. if ret2 != 0 {
  17146. return ""
  17147. }
  17148. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17149. }
  17150. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17151. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17152. // readCard := DllDef.MustFindProc("NationEcTrans")
  17153. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17154. //
  17155. // if readCard == nil {
  17156. // fmt.Println("readcard is nil")
  17157. // readCard = DllDef.MustFindProc("NationEcTrans")
  17158. // }
  17159. // str1 := make([]byte, 1024)
  17160. //
  17161. // data := make(map[string]interface{})
  17162. //
  17163. // inputData := make(map[string]interface{})
  17164. // inputData["orgId"] = miConfig.Code
  17165. // inputData["businessType"] = "01101"
  17166. // inputData["operatorId"] = "test001"
  17167. // inputData["operatorName"] = "cn"
  17168. // inputData["officeId"] = "32760"
  17169. // inputData["officeName"] = "waike"
  17170. // inputData["deviceType"] = ""
  17171. //
  17172. // data["data"] = inputData
  17173. // data["transType"] = "ec.query"
  17174. // data["extra "] = ""
  17175. // data["orgId"] = miConfig.Code
  17176. // bytesData, _ := json.Marshal(data)
  17177. // //bytesData, _ := json.Marshal(data)
  17178. //
  17179. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17180. //
  17181. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17182. // fmt.Println(ret2)
  17183. // fmt.Println(string(str1))
  17184. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17185. //
  17186. // if ret2 != 0 {
  17187. // return ""
  17188. // }
  17189. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17190. //}
  17191. func GetJxEleBaseInitInfo(org_id int64) string {
  17192. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17193. readCard := DllDef.MustFindProc("NationEcTrans")
  17194. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17195. if readCard == nil {
  17196. fmt.Println("readcard is nil")
  17197. readCard = DllDef.MustFindProc("NationEcTrans")
  17198. }
  17199. str1 := make([]byte, 2048)
  17200. data := make(map[string]interface{})
  17201. inputData := make(map[string]interface{})
  17202. inputData["orgId"] = miConfig.Code
  17203. inputData["businessType"] = "01101"
  17204. inputData["operatorId"] = "1"
  17205. inputData["operatorName"] = "huangchuang"
  17206. inputData["officeId"] = "101"
  17207. inputData["officeName"] = "xuetou"
  17208. inputData["deviceType"] = ""
  17209. data["data"] = inputData
  17210. data["transType"] = "ec.query"
  17211. data["orgId"] = miConfig.Code
  17212. bytesData, _ := json.Marshal(data)
  17213. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17214. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17215. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17216. fmt.Println(ret2)
  17217. fmt.Println(string(str1))
  17218. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17219. if ret2 != 0 {
  17220. return ""
  17221. }
  17222. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17223. initEleFlag = 1
  17224. }
  17225. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17226. }
  17227. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17228. // // 构建命令
  17229. // cmd := exec.Command("python", "b.py")
  17230. //
  17231. // // 执行命令并等待完成
  17232. // output, err := cmd.CombinedOutput()
  17233. // if err != nil {
  17234. // fmt.Println("Error executing Python script:", err)
  17235. // return
  17236. // }
  17237. //
  17238. // // 打印Python脚本的输出
  17239. // fmt.Println(string(output))
  17240. //}
  17241. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17242. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17243. readCard := DllDef.MustFindProc("gxyb_call")
  17244. if readCard == nil {
  17245. fmt.Println("readcard is nil")
  17246. readCard = DllDef.MustFindProc("gxyb_call")
  17247. }
  17248. str := make([]byte, 1024)
  17249. str1 := make([]byte, 1024)
  17250. //data := make(map[string]interface{})
  17251. currentTime := time.Now()
  17252. // 格式化时间为 "YYYYMMDDHH24MISS"
  17253. formattedTime := currentTime.Format("20060102150405")
  17254. inputData := make(map[string]interface{})
  17255. inputData2 := make(map[string]interface{})
  17256. inputData["transNo"] = "1401"
  17257. inputData["transType"] = "passwordCheck"
  17258. inputData["timestamp"] = formattedTime
  17259. inputData2["fixmedinsCode"] = code
  17260. inputData2["psnNo"] = ""
  17261. inputData["data"] = inputData2
  17262. jsonBytes, err := json.Marshal(inputData)
  17263. if err != nil {
  17264. fmt.Println("Error encoding map to JSON:", err)
  17265. }
  17266. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17267. fmt.Println(string(str1))
  17268. fmt.Println(string(str))
  17269. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17270. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17271. if ret2 != 0 {
  17272. return ""
  17273. }
  17274. return string(str)
  17275. }
  17276. func (c *HisApiController) GetoleInfo() Response {
  17277. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17278. defer ole.CoUninitialize()
  17279. // Replace with the ProgID or CLSID of your COM object
  17280. progID := "YinHai.XJ.Actual.Interface.New"
  17281. // Create COM object
  17282. unknown, err := oleutil.CreateObject(progID)
  17283. if err != nil {
  17284. fmt.Println("Unable to create COM object:", err)
  17285. }
  17286. defer unknown.Release()
  17287. // Query for the IDispatch interface
  17288. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17289. if err != nil {
  17290. fmt.Println("Unable to get IDispatch interface:", err)
  17291. }
  17292. defer dispatch.Release()
  17293. // Prepare parameters
  17294. transNo := "1401"
  17295. transType := "passwordCheck"
  17296. timestamp := time.Now().Unix()
  17297. fixmedinsCode := "H45072101171"
  17298. psnNo := ""
  17299. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17300. result2 := ""
  17301. // Call COM object's method using the IDispatch interface
  17302. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17303. fmt.Println(resulr)
  17304. fmt.Println(result2)
  17305. if err != nil {
  17306. fmt.Println("调用COM对象方法失败:", err)
  17307. }
  17308. var response Response
  17309. err2 := json.Unmarshal([]byte(result2), &response)
  17310. if err2 != nil {
  17311. fmt.Println("解析JSON失败:", err)
  17312. }
  17313. return response
  17314. }
  17315. func (c *HisApiController) GetBasBaseInfo() string {
  17316. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17317. readCard := DllDef.MustFindProc("ReadCardBas")
  17318. if readCard == nil {
  17319. fmt.Println("readcard is nil")
  17320. readCard = DllDef.MustFindProc("ReadCardBas")
  17321. }
  17322. str := make([]byte, 1024)
  17323. str1 := make([]byte, 1024)
  17324. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17325. fmt.Println(string(str1))
  17326. fmt.Println(string(str))
  17327. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17328. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17329. if ret2 != 0 {
  17330. return ""
  17331. }
  17332. return string(str)
  17333. }
  17334. type Program struct {
  17335. FunctionID string `xml:"function_id"`
  17336. CardInfo string `xml:"cardinfo"`
  17337. User string `xml:"user"`
  17338. }
  17339. func (c *HisApiController) GetBasBaseInfo1111() string {
  17340. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17341. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17342. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17343. if readCard == nil {
  17344. fmt.Println("readcard is nil")
  17345. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17346. }
  17347. if readCard2 == nil {
  17348. fmt.Println("readcard is nil")
  17349. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17350. }
  17351. str := make([]byte, 1024)
  17352. str1 := make([]byte, 1024)
  17353. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17354. str3 := make([]byte, 1024)
  17355. str4 := make([]byte, 1024)
  17356. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17357. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17358. //if err != nil {
  17359. // fmt.Println("Error opening file:", err)
  17360. //}
  17361. //defer file.Close()
  17362. //
  17363. //var lastProgram Program
  17364. //scanner := bufio.NewScanner(file)
  17365. //inProgram := false
  17366. //
  17367. //for scanner.Scan() {
  17368. // line := scanner.Text()
  17369. // if strings.Contains(line, "<program>") {
  17370. // inProgram = true
  17371. // programXML := "<program>"
  17372. // for scanner.Scan() {
  17373. // line = scanner.Text()
  17374. // programXML += line
  17375. // if strings.Contains(line, "</program>") {
  17376. // programXML += "</program>"
  17377. // break
  17378. // }
  17379. // }
  17380. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17381. // // 解析成功,更新最后的 Program
  17382. // }
  17383. // inProgram = false
  17384. // }
  17385. //}
  17386. //
  17387. // fmt.Println("Error reading file:", inProgram)
  17388. //
  17389. //if err := scanner.Err(); err != nil {
  17390. // fmt.Println("Error reading file:", err)
  17391. //}
  17392. // 输出最后一次的 Program
  17393. //fmt.Printf("最后一次的 <program>:\n")
  17394. //fmt.Printf("<program>\n")
  17395. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17396. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17397. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17398. //fmt.Printf("</program>\n")
  17399. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17400. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17401. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17402. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17403. return ConvertToString(string(str), "gbk", "utf-8")
  17404. }
  17405. func (c *HisApiController) GetBasBaseInfo22222() string {
  17406. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17407. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17408. if readCard == nil {
  17409. fmt.Println("readcard is nil")
  17410. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17411. }
  17412. str := make([]byte, 1024)
  17413. str1 := make([]byte, 1024)
  17414. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17415. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17416. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17417. //if err != nil {
  17418. // fmt.Println("Error opening file:", err)
  17419. //}
  17420. //defer file.Close()
  17421. //
  17422. //var lastProgram Program
  17423. //scanner := bufio.NewScanner(file)
  17424. //inProgram := false
  17425. //
  17426. //for scanner.Scan() {
  17427. // line := scanner.Text()
  17428. // if strings.Contains(line, "<program>") {
  17429. // inProgram = true
  17430. // programXML := "<program>"
  17431. // for scanner.Scan() {
  17432. // line = scanner.Text()
  17433. // programXML += line
  17434. // if strings.Contains(line, "</program>") {
  17435. // programXML += "</program>"
  17436. // break
  17437. // }
  17438. // }
  17439. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17440. // // 解析成功,更新最后的 Program
  17441. // }
  17442. // inProgram = false
  17443. // }
  17444. //}
  17445. //
  17446. // fmt.Println("Error reading file:", inProgram)
  17447. //
  17448. //if err := scanner.Err(); err != nil {
  17449. // fmt.Println("Error reading file:", err)
  17450. //}
  17451. // 输出最后一次的 Program
  17452. //fmt.Printf("最后一次的 <program>:\n")
  17453. //fmt.Printf("<program>\n")
  17454. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17455. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17456. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17457. //fmt.Printf("</program>\n")
  17458. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17459. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17460. return ConvertToString(string(str1), "gbk", "utf-8")
  17461. }
  17462. func (c *HisApiController) GetahBasBaseInfo() string {
  17463. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17464. readCard := DllDef.MustFindProc("iReadCardBas")
  17465. if readCard == nil {
  17466. fmt.Println("readcard is nil")
  17467. readCard = DllDef.MustFindProc("iReadCardBas")
  17468. }
  17469. //str := make([]byte, 1024)
  17470. str1 := make([]byte, 1024)
  17471. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17472. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17473. //if err != nil {
  17474. // fmt.Println("Error opening file:", err)
  17475. //}
  17476. //defer file.Close()
  17477. //
  17478. //var lastProgram Program
  17479. //scanner := bufio.NewScanner(file)
  17480. //inProgram := false
  17481. //
  17482. //for scanner.Scan() {
  17483. // line := scanner.Text()
  17484. // if strings.Contains(line, "<program>") {
  17485. // inProgram = true
  17486. // programXML := "<program>"
  17487. // for scanner.Scan() {
  17488. // line = scanner.Text()
  17489. // programXML += line
  17490. // if strings.Contains(line, "</program>") {
  17491. // programXML += "</program>"
  17492. // break
  17493. // }
  17494. // }
  17495. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17496. // // 解析成功,更新最后的 Program
  17497. // }
  17498. // inProgram = false
  17499. // }
  17500. //}
  17501. //
  17502. // fmt.Println("Error reading file:", inProgram)
  17503. //
  17504. //if err := scanner.Err(); err != nil {
  17505. // fmt.Println("Error reading file:", err)
  17506. //}
  17507. // 输出最后一次的 Program
  17508. //fmt.Printf("最后一次的 <program>:\n")
  17509. //fmt.Printf("<program>\n")
  17510. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17511. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17512. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17513. //fmt.Printf("</program>\n")
  17514. fmt.Println(string(str1))
  17515. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17516. if ret2 != 0 {
  17517. return ""
  17518. }
  17519. return string(str1)
  17520. }
  17521. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17522. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17523. readCard := DllDef.MustFindProc("read_cardinfo")
  17524. if readCard == nil {
  17525. fmt.Println("readcard is nil")
  17526. readCard = DllDef.MustFindProc("read_cardinfo")
  17527. }
  17528. str := make([]byte, 1024) //卡号
  17529. str1 := make([]byte, 1024) //卡识别码
  17530. str2 := make([]byte, 1024) //身份证号
  17531. str3 := make([]byte, 1024) //姓名
  17532. str4 := make([]byte, 1024) //错误信息
  17533. 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])))
  17534. fmt.Println(string(str1))
  17535. fmt.Println(string(str))
  17536. fmt.Println(string(str2))
  17537. fmt.Println(string(str3))
  17538. fmt.Println(string(str4))
  17539. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17540. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17541. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17542. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17543. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17544. if ret2 != 0 {
  17545. return "", "", "", "", ""
  17546. }
  17547. return string(str), string(str1), string(str2), string(str3), string(str4)
  17548. }
  17549. type CustomFundPay struct {
  17550. FundPayType string `json:"fund_pay_type"`
  17551. FundPayamt float64 `json:"fund_payamt"`
  17552. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17553. }
  17554. //func (c *HisApiController) GetBatchSettleList() {
  17555. // start_time_str := c.GetString("start_time")
  17556. // //end_time_str := c.GetString("end_time")
  17557. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17558. //
  17559. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17560. //
  17561. // for _, item := range orders {
  17562. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17563. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17564. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17565. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17566. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17567. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17568. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17569. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17570. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17571. //
  17572. // if order.ID == 0 {
  17573. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17574. // return
  17575. // }
  17576. //
  17577. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17578. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17579. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17580. // //fmt.Println(count)
  17581. // //var zero string
  17582. // //number := count + 1
  17583. // //if number >= 1000 {
  17584. // // zero = "0000" + strconv.FormatInt(number, 10)
  17585. // //} else if number >= 10000 {
  17586. // // zero = "000" + strconv.FormatInt(number, 10)
  17587. // //} else if number >= 100000 {
  17588. // // zero = "00" + strconv.FormatInt(number, 10)
  17589. // //} else if number >= 1000000 {
  17590. // // zero = "0" + strconv.FormatInt(number, 10)
  17591. // //} else {
  17592. // // zero = strconv.FormatInt(number, 10)
  17593. // //}
  17594. // //fmt.Println(zero)
  17595. //
  17596. // struct4101 := service.Struct4101{
  17597. // PsnNo: order.PsnNo,
  17598. // MdtrtId: order.MdtrtId,
  17599. // SetlId: order.SetlId,
  17600. // PsnName: order.PsnName,
  17601. // Gend: order.Gend,
  17602. // Brdy: his.Brdy,
  17603. // Age: his.Age,
  17604. // Naty: order.Naty,
  17605. // PatnCertType: "01",
  17606. // Certno: order.Certno,
  17607. // Prfs: "90",
  17608. // ConerName: roles[0].UserName,
  17609. // PatnRlts: "99",
  17610. // ConerAddr: miConfig.OrgName,
  17611. // ConerTel: admin.Mobile,
  17612. // HiType: order.Insutype,
  17613. // Insuplc: miConfig.InsuplcAdmdvs,
  17614. // MaindiagFlag: "1",
  17615. // BillCode: order.SetlId,
  17616. // BillNo: order.SetlId,
  17617. // BizSn: order.Number,
  17618. // PsnSelfPay: order.PsnPartAmt,
  17619. // PsnOwnPay: order.PsnPartAmt,
  17620. // AcctPay: order.AcctPay,
  17621. // PsnCashpay: order.PsnCashPay,
  17622. // HiPaymtd: "1",
  17623. // Hsorg: miConfig.InsuplcAdmdvs,
  17624. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17625. // MedinsFillPsn: curRoles.UserName,
  17626. // MedinsFillDept: miConfig.OrgName,
  17627. // IptMedType: "2",
  17628. // }
  17629. // struct4101.SetlBegnDate = order.SetlTime
  17630. // struct4101.SetlEndDate = order.SetlTime
  17631. // time_arr := strings.Split(order.SetlTime, " ")
  17632. // struct4101.AdmTime = time_arr[0]
  17633. // struct4101.AdmEndTime = time_arr[0]
  17634. //
  17635. // var rf []CustomFundPay
  17636. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17637. //
  17638. // var tempFunPays []service.CustomStruct
  17639. // for _, item := range rf {
  17640. // var tempFunPay service.CustomStruct
  17641. // tempFunPay.FundPayamt = item.FundPayamt
  17642. // tempFunPay.FundPayType = item.FundPayType
  17643. // tempFunPays = append(tempFunPays, tempFunPay)
  17644. // }
  17645. // struct4101.CustomStruct = tempFunPays
  17646. //
  17647. // var tempDiaginfos []service.DiaginfoStructTwo
  17648. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17649. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17650. //
  17651. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17652. // var config []*models.HisXtDiagnoseConfig
  17653. // for _, item := range diagnosis_ids {
  17654. // id, _ := strconv.ParseInt(item, 10, 64)
  17655. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17656. // config = append(config, &diagnosisConfig)
  17657. // }
  17658. //
  17659. // for index, item := range config {
  17660. // if index == 0 {
  17661. // var tempDiaginfo service.DiaginfoStructTwo
  17662. // tempDiaginfo.DiagCode = item.CountryCode
  17663. // tempDiaginfo.DiagName = item.CountryContentName
  17664. // tempDiaginfo.DiagType = "1"
  17665. // tempDiaginfo.MaindiagFlag = "1"
  17666. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17667. // } else {
  17668. // var tempDiaginfo service.DiaginfoStructTwo
  17669. // tempDiaginfo.DiagCode = item.CountryCode
  17670. // tempDiaginfo.DiagName = item.CountryContentName
  17671. // tempDiaginfo.DiagType = "1"
  17672. // tempDiaginfo.MaindiagFlag = "0"
  17673. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17674. // }
  17675. // }
  17676. // struct4101.Diseinfo = tempDiaginfos
  17677. //
  17678. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17679. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17680. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17681. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17682. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17683. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17684. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17685. //
  17686. // var iteminfo service.IteminfoStruct
  17687. //
  17688. // var bedCostTotal float64 = 0 //床位总费
  17689. // var bedCostSelfTotal float64 = 0 //床位自费
  17690. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17691. //
  17692. // var operationCostTotal float64 = 0 //手术费
  17693. // var operationCostSelfTotal float64 = 0 //手术费
  17694. // var operationCostPartSelfTotal float64 = 0 //手术费
  17695. //
  17696. // var otherCostTotal float64 = 0 //其他费用
  17697. // var otherCostSelfTotal float64 = 0 //其他费用
  17698. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17699. //
  17700. // var materialCostTotal float64 = 0 //材料费
  17701. // var materialCostSelfTotal float64 = 0 //材料费
  17702. // var materialCostPartSelfTotal float64 = 0 //材料费
  17703. //
  17704. // var westernMedicineCostTotal float64 = 0 //西药费
  17705. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17706. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17707. //
  17708. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17709. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17710. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17711. //
  17712. // var checkCostTotal float64 = 0 //检查费
  17713. // var checkCostSelfTotal float64 = 0 //检查费
  17714. // var checkCostPartSelfTotal float64 = 0 //检查费
  17715. //
  17716. // var laboratoryCostTotal float64 = 0 //化验费
  17717. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17718. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17719. //
  17720. // var treatCostTotal float64 = 0 //治疗费用
  17721. // var treatCostSelfTotal float64 = 0 //治疗费用
  17722. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17723. //
  17724. // decimal.DivisionPrecision = 2
  17725. //
  17726. // var bed_fulamt_ownpay_amt float64 = 0
  17727. // var operation_fulamt_ownpay_amt float64 = 0
  17728. // var other_fulamt_ownpay_amt float64 = 0
  17729. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17730. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17731. // var check_fulamt_ownpay_amt float64 = 0
  17732. // var material_fulamt_ownpay_amt float64 = 0
  17733. // var laboratory_fulamt_ownpay_amt float64 = 0
  17734. // var treat_fulamt_ownpay_amt float64 = 0
  17735. //
  17736. // var bed_claa_sunmfee float64 = 0
  17737. // var bed_clab_amt float64 = 0
  17738. // var bed_other_amt float64 = 0
  17739. //
  17740. // var operation_claa_sunmfee float64 = 0
  17741. // var operation_clab_amt float64 = 0
  17742. // var operation_other_amt float64 = 0
  17743. //
  17744. // var other_claa_sunmfee float64 = 0
  17745. // var other_clab_amt float64 = 0
  17746. // var other_other_amt float64 = 0
  17747. //
  17748. // var westernMedicine_claa_sunmfee float64 = 0
  17749. // var westernMedicine_clab_amt float64 = 0
  17750. // var westernMedicine_other_amt float64 = 0
  17751. //
  17752. // var chineseTraditional_claa_sunmfee float64 = 0
  17753. // var chineseTraditional_clab_amt float64 = 0
  17754. // var chineseTraditional_other_amt float64 = 0
  17755. //
  17756. // var check_claa_sunmfee float64 = 0
  17757. // var check_clab_amt float64 = 0
  17758. // var check_other_amt float64 = 0
  17759. //
  17760. // var material_claa_sunmfee float64 = 0
  17761. // var material_clab_amt float64 = 0
  17762. // var material_other_amt float64 = 0
  17763. //
  17764. // var laboratory_claa_sunmfee float64 = 0
  17765. // var laboratory_clab_amt float64 = 0
  17766. // var laboratory_other_amt float64 = 0
  17767. //
  17768. // var treat_claa_sunmfee float64 = 0
  17769. // var treat_clab_amt float64 = 0
  17770. // var treat_other_amt float64 = 0
  17771. //
  17772. // for _, item := range order.HisOrderInfo {
  17773. // if item.MedChrgitmType == "01" { //床位费
  17774. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17775. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17776. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17777. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17778. // if item.ChrgitmLv == "1" {
  17779. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17780. // }
  17781. // if item.ChrgitmLv == "2" {
  17782. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17783. //
  17784. // }
  17785. // if item.ChrgitmLv == "3" {
  17786. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17787. // }
  17788. //
  17789. // }
  17790. //
  17791. // if item.MedChrgitmType == "03" { //检查费
  17792. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17793. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17794. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17795. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17796. // if item.ChrgitmLv == "1" {
  17797. //
  17798. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17799. //
  17800. // }
  17801. // if item.ChrgitmLv == "2" {
  17802. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17803. //
  17804. // }
  17805. // if item.ChrgitmLv == "3" {
  17806. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17807. // }
  17808. // }
  17809. //
  17810. // if item.MedChrgitmType == "04" { //化验费
  17811. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17812. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17813. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17814. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17815. // if item.ChrgitmLv == "1" {
  17816. //
  17817. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17818. //
  17819. // }
  17820. // if item.ChrgitmLv == "2" {
  17821. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17822. //
  17823. // }
  17824. // if item.ChrgitmLv == "3" {
  17825. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17826. // }
  17827. // }
  17828. //
  17829. // if item.MedChrgitmType == "05" { //治疗费
  17830. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17831. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17832. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17833. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17834. // if item.ChrgitmLv == "1" {
  17835. //
  17836. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17837. //
  17838. // }
  17839. // if item.ChrgitmLv == "2" {
  17840. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17841. //
  17842. // }
  17843. // if item.ChrgitmLv == "3" {
  17844. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17845. // }
  17846. // }
  17847. //
  17848. // if item.MedChrgitmType == "06" { //手术费
  17849. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17850. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17851. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17852. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17853. //
  17854. // if item.ChrgitmLv == "1" {
  17855. //
  17856. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17857. //
  17858. // }
  17859. // if item.ChrgitmLv == "2" {
  17860. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17861. //
  17862. // }
  17863. // if item.ChrgitmLv == "3" {
  17864. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17865. // }
  17866. // }
  17867. //
  17868. // if item.MedChrgitmType == "08" { //材料费
  17869. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17870. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17871. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17872. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17873. // if item.ChrgitmLv == "1" {
  17874. //
  17875. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17876. //
  17877. // }
  17878. // if item.ChrgitmLv == "2" {
  17879. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17880. //
  17881. // }
  17882. // if item.ChrgitmLv == "3" {
  17883. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17884. // }
  17885. // }
  17886. //
  17887. // if item.MedChrgitmType == "09" { //西药费
  17888. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17889. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17890. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17891. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17892. // if item.ChrgitmLv == "1" {
  17893. //
  17894. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17895. //
  17896. // }
  17897. // if item.ChrgitmLv == "2" {
  17898. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17899. //
  17900. // }
  17901. // if item.ChrgitmLv == "3" {
  17902. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17903. // }
  17904. // }
  17905. //
  17906. // if item.MedChrgitmType == "11" { //中成费
  17907. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17908. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17909. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17910. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17911. // if item.ChrgitmLv == "1" {
  17912. //
  17913. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17914. //
  17915. // }
  17916. // if item.ChrgitmLv == "2" {
  17917. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17918. //
  17919. // }
  17920. // if item.ChrgitmLv == "3" {
  17921. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17922. // }
  17923. // }
  17924. //
  17925. // if item.MedChrgitmType == "14" { //其他费
  17926. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17927. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17928. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17929. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17930. // if item.ChrgitmLv == "1" {
  17931. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17932. //
  17933. // }
  17934. // if item.ChrgitmLv == "2" {
  17935. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17936. //
  17937. // }
  17938. // if item.ChrgitmLv == "3" {
  17939. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17940. // }
  17941. // }
  17942. //
  17943. // }
  17944. //
  17945. // var iteminfoStructs []service.IteminfoStruct
  17946. //
  17947. // if bedCostTotal != 0 {
  17948. // iteminfo.MedChrgitm = "01"
  17949. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17950. // iteminfo.Amt = bedCostTotal
  17951. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  17952. // iteminfo.ClabAmt = bed_clab_amt
  17953. // iteminfo.OthAmt = bed_other_amt
  17954. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17955. // }
  17956. //
  17957. // if checkCostTotal != 0 {
  17958. // iteminfo.MedChrgitm = "03"
  17959. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17960. // iteminfo.Amt = checkCostTotal
  17961. // iteminfo.ClaaSumfee = check_claa_sunmfee
  17962. // iteminfo.ClabAmt = check_clab_amt
  17963. // iteminfo.OthAmt = check_other_amt
  17964. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17965. //
  17966. // }
  17967. //
  17968. // if laboratoryCostTotal != 0 {
  17969. // iteminfo.MedChrgitm = "04"
  17970. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17971. // iteminfo.Amt = laboratoryCostTotal
  17972. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17973. // iteminfo.ClabAmt = laboratory_clab_amt
  17974. // iteminfo.OthAmt = laboratory_other_amt
  17975. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17976. //
  17977. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17978. //
  17979. // }
  17980. //
  17981. // if treatCostTotal != 0 {
  17982. // iteminfo.MedChrgitm = "05"
  17983. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17984. // iteminfo.Amt = treatCostTotal
  17985. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  17986. // iteminfo.ClabAmt = treat_clab_amt
  17987. // iteminfo.OthAmt = treat_other_amt
  17988. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17989. // //(struct4101.IteminfoStruct, iteminfo)
  17990. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17991. // }
  17992. //
  17993. // if operationCostTotal != 0 {
  17994. // iteminfo.MedChrgitm = "06"
  17995. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17996. // iteminfo.Amt = operationCostTotal
  17997. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  17998. // iteminfo.ClabAmt = operation_clab_amt
  17999. // iteminfo.OthAmt = operation_other_amt
  18000. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18001. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18002. // }
  18003. //
  18004. // if materialCostTotal != 0 {
  18005. // iteminfo.MedChrgitm = "08"
  18006. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18007. // iteminfo.Amt = materialCostTotal
  18008. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18009. // iteminfo.ClabAmt = material_clab_amt
  18010. // iteminfo.OthAmt = material_other_amt
  18011. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18012. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18013. // }
  18014. //
  18015. // if westernMedicineCostTotal != 0 {
  18016. // iteminfo.MedChrgitm = "09"
  18017. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18018. // iteminfo.Amt = westernMedicineCostTotal
  18019. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18020. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18021. // iteminfo.OthAmt = westernMedicine_other_amt
  18022. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18023. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18024. //
  18025. // }
  18026. // if chineseTraditionalMedicineCostTotal != 0 {
  18027. // iteminfo.MedChrgitm = "11"
  18028. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18029. // iteminfo.Amt = westernMedicineCostTotal
  18030. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18031. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18032. // iteminfo.OthAmt = westernMedicine_other_amt
  18033. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18034. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18035. //
  18036. // }
  18037. // if otherCostTotal != 0 {
  18038. // iteminfo.MedChrgitm = "14"
  18039. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18040. // iteminfo.Amt = otherCostTotal
  18041. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18042. // iteminfo.ClabAmt = other_clab_amt
  18043. // iteminfo.OthAmt = other_other_amt
  18044. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18045. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18046. //
  18047. // }
  18048. // struct4101.IteminfoStruct = iteminfoStructs
  18049. // struct4101.Ntly = "中国"
  18050. // struct4101.AdmCaty = "A03.06"
  18051. //
  18052. // struct4101.DoctorName = doctor.UserName
  18053. // struct4101.DoctorCode = doctor.DoctorNumber
  18054. //
  18055. // var res ResultSeventeen
  18056. //
  18057. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18058. // struct4101.BillCode = order.Number
  18059. // struct4101.BillNo = order.SetlId
  18060. // var resOther ResultSeventeenOther
  18061. // var pp models.PublicParams
  18062. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18063. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18064. // pp.FixmedinsName = miConfig.OrgName
  18065. // pp.FixmedinsCode = miConfig.Code
  18066. // pp.RequestUrl = miConfig.Url
  18067. // pp.Cainfo = miConfig.Cainfo
  18068. // pp.SecretKey = miConfig.SecretKey
  18069. // pp.AccessKey = miConfig.AccessKey
  18070. // pp.OpterName = curRoles.UserName
  18071. //
  18072. // client := &http.Client{}
  18073. // var req *http.Request
  18074. // data := make(map[string]interface{})
  18075. // data["struct4101"] = struct4101
  18076. // data["pp"] = pp
  18077. // bytesData, _ := json.Marshal(data)
  18078. // if miConfig.MdtrtareaAdmvs == "320921" {
  18079. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18080. // } else {
  18081. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18082. // }
  18083. // resp, _ := client.Do(req)
  18084. // defer resp.Body.Close()
  18085. // body, ioErr := ioutil.ReadAll(resp.Body)
  18086. // if ioErr != nil {
  18087. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18088. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18089. // return
  18090. // }
  18091. // var respJSON map[string]interface{}
  18092. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18093. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18095. // return
  18096. // }
  18097. //
  18098. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18099. // userJSONBytes, _ := json.Marshal(respJSON)
  18100. // fmt.Println("log")
  18101. // fmt.Println(string(userJSONBytes))
  18102. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18103. // utils.ErrorLog("解析失败:%v", err)
  18104. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18105. // return
  18106. // }
  18107. // res.InfRefmsgid = resOther.InfRefmsgid
  18108. // res.Output = resOther.Output
  18109. // res.ErrMsg = resOther.ErrMsg
  18110. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18111. // res.Infcode = infocode
  18112. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18113. //
  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. // result, _ := service.Jxyb4101(struct4101, pp)
  18125. // var dat map[string]interface{}
  18126. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18127. // fmt.Println(dat)
  18128. // } else {
  18129. // fmt.Println(err)
  18130. // }
  18131. // userJSONBytes, _ := json.Marshal(dat)
  18132. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18133. // utils.ErrorLog("解析失败:%v", err)
  18134. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18135. // return
  18136. // }
  18137. //
  18138. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18139. // var pp models.PublicParams
  18140. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18141. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18142. // pp.FixmedinsName = miConfig.OrgName
  18143. // pp.FixmedinsCode = miConfig.Code
  18144. // pp.RequestUrl = miConfig.Url
  18145. // pp.Cainfo = miConfig.Cainfo
  18146. // pp.SecretKey = miConfig.SecretKey
  18147. // pp.AccessKey = miConfig.AccessKey
  18148. // pp.OpterName = curRoles.UserName
  18149. // result, _ := service.Hnyb4101(struct4101, pp)
  18150. // var dat map[string]interface{}
  18151. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18152. // fmt.Println(dat)
  18153. // } else {
  18154. // fmt.Println(err)
  18155. // }
  18156. // userJSONBytes, _ := json.Marshal(dat)
  18157. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18158. // utils.ErrorLog("解析失败:%v", err)
  18159. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18160. // return
  18161. // }
  18162. //
  18163. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18164. // var resOther ResultSeventeenOther
  18165. //
  18166. // var pp models.PublicParams
  18167. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18168. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18169. // pp.FixmedinsName = miConfig.OrgName
  18170. // pp.FixmedinsCode = miConfig.Code
  18171. // pp.RequestUrl = miConfig.Url
  18172. // pp.Cainfo = miConfig.Cainfo
  18173. // pp.SecretKey = miConfig.SecretKey
  18174. // pp.AccessKey = miConfig.AccessKey
  18175. // pp.OpterName = curRoles.UserName
  18176. // client := &http.Client{}
  18177. // var req *http.Request
  18178. // data := make(map[string]interface{})
  18179. // data["struct4101"] = struct4101
  18180. // data["pp"] = pp
  18181. // bytesData, _ := json.Marshal(data)
  18182. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18183. // resp, _ := client.Do(req)
  18184. // defer resp.Body.Close()
  18185. // body, ioErr := ioutil.ReadAll(resp.Body)
  18186. // if ioErr != nil {
  18187. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18188. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18189. // return
  18190. // }
  18191. // var respJSON map[string]interface{}
  18192. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18195. // return
  18196. // }
  18197. //
  18198. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18199. // userJSONBytes, _ := json.Marshal(respJSON)
  18200. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18201. // utils.ErrorLog("解析失败:%v", err)
  18202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18203. // return
  18204. // }
  18205. // res.InfRefmsgid = resOther.InfRefmsgid
  18206. // res.Output = resOther.Output
  18207. // res.ErrMsg = resOther.ErrMsg
  18208. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18209. // res.Infcode = infocode
  18210. //
  18211. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18212. // var pp models.PublicParams
  18213. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18214. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18215. // pp.FixmedinsName = miConfig.OrgName
  18216. // pp.FixmedinsCode = miConfig.Code
  18217. // pp.RequestUrl = miConfig.Url
  18218. // pp.Cainfo = miConfig.Cainfo
  18219. // pp.SecretKey = miConfig.SecretKey
  18220. // pp.AccessKey = miConfig.AccessKey
  18221. // pp.OpterName = curRoles.UserName
  18222. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18223. // fmt.Println(requestLog)
  18224. // fmt.Println(errMsgLog)
  18225. //
  18226. // saveLog(result, requestLog, "4101a", "上传清单")
  18227. //
  18228. // var dat map[string]interface{}
  18229. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18230. // fmt.Println(dat)
  18231. // } else {
  18232. // fmt.Println(err)
  18233. // }
  18234. // userJSONBytes, _ := json.Marshal(dat)
  18235. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18236. // utils.ErrorLog("解析失败:%v", err)
  18237. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18238. // return
  18239. // }
  18240. //
  18241. // } else {
  18242. //
  18243. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18244. // var dat map[string]interface{}
  18245. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18246. // fmt.Println(dat)
  18247. // } else {
  18248. // fmt.Println(err)
  18249. // }
  18250. // userJSONBytes, _ := json.Marshal(dat)
  18251. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18252. // utils.ErrorLog("解析失败:%v", err)
  18253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18254. // return
  18255. // }
  18256. // }
  18257. //
  18258. // if res.Infcode != 0 {
  18259. // adminUser := c.GetAdminUserInfo()
  18260. // errlog := &models.HisOrderError{
  18261. // UserOrgId: adminUser.CurrentOrgId,
  18262. // Ctime: time.Now().Unix(),
  18263. // Mtime: time.Now().Unix(),
  18264. // ErrMsg: res.ErrMsg,
  18265. // Status: 1,
  18266. // PatientId: order.ID,
  18267. // Stage: 10265,
  18268. // }
  18269. // service.CreateErrMsgLog(errlog)
  18270. // continue
  18271. // } else {
  18272. // //order.FaPiaoNumber = zero
  18273. // //order.FaPiaoCode = last_order.FaPiaoCode
  18274. // //service.UpdateOrder(order)
  18275. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18276. // Number: res.Output.SetlListId,
  18277. // Status: 1,
  18278. // Ctime: time.Now().Unix(),
  18279. // Mtime: time.Now().Unix(),
  18280. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18281. // IsUpload: 1,
  18282. // OrderId: order.ID,
  18283. // }
  18284. // service.CreateUploadRecord(hisFundSettleListResult)
  18285. // c.ServeSuccessJSON(map[string]interface{}{
  18286. // "msg": "上传成功",
  18287. // "result": hisFundSettleListResult,
  18288. // })
  18289. // continue
  18290. // }
  18291. // }
  18292. //}
  18293. func (c *HisApiController) GetbatchSettleList() {
  18294. //order_id, _ := c.GetInt64("order_id")
  18295. admin_user_id, _ := c.GetInt64("admin_user_id")
  18296. orders, _ := service.GetAllHisOrderTwo10485()
  18297. for _, item := range orders {
  18298. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18299. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18300. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18301. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18302. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18303. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18304. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18305. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18306. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18307. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18308. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18309. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18310. //fmt.Println(count)
  18311. //var zero string
  18312. //number := count + 1
  18313. //if number >= 1000 {
  18314. // zero = "0000" + strconv.FormatInt(number, 10)
  18315. //} else if number >= 10000 {
  18316. // zero = "000" + strconv.FormatInt(number, 10)
  18317. //} else if number >= 100000 {
  18318. // zero = "00" + strconv.FormatInt(number, 10)
  18319. //} else if number >= 1000000 {
  18320. // zero = "0" + strconv.FormatInt(number, 10)
  18321. //} else {
  18322. // zero = strconv.FormatInt(number, 10)
  18323. //}
  18324. //fmt.Println(zero)
  18325. struct4101 := service.Struct4101{
  18326. PsnNo: order.PsnNo,
  18327. MdtrtId: order.MdtrtId,
  18328. SetlId: order.SetlId,
  18329. PsnName: order.PsnName,
  18330. Gend: order.Gend,
  18331. Brdy: his.Brdy,
  18332. Age: his.Age,
  18333. Naty: order.Naty,
  18334. PatnCertType: "01",
  18335. Certno: order.Certno,
  18336. Prfs: "90",
  18337. ConerName: roles[0].UserName,
  18338. PatnRlts: "99",
  18339. ConerAddr: miConfig.OrgName,
  18340. ConerTel: admin.Mobile,
  18341. HiType: order.Insutype,
  18342. Insuplc: miConfig.InsuplcAdmdvs,
  18343. MaindiagFlag: "1",
  18344. BillCode: order.SetlId,
  18345. BillNo: order.SetlId,
  18346. BizSn: order.Number,
  18347. PsnSelfPay: order.PsnPartAmt,
  18348. PsnOwnPay: order.PsnPartAmt,
  18349. AcctPay: order.AcctPay,
  18350. PsnCashpay: order.PsnCashPay,
  18351. HiPaymtd: "1",
  18352. Hsorg: miConfig.InsuplcAdmdvs,
  18353. HsorgOpter: miConfig.InsuplcAdmdvs,
  18354. MedinsFillPsn: curRoles.UserName,
  18355. MedinsFillDept: miConfig.OrgName,
  18356. IptMedType: "2",
  18357. }
  18358. struct4101.SetlBegnDate = order.SetlTime
  18359. struct4101.SetlEndDate = order.SetlTime
  18360. time_arr := strings.Split(order.SetlTime, " ")
  18361. struct4101.AdmTime = time_arr[0]
  18362. struct4101.AdmEndTime = time_arr[0]
  18363. //var rf []CustomFundPay
  18364. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18365. //
  18366. //var tempFunPays []service.CustomStruct
  18367. //for _, item := range rf {
  18368. // var tempFunPay service.CustomStruct
  18369. // tempFunPay.FundPayamt = item.FundPayamt
  18370. // tempFunPay.FundPayType = item.FundPayType
  18371. // tempFunPays = append(tempFunPays, tempFunPay)
  18372. //}
  18373. //struct4101.CustomStruct = tempFunPays
  18374. var tempDiaginfos []service.DiaginfoStructTwo
  18375. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18376. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18377. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18378. var config []*models.HisXtDiagnoseConfig
  18379. for _, item := range diagnosis_ids {
  18380. id, _ := strconv.ParseInt(item, 10, 64)
  18381. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18382. config = append(config, &diagnosisConfig)
  18383. }
  18384. for index, item := range config {
  18385. if index == 0 {
  18386. var tempDiaginfo service.DiaginfoStructTwo
  18387. tempDiaginfo.DiagCode = item.CountryCode
  18388. tempDiaginfo.DiagName = item.CountryContentName
  18389. tempDiaginfo.DiagType = "1"
  18390. tempDiaginfo.MaindiagFlag = "1"
  18391. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18392. } else {
  18393. var tempDiaginfo service.DiaginfoStructTwo
  18394. tempDiaginfo.DiagCode = item.CountryCode
  18395. tempDiaginfo.DiagName = item.CountryContentName
  18396. tempDiaginfo.DiagType = "1"
  18397. tempDiaginfo.MaindiagFlag = "0"
  18398. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18399. }
  18400. }
  18401. struct4101.Diseinfo = tempDiaginfos
  18402. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18403. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18404. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18405. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18406. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18407. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18408. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18409. var iteminfo service.IteminfoStruct
  18410. var bedCostTotal float64 = 0 //床位总费
  18411. var bedCostSelfTotal float64 = 0 //床位自费
  18412. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18413. var operationCostTotal float64 = 0 //手术费
  18414. var operationCostSelfTotal float64 = 0 //手术费
  18415. var operationCostPartSelfTotal float64 = 0 //手术费
  18416. var otherCostTotal float64 = 0 //其他费用
  18417. var otherCostSelfTotal float64 = 0 //其他费用
  18418. var otherCostPartSelfTotal float64 = 0 //其他费用
  18419. var materialCostTotal float64 = 0 //材料费
  18420. var materialCostSelfTotal float64 = 0 //材料费
  18421. var materialCostPartSelfTotal float64 = 0 //材料费
  18422. var westernMedicineCostTotal float64 = 0 //西药费
  18423. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18424. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18425. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18426. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18427. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18428. var checkCostTotal float64 = 0 //检查费
  18429. var checkCostSelfTotal float64 = 0 //检查费
  18430. var checkCostPartSelfTotal float64 = 0 //检查费
  18431. var laboratoryCostTotal float64 = 0 //化验费
  18432. var laboratoryCostSelfTotal float64 = 0 //化验费
  18433. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18434. var treatCostTotal float64 = 0 //治疗费用
  18435. var treatCostSelfTotal float64 = 0 //治疗费用
  18436. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18437. decimal.DivisionPrecision = 2
  18438. var bed_fulamt_ownpay_amt float64 = 0
  18439. var operation_fulamt_ownpay_amt float64 = 0
  18440. var other_fulamt_ownpay_amt float64 = 0
  18441. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18442. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18443. var check_fulamt_ownpay_amt float64 = 0
  18444. var material_fulamt_ownpay_amt float64 = 0
  18445. var laboratory_fulamt_ownpay_amt float64 = 0
  18446. var treat_fulamt_ownpay_amt float64 = 0
  18447. var bed_claa_sunmfee float64 = 0
  18448. var bed_clab_amt float64 = 0
  18449. var bed_other_amt float64 = 0
  18450. var operation_claa_sunmfee float64 = 0
  18451. var operation_clab_amt float64 = 0
  18452. var operation_other_amt float64 = 0
  18453. var other_claa_sunmfee float64 = 0
  18454. var other_clab_amt float64 = 0
  18455. var other_other_amt float64 = 0
  18456. var westernMedicine_claa_sunmfee float64 = 0
  18457. var westernMedicine_clab_amt float64 = 0
  18458. var westernMedicine_other_amt float64 = 0
  18459. var chineseTraditional_claa_sunmfee float64 = 0
  18460. var chineseTraditional_clab_amt float64 = 0
  18461. var chineseTraditional_other_amt float64 = 0
  18462. var check_claa_sunmfee float64 = 0
  18463. var check_clab_amt float64 = 0
  18464. var check_other_amt float64 = 0
  18465. var material_claa_sunmfee float64 = 0
  18466. var material_clab_amt float64 = 0
  18467. var material_other_amt float64 = 0
  18468. var laboratory_claa_sunmfee float64 = 0
  18469. var laboratory_clab_amt float64 = 0
  18470. var laboratory_other_amt float64 = 0
  18471. var treat_claa_sunmfee float64 = 0
  18472. var treat_clab_amt float64 = 0
  18473. var treat_other_amt float64 = 0
  18474. for _, item := range order.HisOrderInfo {
  18475. if item.MedChrgitmType == "01" { //床位费
  18476. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18477. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18478. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18479. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18480. if item.ChrgitmLv == "1" {
  18481. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18482. }
  18483. if item.ChrgitmLv == "2" {
  18484. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18485. }
  18486. if item.ChrgitmLv == "3" {
  18487. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18488. }
  18489. }
  18490. if item.MedChrgitmType == "03" { //检查费
  18491. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18492. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18493. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18494. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18495. if item.ChrgitmLv == "1" {
  18496. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18497. }
  18498. if item.ChrgitmLv == "2" {
  18499. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18500. }
  18501. if item.ChrgitmLv == "3" {
  18502. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18503. }
  18504. }
  18505. if item.MedChrgitmType == "04" { //化验费
  18506. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18507. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18508. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18509. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18510. if item.ChrgitmLv == "1" {
  18511. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18512. }
  18513. if item.ChrgitmLv == "2" {
  18514. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18515. }
  18516. if item.ChrgitmLv == "3" {
  18517. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18518. }
  18519. }
  18520. if item.MedChrgitmType == "05" { //治疗费
  18521. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18522. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18523. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18524. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18525. if item.ChrgitmLv == "1" {
  18526. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18527. }
  18528. if item.ChrgitmLv == "2" {
  18529. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18530. }
  18531. if item.ChrgitmLv == "3" {
  18532. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18533. }
  18534. }
  18535. if item.MedChrgitmType == "06" { //手术费
  18536. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18537. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18538. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18539. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18540. if item.ChrgitmLv == "1" {
  18541. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18542. }
  18543. if item.ChrgitmLv == "2" {
  18544. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18545. }
  18546. if item.ChrgitmLv == "3" {
  18547. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18548. }
  18549. }
  18550. if item.MedChrgitmType == "08" { //材料费
  18551. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18552. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18553. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18554. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18555. if item.ChrgitmLv == "1" {
  18556. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18557. }
  18558. if item.ChrgitmLv == "2" {
  18559. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18560. }
  18561. if item.ChrgitmLv == "3" {
  18562. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18563. }
  18564. }
  18565. if item.MedChrgitmType == "09" { //西药费
  18566. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18567. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18568. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18569. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18570. if item.ChrgitmLv == "1" {
  18571. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18572. }
  18573. if item.ChrgitmLv == "2" {
  18574. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18575. }
  18576. if item.ChrgitmLv == "3" {
  18577. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18578. }
  18579. }
  18580. if item.MedChrgitmType == "11" { //中成费
  18581. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18582. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18583. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18584. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18585. if item.ChrgitmLv == "1" {
  18586. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18587. }
  18588. if item.ChrgitmLv == "2" {
  18589. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18590. }
  18591. if item.ChrgitmLv == "3" {
  18592. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18593. }
  18594. }
  18595. if item.MedChrgitmType == "14" { //其他费
  18596. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18597. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18598. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18599. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18600. if item.ChrgitmLv == "1" {
  18601. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18602. }
  18603. if item.ChrgitmLv == "2" {
  18604. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18605. }
  18606. if item.ChrgitmLv == "3" {
  18607. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18608. }
  18609. }
  18610. }
  18611. var iteminfoStructs []service.IteminfoStruct
  18612. if bedCostTotal != 0 {
  18613. iteminfo.MedChrgitm = "01"
  18614. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18615. iteminfo.Amt = bedCostTotal
  18616. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18617. iteminfo.ClabAmt = bed_clab_amt
  18618. iteminfo.OthAmt = bed_other_amt
  18619. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18620. }
  18621. if checkCostTotal != 0 {
  18622. iteminfo.MedChrgitm = "03"
  18623. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18624. iteminfo.Amt = checkCostTotal
  18625. iteminfo.ClaaSumfee = check_claa_sunmfee
  18626. iteminfo.ClabAmt = check_clab_amt
  18627. iteminfo.OthAmt = check_other_amt
  18628. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18629. }
  18630. if laboratoryCostTotal != 0 {
  18631. iteminfo.MedChrgitm = "04"
  18632. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18633. iteminfo.Amt = laboratoryCostTotal
  18634. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18635. iteminfo.ClabAmt = laboratory_clab_amt
  18636. iteminfo.OthAmt = laboratory_other_amt
  18637. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18638. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18639. }
  18640. if treatCostTotal != 0 {
  18641. iteminfo.MedChrgitm = "05"
  18642. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18643. iteminfo.Amt = treatCostTotal
  18644. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18645. iteminfo.ClabAmt = treat_clab_amt
  18646. iteminfo.OthAmt = treat_other_amt
  18647. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18648. //(struct4101.IteminfoStruct, iteminfo)
  18649. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18650. }
  18651. if operationCostTotal != 0 {
  18652. iteminfo.MedChrgitm = "06"
  18653. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18654. iteminfo.Amt = operationCostTotal
  18655. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18656. iteminfo.ClabAmt = operation_clab_amt
  18657. iteminfo.OthAmt = operation_other_amt
  18658. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18659. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18660. }
  18661. if materialCostTotal != 0 {
  18662. iteminfo.MedChrgitm = "08"
  18663. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18664. iteminfo.Amt = materialCostTotal
  18665. iteminfo.ClaaSumfee = material_claa_sunmfee
  18666. iteminfo.ClabAmt = material_clab_amt
  18667. iteminfo.OthAmt = material_other_amt
  18668. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18669. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18670. }
  18671. if westernMedicineCostTotal != 0 {
  18672. iteminfo.MedChrgitm = "09"
  18673. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18674. iteminfo.Amt = westernMedicineCostTotal
  18675. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18676. iteminfo.ClabAmt = westernMedicine_clab_amt
  18677. iteminfo.OthAmt = westernMedicine_other_amt
  18678. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18679. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18680. }
  18681. if chineseTraditionalMedicineCostTotal != 0 {
  18682. iteminfo.MedChrgitm = "11"
  18683. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18684. iteminfo.Amt = westernMedicineCostTotal
  18685. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18686. iteminfo.ClabAmt = westernMedicine_clab_amt
  18687. iteminfo.OthAmt = westernMedicine_other_amt
  18688. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18689. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18690. }
  18691. if otherCostTotal != 0 {
  18692. iteminfo.MedChrgitm = "14"
  18693. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18694. iteminfo.Amt = otherCostTotal
  18695. iteminfo.ClaaSumfee = other_claa_sunmfee
  18696. iteminfo.ClabAmt = other_clab_amt
  18697. iteminfo.OthAmt = other_other_amt
  18698. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18699. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18700. }
  18701. struct4101.IteminfoStruct = iteminfoStructs
  18702. struct4101.Ntly = "中国"
  18703. struct4101.AdmCaty = "A03.06"
  18704. struct4101.DoctorName = doctor.UserName
  18705. struct4101.DoctorCode = doctor.DoctorNumber
  18706. var res ResultSeventeen
  18707. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18708. struct4101.BillCode = order.Number
  18709. struct4101.BillNo = order.SetlId
  18710. var resOther ResultSeventeenOther
  18711. var pp models.PublicParams
  18712. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18713. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18714. pp.FixmedinsName = miConfig.OrgName
  18715. pp.FixmedinsCode = miConfig.Code
  18716. pp.RequestUrl = miConfig.Url
  18717. pp.Cainfo = miConfig.Cainfo
  18718. pp.SecretKey = miConfig.SecretKey
  18719. pp.AccessKey = miConfig.AccessKey
  18720. pp.OpterName = curRoles.UserName
  18721. client := &http.Client{}
  18722. var req *http.Request
  18723. data := make(map[string]interface{})
  18724. data["struct4101"] = struct4101
  18725. data["pp"] = pp
  18726. bytesData, _ := json.Marshal(data)
  18727. if miConfig.MdtrtareaAdmvs == "320921" {
  18728. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18729. } else {
  18730. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18731. }
  18732. resp, _ := client.Do(req)
  18733. defer resp.Body.Close()
  18734. body, ioErr := ioutil.ReadAll(resp.Body)
  18735. if ioErr != nil {
  18736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18738. return
  18739. }
  18740. var respJSON map[string]interface{}
  18741. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18744. return
  18745. }
  18746. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18747. userJSONBytes, _ := json.Marshal(respJSON)
  18748. fmt.Println("log")
  18749. fmt.Println(string(userJSONBytes))
  18750. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18751. utils.ErrorLog("解析失败:%v", err)
  18752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18753. return
  18754. }
  18755. res.InfRefmsgid = resOther.InfRefmsgid
  18756. res.Output = resOther.Output
  18757. res.ErrMsg = resOther.ErrMsg
  18758. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18759. res.Infcode = infocode
  18760. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18761. var pp models.PublicParams
  18762. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18763. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18764. pp.FixmedinsName = miConfig.OrgName
  18765. pp.FixmedinsCode = miConfig.Code
  18766. pp.RequestUrl = miConfig.Url
  18767. pp.Cainfo = miConfig.Cainfo
  18768. pp.SecretKey = miConfig.SecretKey
  18769. pp.AccessKey = miConfig.AccessKey
  18770. pp.OpterName = curRoles.UserName
  18771. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18772. result, _ := service.Jxyb4101(struct4101, pp)
  18773. var dat map[string]interface{}
  18774. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18775. fmt.Println(dat)
  18776. } else {
  18777. fmt.Println(err)
  18778. }
  18779. userJSONBytes, _ := json.Marshal(dat)
  18780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18781. utils.ErrorLog("解析失败:%v", err)
  18782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18783. return
  18784. }
  18785. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18786. var pp models.PublicParams
  18787. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18788. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18789. pp.FixmedinsName = miConfig.OrgName
  18790. pp.FixmedinsCode = miConfig.Code
  18791. pp.RequestUrl = miConfig.Url
  18792. pp.Cainfo = miConfig.Cainfo
  18793. pp.SecretKey = miConfig.SecretKey
  18794. pp.AccessKey = miConfig.AccessKey
  18795. pp.OpterName = curRoles.UserName
  18796. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18797. result, _ := service.Jxyb4101(struct4101, pp)
  18798. var dat map[string]interface{}
  18799. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18800. fmt.Println(dat)
  18801. } else {
  18802. fmt.Println(err)
  18803. }
  18804. userJSONBytes, _ := json.Marshal(dat)
  18805. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18806. utils.ErrorLog("解析失败:%v", err)
  18807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18808. return
  18809. }
  18810. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18811. var pp models.PublicParams
  18812. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18813. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18814. pp.FixmedinsName = miConfig.OrgName
  18815. pp.FixmedinsCode = miConfig.Code
  18816. pp.RequestUrl = miConfig.Url
  18817. pp.Cainfo = miConfig.Cainfo
  18818. pp.SecretKey = miConfig.SecretKey
  18819. pp.AccessKey = miConfig.AccessKey
  18820. pp.OpterName = curRoles.UserName
  18821. result, _ := service.Hnyb4101(struct4101, pp)
  18822. var dat map[string]interface{}
  18823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18824. fmt.Println(dat)
  18825. } else {
  18826. fmt.Println(err)
  18827. }
  18828. userJSONBytes, _ := json.Marshal(dat)
  18829. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18830. utils.ErrorLog("解析失败:%v", err)
  18831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18832. return
  18833. }
  18834. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18835. var resOther ResultSeventeenOther
  18836. var pp models.PublicParams
  18837. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18838. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18839. pp.FixmedinsName = miConfig.OrgName
  18840. pp.FixmedinsCode = miConfig.Code
  18841. pp.RequestUrl = miConfig.Url
  18842. pp.Cainfo = miConfig.Cainfo
  18843. pp.SecretKey = miConfig.SecretKey
  18844. pp.AccessKey = miConfig.AccessKey
  18845. pp.OpterName = curRoles.UserName
  18846. client := &http.Client{}
  18847. var req *http.Request
  18848. data := make(map[string]interface{})
  18849. data["struct4101"] = struct4101
  18850. data["pp"] = pp
  18851. bytesData, _ := json.Marshal(data)
  18852. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18853. resp, _ := client.Do(req)
  18854. defer resp.Body.Close()
  18855. body, ioErr := ioutil.ReadAll(resp.Body)
  18856. if ioErr != nil {
  18857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18859. return
  18860. }
  18861. var respJSON map[string]interface{}
  18862. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18865. return
  18866. }
  18867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18868. userJSONBytes, _ := json.Marshal(respJSON)
  18869. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18870. utils.ErrorLog("解析失败:%v", err)
  18871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18872. return
  18873. }
  18874. res.InfRefmsgid = resOther.InfRefmsgid
  18875. res.Output = resOther.Output
  18876. res.ErrMsg = resOther.ErrMsg
  18877. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18878. res.Infcode = infocode
  18879. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18880. var pp models.PublicParams
  18881. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18882. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18883. pp.FixmedinsName = miConfig.OrgName
  18884. pp.FixmedinsCode = miConfig.Code
  18885. pp.RequestUrl = miConfig.Url
  18886. pp.Cainfo = miConfig.Cainfo
  18887. pp.SecretKey = miConfig.SecretKey
  18888. pp.AccessKey = miConfig.AccessKey
  18889. pp.OpterName = curRoles.UserName
  18890. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18891. fmt.Println(requestLog)
  18892. fmt.Println(errMsgLog)
  18893. saveLog(result, requestLog, "4101a", "上传清单")
  18894. var dat map[string]interface{}
  18895. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18896. fmt.Println(dat)
  18897. } else {
  18898. fmt.Println(err)
  18899. }
  18900. userJSONBytes, _ := json.Marshal(dat)
  18901. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18902. utils.ErrorLog("解析失败:%v", err)
  18903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18904. return
  18905. }
  18906. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18907. var pp models.PublicParams
  18908. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18909. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18910. pp.FixmedinsName = miConfig.OrgName
  18911. pp.FixmedinsCode = miConfig.Code
  18912. pp.RequestUrl = miConfig.Url
  18913. pp.Cainfo = miConfig.Cainfo
  18914. pp.SecretKey = miConfig.SecretKey
  18915. pp.AccessKey = miConfig.AccessKey
  18916. pp.OpterName = curRoles.UserName
  18917. client := &http.Client{}
  18918. var req *http.Request
  18919. data := make(map[string]interface{})
  18920. data["struct4101"] = struct4101
  18921. data["pp"] = pp
  18922. bytesData, _ := json.Marshal(data)
  18923. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18924. resp, _ := client.Do(req)
  18925. defer resp.Body.Close()
  18926. body, ioErr := ioutil.ReadAll(resp.Body)
  18927. if ioErr != nil {
  18928. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18930. return
  18931. }
  18932. var respJSON map[string]interface{}
  18933. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18936. return
  18937. }
  18938. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18939. userJSONBytes, _ := json.Marshal(respJSON)
  18940. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18941. utils.ErrorLog("解析失败:%v", err)
  18942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18943. return
  18944. }
  18945. } else {
  18946. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  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. }
  18960. if res.Infcode != 0 {
  18961. errlog := &models.HisOrderError{
  18962. UserOrgId: order.UserOrgId,
  18963. Ctime: time.Now().Unix(),
  18964. Mtime: time.Now().Unix(),
  18965. ErrMsg: res.ErrMsg + "解析失败",
  18966. Status: 1,
  18967. PatientId: order.ID,
  18968. Stage: 10485,
  18969. }
  18970. service.CreateErrMsgLog(errlog)
  18971. continue
  18972. //c.ServeSuccessJSON(map[string]interface{}{
  18973. // "failed_code": -10,
  18974. // "msg": res.ErrMsg,
  18975. //})
  18976. } else {
  18977. //order.FaPiaoNumber = zero
  18978. //order.FaPiaoCode = last_order.FaPiaoCode
  18979. //service.UpdateOrder(order)
  18980. hisFundSettleListResult := &models.HisFundSettleListResult{
  18981. Number: res.Output.SetlListId,
  18982. Status: 1,
  18983. Ctime: time.Now().Unix(),
  18984. Mtime: time.Now().Unix(),
  18985. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18986. IsUpload: 1,
  18987. OrderId: order.ID,
  18988. }
  18989. service.CreateUploadRecord(hisFundSettleListResult)
  18990. continue
  18991. }
  18992. }
  18993. }
  18994. func (c *HisApiController) GetSettleList() {
  18995. order_id, _ := c.GetInt64("order_id")
  18996. admin_user_id, _ := c.GetInt64("admin_user_id")
  18997. order, _ := service.GetHisOrderByIDTwo(order_id)
  18998. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18999. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19000. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19001. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19002. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19003. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19004. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19005. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19006. if order.ID == 0 {
  19007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19008. return
  19009. }
  19010. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19011. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19012. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19013. //fmt.Println(count)
  19014. //var zero string
  19015. //number := count + 1
  19016. //if number >= 1000 {
  19017. // zero = "0000" + strconv.FormatInt(number, 10)
  19018. //} else if number >= 10000 {
  19019. // zero = "000" + strconv.FormatInt(number, 10)
  19020. //} else if number >= 100000 {
  19021. // zero = "00" + strconv.FormatInt(number, 10)
  19022. //} else if number >= 1000000 {
  19023. // zero = "0" + strconv.FormatInt(number, 10)
  19024. //} else {
  19025. // zero = strconv.FormatInt(number, 10)
  19026. //}
  19027. //fmt.Println(zero)
  19028. struct4101 := service.Struct4101{
  19029. PsnNo: order.PsnNo,
  19030. MdtrtId: order.MdtrtId,
  19031. SetlId: order.SetlId,
  19032. PsnName: order.PsnName,
  19033. Gend: order.Gend,
  19034. Brdy: his.Brdy,
  19035. Age: his.Age,
  19036. Naty: order.Naty,
  19037. PatnCertType: "01",
  19038. Certno: order.Certno,
  19039. Prfs: "90",
  19040. ConerName: roles[0].UserName,
  19041. PatnRlts: "99",
  19042. ConerAddr: miConfig.OrgName,
  19043. ConerTel: admin.Mobile,
  19044. HiType: order.Insutype,
  19045. Insuplc: miConfig.InsuplcAdmdvs,
  19046. MaindiagFlag: "1",
  19047. BillCode: order.SetlId,
  19048. BillNo: order.SetlId,
  19049. BizSn: order.Number,
  19050. PsnSelfPay: order.PsnPartAmt,
  19051. PsnOwnPay: order.PsnPartAmt,
  19052. AcctPay: order.AcctPay,
  19053. PsnCashpay: order.PsnCashPay,
  19054. HiPaymtd: "1",
  19055. Hsorg: miConfig.InsuplcAdmdvs,
  19056. HsorgOpter: miConfig.InsuplcAdmdvs,
  19057. MedinsFillPsn: curRoles.UserName,
  19058. MedinsFillDept: miConfig.OrgName,
  19059. IptMedType: "2",
  19060. }
  19061. struct4101.SetlBegnDate = order.SetlTime
  19062. struct4101.SetlEndDate = order.SetlTime
  19063. time_arr := strings.Split(order.SetlTime, " ")
  19064. struct4101.AdmTime = time_arr[0]
  19065. struct4101.AdmEndTime = time_arr[0]
  19066. //
  19067. //var rf []CustomFundPay
  19068. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19069. //
  19070. //var tempFunPays []service.CustomStruct
  19071. //for _, item := range rf {
  19072. // var tempFunPay service.CustomStruct
  19073. // tempFunPay.FundPayamt = item.FundPayamt
  19074. // tempFunPay.FundPayType = item.FundPayType
  19075. // tempFunPays = append(tempFunPays, tempFunPay)
  19076. //}
  19077. //struct4101.CustomStruct = tempFunPays
  19078. var tempDiaginfos []service.DiaginfoStructTwo
  19079. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19080. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19081. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19082. var config []*models.HisXtDiagnoseConfig
  19083. for _, item := range diagnosis_ids {
  19084. id, _ := strconv.ParseInt(item, 10, 64)
  19085. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19086. config = append(config, &diagnosisConfig)
  19087. }
  19088. if miConfig.Code == "H15049901371" {
  19089. //for _, item := range config {
  19090. // if item.ID == 138 {
  19091. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19092. var tempDiaginfo service.DiaginfoStructTwo
  19093. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19094. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19095. tempDiaginfo.DiagType = "1"
  19096. tempDiaginfo.MaindiagFlag = "1"
  19097. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19098. //}
  19099. //}
  19100. for _, item := range config {
  19101. if item.ID != 138 {
  19102. var tempDiaginfo service.DiaginfoStructTwo
  19103. tempDiaginfo.DiagCode = item.CountryCode
  19104. tempDiaginfo.DiagName = item.CountryContentName
  19105. tempDiaginfo.DiagType = "1"
  19106. tempDiaginfo.MaindiagFlag = "0"
  19107. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19108. }
  19109. }
  19110. } else {
  19111. for index, item := range config {
  19112. if index == 0 {
  19113. var tempDiaginfo service.DiaginfoStructTwo
  19114. tempDiaginfo.DiagCode = item.CountryCode
  19115. tempDiaginfo.DiagName = item.CountryContentName
  19116. tempDiaginfo.DiagType = "1"
  19117. tempDiaginfo.MaindiagFlag = "1"
  19118. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19119. } else {
  19120. var tempDiaginfo service.DiaginfoStructTwo
  19121. tempDiaginfo.DiagCode = item.CountryCode
  19122. tempDiaginfo.DiagName = item.CountryContentName
  19123. tempDiaginfo.DiagType = "1"
  19124. tempDiaginfo.MaindiagFlag = "0"
  19125. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19126. }
  19127. }
  19128. }
  19129. struct4101.Diseinfo = tempDiaginfos
  19130. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19131. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19132. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19133. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19134. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19135. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19136. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19137. var iteminfo service.IteminfoStruct
  19138. var bedCostTotal float64 = 0 //床位总费
  19139. var bedCostSelfTotal float64 = 0 //床位自费
  19140. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19141. var operationCostTotal float64 = 0 //手术费
  19142. var operationCostSelfTotal float64 = 0 //手术费
  19143. var operationCostPartSelfTotal float64 = 0 //手术费
  19144. var otherCostTotal float64 = 0 //其他费用
  19145. var otherCostSelfTotal float64 = 0 //其他费用
  19146. var otherCostPartSelfTotal float64 = 0 //其他费用
  19147. var materialCostTotal float64 = 0 //材料费
  19148. var materialCostSelfTotal float64 = 0 //材料费
  19149. var materialCostPartSelfTotal float64 = 0 //材料费
  19150. var westernMedicineCostTotal float64 = 0 //西药费
  19151. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19152. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19153. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19154. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19155. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19156. var checkCostTotal float64 = 0 //检查费
  19157. var checkCostSelfTotal float64 = 0 //检查费
  19158. var checkCostPartSelfTotal float64 = 0 //检查费
  19159. var laboratoryCostTotal float64 = 0 //化验费
  19160. var laboratoryCostSelfTotal float64 = 0 //化验费
  19161. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19162. var treatCostTotal float64 = 0 //治疗费用
  19163. var treatCostSelfTotal float64 = 0 //治疗费用
  19164. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19165. decimal.DivisionPrecision = 2
  19166. var bed_fulamt_ownpay_amt float64 = 0
  19167. var operation_fulamt_ownpay_amt float64 = 0
  19168. var other_fulamt_ownpay_amt float64 = 0
  19169. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19170. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19171. var check_fulamt_ownpay_amt float64 = 0
  19172. var material_fulamt_ownpay_amt float64 = 0
  19173. var laboratory_fulamt_ownpay_amt float64 = 0
  19174. var treat_fulamt_ownpay_amt float64 = 0
  19175. var bed_claa_sunmfee float64 = 0
  19176. var bed_clab_amt float64 = 0
  19177. var bed_other_amt float64 = 0
  19178. var operation_claa_sunmfee float64 = 0
  19179. var operation_clab_amt float64 = 0
  19180. var operation_other_amt float64 = 0
  19181. var other_claa_sunmfee float64 = 0
  19182. var other_clab_amt float64 = 0
  19183. var other_other_amt float64 = 0
  19184. var westernMedicine_claa_sunmfee float64 = 0
  19185. var westernMedicine_clab_amt float64 = 0
  19186. var westernMedicine_other_amt float64 = 0
  19187. var chineseTraditional_claa_sunmfee float64 = 0
  19188. var chineseTraditional_clab_amt float64 = 0
  19189. var chineseTraditional_other_amt float64 = 0
  19190. var check_claa_sunmfee float64 = 0
  19191. var check_clab_amt float64 = 0
  19192. var check_other_amt float64 = 0
  19193. var material_claa_sunmfee float64 = 0
  19194. var material_clab_amt float64 = 0
  19195. var material_other_amt float64 = 0
  19196. var laboratory_claa_sunmfee float64 = 0
  19197. var laboratory_clab_amt float64 = 0
  19198. var laboratory_other_amt float64 = 0
  19199. var treat_claa_sunmfee float64 = 0
  19200. var treat_clab_amt float64 = 0
  19201. var treat_other_amt float64 = 0
  19202. for _, item := range order.HisOrderInfo {
  19203. if item.MedChrgitmType == "01" { //床位费
  19204. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19205. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19206. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19207. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19208. if item.ChrgitmLv == "1" {
  19209. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19210. }
  19211. if item.ChrgitmLv == "2" {
  19212. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19213. }
  19214. if item.ChrgitmLv == "3" {
  19215. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19216. }
  19217. }
  19218. if item.MedChrgitmType == "03" { //检查费
  19219. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19220. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19221. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19222. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19223. if item.ChrgitmLv == "1" {
  19224. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19225. }
  19226. if item.ChrgitmLv == "2" {
  19227. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19228. }
  19229. if item.ChrgitmLv == "3" {
  19230. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19231. }
  19232. }
  19233. if item.MedChrgitmType == "04" { //化验费
  19234. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19235. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19236. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19237. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19238. if item.ChrgitmLv == "1" {
  19239. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19240. }
  19241. if item.ChrgitmLv == "2" {
  19242. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19243. }
  19244. if item.ChrgitmLv == "3" {
  19245. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19246. }
  19247. }
  19248. if item.MedChrgitmType == "05" { //治疗费
  19249. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19250. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19251. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19252. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19253. if item.ChrgitmLv == "1" {
  19254. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19255. }
  19256. if item.ChrgitmLv == "2" {
  19257. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19258. }
  19259. if item.ChrgitmLv == "3" {
  19260. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19261. }
  19262. }
  19263. if item.MedChrgitmType == "06" { //手术费
  19264. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19265. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19266. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19267. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19268. if item.ChrgitmLv == "1" {
  19269. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19270. }
  19271. if item.ChrgitmLv == "2" {
  19272. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19273. }
  19274. if item.ChrgitmLv == "3" {
  19275. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19276. }
  19277. }
  19278. if item.MedChrgitmType == "08" { //材料费
  19279. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19280. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19281. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19282. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19283. if item.ChrgitmLv == "1" {
  19284. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19285. }
  19286. if item.ChrgitmLv == "2" {
  19287. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19288. }
  19289. if item.ChrgitmLv == "3" {
  19290. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19291. }
  19292. }
  19293. if item.MedChrgitmType == "09" { //西药费
  19294. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19295. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19296. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19297. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19298. if item.ChrgitmLv == "1" {
  19299. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19300. }
  19301. if item.ChrgitmLv == "2" {
  19302. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19303. }
  19304. if item.ChrgitmLv == "3" {
  19305. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19306. }
  19307. }
  19308. if item.MedChrgitmType == "11" { //中成费
  19309. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19310. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19311. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19312. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19313. if item.ChrgitmLv == "1" {
  19314. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19315. }
  19316. if item.ChrgitmLv == "2" {
  19317. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19318. }
  19319. if item.ChrgitmLv == "3" {
  19320. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19321. }
  19322. }
  19323. if item.MedChrgitmType == "14" { //其他费
  19324. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19325. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19326. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19327. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19328. if item.ChrgitmLv == "1" {
  19329. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19330. }
  19331. if item.ChrgitmLv == "2" {
  19332. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19333. }
  19334. if item.ChrgitmLv == "3" {
  19335. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19336. }
  19337. }
  19338. }
  19339. var iteminfoStructs []service.IteminfoStruct
  19340. if bedCostTotal != 0 {
  19341. iteminfo.MedChrgitm = "01"
  19342. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19343. iteminfo.Amt = bedCostTotal
  19344. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19345. iteminfo.ClabAmt = bed_clab_amt
  19346. iteminfo.OthAmt = bed_other_amt
  19347. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19348. }
  19349. if checkCostTotal != 0 {
  19350. iteminfo.MedChrgitm = "03"
  19351. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19352. iteminfo.Amt = checkCostTotal
  19353. iteminfo.ClaaSumfee = check_claa_sunmfee
  19354. iteminfo.ClabAmt = check_clab_amt
  19355. iteminfo.OthAmt = check_other_amt
  19356. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19357. }
  19358. if laboratoryCostTotal != 0 {
  19359. iteminfo.MedChrgitm = "04"
  19360. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19361. iteminfo.Amt = laboratoryCostTotal
  19362. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19363. iteminfo.ClabAmt = laboratory_clab_amt
  19364. iteminfo.OthAmt = laboratory_other_amt
  19365. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19366. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19367. }
  19368. if treatCostTotal != 0 {
  19369. iteminfo.MedChrgitm = "05"
  19370. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19371. iteminfo.Amt = treatCostTotal
  19372. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19373. iteminfo.ClabAmt = treat_clab_amt
  19374. iteminfo.OthAmt = treat_other_amt
  19375. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19376. //(struct4101.IteminfoStruct, iteminfo)
  19377. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19378. }
  19379. if operationCostTotal != 0 {
  19380. iteminfo.MedChrgitm = "06"
  19381. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19382. iteminfo.Amt = operationCostTotal
  19383. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19384. iteminfo.ClabAmt = operation_clab_amt
  19385. iteminfo.OthAmt = operation_other_amt
  19386. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19387. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19388. }
  19389. if materialCostTotal != 0 {
  19390. iteminfo.MedChrgitm = "08"
  19391. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19392. iteminfo.Amt = materialCostTotal
  19393. iteminfo.ClaaSumfee = material_claa_sunmfee
  19394. iteminfo.ClabAmt = material_clab_amt
  19395. iteminfo.OthAmt = material_other_amt
  19396. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19397. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19398. }
  19399. if westernMedicineCostTotal != 0 {
  19400. iteminfo.MedChrgitm = "09"
  19401. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19402. iteminfo.Amt = westernMedicineCostTotal
  19403. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19404. iteminfo.ClabAmt = westernMedicine_clab_amt
  19405. iteminfo.OthAmt = westernMedicine_other_amt
  19406. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19407. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19408. }
  19409. if chineseTraditionalMedicineCostTotal != 0 {
  19410. iteminfo.MedChrgitm = "11"
  19411. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19412. iteminfo.Amt = westernMedicineCostTotal
  19413. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19414. iteminfo.ClabAmt = westernMedicine_clab_amt
  19415. iteminfo.OthAmt = westernMedicine_other_amt
  19416. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19417. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19418. }
  19419. if otherCostTotal != 0 {
  19420. iteminfo.MedChrgitm = "14"
  19421. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19422. iteminfo.Amt = otherCostTotal
  19423. iteminfo.ClaaSumfee = other_claa_sunmfee
  19424. iteminfo.ClabAmt = other_clab_amt
  19425. iteminfo.OthAmt = other_other_amt
  19426. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19427. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19428. }
  19429. struct4101.IteminfoStruct = iteminfoStructs
  19430. struct4101.Ntly = "中国"
  19431. struct4101.AdmCaty = "A03.06"
  19432. struct4101.DoctorName = doctor.UserName
  19433. struct4101.DoctorCode = doctor.DoctorNumber
  19434. var res ResultSeventeen
  19435. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19436. struct4101.BillCode = order.Number
  19437. struct4101.BillNo = order.SetlId
  19438. var resOther ResultSeventeenOther
  19439. var pp models.PublicParams
  19440. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19441. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19442. pp.FixmedinsName = miConfig.OrgName
  19443. pp.FixmedinsCode = miConfig.Code
  19444. pp.RequestUrl = miConfig.Url
  19445. pp.Cainfo = miConfig.Cainfo
  19446. pp.SecretKey = miConfig.SecretKey
  19447. pp.AccessKey = miConfig.AccessKey
  19448. pp.OpterName = curRoles.UserName
  19449. client := &http.Client{}
  19450. var req *http.Request
  19451. data := make(map[string]interface{})
  19452. data["struct4101"] = struct4101
  19453. data["pp"] = pp
  19454. bytesData, _ := json.Marshal(data)
  19455. if miConfig.MdtrtareaAdmvs == "320921" {
  19456. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19457. } else {
  19458. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19459. }
  19460. resp, _ := client.Do(req)
  19461. defer resp.Body.Close()
  19462. body, ioErr := ioutil.ReadAll(resp.Body)
  19463. if ioErr != nil {
  19464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19466. return
  19467. }
  19468. var respJSON map[string]interface{}
  19469. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19472. return
  19473. }
  19474. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19475. userJSONBytes, _ := json.Marshal(respJSON)
  19476. fmt.Println("log")
  19477. fmt.Println(string(userJSONBytes))
  19478. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19479. utils.ErrorLog("解析失败:%v", err)
  19480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19481. return
  19482. }
  19483. res.InfRefmsgid = resOther.InfRefmsgid
  19484. res.Output = resOther.Output
  19485. res.ErrMsg = resOther.ErrMsg
  19486. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19487. res.Infcode = infocode
  19488. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19489. var pp models.PublicParams
  19490. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19491. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19492. pp.FixmedinsName = miConfig.OrgName
  19493. pp.FixmedinsCode = miConfig.Code
  19494. pp.RequestUrl = miConfig.Url
  19495. pp.Cainfo = miConfig.Cainfo
  19496. pp.SecretKey = miConfig.SecretKey
  19497. pp.AccessKey = miConfig.AccessKey
  19498. pp.OpterName = curRoles.UserName
  19499. result, _ := service.Jxyb4101(struct4101, pp)
  19500. var dat map[string]interface{}
  19501. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19502. fmt.Println(dat)
  19503. } else {
  19504. fmt.Println(err)
  19505. }
  19506. userJSONBytes, _ := json.Marshal(dat)
  19507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19508. utils.ErrorLog("解析失败:%v", err)
  19509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19510. return
  19511. }
  19512. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19513. var pp models.PublicParams
  19514. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19515. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19516. pp.FixmedinsName = miConfig.OrgName
  19517. pp.FixmedinsCode = miConfig.Code
  19518. pp.RequestUrl = miConfig.Url
  19519. pp.Cainfo = miConfig.Cainfo
  19520. pp.SecretKey = miConfig.SecretKey
  19521. pp.AccessKey = miConfig.AccessKey
  19522. pp.OpterName = curRoles.UserName
  19523. result, _ := service.Jxyb4101(struct4101, pp)
  19524. var dat map[string]interface{}
  19525. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19526. fmt.Println(dat)
  19527. } else {
  19528. fmt.Println(err)
  19529. }
  19530. userJSONBytes, _ := json.Marshal(dat)
  19531. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19532. utils.ErrorLog("解析失败:%v", err)
  19533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19534. return
  19535. }
  19536. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19537. var pp models.PublicParams
  19538. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19539. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19540. pp.FixmedinsName = miConfig.OrgName
  19541. pp.FixmedinsCode = miConfig.Code
  19542. pp.RequestUrl = miConfig.Url
  19543. pp.Cainfo = miConfig.Cainfo
  19544. pp.SecretKey = miConfig.SecretKey
  19545. pp.AccessKey = miConfig.AccessKey
  19546. pp.OpterName = curRoles.UserName
  19547. result, _ := service.Hnyb4101(struct4101, pp)
  19548. var dat map[string]interface{}
  19549. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19550. fmt.Println(dat)
  19551. } else {
  19552. fmt.Println(err)
  19553. }
  19554. userJSONBytes, _ := json.Marshal(dat)
  19555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19556. utils.ErrorLog("解析失败:%v", err)
  19557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19558. return
  19559. }
  19560. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19561. var resOther ResultSeventeenOther
  19562. var pp models.PublicParams
  19563. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19564. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19565. pp.FixmedinsName = miConfig.OrgName
  19566. pp.FixmedinsCode = miConfig.Code
  19567. pp.RequestUrl = miConfig.Url
  19568. pp.Cainfo = miConfig.Cainfo
  19569. pp.SecretKey = miConfig.SecretKey
  19570. pp.AccessKey = miConfig.AccessKey
  19571. pp.OpterName = curRoles.UserName
  19572. client := &http.Client{}
  19573. var req *http.Request
  19574. data := make(map[string]interface{})
  19575. data["struct4101"] = struct4101
  19576. data["pp"] = pp
  19577. bytesData, _ := json.Marshal(data)
  19578. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19579. resp, _ := client.Do(req)
  19580. defer resp.Body.Close()
  19581. body, ioErr := ioutil.ReadAll(resp.Body)
  19582. if ioErr != nil {
  19583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19585. return
  19586. }
  19587. var respJSON map[string]interface{}
  19588. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19591. return
  19592. }
  19593. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19594. userJSONBytes, _ := json.Marshal(respJSON)
  19595. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19596. utils.ErrorLog("解析失败:%v", err)
  19597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19598. return
  19599. }
  19600. res.InfRefmsgid = resOther.InfRefmsgid
  19601. res.Output = resOther.Output
  19602. res.ErrMsg = resOther.ErrMsg
  19603. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19604. res.Infcode = infocode
  19605. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19606. var pp models.PublicParams
  19607. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19608. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19609. pp.FixmedinsName = miConfig.OrgName
  19610. pp.FixmedinsCode = miConfig.Code
  19611. pp.RequestUrl = miConfig.Url
  19612. pp.Cainfo = miConfig.Cainfo
  19613. pp.SecretKey = miConfig.SecretKey
  19614. pp.AccessKey = miConfig.AccessKey
  19615. pp.OpterName = curRoles.UserName
  19616. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19617. fmt.Println(requestLog)
  19618. fmt.Println(errMsgLog)
  19619. saveLog(result, requestLog, "4101a", "上传清单")
  19620. var dat map[string]interface{}
  19621. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19622. fmt.Println(dat)
  19623. } else {
  19624. fmt.Println(err)
  19625. }
  19626. userJSONBytes, _ := json.Marshal(dat)
  19627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19628. utils.ErrorLog("解析失败:%v", err)
  19629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19630. return
  19631. }
  19632. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19633. var pp models.PublicParams
  19634. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19635. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19636. pp.FixmedinsName = miConfig.OrgName
  19637. pp.FixmedinsCode = miConfig.Code
  19638. pp.RequestUrl = miConfig.Url
  19639. pp.Cainfo = miConfig.Cainfo
  19640. pp.SecretKey = miConfig.SecretKey
  19641. pp.AccessKey = miConfig.AccessKey
  19642. pp.OpterName = curRoles.UserName
  19643. client := &http.Client{}
  19644. var req *http.Request
  19645. data := make(map[string]interface{})
  19646. data["struct4101"] = struct4101
  19647. data["pp"] = pp
  19648. bytesData, _ := json.Marshal(data)
  19649. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19650. resp, _ := client.Do(req)
  19651. defer resp.Body.Close()
  19652. body, ioErr := ioutil.ReadAll(resp.Body)
  19653. if ioErr != nil {
  19654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19656. return
  19657. }
  19658. var respJSON map[string]interface{}
  19659. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19662. return
  19663. }
  19664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19665. userJSONBytes, _ := json.Marshal(respJSON)
  19666. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19667. utils.ErrorLog("解析失败:%v", err)
  19668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19669. return
  19670. }
  19671. } else {
  19672. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  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. }
  19686. if res.Infcode != 0 {
  19687. c.ServeSuccessJSON(map[string]interface{}{
  19688. "failed_code": -10,
  19689. "msg": res.ErrMsg,
  19690. })
  19691. return
  19692. } else {
  19693. //order.FaPiaoNumber = zero
  19694. //order.FaPiaoCode = last_order.FaPiaoCode
  19695. //service.UpdateOrder(order)
  19696. hisFundSettleListResult := &models.HisFundSettleListResult{
  19697. Number: res.Output.SetlListId,
  19698. Status: 1,
  19699. Ctime: time.Now().Unix(),
  19700. Mtime: time.Now().Unix(),
  19701. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19702. IsUpload: 1,
  19703. OrderId: order_id,
  19704. }
  19705. service.CreateUploadRecord(hisFundSettleListResult)
  19706. c.ServeSuccessJSON(map[string]interface{}{
  19707. "msg": "上传成功",
  19708. "result": hisFundSettleListResult,
  19709. })
  19710. return
  19711. }
  19712. }
  19713. func (c *HisApiController) GetSettleListHospital() {
  19714. order_id, _ := c.GetInt64("order_id")
  19715. admin_user_id, _ := c.GetInt64("admin_user_id")
  19716. order, _ := service.GetHisOrderByIDTwo(order_id)
  19717. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19718. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19719. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19720. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19721. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19722. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19723. if order.ID == 0 {
  19724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19725. return
  19726. }
  19727. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19728. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19729. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19730. fmt.Println(count)
  19731. var zero string
  19732. number := count + 1
  19733. if number >= 1000 {
  19734. zero = "0000" + strconv.FormatInt(number, 10)
  19735. } else if number >= 10000 {
  19736. zero = "000" + strconv.FormatInt(number, 10)
  19737. } else if number >= 100000 {
  19738. zero = "00" + strconv.FormatInt(number, 10)
  19739. } else if number >= 1000000 {
  19740. zero = "0" + strconv.FormatInt(number, 10)
  19741. } else {
  19742. zero = strconv.FormatInt(number, 10)
  19743. }
  19744. fmt.Println(zero)
  19745. struct4101 := service.Struct4101{
  19746. PsnNo: order.PsnNo,
  19747. MdtrtId: order.MdtrtId,
  19748. SetlId: order.SetlId,
  19749. PsnName: order.PsnName,
  19750. Gend: order.Gend,
  19751. Brdy: his.Brdy,
  19752. Age: int64(order.Age),
  19753. Naty: order.Naty,
  19754. PatnCertType: "01",
  19755. Certno: order.Certno,
  19756. Prfs: "90",
  19757. ConerName: roles[0].UserName,
  19758. PatnRlts: "99",
  19759. ConerAddr: miConfig.OrgName,
  19760. ConerTel: admin.Mobile,
  19761. HiType: order.Insutype,
  19762. Insuplc: miConfig.InsuplcAdmdvs,
  19763. MaindiagFlag: "1",
  19764. BillCode: order.SetlId,
  19765. BillNo: order.SetlId,
  19766. BizSn: order.Number,
  19767. PsnSelfPay: order.PsnPartAmt,
  19768. PsnOwnPay: order.PsnPartAmt,
  19769. AcctPay: order.AcctPay,
  19770. PsnCashpay: order.PsnCashPay,
  19771. HiPaymtd: "1",
  19772. Hsorg: miConfig.InsuplcAdmdvs,
  19773. HsorgOpter: miConfig.InsuplcAdmdvs,
  19774. MedinsFillPsn: curRoles.UserName,
  19775. MedinsFillDept: depart.Name,
  19776. IptMedType: "2",
  19777. AdmTime: his.InHosptialTime,
  19778. AdmEndTime: his.OutHosptialTime,
  19779. }
  19780. struct4101.SetlBegnDate = order.SetlTime
  19781. struct4101.SetlEndDate = order.SetlTime
  19782. //var rf []CustomFundPay
  19783. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19784. //
  19785. //var tempFunPays []service.CustomStruct
  19786. //for _, item := range rf {
  19787. // var tempFunPay service.CustomStruct
  19788. // tempFunPay.FundPayamt = item.FundPayamt
  19789. // tempFunPay.FundPayType = item.FundPayType
  19790. // tempFunPays = append(tempFunPays, tempFunPay)
  19791. //}
  19792. //struct4101.CustomStruct = tempFunPays
  19793. var tempDiaginfos []service.DiaginfoStructTwo
  19794. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19795. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19796. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19797. //for _, item := range infos {
  19798. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19799. //}
  19800. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19801. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19802. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19803. fmt.Println(diagnosis_ids_arr)
  19804. if order.UserOrgId == 10210 {
  19805. var diagnosis_ids_arr_two []int64
  19806. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19807. var config []*models.HisXtDiagnoseConfig
  19808. for _, id := range diagnosis_ids_arr_two {
  19809. //id, _ := strconv.ParseInt(item, 10, 64)
  19810. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19811. if diagnosisConfig.ID > 0 {
  19812. config = append(config, &diagnosisConfig)
  19813. }
  19814. }
  19815. for index, item := range config {
  19816. if item.ID > 0 {
  19817. if index == 0 {
  19818. var tempDiaginfo service.DiaginfoStructTwo
  19819. tempDiaginfo.DiagCode = item.CountryCode
  19820. tempDiaginfo.DiagName = item.CountryContentName
  19821. tempDiaginfo.DiagType = "1"
  19822. tempDiaginfo.MaindiagFlag = "1"
  19823. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19824. } else {
  19825. var tempDiaginfo service.DiaginfoStructTwo
  19826. tempDiaginfo.DiagCode = item.CountryCode
  19827. tempDiaginfo.DiagName = item.CountryContentName
  19828. tempDiaginfo.DiagType = "1"
  19829. tempDiaginfo.MaindiagFlag = "0"
  19830. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19831. }
  19832. }
  19833. }
  19834. struct4101.Diseinfo = tempDiaginfos
  19835. } else {
  19836. var config []*models.HisXtDiagnoseConfig
  19837. for _, item := range diagnosis_ids_arr {
  19838. id, _ := strconv.ParseInt(item, 10, 64)
  19839. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19840. if diagnosisConfig.ID > 0 {
  19841. config = append(config, &diagnosisConfig)
  19842. }
  19843. }
  19844. for index, item := range config {
  19845. if item.ID > 0 {
  19846. if index == 0 {
  19847. var tempDiaginfo service.DiaginfoStructTwo
  19848. tempDiaginfo.DiagCode = item.CountryCode
  19849. tempDiaginfo.DiagName = item.CountryContentName
  19850. tempDiaginfo.DiagType = "1"
  19851. tempDiaginfo.MaindiagFlag = "1"
  19852. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19853. } else {
  19854. var tempDiaginfo service.DiaginfoStructTwo
  19855. tempDiaginfo.DiagCode = item.CountryCode
  19856. tempDiaginfo.DiagName = item.CountryContentName
  19857. tempDiaginfo.DiagType = "1"
  19858. tempDiaginfo.MaindiagFlag = "0"
  19859. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19860. }
  19861. }
  19862. }
  19863. struct4101.Diseinfo = tempDiaginfos
  19864. }
  19865. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19866. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19867. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19868. tempOpspdiseinfo2.OprnOprtCode = ""
  19869. tempOpspdiseinfo2.OprnOprtName = ""
  19870. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19871. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19872. var iteminfo service.IteminfoStruct
  19873. var bedCostTotal float64 = 0 //床位总费
  19874. var bedCostSelfTotal float64 = 0 //床位自费
  19875. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19876. var operationCostTotal float64 = 0 //手术费
  19877. var operationCostSelfTotal float64 = 0 //手术费
  19878. var operationCostPartSelfTotal float64 = 0 //手术费
  19879. var otherCostTotal float64 = 0 //其他费用
  19880. var otherCostSelfTotal float64 = 0 //其他费用
  19881. var otherCostPartSelfTotal float64 = 0 //其他费用
  19882. var materialCostTotal float64 = 0 //材料费
  19883. var materialCostSelfTotal float64 = 0 //材料费
  19884. var materialCostPartSelfTotal float64 = 0 //材料费
  19885. var westernMedicineCostTotal float64 = 0 //西药费
  19886. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19887. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19888. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19889. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19890. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19891. var checkCostTotal float64 = 0 //检查费
  19892. var checkCostSelfTotal float64 = 0 //检查费
  19893. var checkCostPartSelfTotal float64 = 0 //检查费
  19894. var laboratoryCostTotal float64 = 0 //化验费
  19895. var laboratoryCostSelfTotal float64 = 0 //化验费
  19896. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19897. var treatCostTotal float64 = 0 //治疗费用
  19898. var treatCostSelfTotal float64 = 0 //治疗费用
  19899. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19900. decimal.DivisionPrecision = 2
  19901. var bed_fulamt_ownpay_amt float64 = 0
  19902. var operation_fulamt_ownpay_amt float64 = 0
  19903. var other_fulamt_ownpay_amt float64 = 0
  19904. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19905. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19906. var check_fulamt_ownpay_amt float64 = 0
  19907. var material_fulamt_ownpay_amt float64 = 0
  19908. var laboratory_fulamt_ownpay_amt float64 = 0
  19909. var treat_fulamt_ownpay_amt float64 = 0
  19910. var bed_claa_sunmfee float64 = 0
  19911. var bed_clab_amt float64 = 0
  19912. var bed_other_amt float64 = 0
  19913. var operation_claa_sunmfee float64 = 0
  19914. var operation_clab_amt float64 = 0
  19915. var operation_other_amt float64 = 0
  19916. var other_claa_sunmfee float64 = 0
  19917. var other_clab_amt float64 = 0
  19918. var other_other_amt float64 = 0
  19919. var westernMedicine_claa_sunmfee float64 = 0
  19920. var westernMedicine_clab_amt float64 = 0
  19921. var westernMedicine_other_amt float64 = 0
  19922. var chineseTraditional_claa_sunmfee float64 = 0
  19923. var chineseTraditional_clab_amt float64 = 0
  19924. var chineseTraditional_other_amt float64 = 0
  19925. var check_claa_sunmfee float64 = 0
  19926. var check_clab_amt float64 = 0
  19927. var check_other_amt float64 = 0
  19928. var material_claa_sunmfee float64 = 0
  19929. var material_clab_amt float64 = 0
  19930. var material_other_amt float64 = 0
  19931. var laboratory_claa_sunmfee float64 = 0
  19932. var laboratory_clab_amt float64 = 0
  19933. var laboratory_other_amt float64 = 0
  19934. var treat_claa_sunmfee float64 = 0
  19935. var treat_clab_amt float64 = 0
  19936. var treat_other_amt float64 = 0
  19937. for _, item := range order.HisOrderInfo {
  19938. if item.MedChrgitmType == "01" { //床位费
  19939. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19940. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19941. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19942. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19943. if item.ChrgitmLv == "1" {
  19944. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19945. }
  19946. if item.ChrgitmLv == "2" {
  19947. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19948. }
  19949. if item.ChrgitmLv == "3" {
  19950. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19951. }
  19952. }
  19953. if item.MedChrgitmType == "03" { //检查费
  19954. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19955. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19956. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19957. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19958. if item.ChrgitmLv == "1" {
  19959. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19960. }
  19961. if item.ChrgitmLv == "2" {
  19962. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19963. }
  19964. if item.ChrgitmLv == "3" {
  19965. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19966. }
  19967. }
  19968. if item.MedChrgitmType == "04" { //化验费
  19969. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19970. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19971. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19972. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19973. if item.ChrgitmLv == "1" {
  19974. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19975. }
  19976. if item.ChrgitmLv == "2" {
  19977. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19978. }
  19979. if item.ChrgitmLv == "3" {
  19980. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19981. }
  19982. }
  19983. if item.MedChrgitmType == "05" { //治疗费
  19984. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19985. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19986. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19987. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19988. if item.ChrgitmLv == "1" {
  19989. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19990. }
  19991. if item.ChrgitmLv == "2" {
  19992. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19993. }
  19994. if item.ChrgitmLv == "3" {
  19995. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19996. }
  19997. }
  19998. if item.MedChrgitmType == "06" { //手术费
  19999. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20000. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20001. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20002. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20003. if item.ChrgitmLv == "1" {
  20004. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20005. }
  20006. if item.ChrgitmLv == "2" {
  20007. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20008. }
  20009. if item.ChrgitmLv == "3" {
  20010. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20011. }
  20012. }
  20013. if item.MedChrgitmType == "08" { //材料费
  20014. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20015. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20016. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20017. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20018. if item.ChrgitmLv == "1" {
  20019. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20020. }
  20021. if item.ChrgitmLv == "2" {
  20022. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20023. }
  20024. if item.ChrgitmLv == "3" {
  20025. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20026. }
  20027. }
  20028. if item.MedChrgitmType == "09" { //西药费
  20029. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20030. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20031. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20032. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20033. if item.ChrgitmLv == "1" {
  20034. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20035. }
  20036. if item.ChrgitmLv == "2" {
  20037. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20038. }
  20039. if item.ChrgitmLv == "3" {
  20040. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20041. }
  20042. }
  20043. if item.MedChrgitmType == "11" { //中成费
  20044. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20045. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20046. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20047. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20048. if item.ChrgitmLv == "1" {
  20049. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20050. }
  20051. if item.ChrgitmLv == "2" {
  20052. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20053. }
  20054. if item.ChrgitmLv == "3" {
  20055. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20056. }
  20057. }
  20058. if item.MedChrgitmType == "14" { //其他费
  20059. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20060. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20061. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20062. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20063. if item.ChrgitmLv == "1" {
  20064. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20065. }
  20066. if item.ChrgitmLv == "2" {
  20067. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20068. }
  20069. if item.ChrgitmLv == "3" {
  20070. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20071. }
  20072. }
  20073. }
  20074. var iteminfoStructs []service.IteminfoStruct
  20075. if bedCostTotal != 0 {
  20076. iteminfo.MedChrgitm = "01"
  20077. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20078. iteminfo.Amt = bedCostTotal
  20079. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20080. iteminfo.ClabAmt = bed_clab_amt
  20081. iteminfo.OthAmt = bed_other_amt
  20082. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20083. }
  20084. if checkCostTotal != 0 {
  20085. iteminfo.MedChrgitm = "03"
  20086. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20087. iteminfo.Amt = checkCostTotal
  20088. iteminfo.ClaaSumfee = check_claa_sunmfee
  20089. iteminfo.ClabAmt = check_clab_amt
  20090. iteminfo.OthAmt = check_other_amt
  20091. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20092. }
  20093. if laboratoryCostTotal != 0 {
  20094. iteminfo.MedChrgitm = "04"
  20095. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20096. iteminfo.Amt = laboratoryCostTotal
  20097. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20098. iteminfo.ClabAmt = laboratory_clab_amt
  20099. iteminfo.OthAmt = laboratory_other_amt
  20100. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20101. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20102. }
  20103. if treatCostTotal != 0 {
  20104. iteminfo.MedChrgitm = "05"
  20105. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20106. iteminfo.Amt = treatCostTotal
  20107. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20108. iteminfo.ClabAmt = treat_clab_amt
  20109. iteminfo.OthAmt = treat_other_amt
  20110. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20111. //(struct4101.IteminfoStruct, iteminfo)
  20112. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20113. }
  20114. if operationCostTotal != 0 {
  20115. iteminfo.MedChrgitm = "06"
  20116. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20117. iteminfo.Amt = operationCostTotal
  20118. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20119. iteminfo.ClabAmt = operation_clab_amt
  20120. iteminfo.OthAmt = operation_other_amt
  20121. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20122. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20123. }
  20124. if materialCostTotal != 0 {
  20125. iteminfo.MedChrgitm = "08"
  20126. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20127. iteminfo.Amt = materialCostTotal
  20128. iteminfo.ClaaSumfee = material_claa_sunmfee
  20129. iteminfo.ClabAmt = material_clab_amt
  20130. iteminfo.OthAmt = material_other_amt
  20131. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20132. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20133. }
  20134. if westernMedicineCostTotal != 0 {
  20135. iteminfo.MedChrgitm = "09"
  20136. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20137. iteminfo.Amt = westernMedicineCostTotal
  20138. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20139. iteminfo.ClabAmt = westernMedicine_clab_amt
  20140. iteminfo.OthAmt = westernMedicine_other_amt
  20141. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20142. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20143. }
  20144. if chineseTraditionalMedicineCostTotal != 0 {
  20145. iteminfo.MedChrgitm = "11"
  20146. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20147. iteminfo.Amt = westernMedicineCostTotal
  20148. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20149. iteminfo.ClabAmt = westernMedicine_clab_amt
  20150. iteminfo.OthAmt = westernMedicine_other_amt
  20151. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20152. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20153. }
  20154. if otherCostTotal != 0 {
  20155. iteminfo.MedChrgitm = "14"
  20156. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20157. iteminfo.Amt = otherCostTotal
  20158. iteminfo.ClaaSumfee = other_claa_sunmfee
  20159. iteminfo.ClabAmt = other_clab_amt
  20160. iteminfo.OthAmt = other_other_amt
  20161. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20162. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20163. }
  20164. struct4101.IteminfoStruct = iteminfoStructs
  20165. struct4101.Ntly = "中国"
  20166. struct4101.AdmCaty = "A03.06"
  20167. var resOther ResultSeventeenOther
  20168. var res ResultSeventeen
  20169. if miConfig.MdtrtareaAdmvs == "150499" {
  20170. var pp models.PublicParams
  20171. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20172. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20173. pp.FixmedinsName = miConfig.OrgName
  20174. pp.FixmedinsCode = miConfig.Code
  20175. pp.RequestUrl = miConfig.Url
  20176. pp.Cainfo = miConfig.Cainfo
  20177. pp.SecretKey = miConfig.SecretKey
  20178. pp.AccessKey = miConfig.AccessKey
  20179. pp.OpterName = curRoles.UserName
  20180. client := &http.Client{}
  20181. var req *http.Request
  20182. data := make(map[string]interface{})
  20183. data["struct4101"] = struct4101
  20184. data["pp"] = pp
  20185. bytesData, _ := json.Marshal(data)
  20186. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20187. resp, _ := client.Do(req)
  20188. defer resp.Body.Close()
  20189. body, ioErr := ioutil.ReadAll(resp.Body)
  20190. if ioErr != nil {
  20191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20193. return
  20194. }
  20195. var respJSON map[string]interface{}
  20196. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20199. return
  20200. }
  20201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20202. userJSONBytes, _ := json.Marshal(respJSON)
  20203. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20204. utils.ErrorLog("解析失败:%v", err)
  20205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20206. return
  20207. }
  20208. res.InfRefmsgid = resOther.InfRefmsgid
  20209. res.Output = resOther.Output
  20210. res.ErrMsg = resOther.ErrMsg
  20211. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20212. res.Infcode = infocode
  20213. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20214. var pp models.PublicParams
  20215. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20216. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20217. pp.FixmedinsName = miConfig.OrgName
  20218. pp.FixmedinsCode = miConfig.Code
  20219. pp.RequestUrl = miConfig.Url
  20220. pp.Cainfo = miConfig.Cainfo
  20221. pp.SecretKey = miConfig.SecretKey
  20222. pp.AccessKey = miConfig.AccessKey
  20223. pp.OpterName = curRoles.UserName
  20224. result, _ := service.Jxyb4101(struct4101, pp)
  20225. var dat map[string]interface{}
  20226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20227. fmt.Println(dat)
  20228. } else {
  20229. fmt.Println(err)
  20230. }
  20231. userJSONBytes, _ := json.Marshal(dat)
  20232. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20233. utils.ErrorLog("解析失败:%v", err)
  20234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20235. return
  20236. }
  20237. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20238. var pp models.PublicParams
  20239. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20240. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20241. pp.FixmedinsName = miConfig.OrgName
  20242. pp.FixmedinsCode = miConfig.Code
  20243. pp.RequestUrl = miConfig.Url
  20244. pp.Cainfo = miConfig.Cainfo
  20245. pp.SecretKey = miConfig.SecretKey
  20246. pp.AccessKey = miConfig.AccessKey
  20247. pp.OpterName = curRoles.UserName
  20248. result, _ := service.Jxyb4101(struct4101, pp)
  20249. var dat map[string]interface{}
  20250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20251. fmt.Println(dat)
  20252. } else {
  20253. fmt.Println(err)
  20254. }
  20255. userJSONBytes, _ := json.Marshal(dat)
  20256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20257. utils.ErrorLog("解析失败:%v", err)
  20258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20259. return
  20260. }
  20261. } else {
  20262. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20263. var dat map[string]interface{}
  20264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20265. fmt.Println(dat)
  20266. } else {
  20267. fmt.Println(err)
  20268. }
  20269. userJSONBytes, _ := json.Marshal(dat)
  20270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20271. utils.ErrorLog("解析失败:%v", err)
  20272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20273. return
  20274. }
  20275. }
  20276. if res.Infcode != 0 {
  20277. c.ServeSuccessJSON(map[string]interface{}{
  20278. "failed_code": -10,
  20279. "msg": res.ErrMsg,
  20280. })
  20281. return
  20282. } else {
  20283. if miConfig.MdtrtareaAdmvs != "150499" {
  20284. order.FaPiaoNumber = zero
  20285. order.FaPiaoCode = last_order.FaPiaoCode
  20286. service.UpdateOrder(order)
  20287. }
  20288. hisFundSettleListResult := &models.HisFundSettleListResult{
  20289. Number: res.Output.SetlListId,
  20290. Status: 1,
  20291. Ctime: time.Now().Unix(),
  20292. Mtime: time.Now().Unix(),
  20293. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20294. IsUpload: 1,
  20295. OrderId: order_id,
  20296. }
  20297. service.CreateUploadRecord(hisFundSettleListResult)
  20298. c.ServeSuccessJSON(map[string]interface{}{
  20299. "msg": "上传成功",
  20300. "result": hisFundSettleListResult,
  20301. })
  20302. return
  20303. }
  20304. }
  20305. //func (c *HisApiController) GetBatchSettleList() {
  20306. // orders, _ := service.GetAllHisOrder(10106)
  20307. // for _, item := range orders {
  20308. // order_id := item.ID
  20309. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20310. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20311. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20312. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20313. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20314. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20315. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20316. //
  20317. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20318. //
  20319. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20320. //
  20321. // if order.ID == 0 {
  20322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20323. // return
  20324. // }
  20325. // if his.BalanceAccountsType == 2 {
  20326. // continue
  20327. // }
  20328. // struct4101 := service.Struct4101{
  20329. // PsnNo: order.PsnNo,
  20330. // MdtrtId: order.MdtrtId,
  20331. // SetlId: order.SetlId,
  20332. // PsnName: order.PsnName,
  20333. // Gend: order.Gend,
  20334. // Brdy: his.Brdy,
  20335. // Age: his.Age,
  20336. // Naty: order.Naty,
  20337. // PatnCertType: "01",
  20338. // Certno: order.Certno,
  20339. // Prfs: "90",
  20340. // ConerName: roles[0].UserName,
  20341. // PatnRlts: "99",
  20342. // ConerAddr: miConfig.OrgName,
  20343. // ConerTel: admin.Mobile,
  20344. // HiType: order.Insutype,
  20345. // Insuplc: his.InsuplcAdmdvs,
  20346. // MaindiagFlag: "1",
  20347. // BillCode: order.SetlId,
  20348. // BillNo: order.SetlId,
  20349. // BizSn: order.Number,
  20350. // PsnSelfPay: order.PsnPartAmt,
  20351. // PsnOwnPay: order.PsnPartAmt,
  20352. // AcctPay: order.AcctPay,
  20353. // PsnCashpay: order.PsnCashPay,
  20354. // HiPaymtd: "1",
  20355. // Hsorg: his.InsuplcAdmdvs,
  20356. // HsorgOpter: his.InsuplcAdmdvs,
  20357. // MedinsFillPsn: curRoles.UserName,
  20358. // MedinsFillDept: depart.Name,
  20359. // IptMedType: "2",
  20360. // }
  20361. // struct4101.SetlBegnDate = order.SetlTime
  20362. // struct4101.SetlEndDate = order.SetlTime
  20363. // //if order.SettleType == 1 {
  20364. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20365. // // dateStr := t.Format("2006-01-02")
  20366. // // struct4101.SetlBegnDate = dateStr
  20367. // // struct4101.SetlEndDate = dateStr
  20368. // //} else {
  20369. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20370. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20371. // // dateStartStr := t.Format("2006-01-02")
  20372. // // dateEndStr := t2.Format("2006-01-02")
  20373. // // struct4101.SetlBegnDate = dateStartStr
  20374. // // struct4101.SetlEndDate = dateEndStr
  20375. // //}
  20376. //
  20377. // var rf []CustomFundPay
  20378. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20379. //
  20380. // var tempFunPays []service.CustomStruct
  20381. // var tempFunPay610100 service.CustomStruct
  20382. //
  20383. // for _, item := range rf {
  20384. // if item.FundPayType == "610100" {
  20385. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20386. // tempFunPay610100.FundPayType = item.FundPayType
  20387. // } else {
  20388. // var tempFunPay service.CustomStruct
  20389. // tempFunPay.FundPayamt = item.FundPayamt
  20390. // tempFunPay.FundPayType = item.FundPayType
  20391. // tempFunPays = append(tempFunPays, tempFunPay)
  20392. // }
  20393. // }
  20394. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20395. // struct4101.CustomStruct = tempFunPays
  20396. //
  20397. // var tempDiaginfos []service.DiaginfoStructTwo
  20398. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20399. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20400. //
  20401. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20402. // var config []*models.HisXtDiagnoseConfig
  20403. // for _, item := range diagnosis_ids {
  20404. // id, _ := strconv.ParseInt(item, 10, 64)
  20405. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20406. // config = append(config, &diagnosisConfig)
  20407. // }
  20408. //
  20409. // for index, item := range config {
  20410. // if index == 0 {
  20411. // var tempDiaginfo service.DiaginfoStructTwo
  20412. // tempDiaginfo.DiagCode = item.CountryCode
  20413. // tempDiaginfo.DiagName = item.CountryContentName
  20414. // tempDiaginfo.DiagType = "1"
  20415. // tempDiaginfo.MaindiagFlag = "1"
  20416. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20417. // } else {
  20418. //
  20419. // var tempDiaginfo service.DiaginfoStructTwo
  20420. // tempDiaginfo.DiagCode = item.CountryCode
  20421. // tempDiaginfo.DiagName = item.CountryContentName
  20422. // tempDiaginfo.DiagType = "2"
  20423. // tempDiaginfo.MaindiagFlag = "0"
  20424. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20425. // }
  20426. // }
  20427. // struct4101.Diseinfo = tempDiaginfos
  20428. //
  20429. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20430. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20431. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20432. // tempOpspdiseinfo2.OprnOprtCode = ""
  20433. // tempOpspdiseinfo2.OprnOprtName = ""
  20434. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20435. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20436. //
  20437. // var iteminfo service.IteminfoStruct
  20438. //
  20439. // var bedCostTotal float64 = 0 //床位总费
  20440. // var bedCostSelfTotal float64 = 0 //床位自费
  20441. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20442. //
  20443. // var examineCostTotal float64 = 0 //诊查总费
  20444. // var examineCostSelfTotal float64 = 0 //诊查自费
  20445. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20446. //
  20447. // var nursingCostTotal float64 = 0 //护理总费
  20448. // var nursingCostSelfTotal float64 = 0 //护理自费
  20449. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20450. //
  20451. // var chineseMedicineCostTotal float64 = 0 //中成药
  20452. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20453. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20454. //
  20455. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20456. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20457. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20458. //
  20459. // var registerCostTotal float64 = 0 //一般诊疗费
  20460. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20461. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20462. //
  20463. // var operationCostTotal float64 = 0 //手术费
  20464. // var operationCostSelfTotal float64 = 0 //手术费
  20465. // var operationCostPartSelfTotal float64 = 0 //手术费
  20466. //
  20467. // var otherCostTotal float64 = 0 //其他费用
  20468. // var otherCostSelfTotal float64 = 0 //其他费用
  20469. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20470. //
  20471. // var materialCostTotal float64 = 0 //材料费
  20472. // var materialCostSelfTotal float64 = 0 //材料费
  20473. // var materialCostPartSelfTotal float64 = 0 //材料费
  20474. //
  20475. // var westernMedicineCostTotal float64 = 0 //西药费
  20476. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20477. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20478. //
  20479. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20480. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20481. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20482. //
  20483. // var checkCostTotal float64 = 0 //检查费
  20484. // var checkCostSelfTotal float64 = 0 //检查费
  20485. // var checkCostPartSelfTotal float64 = 0 //检查费
  20486. //
  20487. // var laboratoryCostTotal float64 = 0 //化验费
  20488. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20489. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20490. //
  20491. // var treatCostTotal float64 = 0 //治疗费用
  20492. // var treatCostSelfTotal float64 = 0 //治疗费用
  20493. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20494. //
  20495. // decimal.DivisionPrecision = 2
  20496. //
  20497. // var bed_fulamt_ownpay_amt float64 = 0
  20498. //
  20499. // var examine_fulamt_ownpay_amt float64 = 0
  20500. //
  20501. // var nursing_fulamt_ownpay_amt float64 = 0
  20502. //
  20503. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20504. //
  20505. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20506. //
  20507. // var register_fulamt_ownpay_amt float64 = 0
  20508. //
  20509. // var operation_fulamt_ownpay_amt float64 = 0
  20510. // var other_fulamt_ownpay_amt float64 = 0
  20511. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20512. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20513. // var check_fulamt_ownpay_amt float64 = 0
  20514. // var material_fulamt_ownpay_amt float64 = 0
  20515. // var laboratory_fulamt_ownpay_amt float64 = 0
  20516. // var treat_fulamt_ownpay_amt float64 = 0
  20517. //
  20518. // var bed_claa_sunmfee float64 = 0
  20519. // var bed_clab_amt float64 = 0
  20520. // var bed_other_amt float64 = 0
  20521. //
  20522. // var examine_claa_sunmfee float64 = 0
  20523. // var examine_clab_amt float64 = 0
  20524. // var examine_other_amt float64 = 0
  20525. //
  20526. // var nursing_claa_sunmfee float64 = 0
  20527. // var nursing_clab_amt float64 = 0
  20528. // var nursing_other_amt float64 = 0
  20529. //
  20530. // var chinese_medicine_claa_sunmfee float64 = 0
  20531. // var chinese_medicine_clab_amt float64 = 0
  20532. // var chinese_medicine_other_amt float64 = 0
  20533. //
  20534. // var commonly_treatment_claa_sunmfee float64 = 0
  20535. // var commonly_treatment_clab_amt float64 = 0
  20536. // var commonly_treatment_other_amt float64 = 0
  20537. //
  20538. // var operation_claa_sunmfee float64 = 0
  20539. // var operation_clab_amt float64 = 0
  20540. // var operation_other_amt float64 = 0
  20541. //
  20542. // var other_claa_sunmfee float64 = 0
  20543. // var other_clab_amt float64 = 0
  20544. // var other_other_amt float64 = 0
  20545. //
  20546. // var westernMedicine_claa_sunmfee float64 = 0
  20547. // var westernMedicine_clab_amt float64 = 0
  20548. // var westernMedicine_other_amt float64 = 0
  20549. //
  20550. // var chineseTraditional_claa_sunmfee float64 = 0
  20551. // var chineseTraditional_clab_amt float64 = 0
  20552. // var chineseTraditional_other_amt float64 = 0
  20553. //
  20554. // var check_claa_sunmfee float64 = 0
  20555. // var check_clab_amt float64 = 0
  20556. // var check_other_amt float64 = 0
  20557. //
  20558. // var material_claa_sunmfee float64 = 0
  20559. // var material_clab_amt float64 = 0
  20560. // var material_other_amt float64 = 0
  20561. //
  20562. // var laboratory_claa_sunmfee float64 = 0
  20563. // var laboratory_clab_amt float64 = 0
  20564. // var laboratory_other_amt float64 = 0
  20565. //
  20566. // var treat_claa_sunmfee float64 = 0
  20567. // var treat_clab_amt float64 = 0
  20568. // var treat_other_amt float64 = 0
  20569. //
  20570. // var register_claa_sunmfee float64 = 0
  20571. // var register_clab_amt float64 = 0
  20572. // var register_other_amt float64 = 0
  20573. //
  20574. // for _, item := range order.HisOrderInfo {
  20575. // if item.MedChrgitmType == "01" { //床位费
  20576. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20577. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20578. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20579. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20580. // if item.ChrgitmLv == "1" {
  20581. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20582. // }
  20583. // if item.ChrgitmLv == "2" {
  20584. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20585. //
  20586. // }
  20587. // if item.ChrgitmLv == "3" {
  20588. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20589. // }
  20590. //
  20591. // }
  20592. //
  20593. // if item.MedChrgitmType == "02" { //诊查
  20594. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20595. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20596. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20597. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20598. // if item.ChrgitmLv == "1" {
  20599. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20600. // }
  20601. // if item.ChrgitmLv == "2" {
  20602. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20603. //
  20604. // }
  20605. // if item.ChrgitmLv == "3" {
  20606. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20607. // }
  20608. //
  20609. // }
  20610. //
  20611. // if item.MedChrgitmType == "03" { //检查费
  20612. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20613. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20614. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20615. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20616. // if item.ChrgitmLv == "1" {
  20617. //
  20618. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20619. //
  20620. // }
  20621. // if item.ChrgitmLv == "2" {
  20622. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20623. //
  20624. // }
  20625. // if item.ChrgitmLv == "3" {
  20626. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20627. // }
  20628. // }
  20629. //
  20630. // if item.MedChrgitmType == "04" { //化验费
  20631. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20632. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20633. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20634. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20635. // if item.ChrgitmLv == "1" {
  20636. //
  20637. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20638. //
  20639. // }
  20640. // if item.ChrgitmLv == "2" {
  20641. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20642. //
  20643. // }
  20644. // if item.ChrgitmLv == "3" {
  20645. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20646. // }
  20647. // }
  20648. //
  20649. // if item.MedChrgitmType == "05" { //治疗费
  20650. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20651. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20652. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20653. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20654. // if item.ChrgitmLv == "1" {
  20655. //
  20656. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20657. //
  20658. // }
  20659. // if item.ChrgitmLv == "2" {
  20660. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20661. //
  20662. // }
  20663. // if item.ChrgitmLv == "3" {
  20664. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20665. // }
  20666. // }
  20667. //
  20668. // if item.MedChrgitmType == "06" { //手术费
  20669. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20670. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20671. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20672. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20673. //
  20674. // if item.ChrgitmLv == "1" {
  20675. //
  20676. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20677. //
  20678. // }
  20679. // if item.ChrgitmLv == "2" {
  20680. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20681. //
  20682. // }
  20683. // if item.ChrgitmLv == "3" {
  20684. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20685. // }
  20686. // }
  20687. //
  20688. // if item.MedChrgitmType == "07" { //手术费
  20689. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20690. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20691. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20692. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20693. //
  20694. // if item.ChrgitmLv == "1" {
  20695. //
  20696. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20697. //
  20698. // }
  20699. // if item.ChrgitmLv == "2" {
  20700. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20701. //
  20702. // }
  20703. // if item.ChrgitmLv == "3" {
  20704. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20705. // }
  20706. // }
  20707. //
  20708. // if item.MedChrgitmType == "08" { //材料费
  20709. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20710. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20711. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20712. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20713. // if item.ChrgitmLv == "1" {
  20714. //
  20715. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20716. //
  20717. // }
  20718. // if item.ChrgitmLv == "2" {
  20719. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20720. //
  20721. // }
  20722. // if item.ChrgitmLv == "3" {
  20723. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20724. // }
  20725. // }
  20726. // if item.MedChrgitmType == "09" { //西药费
  20727. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20728. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20729. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20730. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20731. // if item.ChrgitmLv == "1" {
  20732. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20733. // }
  20734. // if item.ChrgitmLv == "2" {
  20735. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20736. // }
  20737. // if item.ChrgitmLv == "3" {
  20738. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20739. // }
  20740. // }
  20741. // if item.MedChrgitmType == "10" { //中药饮片
  20742. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20743. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20744. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20745. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20746. // if item.ChrgitmLv == "1" {
  20747. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20748. // }
  20749. // if item.ChrgitmLv == "2" {
  20750. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20751. // }
  20752. // if item.ChrgitmLv == "3" {
  20753. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20754. // }
  20755. // }
  20756. //
  20757. // if item.MedChrgitmType == "11" { //中成费
  20758. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20759. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20760. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20761. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20762. // if item.ChrgitmLv == "1" {
  20763. //
  20764. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20765. //
  20766. // }
  20767. // if item.ChrgitmLv == "2" {
  20768. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20769. //
  20770. // }
  20771. // if item.ChrgitmLv == "3" {
  20772. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20773. // }
  20774. // }
  20775. //
  20776. // if item.MedChrgitmType == "12" { //中成费
  20777. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20778. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20779. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20780. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20781. // if item.ChrgitmLv == "1" {
  20782. //
  20783. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20784. //
  20785. // }
  20786. // if item.ChrgitmLv == "2" {
  20787. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20788. //
  20789. // }
  20790. // if item.ChrgitmLv == "3" {
  20791. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20792. // }
  20793. // }
  20794. //
  20795. // if item.MedChrgitmType == "13" { //中成费
  20796. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20797. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20798. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20799. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20800. // if item.ChrgitmLv == "1" {
  20801. //
  20802. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20803. //
  20804. // }
  20805. // if item.ChrgitmLv == "2" {
  20806. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20807. //
  20808. // }
  20809. // if item.ChrgitmLv == "3" {
  20810. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20811. // }
  20812. // }
  20813. //
  20814. // if item.MedChrgitmType == "14" { //其他费
  20815. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20816. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20817. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20818. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20819. // if item.ChrgitmLv == "1" {
  20820. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20821. //
  20822. // }
  20823. // if item.ChrgitmLv == "2" {
  20824. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20825. //
  20826. // }
  20827. // if item.ChrgitmLv == "3" {
  20828. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20829. // }
  20830. // }
  20831. //
  20832. // }
  20833. //
  20834. // var iteminfoStructs []service.IteminfoStruct
  20835. //
  20836. // if bedCostTotal != 0 {
  20837. // iteminfo.MedChrgitm = "01"
  20838. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20839. // iteminfo.Amt = bedCostTotal
  20840. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20841. // iteminfo.ClabAmt = bed_clab_amt
  20842. // iteminfo.OthAmt = bed_other_amt
  20843. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20844. // }
  20845. //
  20846. // if examineCostTotal != 0 {
  20847. // iteminfo.MedChrgitm = "02"
  20848. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20849. // iteminfo.Amt = examineCostTotal
  20850. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20851. // iteminfo.ClabAmt = examine_clab_amt
  20852. // iteminfo.OthAmt = examine_other_amt
  20853. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20854. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20855. // }
  20856. //
  20857. // if checkCostTotal != 0 {
  20858. // iteminfo.MedChrgitm = "03"
  20859. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20860. // iteminfo.Amt = checkCostTotal
  20861. // iteminfo.ClaaSumfee = check_claa_sunmfee
  20862. // iteminfo.ClabAmt = check_clab_amt
  20863. // iteminfo.OthAmt = check_other_amt
  20864. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20865. //
  20866. // }
  20867. //
  20868. // if laboratoryCostTotal != 0 {
  20869. // iteminfo.MedChrgitm = "04"
  20870. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20871. // iteminfo.Amt = laboratoryCostTotal
  20872. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20873. // iteminfo.ClabAmt = laboratory_clab_amt
  20874. // iteminfo.OthAmt = laboratory_other_amt
  20875. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20876. //
  20877. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20878. //
  20879. // }
  20880. //
  20881. // if treatCostTotal != 0 {
  20882. // iteminfo.MedChrgitm = "05"
  20883. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20884. // iteminfo.Amt = treatCostTotal
  20885. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  20886. // iteminfo.ClabAmt = treat_clab_amt
  20887. // iteminfo.OthAmt = treat_other_amt
  20888. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20889. // //(struct4101.IteminfoStruct, iteminfo)
  20890. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20891. // }
  20892. //
  20893. // if operationCostTotal != 0 {
  20894. // iteminfo.MedChrgitm = "06"
  20895. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20896. // iteminfo.Amt = operationCostTotal
  20897. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  20898. // iteminfo.ClabAmt = operation_clab_amt
  20899. // iteminfo.OthAmt = operation_other_amt
  20900. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20901. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20902. // }
  20903. //
  20904. // if nursingCostTotal != 0 {
  20905. // iteminfo.MedChrgitm = "07"
  20906. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  20907. // iteminfo.Amt = nursingCostTotal
  20908. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  20909. // iteminfo.ClabAmt = nursing_clab_amt
  20910. // iteminfo.OthAmt = nursing_other_amt
  20911. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20912. // }
  20913. //
  20914. // if materialCostTotal != 0 {
  20915. // iteminfo.MedChrgitm = "08"
  20916. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20917. // iteminfo.Amt = materialCostTotal
  20918. // iteminfo.ClaaSumfee = material_claa_sunmfee
  20919. // iteminfo.ClabAmt = material_clab_amt
  20920. // iteminfo.OthAmt = material_other_amt
  20921. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20922. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20923. // }
  20924. //
  20925. // if westernMedicineCostTotal != 0 {
  20926. // iteminfo.MedChrgitm = "09"
  20927. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20928. // iteminfo.Amt = westernMedicineCostTotal
  20929. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20930. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20931. // iteminfo.OthAmt = westernMedicine_other_amt
  20932. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20933. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20934. //
  20935. // }
  20936. //
  20937. // if chineseMedicineCostTotal != 0 {
  20938. // iteminfo.MedChrgitm = "10"
  20939. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  20940. // iteminfo.Amt = chineseMedicineCostTotal
  20941. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  20942. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  20943. // iteminfo.OthAmt = chinese_medicine_other_amt
  20944. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20945. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20946. //
  20947. // }
  20948. //
  20949. // if chineseTraditionalMedicineCostTotal != 0 {
  20950. // iteminfo.MedChrgitm = "11"
  20951. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20952. // iteminfo.Amt = westernMedicineCostTotal
  20953. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20954. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20955. // iteminfo.OthAmt = westernMedicine_other_amt
  20956. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20957. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20958. //
  20959. // }
  20960. //
  20961. // if commonlyTreatmentCostTotal != 0 {
  20962. // iteminfo.MedChrgitm = "12"
  20963. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  20964. // iteminfo.Amt = commonlyTreatmentCostTotal
  20965. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  20966. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  20967. // iteminfo.OthAmt = commonly_treatment_other_amt
  20968. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20969. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20970. //
  20971. // }
  20972. //
  20973. // if registerCostTotal != 0 {
  20974. // iteminfo.MedChrgitm = "13"
  20975. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  20976. // iteminfo.Amt = registerCostTotal
  20977. // iteminfo.ClaaSumfee = register_claa_sunmfee
  20978. // iteminfo.ClabAmt = register_clab_amt
  20979. // iteminfo.OthAmt = register_other_amt
  20980. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20981. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20982. //
  20983. // }
  20984. //
  20985. // if otherCostTotal != 0 {
  20986. // iteminfo.MedChrgitm = "14"
  20987. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20988. // iteminfo.Amt = otherCostTotal
  20989. // iteminfo.ClaaSumfee = other_claa_sunmfee
  20990. // iteminfo.ClabAmt = other_clab_amt
  20991. // iteminfo.OthAmt = other_other_amt
  20992. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20993. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20994. //
  20995. // }
  20996. // struct4101.IteminfoStruct = iteminfoStructs
  20997. // time_arr := strings.Split(order.SetlTime, " ")
  20998. // struct4101.AdmTime = time_arr[0]
  20999. // struct4101.AdmEndTime = time_arr[0]
  21000. //
  21001. // struct4101.DoctorName = doctor.UserName
  21002. // struct4101.DoctorCode = doctor.DoctorNumber
  21003. //
  21004. // struct4101.Ntly = "中国"
  21005. // struct4101.AdmCaty = "A03.06"
  21006. // var res ResultSeventeen
  21007. // if miConfig.MdtrtareaAdmvs == "421300" {
  21008. // data := make(map[string]interface{})
  21009. // data["struct4101"] = struct4101
  21010. // data["secret_key"] = miConfig.SecretKey
  21011. // data["org_name"] = miConfig.OrgName
  21012. // data["opera"] = curRoles.UserName
  21013. // data["code"] = miConfig.Code
  21014. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21015. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21016. //
  21017. // client := &http.Client{}
  21018. // bytesData, _ := json.Marshal(data)
  21019. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21020. // resp, _ := client.Do(req)
  21021. // defer resp.Body.Close()
  21022. // body, ioErr := ioutil.ReadAll(resp.Body)
  21023. // if ioErr != nil {
  21024. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21025. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21026. // return
  21027. // }
  21028. // var respJSON map[string]interface{}
  21029. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21030. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21032. // return
  21033. // }
  21034. //
  21035. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21036. // userJSONBytes, _ := json.Marshal(respJSON)
  21037. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21038. // utils.ErrorLog("解析失败:%v", err)
  21039. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21040. // adminUser := c.GetAdminUserInfo()
  21041. // errlog := &models.HisOrderError{
  21042. // UserOrgId: adminUser.CurrentOrgId,
  21043. // Ctime: time.Now().Unix(),
  21044. // Mtime: time.Now().Unix(),
  21045. // ErrMsg: res.ErrMsg + "解析失败",
  21046. // Status: 1,
  21047. // PatientId: order_id,
  21048. // Stage: 10088,
  21049. // }
  21050. // service.CreateErrMsgLog(errlog)
  21051. // continue
  21052. // }
  21053. //
  21054. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21055. // data := make(map[string]interface{})
  21056. // data["struct4101"] = struct4101
  21057. // data["secret_key"] = miConfig.SecretKey
  21058. // data["org_name"] = miConfig.OrgName
  21059. // data["opera"] = curRoles.UserName
  21060. // data["code"] = miConfig.Code
  21061. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21062. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21063. //
  21064. // client := &http.Client{}
  21065. // bytesData, _ := json.Marshal(data)
  21066. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21067. // resp, _ := client.Do(req)
  21068. // defer resp.Body.Close()
  21069. // body, ioErr := ioutil.ReadAll(resp.Body)
  21070. // if ioErr != nil {
  21071. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21073. // return
  21074. // }
  21075. // var respJSON map[string]interface{}
  21076. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21077. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21079. // return
  21080. // }
  21081. //
  21082. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21083. // userJSONBytes, _ := json.Marshal(respJSON)
  21084. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21085. // utils.ErrorLog("解析失败:%v", err)
  21086. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21087. // adminUser := c.GetAdminUserInfo()
  21088. // errlog := &models.HisOrderError{
  21089. // UserOrgId: adminUser.CurrentOrgId,
  21090. // Ctime: time.Now().Unix(),
  21091. // Mtime: time.Now().Unix(),
  21092. // ErrMsg: res.ErrMsg + "解析失败",
  21093. // Status: 1,
  21094. // PatientId: order_id,
  21095. // Stage: 10088,
  21096. // }
  21097. // service.CreateErrMsgLog(errlog)
  21098. // continue
  21099. // }
  21100. //
  21101. // } else {
  21102. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21103. // fmt.Println(result)
  21104. //
  21105. // var dat map[string]interface{}
  21106. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21107. // fmt.Println(dat)
  21108. // } else {
  21109. // fmt.Println(err)
  21110. // }
  21111. // userJSONBytes, _ := json.Marshal(dat)
  21112. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21113. // utils.ErrorLog("解析失败:%v", err)
  21114. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21115. // adminUser := c.GetAdminUserInfo()
  21116. // errlog := &models.HisOrderError{
  21117. // UserOrgId: adminUser.CurrentOrgId,
  21118. // Ctime: time.Now().Unix(),
  21119. // Mtime: time.Now().Unix(),
  21120. // ErrMsg: res.ErrMsg + "解析失败",
  21121. // Status: 1,
  21122. // PatientId: order_id,
  21123. // Stage: 10106,
  21124. // }
  21125. // service.CreateErrMsgLog(errlog)
  21126. // continue
  21127. // }
  21128. // }
  21129. //
  21130. // if res.Infcode != 0 {
  21131. // adminUser := c.GetAdminUserInfo()
  21132. // errlog := &models.HisOrderError{
  21133. // UserOrgId: adminUser.CurrentOrgId,
  21134. // Ctime: time.Now().Unix(),
  21135. // Mtime: time.Now().Unix(),
  21136. // ErrMsg: res.ErrMsg,
  21137. // Status: 1,
  21138. // PatientId: order_id,
  21139. // Stage: 10106,
  21140. // }
  21141. // service.CreateErrMsgLog(errlog)
  21142. // continue
  21143. // } else {
  21144. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21145. // Number: res.Output.SetlListId,
  21146. // Status: 1,
  21147. // Ctime: time.Now().Unix(),
  21148. // Mtime: time.Now().Unix(),
  21149. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21150. // IsUpload: 1,
  21151. // OrderId: order_id,
  21152. // }
  21153. // service.CreateUploadRecord(hisFundSettleListResult)
  21154. // continue
  21155. // }
  21156. // }
  21157. //}
  21158. func (c *HisApiController) GetOrgInfo() {
  21159. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21160. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21161. }
  21162. func (c *HisApiController) GetHisPatientInfo() {
  21163. medical_insurance_card := c.GetString("medical_insurance_card")
  21164. id_card_type, _ := c.GetInt64("id_card_type")
  21165. id_card := c.GetString("id_card")
  21166. adminInfo := c.GetAdminUserInfo()
  21167. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21168. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21169. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21170. IdCardNo := ""
  21171. if id_card_type == 1 {
  21172. IdCardNo = medical_insurance_card
  21173. } else if id_card_type == 2 {
  21174. IdCardNo = id_card
  21175. }
  21176. if config.IsOpen == 1 {
  21177. 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
  21178. resp, requestErr := http.Get(api)
  21179. if requestErr != nil {
  21180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21181. return
  21182. }
  21183. defer resp.Body.Close()
  21184. body, ioErr := ioutil.ReadAll(resp.Body)
  21185. if ioErr != nil {
  21186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21188. return
  21189. }
  21190. var respJSON map[string]interface{}
  21191. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21194. return
  21195. }
  21196. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21197. userJSONBytes, _ := json.Marshal(userJSON)
  21198. var res ResultTwo
  21199. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21200. utils.ErrorLog("解析失败:%v", err)
  21201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21202. return
  21203. }
  21204. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21205. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21206. infoStr := string(Iinfos)
  21207. idetinfoStr := string(Idetinfos)
  21208. if res.Infcode == 0 {
  21209. his := models.VMHisPatient{
  21210. Status: 1,
  21211. Ctime: time.Now().Unix(),
  21212. Mtime: time.Now().Unix(),
  21213. PsnNo: res.Output.Baseinfo.PsnNo,
  21214. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21215. Certno: res.Output.Baseinfo.Certno,
  21216. PsnName: res.Output.Baseinfo.PsnName,
  21217. Gend: res.Output.Baseinfo.Gend,
  21218. Naty: res.Output.Baseinfo.Naty,
  21219. Iinfo: infoStr,
  21220. Idetinfo: idetinfoStr,
  21221. UserOrgId: adminInfo.CurrentOrgId,
  21222. IsReturn: 1,
  21223. IdCardType: id_card_type,
  21224. }
  21225. c.ServeSuccessJSON(map[string]interface{}{
  21226. "info": his,
  21227. })
  21228. } else {
  21229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21230. return
  21231. }
  21232. }
  21233. }
  21234. //func GetBasBaseInfo() (jsonStr string, err error) {
  21235. //
  21236. // handle := syscall.NewLazyDLL("SSCard.dll")
  21237. // add := handle.NewProc("ReadCardBas")
  21238. // str := make([]byte, 1024)
  21239. // str1 := make([]byte, 1024)
  21240. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21241. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21242. //
  21243. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21244. //
  21245. // fmt.Println("> Add(4,5)的结果为:", ret)
  21246. // handle.Release()
  21247. //
  21248. // return "", nil
  21249. //
  21250. //}
  21251. //func GetQRBaseInfo() (jsonStr string, err error) {
  21252. // handle := syscall.LoadDLL("SSCard.dll")
  21253. // ReadCardBas := handle.FindProc("GetQRBase")
  21254. //
  21255. // str := make([]byte, 256)
  21256. // str1 := make([]byte, 256)
  21257. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21258. //
  21259. // fmt.Println(string(str))
  21260. // fmt.Println(r)
  21261. // return string(str), nil
  21262. //}
  21263. //func CardInit() int {
  21264. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21265. // add := DllTestDef.MustFindProc("Init")
  21266. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21267. // if err != nil {
  21268. // fmt.Println("SSCard的运算结果为:", ret)
  21269. // }
  21270. // result := int(ret)
  21271. // return result
  21272. //}
  21273. //func CardInit() int {
  21274. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21275. // if err != nil {
  21276. // fmt.Println("SSCard的运算结果为:", ret)
  21277. // }
  21278. // fmt.Println(err)
  21279. // result := int(ret)
  21280. // return result
  21281. //}
  21282. func IntPtr(n int) uintptr {
  21283. return uintptr(n)
  21284. }
  21285. func StrPtr(s string) uintptr {
  21286. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21287. }
  21288. type Result2001 struct {
  21289. Cainfo interface{} `json:"cainfo"`
  21290. ErrMsg string `json:"err_msg"`
  21291. InfRefmsgid string `json:"inf_refmsgid"`
  21292. Infcode int64 `json:"infcode"`
  21293. Output struct {
  21294. Trtinfo struct {
  21295. PsnNo string `json:"psn_no"`
  21296. TrtChkType string `json:"trt_chk_type"`
  21297. FundPayType string `json:"fund_pay_type"`
  21298. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21299. Begndate string `json:"begndate"`
  21300. Enddate string `json:"enddate"`
  21301. TrtChkRslt string `json:"trt_chk_rslt"`
  21302. } `json:"trtinfo"`
  21303. } `json:"output"`
  21304. RefmsgTime string `json:"refmsg_time"`
  21305. RespondTime string `json:"respond_time"`
  21306. Signtype interface{} `json:"signtype"`
  21307. WarnMsg interface{} `json:"warn_msg"`
  21308. }
  21309. type Result2001Org10265 struct {
  21310. Cainfo interface{} `json:"cainfo"`
  21311. ErrMsg string `json:"err_msg"`
  21312. InfRefmsgid string `json:"inf_refmsgid"`
  21313. Infcode string `json:"infcode"`
  21314. Output struct {
  21315. Trtinfo struct {
  21316. PsnNo string `json:"psn_no"`
  21317. TrtChkType string `json:"trt_chk_type"`
  21318. FundPayType string `json:"fund_pay_type"`
  21319. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21320. Begndate string `json:"begndate"`
  21321. Enddate string `json:"enddate"`
  21322. TrtChkRslt string `json:"trt_chk_rslt"`
  21323. } `json:"trtinfo"`
  21324. } `json:"output"`
  21325. RefmsgTime string `json:"refmsg_time"`
  21326. RespondTime string `json:"respond_time"`
  21327. Signtype interface{} `json:"signtype"`
  21328. WarnMsg interface{} `json:"warn_msg"`
  21329. }
  21330. type ResultTwo struct {
  21331. ErrMsg string `json:"err_msg"`
  21332. InfRefmsgid string `json:"inf_refmsgid"`
  21333. Infcode int64 `json:"infcode"`
  21334. Output struct {
  21335. Baseinfo struct {
  21336. //Brdy string `json:"brdy"`
  21337. Certno string `json:"certno"`
  21338. Gend string `json:"gend"`
  21339. Naty string `json:"naty"`
  21340. PsnCertType string `json:"psn_cert_type"`
  21341. PsnName string `json:"psn_name"`
  21342. PsnNo string `json:"psn_no"`
  21343. } `json:"baseinfo"`
  21344. Idetinfo []interface{} `json:"idetinfo"`
  21345. Iinfo []struct {
  21346. Balc float64 `json:"balc"`
  21347. CvlservFlag string `json:"cvlserv_flag"`
  21348. EmpName string `json:"emp_name"`
  21349. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21350. Insutype string `json:"insutype"`
  21351. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21352. //PausInsuDate string `json:"paus_insu_date"`
  21353. //PsnInsuDate string `json:"psn_insu_date"`
  21354. PsnInsuStas string `json:"psn_insu_stas"`
  21355. PsnType string `json:"psn_type"`
  21356. } `json:"insuinfo"`
  21357. } `json:"output"`
  21358. RefmsgTime string `json:"refmsg_time"`
  21359. RespondTime string `json:"respond_time"`
  21360. Signtype interface{} `json:"signtype"`
  21361. WarnInfo interface{} `json:"warn_info"`
  21362. }
  21363. type ResultTwo10265 struct {
  21364. ErrMsg string `json:"err_msg"`
  21365. InfRefmsgid string `json:"inf_refmsgid"`
  21366. Infcode string `json:"infcode"`
  21367. Output struct {
  21368. Baseinfo struct {
  21369. //Brdy string `json:"brdy"`
  21370. Certno string `json:"certno"`
  21371. Gend string `json:"gend"`
  21372. Naty string `json:"naty"`
  21373. PsnCertType string `json:"psn_cert_type"`
  21374. PsnName string `json:"psn_name"`
  21375. PsnNo string `json:"psn_no"`
  21376. } `json:"baseinfo"`
  21377. Idetinfo []interface{} `json:"idetinfo"`
  21378. Iinfo []struct {
  21379. Balc float64 `json:"balc"`
  21380. CvlservFlag string `json:"cvlserv_flag"`
  21381. EmpName string `json:"emp_name"`
  21382. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21383. Insutype string `json:"insutype"`
  21384. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21385. PsnInsuStas string `json:"psn_insu_stas"`
  21386. PsnType string `json:"psn_type"`
  21387. } `json:"insuinfo"`
  21388. } `json:"output"`
  21389. RefmsgTime string `json:"refmsg_time"`
  21390. RespondTime string `json:"respond_time"`
  21391. Signtype interface{} `json:"signtype"`
  21392. WarnInfo interface{} `json:"warn_info"`
  21393. }
  21394. type ResultThree struct {
  21395. Cainfo interface{} `json:"cainfo"`
  21396. ErrMsg string `json:"err_msg"`
  21397. InfRefmsgid string `json:"inf_refmsgid"`
  21398. Infcode int64 `json:"infcode"`
  21399. Output struct {
  21400. Data struct {
  21401. IptOtpNo string `json:"ipt_otp_no"`
  21402. MdtrtID string `json:"mdtrt_id"`
  21403. PsnNo string `json:"psn_no"`
  21404. } `json:"data"`
  21405. } `json:"output"`
  21406. RefmsgTime string `json:"refmsg_time"`
  21407. RespondTime string `json:"respond_time"`
  21408. Signtype interface{} `json:"signtype"`
  21409. WarnMsg interface{} `json:"warn_msg"`
  21410. }
  21411. type ResultThree10265 struct {
  21412. Cainfo interface{} `json:"cainfo"`
  21413. ErrMsg string `json:"err_msg"`
  21414. InfRefmsgid string `json:"inf_refmsgid"`
  21415. Infcode string `json:"infcode"`
  21416. Output struct {
  21417. Data struct {
  21418. IptOtpNo string `json:"ipt_otp_no"`
  21419. MdtrtID string `json:"mdtrt_id"`
  21420. PsnNo string `json:"psn_no"`
  21421. } `json:"data"`
  21422. } `json:"output"`
  21423. RefmsgTime string `json:"refmsg_time"`
  21424. RespondTime string `json:"respond_time"`
  21425. Signtype interface{} `json:"signtype"`
  21426. WarnMsg interface{} `json:"warn_msg"`
  21427. }
  21428. type ResultFour struct {
  21429. Cainfo string `json:"cainfo"`
  21430. ErrMsg string `json:"err_msg"`
  21431. InfRefmsgid string `json:"inf_refmsgid"`
  21432. Infcode int64 `json:"infcode"`
  21433. Output struct {
  21434. Result []struct {
  21435. BasMednFlag string `json:"bas_medn_flag"`
  21436. ChldMedcFlag string `json:"chld_medc_flag"`
  21437. ChrgitmLv string `json:"chrgitm_lv"`
  21438. Cnt float64 `json:"cnt"`
  21439. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21440. DrtReimFlag string `json:"drt_reim_flag"`
  21441. FeedetlSn string `json:"feedetl_sn"`
  21442. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21443. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21444. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21445. ListSpItemFlag string `json:"list_sp_item_flag"`
  21446. LmtUsedFlag string `json:"lmt_used_flag"`
  21447. MedChrgitmType string `json:"med_chrgitm_type"`
  21448. Memo string `json:"memo"`
  21449. OverlmtAmt float64 `json:"overlmt_amt"`
  21450. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21451. Pric float64 `json:"pric"`
  21452. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21453. SelfpayProp float64 `json:"selfpay_prop"`
  21454. } `json:"result"`
  21455. } `json:"output"`
  21456. RefmsgTime string `json:"refmsg_time"`
  21457. RespondTime string `json:"respond_time"`
  21458. Signtype string `json:"signtype"`
  21459. WarnMsg string `json:"warn_msg"`
  21460. }
  21461. type ResultFour10265 struct {
  21462. Cainfo string `json:"cainfo"`
  21463. ErrMsg string `json:"err_msg"`
  21464. InfRefmsgid string `json:"inf_refmsgid"`
  21465. Infcode string `json:"infcode"`
  21466. Output struct {
  21467. Result []struct {
  21468. BasMednFlag string `json:"bas_medn_flag"`
  21469. ChldMedcFlag string `json:"chld_medc_flag"`
  21470. ChrgitmLv string `json:"chrgitm_lv"`
  21471. Cnt float64 `json:"cnt"`
  21472. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21473. DrtReimFlag string `json:"drt_reim_flag"`
  21474. FeedetlSn string `json:"feedetl_sn"`
  21475. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21476. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21477. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21478. ListSpItemFlag string `json:"list_sp_item_flag"`
  21479. LmtUsedFlag string `json:"lmt_used_flag"`
  21480. MedChrgitmType string `json:"med_chrgitm_type"`
  21481. Memo string `json:"memo"`
  21482. OverlmtAmt float64 `json:"overlmt_amt"`
  21483. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21484. Pric float64 `json:"pric"`
  21485. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21486. SelfpayProp float64 `json:"selfpay_prop"`
  21487. } `json:"result"`
  21488. } `json:"output"`
  21489. RefmsgTime string `json:"refmsg_time"`
  21490. RespondTime string `json:"respond_time"`
  21491. Signtype string `json:"signtype"`
  21492. WarnMsg string `json:"warn_msg"`
  21493. }
  21494. type ResultMemo struct {
  21495. InsuAdmdvs string `json:"insuAdmdvs"`
  21496. }
  21497. // [{"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}]
  21498. type ResultIDInfo struct {
  21499. Begntime string `json:"begntime"`
  21500. Endtime string `json:"endtime"`
  21501. Memo string `json:"memo"`
  21502. }
  21503. type ResultFive struct {
  21504. Balc float64 `json:"balc"`
  21505. CvlservFlag string `json:"cvlserv_flag"`
  21506. EmpName string `json:"emp_name"`
  21507. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21508. Insutype string `json:"insutype"`
  21509. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21510. PausInsuDate string `json:"paus_insu_date"`
  21511. PsnInsuDate string `json:"psn_insu_date"`
  21512. PsnInsuStas string `json:"psn_insu_stas"`
  21513. PsnType string `json:"psn_type"`
  21514. }
  21515. type ResultSix struct {
  21516. Cainfo interface{} `json:"cainfo"`
  21517. ErrMsg string `json:"err_msg"`
  21518. InfRefmsgid string `json:"inf_refmsgid"`
  21519. Infcode int64 `json:"infcode"`
  21520. Output struct {
  21521. } `json:"output"`
  21522. RefmsgTime string `json:"refmsg_time"`
  21523. RespondTime string `json:"respond_time"`
  21524. Signtype interface{} `json:"signtype"`
  21525. WarnMsg interface{} `json:"warn_msg"`
  21526. }
  21527. type FJ3507Result struct {
  21528. Cainfo interface{} `json:"cainfo"`
  21529. ErrMsg string `json:"err_msg"`
  21530. InfRefmsgid string `json:"inf_refmsgid"`
  21531. Infcode int64 `json:"infcode"`
  21532. Output struct {
  21533. retRslt string `json:"retRslt"`
  21534. msgRslt string `json:"msgRslt"`
  21535. } `json:"output"`
  21536. RefmsgTime string `json:"refmsg_time"`
  21537. RespondTime string `json:"respond_time"`
  21538. Signtype interface{} `json:"signtype"`
  21539. WarnMsg interface{} `json:"warn_msg"`
  21540. }
  21541. type FJ3507ResultFor10188 struct {
  21542. Cainfo interface{} `json:"cainfo"`
  21543. ErrMsg string `json:"err_msg"`
  21544. InfRefmsgid string `json:"inf_refmsgid"`
  21545. Infcode string `json:"infcode"`
  21546. RefmsgTime string `json:"refmsg_time"`
  21547. RespondTime string `json:"respond_time"`
  21548. Signtype interface{} `json:"signtype"`
  21549. WarnMsg interface{} `json:"warn_msg"`
  21550. }
  21551. type Result2406 struct {
  21552. Cainfo interface{} `json:"cainfo"`
  21553. ErrMsg string `json:"err_msg"`
  21554. InfRefmsgid string `json:"inf_refmsgid"`
  21555. Infcode int64 `json:"infcode"`
  21556. Output struct {
  21557. Result struct {
  21558. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21559. } `json:"result"`
  21560. } `json:"output"`
  21561. RefmsgTime string `json:"refmsg_time"`
  21562. RespondTime string `json:"respond_time"`
  21563. Signtype interface{} `json:"signtype"`
  21564. WarnMsg interface{} `json:"warn_msg"`
  21565. }
  21566. type GZResultSix struct {
  21567. Cainfo interface{} `json:"cainfo"`
  21568. ErrMsg string `json:"err_msg"`
  21569. InfRefmsgid string `json:"inf_refmsgid"`
  21570. Infcode int64 `json:"infcode"`
  21571. Output string `json:"output"`
  21572. RefmsgTime string `json:"refmsg_time"`
  21573. RespondTime string `json:"respond_time"`
  21574. Signtype interface{} `json:"signtype"`
  21575. WarnMsg interface{} `json:"warn_msg"`
  21576. }
  21577. type ResultSix10265 struct {
  21578. Cainfo interface{} `json:"cainfo"`
  21579. ErrMsg string `json:"err_msg"`
  21580. InfRefmsgid string `json:"inf_refmsgid"`
  21581. Infcode string `json:"infcode"`
  21582. Output struct {
  21583. } `json:"output"`
  21584. RefmsgTime string `json:"refmsg_time"`
  21585. RespondTime string `json:"respond_time"`
  21586. Signtype interface{} `json:"signtype"`
  21587. WarnMsg interface{} `json:"warn_msg"`
  21588. }
  21589. type ResultSeven struct {
  21590. Cainfo string `json:"cainfo"`
  21591. ErrMsg string `json:"err_msg"`
  21592. InfRefmsgid string `json:"inf_refmsgid"`
  21593. Infcode int64 `json:"infcode"`
  21594. Output struct {
  21595. Setlinfo struct {
  21596. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21597. AcctPay float64 `json:"acct_pay"`
  21598. ActPayDedc float64 `json:"act_pay_dedc"`
  21599. Age float64 `json:"age"`
  21600. Balc float64 `json:"balc"`
  21601. Certno string `json:"certno"`
  21602. ClrOptins string `json:"clr_optins"`
  21603. ClrType string `json:"clr_type"`
  21604. ClrWay string `json:"clr_way"`
  21605. CvlservFlag string `json:"cvlserv_flag"`
  21606. CvlservPay float64 `json:"cvlserv_pay"`
  21607. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21608. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21609. Gend string `json:"gend"`
  21610. HifesPay float64 `json:"hifes_pay"`
  21611. HifmiPay float64 `json:"hifmi_pay"`
  21612. HifpPay float64 `json:"hifp_pay"`
  21613. HospPartAmt float64 `json:"hosp_part_amt"`
  21614. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21615. Insutype string `json:"insutype"`
  21616. MafPay float64 `json:"maf_pay"`
  21617. MdtrtCertType string `json:"mdtrt_cert_type"`
  21618. HifobPay float64 `json:"hifob_pay"`
  21619. MdtrtID string `json:"mdtrt_id"`
  21620. MedType string `json:"med_type"`
  21621. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21622. MedinsSetlID string `json:"medins_setl_id"`
  21623. Naty string `json:"naty"`
  21624. OthPay float64 `json:"oth_pay"`
  21625. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21626. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21627. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21628. PsnCashPay float64 `json:"psn_cash_pay"`
  21629. PsnCertType string `json:"psn_cert_type"`
  21630. PsnName string `json:"psn_name"`
  21631. PsnNo string `json:"psn_no"`
  21632. PsnPartAmt float64 `json:"psn_part_amt"`
  21633. PsnType string `json:"psn_type"`
  21634. SetlID string `json:"setl_id"`
  21635. SetlTime string `json:"setl_time"`
  21636. } `json:"setlinfo"`
  21637. Setldetail interface{} `json:"setldetail"`
  21638. } `json:"output"`
  21639. RefmsgTime string `json:"refmsg_time"`
  21640. RespondTime string `json:"respond_time"`
  21641. Signtype interface{} `json:"signtype"`
  21642. WarnMsg interface{} `json:"warn_msg"`
  21643. }
  21644. type ResultSevenAH struct {
  21645. Cainfo string `json:"cainfo"`
  21646. ErrMsg string `json:"err_msg"`
  21647. InfRefmsgid string `json:"inf_refmsgid"`
  21648. Infcode int64 `json:"infcode"`
  21649. Output struct {
  21650. Setlinfo struct {
  21651. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21652. AcctPay float64 `json:"acct_pay"`
  21653. ActPayDedc float64 `json:"act_pay_dedc"`
  21654. Age float64 `json:"age"`
  21655. Balc float64 `json:"balc"`
  21656. Certno string `json:"certno"`
  21657. ClrOptins string `json:"clr_optins"`
  21658. ClrType string `json:"clr_type"`
  21659. ClrWay string `json:"clr_way"`
  21660. CvlservFlag string `json:"cvlserv_flag"`
  21661. CvlservPay float64 `json:"cvlserv_pay"`
  21662. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21663. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21664. Gend string `json:"gend"`
  21665. HifesPay float64 `json:"hifes_pay"`
  21666. HifmiPay float64 `json:"hifmi_pay"`
  21667. HifpPay float64 `json:"hifp_pay"`
  21668. HospPartAmt float64 `json:"hosp_part_amt"`
  21669. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21670. Insutype string `json:"insutype"`
  21671. MafPay float64 `json:"maf_pay"`
  21672. MdtrtCertType string `json:"mdtrt_cert_type"`
  21673. HifobPay float64 `json:"hifob_pay"`
  21674. MdtrtID string `json:"mdtrt_id"`
  21675. MedType string `json:"med_type"`
  21676. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21677. MedinsSetlID string `json:"medins_setl_id"`
  21678. Naty string `json:"naty"`
  21679. OthPay float64 `json:"oth_pay"`
  21680. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21681. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21682. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21683. PsnCashPay float64 `json:"psn_cash_pay"`
  21684. PsnCertType string `json:"psn_cert_type"`
  21685. PsnName string `json:"psn_name"`
  21686. PsnNo string `json:"psn_no"`
  21687. PsnPartAmt float64 `json:"psn_part_amt"`
  21688. PsnType string `json:"psn_type"`
  21689. SetlID string `json:"setl_id"`
  21690. SetlTime int64 `json:"setl_time"`
  21691. } `json:"setlinfo"`
  21692. Setldetail interface{} `json:"setldetail"`
  21693. } `json:"output"`
  21694. RefmsgTime string `json:"refmsg_time"`
  21695. RespondTime string `json:"respond_time"`
  21696. Signtype interface{} `json:"signtype"`
  21697. WarnMsg interface{} `json:"warn_msg"`
  21698. }
  21699. type ResultSeven10265 struct {
  21700. Cainfo string `json:"cainfo"`
  21701. ErrMsg string `json:"err_msg"`
  21702. InfRefmsgid string `json:"inf_refmsgid"`
  21703. Infcode string `json:"infcode"`
  21704. Output struct {
  21705. Setlinfo struct {
  21706. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21707. AcctPay float64 `json:"acct_pay"`
  21708. ActPayDedc float64 `json:"act_pay_dedc"`
  21709. Age float64 `json:"age"`
  21710. Balc float64 `json:"balc"`
  21711. Certno string `json:"certno"`
  21712. ClrOptins string `json:"clr_optins"`
  21713. ClrType string `json:"clr_type"`
  21714. ClrWay string `json:"clr_way"`
  21715. CvlservFlag string `json:"cvlserv_flag"`
  21716. CvlservPay float64 `json:"cvlserv_pay"`
  21717. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21718. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21719. Gend string `json:"gend"`
  21720. HifesPay float64 `json:"hifes_pay"`
  21721. HifmiPay float64 `json:"hifmi_pay"`
  21722. HifpPay float64 `json:"hifp_pay"`
  21723. HospPartAmt float64 `json:"hosp_part_amt"`
  21724. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21725. Insutype string `json:"insutype"`
  21726. MafPay float64 `json:"maf_pay"`
  21727. MdtrtCertType string `json:"mdtrt_cert_type"`
  21728. HifobPay float64 `json:"hifob_pay"`
  21729. MdtrtID string `json:"mdtrt_id"`
  21730. MedType string `json:"med_type"`
  21731. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21732. MedinsSetlID string `json:"medins_setl_id"`
  21733. Naty string `json:"naty"`
  21734. OthPay float64 `json:"oth_pay"`
  21735. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21736. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21737. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21738. PsnCashPay float64 `json:"psn_cash_pay"`
  21739. PsnCertType string `json:"psn_cert_type"`
  21740. PsnName string `json:"psn_name"`
  21741. PsnNo string `json:"psn_no"`
  21742. PsnPartAmt float64 `json:"psn_part_amt"`
  21743. PsnType string `json:"psn_type"`
  21744. SetlID string `json:"setl_id"`
  21745. SetlTime string `json:"setl_time"`
  21746. } `json:"setlinfo"`
  21747. Setldetail interface{} `json:"setldetail"`
  21748. } `json:"output"`
  21749. RefmsgTime string `json:"refmsg_time"`
  21750. RespondTime string `json:"respond_time"`
  21751. Signtype interface{} `json:"signtype"`
  21752. WarnMsg interface{} `json:"warn_msg"`
  21753. }
  21754. type ResultSeven10265Two struct {
  21755. Cainfo string `json:"cainfo"`
  21756. ErrMsg string `json:"err_msg"`
  21757. InfRefmsgid string `json:"inf_refmsgid"`
  21758. Infcode string `json:"infcode"`
  21759. Output struct {
  21760. Setlinfo struct {
  21761. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21762. AcctPay float64 `json:"acct_pay"`
  21763. ActPayDedc float64 `json:"act_pay_dedc"`
  21764. Age float64 `json:"age"`
  21765. Balc float64 `json:"balc"`
  21766. Certno string `json:"certno"`
  21767. ClrOptins string `json:"clr_optins"`
  21768. ClrType string `json:"clr_type"`
  21769. ClrWay string `json:"clr_way"`
  21770. CvlservFlag string `json:"cvlserv_flag"`
  21771. CvlservPay float64 `json:"cvlserv_pay"`
  21772. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21773. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21774. Gend string `json:"gend"`
  21775. HifesPay float64 `json:"hifes_pay"`
  21776. HifmiPay float64 `json:"hifmi_pay"`
  21777. HifpPay float64 `json:"hifp_pay"`
  21778. HospPartAmt string `json:"hosp_part_amt"`
  21779. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21780. Insutype string `json:"insutype"`
  21781. MafPay float64 `json:"maf_pay"`
  21782. MdtrtCertType string `json:"mdtrt_cert_type"`
  21783. HifobPay float64 `json:"hifob_pay"`
  21784. MdtrtID string `json:"mdtrt_id"`
  21785. MedType string `json:"med_type"`
  21786. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21787. MedinsSetlID string `json:"medins_setl_id"`
  21788. Naty string `json:"naty"`
  21789. OthPay float64 `json:"oth_pay"`
  21790. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21791. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21792. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21793. PsnCashPay float64 `json:"psn_cash_pay"`
  21794. PsnCertType string `json:"psn_cert_type"`
  21795. PsnName string `json:"psn_name"`
  21796. PsnNo string `json:"psn_no"`
  21797. PsnPartAmt float64 `json:"psn_part_amt"`
  21798. PsnType string `json:"psn_type"`
  21799. SetlID string `json:"setl_id"`
  21800. SetlTime string `json:"setl_time"`
  21801. } `json:"setlinfo"`
  21802. Setldetail interface{} `json:"setldetail"`
  21803. } `json:"output"`
  21804. RefmsgTime string `json:"refmsg_time"`
  21805. RespondTime string `json:"respond_time"`
  21806. Signtype interface{} `json:"signtype"`
  21807. WarnMsg interface{} `json:"warn_msg"`
  21808. }
  21809. type GZResultSeven10265Two struct {
  21810. Cainfo string `json:"cainfo"`
  21811. ErrMsg string `json:"err_msg"`
  21812. InfRefmsgid string `json:"inf_refmsgid"`
  21813. Infcode int64 `json:"infcode"`
  21814. Output struct {
  21815. Setlinfo struct {
  21816. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21817. AcctPay float64 `json:"acct_pay"`
  21818. ActPayDedc float64 `json:"act_pay_dedc"`
  21819. Age float64 `json:"age"`
  21820. Balc float64 `json:"balc"`
  21821. Certno string `json:"certno"`
  21822. ClrOptins string `json:"clr_optins"`
  21823. ClrType string `json:"clr_type"`
  21824. ClrWay string `json:"clr_way"`
  21825. CvlservFlag string `json:"cvlserv_flag"`
  21826. CvlservPay float64 `json:"cvlserv_pay"`
  21827. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21828. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21829. Gend string `json:"gend"`
  21830. HifesPay float64 `json:"hifes_pay"`
  21831. HifmiPay float64 `json:"hifmi_pay"`
  21832. HifpPay float64 `json:"hifp_pay"`
  21833. HospPartAmt float64 `json:"hosp_part_amt"`
  21834. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21835. Insutype string `json:"insutype"`
  21836. MafPay float64 `json:"maf_pay"`
  21837. MdtrtCertType string `json:"mdtrt_cert_type"`
  21838. HifobPay float64 `json:"hifob_pay"`
  21839. MdtrtID string `json:"mdtrt_id"`
  21840. MedType string `json:"med_type"`
  21841. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21842. MedinsSetlID string `json:"medins_setl_id"`
  21843. Naty string `json:"naty"`
  21844. OthPay float64 `json:"oth_pay"`
  21845. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21846. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21847. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21848. PsnCashPay float64 `json:"psn_cash_pay"`
  21849. PsnCertType string `json:"psn_cert_type"`
  21850. PsnName string `json:"psn_name"`
  21851. PsnNo string `json:"psn_no"`
  21852. PsnPartAmt float64 `json:"psn_part_amt"`
  21853. PsnType string `json:"psn_type"`
  21854. SetlID string `json:"setl_id"`
  21855. SetlTime string `json:"setl_time"`
  21856. } `json:"setlinfo"`
  21857. Setldetail interface{} `json:"setldetail"`
  21858. } `json:"output"`
  21859. RefmsgTime string `json:"refmsg_time"`
  21860. RespondTime string `json:"respond_time"`
  21861. Signtype interface{} `json:"signtype"`
  21862. WarnMsg interface{} `json:"warn_msg"`
  21863. }
  21864. type ResultEight struct {
  21865. Cainfo string `json:"cainfo"`
  21866. ErrMsg string `json:"err_msg"`
  21867. InfRefmsgid string `json:"inf_refmsgid"`
  21868. Infcode int64 `json:"infcode"`
  21869. Output struct {
  21870. Stmtinfo struct {
  21871. SetlOptins string `json:"setl_optins"`
  21872. StmtRslt string `json:"stmt_rslt"`
  21873. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21874. } `json:"stmtinfo"`
  21875. } `json:"output"`
  21876. RefmsgTime string `json:"refmsg_time"`
  21877. RespondTime string `json:"respond_time"`
  21878. Signtype interface{} `json:"signtype"`
  21879. WarnMsg interface{} `json:"warn_msg"`
  21880. }
  21881. type ResultEightFor10188 struct {
  21882. Cainfo string `json:"cainfo"`
  21883. ErrMsg string `json:"err_msg"`
  21884. InfRefmsgid string `json:"inf_refmsgid"`
  21885. Infcode string `json:"infcode"`
  21886. Output struct {
  21887. Stmtinfo struct {
  21888. SetlOptins string `json:"setl_optins"`
  21889. StmtRslt string `json:"stmt_rslt"`
  21890. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21891. } `json:"stmtinfo"`
  21892. } `json:"output"`
  21893. RefmsgTime string `json:"refmsg_time"`
  21894. RespondTime string `json:"respond_time"`
  21895. Signtype interface{} `json:"signtype"`
  21896. WarnMsg interface{} `json:"warn_msg"`
  21897. }
  21898. type ResultNine struct {
  21899. Cainfo string `json:"cainfo"`
  21900. ErrMsg string `json:"err_msg"`
  21901. InfRefmsgid string `json:"inf_refmsgid"`
  21902. Infcode int64 `json:"infcode"`
  21903. Output struct {
  21904. FileQuryNo string `json:"file_qury_no"`
  21905. } `json:"output"`
  21906. RefmsgTime string `json:"refmsg_time"`
  21907. RespondTime string `json:"respond_time"`
  21908. Signtype interface{} `json:"signtype"`
  21909. WarnMsg interface{} `json:"warn_msg"`
  21910. }
  21911. type ResultTen struct {
  21912. Cainfo string `json:"cainfo"`
  21913. ErrMsg string `json:"err_msg"`
  21914. InfRefmsgid string `json:"inf_refmsgid"`
  21915. Infcode int64 `json:"infcode"`
  21916. Output struct {
  21917. Fileinfo struct {
  21918. DldEndtime string `json:"dld_endtime"`
  21919. FileQuryNo string `json:"file_qury_no"`
  21920. Filename string `json:"filename"`
  21921. } `json:"fileinfo"`
  21922. } `json:"output"`
  21923. RefmsgTime string `json:"refmsg_time"`
  21924. RespondTime string `json:"respond_time"`
  21925. Signtype interface{} `json:"signtype"`
  21926. WarnMsg interface{} `json:"warn_msg"`
  21927. }
  21928. type Result5262 struct {
  21929. ErrMsg string `json:"err_msg"`
  21930. InfRefmsgid string `json:"inf_refmsgid"`
  21931. Infcode int64 `json:"infcode"`
  21932. Output struct {
  21933. PageInfo struct {
  21934. Size int `json:"size"`
  21935. RecordCounts int `json:"record_counts"`
  21936. } `json:"page_info"`
  21937. Idetinfo []interface{} `json:"idetinfo"`
  21938. Result []struct {
  21939. SetlID string `json:"setl_id"`
  21940. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21941. MdtrtID string `json:"mdtrt_id"`
  21942. InitSetlID string `json:"init_setl_id,omitempty"`
  21943. PsnNo string `json:"psn_no"`
  21944. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21945. PsnName string `json:"psn_name"`
  21946. PsnCertType string `json:"psn_cert_type"`
  21947. Certno string `json:"certno"`
  21948. Gend string `json:"gend,omitempty"`
  21949. Naty string `json:"naty,omitempty"`
  21950. Brdy string `json:"brdy,omitempty"`
  21951. Age float64 `json:"age,omitempty"`
  21952. Insutype string `json:"insutype,omitempty"`
  21953. PsnType string `json:"psn_type"`
  21954. CvlservFlag string `json:"cvlserv_flag"`
  21955. CvlservLv string `json:"cvlserv_lv,omitempty"`
  21956. SpPsnType string `json:"sp_psn_type,omitempty"`
  21957. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  21958. ClctGrde string `json:"clct_grde,omitempty"`
  21959. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  21960. NwbFlag string `json:"nwb_flag,omitempty"`
  21961. InsuAdmdvs string `json:"insu_admdvs"`
  21962. EmpNo string `json:"emp_no,omitempty"`
  21963. EmpName string `json:"emp_name,omitempty"`
  21964. EmpType string `json:"emp_type,omitempty"`
  21965. EconType string `json:"econ_type,omitempty"`
  21966. AfilIndu string `json:"afil_indu,omitempty"`
  21967. AfilRlts string `json:"afil_rlts,omitempty"`
  21968. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  21969. PayLoc string `json:"pay_loc,omitempty"`
  21970. FixmedinsCode string `json:"fixmedins_code"`
  21971. FixmedinsName string `json:"fixmedins_name"`
  21972. HospLv string `json:"hosp_lv,omitempty"`
  21973. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  21974. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  21975. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  21976. Begndate string `json:"begndate"`
  21977. Enddate string `json:"enddate"`
  21978. SetlTime string `json:"setl_time"`
  21979. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  21980. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  21981. MedType string `json:"med_type"`
  21982. SetlType string `json:"setl_type,omitempty"`
  21983. ClrType string `json:"clr_type,omitempty"`
  21984. ClrWay string `json:"clr_way,omitempty"`
  21985. PsnSetlway string `json:"psn_setlway,omitempty"`
  21986. ClrOptins string `json:"clr_optins,omitempty"`
  21987. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  21988. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  21989. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  21990. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  21991. InscpAmt float64 `json:"inscp_amt,omitempty"`
  21992. DedcStd float64 `json:"dedc_std,omitempty"`
  21993. CrtDedc float64 `json:"crt_dedc,omitempty"`
  21994. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  21995. HifpPay float64 `json:"hifp_pay,omitempty"`
  21996. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  21997. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  21998. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  21999. HifesPay float64 `json:"hifes_pay,omitempty"`
  22000. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22001. HifobPay float64 `json:"hifob_pay,omitempty"`
  22002. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22003. MafPay float64 `json:"maf_pay,omitempty"`
  22004. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22005. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22006. PsnPay float64 `json:"psn_pay,omitempty"`
  22007. AcctPay float64 `json:"acct_pay,omitempty"`
  22008. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22009. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22010. Balc float64 `json:"balc,omitempty"`
  22011. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22012. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22013. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22014. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22015. Year string `json:"year,omitempty"`
  22016. DiseNo string `json:"dise_no,omitempty"`
  22017. DiseName string `json:"dise_name,omitempty"`
  22018. Invono string `json:"invono,omitempty"`
  22019. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22020. ValiFlag string `json:"vali_flag,omitempty"`
  22021. Memo string `json:"memo,omitempty"`
  22022. Rid string `json:"rid"`
  22023. UpdtTime string `json:"updt_time,omitempty"`
  22024. CrterID string `json:"crter_id,omitempty"`
  22025. CrterName string `json:"crter_name,omitempty"`
  22026. CrteTime string `json:"crte_time,omitempty"`
  22027. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22028. OpterID string `json:"opter_id,omitempty"`
  22029. OpterName string `json:"opter_name,omitempty"`
  22030. OptTime string `json:"opt_time,omitempty"`
  22031. OptinsNo string `json:"optins_no,omitempty"`
  22032. PoolareaNo string `json:"poolarea_no,omitempty"`
  22033. } `json:"result"`
  22034. } `json:"output"`
  22035. RefmsgTime string `json:"refmsg_time"`
  22036. RespondTime string `json:"respond_time"`
  22037. Signtype interface{} `json:"signtype"`
  22038. WarnInfo interface{} `json:"warn_info"`
  22039. }
  22040. type Result5267 struct {
  22041. ErrMsg string `json:"err_msg"`
  22042. InfRefmsgid string `json:"inf_refmsgid"`
  22043. Infcode int64 `json:"infcode"`
  22044. Output struct {
  22045. PageInfo struct {
  22046. Size int `json:"size"`
  22047. RecordCounts int `json:"record_counts"`
  22048. } `json:"pageinfo"`
  22049. Result []struct {
  22050. SetlID string `json:"setl_id"`
  22051. ClrOptins string `json:"clr_optins"`
  22052. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22053. MdtrtID string `json:"mdtrt_id"`
  22054. InitSetlID string `json:"init_setl_id,omitempty"`
  22055. PsnNo string `json:"psn_no"`
  22056. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22057. PsnName string `json:"psn_name"`
  22058. PsnCertType string `json:"psn_cert_type"`
  22059. Certno string `json:"certno"`
  22060. Gend string `json:"gend,omitempty"`
  22061. Naty string `json:"naty,omitempty"`
  22062. Brdy string `json:"brdy,omitempty"`
  22063. Age float64 `json:"age,omitempty"`
  22064. Insutype string `json:"insutype,omitempty"`
  22065. PsnType string `json:"psn_type"`
  22066. CvlservFlag string `json:"cvlserv_flag"`
  22067. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22068. SpPsnType string `json:"sp_psn_type,omitempty"`
  22069. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22070. ClctGrde string `json:"clct_grde,omitempty"`
  22071. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22072. NwbFlag string `json:"nwb_flag,omitempty"`
  22073. InsuAdmdvs string `json:"insu_admdvs"`
  22074. EmpNo string `json:"emp_no,omitempty"`
  22075. EmpName string `json:"emp_name,omitempty"`
  22076. EmpType string `json:"emp_type,omitempty"`
  22077. EconType string `json:"econ_type,omitempty"`
  22078. AfilIndu string `json:"afil_indu,omitempty"`
  22079. AfilRlts string `json:"afil_rlts,omitempty"`
  22080. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22081. PayLoc string `json:"pay_loc,omitempty"`
  22082. FixmedinsCode string `json:"fixmedins_code"`
  22083. FixmedinsName string `json:"fixmedins_name"`
  22084. HospLv string `json:"hosp_lv,omitempty"`
  22085. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22086. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22087. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22088. Begndate string `json:"begndate,omitempty"`
  22089. Enddate string `json:"enddate,omitempty"`
  22090. SetlTime string `json:"setl_time,omitempty"`
  22091. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22092. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22093. MedType string `json:"med_type"`
  22094. SetlType string `json:"setl_type,omitempty"`
  22095. ClrType string `json:"clr_type,omitempty"`
  22096. ClrWay string `json:"clr_way,omitempty"`
  22097. PsnSetlway string `json:"psn_setlway,omitempty"`
  22098. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22099. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22100. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22101. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22102. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22103. DedcStd float64 `json:"dedc_std,omitempty"`
  22104. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22105. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22106. HifpPay float64 `json:"hifp_pay,omitempty"`
  22107. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22108. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22109. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22110. HifesPay float64 `json:"hifes_pay,omitempty"`
  22111. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22112. HifobPay float64 `json:"hifob_pay,omitempty"`
  22113. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22114. MafPay float64 `json:"maf_pay,omitempty"`
  22115. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22116. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22117. PsnPay float64 `json:"psn_pay,omitempty"`
  22118. AcctPay float64 `json:"acct_pay,omitempty"`
  22119. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22120. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22121. Balc float64 `json:"balc,omitempty"`
  22122. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22123. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22124. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22125. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22126. Year string `json:"year,omitempty"`
  22127. DiseNo string `json:"dise_no,omitempty"`
  22128. DiseName string `json:"dise_name,omitempty"`
  22129. Invono string `json:"invono,omitempty"`
  22130. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22131. Memo string `json:"memo,omitempty"`
  22132. UpdtTime string `json:"updt_time,omitempty"`
  22133. OpterID string `json:"opter_id,omitempty"`
  22134. OpterName string `json:"opter_name,omitempty"`
  22135. OptTime string `json:"opt_time,omitempty"`
  22136. OptinsNo string `json:"optins_no,omitempty"`
  22137. PoolareaNo string `json:"poolarea_no,omitempty"`
  22138. } `json:"result"`
  22139. } `json:"output"`
  22140. RefmsgTime string `json:"refmsg_time"`
  22141. RespondTime string `json:"respond_time"`
  22142. Signtype interface{} `json:"signtype"`
  22143. WarnInfo interface{} `json:"warn_info"`
  22144. }
  22145. // type Autogenerated struct {
  22146. // Output struct {
  22147. // Setlinfo struct {
  22148. // SetlTime string `json:"setl_time"`
  22149. // CvlservPay float64 `json:"cvlserv_pay"`
  22150. // Year string `json:"year"`
  22151. // MedType string `json:"med_type"`
  22152. // PsnPay float64 `json:"psn_pay"`
  22153. // OpterID string `json:"opter_id"`
  22154. // Begndate string `json:"begndate"`
  22155. // FlxempeFlag string `json:"flxempe_flag"`
  22156. // HifmiPay float64 `json:"hifmi_pay"`
  22157. // PsnNo string `json:"psn_no"`
  22158. // ActPayDedc float64 `json:"act_pay_dedc"`
  22159. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22160. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22161. // ClrWay string `json:"clr_way"`
  22162. // OthPay float64 `json:"oth_pay"`
  22163. // Gend string `json:"gend"`
  22164. // MdtrtID string `json:"mdtrt_id"`
  22165. // AcctPay float64 `json:"acct_pay"`
  22166. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22167. // Insutype string `json:"insutype"`
  22168. // Invono interface{} `json:"invono"`
  22169. // Enddate string `json:"enddate"`
  22170. // CashPayamt float64 `json:"cash_payamt"`
  22171. // PsnType string `json:"psn_type"`
  22172. // FixmedinsName string `json:"fixmedins_name"`
  22173. // HifpPay float64 `json:"hifp_pay"`
  22174. // NewFlag interface{} `json:"new_flag"`
  22175. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22176. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22177. // PayLoc string `json:"pay_loc"`
  22178. // ClrType string `json:"clr_type"`
  22179. // RefdSetlFlag string `json:"refd_setl_flag"`
  22180. // CvlservFlag string `json:"cvlserv_flag"`
  22181. // EmpName string `json:"emp_name"`
  22182. // Brdy string `json:"brdy"`
  22183. // Naty string `json:"naty"`
  22184. // Certno string `json:"certno"`
  22185. // DiseCode string `json:"dise_code"`
  22186. // FixmedinsCode string `json:"fixmedins_code"`
  22187. // DedcHospLv string `json:"dedc_hosp_lv"`
  22188. // OpterName string `json:"opter_name"`
  22189. // Balc float64 `json:"balc"`
  22190. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22191. // PsnCertType string `json:"psn_cert_type"`
  22192. // HifobPay float64 `json:"hifob_pay"`
  22193. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22194. // HifesPay float64 `json:"hifes_pay"`
  22195. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22196. // OptTime string `json:"opt_time"`
  22197. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22198. // SetlID string `json:"setl_id"`
  22199. // MafPay float64 `json:"maf_pay"`
  22200. // PsnName string `json:"psn_name"`
  22201. // InsuOptins interface{} `json:"insu_optins"`
  22202. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22203. // ClrOptins string `json:"clr_optins"`
  22204. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22205. // DiseName string `json:"dise_name"`
  22206. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22207. // Age float64 `json:"age"`
  22208. // DtrtCertType string `json:"dtrt_cert_type"`
  22209. // HospLv string `json:"hosp_lv"`
  22210. // } `json:"setlinfo"`
  22211. // Setldetail []struct {
  22212. // FundPayType string `json:"fund_pay_type"`
  22213. // FundPayamt float64 `json:"fund_payamt"`
  22214. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22215. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22216. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22217. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22218. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22219. // } `json:"setldetail"`
  22220. // } `json:"output"`
  22221. // Infcode int `json:"infcode"`
  22222. // WarnMsg interface{} `json:"warn_msg"`
  22223. // Cainfo interface{} `json:"cainfo"`
  22224. // ErrMsg interface{} `json:"err_msg"`
  22225. // RefmsgTime string `json:"refmsg_time"`
  22226. // Signtype interface{} `json:"signtype"`
  22227. // RespondTime string `json:"respond_time"`
  22228. // InfRefmsgid string `json:"inf_refmsgid"`
  22229. // }
  22230. type Result002 struct {
  22231. Cainfo interface{} `json:"cainfo"`
  22232. ErrMsg string `json:"err_msg"`
  22233. InfRefmsgid string `json:"inf_refmsgid"`
  22234. Infcode int64 `json:"infcode"`
  22235. Output struct {
  22236. RxFile string `json:"rx_file"`
  22237. SignDigest string `json:"sign_digest"`
  22238. SignCertSn string `json:"sign_cert_sn"`
  22239. SignCertDn string `json:"sign_cert_dn"`
  22240. } `json:"output"`
  22241. RefmsgTime string `json:"refmsg_time"`
  22242. RespondTime string `json:"respond_time"`
  22243. Signtype interface{} `json:"signtype"`
  22244. WarnMsg interface{} `json:"warn_msg"`
  22245. }
  22246. type Result003 struct {
  22247. Cainfo interface{} `json:"cainfo"`
  22248. ErrMsg string `json:"err_msg"`
  22249. InfRefmsgid string `json:"inf_refmsgid"`
  22250. Infcode int64 `json:"infcode"`
  22251. Output struct {
  22252. HiRxno string `json:"hi_rxno"`
  22253. RxStasCodg string `json:"rx_stas_codg"`
  22254. RxStasName string `json:"rx_stas_name"`
  22255. } `json:"output"`
  22256. RefmsgTime string `json:"refmsg_time"`
  22257. RespondTime string `json:"respond_time"`
  22258. Signtype interface{} `json:"signtype"`
  22259. WarnMsg interface{} `json:"warn_msg"`
  22260. }
  22261. type ResultEleven struct {
  22262. Cainfo string `json:"cainfo"`
  22263. ErrMsg string `json:"err_msg"`
  22264. InfRefmsgid string `json:"inf_refmsgid"`
  22265. Infcode int64 `json:"infcode"`
  22266. Output struct {
  22267. Setlinfo struct {
  22268. SetlTime string `json:"setl_time"`
  22269. CvlservPay float64 `json:"cvlserv_pay"`
  22270. Year string `json:"year"`
  22271. MedType string `json:"med_type"`
  22272. PsnPay float64 `json:"psn_pay"`
  22273. OpterID string `json:"opter_id"`
  22274. Begndate string `json:"begndate"`
  22275. FlxempeFlag string `json:"flxempe_flag"`
  22276. HifmiPay float64 `json:"hifmi_pay"`
  22277. PsnNo string `json:"psn_no"`
  22278. ActPayDedc float64 `json:"act_pay_dedc"`
  22279. MedinsSetlID interface{} `json:"medins_setl_id"`
  22280. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22281. ClrWay string `json:"clr_way"`
  22282. OthPay float64 `json:"oth_pay"`
  22283. Gend string `json:"gend"`
  22284. MdtrtID string `json:"mdtrt_id"`
  22285. AcctPay float64 `json:"acct_pay"`
  22286. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22287. Insutype string `json:"insutype"`
  22288. Invono interface{} `json:"invono"`
  22289. Enddate string `json:"enddate"`
  22290. CashPayamt float64 `json:"cash_payamt"`
  22291. PsnType string `json:"psn_type"`
  22292. FixmedinsName string `json:"fixmedins_name"`
  22293. HifpPay float64 `json:"hifp_pay"`
  22294. NewFlag interface{} `json:"new_flag"`
  22295. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22296. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22297. PayLoc string `json:"pay_loc"`
  22298. ClrType string `json:"clr_type"`
  22299. RefdSetlFlag string `json:"refd_setl_flag"`
  22300. CvlservFlag string `json:"cvlserv_flag"`
  22301. EmpName string `json:"emp_name"`
  22302. Brdy string `json:"brdy"`
  22303. Naty string `json:"naty"`
  22304. Certno string `json:"certno"`
  22305. DiseCode string `json:"dise_code"`
  22306. FixmedinsCode string `json:"fixmedins_code"`
  22307. DedcHospLv string `json:"dedc_hosp_lv"`
  22308. OpterName string `json:"opter_name"`
  22309. Balc float64 `json:"balc"`
  22310. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22311. PsnCertType string `json:"psn_cert_type"`
  22312. HifobPay float64 `json:"hifob_pay"`
  22313. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22314. HifesPay float64 `json:"hifes_pay"`
  22315. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22316. OptTime string `json:"opt_time"`
  22317. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22318. SetlID string `json:"setl_id"`
  22319. MafPay float64 `json:"maf_pay"`
  22320. PsnName string `json:"psn_name"`
  22321. InsuOptins interface{} `json:"insu_optins"`
  22322. PrefFundPay interface{} `json:"pref_fund_pay"`
  22323. ClrOptins string `json:"clr_optins"`
  22324. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22325. DiseName string `json:"dise_name"`
  22326. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22327. Age float64 `json:"age"`
  22328. DtrtCertType string `json:"dtrt_cert_type"`
  22329. HospLv string `json:"hosp_lv"`
  22330. PsnCashPay float64 `json:"psn_cash_pay"`
  22331. } `json:"setlinfo"`
  22332. } `json:"output"`
  22333. RefmsgTime string `json:"refmsg_time"`
  22334. RespondTime string `json:"respond_time"`
  22335. Signtype interface{} `json:"signtype"`
  22336. WarnMsg interface{} `json:"warn_msg"`
  22337. }
  22338. type ResultElevenah struct {
  22339. Cainfo string `json:"cainfo"`
  22340. ErrMsg string `json:"err_msg"`
  22341. InfRefmsgid string `json:"inf_refmsgid"`
  22342. Infcode int64 `json:"infcode"`
  22343. Output struct {
  22344. Setlinfo struct {
  22345. SetlTime int64 `json:"setl_time"`
  22346. CvlservPay float64 `json:"cvlserv_pay"`
  22347. Year string `json:"year"`
  22348. MedType string `json:"med_type"`
  22349. PsnPay float64 `json:"psn_pay"`
  22350. OpterID string `json:"opter_id"`
  22351. Begndate int64 `json:"begndate"`
  22352. FlxempeFlag string `json:"flxempe_flag"`
  22353. HifmiPay float64 `json:"hifmi_pay"`
  22354. PsnNo string `json:"psn_no"`
  22355. ActPayDedc float64 `json:"act_pay_dedc"`
  22356. MedinsSetlID interface{} `json:"medins_setl_id"`
  22357. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22358. ClrWay string `json:"clr_way"`
  22359. OthPay float64 `json:"oth_pay"`
  22360. Gend string `json:"gend"`
  22361. MdtrtID string `json:"mdtrt_id"`
  22362. AcctPay float64 `json:"acct_pay"`
  22363. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22364. Insutype string `json:"insutype"`
  22365. Invono interface{} `json:"invono"`
  22366. Enddate int64 `json:"enddate"`
  22367. CashPayamt float64 `json:"cash_payamt"`
  22368. PsnType string `json:"psn_type"`
  22369. FixmedinsName string `json:"fixmedins_name"`
  22370. HifpPay float64 `json:"hifp_pay"`
  22371. NewFlag interface{} `json:"new_flag"`
  22372. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22373. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22374. PayLoc string `json:"pay_loc"`
  22375. ClrType string `json:"clr_type"`
  22376. RefdSetlFlag string `json:"refd_setl_flag"`
  22377. CvlservFlag string `json:"cvlserv_flag"`
  22378. EmpName string `json:"emp_name"`
  22379. Brdy int64 `json:"brdy"`
  22380. Naty string `json:"naty"`
  22381. Certno string `json:"certno"`
  22382. DiseCode string `json:"dise_code"`
  22383. FixmedinsCode string `json:"fixmedins_code"`
  22384. DedcHospLv string `json:"dedc_hosp_lv"`
  22385. OpterName string `json:"opter_name"`
  22386. Balc float64 `json:"balc"`
  22387. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22388. PsnCertType string `json:"psn_cert_type"`
  22389. HifobPay float64 `json:"hifob_pay"`
  22390. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22391. HifesPay float64 `json:"hifes_pay"`
  22392. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22393. OptTime int64 `json:"opt_time"`
  22394. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22395. SetlID string `json:"setl_id"`
  22396. MafPay float64 `json:"maf_pay"`
  22397. PsnName string `json:"psn_name"`
  22398. InsuOptins interface{} `json:"insu_optins"`
  22399. PrefFundPay interface{} `json:"pref_fund_pay"`
  22400. ClrOptins string `json:"clr_optins"`
  22401. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22402. DiseName string `json:"dise_name"`
  22403. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22404. Age float64 `json:"age"`
  22405. DtrtCertType string `json:"dtrt_cert_type"`
  22406. HospLv string `json:"hosp_lv"`
  22407. PsnCashPay float64 `json:"psn_cash_pay"`
  22408. } `json:"setlinfo"`
  22409. } `json:"output"`
  22410. RefmsgTime string `json:"refmsg_time"`
  22411. RespondTime string `json:"respond_time"`
  22412. Signtype interface{} `json:"signtype"`
  22413. WarnMsg interface{} `json:"warn_msg"`
  22414. }
  22415. type ResultEleven10265 struct {
  22416. Cainfo string `json:"cainfo"`
  22417. ErrMsg string `json:"err_msg"`
  22418. InfRefmsgid string `json:"inf_refmsgid"`
  22419. Infcode string `json:"infcode"`
  22420. Output struct {
  22421. Setlinfo struct {
  22422. SetlTime string `json:"setl_time"`
  22423. CvlservPay float64 `json:"cvlserv_pay"`
  22424. Year string `json:"year"`
  22425. MedType string `json:"med_type"`
  22426. PsnPay float64 `json:"psn_pay"`
  22427. OpterID string `json:"opter_id"`
  22428. Begndate string `json:"begndate"`
  22429. FlxempeFlag string `json:"flxempe_flag"`
  22430. HifmiPay float64 `json:"hifmi_pay"`
  22431. PsnNo string `json:"psn_no"`
  22432. ActPayDedc float64 `json:"act_pay_dedc"`
  22433. MedinsSetlID interface{} `json:"medins_setl_id"`
  22434. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22435. ClrWay string `json:"clr_way"`
  22436. OthPay float64 `json:"oth_pay"`
  22437. Gend string `json:"gend"`
  22438. MdtrtID string `json:"mdtrt_id"`
  22439. AcctPay float64 `json:"acct_pay"`
  22440. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22441. Insutype string `json:"insutype"`
  22442. Invono interface{} `json:"invono"`
  22443. Enddate string `json:"enddate"`
  22444. CashPayamt float64 `json:"cash_payamt"`
  22445. PsnType string `json:"psn_type"`
  22446. FixmedinsName string `json:"fixmedins_name"`
  22447. HifpPay float64 `json:"hifp_pay"`
  22448. NewFlag interface{} `json:"new_flag"`
  22449. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22450. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22451. PayLoc string `json:"pay_loc"`
  22452. ClrType string `json:"clr_type"`
  22453. RefdSetlFlag string `json:"refd_setl_flag"`
  22454. CvlservFlag string `json:"cvlserv_flag"`
  22455. EmpName string `json:"emp_name"`
  22456. Brdy string `json:"brdy"`
  22457. Naty string `json:"naty"`
  22458. Certno string `json:"certno"`
  22459. DiseCode string `json:"dise_code"`
  22460. FixmedinsCode string `json:"fixmedins_code"`
  22461. DedcHospLv string `json:"dedc_hosp_lv"`
  22462. OpterName string `json:"opter_name"`
  22463. Balc float64 `json:"balc"`
  22464. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22465. PsnCertType string `json:"psn_cert_type"`
  22466. HifobPay float64 `json:"hifob_pay"`
  22467. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22468. HifesPay float64 `json:"hifes_pay"`
  22469. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22470. OptTime string `json:"opt_time"`
  22471. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22472. SetlID string `json:"setl_id"`
  22473. MafPay float64 `json:"maf_pay"`
  22474. PsnName string `json:"psn_name"`
  22475. InsuOptins interface{} `json:"insu_optins"`
  22476. PrefFundPay interface{} `json:"pref_fund_pay"`
  22477. ClrOptins string `json:"clr_optins"`
  22478. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22479. DiseName string `json:"dise_name"`
  22480. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22481. Age float64 `json:"age"`
  22482. DtrtCertType string `json:"dtrt_cert_type"`
  22483. HospLv string `json:"hosp_lv"`
  22484. PsnCashPay float64 `json:"psn_cash_pay"`
  22485. } `json:"setlinfo"`
  22486. } `json:"output"`
  22487. RefmsgTime string `json:"refmsg_time"`
  22488. RespondTime string `json:"respond_time"`
  22489. Signtype interface{} `json:"signtype"`
  22490. WarnMsg interface{} `json:"warn_msg"`
  22491. }
  22492. type ResultTwelve struct {
  22493. Cainfo string `json:"cainfo"`
  22494. ErrMsg string `json:"err_msg"`
  22495. InfRefmsgid string `json:"inf_refmsgid"`
  22496. Infcode int64 `json:"infcode"`
  22497. Output struct {
  22498. MdtrtId string `json:"mdtrt_id"`
  22499. ChrgBchno string `json:"chrg_bchno"`
  22500. PsnNo string `json:"psn_no"`
  22501. } `json:"output"`
  22502. RefmsgTime string `json:"refmsg_time"`
  22503. RespondTime string `json:"respond_time"`
  22504. Signtype interface{} `json:"signtype"`
  22505. WarnMsg interface{} `json:"warn_msg"`
  22506. }
  22507. type ResultThirteen struct {
  22508. ErrMsg string `json:"err_msg"`
  22509. InfRefmsgid string `json:"inf_refmsgid"`
  22510. Infcode int64 `json:"infcode"`
  22511. Output struct {
  22512. Result struct {
  22513. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22514. } `json:"result"`
  22515. } `json:"output"`
  22516. RefmsgTime string `json:"refmsg_time"`
  22517. RespondTime string `json:"respond_time"`
  22518. Signtype interface{} `json:"signtype"`
  22519. WarnInfo interface{} `json:"warn_info"`
  22520. }
  22521. type ResultThirteen10265 struct {
  22522. ErrMsg string `json:"err_msg"`
  22523. InfRefmsgid string `json:"inf_refmsgid"`
  22524. Infcode string `json:"infcode"`
  22525. Output struct {
  22526. Result struct {
  22527. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22528. } `json:"result"`
  22529. } `json:"output"`
  22530. RefmsgTime string `json:"refmsg_time"`
  22531. RespondTime string `json:"respond_time"`
  22532. Signtype interface{} `json:"signtype"`
  22533. WarnInfo interface{} `json:"warn_info"`
  22534. }
  22535. type ResultFourteen struct {
  22536. ErrMsg string `json:"err_msg"`
  22537. InfRefmsgid string `json:"inf_refmsgid"`
  22538. Infcode int64 `json:"infcode"`
  22539. Output struct {
  22540. } `json:"output"`
  22541. RefmsgTime string `json:"refmsg_time"`
  22542. RespondTime string `json:"respond_time"`
  22543. Signtype interface{} `json:"signtype"`
  22544. WarnInfo interface{} `json:"warn_info"`
  22545. }
  22546. type ResultCFYLJG001 struct {
  22547. ErrMsg string `json:"err_msg"`
  22548. InfRefmsgid string `json:"inf_refmsgid"`
  22549. Infcode int64 `json:"infcode"`
  22550. Output struct {
  22551. RxTraceCode string `json:"rx_trace_code"`
  22552. HiRxno string `json:"hi_rxno"`
  22553. } `json:"output"`
  22554. RefmsgTime string `json:"refmsg_time"`
  22555. RespondTime string `json:"respond_time"`
  22556. Signtype interface{} `json:"signtype"`
  22557. WarnInfo interface{} `json:"warn_info"`
  22558. }
  22559. type ResultCFYLJG007 struct {
  22560. ErrMsg string `json:"err_msg"`
  22561. InfRefmsgid string `json:"inf_refmsgid"`
  22562. Infcode int64 `json:"infcode"`
  22563. Output struct {
  22564. HiRxno string `json:"hi_rxno"`
  22565. RxStasName string `json:"rx_stas_name"`
  22566. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22567. Seltdelts []interface{} `json:"seltdelts"`
  22568. RxUsedStasName string `json:"rx_used_stas_name"`
  22569. RxStasCodg string `json:"rx_stas_codg"`
  22570. } `json:"output"`
  22571. RefmsgTime string `json:"refmsg_time"`
  22572. RespondTime string `json:"respond_time"`
  22573. Signtype interface{} `json:"signtype"`
  22574. WarnInfo interface{} `json:"warn_info"`
  22575. }
  22576. type ResultCFYLJG002 struct {
  22577. ErrMsg string `json:"err_msg"`
  22578. InfRefmsgid string `json:"inf_refmsgid"`
  22579. Infcode int64 `json:"infcode"`
  22580. Output struct {
  22581. RxFile string `json:"rx_file"`
  22582. SignDigest string `json:"sign_digest"`
  22583. SignCertSn string `json:"sign_cert_sn"`
  22584. SignCertDn string `json:"sign_cert_dn"`
  22585. } `json:"output"`
  22586. RefmsgTime string `json:"refmsg_time"`
  22587. RespondTime string `json:"respond_time"`
  22588. Signtype interface{} `json:"signtype"`
  22589. WarnInfo interface{} `json:"warn_info"`
  22590. }
  22591. type ResultCFYLJG003 struct {
  22592. ErrMsg string `json:"err_msg"`
  22593. InfRefmsgid string `json:"inf_refmsgid"`
  22594. Infcode int64 `json:"infcode"`
  22595. Output struct {
  22596. HiRxno string `json:"hi_rxno"`
  22597. RxStasCodg string `json:"rx_stas_codg"`
  22598. RxStasName string `json:"rx_stas_name"`
  22599. } `json:"output"`
  22600. RefmsgTime string `json:"refmsg_time"`
  22601. RespondTime string `json:"respond_time"`
  22602. Signtype interface{} `json:"signtype"`
  22603. WarnInfo interface{} `json:"warn_info"`
  22604. }
  22605. type ResultCFYLJG004 struct {
  22606. ErrMsg string `json:"err_msg"`
  22607. InfRefmsgid string `json:"inf_refmsgid"`
  22608. Infcode int64 `json:"infcode"`
  22609. Output struct {
  22610. HiRxno string `json:"hi_rxno"`
  22611. RxStasCodg string `json:"rx_stas_codg"`
  22612. RxStasName string `json:"rx_stas_name"`
  22613. } `json:"output"`
  22614. RefmsgTime string `json:"refmsg_time"`
  22615. RespondTime string `json:"respond_time"`
  22616. Signtype interface{} `json:"signtype"`
  22617. WarnInfo interface{} `json:"warn_info"`
  22618. }
  22619. type ResultCFYLJG008 struct {
  22620. ErrMsg string `json:"err_msg"`
  22621. InfRefmsgid string `json:"inf_refmsgid"`
  22622. Infcode int64 `json:"infcode"`
  22623. Output struct {
  22624. PoolareaNo string `json:"poolareaNo"`
  22625. AdmdvsName string `json:"admdvsName"`
  22626. Count string `json:"count"`
  22627. } `json:"output"`
  22628. RefmsgTime string `json:"refmsg_time"`
  22629. RespondTime string `json:"respond_time"`
  22630. Signtype interface{} `json:"signtype"`
  22631. WarnInfo interface{} `json:"warn_info"`
  22632. }
  22633. type ResultCFYLJG005 struct {
  22634. ErrMsg string `json:"err_msg"`
  22635. InfRefmsgid string `json:"inf_refmsgid"`
  22636. Infcode int64 `json:"infcode"`
  22637. Output struct {
  22638. HiRxNo string `json:"hi_rxno"`
  22639. FixMedinsCode string `json:"fixmedins_code"`
  22640. FixMedinsName string `json:"fixmedins_name"`
  22641. RxStasCodg string `json:"rx_stas_codg"`
  22642. RxStasName string `json:"rx_stas_name"`
  22643. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22644. RxUserdStasName string `json:"rx_userd_stas_name"`
  22645. PrscTime string `json:"prsc_time"`
  22646. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22647. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22648. RxUsedWayName string `json:"rx_used_way_name"`
  22649. RxFrquCodg string `json:"rx_frqu_codg"`
  22650. RxFrquName string `json:"rx_frqu_name"`
  22651. RxDosunt string `json:"rx_dosunt"`
  22652. RxDoscnt float64 `json:"rx_doscnt"`
  22653. RxDrordDscr string `json:"rx_drord_dscr"`
  22654. ValiDays int64 `json:"vali_days"`
  22655. ValiEndTime string `json:"vali_end_time"`
  22656. ReptFlag string `json:"rept_flag"`
  22657. MaxReptCnt int64 `json:"max_rept_cnt"`
  22658. ReptdCnt int64 `json:"reptd_cnt"`
  22659. MinInrvDays int64 `json:"min_inrv_days"`
  22660. RxTypeCode string `json:"rx_type_code"`
  22661. RxTypeName string `json:"rx_type_name"`
  22662. LongRxFlag string `json:"long_rx_flag"`
  22663. RxDetlList []struct {
  22664. MedListCodg string `json:"med_list_codg"`
  22665. MedinsListCodg string `json:"medins_list_codg"`
  22666. HospPrepFlag string `json:"hosp_prep_flag"`
  22667. RxItemTypeCode string `json:"rx_item_type_code"`
  22668. RxItemTypeName string `json:"rx_item_type_name"`
  22669. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22670. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22671. TcmHerbFoote string `json:"tcmherb_foote"`
  22672. MednTypeCode string `json:"medn_type_code"`
  22673. MednTypeName string `json:"medn_type_name"`
  22674. MainMedcFlag string `json:"main_medc_flag"`
  22675. UrgtFlag string `json:"urgt_flag"`
  22676. BasMednFlag string `json:"bas_medn_flag"`
  22677. ImpDrugFlag string `json:"imp_drug_flag"`
  22678. ProdBarc string `json:"prod_barc"`
  22679. DrugProdname string `json:"drug_prodname"`
  22680. GennameCodg string `json:"genname_codg"`
  22681. DrugGenname string `json:"drug_genname"`
  22682. DrugDosform string `json:"drug_dosform"`
  22683. DrugSpec string `json:"drug_spec"`
  22684. PrdrName string `json:"prdr_name"`
  22685. MedcWayCodg string `json:"medc_way_codg"`
  22686. MedcWayDscr string `json:"medc_way_dscr"`
  22687. MedcBegntime string `json:"medc_begntime"`
  22688. MedcEndtime string `json:"medc_endtime"`
  22689. MedcDays float64 `json:"medc_days"`
  22690. DrugPric float64 `json:"drug_pric"`
  22691. DrugSumamt float64 `json:"drug_sumamt"`
  22692. DrugCnt float64 `json:"drug_cnt"`
  22693. DrugDosunt string `json:"drug_dosunt"`
  22694. SinDoscnt float64 `json:"sin_doscnt"`
  22695. SinDosunt string `json:"sin_dosunt"`
  22696. UsedFrquCodg string `json:"used_frqu_codg"`
  22697. UsedFrquName string `json:"used_frqu_name"`
  22698. DrugTotlcnt string `json:"drug_totlcnt"`
  22699. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22700. DiseCodg string `json:"dise_codg"`
  22701. HospApprFlag string `json:"hosp_appr_flag"`
  22702. } `json:"rx_detl_list"`
  22703. RxOtpinfo struct {
  22704. MedType string `json:"med_type"`
  22705. IptOtpNo string `json:"ipt_otp_no"`
  22706. OtpIptFlag string `json:"otp_ipt_flag"`
  22707. PatnName string `json:"patn_name"`
  22708. PatnAge float64 `json:"patn_age"`
  22709. PatnHgt float64 `json:"patn_hgt"`
  22710. PatnWt float64 `json:"patn_wt"`
  22711. Gend string `json:"gend"`
  22712. GesoVal float64 `json:"geso_val"`
  22713. NwbFlag string `json:"nwb_flag"`
  22714. NwbAge string `json:"nwb_age"`
  22715. SuckPrdFlag string `json:"suck_prd_flag"`
  22716. AlgsHis string `json:"algs_his"`
  22717. Insutype string `json:"insutype"`
  22718. PrscDeptName string `json:"prsc_dept_name"`
  22719. PrscDrName string `json:"prsc_dr_name"`
  22720. PharName string `json:"phar_name"`
  22721. PharChkTime string `json:"phar_chk_time"`
  22722. MdtrtTime string `json:"mdtrt_time"`
  22723. DiseCodg string `json:"dise_codg"`
  22724. DiseName string `json:"dise_name"`
  22725. SpDiseFlag string `json:"sp_dise_flag"`
  22726. MaindiagCode string `json:"maindiag_code"`
  22727. MaindiagName string `json:"maindiag_name"`
  22728. DiseCondDscr string `json:"dise_cond_dscr"`
  22729. FstdiagFlag string `json:"fstdiag_flag"`
  22730. } `json:"rx_otpinfo"`
  22731. RxDiseList []struct {
  22732. DiagType string `json:"diag_type"`
  22733. MaindiagFlag string `json:"maindiag_flag"`
  22734. DiagSrtNo string `json:"diag_srt_no"`
  22735. DiagCode string `json:"diag_code"`
  22736. DiagName string `json:"diag_name"`
  22737. DiagDept string `json:"diag_dept"`
  22738. DiagDrNo string `json:"diag_dr_no"`
  22739. DiagDrName string `json:"diag_dr_name"`
  22740. DiagTime string `json:"diag_time"`
  22741. TcmDiseCode string `json:"tcm_dise_code"`
  22742. TcmDiseName string `json:"tcm_dise_name"`
  22743. TcmSympCode string `json:"tcmsymp_code"`
  22744. TcmSymp string `json:"tcmsymp"`
  22745. } `json:"rx_dise_list"`
  22746. } `json:"output"`
  22747. RefmsgTime string `json:"refmsg_time"`
  22748. RespondTime string `json:"respond_time"`
  22749. Signtype interface{} `json:"signtype"`
  22750. WarnInfo interface{} `json:"warn_info"`
  22751. }
  22752. type ResultCFYLJG006 struct {
  22753. ErrMsg string `json:"err_msg"`
  22754. InfRefmsgid string `json:"inf_refmsgid"`
  22755. Infcode int64 `json:"infcode"`
  22756. Output struct {
  22757. HiRxNo string `json:"hi_rxno"`
  22758. PharCode string `json:"phar_code"`
  22759. PharName string `json:"phar_name"`
  22760. RxChkOpnn string `json:"rx_chk_opnn"`
  22761. RxChkTime string `json:"rx_chk_time"`
  22762. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22763. RxChkStasName string `json:"rx_chk_stas_name"`
  22764. RxStasCodg string `json:"rx_stas_codg"`
  22765. RxStasName string `json:"rx_stas_name"`
  22766. } `json:"output"`
  22767. RefmsgTime string `json:"refmsg_time"`
  22768. RespondTime string `json:"respond_time"`
  22769. Signtype interface{} `json:"signtype"`
  22770. WarnInfo interface{} `json:"warn_info"`
  22771. }
  22772. type ResultFourteen10265 struct {
  22773. ErrMsg string `json:"err_msg"`
  22774. InfRefmsgid string `json:"inf_refmsgid"`
  22775. Infcode string `json:"infcode"`
  22776. Output struct {
  22777. } `json:"output"`
  22778. RefmsgTime string `json:"refmsg_time"`
  22779. RespondTime string `json:"respond_time"`
  22780. Signtype interface{} `json:"signtype"`
  22781. WarnInfo interface{} `json:"warn_info"`
  22782. }
  22783. type ResultSixteen struct {
  22784. Cainfo string `json:"cainfo"`
  22785. ErrMsg string `json:"err_msg"`
  22786. InfRefmsgid string `json:"inf_refmsgid"`
  22787. Infcode int64 `json:"infcode"`
  22788. Output struct {
  22789. Setlinfo struct {
  22790. MdtrtID string `json:"mdtrt_id"`
  22791. SetlID string `json:"setl_id"`
  22792. ClrOptins string `json:"clr_optins"`
  22793. SetlTime string `json:"setl_time"`
  22794. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22795. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22796. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22797. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22798. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22799. ActPayDedc float64 `json:"act_pay_dedc"`
  22800. HifpPay float64 `json:"hifp_pay"`
  22801. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22802. Lfpay float64 `json:"selfpay"`
  22803. CvlservPay float64 `json:"cvlserv_pay"`
  22804. HifesPay float64 `json:"hifes_pay"`
  22805. HifmiPay float64 `json:"hifmi_pay"`
  22806. HifobPay float64 `json:"hifob_pay"`
  22807. MafPay float64 `json:"maf_pay"`
  22808. OthPay float64 `json:"oth_pay"`
  22809. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22810. PsnPartAmt float64 `json:"psn_part_amt"`
  22811. AcctPay float64 `json:"acct_pay"`
  22812. Balc float64 `json:"balc"`
  22813. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22814. HospPartAmt float64 `json:"hosp_part_amt"`
  22815. MedinsSetlID string `json:"medins_setl_id"`
  22816. PdnCashPay string `json:"pdn_cash_pay"`
  22817. } `json:"setlinfo"`
  22818. } `json:"output"`
  22819. RefmsgTime string `json:"refmsg_time"`
  22820. RespondTime string `json:"respond_time"`
  22821. Signtype interface{} `json:"signtype"`
  22822. WarnMsg interface{} `json:"warn_msg"`
  22823. }
  22824. type ResultSixteen10265 struct {
  22825. Cainfo string `json:"cainfo"`
  22826. ErrMsg string `json:"err_msg"`
  22827. InfRefmsgid string `json:"inf_refmsgid"`
  22828. Infcode string `json:"infcode"`
  22829. Output struct {
  22830. Setlinfo struct {
  22831. MdtrtID string `json:"mdtrt_id"`
  22832. SetlID string `json:"setl_id"`
  22833. ClrOptins string `json:"clr_optins"`
  22834. SetlTime string `json:"setl_time"`
  22835. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22836. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22837. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22838. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22839. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22840. ActPayDedc float64 `json:"act_pay_dedc"`
  22841. HifpPay float64 `json:"hifp_pay"`
  22842. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22843. Lfpay float64 `json:"selfpay"`
  22844. CvlservPay float64 `json:"cvlserv_pay"`
  22845. HifesPay float64 `json:"hifes_pay"`
  22846. HifmiPay float64 `json:"hifmi_pay"`
  22847. HifobPay float64 `json:"hifob_pay"`
  22848. MafPay float64 `json:"maf_pay"`
  22849. OthPay float64 `json:"oth_pay"`
  22850. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22851. PsnPartAmt float64 `json:"psn_part_amt"`
  22852. AcctPay float64 `json:"acct_pay"`
  22853. Balc float64 `json:"balc"`
  22854. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22855. HospPartAmt float64 `json:"hosp_part_amt"`
  22856. MedinsSetlID string `json:"medins_setl_id"`
  22857. PdnCashPay string `json:"pdn_cash_pay"`
  22858. } `json:"setlinfo"`
  22859. } `json:"output"`
  22860. RefmsgTime string `json:"refmsg_time"`
  22861. RespondTime string `json:"respond_time"`
  22862. Signtype interface{} `json:"signtype"`
  22863. WarnMsg interface{} `json:"warn_msg"`
  22864. }
  22865. type ResultSixteen10265Two struct {
  22866. Cainfo string `json:"cainfo"`
  22867. ErrMsg string `json:"err_msg"`
  22868. InfRefmsgid string `json:"inf_refmsgid"`
  22869. Infcode string `json:"infcode"`
  22870. Output struct {
  22871. Setlinfo interface{} `json:"setlinfo"`
  22872. } `json:"output"`
  22873. RefmsgTime string `json:"refmsg_time"`
  22874. RespondTime string `json:"respond_time"`
  22875. Signtype interface{} `json:"signtype"`
  22876. WarnMsg interface{} `json:"warn_msg"`
  22877. }
  22878. type ResultgzSixteen10265Two struct {
  22879. Cainfo string `json:"cainfo"`
  22880. ErrMsg string `json:"err_msg"`
  22881. InfRefmsgid string `json:"inf_refmsgid"`
  22882. Infcode int64 `json:"infcode"`
  22883. Output struct {
  22884. Setlinfo interface{} `json:"setlinfo"`
  22885. } `json:"output"`
  22886. RefmsgTime string `json:"refmsg_time"`
  22887. RespondTime string `json:"respond_time"`
  22888. Signtype interface{} `json:"signtype"`
  22889. WarnMsg interface{} `json:"warn_msg"`
  22890. }
  22891. type ResultSeventeen struct {
  22892. ErrMsg string `json:"err_msg"`
  22893. InfRefmsgid string `json:"inf_refmsgid"`
  22894. Infcode int64 `json:"infcode"`
  22895. Output struct {
  22896. SetlListId string `json:"setl_list_id"`
  22897. } `json:"output"`
  22898. RefmsgTime string `json:"refmsg_time"`
  22899. RespondTime string `json:"respond_time"`
  22900. Signtype string `json:"signtype"`
  22901. WarnInfo string `json:"warn_info"`
  22902. }
  22903. type ResultSeventeenOther struct {
  22904. ErrMsg string `json:"err_msg"`
  22905. InfRefmsgid string `json:"inf_refmsgid"`
  22906. Infcode string `json:"infcode"`
  22907. Output struct {
  22908. SetlListId string `json:"setl_list_id"`
  22909. } `json:"output"`
  22910. RefmsgTime string `json:"refmsg_time"`
  22911. RespondTime string `json:"respond_time"`
  22912. Signtype string `json:"signtype"`
  22913. WarnInfo string `json:"warn_info"`
  22914. }
  22915. type Result90991 struct {
  22916. ErrMsg string `json:"err_msg"`
  22917. InfRefmsgid string `json:"inf_refmsgid"`
  22918. Infcode int64 `json:"infcode"`
  22919. Output struct {
  22920. Result struct {
  22921. PsnNo string `json:"psn_no"`
  22922. CardStat string `json:"card_stat"`
  22923. Certno string `json:"certno"`
  22924. PsnName string `json:"psn_name"`
  22925. CheckStat string `json:"check_stat"`
  22926. SscnoCheckStat string `json:"sscno_check_stat"`
  22927. } `json:"result"`
  22928. } `json:"output"`
  22929. RefmsgTime string `json:"refmsg_time"`
  22930. RespondTime string `json:"respond_time"`
  22931. Signtype interface{} `json:"signtype"`
  22932. WarnInfo interface{} `json:"warn_info"`
  22933. }
  22934. type Result90100 struct {
  22935. ErrMsg string `json:"err_msg"`
  22936. InfRefmsgid string `json:"inf_refmsgid"`
  22937. Infcode int64 `json:"infcode"`
  22938. Output struct {
  22939. PoolareaNo string `json:"poolarea_no"`
  22940. PoolareaNoName string `json:"poolarea_no_name"`
  22941. Insutype string `json:"insutype"`
  22942. InsutypeName string `json:"insutype_name"`
  22943. ClctType string `json:"clct_type"`
  22944. ClctTypeName string `json:"clct_type_name"`
  22945. ClctFlag string `json:"clct_flag"`
  22946. ClctFlagName string `json:"clct_flag_name"`
  22947. AccrymBegn string `json:"accrym_begn"`
  22948. AccrymEnd string `json:"accrym_end"`
  22949. ClctTime string `json:"clct_time"`
  22950. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  22951. } `json:"output"`
  22952. RefmsgTime string `json:"refmsg_time"`
  22953. RespondTime string `json:"respond_time"`
  22954. Signtype interface{} `json:"signtype"`
  22955. WarnInfo interface{} `json:"warn_info"`
  22956. }
  22957. type Custom struct {
  22958. DetItemFeeSumamt string
  22959. Cut string
  22960. FeedetlSn string
  22961. Price string
  22962. MedListCodg string
  22963. Type int64
  22964. AdviceId int64
  22965. ProjectId int64
  22966. ItemId int64
  22967. }
  22968. type Result5301 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. OpspDiseCode string `json:"opsp_dise_code"`
  22975. OpspDiseName string `json:"opsp_dise_name"`
  22976. Begndate string `json:"begndate"`
  22977. Enddate string `json:"enddate"`
  22978. } `json:"feedetail"`
  22979. } `json:"output"`
  22980. RefmsgTime string `json:"refmsg_time"`
  22981. RespondTime string `json:"respond_time"`
  22982. Signtype interface{} `json:"signtype"`
  22983. WarnInfo interface{} `json:"warn_info"`
  22984. }
  22985. type Result5301For10265 struct {
  22986. ErrMsg string `json:"err_msg"`
  22987. InfRefmsgid string `json:"inf_refmsgid"`
  22988. Infcode string `json:"infcode"`
  22989. Output struct {
  22990. Result []struct {
  22991. OpspDiseCode string `json:"opsp_dise_code"`
  22992. OpspDiseName string `json:"opsp_dise_name"`
  22993. Begndate string `json:"begndate"`
  22994. Enddate string `json:"enddate"`
  22995. } `json:"feedetail"`
  22996. } `json:"output"`
  22997. RefmsgTime string `json:"refmsg_time"`
  22998. RespondTime string `json:"respond_time"`
  22999. Signtype interface{} `json:"signtype"`
  23000. WarnInfo interface{} `json:"warn_info"`
  23001. }
  23002. //获取个人信息----挂号-----上传就诊信息
  23003. func (c *HisApiController) GetRegisterInfo() {
  23004. id, _ := c.GetInt64("id")
  23005. record_time := c.GetString("record_time")
  23006. settlementValue, _ := c.GetInt64("settlement_value")
  23007. medical_insurance_card := c.GetString("medical_insurance_card")
  23008. name := c.GetString("name")
  23009. id_card_type, _ := c.GetInt64("id_card_type")
  23010. certificates, _ := c.GetInt64("certificates")
  23011. medical_care, _ := c.GetInt64("medical_care")
  23012. birthday := c.GetString("birthday")
  23013. id_card := c.GetString("id_card")
  23014. register_type, _ := c.GetInt64("register")
  23015. doctor, _ := c.GetInt64("doctor")
  23016. department, _ := c.GetInt64("department")
  23017. gender, _ := c.GetInt64("sex")
  23018. registration_fee, _ := c.GetFloat("registration_fee")
  23019. medical_expenses, _ := c.GetFloat("medical_expenses")
  23020. social_type, _ := c.GetInt64("social_type")
  23021. admin_user_id, _ := c.GetInt64("admin_user_id")
  23022. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23023. mdtrt_type := c.GetString("mdtrt_type")
  23024. if id_card_type == 5 {
  23025. id_card_type = 4
  23026. }
  23027. timeLayout := "2006-01-02"
  23028. loc, _ := time.LoadLocation("Local")
  23029. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23030. birthUnix := birthdays.Unix()
  23031. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23032. if err != nil {
  23033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23034. return
  23035. }
  23036. recordDateTime := theTime.Unix()
  23037. adminInfo := c.GetAdminUserInfo()
  23038. var patient service.Patients
  23039. if id == 0 {
  23040. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23041. } else {
  23042. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23043. }
  23044. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23045. if patientPrescription.ID == 0 {
  23046. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23047. }
  23048. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23049. if patient.ID == 0 {
  23050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23051. return
  23052. }
  23053. if len(patient.IdCardNo) == 0 {
  23054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23055. return
  23056. }
  23057. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23058. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23059. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23060. //就诊结算未完成,不能进行二次挂号
  23061. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23062. if len(his) >= 1 {
  23063. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23064. if len(his) >= 1 && order.ID == 0 {
  23065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23066. return
  23067. }
  23068. }
  23069. //var register_log string
  23070. if config.IsOpen == 1 {
  23071. var res ResultTwo
  23072. var res10265 ResultTwo10265
  23073. var PsnNo string
  23074. var PsnCertType string
  23075. var Certno string
  23076. var PsnName string
  23077. var Gend string
  23078. var Naty string
  23079. var Brdy string
  23080. var Age float64
  23081. var infoStr string
  23082. var idetinfoStr string
  23083. var infocode int64
  23084. var verify_number string
  23085. fmt.Println(verify_number)
  23086. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23087. psn_info, _ := service.GetPsnByPatientId(id)
  23088. PsnNo = psn_info.PsnNo
  23089. PsnCertType = psn_info.PsnCertType
  23090. Certno = psn_info.Certno
  23091. PsnName = psn_info.PsnName
  23092. Gend = psn_info.Gend
  23093. Naty = psn_info.Naty
  23094. Brdy = psn_info.Brdy
  23095. Age = psn_info.Age
  23096. infoStr = psn_info.Insuinfo
  23097. idetinfoStr = psn_info.Idetinfo
  23098. infocode = 0
  23099. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23100. psn_info, _ := service.GetPsnByPatientId(id)
  23101. PsnNo = psn_info.PsnNo
  23102. PsnCertType = psn_info.PsnCertType
  23103. Certno = psn_info.Certno
  23104. PsnName = psn_info.PsnName
  23105. Gend = psn_info.Gend
  23106. Naty = psn_info.Naty
  23107. Brdy = psn_info.Brdy
  23108. Age = psn_info.Age
  23109. infoStr = psn_info.Insuinfo
  23110. idetinfoStr = psn_info.Idetinfo
  23111. infocode = 0
  23112. verify_number = psn_info.VerifyNumber
  23113. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23114. if id_card_type == 2 {
  23115. //请求内网数据
  23116. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23117. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23118. "&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
  23119. resp, requestErr := http.Get(api)
  23120. if requestErr != nil {
  23121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23122. return
  23123. }
  23124. body, ioErr := ioutil.ReadAll(resp.Body)
  23125. if ioErr != nil {
  23126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23128. return
  23129. }
  23130. var respJSON map[string]interface{}
  23131. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23134. return
  23135. }
  23136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23137. result_byte, _ := json.Marshal(respJSON)
  23138. result := string(result_byte)
  23139. var dat map[string]interface{}
  23140. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23141. fmt.Println(dat)
  23142. } else {
  23143. fmt.Println(err)
  23144. }
  23145. userJSONBytes, _ := json.Marshal(dat)
  23146. var res ResultTwo
  23147. var resTwo10265 ResultTwo10265
  23148. if miConfig.Code == "H15049901371" {
  23149. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23150. utils.ErrorLog("解析失败:%v", err)
  23151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23152. return
  23153. }
  23154. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23155. res.Infcode = Infcode
  23156. res.ErrMsg = resTwo10265.ErrMsg
  23157. res.Output = resTwo10265.Output
  23158. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23159. res.RespondTime = resTwo10265.RespondTime
  23160. res.WarnInfo = resTwo10265.WarnInfo
  23161. } else {
  23162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23163. utils.ErrorLog("解析失败:%v", err)
  23164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23165. return
  23166. }
  23167. }
  23168. //var insutypes []string
  23169. //var insutype string
  23170. //var is390 int = 0
  23171. //var is310 int = 0
  23172. //for _, item := range res.Output.Iinfo {
  23173. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23174. // insutypes = append(insutypes, item.Insutype)
  23175. // }
  23176. //}
  23177. //if len(insutypes) == 1 {
  23178. // insutype = insutypes[0]
  23179. //} else {
  23180. // for _, i := range insutypes {
  23181. // if i == "390" {
  23182. // is390 = 1
  23183. // }
  23184. //
  23185. // if i == "310" {
  23186. // is310 = 1
  23187. // }
  23188. // }
  23189. //}
  23190. //if is390 == 1 {
  23191. // insutype = "390"
  23192. //}
  23193. //if is310 == 1 {
  23194. // insutype = "310"
  23195. //}
  23196. //if len(insutypes) == 0 {
  23197. // insutype = "310"
  23198. //}
  23199. PsnNo = res.Output.Baseinfo.PsnNo
  23200. PsnCertType = res.Output.Baseinfo.PsnCertType
  23201. Certno = res.Output.Baseinfo.Certno
  23202. PsnName = res.Output.Baseinfo.PsnName
  23203. Gend = res.Output.Baseinfo.Gend
  23204. Naty = res.Output.Baseinfo.Naty
  23205. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23206. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23207. infoStr = string(Iinfos)
  23208. idetinfoStr = string(Idetinfos)
  23209. infocode = res.Infcode
  23210. //infocode = 0
  23211. //verify_number = psn_info.VerifyNumber
  23212. } else {
  23213. psn_info, _ := service.GetPsnByPatientId(id)
  23214. PsnNo = psn_info.PsnNo
  23215. PsnCertType = psn_info.PsnCertType
  23216. Certno = psn_info.Certno
  23217. PsnName = psn_info.PsnName
  23218. Gend = psn_info.Gend
  23219. Naty = psn_info.Naty
  23220. Brdy = psn_info.Brdy
  23221. Age = psn_info.Age
  23222. infoStr = psn_info.Insuinfo
  23223. idetinfoStr = psn_info.Idetinfo
  23224. infocode = 0
  23225. verify_number = psn_info.VerifyNumber
  23226. }
  23227. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23228. if id_card_type == 1 {
  23229. psn_info, _ := service.GetPsnByPatientId(id)
  23230. PsnNo = psn_info.PsnNo
  23231. PsnCertType = psn_info.PsnCertType
  23232. Certno = psn_info.Certno
  23233. PsnName = psn_info.PsnName
  23234. Gend = psn_info.Gend
  23235. Naty = psn_info.Naty
  23236. Brdy = psn_info.Brdy
  23237. Age = psn_info.Age
  23238. infoStr = psn_info.Insuinfo
  23239. idetinfoStr = psn_info.Idetinfo
  23240. infocode = 0
  23241. verify_number = psn_info.VerifyNumber
  23242. } else if id_card_type == 2 {
  23243. 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)
  23244. fmt.Println(errMsgLog)
  23245. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23246. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23247. utils.ErrorLog("解析失败:%v", err)
  23248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23249. return
  23250. }
  23251. PsnNo = res.Output.Baseinfo.PsnNo
  23252. PsnCertType = res.Output.Baseinfo.PsnCertType
  23253. Certno = res.Output.Baseinfo.Certno
  23254. PsnName = res.Output.Baseinfo.PsnName
  23255. Gend = res.Output.Baseinfo.Gend
  23256. Naty = res.Output.Baseinfo.Naty
  23257. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23258. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23259. infoStr = string(Iinfos)
  23260. idetinfoStr = string(Idetinfos)
  23261. infocode = res.Infcode
  23262. }
  23263. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23264. if id_card_type == 1 {
  23265. psn_info, _ := service.GetPsnByPatientId(id)
  23266. PsnNo = psn_info.PsnNo
  23267. PsnCertType = psn_info.PsnCertType
  23268. Certno = psn_info.Certno
  23269. PsnName = psn_info.PsnName
  23270. Gend = psn_info.Gend
  23271. Naty = psn_info.Naty
  23272. Brdy = psn_info.Brdy
  23273. Age = psn_info.Age
  23274. infoStr = psn_info.Insuinfo
  23275. idetinfoStr = psn_info.Idetinfo
  23276. infocode = 0
  23277. verify_number = psn_info.VerifyNumber
  23278. } else if id_card_type == 2 {
  23279. 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, "")
  23280. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23281. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23282. utils.ErrorLog("解析失败:%v", err)
  23283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23284. return
  23285. }
  23286. PsnNo = res.Output.Baseinfo.PsnNo
  23287. PsnCertType = res.Output.Baseinfo.PsnCertType
  23288. Certno = res.Output.Baseinfo.Certno
  23289. PsnName = res.Output.Baseinfo.PsnName
  23290. Gend = res.Output.Baseinfo.Gend
  23291. Naty = res.Output.Baseinfo.Naty
  23292. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23293. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23294. infoStr = string(Iinfos)
  23295. idetinfoStr = string(Idetinfos)
  23296. infocode = res.Infcode
  23297. } else {
  23298. psn_info, _ := service.GetPsnByPatientId(id)
  23299. PsnNo = psn_info.PsnNo
  23300. PsnCertType = psn_info.PsnCertType
  23301. Certno = psn_info.Certno
  23302. PsnName = psn_info.PsnName
  23303. Gend = psn_info.Gend
  23304. Naty = psn_info.Naty
  23305. Brdy = psn_info.Brdy
  23306. Age = psn_info.Age
  23307. infoStr = psn_info.Insuinfo
  23308. idetinfoStr = psn_info.Idetinfo
  23309. infocode = 0
  23310. verify_number = psn_info.VerifyNumber
  23311. }
  23312. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23313. if id_card_type == 1 {
  23314. psn_info, _ := service.GetPsnByPatientId(id)
  23315. PsnNo = psn_info.PsnNo
  23316. PsnCertType = psn_info.PsnCertType
  23317. Certno = psn_info.Certno
  23318. PsnName = psn_info.PsnName
  23319. Gend = psn_info.Gend
  23320. Naty = psn_info.Naty
  23321. Brdy = psn_info.Brdy
  23322. Age = psn_info.Age
  23323. infoStr = psn_info.Insuinfo
  23324. idetinfoStr = psn_info.Idetinfo
  23325. infocode = 0
  23326. verify_number = psn_info.VerifyNumber
  23327. } else if id_card_type == 2 {
  23328. psn_info, _ := service.GetPsnByPatientId(id)
  23329. PsnNo = psn_info.PsnNo
  23330. PsnCertType = psn_info.PsnCertType
  23331. Certno = psn_info.Certno
  23332. PsnName = psn_info.PsnName
  23333. Gend = psn_info.Gend
  23334. Naty = psn_info.Naty
  23335. Brdy = psn_info.Brdy
  23336. Age = psn_info.Age
  23337. infoStr = psn_info.Insuinfo
  23338. idetinfoStr = psn_info.Idetinfo
  23339. infocode = 0
  23340. verify_number = psn_info.VerifyNumber
  23341. } else {
  23342. psn_info, _ := service.GetPsnByPatientId(id)
  23343. PsnNo = psn_info.PsnNo
  23344. PsnCertType = psn_info.PsnCertType
  23345. Certno = psn_info.Certno
  23346. PsnName = psn_info.PsnName
  23347. Gend = psn_info.Gend
  23348. Naty = psn_info.Naty
  23349. Brdy = psn_info.Brdy
  23350. Age = psn_info.Age
  23351. infoStr = psn_info.Insuinfo
  23352. idetinfoStr = psn_info.Idetinfo
  23353. infocode = 0
  23354. verify_number = psn_info.VerifyNumber
  23355. }
  23356. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23357. psn_info, _ := service.GetPsnByPatientId(id)
  23358. PsnNo = psn_info.PsnNo
  23359. PsnCertType = psn_info.PsnCertType
  23360. Certno = psn_info.Certno
  23361. PsnName = psn_info.PsnName
  23362. Gend = psn_info.Gend
  23363. Naty = psn_info.Naty
  23364. Brdy = psn_info.Brdy
  23365. Age = psn_info.Age
  23366. infoStr = psn_info.Insuinfo
  23367. idetinfoStr = psn_info.Idetinfo
  23368. infocode = 0
  23369. verify_number = psn_info.VerifyNumber
  23370. idetinfoStr = psn_info.Idetinfo
  23371. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23372. if id_card_type == 1 {
  23373. psn_info, _ := service.GetPsnByPatientId(id)
  23374. PsnNo = psn_info.PsnNo
  23375. PsnCertType = psn_info.PsnCertType
  23376. Certno = psn_info.Certno
  23377. PsnName = psn_info.PsnName
  23378. Gend = psn_info.Gend
  23379. Naty = psn_info.Naty
  23380. Brdy = psn_info.Brdy
  23381. Age = psn_info.Age
  23382. infoStr = psn_info.Insuinfo
  23383. idetinfoStr = psn_info.Idetinfo
  23384. infocode = 0
  23385. verify_number = psn_info.VerifyNumber
  23386. } else if id_card_type == 2 {
  23387. 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)
  23388. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23389. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23390. utils.ErrorLog("解析失败:%v", err)
  23391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23392. return
  23393. }
  23394. PsnNo = res.Output.Baseinfo.PsnNo
  23395. PsnCertType = res.Output.Baseinfo.PsnCertType
  23396. Certno = res.Output.Baseinfo.Certno
  23397. PsnName = res.Output.Baseinfo.PsnName
  23398. Gend = res.Output.Baseinfo.Gend
  23399. Naty = res.Output.Baseinfo.Naty
  23400. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23401. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23402. infoStr = string(Iinfos)
  23403. idetinfoStr = string(Idetinfos)
  23404. infocode = res.Infcode
  23405. } else if id_card_type == 4 {
  23406. psn_info, _ := service.GetPsnByPatientId(id)
  23407. PsnNo = psn_info.PsnNo
  23408. PsnCertType = psn_info.PsnCertType
  23409. Certno = psn_info.Certno
  23410. PsnName = psn_info.PsnName
  23411. Gend = psn_info.Gend
  23412. Naty = psn_info.Naty
  23413. Brdy = psn_info.Brdy
  23414. Age = psn_info.Age
  23415. infoStr = psn_info.Insuinfo
  23416. idetinfoStr = psn_info.Idetinfo
  23417. infocode = 0
  23418. verify_number = psn_info.VerifyNumber
  23419. }
  23420. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23421. var result string
  23422. var requestLog string
  23423. 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), "")
  23424. if id_card_type == 4 {
  23425. psn_info, _ := service.GetPsnByPatientId(id)
  23426. PsnNo = psn_info.PsnNo
  23427. PsnCertType = psn_info.PsnCertType
  23428. Certno = psn_info.Certno
  23429. PsnName = psn_info.PsnName
  23430. Gend = psn_info.Gend
  23431. Naty = psn_info.Naty
  23432. Brdy = psn_info.Brdy
  23433. Age = psn_info.Age
  23434. infoStr = psn_info.Insuinfo
  23435. idetinfoStr = psn_info.Idetinfo
  23436. infocode = 0
  23437. verify_number = psn_info.VerifyNumber
  23438. } else {
  23439. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23440. if miConfig.Code == "H15049901371" {
  23441. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23442. utils.ErrorLog("解析失败:%v", err)
  23443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23444. return
  23445. }
  23446. res.ErrMsg = res10265.ErrMsg
  23447. res.Output = res10265.Output
  23448. res.InfRefmsgid = res10265.InfRefmsgid
  23449. } else {
  23450. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23451. utils.ErrorLog("解析失败:%v", err)
  23452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23453. return
  23454. }
  23455. }
  23456. PsnNo = res.Output.Baseinfo.PsnNo
  23457. PsnCertType = res.Output.Baseinfo.PsnCertType
  23458. Certno = res.Output.Baseinfo.Certno
  23459. PsnName = res.Output.Baseinfo.PsnName
  23460. Gend = res.Output.Baseinfo.Gend
  23461. Naty = res.Output.Baseinfo.Naty
  23462. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23463. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23464. infoStr = string(Iinfos)
  23465. idetinfoStr = string(Idetinfos)
  23466. if miConfig.Code == "H15049901371" {
  23467. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23468. } else {
  23469. infocode = res.Infcode
  23470. }
  23471. }
  23472. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23473. psn_info, _ := service.GetPsnByPatientId(id)
  23474. PsnNo = psn_info.PsnNo
  23475. PsnCertType = psn_info.PsnCertType
  23476. Certno = psn_info.Certno
  23477. PsnName = psn_info.PsnName
  23478. Gend = psn_info.Gend
  23479. Naty = psn_info.Naty
  23480. Brdy = psn_info.Brdy
  23481. Age = psn_info.Age
  23482. infoStr = psn_info.Insuinfo
  23483. idetinfoStr = psn_info.Idetinfo
  23484. infocode = 0
  23485. verify_number = psn_info.VerifyNumber
  23486. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23487. psn_info, _ := service.GetPsnByPatientId(id)
  23488. PsnNo = psn_info.PsnNo
  23489. PsnCertType = psn_info.PsnCertType
  23490. Certno = psn_info.Certno
  23491. PsnName = psn_info.PsnName
  23492. Gend = psn_info.Gend
  23493. Naty = psn_info.Naty
  23494. Brdy = psn_info.Brdy
  23495. Age = psn_info.Age
  23496. infoStr = psn_info.Insuinfo
  23497. idetinfoStr = psn_info.Idetinfo
  23498. infocode = 0
  23499. verify_number = psn_info.VerifyNumber
  23500. } else {
  23501. var result string
  23502. var requestLog string
  23503. //if miConfig.UserOrgId == 10138 {
  23504. if id_card_type != 4 || id_card_type != 1 {
  23505. var insa string
  23506. if len(patient.InsuplcAdmdvs) > 0 {
  23507. insa = patient.InsuplcAdmdvs
  23508. } else {
  23509. insa = miConfig.InsuplcAdmdvs
  23510. }
  23511. //psn_info, _ := service.GetPsnByPatientId(id)
  23512. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23513. 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)
  23514. }
  23515. //}
  23516. //else {
  23517. // var insa string
  23518. // if len(patient.InsuplcAdmdvs) > 0 {
  23519. // insa = patient.InsuplcAdmdvs
  23520. // } else {
  23521. // insa = miConfig.InsuplcAdmdvs
  23522. // }
  23523. // 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)
  23524. //}
  23525. if id_card_type == 4 || id_card_type == 1 {
  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 {
  23540. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23541. if miConfig.Code == "H15049901371" {
  23542. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23543. utils.ErrorLog("解析失败:%v", err)
  23544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23545. return
  23546. }
  23547. res.ErrMsg = res10265.ErrMsg
  23548. res.Output = res10265.Output
  23549. res.InfRefmsgid = res10265.InfRefmsgid
  23550. } else {
  23551. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23552. utils.ErrorLog("解析失败:%v", err)
  23553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23554. return
  23555. }
  23556. }
  23557. PsnNo = res.Output.Baseinfo.PsnNo
  23558. PsnCertType = res.Output.Baseinfo.PsnCertType
  23559. Certno = res.Output.Baseinfo.Certno
  23560. PsnName = res.Output.Baseinfo.PsnName
  23561. Gend = res.Output.Baseinfo.Gend
  23562. Naty = res.Output.Baseinfo.Naty
  23563. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23564. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23565. infoStr = string(Iinfos)
  23566. idetinfoStr = string(Idetinfos)
  23567. if miConfig.Code == "H15049901371" {
  23568. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23569. } else {
  23570. infocode = res.Infcode
  23571. }
  23572. }
  23573. }
  23574. if infocode == 0 {
  23575. his := models.VMHisPatient{
  23576. Name: name,
  23577. Gender: gender,
  23578. Birthday: birthUnix,
  23579. MedicalTreatmentType: medical_care,
  23580. IdType: certificates,
  23581. IdCardNo: id_card,
  23582. BalanceAccountsType: settlementValue,
  23583. SocialType: social_type,
  23584. MedicalInsuranceNumber: medical_insurance_card,
  23585. RegisterType: register_type,
  23586. RegisterCost: registration_fee,
  23587. TreatmentCost: medical_expenses,
  23588. Status: 1,
  23589. Ctime: time.Now().Unix(),
  23590. Mtime: time.Now().Unix(),
  23591. PsnNo: PsnNo,
  23592. PsnCertType: PsnCertType,
  23593. Certno: Certno,
  23594. PsnName: PsnName,
  23595. Gend: Gend,
  23596. Naty: Naty,
  23597. Brdy: Brdy,
  23598. Age: Age,
  23599. Iinfo: infoStr,
  23600. Idetinfo: idetinfoStr,
  23601. PatientId: patient.ID,
  23602. RecordDate: theTime.Unix(),
  23603. UserOrgId: adminInfo.CurrentOrgId,
  23604. AdminUserId: admin_user_id,
  23605. IsReturn: 1,
  23606. IdCardType: id_card_type,
  23607. Doctor: doctor,
  23608. Departments: department,
  23609. MdtrtGrpType: mdtrt_type,
  23610. }
  23611. timestamp := time.Now().Unix()
  23612. tempTime := time.Unix(timestamp, 0)
  23613. timeFormat := tempTime.Format("20060102150405")
  23614. chrgBchno := rand.Intn(100000) + 10000
  23615. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23616. his.Number = ipt_otp_no
  23617. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23618. department, _ := service.GetDepartMentDetail(department)
  23619. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23620. IdCardNo := ""
  23621. if id_card_type == 1 {
  23622. // IdCardNo = medical_insurance_card
  23623. IdCardNo = patient.IdCardNo
  23624. } else {
  23625. IdCardNo = patient.IdCardNo
  23626. }
  23627. var rf []*ResultFive
  23628. json.Unmarshal([]byte(his.Iinfo), &rf)
  23629. var insutypes []*ResultFive
  23630. var insutype string
  23631. var insuplc_admdvs_temp string
  23632. var is390 int = 0
  23633. var is310 int = 0
  23634. for _, item := range rf {
  23635. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23636. insutypes = append(insutypes, item)
  23637. }
  23638. }
  23639. if len(insutypes) == 1 {
  23640. insutype = insutypes[0].Insutype
  23641. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23642. if insutype == "390" {
  23643. is390 = 1
  23644. }
  23645. if insutype == "310" {
  23646. is310 = 1
  23647. }
  23648. } else {
  23649. for _, i := range insutypes {
  23650. if i.Insutype == "390" {
  23651. is390 = 1
  23652. }
  23653. if i.Insutype == "310" {
  23654. is310 = 1
  23655. }
  23656. }
  23657. }
  23658. if is390 == 1 {
  23659. insutype = "390"
  23660. }
  23661. if is310 == 1 {
  23662. insutype = "310"
  23663. }
  23664. fmt.Println(social_type)
  23665. if social_type > 0 {
  23666. insutype = strconv.FormatInt(social_type, 10)
  23667. }
  23668. var infocode int64
  23669. var resThree ResultThree
  23670. var resThree10265 ResultThree10265
  23671. if len(insuplc_admdvs) == 0 {
  23672. psn_info, _ := service.GetPsnByPatientId(id)
  23673. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23674. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23675. //}
  23676. } else {
  23677. insuplc_admdvs_temp = insuplc_admdvs
  23678. }
  23679. if miConfig.MdtrtareaAdmvs == "421300" {
  23680. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23681. psn_info, _ := service.GetPsnByPatientId(id)
  23682. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23683. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23684. "&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
  23685. resp, requestErr := http.Get(api)
  23686. if requestErr != nil {
  23687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23688. return
  23689. }
  23690. body, ioErr := ioutil.ReadAll(resp.Body)
  23691. if ioErr != nil {
  23692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23694. return
  23695. }
  23696. var respJSON map[string]interface{}
  23697. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23700. return
  23701. }
  23702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23703. result, _ := json.Marshal(respJSON)
  23704. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23705. utils.ErrorLog("解析失败:%v", err)
  23706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23707. return
  23708. }
  23709. infocode = resThree.Infcode
  23710. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23711. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23712. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23713. // insuplc_admdvs_temp =
  23714. //}
  23715. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23716. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23717. //}
  23718. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23719. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23720. "&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
  23721. resp, requestErr := http.Get(api)
  23722. if requestErr != nil {
  23723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23724. return
  23725. }
  23726. body, ioErr := ioutil.ReadAll(resp.Body)
  23727. if ioErr != nil {
  23728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23730. return
  23731. }
  23732. var respJSON map[string]interface{}
  23733. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23736. return
  23737. }
  23738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23739. result, _ := json.Marshal(respJSON)
  23740. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23741. utils.ErrorLog("解析失败:%v", err)
  23742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23743. return
  23744. }
  23745. infocode = resThree.Infcode
  23746. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23747. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23748. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23749. // insuplc_admdvs_temp =
  23750. //}
  23751. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23752. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23753. //}
  23754. utils.ErrorLog("解析失败:%v", insutype)
  23755. utils.ErrorLog("解析失败:%v", PsnNo)
  23756. utils.ErrorLog("解析失败:%v", Certno)
  23757. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23758. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23759. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23760. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23761. utils.ErrorLog("解析失败:%v", PsnNo)
  23762. utils.ErrorLog("解析失败:%v", department.Number)
  23763. utils.ErrorLog("解析失败:%v", department.Name)
  23764. utils.ErrorLog("解析失败:%v", roles.UserName)
  23765. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23766. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23767. "&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
  23768. resp, requestErr := http.Get(api)
  23769. if requestErr != nil {
  23770. utils.ErrorLog("解析失败:%v", requestErr)
  23771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23772. return
  23773. }
  23774. body, ioErr := ioutil.ReadAll(resp.Body)
  23775. if ioErr != nil {
  23776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23778. return
  23779. }
  23780. var respJSON map[string]interface{}
  23781. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23784. return
  23785. }
  23786. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23787. result, _ := json.Marshal(respJSON)
  23788. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23789. utils.ErrorLog("解析失败:%v", err)
  23790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23791. return
  23792. }
  23793. infocode = resThree.Infcode
  23794. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23795. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23796. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23797. // insuplc_admdvs_temp =
  23798. //}
  23799. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23800. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23801. //}
  23802. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23803. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23804. "&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
  23805. resp, requestErr := http.Get(api)
  23806. if requestErr != nil {
  23807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23808. return
  23809. }
  23810. body, ioErr := ioutil.ReadAll(resp.Body)
  23811. if ioErr != nil {
  23812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23814. return
  23815. }
  23816. var respJSON map[string]interface{}
  23817. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23820. return
  23821. }
  23822. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23823. result, _ := json.Marshal(respJSON)
  23824. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23825. utils.ErrorLog("解析失败:%v", err)
  23826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23827. return
  23828. }
  23829. infocode = resThree.Infcode
  23830. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23831. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23832. psn_info, _ := service.GetPsnByPatientId(id)
  23833. var verify_number string
  23834. if id_card_type == 4 {
  23835. verify_number = psn_info.VerifyNumber
  23836. } else if id_card_type == 1 {
  23837. bas := strings.Split(psn_info.CardInfo, "|")
  23838. cardNumber := bas[2]
  23839. verify_number = cardNumber
  23840. }
  23841. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23842. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23843. "&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
  23844. resp, requestErr := http.Get(api)
  23845. if requestErr != nil {
  23846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23847. return
  23848. }
  23849. body, ioErr := ioutil.ReadAll(resp.Body)
  23850. if ioErr != nil {
  23851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23853. return
  23854. }
  23855. var respJSON map[string]interface{}
  23856. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23859. return
  23860. }
  23861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23862. result, _ := json.Marshal(respJSON)
  23863. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23864. // utils.ErrorLog("解析失败:%v", err)
  23865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23866. // return
  23867. //}
  23868. //infocode = resThree.Infcode
  23869. //result, _ := json.Marshal(respJSON)
  23870. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23871. utils.ErrorLog("解析失败:%v", err)
  23872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23873. return
  23874. }
  23875. resThree.ErrMsg = resThree10265.ErrMsg
  23876. resThree.Output = resThree10265.Output
  23877. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23878. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23879. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23880. psn_info, _ := service.GetPsnByPatientId(id)
  23881. his.PsnNo = psn_info.PsnNo
  23882. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23883. var cert_no string
  23884. if id_card_type == 3 {
  23885. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  23886. cert_no = IdCardNo
  23887. } else if id_card_type == 4 {
  23888. cert_no = IdCardNo
  23889. psn_info.VerifyNumber = psn_info.VerifyNumber
  23890. } else {
  23891. bas := strings.Split(psn_info.CardInfo, "|")
  23892. cert_no = bas[2]
  23893. }
  23894. var hisPrescription []*models.HisPrescription
  23895. for _, item := range rf {
  23896. if item.Insutype == insutype {
  23897. //insuplc_admdvs = item.InsuplcAdmdvs
  23898. his.InsuplcAdmdvs = insuplc_admdvs
  23899. }
  23900. }
  23901. his.Insutype = insutype
  23902. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23903. fmt.Println(res3101)
  23904. fmt.Println(res3101.Infcode)
  23905. if res3101.Infcode == "0" {
  23906. fmt.Println("33333333")
  23907. if len(res3101.Output.Result) > 0 {
  23908. fmt.Println("222222")
  23909. for _, item := range res3101.Output.Result {
  23910. if len(res3101.ErrMsg) == 0 {
  23911. res3101.ErrMsg = item.VolaCont
  23912. } else {
  23913. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23914. }
  23915. }
  23916. c.ServeSuccessJSON(map[string]interface{}{
  23917. "failed_code": -10,
  23918. "msg": res3101.ErrMsg,
  23919. })
  23920. return
  23921. } else {
  23922. fmt.Println("11111")
  23923. var api string
  23924. if miConfig.MdtrtareaAdmvs == "320921" {
  23925. ipt_otp_no = timeFormat
  23926. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23927. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23928. "&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
  23929. } else {
  23930. ipt_otp_no = timeFormat
  23931. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23932. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23933. "&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
  23934. }
  23935. resp, requestErr := http.Get(api)
  23936. if requestErr != nil {
  23937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23938. return
  23939. }
  23940. body, ioErr := ioutil.ReadAll(resp.Body)
  23941. if ioErr != nil {
  23942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23944. return
  23945. }
  23946. var respJSON map[string]interface{}
  23947. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23950. return
  23951. }
  23952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23953. result, _ := json.Marshal(respJSON)
  23954. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23955. utils.ErrorLog("解析失败:%v", err)
  23956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23957. return
  23958. }
  23959. resThree.ErrMsg = resThree10265.ErrMsg
  23960. resThree.Output = resThree10265.Output
  23961. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23962. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23963. }
  23964. } else if res3101.Infcode != "0" {
  23965. c.ServeSuccessJSON(map[string]interface{}{
  23966. "failed_code": -10,
  23967. "msg": res3101.ErrMsg,
  23968. })
  23969. return
  23970. }
  23971. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23972. psn_info, _ := service.GetPsnByPatientId(id)
  23973. var cert_no string
  23974. if id_card_type == 1 {
  23975. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  23976. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23977. } else if id_card_type == 4 {
  23978. cert_no = psn_info.VerifyNumber
  23979. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23980. } else {
  23981. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23982. cert_no = psn_info.VerifyNumber
  23983. }
  23984. 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)
  23985. saveLog(result, requestLog, "2201", "挂号")
  23986. if miConfig.Code == "H15049901371" {
  23987. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23988. utils.ErrorLog("解析失败:%v", err)
  23989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23990. return
  23991. }
  23992. resThree.ErrMsg = resThree10265.ErrMsg
  23993. resThree.Output = resThree10265.Output
  23994. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23995. } else {
  23996. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23997. utils.ErrorLog("解析失败:%v", err)
  23998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23999. return
  24000. }
  24001. }
  24002. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24003. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24004. psn_info, _ := service.GetPsnByPatientId(id)
  24005. var result string
  24006. var requestLog string
  24007. if id_card_type == 1 {
  24008. bas := strings.Split(psn_info.CardInfo, "|")
  24009. basNumber := bas[2]
  24010. card_sn := bas[3]
  24011. 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)
  24012. saveLog(result, requestLog, "2201A", "挂号")
  24013. } else if id_card_type == 2 {
  24014. 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, "", "", "", "", "", "")
  24015. saveLog(result, requestLog, "2201A", "挂号")
  24016. } else {
  24017. 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)
  24018. saveLog(result, requestLog, "2201A", "挂号")
  24019. }
  24020. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24021. utils.ErrorLog("解析失败:%v", err)
  24022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24023. return
  24024. }
  24025. infocode = resThree.Infcode
  24026. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24027. psn_info, _ := service.GetPsnByPatientId(id)
  24028. var result string
  24029. var requestLog string
  24030. if id_card_type == 1 {
  24031. bas := strings.Split(psn_info.CardInfo, "|")
  24032. basNumber := bas[2]
  24033. card_sn := ""
  24034. 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)
  24035. saveLog(result, requestLog, "2201A", "挂号")
  24036. } else if id_card_type == 2 {
  24037. 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, "", "", "", "", "", "")
  24038. saveLog(result, requestLog, "2201A", "挂号")
  24039. } else {
  24040. 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)
  24041. saveLog(result, requestLog, "2201A", "挂号")
  24042. }
  24043. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24044. utils.ErrorLog("解析失败:%v", err)
  24045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24046. return
  24047. }
  24048. infocode = resThree.Infcode
  24049. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24050. psn_info, _ := service.GetPsnByPatientId(id)
  24051. his.PsnNo = psn_info.PsnNo
  24052. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24053. var cert_no string
  24054. if id_card_type == 1 {
  24055. bas := strings.Split(psn_info.CardInfo, "|")
  24056. cert_no = bas[2]
  24057. } else if id_card_type == 4 {
  24058. cert_no = psn_info.VerifyNumber
  24059. psn_info.VerifyNumber = psn_info.VerifyNumber
  24060. IdCardNo = psn_info.VerifyNumber
  24061. } else {
  24062. cert_no = IdCardNo
  24063. psn_info.VerifyNumber = cert_no
  24064. }
  24065. for _, item := range rf {
  24066. if item.Insutype == insutype {
  24067. his.InsuplcAdmdvs = insuplc_admdvs
  24068. }
  24069. }
  24070. his.Insutype = insutype
  24071. var api string
  24072. ipt_otp_no = timeFormat
  24073. 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 +
  24074. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24075. "&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
  24076. resp, requestErr := http.Get(api)
  24077. if requestErr != nil {
  24078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24079. return
  24080. }
  24081. body, ioErr := ioutil.ReadAll(resp.Body)
  24082. if ioErr != nil {
  24083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24085. return
  24086. }
  24087. var respJSON map[string]interface{}
  24088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24091. return
  24092. }
  24093. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24094. if status == "0" {
  24095. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24096. c.ServeSuccessJSON(map[string]interface{}{
  24097. "failed_code": -10,
  24098. "msg": err_msg,
  24099. })
  24100. return
  24101. }
  24102. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24103. result, _ := json.Marshal(respJSON)
  24104. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24105. utils.ErrorLog("解析失败:%v", err)
  24106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24107. return
  24108. }
  24109. infocode = resThree.Infcode
  24110. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24111. psn_info, _ := service.GetPsnByPatientId(id)
  24112. his.PsnNo = psn_info.PsnNo
  24113. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24114. var cert_no string
  24115. if id_card_type == 1 {
  24116. bas := strings.Split(psn_info.CardInfo, "|")
  24117. cert_no = bas[2]
  24118. } else if id_card_type == 4 {
  24119. cert_no = psn_info.VerifyNumber
  24120. psn_info.VerifyNumber = psn_info.VerifyNumber
  24121. IdCardNo = psn_info.VerifyNumber
  24122. } else {
  24123. cert_no = IdCardNo
  24124. psn_info.VerifyNumber = cert_no
  24125. }
  24126. for _, item := range rf {
  24127. if item.Insutype == insutype {
  24128. his.InsuplcAdmdvs = insuplc_admdvs
  24129. patient.InsuplcAdmdvs = insuplc_admdvs
  24130. }
  24131. }
  24132. his.Insutype = insutype
  24133. var api string
  24134. ipt_otp_no = timeFormat
  24135. 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 +
  24136. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24137. "&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
  24138. resp, requestErr := http.Get(api)
  24139. if requestErr != nil {
  24140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24141. return
  24142. }
  24143. body, ioErr := ioutil.ReadAll(resp.Body)
  24144. if ioErr != nil {
  24145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24147. return
  24148. }
  24149. var respJSON map[string]interface{}
  24150. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24153. return
  24154. }
  24155. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24156. if status == "0" {
  24157. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24158. c.ServeSuccessJSON(map[string]interface{}{
  24159. "failed_code": -10,
  24160. "msg": err_msg,
  24161. })
  24162. return
  24163. }
  24164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24165. result, _ := json.Marshal(respJSON)
  24166. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24167. utils.ErrorLog("解析失败:%v", err)
  24168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24169. return
  24170. }
  24171. infocode = resThree.Infcode
  24172. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24173. psn_info, _ := service.GetPsnByPatientId(id)
  24174. var result string
  24175. var requestLog string
  24176. if id_card_type == 1 {
  24177. bas := strings.Split(psn_info.CardInfo, "|")
  24178. basNumber := bas[2]
  24179. card_sn := bas[3]
  24180. 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)
  24181. saveLog(result, requestLog, "2201A", "挂号")
  24182. } else if id_card_type == 2 {
  24183. 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, "", "")
  24184. saveLog(result, requestLog, "2201A", "挂号")
  24185. } else {
  24186. 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, "", "")
  24187. saveLog(result, requestLog, "2201A", "挂号")
  24188. }
  24189. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24190. utils.ErrorLog("解析失败:%v", err)
  24191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24192. return
  24193. }
  24194. infocode = resThree.Infcode
  24195. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24196. psn_info, _ := service.GetPsnByPatientId(id)
  24197. 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)
  24198. saveLog(result, requestLog, "2201A", "挂号")
  24199. if miConfig.Code == "H15049901371" {
  24200. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24201. utils.ErrorLog("解析失败:%v", err)
  24202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24203. return
  24204. }
  24205. resThree.ErrMsg = resThree10265.ErrMsg
  24206. resThree.Output = resThree10265.Output
  24207. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24208. } else {
  24209. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24210. utils.ErrorLog("解析失败:%v", err)
  24211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24212. return
  24213. }
  24214. }
  24215. if miConfig.Code == "H15049901371" {
  24216. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24217. } else {
  24218. infocode = resThree.Infcode
  24219. }
  24220. } else {
  24221. psn_info, _ := service.GetPsnByPatientId(id)
  24222. if id_card_type == 4 || id_card_type == 1 {
  24223. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24224. }
  24225. var rf []*ResultFive
  24226. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24227. var insutypes []*ResultFive
  24228. var insutype string
  24229. var is390 int = 0
  24230. var is310 int = 0
  24231. for _, item := range rf {
  24232. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24233. insutypes = append(insutypes, item)
  24234. }
  24235. }
  24236. if len(insutypes) == 1 {
  24237. insutype = insutypes[0].Insutype
  24238. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24239. } else {
  24240. for _, i := range insutypes {
  24241. if i.Insutype == "390" {
  24242. is390 = 1
  24243. }
  24244. if i.Insutype == "310" {
  24245. is310 = 1
  24246. }
  24247. }
  24248. }
  24249. if is390 == 1 {
  24250. insutype = "390"
  24251. }
  24252. if is310 == 1 {
  24253. insutype = "310"
  24254. }
  24255. fmt.Println(len(insutypes))
  24256. if len(insutypes) == 0 {
  24257. for index, item := range rf {
  24258. if index == 0 {
  24259. insutype = item.Insutype
  24260. insuplc_admdvs = item.InsuplcAdmdvs
  24261. }
  24262. }
  24263. fmt.Println(insutype)
  24264. fmt.Println(insuplc_admdvs)
  24265. }
  24266. if social_type > 0 {
  24267. insutype = strconv.FormatInt(social_type, 10)
  24268. }
  24269. fmt.Println("--------")
  24270. fmt.Println(psn_info)
  24271. fmt.Println(psn_info.PsnNo)
  24272. if miConfig.MdtrtareaAdmvs == "441202" {
  24273. var hisPrescription []*models.HisPrescription
  24274. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24275. if res3101.Infcode == 0 {
  24276. fmt.Println("33333333")
  24277. if len(res3101.Output.Result) > 0 {
  24278. fmt.Println("222222")
  24279. for _, item := range res3101.Output.Result {
  24280. if len(res3101.ErrMsg) == 0 {
  24281. res3101.ErrMsg = item.VolaCont
  24282. } else {
  24283. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24284. }
  24285. }
  24286. c.ServeSuccessJSON(map[string]interface{}{
  24287. "failed_code": -10,
  24288. "msg": res3101.ErrMsg,
  24289. })
  24290. return
  24291. } else {
  24292. hour := time.Now().Format("15")
  24293. min := time.Now().Format("04")
  24294. sec := time.Now().Format("05")
  24295. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24296. fmt.Println(record_time_two)
  24297. 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)
  24298. saveLog(result, requestLog, "2201A", "挂号")
  24299. if miConfig.Code == "H15049901371" {
  24300. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24301. utils.ErrorLog("解析失败:%v", err)
  24302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24303. return
  24304. }
  24305. resThree.ErrMsg = resThree10265.ErrMsg
  24306. resThree.Output = resThree10265.Output
  24307. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24308. } else {
  24309. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24310. utils.ErrorLog("解析失败:%v", err)
  24311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24312. return
  24313. }
  24314. }
  24315. if miConfig.Code == "H15049901371" {
  24316. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24317. } else {
  24318. infocode = resThree.Infcode
  24319. }
  24320. }
  24321. } else if res3101.Infcode != 0 {
  24322. c.ServeSuccessJSON(map[string]interface{}{
  24323. "failed_code": -10,
  24324. "msg": res3101.ErrMsg,
  24325. })
  24326. return
  24327. }
  24328. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24329. var hisPrescription []*models.HisPrescription
  24330. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24331. if res3101.Infcode == 0 {
  24332. fmt.Println("33333333")
  24333. if len(res3101.Output.Result) > 0 {
  24334. fmt.Println("222222")
  24335. for _, item := range res3101.Output.Result {
  24336. if len(res3101.ErrMsg) == 0 {
  24337. res3101.ErrMsg = item.VolaCont
  24338. } else {
  24339. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24340. }
  24341. }
  24342. c.ServeSuccessJSON(map[string]interface{}{
  24343. "failed_code": -10,
  24344. "msg": res3101.ErrMsg,
  24345. })
  24346. return
  24347. } else {
  24348. hour := time.Now().Format("15")
  24349. min := time.Now().Format("04")
  24350. sec := time.Now().Format("05")
  24351. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24352. fmt.Println(record_time_two)
  24353. 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)
  24354. saveLog(result, requestLog, "2201A", "挂号")
  24355. if miConfig.Code == "H15049901371" {
  24356. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24357. utils.ErrorLog("解析失败:%v", err)
  24358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24359. return
  24360. }
  24361. resThree.ErrMsg = resThree10265.ErrMsg
  24362. resThree.Output = resThree10265.Output
  24363. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24364. } else {
  24365. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24366. utils.ErrorLog("解析失败:%v", err)
  24367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24368. return
  24369. }
  24370. }
  24371. if miConfig.Code == "H15049901371" {
  24372. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24373. } else {
  24374. infocode = resThree.Infcode
  24375. }
  24376. }
  24377. } else if res3101.Infcode != 0 {
  24378. c.ServeSuccessJSON(map[string]interface{}{
  24379. "failed_code": -10,
  24380. "msg": res3101.ErrMsg,
  24381. })
  24382. return
  24383. }
  24384. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24385. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24386. psn_info, _ := service.GetPsnByPatientId(id)
  24387. var verify_number string
  24388. if id_card_type == 4 {
  24389. verify_number = psn_info.VerifyNumber
  24390. } else if id_card_type == 1 {
  24391. bas := strings.Split(psn_info.CardInfo, "|")
  24392. cardNumber := bas[2]
  24393. verify_number = cardNumber
  24394. } else {
  24395. verify_number = psn_info.Certno
  24396. }
  24397. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24398. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24399. "&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
  24400. resp, requestErr := http.Get(api)
  24401. if requestErr != nil {
  24402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24403. return
  24404. }
  24405. body, ioErr := ioutil.ReadAll(resp.Body)
  24406. if ioErr != nil {
  24407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24409. return
  24410. }
  24411. var respJSON map[string]interface{}
  24412. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24415. return
  24416. }
  24417. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24418. result, _ := json.Marshal(respJSON)
  24419. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24420. utils.ErrorLog("解析失败:%v", err)
  24421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24422. return
  24423. }
  24424. infocode = resThree.Infcode
  24425. } else {
  24426. hour := time.Now().Format("15")
  24427. min := time.Now().Format("04")
  24428. sec := time.Now().Format("05")
  24429. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24430. if id_card_type == 1 {
  24431. for _, item := range rf {
  24432. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24433. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24434. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24435. } else if strconv.FormatInt(social_type, 10) == "390" {
  24436. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24437. } else {
  24438. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24439. }
  24440. }
  24441. }
  24442. }
  24443. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24444. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24445. }
  24446. if id_card_type == 1 {
  24447. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24448. bas := strings.Split(psn_info.CardInfo, "|")
  24449. basNumber := bas[1]
  24450. IdCardNo = basNumber
  24451. }
  24452. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24453. IdCardNo = psn_info.VerifyNumber
  24454. }
  24455. if len(insuplc_admdvs_temp) == 0 {
  24456. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24457. }
  24458. var result string
  24459. var requestLog string
  24460. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  24461. var hisPrescription []*models.HisPrescription
  24462. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24463. if res3101.Infcode == 0 {
  24464. if len(res3101.Output.Result) > 0 {
  24465. for _, item := range res3101.Output.Result {
  24466. if len(res3101.ErrMsg) == 0 {
  24467. res3101.ErrMsg = item.VolaCont
  24468. } else {
  24469. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24470. }
  24471. }
  24472. c.ServeSuccessJSON(map[string]interface{}{
  24473. "failed_code": -10,
  24474. "msg": res3101.ErrMsg,
  24475. })
  24476. return
  24477. } else {
  24478. hour := time.Now().Format("15")
  24479. min := time.Now().Format("04")
  24480. sec := time.Now().Format("05")
  24481. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24482. fmt.Println(record_time_two)
  24483. 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)
  24484. saveLog(result, requestLog, "2201A", "挂号")
  24485. if miConfig.Code == "H15049901371" {
  24486. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24487. utils.ErrorLog("解析失败:%v", err)
  24488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24489. return
  24490. }
  24491. resThree.ErrMsg = resThree10265.ErrMsg
  24492. resThree.Output = resThree10265.Output
  24493. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24494. } else {
  24495. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24496. utils.ErrorLog("解析失败:%v", err)
  24497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24498. return
  24499. }
  24500. }
  24501. if miConfig.Code == "H15049901371" {
  24502. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24503. } else {
  24504. infocode = resThree.Infcode
  24505. }
  24506. }
  24507. } else if res3101.Infcode != 0 {
  24508. c.ServeSuccessJSON(map[string]interface{}{
  24509. "failed_code": -10,
  24510. "msg": res3101.ErrMsg,
  24511. })
  24512. return
  24513. }
  24514. } else {
  24515. psn_info, _ := service.GetPsnByPatientId(id)
  24516. var rf []*ResultFive
  24517. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24518. //var insutypes []*ResultFive
  24519. var insutype string
  24520. if social_type > 0 {
  24521. insutype = strconv.FormatInt(social_type, 10)
  24522. }
  24523. for _, item := range rf {
  24524. if item.Insutype == insutype {
  24525. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24526. }
  24527. }
  24528. 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)
  24529. saveLog(result, requestLog, "2201A", "挂号")
  24530. }
  24531. if miConfig.Code == "H15049901371" {
  24532. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24533. utils.ErrorLog("解析失败:%v", err)
  24534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24535. return
  24536. }
  24537. resThree.ErrMsg = resThree10265.ErrMsg
  24538. resThree.Output = resThree10265.Output
  24539. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24540. } else {
  24541. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24542. utils.ErrorLog("解析失败:%v", err)
  24543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24544. return
  24545. }
  24546. }
  24547. if miConfig.Code == "H15049901371" {
  24548. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24549. } else {
  24550. infocode = resThree.Infcode
  24551. }
  24552. }
  24553. }
  24554. if infocode == -1 {
  24555. adminUser := c.GetAdminUserInfo()
  24556. errlog := &models.HisOrderError{
  24557. UserOrgId: adminUser.CurrentOrgId,
  24558. Ctime: time.Now().Unix(),
  24559. Mtime: time.Now().Unix(),
  24560. ErrMsg: resThree.ErrMsg,
  24561. Status: 1,
  24562. PatientId: id,
  24563. RecordTime: recordDateTime,
  24564. Stage: 2,
  24565. }
  24566. service.CreateErrMsgLog(errlog)
  24567. c.ServeSuccessJSON(map[string]interface{}{
  24568. "failed_code": -10,
  24569. "msg": resThree.ErrMsg,
  24570. })
  24571. return
  24572. }
  24573. his.Number = resThree.Output.Data.MdtrtID
  24574. his.PsnNo = resThree.Output.Data.PsnNo
  24575. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24576. his.IdCardNo = patient.IdCardNo
  24577. his.PhoneNumber = patient.Phone
  24578. his.UserOrgId = adminInfo.CurrentOrgId
  24579. his.Insutype = insutype
  24580. his.Ctime = time.Now().Unix()
  24581. his.Mtime = time.Now().Unix()
  24582. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24583. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24584. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24585. }
  24586. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24587. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24588. }
  24589. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24590. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24591. }
  24592. his.Status = 1
  24593. his.MdtrtGrpType = mdtrt_type
  24594. service.UpdateHisPatientStatus(&his)
  24595. service.UpdateHisPatient123(&patient)
  24596. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24597. c.ServeSuccessJSON(map[string]interface{}{
  24598. "his_info": his,
  24599. })
  24600. } else {
  24601. adminUser := c.GetAdminUserInfo()
  24602. errlog := &models.HisOrderError{
  24603. UserOrgId: adminUser.CurrentOrgId,
  24604. Ctime: time.Now().Unix(),
  24605. Mtime: time.Now().Unix(),
  24606. ErrMsg: res.ErrMsg,
  24607. Status: 1,
  24608. PatientId: id,
  24609. RecordTime: recordDateTime,
  24610. Stage: 1,
  24611. }
  24612. service.CreateErrMsgLog(errlog)
  24613. c.ServeSuccessJSON(map[string]interface{}{
  24614. "failed_code": -10,
  24615. "msg": res.ErrMsg,
  24616. })
  24617. return
  24618. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24619. }
  24620. }
  24621. }
  24622. func (c *HisApiController) GetUploadInfo() {
  24623. id, _ := c.GetInt64("id")
  24624. record_time := c.GetString("record_time")
  24625. his_patient_id, _ := c.GetInt64("his_patient_id")
  24626. order_id, _ := c.GetInt64("order_id")
  24627. pay_way, _ := c.GetInt64("pay_way")
  24628. pay_ways := c.GetString("pay_ways")
  24629. oth_desc := c.GetString("oth_desc")
  24630. pay_price, _ := c.GetFloat("pay_price")
  24631. pay_card_no := c.GetString("pay_card_no")
  24632. discount_price, _ := c.GetFloat("discount_price")
  24633. preferential_price, _ := c.GetFloat("preferential_price")
  24634. reality_price, _ := c.GetFloat("reality_price")
  24635. found_price, _ := c.GetFloat("found_price")
  24636. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24637. private_price, _ := c.GetFloat("private_price")
  24638. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24639. admin_user_id, _ := c.GetInt64("admin_user_id")
  24640. fapiao_code := c.GetString("fapiao_code")
  24641. fapiao_number := c.GetString("fapiao_number")
  24642. diagnosis_id := c.GetString("diagnosis")
  24643. sick_type, _ := c.GetInt64("sick_type")
  24644. reg_type, _ := c.GetInt64("p_type")
  24645. begin_time := c.GetString("begin_time")
  24646. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24647. cash_pay := c.GetString("cash_pay")
  24648. band_card_pay := c.GetString("band_card_pay")
  24649. wechat_pay := c.GetString("wechat_pay")
  24650. ali_pay := c.GetString("ali_pay")
  24651. jifen_pay := c.GetString("jifen_pay")
  24652. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24653. fmt.Println(acct_used_flag)
  24654. id_str := c.GetString("ids")
  24655. ids_arr := strings.Split(id_str, ",")
  24656. timeLayout := "2006-01-02"
  24657. loc, _ := time.LoadLocation("Local")
  24658. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24659. if err != nil {
  24660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24661. return
  24662. }
  24663. recordDateTime := theTime.Unix()
  24664. adminUser := c.GetAdminUserInfo()
  24665. var tempOrder models.HisOrder
  24666. tempOrder, _ = service.GetHisOrderByID(order_id)
  24667. var prescriptions []*models.HisPrescription
  24668. var start_time int64
  24669. var end_time int64
  24670. //押金模块
  24671. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24672. tmp_decimal := c.GetString("tmp_decimal")
  24673. var decimal float64 //本次使用的押金
  24674. var errmsg error
  24675. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24676. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24677. return
  24678. }
  24679. if len(tmp_decimal) > 0 {
  24680. if tmp_decimal[0] == 45 {
  24681. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24682. return
  24683. }
  24684. }
  24685. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24686. fmt.Println(errs)
  24687. decimal = tt
  24688. //if adminUser.CurrentOrgId == 10106{
  24689. // if len(fapiao_code) == 0{
  24690. // fapiao_code = "144072080589"
  24691. // }
  24692. // if len(fapiao_number) == 0{
  24693. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24694. // if order.ID == 0{
  24695. // fapiao_number = "00001520"
  24696. // }else{
  24697. // //fapiao_code = "00001520"
  24698. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24699. // var zero string
  24700. // if fpNumber >= 1000{
  24701. // zero = "0000" + strconv.Itoa(fpNumber)
  24702. // }else if fpNumber >= 10000{
  24703. // zero = "000" + strconv.Itoa(fpNumber)
  24704. // } else if fpNumber >= 100000{
  24705. // zero = "00" + strconv.Itoa(fpNumber)
  24706. // } else if fpNumber >= 1000000{
  24707. // zero = "0" + strconv.Itoa(fpNumber)
  24708. // }else {
  24709. // zero = strconv.Itoa(fpNumber)
  24710. // }
  24711. // fapiao_number = zero
  24712. // }
  24713. // }
  24714. //}
  24715. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24716. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24717. var patientPrescription models.HisPrescriptionInfo
  24718. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24719. if patientPrescription.ID == 0 {
  24720. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24721. }
  24722. //if patientPrescription.Do
  24723. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24724. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24725. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24726. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24727. var config []*models.HisXtDiagnoseConfig
  24728. for _, item := range diagnosis_ids {
  24729. id, _ := strconv.ParseInt(item, 10, 64)
  24730. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24731. config = append(config, &diagnosisConfig)
  24732. }
  24733. sickConfig, _ := service.FindSickById(sick_type)
  24734. //if tempOrder.ID == 0 {
  24735. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24736. //}
  24737. if tempOrder.ID == 0 {
  24738. var result string
  24739. var requestLog string
  24740. var res2 ResultSix
  24741. var res3 GZResultSix
  24742. var ressix10265 ResultSix10265
  24743. if miConfig.MdtrtareaAdmvs == "421300" {
  24744. data := make(map[string]interface{})
  24745. client := &http.Client{}
  24746. data["psn_no"] = his.PsnNo
  24747. data["mdtrt_id"] = his.Number
  24748. data["opter"] = roles.UserName
  24749. data["org_name"] = miConfig.OrgName
  24750. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24751. data["doctor_id"] = doctor_info.DoctorNumber
  24752. data["doctor_name"] = doctor_info.UserName
  24753. data["department"] = department.Name
  24754. data["fixmedins_code"] = miConfig.Code
  24755. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24756. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24757. data["secret_key"] = miConfig.SecretKey
  24758. data["sick_code"] = sickConfig.CountryCode
  24759. data["sick_name"] = sickConfig.ClassName
  24760. data["dept"] = strconv.FormatInt(department.ID, 10)
  24761. data["config"] = config
  24762. data["begin_time"] = begin_time
  24763. bytesData, _ := json.Marshal(data)
  24764. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24765. resp, _ := client.Do(req)
  24766. defer resp.Body.Close()
  24767. body, ioErr := ioutil.ReadAll(resp.Body)
  24768. if ioErr != nil {
  24769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24771. return
  24772. }
  24773. var respJSON map[string]interface{}
  24774. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24777. return
  24778. }
  24779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24780. userJSONBytes, _ := json.Marshal(respJSON)
  24781. fmt.Println("log")
  24782. fmt.Println(string(userJSONBytes))
  24783. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24784. utils.ErrorLog("解析失败:%v", err)
  24785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24786. return
  24787. }
  24788. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24789. data := make(map[string]interface{})
  24790. client := &http.Client{}
  24791. data["psn_no"] = his.PsnNo
  24792. data["mdtrt_id"] = his.Number
  24793. data["opter"] = roles.UserName
  24794. data["org_name"] = miConfig.OrgName
  24795. if reg_type == 11 && his.Insutype == "390" {
  24796. data["med_type"] = "110104"
  24797. } else {
  24798. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24799. }
  24800. data["doctor_id"] = doctor_info.DoctorNumber
  24801. data["doctor_name"] = doctor_info.UserName
  24802. data["department"] = department.Name
  24803. data["fixmedins_code"] = miConfig.Code
  24804. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24805. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24806. data["secret_key"] = miConfig.SecretKey
  24807. data["sick_code"] = sickConfig.CountryCode
  24808. data["sick_name"] = sickConfig.ClassName
  24809. data["dept"] = strconv.FormatInt(department.ID, 10)
  24810. data["config"] = config
  24811. data["begin_time"] = begin_time
  24812. bytesData, _ := json.Marshal(data)
  24813. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24814. resp, _ := client.Do(req)
  24815. defer resp.Body.Close()
  24816. body, ioErr := ioutil.ReadAll(resp.Body)
  24817. if ioErr != nil {
  24818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24820. return
  24821. }
  24822. var respJSON map[string]interface{}
  24823. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24826. return
  24827. }
  24828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24829. userJSONBytes, _ := json.Marshal(respJSON)
  24830. fmt.Println("log")
  24831. fmt.Println(string(userJSONBytes))
  24832. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24833. utils.ErrorLog("解析失败:%v", err)
  24834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24835. return
  24836. }
  24837. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24838. data := make(map[string]interface{})
  24839. client := &http.Client{}
  24840. data["psn_no"] = his.PsnNo
  24841. data["mdtrt_id"] = his.Number
  24842. data["opter"] = roles.UserName
  24843. data["org_name"] = miConfig.OrgName
  24844. if reg_type == 11 && his.Insutype == "390" {
  24845. data["med_type"] = "110104"
  24846. } else {
  24847. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24848. }
  24849. data["doctor_id"] = doctor_info.DoctorNumber
  24850. data["doctor_name"] = doctor_info.UserName
  24851. data["department"] = department.Name
  24852. data["fixmedins_code"] = miConfig.Code
  24853. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24854. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24855. data["secret_key"] = miConfig.SecretKey
  24856. data["sick_code"] = sickConfig.CountryCode
  24857. data["sick_name"] = sickConfig.ClassName
  24858. data["dept"] = strconv.FormatInt(department.ID, 10)
  24859. data["config"] = config
  24860. data["begin_time"] = begin_time
  24861. bytesData, _ := json.Marshal(data)
  24862. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24863. resp, _ := client.Do(req)
  24864. defer resp.Body.Close()
  24865. body, ioErr := ioutil.ReadAll(resp.Body)
  24866. if ioErr != nil {
  24867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24869. return
  24870. }
  24871. var respJSON map[string]interface{}
  24872. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24875. return
  24876. }
  24877. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24878. userJSONBytes, _ := json.Marshal(respJSON)
  24879. fmt.Println("log")
  24880. fmt.Println(string(userJSONBytes))
  24881. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24882. utils.ErrorLog("解析失败:%v", err)
  24883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24884. return
  24885. }
  24886. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24887. data := make(map[string]interface{})
  24888. client := &http.Client{}
  24889. data["psn_no"] = his.PsnNo
  24890. data["mdtrt_id"] = his.Number
  24891. data["opter"] = roles.UserName
  24892. data["org_name"] = miConfig.OrgName
  24893. if reg_type == 11 && his.Insutype == "390" {
  24894. data["med_type"] = "110104"
  24895. } else {
  24896. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24897. }
  24898. data["doctor_id"] = doctor_info.DoctorNumber
  24899. data["doctor_name"] = doctor_info.UserName
  24900. data["department"] = department.Name
  24901. data["fixmedins_code"] = miConfig.Code
  24902. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24903. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24904. data["secret_key"] = miConfig.SecretKey
  24905. data["sick_code"] = sickConfig.CountryCode
  24906. data["sick_name"] = sickConfig.ClassName
  24907. data["dept"] = strconv.FormatInt(department.ID, 10)
  24908. data["config"] = config
  24909. data["begin_time"] = begin_time
  24910. bytesData, _ := json.Marshal(data)
  24911. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24912. resp, _ := client.Do(req)
  24913. defer resp.Body.Close()
  24914. body, ioErr := ioutil.ReadAll(resp.Body)
  24915. if ioErr != nil {
  24916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24918. return
  24919. }
  24920. var respJSON map[string]interface{}
  24921. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24924. return
  24925. }
  24926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24927. userJSONBytes, _ := json.Marshal(respJSON)
  24928. fmt.Println("log")
  24929. fmt.Println(string(userJSONBytes))
  24930. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24931. utils.ErrorLog("解析失败:%v", err)
  24932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24933. return
  24934. }
  24935. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24936. data := make(map[string]interface{})
  24937. client := &http.Client{}
  24938. data["psn_no"] = his.PsnNo
  24939. data["mdtrt_id"] = his.Number
  24940. data["doctor"] = roles.UserName
  24941. data["department"] = department.Name
  24942. data["org_name"] = miConfig.OrgName
  24943. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24944. data["doctor_id"] = doctor_info.DoctorNumber
  24945. data["new_doctor_name"] = doctor_info.UserName
  24946. data["fixmedins_code"] = miConfig.Code
  24947. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24948. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24949. data["secret_key"] = miConfig.SecretKey
  24950. data["sick_code"] = sickConfig.CountryCode
  24951. data["sick_name"] = sickConfig.ClassName
  24952. data["url"] = miConfig.Url
  24953. data["ak"] = miConfig.AccessKey
  24954. data["begin_time"] = begin_time
  24955. data["cainfo"] = miConfig.Cainfo
  24956. data["dept"] = strconv.FormatInt(department.ID, 10)
  24957. data["config"] = config
  24958. bytesData, _ := json.Marshal(data)
  24959. var req *http.Request
  24960. if miConfig.MdtrtareaAdmvs == "320921" {
  24961. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24962. //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 +
  24963. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  24964. } else {
  24965. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24966. }
  24967. resp, _ := client.Do(req)
  24968. defer resp.Body.Close()
  24969. body, ioErr := ioutil.ReadAll(resp.Body)
  24970. if ioErr != nil {
  24971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24973. return
  24974. }
  24975. var respJSON map[string]interface{}
  24976. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24979. return
  24980. }
  24981. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24982. userJSONBytes, _ := json.Marshal(respJSON)
  24983. fmt.Println("log")
  24984. fmt.Println(string(userJSONBytes))
  24985. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  24986. utils.ErrorLog("解析失败:%v", err)
  24987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24988. return
  24989. }
  24990. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24991. res2.Output = ressix10265.Output
  24992. res2.ErrMsg = ressix10265.ErrMsg
  24993. res2.Cainfo = ressix10265.Cainfo
  24994. res2.WarnMsg = ressix10265.WarnMsg
  24995. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24996. res2.Infcode = infocode
  24997. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24998. data := make(map[string]interface{})
  24999. client := &http.Client{}
  25000. data["psn_no"] = his.PsnNo
  25001. data["mdtrt_id"] = his.Number
  25002. data["doctor"] = roles.UserName
  25003. data["department"] = department.Name
  25004. data["org_name"] = miConfig.OrgName
  25005. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25006. data["doctor_id"] = doctor_info.DoctorNumber
  25007. data["new_doctor_name"] = doctor_info.UserName
  25008. data["fixmedins_code"] = miConfig.Code
  25009. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25010. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25011. data["secret_key"] = miConfig.SecretKey
  25012. data["sick_code"] = sickConfig.CountryCode
  25013. data["sick_name"] = sickConfig.ClassName
  25014. data["url"] = miConfig.Url
  25015. data["ak"] = miConfig.AccessKey
  25016. data["begin_time"] = begin_time
  25017. data["cainfo"] = miConfig.Cainfo
  25018. data["dept"] = strconv.FormatInt(department.ID, 10)
  25019. data["config"] = config
  25020. bytesData, _ := json.Marshal(data)
  25021. var req *http.Request
  25022. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25023. resp, _ := client.Do(req)
  25024. defer resp.Body.Close()
  25025. body, ioErr := ioutil.ReadAll(resp.Body)
  25026. if ioErr != nil {
  25027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25029. return
  25030. }
  25031. var respJSON map[string]interface{}
  25032. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25035. return
  25036. }
  25037. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25038. userJSONBytes, _ := json.Marshal(respJSON)
  25039. fmt.Println("log")
  25040. fmt.Println(string(userJSONBytes))
  25041. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25042. utils.ErrorLog("解析失败:%v", err)
  25043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25044. return
  25045. }
  25046. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25047. res2.Output = ressix10265.Output
  25048. res2.ErrMsg = ressix10265.ErrMsg
  25049. res2.Cainfo = ressix10265.Cainfo
  25050. res2.WarnMsg = ressix10265.WarnMsg
  25051. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25052. res2.Infcode = infocode
  25053. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25054. 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)
  25055. saveLog(result, requestLog, "2203", "上传就诊信息")
  25056. var respJSON2 map[string]interface{}
  25057. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25060. return
  25061. }
  25062. userJSONBytes2, _ := json.Marshal(respJSON2)
  25063. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25064. utils.ErrorLog("解析失败:%v", err)
  25065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25066. return
  25067. }
  25068. 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)
  25069. fmt.Println(result2)
  25070. fmt.Println(src_request)
  25071. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25072. data := make(map[string]interface{})
  25073. client := &http.Client{}
  25074. data["psn_no"] = his.PsnNo
  25075. data["mdtrt_id"] = his.Number
  25076. data["doctor"] = roles.UserName
  25077. data["department"] = department.Name
  25078. data["org_name"] = miConfig.OrgName
  25079. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25080. data["doctor_id"] = doctor_info.DoctorNumber
  25081. data["new_doctor_name"] = doctor_info.UserName
  25082. data["fixmedins_code"] = miConfig.Code
  25083. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25084. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25085. data["secret_key"] = miConfig.SecretKey
  25086. data["sick_code"] = sickConfig.CountryCode
  25087. data["sick_name"] = sickConfig.ClassName
  25088. data["url"] = miConfig.Url
  25089. data["ak"] = miConfig.AccessKey
  25090. data["begin_time"] = begin_time
  25091. data["cainfo"] = miConfig.Cainfo
  25092. data["dept"] = strconv.FormatInt(department.ID, 10)
  25093. data["config"] = config
  25094. bytesData, _ := json.Marshal(data)
  25095. var req *http.Request
  25096. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25097. resp, _ := client.Do(req)
  25098. defer resp.Body.Close()
  25099. body, ioErr := ioutil.ReadAll(resp.Body)
  25100. if ioErr != nil {
  25101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25103. return
  25104. }
  25105. var respJSON map[string]interface{}
  25106. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25109. return
  25110. }
  25111. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25112. userJSONBytes, _ := json.Marshal(respJSON)
  25113. fmt.Println("log")
  25114. fmt.Println(string(userJSONBytes))
  25115. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25116. utils.ErrorLog("解析失败:%v", err)
  25117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25118. return
  25119. }
  25120. } else {
  25121. if miConfig.MdtrtareaAdmvs == "440781" { //
  25122. 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)
  25123. } else {
  25124. if miConfig.Code == "H15049901371" {
  25125. //赤峰地区国家医保医疗类别
  25126. //职工透析:医疗类别选特殊情况门诊990502
  25127. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25128. var med_type string
  25129. if his.Insutype == "390" {
  25130. if reg_type == 14 {
  25131. med_type = "9933"
  25132. } else if reg_type == 11 {
  25133. med_type = "11"
  25134. }
  25135. } else if his.Insutype == "310" {
  25136. if reg_type == 14 {
  25137. med_type = "990502"
  25138. } else if reg_type == 11 {
  25139. med_type = "11"
  25140. }
  25141. }
  25142. 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)
  25143. } else {
  25144. 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)
  25145. }
  25146. }
  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 miConfig.Code == "H15049901371" {
  25156. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25157. utils.ErrorLog("解析失败:%v", err)
  25158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25159. return
  25160. }
  25161. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25162. res2.Output = ressix10265.Output
  25163. res2.ErrMsg = ressix10265.ErrMsg
  25164. res2.Cainfo = ressix10265.Cainfo
  25165. res2.WarnMsg = ressix10265.WarnMsg
  25166. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25167. res2.Infcode = infocode
  25168. } else {
  25169. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25170. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25171. utils.ErrorLog("解析失败:%v", err)
  25172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25173. return
  25174. }
  25175. res2.Infcode = res3.Infcode
  25176. } else {
  25177. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25178. utils.ErrorLog("解析失败:%v", err)
  25179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25180. return
  25181. }
  25182. }
  25183. }
  25184. }
  25185. if res2.Infcode == -1 {
  25186. adminUser := c.GetAdminUserInfo()
  25187. errlog := &models.HisOrderError{
  25188. UserOrgId: adminUser.CurrentOrgId,
  25189. Ctime: time.Now().Unix(),
  25190. Mtime: time.Now().Unix(),
  25191. ErrMsg: res2.ErrMsg,
  25192. Status: 1,
  25193. PatientId: id,
  25194. RecordTime: recordDateTime,
  25195. Stage: 3,
  25196. }
  25197. service.CreateErrMsgLog(errlog)
  25198. c.ServeSuccessJSON(map[string]interface{}{
  25199. "failed_code": -10,
  25200. "msg": res2.ErrMsg,
  25201. })
  25202. return
  25203. } else {
  25204. his.Diagnosis = diagnosis_id
  25205. his.SickType = sickConfig.ID
  25206. //var p_type int64
  25207. //if reg_type == 1111 || reg_type == 1112 {
  25208. // p_type = 11
  25209. //
  25210. //}
  25211. his.PType = fmt.Sprintf("%d", reg_type)
  25212. service.UpdateHisPatientThree(&his)
  25213. data := make(map[string]interface{})
  25214. if settle_accounts_type == 1 { //日结
  25215. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25216. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25217. } else {
  25218. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25219. }
  25220. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25221. data["pre"] = prescriptions
  25222. } else { //月结
  25223. start_time_str := c.GetString("start_time")
  25224. end_time_str := c.GetString("end_time")
  25225. timeLayout := "2006-01-02"
  25226. loc, _ := time.LoadLocation("Local")
  25227. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25228. if err != nil {
  25229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25230. return
  25231. }
  25232. recordStartTime := theStartTime.Unix()
  25233. start_time = recordStartTime
  25234. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25235. if err != nil {
  25236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25237. return
  25238. }
  25239. recordEndTime := theEndTime.Unix()
  25240. end_time = recordEndTime
  25241. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25242. data["pre"] = prescriptions
  25243. }
  25244. timestamp := time.Now().Unix()
  25245. tempTime := time.Unix(timestamp, 0)
  25246. timeFormat := tempTime.Format("20060102150405")
  25247. chrgBchno := rand.Intn(100000) + 10000
  25248. new_chrg_bchno := ""
  25249. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25250. new_chrg_bchno = chrg_bchno
  25251. strconv.FormatInt(his.PatientId, 10)
  25252. client := &http.Client{}
  25253. if adminUser.CurrentOrgId == 10265 {
  25254. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25255. new_chrg_bchno = "0000"
  25256. }
  25257. }
  25258. data["psn_no"] = his.PsnNo
  25259. data["mdtrt_id"] = his.Number
  25260. data["chrg_bchno"] = new_chrg_bchno
  25261. data["org_name"] = miConfig.OrgName
  25262. data["doctor"] = doctor_info.UserName
  25263. data["doctor_id"] = doctor_info.DoctorNumber
  25264. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25265. data["fixmedins_code"] = miConfig.Code
  25266. data["dept_code"] = department.Number
  25267. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25268. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25269. data["secret_key"] = miConfig.SecretKey
  25270. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25271. data["url"] = miConfig.Url
  25272. data["ak"] = miConfig.AccessKey
  25273. data["new_doctor_name"] = patientPrescription.Doctor
  25274. data["diag_code"] = sickConfig.CountryCode
  25275. data["cainfo"] = miConfig.Cainfo
  25276. data["opter"] = roles.UserName
  25277. var ids []int64
  25278. for _, item := range prescriptions {
  25279. ids = append(ids, item.ID)
  25280. }
  25281. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25282. if config.IsOpen == 1 { //对接了医保,走医保流程
  25283. var res ResultFour
  25284. var resFour10265 ResultFour10265
  25285. if miConfig.MdtrtareaAdmvs == "421300" {
  25286. bytesData, _ := json.Marshal(data)
  25287. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25288. resp, _ := client.Do(req)
  25289. defer resp.Body.Close()
  25290. body, ioErr := ioutil.ReadAll(resp.Body)
  25291. if ioErr != nil {
  25292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25294. return
  25295. }
  25296. var respJSON map[string]interface{}
  25297. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25300. return
  25301. }
  25302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25303. userJSONBytes, _ := json.Marshal(respJSON)
  25304. fmt.Println("log")
  25305. fmt.Println(string(userJSONBytes))
  25306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25307. utils.ErrorLog("解析失败:%v", err)
  25308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25309. return
  25310. }
  25311. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25312. bytesData, _ := json.Marshal(data)
  25313. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25314. resp, _ := client.Do(req)
  25315. defer resp.Body.Close()
  25316. body, ioErr := ioutil.ReadAll(resp.Body)
  25317. if ioErr != nil {
  25318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25320. return
  25321. }
  25322. var respJSON map[string]interface{}
  25323. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25326. return
  25327. }
  25328. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25329. userJSONBytes, _ := json.Marshal(respJSON)
  25330. fmt.Println("log")
  25331. fmt.Println(string(userJSONBytes))
  25332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25333. utils.ErrorLog("解析失败:%v", err)
  25334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25335. return
  25336. }
  25337. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25338. bytesData, _ := json.Marshal(data)
  25339. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25340. resp, _ := client.Do(req)
  25341. defer resp.Body.Close()
  25342. body, ioErr := ioutil.ReadAll(resp.Body)
  25343. if ioErr != nil {
  25344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25346. return
  25347. }
  25348. var respJSON map[string]interface{}
  25349. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25352. return
  25353. }
  25354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25355. userJSONBytes, _ := json.Marshal(respJSON)
  25356. fmt.Println("log")
  25357. fmt.Println(string(userJSONBytes))
  25358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25359. utils.ErrorLog("解析失败:%v", err)
  25360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25361. return
  25362. }
  25363. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25364. bytesData, _ := json.Marshal(data)
  25365. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25366. resp, _ := client.Do(req)
  25367. defer resp.Body.Close()
  25368. body, ioErr := ioutil.ReadAll(resp.Body)
  25369. if ioErr != nil {
  25370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25372. return
  25373. }
  25374. var respJSON map[string]interface{}
  25375. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25378. return
  25379. }
  25380. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25381. userJSONBytes, _ := json.Marshal(respJSON)
  25382. fmt.Println("log")
  25383. fmt.Println(string(userJSONBytes))
  25384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25385. utils.ErrorLog("解析失败:%v", err)
  25386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25387. return
  25388. }
  25389. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25390. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25391. if result3101.Infcode == "0" {
  25392. if len(result3101.Output.Result) > 0 {
  25393. var errMsgs []string
  25394. for _, item := range result3101.Output.Result {
  25395. errMsgs = append(errMsgs, item.VolaCont)
  25396. }
  25397. c.ServeSuccessJSON(map[string]interface{}{
  25398. "failed_code": -10,
  25399. "msg": errMsgs,
  25400. })
  25401. return
  25402. }
  25403. }
  25404. bytesData, _ := json.Marshal(data)
  25405. var req *http.Request
  25406. if miConfig.MdtrtareaAdmvs == "320921" {
  25407. data["diag_code"] = sickConfig.CountryCode
  25408. fmt.Println(data)
  25409. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25410. } else {
  25411. data["diag_code"] = sickConfig.CountryCode
  25412. fmt.Println(data)
  25413. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25414. }
  25415. resp, _ := client.Do(req)
  25416. defer resp.Body.Close()
  25417. body, ioErr := ioutil.ReadAll(resp.Body)
  25418. if ioErr != nil {
  25419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25421. return
  25422. }
  25423. var respJSON map[string]interface{}
  25424. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25427. return
  25428. }
  25429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25430. userJSONBytes, _ := json.Marshal(respJSON)
  25431. fmt.Println("log")
  25432. fmt.Println(string(userJSONBytes))
  25433. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25434. utils.ErrorLog("解析失败:%v", err)
  25435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25436. return
  25437. }
  25438. res.InfRefmsgid = resFour10265.InfRefmsgid
  25439. res.Output = resFour10265.Output
  25440. res.ErrMsg = resFour10265.ErrMsg
  25441. res.Cainfo = resFour10265.Cainfo
  25442. res.WarnMsg = resFour10265.WarnMsg
  25443. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25444. res.Infcode = infocode
  25445. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25446. var pagesize int = 2
  25447. var start int = 1
  25448. var stop int
  25449. var pagecount int
  25450. var curpage int
  25451. var isSuccess bool = true
  25452. data["doctor_id"] = doctor_info.DoctorNumber
  25453. //总页数,向上取整,注意除之前要先转换类型为float64
  25454. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25455. for curpage = 1; curpage <= pagecount; curpage++ {
  25456. if curpage == 1 {
  25457. start = 1
  25458. } else {
  25459. start = (curpage-1)*pagesize + 1
  25460. }
  25461. stop = curpage * pagesize
  25462. if stop > len(prescriptions) {
  25463. stop = len(prescriptions)
  25464. }
  25465. //var requestLog string
  25466. data["pre"] = prescriptions[start-1 : stop]
  25467. fmt.Println(data["pre"])
  25468. bytesData, _ := json.Marshal(data)
  25469. var req *http.Request
  25470. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25471. resp, _ := client.Do(req)
  25472. defer resp.Body.Close()
  25473. body, ioErr := ioutil.ReadAll(resp.Body)
  25474. if ioErr != nil {
  25475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25477. return
  25478. }
  25479. var respJSON map[string]interface{}
  25480. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25483. return
  25484. }
  25485. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25486. userJSONBytes, _ := json.Marshal(respJSON)
  25487. fmt.Println("log")
  25488. fmt.Println(string(userJSONBytes))
  25489. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25490. utils.ErrorLog("解析失败:%v", err)
  25491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25492. return
  25493. }
  25494. res.InfRefmsgid = resFour10265.InfRefmsgid
  25495. res.Output = resFour10265.Output
  25496. res.ErrMsg = resFour10265.ErrMsg
  25497. res.Cainfo = resFour10265.Cainfo
  25498. res.WarnMsg = resFour10265.WarnMsg
  25499. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25500. res.Infcode = infocode
  25501. if infocode == 0 {
  25502. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25503. } else {
  25504. isSuccess = false
  25505. errlog := &models.HisOrderError{
  25506. UserOrgId: adminUser.CurrentOrgId,
  25507. Ctime: time.Now().Unix(),
  25508. Mtime: time.Now().Unix(),
  25509. Number: chrg_bchno,
  25510. ErrMsg: "",
  25511. Status: 1,
  25512. PatientId: id,
  25513. RecordTime: recordDateTime,
  25514. Stage: 4,
  25515. }
  25516. service.CreateErrMsgLog(errlog)
  25517. c.ServeSuccessJSON(map[string]interface{}{
  25518. "failed_code": -10,
  25519. "msg": res.ErrMsg,
  25520. })
  25521. return
  25522. }
  25523. }
  25524. if isSuccess {
  25525. res.Infcode = 0
  25526. }
  25527. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25528. 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)
  25529. var dat map[string]interface{}
  25530. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25531. fmt.Println(dat)
  25532. } else {
  25533. fmt.Println(err)
  25534. }
  25535. saveLog(result, request_log, "2204", "上传费用明细")
  25536. userJSONBytes, _ := json.Marshal(dat)
  25537. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25538. utils.ErrorLog("解析失败:%v", err)
  25539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25540. return
  25541. }
  25542. res.InfRefmsgid = resFour10265.InfRefmsgid
  25543. res.Output = resFour10265.Output
  25544. res.ErrMsg = resFour10265.ErrMsg
  25545. res.Cainfo = resFour10265.Cainfo
  25546. res.WarnMsg = resFour10265.WarnMsg
  25547. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25548. res.Infcode = infocode
  25549. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25550. bytesData, _ := json.Marshal(data)
  25551. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25552. resp, _ := client.Do(req)
  25553. defer resp.Body.Close()
  25554. body, ioErr := ioutil.ReadAll(resp.Body)
  25555. if ioErr != nil {
  25556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25558. return
  25559. }
  25560. var respJSON map[string]interface{}
  25561. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25564. return
  25565. }
  25566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25567. userJSONBytes, _ := json.Marshal(respJSON)
  25568. fmt.Println("log")
  25569. fmt.Println(string(userJSONBytes))
  25570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25571. utils.ErrorLog("解析失败:%v", err)
  25572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25573. return
  25574. }
  25575. } else {
  25576. if miConfig.Code == "H15049901371" {
  25577. 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)
  25578. var dat map[string]interface{}
  25579. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25580. fmt.Println(dat)
  25581. } else {
  25582. fmt.Println(err)
  25583. }
  25584. saveLog(result, request_log, "2204", "上传费用明细")
  25585. userJSONBytes, _ := json.Marshal(dat)
  25586. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25587. utils.ErrorLog("解析失败:%v", err)
  25588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25589. return
  25590. }
  25591. res.InfRefmsgid = resFour10265.InfRefmsgid
  25592. res.Output = resFour10265.Output
  25593. res.ErrMsg = resFour10265.ErrMsg
  25594. res.Cainfo = resFour10265.Cainfo
  25595. res.WarnMsg = resFour10265.WarnMsg
  25596. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25597. res.Infcode = infocode
  25598. } else {
  25599. 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)
  25600. var dat map[string]interface{}
  25601. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25602. fmt.Println(dat)
  25603. } else {
  25604. fmt.Println(err)
  25605. }
  25606. saveLog(result, request_log, "2204", "上传费用明细")
  25607. userJSONBytes, _ := json.Marshal(dat)
  25608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25609. utils.ErrorLog("解析失败:%v", err)
  25610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25611. return
  25612. }
  25613. }
  25614. }
  25615. if res.Infcode == 0 {
  25616. order := &models.HisOrder{
  25617. UserOrgId: adminUser.CurrentOrgId,
  25618. HisPatientId: his.ID,
  25619. PatientId: his.PatientId,
  25620. SettleAccountsDate: recordDateTime,
  25621. MdtrtId: his.Number,
  25622. PsnNo: his.PsnNo,
  25623. MedType: strconv.FormatInt(reg_type, 10),
  25624. Ctime: time.Now().Unix(),
  25625. Mtime: time.Now().Unix(),
  25626. Status: 1,
  25627. Number: chrg_bchno,
  25628. Infcode: res.Infcode,
  25629. WarnMsg: res.WarnMsg,
  25630. Cainfo: res.Cainfo,
  25631. ErrMsg: res.ErrMsg,
  25632. RespondTime: res.RefmsgTime,
  25633. InfRefmsgid: res.InfRefmsgid,
  25634. OrderStatus: 1,
  25635. PayWay: pay_way,
  25636. PayWays: pay_ways,
  25637. OthDesc: oth_desc,
  25638. PayPrice: pay_price,
  25639. PayCardNo: pay_card_no,
  25640. DiscountPrice: discount_price,
  25641. PreferentialPrice: preferential_price,
  25642. RealityPrice: reality_price,
  25643. FoundPrice: found_price,
  25644. MedicalInsurancePrice: medical_insurance_price,
  25645. PrivatePrice: private_price,
  25646. IsMedicineInsurance: 1,
  25647. SettleType: settle_accounts_type,
  25648. SettleStartTime: start_time,
  25649. SettleEndTime: end_time,
  25650. Creator: roles.AdminUserId,
  25651. Modify: roles.AdminUserId,
  25652. FaPiaoNumber: fapiao_number,
  25653. FaPiaoCode: fapiao_code,
  25654. PType: 2,
  25655. Diagnosis: diagnosis_id,
  25656. CashPay: cash_pay,
  25657. WechatPay: wechat_pay,
  25658. AliPay: ali_pay,
  25659. JifenPay: jifen_pay,
  25660. BandCardPay: band_card_pay,
  25661. }
  25662. err = service.CreateOrder(order)
  25663. if err != nil {
  25664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25665. return
  25666. }
  25667. for _, item := range res.Output.Result {
  25668. temp := strings.Split(item.FeedetlSn, "-")
  25669. var advice_id int64 = 0
  25670. var project_id int64 = 0
  25671. var types int64 = 0
  25672. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25673. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25674. if temp[1] == "1" {
  25675. advice_id = id
  25676. project_id = 0
  25677. } else if temp[1] == "2" {
  25678. advice_id = 0
  25679. project_id = id
  25680. }
  25681. if item.MedChrgitmType == "9" {
  25682. item.MedChrgitmType = "09"
  25683. }
  25684. info := &models.HisOrderInfo{
  25685. OrderNumber: order.Number,
  25686. FeedetlSn: item.FeedetlSn,
  25687. UploadDate: time.Now().Unix(),
  25688. AdviceId: advice_id,
  25689. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25690. Cnt: item.Cnt,
  25691. Pric: float64(item.Pric),
  25692. PatientId: his.PatientId,
  25693. PricUplmtAmt: item.PricUplmtAmt,
  25694. SelfpayProp: item.SelfpayProp,
  25695. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25696. OverlmtAmt: item.OverlmtAmt,
  25697. PreselfpayAmt: item.PreselfpayAmt,
  25698. BasMednFlag: item.BasMednFlag,
  25699. MedChrgitmType: item.MedChrgitmType,
  25700. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25701. Status: 1,
  25702. Memo: item.Memo,
  25703. Mtime: time.Now().Unix(),
  25704. InscpScpAmt: item.InscpScpAmt,
  25705. DrtReimFlag: item.DrtReimFlag,
  25706. Ctime: time.Now().Unix(),
  25707. ListSpItemFlag: item.ListSpItemFlag,
  25708. ChldMedcFlag: item.ChldMedcFlag,
  25709. LmtUsedFlag: item.LmtUsedFlag,
  25710. ChrgitmLv: item.ChrgitmLv,
  25711. UserOrgId: adminUser.CurrentOrgId,
  25712. HisPatientId: his.ID,
  25713. OrderId: order.ID,
  25714. ProjectId: project_id,
  25715. Type: types,
  25716. }
  25717. service.CreateOrderInfo(info)
  25718. }
  25719. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25720. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25721. var total float64
  25722. for _, item := range prescriptions {
  25723. if item.Type == 1 { //药品
  25724. for _, subItem := range item.HisDoctorAdviceInfo {
  25725. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25726. total_one := price * subItem.PrescribingNumber
  25727. total = total + total_one
  25728. }
  25729. }
  25730. if item.Type == 2 { //项目
  25731. for _, subItem := range item.HisPrescriptionProject {
  25732. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25733. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25734. total_one := price * cnt
  25735. total = total + total_one
  25736. }
  25737. }
  25738. }
  25739. allTotal := fmt.Sprintf("%.2f", total)
  25740. //if adminUser.CurrentOrgId == 9919 {
  25741. //
  25742. // allTotal = fmt.Sprintf("%.2f", total)
  25743. //
  25744. //} else {
  25745. //
  25746. // allTotal = fmt.Sprintf("%.2f", total)
  25747. //
  25748. //}
  25749. if res.Infcode == 0 {
  25750. var rf []*ResultFive
  25751. json.Unmarshal([]byte(his.Iinfo), &rf)
  25752. chrg_bchno := chrg_bchno
  25753. cert_no := his.Certno
  25754. var insutypes []string
  25755. var insutype string
  25756. var is390 int = 0
  25757. var is310 int = 0
  25758. for _, item := range rf {
  25759. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25760. insutypes = append(insutypes, item.Insutype)
  25761. }
  25762. }
  25763. if len(insutypes) == 1 {
  25764. insutype = insutypes[0]
  25765. } else {
  25766. for _, i := range insutypes {
  25767. if i == "390" {
  25768. is390 = 1
  25769. }
  25770. if i == "310" {
  25771. is310 = 1
  25772. }
  25773. }
  25774. }
  25775. if is390 == 1 {
  25776. insutype = "390"
  25777. }
  25778. if is310 == 1 {
  25779. insutype = "310"
  25780. }
  25781. if len(insutypes) == 0 {
  25782. insutype = "310"
  25783. }
  25784. if len(insutypes) == 2 {
  25785. insutype = strconv.FormatInt(his.SocialType, 10)
  25786. }
  25787. insutype = strconv.FormatInt(his.SocialType, 10)
  25788. //insutype = "390"
  25789. if his.IdCardType == 1 {
  25790. // cert_no = his.MedicalInsuranceNumber
  25791. cert_no = his.Certno
  25792. } else {
  25793. cert_no = his.Certno
  25794. }
  25795. var res ResultSeven
  25796. var resSeven10265 ResultSeven10265
  25797. var gzresSeven10265Two GZResultSeven10265Two
  25798. var src_resquest string
  25799. var result2 string
  25800. if miConfig.MdtrtareaAdmvs == "421300" {
  25801. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25802. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25803. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25804. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25805. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25806. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25807. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25808. resp, requestErr := http.Get(api)
  25809. if requestErr != nil {
  25810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25811. return
  25812. }
  25813. body, ioErr := ioutil.ReadAll(resp.Body)
  25814. if ioErr != nil {
  25815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25817. return
  25818. }
  25819. var respJSON map[string]interface{}
  25820. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25823. return
  25824. }
  25825. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25826. result, _ := json.Marshal(respJSON)
  25827. if miConfig.Code == "H15049901371" {
  25828. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25829. utils.ErrorLog("解析失败:%v", err)
  25830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25831. return
  25832. }
  25833. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25834. res.Output = resSeven10265.Output
  25835. res.ErrMsg = resSeven10265.ErrMsg
  25836. res.Cainfo = resSeven10265.Cainfo
  25837. res.WarnMsg = resSeven10265.WarnMsg
  25838. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25839. res.Infcode = infocode
  25840. } else {
  25841. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25842. utils.ErrorLog("解析失败:%v", err)
  25843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25844. return
  25845. }
  25846. }
  25847. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25848. if reg_type == 11 && his.Insutype == "390" {
  25849. reg_type = 110104
  25850. }
  25851. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25852. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25853. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25854. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25855. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25856. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25857. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25858. resp, requestErr := http.Get(api)
  25859. if requestErr != nil {
  25860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25861. return
  25862. }
  25863. body, ioErr := ioutil.ReadAll(resp.Body)
  25864. if ioErr != nil {
  25865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25867. return
  25868. }
  25869. var respJSON map[string]interface{}
  25870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25873. return
  25874. }
  25875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25876. result, _ := json.Marshal(respJSON)
  25877. if miConfig.Code == "H15049901371" {
  25878. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25879. utils.ErrorLog("解析失败:%v", err)
  25880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25881. return
  25882. }
  25883. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25884. res.Output = resSeven10265.Output
  25885. res.ErrMsg = resSeven10265.ErrMsg
  25886. res.Cainfo = resSeven10265.Cainfo
  25887. res.WarnMsg = resSeven10265.WarnMsg
  25888. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25889. res.Infcode = infocode
  25890. } else {
  25891. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25892. utils.ErrorLog("解析失败:%v", err)
  25893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25894. return
  25895. }
  25896. }
  25897. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25898. if reg_type == 11 && his.Insutype == "390" {
  25899. reg_type = 110104
  25900. }
  25901. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25902. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25903. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25904. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25905. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25906. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25907. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25908. resp, requestErr := http.Get(api)
  25909. if requestErr != nil {
  25910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25911. return
  25912. }
  25913. body, ioErr := ioutil.ReadAll(resp.Body)
  25914. if ioErr != nil {
  25915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25917. return
  25918. }
  25919. var respJSON map[string]interface{}
  25920. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25923. return
  25924. }
  25925. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25926. result, _ := json.Marshal(respJSON)
  25927. if miConfig.Code == "H15049901371" {
  25928. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25929. utils.ErrorLog("解析失败:%v", err)
  25930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25931. return
  25932. }
  25933. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25934. res.Output = resSeven10265.Output
  25935. res.ErrMsg = resSeven10265.ErrMsg
  25936. res.Cainfo = resSeven10265.Cainfo
  25937. res.WarnMsg = resSeven10265.WarnMsg
  25938. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25939. res.Infcode = infocode
  25940. } else {
  25941. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25942. utils.ErrorLog("解析失败:%v", err)
  25943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25944. return
  25945. }
  25946. }
  25947. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25948. if reg_type == 11 && his.Insutype == "390" {
  25949. reg_type = 110104
  25950. }
  25951. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25952. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25953. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25954. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25955. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25956. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25957. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25958. resp, requestErr := http.Get(api)
  25959. if requestErr != nil {
  25960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25961. return
  25962. }
  25963. body, ioErr := ioutil.ReadAll(resp.Body)
  25964. if ioErr != nil {
  25965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25967. return
  25968. }
  25969. var respJSON map[string]interface{}
  25970. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25973. return
  25974. }
  25975. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25976. result, _ := json.Marshal(respJSON)
  25977. if miConfig.Code == "H15049901371" {
  25978. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25979. utils.ErrorLog("解析失败:%v", err)
  25980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25981. return
  25982. }
  25983. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25984. res.Output = resSeven10265.Output
  25985. res.ErrMsg = resSeven10265.ErrMsg
  25986. res.Cainfo = resSeven10265.Cainfo
  25987. res.WarnMsg = resSeven10265.WarnMsg
  25988. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25989. res.Infcode = infocode
  25990. } else {
  25991. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25992. utils.ErrorLog("解析失败:%v", err)
  25993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25994. return
  25995. }
  25996. }
  25997. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25998. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  25999. if result3101.Infcode == "0" {
  26000. if len(result3101.Output.Result) > 0 {
  26001. var errMsgs []string
  26002. for _, item := range result3101.Output.Result {
  26003. errMsgs = append(errMsgs, item.VolaCont)
  26004. }
  26005. c.ServeSuccessJSON(map[string]interface{}{
  26006. "failed_code": -10,
  26007. "msg": errMsgs,
  26008. })
  26009. return
  26010. } else {
  26011. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26012. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26013. bas := strings.Split(psn_info.CardInfo, "|")
  26014. if his.IdCardType == 1 {
  26015. cert_no = bas[2]
  26016. } else if his.IdCardType == 3 {
  26017. cert_no = his.Certno
  26018. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26019. } else if his.IdCardType == 4 {
  26020. cert_no = his.Certno
  26021. psn_info.VerifyNumber = psn_info.VerifyNumber
  26022. }
  26023. var api string
  26024. if miConfig.MdtrtareaAdmvs == "320921" {
  26025. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26026. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26027. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26028. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26029. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26030. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26031. "&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
  26032. } else {
  26033. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26034. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26035. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26036. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26037. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26038. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26039. "&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
  26040. }
  26041. resp, requestErr := http.Get(api)
  26042. if requestErr != nil {
  26043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26044. return
  26045. }
  26046. body, ioErr := ioutil.ReadAll(resp.Body)
  26047. if ioErr != nil {
  26048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26050. return
  26051. }
  26052. var respJSON map[string]interface{}
  26053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26056. return
  26057. }
  26058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26059. result, _ := json.Marshal(respJSON)
  26060. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26061. utils.ErrorLog("解析失败:%v", err)
  26062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26063. return
  26064. }
  26065. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26066. res.Output = resSeven10265.Output
  26067. res.ErrMsg = resSeven10265.ErrMsg
  26068. res.Cainfo = resSeven10265.Cainfo
  26069. res.WarnMsg = resSeven10265.WarnMsg
  26070. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26071. res.Infcode = infocode
  26072. }
  26073. }
  26074. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26075. psn_info, _ := service.GetPsnByPatientId(id)
  26076. var verify_number string
  26077. if psn_info.IdCardType == 4 {
  26078. verify_number = psn_info.VerifyNumber
  26079. } else if psn_info.IdCardType == 1 {
  26080. bas := strings.Split(psn_info.CardInfo, "|")
  26081. cardNumber := bas[2]
  26082. verify_number = cardNumber
  26083. } else {
  26084. psn_info.IdCardType = 2
  26085. verify_number = psn_info.Certno
  26086. }
  26087. var api string
  26088. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26089. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26090. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26091. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26092. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26093. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26094. "&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
  26095. resp, requestErr := http.Get(api)
  26096. if requestErr != nil {
  26097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26098. return
  26099. }
  26100. body, ioErr := ioutil.ReadAll(resp.Body)
  26101. if ioErr != nil {
  26102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26104. return
  26105. }
  26106. var respJSON map[string]interface{}
  26107. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26110. return
  26111. }
  26112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26113. result, _ := json.Marshal(respJSON)
  26114. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26115. utils.ErrorLog("解析失败:%v", err)
  26116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26117. return
  26118. }
  26119. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26120. res.Output = resSeven10265.Output
  26121. res.ErrMsg = resSeven10265.ErrMsg
  26122. res.Cainfo = resSeven10265.Cainfo
  26123. res.WarnMsg = resSeven10265.WarnMsg
  26124. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26125. res.Infcode = infocode
  26126. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26127. var cert_no string
  26128. if his.IdCardType == 4 {
  26129. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26130. cert_no = psn_info.VerifyNumber
  26131. 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)
  26132. } else if his.IdCardType == 1 {
  26133. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26134. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26135. 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)
  26136. }
  26137. //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)
  26138. var dat map[string]interface{}
  26139. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26140. fmt.Println(dat)
  26141. } else {
  26142. fmt.Println(err)
  26143. }
  26144. saveLog(result2, src_resquest, "2207", "结算")
  26145. userJSONBytes, _ := json.Marshal(dat)
  26146. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26147. utils.ErrorLog("解析失败:%v", err)
  26148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26149. return
  26150. }
  26151. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26152. res.Output = resSeven10265.Output
  26153. res.ErrMsg = resSeven10265.ErrMsg
  26154. res.Cainfo = resSeven10265.Cainfo
  26155. res.WarnMsg = resSeven10265.WarnMsg
  26156. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26157. res.Infcode = infocode
  26158. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26159. res2 := c.GetoleInfo()
  26160. if res2.Infcode == 0 {
  26161. var result string
  26162. var request_log string
  26163. var result_log string
  26164. if res2.Output.MdtrtCertType == "02" {
  26165. 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)
  26166. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26167. } else if res2.Output.MdtrtCertType == "01" {
  26168. 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)
  26169. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26170. } else {
  26171. 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)
  26172. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26173. }
  26174. var dat map[string]interface{}
  26175. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26176. fmt.Println(dat)
  26177. } else {
  26178. fmt.Println(err)
  26179. }
  26180. userJSONBytes, _ := json.Marshal(dat)
  26181. var res5 ResultTwo
  26182. //var resTwo10265 ResultTwo10265
  26183. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26184. utils.ErrorLog("解析失败:%v", err)
  26185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26186. return
  26187. }
  26188. if res5.Infcode == -1 {
  26189. c.ServeSuccessJSON(map[string]interface{}{
  26190. "failed_code": -10,
  26191. "msg": res5.ErrMsg,
  26192. })
  26193. return
  26194. }
  26195. var insutypes []string
  26196. var insutype string
  26197. var is390 int = 0
  26198. var is310 int = 0
  26199. for _, item := range res5.Output.Iinfo {
  26200. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26201. insutypes = append(insutypes, item.Insutype)
  26202. }
  26203. }
  26204. if len(insutypes) == 1 {
  26205. insutype = insutypes[0]
  26206. } else {
  26207. for _, i := range insutypes {
  26208. if i == "390" {
  26209. is390 = 1
  26210. }
  26211. if i == "310" {
  26212. is310 = 1
  26213. }
  26214. }
  26215. }
  26216. if is390 == 1 {
  26217. insutype = "390"
  26218. }
  26219. if is310 == 1 {
  26220. insutype = "310"
  26221. }
  26222. if len(insutypes) == 0 {
  26223. insutype = "310"
  26224. }
  26225. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26226. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26227. infoStr := string(Iinfos)
  26228. idetinfoStr := string(Idetinfos)
  26229. psn := &models.HisPsn{
  26230. PsnNo: res5.Output.Baseinfo.PsnNo,
  26231. PatientId: id,
  26232. Certno: res5.Output.Baseinfo.Certno,
  26233. Gend: res5.Output.Baseinfo.Gend,
  26234. Naty: res5.Output.Baseinfo.Naty,
  26235. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26236. PsnName: res5.Output.Baseinfo.PsnName,
  26237. Idetinfo: idetinfoStr,
  26238. Insuinfo: infoStr,
  26239. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26241. VerifyNumber: res2.Output.EcToken,
  26242. }
  26243. if res2.Output.MdtrtCertType == "01" {
  26244. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26245. psn.VerifyNumber = res2.Output.EcToken
  26246. } else if res2.Output.MdtrtCertType == "02" {
  26247. psn.VerifyNumber = res2.Output.CardNo
  26248. } else {
  26249. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26250. }
  26251. service.CreateHisPsn(psn)
  26252. if res2.Output.MdtrtCertType == "01" {
  26253. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26254. token := res2.Output.EcToken
  26255. 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)
  26256. } else if res2.Output.MdtrtCertType == "02" {
  26257. 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)
  26258. } else {
  26259. 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)
  26260. }
  26261. var dat2 map[string]interface{}
  26262. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26263. fmt.Println(dat2)
  26264. } else {
  26265. fmt.Println(err)
  26266. }
  26267. userJSONBytes3, _ := json.Marshal(dat2)
  26268. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26269. utils.ErrorLog("解析失败:%v", err)
  26270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26271. return
  26272. }
  26273. saveLog(result2, src_resquest, "2207", "结算")
  26274. } else {
  26275. c.ServeSuccessJSON(map[string]interface{}{
  26276. "failed_code": -10,
  26277. "msg": res2.ErrMsg,
  26278. })
  26279. return
  26280. }
  26281. } else {
  26282. if miConfig.Code == "H15049901371" {
  26283. //赤峰地区国家医保医疗类别
  26284. //职工透析:医疗类别选特殊情况门诊990502
  26285. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26286. var med_type string
  26287. if his.Insutype == "390" {
  26288. if reg_type == 14 {
  26289. med_type = "9933"
  26290. } else if reg_type == 11 {
  26291. med_type = "11"
  26292. }
  26293. } else if his.Insutype == "310" {
  26294. if reg_type == 14 {
  26295. med_type = "990502"
  26296. } else if reg_type == 11 {
  26297. med_type = "11"
  26298. }
  26299. }
  26300. 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)
  26301. } else {
  26302. if his.IdCardType == 4 {
  26303. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26304. var token string
  26305. token = psn_info.VerifyNumber
  26306. 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)
  26307. } else {
  26308. if his.IdCardType == 1 {
  26309. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26310. bas := strings.Split(psn_info.CardInfo, "|")
  26311. basNumber := bas[2]
  26312. cert_no = basNumber
  26313. }
  26314. 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)
  26315. }
  26316. }
  26317. //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)
  26318. var dat map[string]interface{}
  26319. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26320. fmt.Println(dat)
  26321. } else {
  26322. fmt.Println(err)
  26323. }
  26324. saveLog(result2, src_resquest, "2207", "结算")
  26325. userJSONBytes, _ := json.Marshal(dat)
  26326. if miConfig.Code == "H15049901371" {
  26327. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26328. utils.ErrorLog("解析失败:%v", err)
  26329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26330. return
  26331. }
  26332. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26333. res.Output = resSeven10265.Output
  26334. res.ErrMsg = resSeven10265.ErrMsg
  26335. res.Cainfo = resSeven10265.Cainfo
  26336. res.WarnMsg = resSeven10265.WarnMsg
  26337. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26338. res.Infcode = infocode
  26339. } else {
  26340. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26341. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26342. utils.ErrorLog("解析失败:%v", err)
  26343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26344. return
  26345. }
  26346. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26347. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26348. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26349. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26350. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26351. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26352. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26353. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26354. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26355. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26356. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26357. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26358. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26359. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26360. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26361. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26362. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26363. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26364. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26365. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26366. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26367. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26368. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26369. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26370. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26371. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26372. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26373. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26374. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26375. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26376. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26377. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26378. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26379. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26380. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26381. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26382. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26383. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26384. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26385. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26386. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26387. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26388. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26389. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26390. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26391. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26392. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26393. res.Cainfo = gzresSeven10265Two.Cainfo
  26394. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26395. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26396. //res.Infcode = infocode
  26397. } else {
  26398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26399. utils.ErrorLog("解析失败:%v", err)
  26400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26401. return
  26402. }
  26403. }
  26404. }
  26405. }
  26406. if res.Infcode == -1 {
  26407. errlog := &models.HisOrderError{
  26408. UserOrgId: adminUser.CurrentOrgId,
  26409. Ctime: time.Now().Unix(),
  26410. Mtime: time.Now().Unix(),
  26411. Number: chrg_bchno,
  26412. ErrMsg: res.ErrMsg,
  26413. Status: 1,
  26414. PatientId: id,
  26415. RecordTime: recordDateTime,
  26416. Stage: 6,
  26417. }
  26418. service.CreateErrMsgLog(errlog)
  26419. c.ServeSuccessJSON(map[string]interface{}{
  26420. "failed_code": -10,
  26421. "msg": res.ErrMsg,
  26422. })
  26423. return
  26424. } else {
  26425. sickConfig, _ := service.FindSickById(his.SickType)
  26426. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26427. order.OrderStatus = 2
  26428. order.Status = 1
  26429. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26430. order.SetlId = res.Output.Setlinfo.SetlID
  26431. order.PsnNo = res.Output.Setlinfo.PsnNo
  26432. order.PsnName = res.Output.Setlinfo.PsnName
  26433. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26434. order.Certno = res.Output.Setlinfo.Certno
  26435. order.Gend = res.Output.Setlinfo.Gend
  26436. order.Naty = res.Output.Setlinfo.Naty
  26437. order.Age = res.Output.Setlinfo.Age
  26438. order.Insutype = res.Output.Setlinfo.Insutype
  26439. order.PsnType = res.Output.Setlinfo.PsnType
  26440. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26441. order.SetlTime = res.Output.Setlinfo.SetlTime
  26442. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26443. if res.Output.Setlinfo.MedType == "140101" {
  26444. order.MedType = "14"
  26445. } else {
  26446. if res.Output.Setlinfo.MedType == "110104" {
  26447. order.MedType = "11"
  26448. } else {
  26449. order.MedType = res.Output.Setlinfo.MedType
  26450. }
  26451. }
  26452. if reg_type == 1112 {
  26453. order.MedType = "1112"
  26454. }
  26455. if reg_type == 1111 {
  26456. order.MedType = "1111"
  26457. }
  26458. order.ClrType = res.Output.Setlinfo.ClrType
  26459. if adminUser.CurrentOrgId == 10480 {
  26460. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26461. order.ClrType = "11"
  26462. } else {
  26463. order.ClrType = "9903"
  26464. }
  26465. }
  26466. if adminUser.CurrentOrgId == 10721 {
  26467. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26468. order.ClrType = "11"
  26469. } else {
  26470. order.ClrType = "9903"
  26471. }
  26472. }
  26473. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26474. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26475. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26476. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26477. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26478. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26479. order.HifpPay = res.Output.Setlinfo.HifpPay
  26480. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26481. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26482. order.HifesPay = res.Output.Setlinfo.HifesPay
  26483. order.HifobPay = res.Output.Setlinfo.HifobPay
  26484. order.MafPay = res.Output.Setlinfo.MafPay
  26485. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26486. order.OthPay = res.Output.Setlinfo.OthPay
  26487. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26488. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26489. order.AcctPay = res.Output.Setlinfo.AcctPay
  26490. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26491. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26492. order.Balc = res.Output.Setlinfo.Balc
  26493. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26494. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26495. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26496. //order.ClrType = res.Output.Setlinfo.ClrType
  26497. order.ClrWay = res.Output.Setlinfo.ClrWay
  26498. order.Creator = order.Creator
  26499. order.Modify = roles.AdminUserId
  26500. order.RequestLog = src_resquest
  26501. order.FaPiaoNumber = fapiao_number
  26502. order.FaPiaoCode = fapiao_code
  26503. order.SickName = sickConfig.ClassName
  26504. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26505. //detailStr := string(setlDetail)
  26506. //order.SetlDetail = detailStr
  26507. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26508. err = service.UpDateOrder(order)
  26509. if err == nil {
  26510. //判断是否使用了押金
  26511. if dec_way == "true" {
  26512. tmpstring := strconv.FormatInt(order.ID, 10)
  26513. order.Decimal = decimal
  26514. service.UpDateOrder(order)
  26515. //扣押金
  26516. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26517. if errmsg != nil {
  26518. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26519. return
  26520. }
  26521. }
  26522. c.ServeSuccessJSON(map[string]interface{}{
  26523. "msg": "结算成功",
  26524. })
  26525. } else {
  26526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26527. return
  26528. }
  26529. }
  26530. } else {
  26531. adminUser := c.GetAdminUserInfo()
  26532. errlog := &models.HisOrderError{
  26533. UserOrgId: adminUser.CurrentOrgId,
  26534. Ctime: time.Now().Unix(),
  26535. Mtime: time.Now().Unix(),
  26536. ErrMsg: res.ErrMsg,
  26537. Status: 1,
  26538. PatientId: id,
  26539. RecordTime: recordDateTime,
  26540. Stage: 4,
  26541. }
  26542. service.CreateErrMsgLog(errlog)
  26543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26544. return
  26545. }
  26546. } else {
  26547. adminUser := c.GetAdminUserInfo()
  26548. errlog := &models.HisOrderError{
  26549. UserOrgId: adminUser.CurrentOrgId,
  26550. Ctime: time.Now().Unix(),
  26551. Mtime: time.Now().Unix(),
  26552. ErrMsg: res.ErrMsg,
  26553. Status: 1,
  26554. PatientId: id,
  26555. RecordTime: recordDateTime,
  26556. Stage: 4,
  26557. }
  26558. service.CreateErrMsgLog(errlog)
  26559. c.ServeSuccessJSON(map[string]interface{}{
  26560. "failed_code": -10,
  26561. "msg": res.ErrMsg,
  26562. })
  26563. return
  26564. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26565. //return
  26566. }
  26567. }
  26568. }
  26569. } else if tempOrder.ID > 0 {
  26570. if tempOrder.IsPre == 1 {
  26571. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26572. var rf []*ResultFive
  26573. json.Unmarshal([]byte(his.Iinfo), &rf)
  26574. chrg_bchno := tempOrder.Number
  26575. cert_no := his.Certno
  26576. var insutypes []string
  26577. var insutype string
  26578. var is390 int = 0
  26579. var is310 int = 0
  26580. for _, item := range rf {
  26581. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26582. insutypes = append(insutypes, item.Insutype)
  26583. }
  26584. }
  26585. if len(insutypes) == 1 {
  26586. insutype = insutypes[0]
  26587. } else {
  26588. for _, i := range insutypes {
  26589. if i == "390" {
  26590. is390 = 1
  26591. }
  26592. if i == "310" {
  26593. is310 = 1
  26594. }
  26595. }
  26596. }
  26597. if is390 == 1 {
  26598. insutype = "390"
  26599. }
  26600. if is310 == 1 {
  26601. insutype = "310"
  26602. }
  26603. if len(insutypes) == 0 {
  26604. insutype = "310"
  26605. }
  26606. if len(insutypes) == 2 {
  26607. insutype = strconv.FormatInt(his.SocialType, 10)
  26608. }
  26609. //insutype = "390"
  26610. if his.IdCardType == 1 {
  26611. // cert_no = his.MedicalInsuranceNumber
  26612. cert_no = his.Certno
  26613. } else {
  26614. cert_no = his.Certno
  26615. }
  26616. var res ResultSeven
  26617. var ahres ResultSevenAH
  26618. var resSeven10265 ResultSeven10265
  26619. var gzresSeven10265Two GZResultSeven10265Two
  26620. var src_resquest string
  26621. var result2 string
  26622. if miConfig.MdtrtareaAdmvs == "450721" {
  26623. res2 := c.GetoleInfo()
  26624. if res2.Infcode == 0 {
  26625. var result string
  26626. var request_log string
  26627. var result_log string
  26628. if res2.Output.MdtrtCertType == "02" {
  26629. 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)
  26630. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26631. } else if res2.Output.MdtrtCertType == "01" {
  26632. 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)
  26633. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26634. } else {
  26635. 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)
  26636. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26637. }
  26638. var dat map[string]interface{}
  26639. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26640. fmt.Println(dat)
  26641. } else {
  26642. fmt.Println(err)
  26643. }
  26644. userJSONBytes, _ := json.Marshal(dat)
  26645. var res5 ResultTwo
  26646. //var resTwo10265 ResultTwo10265
  26647. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26648. utils.ErrorLog("解析失败:%v", err)
  26649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26650. return
  26651. }
  26652. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26653. if res5.Infcode == -1 {
  26654. c.ServeSuccessJSON(map[string]interface{}{
  26655. "failed_code": -10,
  26656. "msg": res5.ErrMsg,
  26657. })
  26658. return
  26659. }
  26660. var insutypes []string
  26661. var insutype string
  26662. var is390 int = 0
  26663. var is310 int = 0
  26664. for _, item := range res5.Output.Iinfo {
  26665. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26666. insutypes = append(insutypes, item.Insutype)
  26667. }
  26668. }
  26669. if len(insutypes) == 1 {
  26670. insutype = insutypes[0]
  26671. } else {
  26672. for _, i := range insutypes {
  26673. if i == "390" {
  26674. is390 = 1
  26675. }
  26676. if i == "310" {
  26677. is310 = 1
  26678. }
  26679. }
  26680. }
  26681. if is390 == 1 {
  26682. insutype = "390"
  26683. }
  26684. if is310 == 1 {
  26685. insutype = "310"
  26686. }
  26687. if len(insutypes) == 0 {
  26688. insutype = "310"
  26689. }
  26690. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26691. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26692. infoStr := string(Iinfos)
  26693. idetinfoStr := string(Idetinfos)
  26694. psn := &models.HisPsn{
  26695. PsnNo: res5.Output.Baseinfo.PsnNo,
  26696. PatientId: id,
  26697. Certno: res5.Output.Baseinfo.Certno,
  26698. Gend: res5.Output.Baseinfo.Gend,
  26699. Naty: res5.Output.Baseinfo.Naty,
  26700. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26701. PsnName: res5.Output.Baseinfo.PsnName,
  26702. Idetinfo: idetinfoStr,
  26703. Insuinfo: infoStr,
  26704. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26705. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26706. VerifyNumber: res2.Output.EcToken,
  26707. }
  26708. service.CreateHisPsn(psn)
  26709. if res2.Output.MdtrtCertType == "01" {
  26710. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26711. token := res2.Output.EcToken
  26712. 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)
  26713. } else if res2.Output.MdtrtCertType == "02" {
  26714. 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)
  26715. } else {
  26716. 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)
  26717. }
  26718. var dat2 map[string]interface{}
  26719. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26720. fmt.Println(dat2)
  26721. } else {
  26722. fmt.Println(err)
  26723. }
  26724. userJSONBytes3, _ := json.Marshal(dat2)
  26725. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26726. utils.ErrorLog("解析失败:%v", err)
  26727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26728. return
  26729. }
  26730. saveLog(result2, src_resquest, "2207", "结算")
  26731. } else {
  26732. c.ServeSuccessJSON(map[string]interface{}{
  26733. "failed_code": -10,
  26734. "msg": res2.ErrMsg,
  26735. })
  26736. return
  26737. }
  26738. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26739. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26740. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26741. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26742. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26743. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26744. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26745. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26746. resp, requestErr := http.Get(api)
  26747. if requestErr != nil {
  26748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26749. return
  26750. }
  26751. body, ioErr := ioutil.ReadAll(resp.Body)
  26752. if ioErr != nil {
  26753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26755. return
  26756. }
  26757. var respJSON map[string]interface{}
  26758. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26761. return
  26762. }
  26763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26764. result, _ := json.Marshal(respJSON)
  26765. fmt.Println("log")
  26766. fmt.Println(string(result))
  26767. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26768. utils.ErrorLog("解析失败:%v", err)
  26769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26770. return
  26771. }
  26772. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26773. if reg_type == 11 && his.Insutype == "390" {
  26774. reg_type = 110104
  26775. }
  26776. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26777. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26778. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26779. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26780. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26781. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26782. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26783. resp, requestErr := http.Get(api)
  26784. if requestErr != nil {
  26785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26786. return
  26787. }
  26788. body, ioErr := ioutil.ReadAll(resp.Body)
  26789. if ioErr != nil {
  26790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26792. return
  26793. }
  26794. var respJSON map[string]interface{}
  26795. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26798. return
  26799. }
  26800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26801. result, _ := json.Marshal(respJSON)
  26802. fmt.Println("log")
  26803. fmt.Println(string(result))
  26804. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26805. utils.ErrorLog("解析失败:%v", err)
  26806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26807. return
  26808. }
  26809. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26810. if reg_type == 11 && his.Insutype == "390" {
  26811. reg_type = 110104
  26812. }
  26813. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26814. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26815. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26816. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26817. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26818. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26819. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26820. resp, requestErr := http.Get(api)
  26821. if requestErr != nil {
  26822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26823. return
  26824. }
  26825. body, ioErr := ioutil.ReadAll(resp.Body)
  26826. if ioErr != nil {
  26827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26829. return
  26830. }
  26831. var respJSON map[string]interface{}
  26832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26835. return
  26836. }
  26837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26838. result, _ := json.Marshal(respJSON)
  26839. fmt.Println("log")
  26840. fmt.Println(string(result))
  26841. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26842. utils.ErrorLog("解析失败:%v", err)
  26843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26844. return
  26845. }
  26846. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26847. if reg_type == 11 && his.Insutype == "390" {
  26848. reg_type = 110104
  26849. }
  26850. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26851. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26852. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26853. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26854. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26855. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26856. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26857. resp, requestErr := http.Get(api)
  26858. if requestErr != nil {
  26859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26860. return
  26861. }
  26862. body, ioErr := ioutil.ReadAll(resp.Body)
  26863. if ioErr != nil {
  26864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26866. return
  26867. }
  26868. var respJSON map[string]interface{}
  26869. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26872. return
  26873. }
  26874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26875. result, _ := json.Marshal(respJSON)
  26876. fmt.Println("log")
  26877. fmt.Println(string(result))
  26878. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26879. utils.ErrorLog("解析失败:%v", err)
  26880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26881. return
  26882. }
  26883. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26884. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  26885. if result3101.Infcode == "0" {
  26886. if len(result3101.Output.Result) > 0 {
  26887. var errMsgs []string
  26888. for _, item := range result3101.Output.Result {
  26889. errMsgs = append(errMsgs, item.VolaCont)
  26890. }
  26891. c.ServeSuccessJSON(map[string]interface{}{
  26892. "failed_code": -10,
  26893. "msg": errMsgs,
  26894. })
  26895. return
  26896. } else {
  26897. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26898. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26899. bas := strings.Split(psn_info.CardInfo, "|")
  26900. if his.IdCardType == 1 {
  26901. cert_no = bas[2]
  26902. } else if his.IdCardType == 3 {
  26903. cert_no = his.Certno
  26904. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26905. } else if his.IdCardType == 4 {
  26906. cert_no = his.Certno
  26907. psn_info.VerifyNumber = psn_info.VerifyNumber
  26908. }
  26909. //江苏地区国家医保医疗类别
  26910. //职工透析:医疗类别选特殊情况门诊9933
  26911. //居民血透门慢: 医疗类别选门诊慢病1402
  26912. //var med_type string
  26913. //if his.Insutype == "310" {
  26914. // if reg_type == 14 {
  26915. // med_type = "9933"
  26916. // } else if reg_type == 11 {
  26917. // med_type = "11"
  26918. //
  26919. // }
  26920. //} else if his.Insutype == "390" {
  26921. // if reg_type == 14 {
  26922. // med_type = "1402"
  26923. // } else if reg_type == 11 {
  26924. // med_type = "11"
  26925. // }
  26926. //}
  26927. var api string
  26928. if miConfig.MdtrtareaAdmvs == "320921" {
  26929. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26930. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26931. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26932. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26933. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26934. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26935. "&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
  26936. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26937. } else {
  26938. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26939. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26940. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26941. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26942. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26943. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26944. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26945. "&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
  26946. }
  26947. resp, requestErr := http.Get(api)
  26948. if requestErr != nil {
  26949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26950. return
  26951. }
  26952. body, ioErr := ioutil.ReadAll(resp.Body)
  26953. if ioErr != nil {
  26954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26956. return
  26957. }
  26958. var respJSON map[string]interface{}
  26959. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26962. return
  26963. }
  26964. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26965. result, _ := json.Marshal(respJSON)
  26966. fmt.Println("log")
  26967. fmt.Println(string(result))
  26968. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26969. utils.ErrorLog("解析失败:%v", err)
  26970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26971. return
  26972. }
  26973. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26974. res.Output = resSeven10265.Output
  26975. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26976. res.ErrMsg = resSeven10265.ErrMsg
  26977. res.Cainfo = resSeven10265.Cainfo
  26978. res.WarnMsg = resSeven10265.WarnMsg
  26979. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26980. res.Infcode = infocode
  26981. }
  26982. }
  26983. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26984. psn_info, _ := service.GetPsnByPatientId(id)
  26985. var verify_number string
  26986. if psn_info.IdCardType == 4 {
  26987. verify_number = psn_info.VerifyNumber
  26988. } else if psn_info.IdCardType == 1 {
  26989. bas := strings.Split(psn_info.CardInfo, "|")
  26990. cardNumber := bas[2]
  26991. verify_number = cardNumber
  26992. } else {
  26993. verify_number = psn_info.Certno
  26994. psn_info.IdCardType = 2
  26995. }
  26996. var api string
  26997. new_chrg_bchno := chrg_bchno
  26998. if adminUser.CurrentOrgId == 10265 {
  26999. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27000. new_chrg_bchno = "0000"
  27001. }
  27002. }
  27003. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27004. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27005. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27006. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27007. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27008. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27009. "&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
  27010. resp, requestErr := http.Get(api)
  27011. if requestErr != nil {
  27012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27013. return
  27014. }
  27015. body, ioErr := ioutil.ReadAll(resp.Body)
  27016. if ioErr != nil {
  27017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27019. return
  27020. }
  27021. var respJSON map[string]interface{}
  27022. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27025. return
  27026. }
  27027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27028. result, _ := json.Marshal(respJSON)
  27029. fmt.Println("log")
  27030. fmt.Println(string(result))
  27031. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27032. utils.ErrorLog("解析失败:%v", err)
  27033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27034. return
  27035. }
  27036. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27037. res.Output = resSeven10265.Output
  27038. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27039. res.ErrMsg = resSeven10265.ErrMsg
  27040. res.Cainfo = resSeven10265.Cainfo
  27041. res.WarnMsg = resSeven10265.WarnMsg
  27042. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27043. res.Infcode = infocode
  27044. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27045. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27046. var cert_no string
  27047. if his.IdCardType == 1 {
  27048. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27049. } else {
  27050. cert_no = psn_info.VerifyNumber
  27051. }
  27052. 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)
  27053. var dat map[string]interface{}
  27054. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27055. fmt.Println(dat)
  27056. } else {
  27057. fmt.Println(err)
  27058. }
  27059. saveLog(result2, src_resquest, "2207", "结算")
  27060. userJSONBytes, _ := json.Marshal(dat)
  27061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27062. utils.ErrorLog("解析失败:%v", err)
  27063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27064. return
  27065. }
  27066. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27067. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27068. var cert_no string
  27069. var card_sn string
  27070. if his.IdCardType == 1 {
  27071. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27072. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27073. bas := strings.Split(psn_info.CardInfo, "|")
  27074. card_sn = bas[3]
  27075. } else if his.IdCardType == 2 {
  27076. cert_no = his.IdCardNo
  27077. } else {
  27078. cert_no = psn_info.VerifyNumber
  27079. }
  27080. var rf []*ResultFive
  27081. json.Unmarshal([]byte(his.Iinfo), &rf)
  27082. var psn_type string
  27083. for _, item := range rf {
  27084. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27085. psn_type = item.PsnType
  27086. }
  27087. }
  27088. 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)
  27089. var dat map[string]interface{}
  27090. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27091. fmt.Println(dat)
  27092. } else {
  27093. fmt.Println(err)
  27094. }
  27095. saveLog(result2, src_resquest, "2207", "结算")
  27096. userJSONBytes, _ := json.Marshal(dat)
  27097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27098. utils.ErrorLog("解析失败:%v", err)
  27099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27100. return
  27101. }
  27102. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27103. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27104. var cert_no string
  27105. var card_sn string
  27106. if his.IdCardType == 1 {
  27107. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27108. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27109. //bas := strings.Split(psn_info.CardInfo, "|")
  27110. card_sn = ""
  27111. } else if his.IdCardType == 2 {
  27112. cert_no = his.IdCardNo
  27113. } else {
  27114. cert_no = psn_info.VerifyNumber
  27115. }
  27116. var rf []*ResultFive
  27117. json.Unmarshal([]byte(his.Iinfo), &rf)
  27118. var psn_type string
  27119. for _, item := range rf {
  27120. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27121. psn_type = item.PsnType
  27122. }
  27123. }
  27124. 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)
  27125. var dat map[string]interface{}
  27126. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27127. fmt.Println(dat)
  27128. } else {
  27129. fmt.Println(err)
  27130. }
  27131. saveLog(result2, src_resquest, "2207", "结算")
  27132. userJSONBytes, _ := json.Marshal(dat)
  27133. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27134. utils.ErrorLog("解析失败:%v", err)
  27135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27136. return
  27137. }
  27138. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27139. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27140. if his.IdCardType == 1 {
  27141. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27142. bas := strings.Split(psn_info.CardInfo, "|")
  27143. cert_no = bas[2]
  27144. } else if his.IdCardType == 3 {
  27145. cert_no = his.Certno
  27146. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27147. } else if his.IdCardType == 4 {
  27148. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27149. cert_no = psn_info.VerifyNumber
  27150. psn_info.VerifyNumber = psn_info.VerifyNumber
  27151. } else {
  27152. cert_no = his.Certno
  27153. psn_info.VerifyNumber = his.Certno
  27154. }
  27155. var api string
  27156. var med_type string
  27157. if his.Insutype == "390" {
  27158. if reg_type == 992102 {
  27159. med_type = "992102"
  27160. }
  27161. if reg_type == 140104 {
  27162. med_type = "140104"
  27163. }
  27164. if reg_type == 140201 {
  27165. med_type = "140201"
  27166. }
  27167. if reg_type == 14 {
  27168. med_type = "14"
  27169. }
  27170. } else if his.Insutype == "310" {
  27171. if reg_type == 992102 {
  27172. med_type = "992102"
  27173. }
  27174. if reg_type == 140104 {
  27175. med_type = "140104"
  27176. }
  27177. if reg_type == 140201 {
  27178. med_type = "140201"
  27179. }
  27180. if reg_type == 14 {
  27181. med_type = "14"
  27182. }
  27183. }
  27184. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27185. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27186. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27187. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27188. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27189. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27190. "&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
  27191. resp, requestErr := http.Get(api)
  27192. if requestErr != nil {
  27193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27194. return
  27195. }
  27196. body, ioErr := ioutil.ReadAll(resp.Body)
  27197. if ioErr != nil {
  27198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27200. return
  27201. }
  27202. var respJSON map[string]interface{}
  27203. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27206. return
  27207. }
  27208. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27209. if status == "0" {
  27210. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27211. c.ServeSuccessJSON(map[string]interface{}{
  27212. "failed_code": -10,
  27213. "msg": err_msg,
  27214. })
  27215. return
  27216. }
  27217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27218. result, _ := json.Marshal(respJSON)
  27219. fmt.Println("log")
  27220. fmt.Println(string(result))
  27221. if err := json.Unmarshal(result, &ahres); err != nil {
  27222. utils.ErrorLog("解析失败:%v", err)
  27223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27224. return
  27225. }
  27226. res.InfRefmsgid = ahres.InfRefmsgid
  27227. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27228. // 创建对应的Time类型
  27229. t := time.UnixMilli(timestamp)
  27230. // 格式化成指定的日期字符串
  27231. str := t.Format("2006-01-02 15:04:05")
  27232. res.Output.Setlinfo.SetlTime = str
  27233. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27234. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27235. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27236. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27237. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27238. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27239. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27240. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27241. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27242. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27243. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27244. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27245. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27246. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27247. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27248. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27249. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27250. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27251. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27252. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27253. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27254. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27255. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27256. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27257. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27258. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27259. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27260. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27261. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27262. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27263. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27264. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27265. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27266. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27267. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27268. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27269. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27270. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27271. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27272. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27273. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27274. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27275. res.Output.Setldetail = ahres.Output.Setldetail
  27276. res.ErrMsg = ahres.ErrMsg
  27277. res.Cainfo = ahres.Cainfo
  27278. res.WarnMsg = ahres.WarnMsg
  27279. res.Infcode = ahres.Infcode
  27280. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27281. res.Output.Setlinfo.ClrType = "11"
  27282. } else {
  27283. res.Output.Setlinfo.ClrType = "9903"
  27284. }
  27285. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27286. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27287. if his.IdCardType == 1 {
  27288. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27289. bas := strings.Split(psn_info.CardInfo, "|")
  27290. cert_no = bas[2]
  27291. } else if his.IdCardType == 3 {
  27292. cert_no = his.Certno
  27293. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27294. } else if his.IdCardType == 4 {
  27295. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27296. cert_no = his.Certno
  27297. psn_info.VerifyNumber = psn_info.VerifyNumber
  27298. } else {
  27299. cert_no = his.Certno
  27300. psn_info.VerifyNumber = his.Certno
  27301. }
  27302. var api string
  27303. var med_type string
  27304. if his.Insutype == "390" {
  27305. if reg_type == 992102 {
  27306. med_type = "992102"
  27307. }
  27308. if reg_type == 140104 {
  27309. med_type = "140104"
  27310. }
  27311. if reg_type == 14 {
  27312. med_type = "14"
  27313. }
  27314. if reg_type == 140201 {
  27315. med_type = "140201"
  27316. }
  27317. } else if his.Insutype == "310" {
  27318. if reg_type == 992102 {
  27319. med_type = "992102"
  27320. }
  27321. if reg_type == 14 {
  27322. med_type = "14"
  27323. }
  27324. if reg_type == 140104 {
  27325. med_type = "140104"
  27326. }
  27327. if reg_type == 140201 {
  27328. med_type = "140201"
  27329. }
  27330. }
  27331. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27332. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27333. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27334. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27335. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27336. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27337. "&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
  27338. resp, requestErr := http.Get(api)
  27339. if requestErr != nil {
  27340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27341. return
  27342. }
  27343. body, ioErr := ioutil.ReadAll(resp.Body)
  27344. if ioErr != nil {
  27345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27347. return
  27348. }
  27349. var respJSON map[string]interface{}
  27350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27353. return
  27354. }
  27355. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27356. if status == "0" {
  27357. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27358. c.ServeSuccessJSON(map[string]interface{}{
  27359. "failed_code": -10,
  27360. "msg": err_msg,
  27361. })
  27362. return
  27363. }
  27364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27365. result, _ := json.Marshal(respJSON)
  27366. fmt.Println("log")
  27367. fmt.Println(string(result))
  27368. if err := json.Unmarshal(result, &ahres); err != nil {
  27369. utils.ErrorLog("解析失败:%v", err)
  27370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27371. return
  27372. }
  27373. res.InfRefmsgid = ahres.InfRefmsgid
  27374. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27375. // 创建对应的Time类型
  27376. t := time.UnixMilli(timestamp)
  27377. // 格式化成指定的日期字符串
  27378. str := t.Format("2006-01-02 15:04:05")
  27379. res.Output.Setlinfo.SetlTime = str
  27380. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27381. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27382. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27383. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27384. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27385. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27386. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27387. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27388. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27389. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27390. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27391. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27392. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27393. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27394. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27395. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27396. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27397. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27398. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27399. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27400. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27401. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27402. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27403. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27404. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27405. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27406. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27407. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27408. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27409. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27410. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27411. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27412. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27413. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27414. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27415. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27416. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27417. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27418. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27419. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27420. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27421. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27422. res.Output.Setldetail = ahres.Output.Setldetail
  27423. res.ErrMsg = ahres.ErrMsg
  27424. res.Cainfo = ahres.Cainfo
  27425. res.WarnMsg = ahres.WarnMsg
  27426. res.Infcode = ahres.Infcode
  27427. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27428. res.Output.Setlinfo.ClrType = "11"
  27429. } else {
  27430. res.Output.Setlinfo.ClrType = "9903"
  27431. }
  27432. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27433. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27434. var cert_no string
  27435. if his.IdCardType == 1 {
  27436. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27437. } else if his.IdCardType == 2 {
  27438. cert_no = his.IdCardNo
  27439. } else {
  27440. cert_no = psn_info.VerifyNumber
  27441. }
  27442. 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, "")
  27443. var dat map[string]interface{}
  27444. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27445. fmt.Println(dat)
  27446. } else {
  27447. fmt.Println(err)
  27448. }
  27449. saveLog(result2, src_resquest, "2207", "结算")
  27450. userJSONBytes, _ := json.Marshal(dat)
  27451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27452. utils.ErrorLog("解析失败:%v", err)
  27453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27454. return
  27455. }
  27456. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27457. psn_info, _ := service.GetPsnByPatientId(id)
  27458. var verify_number string
  27459. if psn_info.IdCardType == 4 {
  27460. verify_number = psn_info.VerifyNumber
  27461. } else if psn_info.IdCardType == 1 {
  27462. bas := strings.Split(psn_info.CardInfo, "|")
  27463. cardNumber := bas[2]
  27464. verify_number = cardNumber
  27465. } else {
  27466. verify_number = psn_info.Certno
  27467. psn_info.IdCardType = 2
  27468. }
  27469. var api string
  27470. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27471. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27472. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27473. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27474. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27475. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27476. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27477. resp, requestErr := http.Get(api)
  27478. if requestErr != nil {
  27479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27480. return
  27481. }
  27482. body, ioErr := ioutil.ReadAll(resp.Body)
  27483. if ioErr != nil {
  27484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27486. return
  27487. }
  27488. var respJSON map[string]interface{}
  27489. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27492. return
  27493. }
  27494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27495. result, _ := json.Marshal(respJSON)
  27496. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27497. utils.ErrorLog("解析失败:%v", err)
  27498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27499. return
  27500. }
  27501. } else {
  27502. var src_resquest string
  27503. if miConfig.Code == "H15049901371" {
  27504. //赤峰地区国家医保医疗类别
  27505. //职工透析:医疗类别选特殊情况门诊990502
  27506. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27507. var med_type string
  27508. if his.Insutype == "390" {
  27509. if reg_type == 14 {
  27510. med_type = "9933"
  27511. } else if reg_type == 11 {
  27512. med_type = "11"
  27513. }
  27514. } else if his.Insutype == "310" {
  27515. if reg_type == 14 {
  27516. med_type = "990502"
  27517. } else if reg_type == 11 {
  27518. med_type = "11"
  27519. }
  27520. }
  27521. 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)
  27522. } else {
  27523. if his.IdCardType == 4 {
  27524. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27525. token := psn_info.VerifyNumber
  27526. 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)
  27527. } else {
  27528. 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)
  27529. }
  27530. }
  27531. var dat map[string]interface{}
  27532. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27533. fmt.Println(dat)
  27534. } else {
  27535. fmt.Println(err)
  27536. }
  27537. saveLog(result2, src_resquest, "2207", "结算")
  27538. userJSONBytes, _ := json.Marshal(dat)
  27539. if miConfig.Code == "H15049901371" {
  27540. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27541. utils.ErrorLog("解析失败:%v", err)
  27542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27543. return
  27544. }
  27545. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27546. res.Output = resSeven10265.Output
  27547. res.ErrMsg = resSeven10265.ErrMsg
  27548. res.Cainfo = resSeven10265.Cainfo
  27549. res.WarnMsg = resSeven10265.WarnMsg
  27550. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27551. res.Infcode = infocode
  27552. } else {
  27553. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27554. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27555. utils.ErrorLog("解析失败:%v", err)
  27556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27557. return
  27558. }
  27559. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27560. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27561. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27562. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27563. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27564. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27565. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27566. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27567. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27568. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27569. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27570. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27571. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27572. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27573. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27574. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27575. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27576. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27577. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27578. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27579. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27580. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27581. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27582. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27583. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27584. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27585. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27586. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27587. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27588. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27589. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27590. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27591. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27592. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27593. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27594. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27595. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27596. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27597. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27598. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27599. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27600. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27601. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27602. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27603. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27604. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27605. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27606. res.Cainfo = gzresSeven10265Two.Cainfo
  27607. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27608. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27609. //res.Infcode = infocode
  27610. } else {
  27611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27612. utils.ErrorLog("解析失败:%v", err)
  27613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27614. return
  27615. }
  27616. }
  27617. }
  27618. }
  27619. if res.Infcode == -1 {
  27620. errlog := &models.HisOrderError{
  27621. UserOrgId: adminUser.CurrentOrgId,
  27622. Ctime: time.Now().Unix(),
  27623. Mtime: time.Now().Unix(),
  27624. Number: chrg_bchno,
  27625. ErrMsg: res.ErrMsg,
  27626. Status: 1,
  27627. PatientId: id,
  27628. RecordTime: recordDateTime,
  27629. Stage: 6,
  27630. }
  27631. service.CreateErrMsgLog(errlog)
  27632. c.ServeSuccessJSON(map[string]interface{}{
  27633. "failed_code": -10,
  27634. "msg": res.ErrMsg,
  27635. })
  27636. return
  27637. } else {
  27638. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27639. order.OrderStatus = 2
  27640. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27641. order.SetlId = res.Output.Setlinfo.SetlID
  27642. order.PsnNo = res.Output.Setlinfo.PsnNo
  27643. order.PsnName = res.Output.Setlinfo.PsnName
  27644. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27645. order.Certno = res.Output.Setlinfo.Certno
  27646. order.Gend = res.Output.Setlinfo.Gend
  27647. order.Naty = res.Output.Setlinfo.Naty
  27648. order.Age = res.Output.Setlinfo.Age
  27649. order.Insutype = res.Output.Setlinfo.Insutype
  27650. order.PsnType = res.Output.Setlinfo.PsnType
  27651. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27652. order.SetlTime = res.Output.Setlinfo.SetlTime
  27653. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27654. order.PayWays = pay_ways
  27655. order.AcctUsedFlag = acct_used_flag
  27656. order.WechatPay = wechat_pay
  27657. order.AliPay = ali_pay
  27658. order.JifenPay = jifen_pay
  27659. order.BandCardPay = band_card_pay
  27660. order.CashPay = cash_pay
  27661. order.OthDesc = oth_desc
  27662. //order.MedType = res.Output.Setlinfo.MedType
  27663. if reg_type == 1112 {
  27664. order.MedType = "1112"
  27665. }
  27666. if reg_type == 1111 {
  27667. order.MedType = "1111"
  27668. }
  27669. order.ClrType = res.Output.Setlinfo.ClrType
  27670. if adminUser.CurrentOrgId == 10480 {
  27671. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27672. order.ClrType = "11"
  27673. } else {
  27674. order.ClrType = "9903"
  27675. }
  27676. }
  27677. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27678. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27679. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27680. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27681. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27682. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27683. order.HifpPay = res.Output.Setlinfo.HifpPay
  27684. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27685. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27686. order.HifesPay = res.Output.Setlinfo.HifesPay
  27687. order.HifobPay = res.Output.Setlinfo.HifobPay
  27688. order.MafPay = res.Output.Setlinfo.MafPay
  27689. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27690. order.OthPay = res.Output.Setlinfo.OthPay
  27691. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27692. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27693. order.AcctPay = res.Output.Setlinfo.AcctPay
  27694. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27695. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27696. order.Balc = res.Output.Setlinfo.Balc
  27697. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27698. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27699. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27700. order.ClrWay = res.Output.Setlinfo.ClrWay
  27701. order.Creator = order.Creator
  27702. order.Modify = roles.AdminUserId
  27703. order.RequestLog = src_resquest
  27704. order.Diagnosis = diagnosis_id
  27705. order.FaPiaoNumber = fapiao_number
  27706. order.FaPiaoCode = fapiao_code
  27707. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27708. detailStr := string(setlDetail)
  27709. order.SetlDetail = detailStr
  27710. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27711. err = service.UpDateOrder(order)
  27712. if err == nil {
  27713. //判断是否使用了押金
  27714. if dec_way == "true" {
  27715. tmpstring := strconv.FormatInt(order.ID, 10)
  27716. //扣押金
  27717. order.Decimal = decimal
  27718. service.UpDateOrder(order)
  27719. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27720. if errmsg != nil {
  27721. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27722. return
  27723. }
  27724. }
  27725. c.ServeSuccessJSON(map[string]interface{}{
  27726. "msg": "结算成功",
  27727. })
  27728. } else {
  27729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27730. return
  27731. }
  27732. }
  27733. }
  27734. }
  27735. }
  27736. // 上传明细-预结算-
  27737. func (c *HisApiController) GetPreUploadInfo() {
  27738. id, _ := c.GetInt64("id")
  27739. record_time := c.GetString("record_time")
  27740. his_patient_id, _ := c.GetInt64("his_patient_id")
  27741. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27742. admin_user_id, _ := c.GetInt64("admin_user_id")
  27743. diagnosis_id := c.GetString("diagnosis")
  27744. sick_type, _ := c.GetInt64("sick_type")
  27745. reg_type, _ := c.GetInt64("p_type")
  27746. begin_time := c.GetString("begin_time")
  27747. acct_used_flag := c.GetString("acct_used_flag")
  27748. id_str := c.GetString("ids")
  27749. ids_arr := strings.Split(id_str, ",")
  27750. timeLayout := "2006-01-02"
  27751. loc, _ := time.LoadLocation("Local")
  27752. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27753. if err != nil {
  27754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27755. return
  27756. }
  27757. recordDateTime := theTime.Unix()
  27758. adminUser := c.GetAdminUserInfo()
  27759. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27760. var config []*models.HisXtDiagnoseConfig
  27761. for _, item := range diagnosis_ids {
  27762. id, _ := strconv.ParseInt(item, 10, 64)
  27763. if id > 0 {
  27764. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27765. config = append(config, &diagnosisConfig)
  27766. }
  27767. }
  27768. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27769. sickConfig, _ := service.FindSickById(sick_type)
  27770. var prescriptions []*models.HisPrescription
  27771. var start_time int64
  27772. var end_time int64
  27773. var isSuccess bool = true
  27774. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27775. fmt.Println(his_patient_id)
  27776. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27777. timestamp := time.Now().Unix()
  27778. tempTime := time.Unix(timestamp, 0)
  27779. timeFormat := tempTime.Format("20060102150405")
  27780. chrgBchno := rand.Intn(100000) + 10000
  27781. new_chrg_bchno := ""
  27782. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27783. new_chrg_bchno = chrg_bchno
  27784. if adminUser.CurrentOrgId == 10265 {
  27785. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27786. new_chrg_bchno = "0000"
  27787. }
  27788. }
  27789. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27790. var patientPrescription models.HisPrescriptionInfo
  27791. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27792. if patientPrescription.ID == 0 {
  27793. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27794. }
  27795. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27796. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27797. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27798. strconv.FormatInt(his.PatientId, 10)
  27799. var res2406 Result2406
  27800. //安徽单病种处理
  27801. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27802. data := make(map[string]interface{})
  27803. client := &http.Client{}
  27804. data["psn_no"] = his.PsnNo
  27805. data["mdtrt_id"] = his.Number
  27806. data["operator"] = roles.UserName
  27807. data["cert_no"] = his.IdCardNo
  27808. data["org_name"] = miConfig.OrgName
  27809. data["psn_name"] = his.Name
  27810. data["ipt_otp_no"] = his.IptOtpNo
  27811. data["ipt_psn_sp_flag_type"] = "0901"
  27812. data["ipt_psn_sp_flag"] = "1"
  27813. data["fixmedins_code"] = miConfig.Code
  27814. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27815. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27816. data["url"] = miConfig.Url
  27817. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27818. bytesData, _ := json.Marshal(data)
  27819. var req *http.Request
  27820. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27821. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27822. resp, _ := client.Do(req)
  27823. defer resp.Body.Close()
  27824. body, ioErr := ioutil.ReadAll(resp.Body)
  27825. if ioErr != nil {
  27826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27828. return
  27829. }
  27830. var respJSON map[string]interface{}
  27831. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27834. return
  27835. }
  27836. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27837. if status == "0" {
  27838. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27839. c.ServeSuccessJSON(map[string]interface{}{
  27840. "failed_code": -10,
  27841. "msg": err_msg,
  27842. })
  27843. return
  27844. }
  27845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27846. userJSONBytes, _ := json.Marshal(respJSON)
  27847. fmt.Println("log")
  27848. fmt.Println(string(userJSONBytes))
  27849. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27850. utils.ErrorLog("解析失败:%v", err)
  27851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27852. return
  27853. }
  27854. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  27855. data := make(map[string]interface{})
  27856. client := &http.Client{}
  27857. data["psn_no"] = his.PsnNo
  27858. data["mdtrt_id"] = his.Number
  27859. data["operator"] = roles.UserName
  27860. data["cert_no"] = his.IdCardNo
  27861. data["org_name"] = miConfig.OrgName
  27862. data["psn_name"] = his.Name
  27863. data["ipt_otp_no"] = his.IptOtpNo
  27864. data["ipt_psn_sp_flag_type"] = "0901"
  27865. data["ipt_psn_sp_flag"] = "1"
  27866. data["fixmedins_code"] = miConfig.Code
  27867. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27868. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27869. data["url"] = miConfig.Url
  27870. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27871. bytesData, _ := json.Marshal(data)
  27872. var req *http.Request
  27873. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27874. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27875. resp, _ := client.Do(req)
  27876. defer resp.Body.Close()
  27877. body, ioErr := ioutil.ReadAll(resp.Body)
  27878. if ioErr != nil {
  27879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27881. return
  27882. }
  27883. var respJSON map[string]interface{}
  27884. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27887. return
  27888. }
  27889. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27890. if status == "0" {
  27891. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27892. c.ServeSuccessJSON(map[string]interface{}{
  27893. "failed_code": -10,
  27894. "msg": err_msg,
  27895. })
  27896. return
  27897. }
  27898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27899. userJSONBytes, _ := json.Marshal(respJSON)
  27900. fmt.Println("log")
  27901. fmt.Println(string(userJSONBytes))
  27902. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27903. utils.ErrorLog("解析失败:%v", err)
  27904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27905. return
  27906. }
  27907. }
  27908. if res2406.Infcode != 0 {
  27909. adminUser := c.GetAdminUserInfo()
  27910. errlog := &models.HisOrderError{
  27911. UserOrgId: adminUser.CurrentOrgId,
  27912. Ctime: time.Now().Unix(),
  27913. Mtime: time.Now().Unix(),
  27914. ErrMsg: res2406.ErrMsg,
  27915. Status: 1,
  27916. PatientId: id,
  27917. RecordTime: recordDateTime,
  27918. Stage: 3,
  27919. }
  27920. service.CreateErrMsgLog(errlog)
  27921. c.ServeSuccessJSON(map[string]interface{}{
  27922. "failed_code": -10,
  27923. "msg": res2406.ErrMsg,
  27924. })
  27925. return
  27926. }
  27927. var res2 ResultSix
  27928. var res3 GZResultSix
  27929. var resSix10265 ResultSix10265
  27930. //var time_stamp string
  27931. if miConfig.MdtrtareaAdmvs == "421300" {
  27932. data := make(map[string]interface{})
  27933. client := &http.Client{}
  27934. data["psn_no"] = his.PsnNo
  27935. data["mdtrt_id"] = his.Number
  27936. data["department"] = department.Name
  27937. data["org_name"] = miConfig.OrgName
  27938. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27939. data["doctor_id"] = doctor_info.DoctorNumber
  27940. data["doctor_name"] = roles.UserName
  27941. data["fixmedins_code"] = miConfig.Code
  27942. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27943. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27944. data["secret_key"] = miConfig.SecretKey
  27945. data["sick_code"] = sickConfig.CountryCode
  27946. data["sick_name"] = sickConfig.ClassName
  27947. data["begin_time"] = begin_time
  27948. data["dept"] = strconv.FormatInt(department.ID, 10)
  27949. data["config"] = config
  27950. data["opter"] = roles.UserName
  27951. fmt.Println(data)
  27952. bytesData, _ := json.Marshal(data)
  27953. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  27954. resp, _ := client.Do(req)
  27955. defer resp.Body.Close()
  27956. body, ioErr := ioutil.ReadAll(resp.Body)
  27957. if ioErr != nil {
  27958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27960. return
  27961. }
  27962. var respJSON map[string]interface{}
  27963. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27966. return
  27967. }
  27968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27969. userJSONBytes, _ := json.Marshal(respJSON)
  27970. fmt.Println("log")
  27971. fmt.Println(string(userJSONBytes))
  27972. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27973. utils.ErrorLog("解析失败:%v", err)
  27974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27975. return
  27976. }
  27977. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27978. data := make(map[string]interface{})
  27979. client := &http.Client{}
  27980. data["psn_no"] = his.PsnNo
  27981. data["mdtrt_id"] = his.Number
  27982. data["department"] = department.Name
  27983. data["org_name"] = miConfig.OrgName
  27984. if reg_type == 11 && his.Insutype == "390" {
  27985. data["med_type"] = "110104"
  27986. } else {
  27987. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27988. }
  27989. data["doctor_id"] = doctor_info.DoctorNumber
  27990. data["doctor_name"] = roles.UserName
  27991. data["fixmedins_code"] = miConfig.Code
  27992. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27993. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27994. data["secret_key"] = miConfig.SecretKey
  27995. data["sick_code"] = sickConfig.CountryCode
  27996. data["sick_name"] = sickConfig.ClassName
  27997. data["begin_time"] = begin_time
  27998. data["dept"] = strconv.FormatInt(department.ID, 10)
  27999. data["config"] = config
  28000. data["opter"] = roles.UserName
  28001. fmt.Println(data)
  28002. bytesData, _ := json.Marshal(data)
  28003. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28004. resp, _ := client.Do(req)
  28005. defer resp.Body.Close()
  28006. body, ioErr := ioutil.ReadAll(resp.Body)
  28007. if ioErr != nil {
  28008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28010. return
  28011. }
  28012. var respJSON map[string]interface{}
  28013. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28016. return
  28017. }
  28018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28019. userJSONBytes, _ := json.Marshal(respJSON)
  28020. fmt.Println("log")
  28021. fmt.Println(string(userJSONBytes))
  28022. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28023. utils.ErrorLog("解析失败:%v", err)
  28024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28025. return
  28026. }
  28027. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28028. data := make(map[string]interface{})
  28029. client := &http.Client{}
  28030. data["psn_no"] = his.PsnNo
  28031. data["mdtrt_id"] = his.Number
  28032. data["department"] = department.Name
  28033. data["org_name"] = miConfig.OrgName
  28034. if reg_type == 11 && his.Insutype == "390" {
  28035. data["med_type"] = "110104"
  28036. } else {
  28037. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28038. }
  28039. data["doctor_id"] = doctor_info.DoctorNumber
  28040. data["doctor_name"] = roles.UserName
  28041. data["fixmedins_code"] = miConfig.Code
  28042. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28043. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28044. data["secret_key"] = miConfig.SecretKey
  28045. data["sick_code"] = sickConfig.CountryCode
  28046. data["sick_name"] = sickConfig.ClassName
  28047. data["begin_time"] = begin_time
  28048. data["dept"] = strconv.FormatInt(department.ID, 10)
  28049. data["config"] = config
  28050. data["opter"] = roles.UserName
  28051. fmt.Println(data)
  28052. bytesData, _ := json.Marshal(data)
  28053. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28054. resp, _ := client.Do(req)
  28055. defer resp.Body.Close()
  28056. body, ioErr := ioutil.ReadAll(resp.Body)
  28057. if ioErr != nil {
  28058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28060. return
  28061. }
  28062. var respJSON map[string]interface{}
  28063. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28066. return
  28067. }
  28068. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28069. userJSONBytes, _ := json.Marshal(respJSON)
  28070. fmt.Println("log")
  28071. fmt.Println(string(userJSONBytes))
  28072. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28073. utils.ErrorLog("解析失败:%v", err)
  28074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28075. return
  28076. }
  28077. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28078. data := make(map[string]interface{})
  28079. client := &http.Client{}
  28080. data["psn_no"] = his.PsnNo
  28081. data["mdtrt_id"] = his.Number
  28082. data["department"] = department.Name
  28083. data["org_name"] = miConfig.OrgName
  28084. if reg_type == 11 && his.Insutype == "390" {
  28085. data["med_type"] = "110104"
  28086. } else {
  28087. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28088. }
  28089. data["doctor_id"] = doctor_info.DoctorNumber
  28090. data["doctor_name"] = roles.UserName
  28091. data["fixmedins_code"] = miConfig.Code
  28092. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28093. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28094. data["secret_key"] = miConfig.SecretKey
  28095. data["sick_code"] = sickConfig.CountryCode
  28096. data["sick_name"] = sickConfig.ClassName
  28097. data["begin_time"] = begin_time
  28098. data["dept"] = strconv.FormatInt(department.ID, 10)
  28099. data["config"] = config
  28100. data["opter"] = roles.UserName
  28101. fmt.Println(data)
  28102. bytesData, _ := json.Marshal(data)
  28103. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28104. resp, _ := client.Do(req)
  28105. defer resp.Body.Close()
  28106. body, ioErr := ioutil.ReadAll(resp.Body)
  28107. if ioErr != nil {
  28108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28110. return
  28111. }
  28112. var respJSON map[string]interface{}
  28113. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28116. return
  28117. }
  28118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28119. userJSONBytes, _ := json.Marshal(respJSON)
  28120. fmt.Println("log")
  28121. fmt.Println(string(userJSONBytes))
  28122. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28123. utils.ErrorLog("解析失败:%v", err)
  28124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28125. return
  28126. }
  28127. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28128. data := make(map[string]interface{})
  28129. client := &http.Client{}
  28130. data["psn_no"] = his.PsnNo
  28131. data["mdtrt_id"] = his.Number
  28132. data["doctor"] = roles.UserName
  28133. data["department"] = department.Name
  28134. data["org_name"] = miConfig.OrgName
  28135. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28136. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28137. data["fixmedins_code"] = miConfig.Code
  28138. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28139. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28140. data["secret_key"] = miConfig.SecretKey
  28141. data["sick_code"] = sickConfig.CountryCode
  28142. data["sick_name"] = sickConfig.ClassName
  28143. data["begin_time"] = begin_time
  28144. data["dept"] = strconv.FormatInt(department.ID, 10)
  28145. data["config"] = config
  28146. data["url"] = miConfig.Url
  28147. data["ak"] = miConfig.AccessKey
  28148. data["cainfo"] = miConfig.Cainfo
  28149. bytesData, _ := json.Marshal(data)
  28150. var req *http.Request
  28151. if miConfig.MdtrtareaAdmvs == "320921" {
  28152. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28153. } else {
  28154. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28155. }
  28156. resp, _ := client.Do(req)
  28157. defer resp.Body.Close()
  28158. body, ioErr := ioutil.ReadAll(resp.Body)
  28159. if ioErr != nil {
  28160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28162. return
  28163. }
  28164. var respJSON map[string]interface{}
  28165. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28168. return
  28169. }
  28170. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28171. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28172. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28174. userJSONBytes, _ := json.Marshal(respJSON)
  28175. fmt.Println("log")
  28176. fmt.Println(string(userJSONBytes))
  28177. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28178. utils.ErrorLog("解析失败:%v", err)
  28179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28180. return
  28181. }
  28182. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28183. res2.Output = resSix10265.Output
  28184. res2.ErrMsg = resSix10265.ErrMsg
  28185. res2.Cainfo = resSix10265.Cainfo
  28186. res2.WarnMsg = resSix10265.WarnMsg
  28187. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28188. res2.Infcode = infocode
  28189. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28190. data := make(map[string]interface{})
  28191. client := &http.Client{}
  28192. data["psn_no"] = his.PsnNo
  28193. data["mdtrt_id"] = his.Number
  28194. data["doctor"] = roles.UserName
  28195. data["department"] = department.Name
  28196. data["org_name"] = miConfig.OrgName
  28197. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28198. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28199. data["fixmedins_code"] = miConfig.Code
  28200. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28201. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28202. data["secret_key"] = miConfig.SecretKey
  28203. data["sick_code"] = sickConfig.CountryCode
  28204. data["sick_name"] = sickConfig.ClassName
  28205. data["begin_time"] = begin_time
  28206. data["dept"] = strconv.FormatInt(department.ID, 10)
  28207. data["config"] = config
  28208. //data["url"] = miConfig.Url
  28209. //data["ak"] = miConfig.AccessKey
  28210. data["cainfo"] = miConfig.Cainfo
  28211. fmt.Println(data)
  28212. bytesData, _ := json.Marshal(data)
  28213. var req *http.Request
  28214. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28215. resp, _ := client.Do(req)
  28216. defer resp.Body.Close()
  28217. body, ioErr := ioutil.ReadAll(resp.Body)
  28218. if ioErr != nil {
  28219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28221. return
  28222. }
  28223. var respJSON map[string]interface{}
  28224. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28227. return
  28228. }
  28229. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28230. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28231. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28232. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28233. userJSONBytes, _ := json.Marshal(respJSON)
  28234. fmt.Println("log")
  28235. fmt.Println(string(userJSONBytes))
  28236. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28237. utils.ErrorLog("解析失败:%v", err)
  28238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28239. return
  28240. }
  28241. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28242. res2.Output = resSix10265.Output
  28243. res2.ErrMsg = resSix10265.ErrMsg
  28244. res2.Cainfo = resSix10265.Cainfo
  28245. res2.WarnMsg = resSix10265.WarnMsg
  28246. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28247. res2.Infcode = infocode
  28248. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28249. 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)
  28250. saveLog(result, requestLog, "2203", "上传就诊信息")
  28251. var respJSON2 map[string]interface{}
  28252. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28255. return
  28256. }
  28257. userJSONBytes2, _ := json.Marshal(respJSON2)
  28258. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28259. utils.ErrorLog("解析失败:%v", err)
  28260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28261. return
  28262. }
  28263. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28264. var result string
  28265. var requestLog string
  28266. 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, "")
  28267. saveLog(result, requestLog, "2203", "上传就诊信息")
  28268. var respJSON2 map[string]interface{}
  28269. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28272. return
  28273. }
  28274. userJSONBytes2, _ := json.Marshal(respJSON2)
  28275. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28276. utils.ErrorLog("解析失败:%v", err)
  28277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28278. return
  28279. }
  28280. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28281. var result string
  28282. var requestLog string
  28283. 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, "")
  28284. saveLog(result, requestLog, "2203", "上传就诊信息")
  28285. var respJSON2 map[string]interface{}
  28286. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28289. return
  28290. }
  28291. userJSONBytes2, _ := json.Marshal(respJSON2)
  28292. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28293. utils.ErrorLog("解析失败:%v", err)
  28294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28295. return
  28296. }
  28297. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28298. data := make(map[string]interface{})
  28299. client := &http.Client{}
  28300. data["psn_no"] = his.PsnNo
  28301. data["mdtrt_id"] = his.Number
  28302. data["operator"] = roles.UserName
  28303. data["department"] = department.Name
  28304. data["org_name"] = miConfig.OrgName
  28305. var med_type string
  28306. if his.Insutype == "390" {
  28307. if reg_type == 992102 {
  28308. med_type = "992102"
  28309. data["sick_code"] = "ZDZ940"
  28310. data["sick_name"] = "慢性肾衰竭"
  28311. }
  28312. if reg_type == 140104 {
  28313. med_type = "140104"
  28314. data["sick_code"] = sickConfig.CountryCode
  28315. data["sick_name"] = sickConfig.ClassName
  28316. }
  28317. if reg_type == 14 {
  28318. med_type = "140104"
  28319. data["sick_code"] = sickConfig.CountryCode
  28320. data["sick_name"] = sickConfig.ClassName
  28321. }
  28322. } else if his.Insutype == "310" {
  28323. if reg_type == 992102 {
  28324. med_type = "992102"
  28325. data["sick_code"] = "ZDZ940"
  28326. data["sick_name"] = "慢性肾衰竭"
  28327. }
  28328. if reg_type == 140104 {
  28329. med_type = "140104"
  28330. data["sick_code"] = sickConfig.CountryCode
  28331. data["sick_name"] = sickConfig.ClassName
  28332. }
  28333. if reg_type == 14 {
  28334. med_type = "14"
  28335. data["sick_code"] = sickConfig.CountryCode
  28336. data["sick_name"] = sickConfig.ClassName
  28337. }
  28338. }
  28339. data["med_type"] = med_type
  28340. data["doctor_number"] = doctor_info.DoctorNumber
  28341. data["doctor_name"] = doctor_info.UserName
  28342. data["fixmedins_code"] = miConfig.Code
  28343. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28344. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28345. data["secret_key"] = miConfig.SecretKey
  28346. data["begin_time"] = begin_time
  28347. data["dept"] = strconv.FormatInt(department.ID, 10)
  28348. data["config"] = config
  28349. data["url"] = miConfig.Url
  28350. data["ak"] = miConfig.AccessKey
  28351. data["cainfo"] = miConfig.Cainfo
  28352. bytesData, _ := json.Marshal(data)
  28353. var req *http.Request
  28354. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28355. resp, _ := client.Do(req)
  28356. defer resp.Body.Close()
  28357. body, ioErr := ioutil.ReadAll(resp.Body)
  28358. if ioErr != nil {
  28359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28361. return
  28362. }
  28363. var respJSON map[string]interface{}
  28364. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28367. return
  28368. }
  28369. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28370. if status == "0" {
  28371. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28372. c.ServeSuccessJSON(map[string]interface{}{
  28373. "failed_code": -10,
  28374. "msg": err_msg,
  28375. })
  28376. return
  28377. }
  28378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28379. userJSONBytes, _ := json.Marshal(respJSON)
  28380. fmt.Println("log")
  28381. fmt.Println(string(userJSONBytes))
  28382. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28383. utils.ErrorLog("解析失败:%v", err)
  28384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28385. return
  28386. }
  28387. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28388. data := make(map[string]interface{})
  28389. client := &http.Client{}
  28390. data["psn_no"] = his.PsnNo
  28391. data["mdtrt_id"] = his.Number
  28392. data["operator"] = roles.UserName
  28393. data["department"] = department.Name
  28394. data["org_name"] = miConfig.OrgName
  28395. var med_type string
  28396. if his.Insutype == "390" {
  28397. if reg_type == 992102 {
  28398. med_type = "992102"
  28399. data["sick_code"] = sickConfig.CountryCode
  28400. data["sick_name"] = sickConfig.ClassName
  28401. }
  28402. if reg_type == 140104 {
  28403. med_type = "140104"
  28404. data["sick_code"] = sickConfig.CountryCode
  28405. data["sick_name"] = sickConfig.ClassName
  28406. }
  28407. if reg_type == 140201 {
  28408. med_type = "140201"
  28409. data["sick_code"] = sickConfig.CountryCode
  28410. data["sick_name"] = sickConfig.ClassName
  28411. }
  28412. if reg_type == 14 {
  28413. med_type = "14"
  28414. data["sick_code"] = sickConfig.CountryCode
  28415. data["sick_name"] = sickConfig.ClassName
  28416. }
  28417. } else if his.Insutype == "310" {
  28418. if reg_type == 992102 {
  28419. med_type = "992102"
  28420. data["sick_code"] = sickConfig.CountryCode
  28421. data["sick_name"] = sickConfig.ClassName
  28422. }
  28423. if reg_type == 140104 {
  28424. med_type = "140104"
  28425. data["sick_code"] = sickConfig.CountryCode
  28426. data["sick_name"] = sickConfig.ClassName
  28427. }
  28428. if reg_type == 140201 {
  28429. med_type = "140201"
  28430. data["sick_code"] = sickConfig.CountryCode
  28431. data["sick_name"] = sickConfig.ClassName
  28432. }
  28433. if reg_type == 14 {
  28434. med_type = "14"
  28435. data["sick_code"] = sickConfig.CountryCode
  28436. data["sick_name"] = sickConfig.ClassName
  28437. }
  28438. }
  28439. data["med_type"] = med_type
  28440. data["doctor_number"] = doctor_info.DoctorNumber
  28441. data["doctor_name"] = doctor_info.UserName
  28442. data["fixmedins_code"] = miConfig.Code
  28443. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28444. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28445. data["secret_key"] = miConfig.SecretKey
  28446. data["begin_time"] = begin_time
  28447. data["dept"] = strconv.FormatInt(department.ID, 10)
  28448. data["config"] = config
  28449. data["url"] = miConfig.Url
  28450. data["ak"] = miConfig.AccessKey
  28451. data["cainfo"] = miConfig.Cainfo
  28452. bytesData, _ := json.Marshal(data)
  28453. var req *http.Request
  28454. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28455. resp, _ := client.Do(req)
  28456. defer resp.Body.Close()
  28457. body, ioErr := ioutil.ReadAll(resp.Body)
  28458. if ioErr != nil {
  28459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28461. return
  28462. }
  28463. var respJSON map[string]interface{}
  28464. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28467. return
  28468. }
  28469. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28470. if status == "0" {
  28471. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28472. c.ServeSuccessJSON(map[string]interface{}{
  28473. "failed_code": -10,
  28474. "msg": err_msg,
  28475. })
  28476. return
  28477. }
  28478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28479. userJSONBytes, _ := json.Marshal(respJSON)
  28480. fmt.Println("log")
  28481. fmt.Println(string(userJSONBytes))
  28482. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28483. utils.ErrorLog("解析失败:%v", err)
  28484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28485. return
  28486. }
  28487. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28488. var result string
  28489. var requestLog string
  28490. 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, "")
  28491. saveLog(result, requestLog, "2203", "上传就诊信息")
  28492. var respJSON2 map[string]interface{}
  28493. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28496. return
  28497. }
  28498. userJSONBytes2, _ := json.Marshal(respJSON2)
  28499. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28500. utils.ErrorLog("解析失败:%v", err)
  28501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28502. return
  28503. }
  28504. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28505. data := make(map[string]interface{})
  28506. client := &http.Client{}
  28507. data["psn_no"] = his.PsnNo
  28508. data["mdtrt_id"] = his.Number
  28509. data["doctor"] = roles.UserName
  28510. data["department"] = department.Name
  28511. data["org_name"] = miConfig.OrgName
  28512. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28513. data["doctor_id"] = doctor_info.DoctorNumber
  28514. data["fixmedins_code"] = miConfig.Code
  28515. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28516. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28517. data["secret_key"] = miConfig.SecretKey
  28518. data["sick_code"] = sickConfig.CountryCode
  28519. data["sick_name"] = sickConfig.ClassName
  28520. data["begin_time"] = begin_time
  28521. data["new_doctor_name"] = doctor_info.UserName
  28522. data["dept"] = strconv.FormatInt(department.ID, 10)
  28523. data["config"] = config
  28524. bytesData, _ := json.Marshal(data)
  28525. var req *http.Request
  28526. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28527. resp, _ := client.Do(req)
  28528. defer resp.Body.Close()
  28529. body, ioErr := ioutil.ReadAll(resp.Body)
  28530. if ioErr != nil {
  28531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28533. return
  28534. }
  28535. var respJSON map[string]interface{}
  28536. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28539. return
  28540. }
  28541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28542. userJSONBytes, _ := json.Marshal(respJSON)
  28543. fmt.Println("log")
  28544. fmt.Println(string(userJSONBytes))
  28545. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28546. utils.ErrorLog("解析失败:%v", err)
  28547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28548. return
  28549. }
  28550. } else {
  28551. var result string
  28552. var requestLog string
  28553. if miConfig.MdtrtareaAdmvs == "440781" { //
  28554. 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)
  28555. } else {
  28556. if miConfig.Code == "H15049901371" {
  28557. //赤峰地区国家医保医疗类别
  28558. //职工透析:医疗类别选特殊情况门诊990502
  28559. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28560. var med_type string
  28561. if his.Insutype == "390" {
  28562. if reg_type == 14 {
  28563. med_type = "9933"
  28564. } else if reg_type == 11 {
  28565. med_type = "11"
  28566. }
  28567. } else if his.Insutype == "310" {
  28568. if reg_type == 14 {
  28569. med_type = "990502"
  28570. } else if reg_type == 11 {
  28571. med_type = "11"
  28572. }
  28573. }
  28574. 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)
  28575. } else {
  28576. 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)
  28577. }
  28578. saveLog(result, requestLog, "2203", "上传就诊信息")
  28579. var respJSON2 map[string]interface{}
  28580. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28583. return
  28584. }
  28585. userJSONBytes2, _ := json.Marshal(respJSON2)
  28586. if miConfig.Code == "H15049901371" {
  28587. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28588. utils.ErrorLog("解析失败:%v", err)
  28589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28590. return
  28591. }
  28592. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28593. res2.Output = resSix10265.Output
  28594. res2.ErrMsg = resSix10265.ErrMsg
  28595. res2.Cainfo = resSix10265.Cainfo
  28596. res2.WarnMsg = resSix10265.WarnMsg
  28597. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28598. res2.Infcode = infocode
  28599. } else {
  28600. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28601. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28602. utils.ErrorLog("解析失败:%v", err)
  28603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28604. return
  28605. }
  28606. res2.Infcode = res3.Infcode
  28607. } else {
  28608. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28609. utils.ErrorLog("解析失败:%v", err)
  28610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28611. return
  28612. }
  28613. }
  28614. }
  28615. }
  28616. }
  28617. if res2.Infcode == -1 {
  28618. adminUser := c.GetAdminUserInfo()
  28619. errlog := &models.HisOrderError{
  28620. UserOrgId: adminUser.CurrentOrgId,
  28621. Ctime: time.Now().Unix(),
  28622. Mtime: time.Now().Unix(),
  28623. ErrMsg: res2.ErrMsg,
  28624. Status: 1,
  28625. PatientId: id,
  28626. RecordTime: recordDateTime,
  28627. Stage: 3,
  28628. }
  28629. service.CreateErrMsgLog(errlog)
  28630. c.ServeSuccessJSON(map[string]interface{}{
  28631. "failed_code": -10,
  28632. "msg": res2.ErrMsg,
  28633. })
  28634. return
  28635. }
  28636. if res2.Infcode != 0 {
  28637. adminUser := c.GetAdminUserInfo()
  28638. errlog := &models.HisOrderError{
  28639. UserOrgId: adminUser.CurrentOrgId,
  28640. Ctime: time.Now().Unix(),
  28641. Mtime: time.Now().Unix(),
  28642. ErrMsg: res2.ErrMsg,
  28643. Status: 1,
  28644. PatientId: id,
  28645. RecordTime: recordDateTime,
  28646. Stage: 3,
  28647. }
  28648. service.CreateErrMsgLog(errlog)
  28649. c.ServeSuccessJSON(map[string]interface{}{
  28650. "failed_code": -10,
  28651. "msg": res2.ErrMsg,
  28652. })
  28653. return
  28654. } else {
  28655. his.Diagnosis = diagnosis_id
  28656. his.SickType = sickConfig.ID
  28657. his.PType = fmt.Sprintf("%d", reg_type)
  28658. service.UpdateHisPatientThree(&his)
  28659. data := make(map[string]interface{})
  28660. if settle_accounts_type == 1 { //日结
  28661. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28662. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28663. } else {
  28664. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28665. }
  28666. data["pre"] = prescriptions
  28667. } else { //月结
  28668. start_time_str := c.GetString("start_time")
  28669. end_time_str := c.GetString("end_time")
  28670. timeLayout := "2006-01-02"
  28671. loc, _ := time.LoadLocation("Local")
  28672. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28673. if err != nil {
  28674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28675. return
  28676. }
  28677. recordStartTime := theStartTime.Unix()
  28678. start_time = recordStartTime
  28679. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28680. if err != nil {
  28681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28682. return
  28683. }
  28684. recordEndTime := theEndTime.Unix()
  28685. end_time = recordEndTime
  28686. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28687. data["pre"] = prescriptions
  28688. }
  28689. client := &http.Client{}
  28690. data["psn_no"] = his.PsnNo
  28691. data["mdtrt_id"] = his.Number
  28692. data["chrg_bchno"] = new_chrg_bchno
  28693. data["org_name"] = miConfig.OrgName
  28694. data["doctor"] = doctor_info.UserName
  28695. data["doctor_id"] = doctor_info.DoctorNumber
  28696. data["dept"] = department.Name
  28697. data["fixmedins_code"] = miConfig.Code
  28698. data["opter"] = roles.UserName
  28699. data["dept_code"] = department.Number
  28700. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28701. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28702. data["secret_key"] = miConfig.SecretKey
  28703. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28704. data["url"] = miConfig.Url
  28705. data["ak"] = miConfig.AccessKey
  28706. data["new_doctor_name"] = patientPrescription.Doctor
  28707. if his.Insutype == "390" {
  28708. if reg_type == 992102 {
  28709. data["diag_code"] = "ZDZ940"
  28710. }
  28711. if reg_type == 140104 {
  28712. data["diag_code"] = sickConfig.CountryCode
  28713. }
  28714. if reg_type == 140201 {
  28715. data["diag_code"] = sickConfig.CountryCode
  28716. }
  28717. if reg_type == 14 {
  28718. data["diag_code"] = sickConfig.CountryCode
  28719. }
  28720. } else if his.Insutype == "310" {
  28721. if miConfig.MdtrtareaAdmvs == "341203" {
  28722. if reg_type == 992102 {
  28723. data["diag_code"] = "ZDZ940"
  28724. }
  28725. if reg_type != 992102 {
  28726. data["diag_code"] = sickConfig.CountryCode
  28727. }
  28728. } else {
  28729. data["diag_code"] = sickConfig.CountryCode
  28730. }
  28731. }
  28732. data["cainfo"] = miConfig.Cainfo
  28733. data["opter"] = roles.UserName
  28734. var ids []int64
  28735. for _, item := range prescriptions {
  28736. ids = append(ids, item.ID)
  28737. }
  28738. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28739. if config.IsOpen == 1 { //对接了医保,走医保流程
  28740. var res ResultFour
  28741. var resFour10265 ResultFour10265
  28742. if miConfig.MdtrtareaAdmvs == "421300" {
  28743. bytesData, _ := json.Marshal(data)
  28744. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28745. resp, _ := client.Do(req)
  28746. defer resp.Body.Close()
  28747. body, ioErr := ioutil.ReadAll(resp.Body)
  28748. if ioErr != nil {
  28749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28751. return
  28752. }
  28753. var respJSON map[string]interface{}
  28754. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28757. return
  28758. }
  28759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28760. userJSONBytes, _ := json.Marshal(respJSON)
  28761. fmt.Println("log")
  28762. fmt.Println(string(userJSONBytes))
  28763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28764. utils.ErrorLog("解析失败:%v", err)
  28765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28766. return
  28767. }
  28768. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28769. bytesData, _ := json.Marshal(data)
  28770. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28771. resp, _ := client.Do(req)
  28772. defer resp.Body.Close()
  28773. body, ioErr := ioutil.ReadAll(resp.Body)
  28774. if ioErr != nil {
  28775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28777. return
  28778. }
  28779. var respJSON map[string]interface{}
  28780. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28783. return
  28784. }
  28785. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28786. userJSONBytes, _ := json.Marshal(respJSON)
  28787. fmt.Println("log")
  28788. fmt.Println(string(userJSONBytes))
  28789. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28790. utils.ErrorLog("解析失败:%v", err)
  28791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28792. return
  28793. }
  28794. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28795. bytesData, _ := json.Marshal(data)
  28796. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28797. resp, _ := client.Do(req)
  28798. defer resp.Body.Close()
  28799. body, ioErr := ioutil.ReadAll(resp.Body)
  28800. if ioErr != nil {
  28801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28803. return
  28804. }
  28805. var respJSON map[string]interface{}
  28806. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28809. return
  28810. }
  28811. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28812. userJSONBytes, _ := json.Marshal(respJSON)
  28813. fmt.Println("log")
  28814. fmt.Println(string(userJSONBytes))
  28815. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28816. utils.ErrorLog("解析失败:%v", err)
  28817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28818. return
  28819. }
  28820. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28821. bytesData, _ := json.Marshal(data)
  28822. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28823. resp, _ := client.Do(req)
  28824. defer resp.Body.Close()
  28825. body, ioErr := ioutil.ReadAll(resp.Body)
  28826. if ioErr != nil {
  28827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28829. return
  28830. }
  28831. var respJSON map[string]interface{}
  28832. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28835. return
  28836. }
  28837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28838. userJSONBytes, _ := json.Marshal(respJSON)
  28839. fmt.Println("log")
  28840. fmt.Println(string(userJSONBytes))
  28841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28842. utils.ErrorLog("解析失败:%v", err)
  28843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28844. return
  28845. }
  28846. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28847. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28848. if result3101.Infcode == "0" {
  28849. if len(result3101.Output.Result) > 0 {
  28850. var errMsgs []string
  28851. for _, item := range result3101.Output.Result {
  28852. errMsgs = append(errMsgs, item.VolaCont)
  28853. }
  28854. c.ServeSuccessJSON(map[string]interface{}{
  28855. "failed_code": -10,
  28856. "msg": errMsgs,
  28857. })
  28858. return
  28859. } else {
  28860. if miConfig.MdtrtareaAdmvs == "320921" {
  28861. data["doctor_id"] = "D320923012139"
  28862. } else {
  28863. data["doctor_id"] = "D371621008686"
  28864. }
  28865. bytesData, _ := json.Marshal(data)
  28866. var req *http.Request
  28867. if miConfig.MdtrtareaAdmvs == "320921" {
  28868. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28869. } else {
  28870. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28871. }
  28872. resp, _ := client.Do(req)
  28873. defer resp.Body.Close()
  28874. body, ioErr := ioutil.ReadAll(resp.Body)
  28875. if ioErr != nil {
  28876. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28878. return
  28879. }
  28880. var respJSON map[string]interface{}
  28881. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28884. return
  28885. }
  28886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28887. userJSONBytes, _ := json.Marshal(respJSON)
  28888. fmt.Println("log")
  28889. fmt.Println(string(userJSONBytes))
  28890. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28891. utils.ErrorLog("解析失败:%v", err)
  28892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28893. return
  28894. }
  28895. res.InfRefmsgid = resFour10265.InfRefmsgid
  28896. res.Output = resFour10265.Output
  28897. res.ErrMsg = resFour10265.ErrMsg
  28898. res.Cainfo = resFour10265.Cainfo
  28899. res.WarnMsg = resFour10265.WarnMsg
  28900. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28901. res.Infcode = infocode
  28902. }
  28903. }
  28904. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28905. var pagesize int = 5
  28906. var start int = 1
  28907. var stop int
  28908. var pagecount int
  28909. var curpage int
  28910. data["doctor_id"] = doctor_info.DoctorNumber
  28911. var res2 ResultFour
  28912. //var result res.
  28913. //总页数,向上取整,注意除之前要先转换类型为float64
  28914. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  28915. for curpage = 1; curpage <= pagecount; curpage++ {
  28916. if curpage == 1 {
  28917. start = 1
  28918. } else {
  28919. start = (curpage-1)*pagesize + 1
  28920. }
  28921. stop = curpage * pagesize
  28922. if stop > len(prescriptions) {
  28923. stop = len(prescriptions)
  28924. }
  28925. //var requestLog string
  28926. data["pre"] = prescriptions[start-1 : stop]
  28927. fmt.Println(data["pre"])
  28928. bytesData, _ := json.Marshal(data)
  28929. var req *http.Request
  28930. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  28931. resp, _ := client.Do(req)
  28932. defer resp.Body.Close()
  28933. body, ioErr := ioutil.ReadAll(resp.Body)
  28934. if ioErr != nil {
  28935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28937. return
  28938. }
  28939. var respJSON map[string]interface{}
  28940. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28943. return
  28944. }
  28945. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28946. userJSONBytes, _ := json.Marshal(respJSON)
  28947. fmt.Println("log")
  28948. fmt.Println(string(userJSONBytes))
  28949. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28950. utils.ErrorLog("解析失败:%v", err)
  28951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28952. return
  28953. }
  28954. res.InfRefmsgid = resFour10265.InfRefmsgid
  28955. res.Output = resFour10265.Output
  28956. res.ErrMsg = resFour10265.ErrMsg
  28957. res.Cainfo = resFour10265.Cainfo
  28958. res.WarnMsg = resFour10265.WarnMsg
  28959. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28960. res.Infcode = infocode
  28961. if infocode == 0 {
  28962. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  28963. } else {
  28964. isSuccess = false
  28965. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  28966. res.Infcode = -1
  28967. res.ErrMsg = resFour10265.ErrMsg
  28968. errlog := &models.HisOrderError{
  28969. UserOrgId: adminUser.CurrentOrgId,
  28970. Ctime: time.Now().Unix(),
  28971. Mtime: time.Now().Unix(),
  28972. Number: chrg_bchno,
  28973. ErrMsg: "",
  28974. Status: 1,
  28975. PatientId: id,
  28976. RecordTime: recordDateTime,
  28977. Stage: 4,
  28978. }
  28979. service.CreateErrMsgLog(errlog)
  28980. }
  28981. }
  28982. if isSuccess {
  28983. res.Infcode = 0
  28984. res.Output.Result = res2.Output.Result
  28985. } else {
  28986. order := &models.HisOrder{
  28987. UserOrgId: adminUser.CurrentOrgId,
  28988. HisPatientId: his.ID,
  28989. PatientId: his.PatientId,
  28990. SettleAccountsDate: recordDateTime,
  28991. Ctime: time.Now().Unix(),
  28992. Mtime: time.Now().Unix(),
  28993. MdtrtId: his.Number,
  28994. PsnNo: his.PsnNo,
  28995. MedType: strconv.FormatInt(reg_type, 10),
  28996. Status: 1,
  28997. Number: chrg_bchno,
  28998. Infcode: res.Infcode,
  28999. WarnMsg: res.WarnMsg,
  29000. Cainfo: res.Cainfo,
  29001. ErrMsg: res.ErrMsg,
  29002. RespondTime: res.RefmsgTime,
  29003. InfRefmsgid: res.InfRefmsgid,
  29004. OrderStatus: 1,
  29005. IsMedicineInsurance: 1,
  29006. SettleType: settle_accounts_type,
  29007. SettleStartTime: start_time,
  29008. SettleEndTime: end_time,
  29009. Creator: roles.AdminUserId,
  29010. Modify: roles.AdminUserId,
  29011. PType: 2,
  29012. Diagnosis: diagnosis_id,
  29013. }
  29014. err = service.CreateOrder(order)
  29015. if err != nil {
  29016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29017. return
  29018. }
  29019. c.ServeSuccessJSON(map[string]interface{}{
  29020. "failed_code": -10,
  29021. "msg": res2.ErrMsg,
  29022. })
  29023. return
  29024. }
  29025. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29026. 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)
  29027. var dat map[string]interface{}
  29028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29029. fmt.Println(dat)
  29030. } else {
  29031. fmt.Println(err)
  29032. }
  29033. saveLog(result, request_log, "2204", "上传费用明细")
  29034. userJSONBytes, _ := json.Marshal(dat)
  29035. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29036. utils.ErrorLog("解析失败:%v", err)
  29037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29038. return
  29039. }
  29040. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29041. 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, "", "")
  29042. var dat map[string]interface{}
  29043. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29044. fmt.Println(dat)
  29045. } else {
  29046. fmt.Println(err)
  29047. }
  29048. saveLog(result, request_log, "2204", "上传费用明细")
  29049. userJSONBytes, _ := json.Marshal(dat)
  29050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29051. utils.ErrorLog("解析失败:%v", err)
  29052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29053. return
  29054. }
  29055. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29056. 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, "", "")
  29057. var dat map[string]interface{}
  29058. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29059. fmt.Println(dat)
  29060. } else {
  29061. fmt.Println(err)
  29062. }
  29063. saveLog(result, request_log, "2204", "上传费用明细")
  29064. userJSONBytes, _ := json.Marshal(dat)
  29065. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29066. utils.ErrorLog("解析失败:%v", err)
  29067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29068. return
  29069. }
  29070. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29071. bytesData, _ := json.Marshal(data)
  29072. var req *http.Request
  29073. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29074. resp, _ := client.Do(req)
  29075. defer resp.Body.Close()
  29076. body, ioErr := ioutil.ReadAll(resp.Body)
  29077. if ioErr != nil {
  29078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29080. return
  29081. }
  29082. var respJSON map[string]interface{}
  29083. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29086. return
  29087. }
  29088. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29089. if status == "0" {
  29090. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29091. c.ServeSuccessJSON(map[string]interface{}{
  29092. "failed_code": -10,
  29093. "msg": err_msg,
  29094. })
  29095. return
  29096. }
  29097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29098. userJSONBytes, _ := json.Marshal(respJSON)
  29099. fmt.Println("log")
  29100. fmt.Println(string(userJSONBytes))
  29101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29102. utils.ErrorLog("解析失败:%v", err)
  29103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29104. return
  29105. }
  29106. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29107. bytesData, _ := json.Marshal(data)
  29108. var req *http.Request
  29109. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29110. resp, _ := client.Do(req)
  29111. defer resp.Body.Close()
  29112. body, ioErr := ioutil.ReadAll(resp.Body)
  29113. if ioErr != nil {
  29114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29116. return
  29117. }
  29118. var respJSON map[string]interface{}
  29119. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29122. return
  29123. }
  29124. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29125. if status == "0" {
  29126. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29127. c.ServeSuccessJSON(map[string]interface{}{
  29128. "failed_code": -10,
  29129. "msg": err_msg,
  29130. })
  29131. return
  29132. }
  29133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29134. userJSONBytes, _ := json.Marshal(respJSON)
  29135. fmt.Println("log")
  29136. fmt.Println(string(userJSONBytes))
  29137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29138. utils.ErrorLog("解析失败:%v", err)
  29139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29140. return
  29141. }
  29142. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29143. 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, "", "")
  29144. var dat map[string]interface{}
  29145. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29146. fmt.Println(dat)
  29147. } else {
  29148. fmt.Println(err)
  29149. }
  29150. saveLog(result, request_log, "2204", "上传费用明细")
  29151. userJSONBytes, _ := json.Marshal(dat)
  29152. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29153. utils.ErrorLog("解析失败:%v", err)
  29154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29155. return
  29156. }
  29157. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29158. bytesData, _ := json.Marshal(data)
  29159. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29160. resp, _ := client.Do(req)
  29161. defer resp.Body.Close()
  29162. body, ioErr := ioutil.ReadAll(resp.Body)
  29163. if ioErr != nil {
  29164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29166. return
  29167. }
  29168. var respJSON map[string]interface{}
  29169. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29172. return
  29173. }
  29174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29175. userJSONBytes, _ := json.Marshal(respJSON)
  29176. fmt.Println("log")
  29177. fmt.Println(string(userJSONBytes))
  29178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29179. utils.ErrorLog("解析失败:%v", err)
  29180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29181. return
  29182. }
  29183. } else {
  29184. if miConfig.MdtrtareaAdmvs == "441202" {
  29185. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29186. if result3101.Infcode == 0 {
  29187. if len(result3101.Output.Result) > 0 {
  29188. var errMsgs []string
  29189. for _, item := range result3101.Output.Result {
  29190. errMsgs = append(errMsgs, item.VolaCont)
  29191. }
  29192. c.ServeSuccessJSON(map[string]interface{}{
  29193. "failed_code": -10,
  29194. "msg": errMsgs,
  29195. })
  29196. return
  29197. } else {
  29198. 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)
  29199. var dat map[string]interface{}
  29200. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29201. fmt.Println(dat)
  29202. } else {
  29203. fmt.Println(err)
  29204. }
  29205. saveLog(result, request_log, "2204", "上传费用明细")
  29206. userJSONBytes, _ := json.Marshal(dat)
  29207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29208. utils.ErrorLog("解析失败:%v", err)
  29209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29210. return
  29211. }
  29212. }
  29213. } else {
  29214. c.ServeSuccessJSON(map[string]interface{}{
  29215. "failed_code": -10,
  29216. "msg": result3101.ErrMsg,
  29217. })
  29218. return
  29219. }
  29220. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29221. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29222. if result3101.Infcode == 0 {
  29223. if len(result3101.Output.Result) > 0 {
  29224. var errMsgs []string
  29225. for _, item := range result3101.Output.Result {
  29226. errMsgs = append(errMsgs, item.VolaCont)
  29227. }
  29228. c.ServeSuccessJSON(map[string]interface{}{
  29229. "failed_code": -10,
  29230. "msg": errMsgs,
  29231. })
  29232. return
  29233. } else {
  29234. 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)
  29235. var dat map[string]interface{}
  29236. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29237. fmt.Println(dat)
  29238. } else {
  29239. fmt.Println(err)
  29240. }
  29241. saveLog(result, request_log, "2204", "上传费用明细")
  29242. userJSONBytes, _ := json.Marshal(dat)
  29243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29244. utils.ErrorLog("解析失败:%v", err)
  29245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29246. return
  29247. }
  29248. }
  29249. } else {
  29250. c.ServeSuccessJSON(map[string]interface{}{
  29251. "failed_code": -10,
  29252. "msg": result3101.ErrMsg,
  29253. })
  29254. return
  29255. }
  29256. } else {
  29257. if miConfig.Code == "H15049901371" {
  29258. 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)
  29259. var dat map[string]interface{}
  29260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29261. fmt.Println(dat)
  29262. } else {
  29263. fmt.Println(err)
  29264. }
  29265. saveLog(result, request_log, "2204", "上传费用明细")
  29266. userJSONBytes, _ := json.Marshal(dat)
  29267. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29268. utils.ErrorLog("解析失败:%v", err)
  29269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29270. return
  29271. }
  29272. res.InfRefmsgid = resFour10265.InfRefmsgid
  29273. res.Output = resFour10265.Output
  29274. res.ErrMsg = resFour10265.ErrMsg
  29275. res.Cainfo = resFour10265.Cainfo
  29276. res.WarnMsg = resFour10265.WarnMsg
  29277. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29278. res.Infcode = infocode
  29279. } else {
  29280. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" {
  29281. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29282. if result3101.Infcode == 0 {
  29283. if len(result3101.Output.Result) > 0 {
  29284. var errMsgs []string
  29285. for _, item := range result3101.Output.Result {
  29286. errMsgs = append(errMsgs, item.VolaCont)
  29287. }
  29288. c.ServeSuccessJSON(map[string]interface{}{
  29289. "failed_code": -10,
  29290. "msg": errMsgs,
  29291. })
  29292. return
  29293. } else {
  29294. 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)
  29295. var dat map[string]interface{}
  29296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29297. fmt.Println(dat)
  29298. } else {
  29299. fmt.Println(err)
  29300. }
  29301. saveLog(result, request_log, "2204", "上传费用明细")
  29302. userJSONBytes, _ := json.Marshal(dat)
  29303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29304. utils.ErrorLog("解析失败:%v", err)
  29305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29306. return
  29307. }
  29308. }
  29309. } else {
  29310. c.ServeSuccessJSON(map[string]interface{}{
  29311. "failed_code": -10,
  29312. "msg": result3101.ErrMsg,
  29313. })
  29314. return
  29315. }
  29316. } else {
  29317. 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)
  29318. var dat map[string]interface{}
  29319. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29320. fmt.Println(dat)
  29321. } else {
  29322. fmt.Println(err)
  29323. }
  29324. saveLog(result, request_log, "2204", "上传费用明细")
  29325. userJSONBytes, _ := json.Marshal(dat)
  29326. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29327. utils.ErrorLog("解析失败:%v", err)
  29328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29329. return
  29330. }
  29331. }
  29332. }
  29333. }
  29334. }
  29335. var total_two float64
  29336. if res.Infcode == -1 {
  29337. errlog := &models.HisOrderError{
  29338. UserOrgId: adminUser.CurrentOrgId,
  29339. Ctime: time.Now().Unix(),
  29340. Mtime: time.Now().Unix(),
  29341. Number: chrg_bchno,
  29342. ErrMsg: res.ErrMsg,
  29343. Status: 1,
  29344. PatientId: id,
  29345. RecordTime: recordDateTime,
  29346. Stage: 4,
  29347. }
  29348. service.CreateErrMsgLog(errlog)
  29349. c.ServeSuccessJSON(map[string]interface{}{
  29350. "failed_code": -10,
  29351. "msg": res.ErrMsg,
  29352. })
  29353. return
  29354. }
  29355. if res.Infcode == 0 {
  29356. order := &models.HisOrder{
  29357. UserOrgId: adminUser.CurrentOrgId,
  29358. HisPatientId: his.ID,
  29359. PatientId: his.PatientId,
  29360. SettleAccountsDate: recordDateTime,
  29361. Ctime: time.Now().Unix(),
  29362. Mtime: time.Now().Unix(),
  29363. MdtrtId: his.Number,
  29364. PsnNo: his.PsnNo,
  29365. MedType: strconv.FormatInt(reg_type, 10),
  29366. Status: 1,
  29367. Number: chrg_bchno,
  29368. Infcode: res.Infcode,
  29369. WarnMsg: res.WarnMsg,
  29370. Cainfo: res.Cainfo,
  29371. ErrMsg: res.ErrMsg,
  29372. RespondTime: res.RefmsgTime,
  29373. InfRefmsgid: res.InfRefmsgid,
  29374. OrderStatus: 1,
  29375. IsMedicineInsurance: 1,
  29376. SettleType: settle_accounts_type,
  29377. SettleStartTime: start_time,
  29378. SettleEndTime: end_time,
  29379. Creator: roles.AdminUserId,
  29380. Modify: roles.AdminUserId,
  29381. PType: 2,
  29382. Diagnosis: diagnosis_id,
  29383. }
  29384. err = service.CreateOrder(order)
  29385. if err != nil {
  29386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29387. return
  29388. }
  29389. for _, item := range res.Output.Result {
  29390. temp := strings.Split(item.FeedetlSn, "-")
  29391. var advice_id int64 = 0
  29392. var project_id int64 = 0
  29393. var types int64 = 0
  29394. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29395. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29396. if temp[1] == "1" {
  29397. advice_id = id
  29398. project_id = 0
  29399. } else if temp[1] == "2" {
  29400. advice_id = 0
  29401. project_id = id
  29402. }
  29403. total_two = total_two + item.DetItemFeeSumamt
  29404. info := &models.HisOrderInfo{
  29405. OrderNumber: order.Number,
  29406. FeedetlSn: item.FeedetlSn,
  29407. UploadDate: time.Now().Unix(),
  29408. AdviceId: advice_id,
  29409. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29410. Cnt: item.Cnt,
  29411. Pric: float64(item.Pric),
  29412. PatientId: his.PatientId,
  29413. PricUplmtAmt: item.PricUplmtAmt,
  29414. SelfpayProp: item.SelfpayProp,
  29415. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29416. OverlmtAmt: item.OverlmtAmt,
  29417. PreselfpayAmt: item.PreselfpayAmt,
  29418. BasMednFlag: item.BasMednFlag,
  29419. MedChrgitmType: item.MedChrgitmType,
  29420. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29421. Status: 1,
  29422. Memo: item.Memo,
  29423. Mtime: time.Now().Unix(),
  29424. InscpScpAmt: item.InscpScpAmt,
  29425. DrtReimFlag: item.DrtReimFlag,
  29426. Ctime: time.Now().Unix(),
  29427. ListSpItemFlag: item.ListSpItemFlag,
  29428. ChldMedcFlag: item.ChldMedcFlag,
  29429. LmtUsedFlag: item.LmtUsedFlag,
  29430. ChrgitmLv: item.ChrgitmLv,
  29431. UserOrgId: adminUser.CurrentOrgId,
  29432. HisPatientId: his.ID,
  29433. OrderId: order.ID,
  29434. ProjectId: project_id,
  29435. Type: types,
  29436. }
  29437. service.CreateOrderInfo(info)
  29438. }
  29439. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29440. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29441. var total float64
  29442. for _, item := range prescriptions {
  29443. if item.Type == 1 { //药品
  29444. for _, subItem := range item.HisDoctorAdviceInfo {
  29445. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29446. total_one := price * subItem.PrescribingNumber
  29447. fmt.Println("subItem")
  29448. fmt.Println(subItem.Price)
  29449. fmt.Println("price")
  29450. fmt.Println(price)
  29451. fmt.Println("total_one")
  29452. fmt.Println(total_one)
  29453. total = total + total_one
  29454. fmt.Println(total)
  29455. }
  29456. }
  29457. if item.Type == 2 { //项目
  29458. for _, subItem := range item.HisPrescriptionProject {
  29459. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29460. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29461. total_one := price * cnt
  29462. total = total + total_one
  29463. }
  29464. }
  29465. }
  29466. allTotal := fmt.Sprintf("%.2f", total)
  29467. if res.Infcode == 0 {
  29468. var rf []*ResultFive
  29469. json.Unmarshal([]byte(his.Iinfo), &rf)
  29470. chrg_bchno := chrg_bchno
  29471. cert_no := his.Certno
  29472. var insutypes []string
  29473. var insutype string
  29474. var is390 int = 0
  29475. var is310 int = 0
  29476. for _, item := range rf {
  29477. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29478. insutypes = append(insutypes, item.Insutype)
  29479. }
  29480. }
  29481. if len(insutypes) == 1 {
  29482. insutype = insutypes[0]
  29483. } else {
  29484. for _, i := range insutypes {
  29485. if i == "390" {
  29486. is390 = 1
  29487. }
  29488. if i == "310" {
  29489. is310 = 1
  29490. }
  29491. }
  29492. }
  29493. if is390 == 1 {
  29494. insutype = "390"
  29495. }
  29496. if is310 == 1 {
  29497. insutype = "310"
  29498. }
  29499. if len(insutypes) == 0 {
  29500. insutype = "390"
  29501. }
  29502. if len(insutypes) == 2 {
  29503. insutype = strconv.FormatInt(his.SocialType, 10)
  29504. }
  29505. //insutype = "390"
  29506. if his.IdCardType == 1 {
  29507. cert_no = his.MedicalInsuranceNumber
  29508. } else {
  29509. cert_no = his.Certno
  29510. }
  29511. var res ResultSeven
  29512. var ahres ResultSevenAH
  29513. var resSeven10265 ResultSeven10265
  29514. var resSeven10265Two ResultSeven10265Two
  29515. var gzresSeven10265Two GZResultSeven10265Two
  29516. if miConfig.MdtrtareaAdmvs == "421300" {
  29517. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29518. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29519. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29520. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29521. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29522. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29523. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29524. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29525. resp, requestErr := http.Get(api)
  29526. if requestErr != nil {
  29527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29528. return
  29529. }
  29530. body, ioErr := ioutil.ReadAll(resp.Body)
  29531. if ioErr != nil {
  29532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29534. return
  29535. }
  29536. var respJSON map[string]interface{}
  29537. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29540. return
  29541. }
  29542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29543. result, _ := json.Marshal(respJSON)
  29544. fmt.Println("log")
  29545. fmt.Println(string(result))
  29546. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29547. utils.ErrorLog("解析失败:%v", err)
  29548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29549. return
  29550. }
  29551. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29552. if reg_type == 11 && his.Insutype == "390" {
  29553. reg_type = 110104
  29554. }
  29555. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29556. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29557. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29558. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29559. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29560. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29561. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29562. resp, requestErr := http.Get(api)
  29563. if requestErr != nil {
  29564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29565. return
  29566. }
  29567. body, ioErr := ioutil.ReadAll(resp.Body)
  29568. if ioErr != nil {
  29569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29571. return
  29572. }
  29573. var respJSON map[string]interface{}
  29574. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29577. return
  29578. }
  29579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29580. result, _ := json.Marshal(respJSON)
  29581. fmt.Println("log")
  29582. fmt.Println(string(result))
  29583. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29584. utils.ErrorLog("解析失败:%v", err)
  29585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29586. return
  29587. }
  29588. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29589. if reg_type == 11 && his.Insutype == "390" {
  29590. reg_type = 110104
  29591. }
  29592. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29593. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29594. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29595. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29596. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29597. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29598. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29599. resp, requestErr := http.Get(api)
  29600. if requestErr != nil {
  29601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29602. return
  29603. }
  29604. body, ioErr := ioutil.ReadAll(resp.Body)
  29605. if ioErr != nil {
  29606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29608. return
  29609. }
  29610. var respJSON map[string]interface{}
  29611. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29614. return
  29615. }
  29616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29617. result, _ := json.Marshal(respJSON)
  29618. fmt.Println("log")
  29619. fmt.Println(string(result))
  29620. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29621. utils.ErrorLog("解析失败:%v", err)
  29622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29623. return
  29624. }
  29625. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29626. if reg_type == 11 && his.Insutype == "390" {
  29627. reg_type = 110104
  29628. }
  29629. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29630. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29631. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29632. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29633. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29634. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29635. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29636. resp, requestErr := http.Get(api)
  29637. if requestErr != nil {
  29638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29639. return
  29640. }
  29641. body, ioErr := ioutil.ReadAll(resp.Body)
  29642. if ioErr != nil {
  29643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29645. return
  29646. }
  29647. var respJSON map[string]interface{}
  29648. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29651. return
  29652. }
  29653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29654. result, _ := json.Marshal(respJSON)
  29655. fmt.Println("log")
  29656. fmt.Println(string(result))
  29657. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29658. utils.ErrorLog("解析失败:%v", err)
  29659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29660. return
  29661. }
  29662. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29663. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29664. if result3101.Infcode == "0" {
  29665. if len(result3101.Output.Result) > 0 {
  29666. var errMsgs []string
  29667. for _, item := range result3101.Output.Result {
  29668. errMsgs = append(errMsgs, item.VolaCont)
  29669. }
  29670. c.ServeSuccessJSON(map[string]interface{}{
  29671. "failed_code": -10,
  29672. "msg": errMsgs,
  29673. })
  29674. return
  29675. } else {
  29676. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29677. if his.IdCardType != 4 {
  29678. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29679. bas := strings.Split(psn_info.CardInfo, "|")
  29680. if his.IdCardType == 1 {
  29681. cert_no = bas[2]
  29682. } else {
  29683. cert_no = bas[1]
  29684. }
  29685. } else {
  29686. cert_no = his.Certno
  29687. }
  29688. //江苏地区国家医保医疗类别
  29689. //职工透析:医疗类别选特殊情况门诊9933
  29690. //居民血透门慢: 医疗类别选门诊慢病1402
  29691. //var med_type string
  29692. //if his.Insutype == "310" {
  29693. // if reg_type == 14 {
  29694. // med_type = "9933"
  29695. // } else if reg_type == 11 {
  29696. // med_type = "11"
  29697. //
  29698. // }
  29699. //} else if his.Insutype == "390" {
  29700. // if reg_type == 14 {
  29701. // med_type = "1402"
  29702. // } else if reg_type == 11 {
  29703. // med_type = "11"
  29704. // }
  29705. //}
  29706. var api string
  29707. if miConfig.MdtrtareaAdmvs == "320921" {
  29708. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29709. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29710. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29711. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29712. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29713. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29714. "&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
  29715. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29716. } else {
  29717. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29718. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29719. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29720. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29721. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29722. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29723. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29724. "&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
  29725. }
  29726. resp, requestErr := http.Get(api)
  29727. if requestErr != nil {
  29728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29729. return
  29730. }
  29731. body, ioErr := ioutil.ReadAll(resp.Body)
  29732. if ioErr != nil {
  29733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29735. return
  29736. }
  29737. var respJSON map[string]interface{}
  29738. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29741. return
  29742. }
  29743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29744. result, _ := json.Marshal(respJSON)
  29745. fmt.Println("log")
  29746. fmt.Println(string(result))
  29747. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29748. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29749. utils.ErrorLog("解析失败:%v", err)
  29750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29751. return
  29752. }
  29753. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29754. res.Output = resSeven10265.Output
  29755. res.ErrMsg = resSeven10265.ErrMsg
  29756. res.Cainfo = resSeven10265.Cainfo
  29757. res.WarnMsg = resSeven10265.WarnMsg
  29758. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29759. res.Infcode = infocode
  29760. } else {
  29761. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29762. utils.ErrorLog("解析失败:%v", err)
  29763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29764. return
  29765. }
  29766. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29767. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29768. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29769. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29770. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29771. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29772. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29773. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29774. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29775. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29776. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29777. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29778. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29779. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29780. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29781. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29782. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29783. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29784. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29785. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29786. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29787. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29788. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29789. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29790. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29791. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29792. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29793. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29794. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29795. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29796. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29797. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29798. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29799. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29800. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29801. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29802. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29803. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29804. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29805. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29806. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29807. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29808. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29809. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29810. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29811. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29812. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29813. res.ErrMsg = resSeven10265Two.ErrMsg
  29814. res.Cainfo = resSeven10265Two.Cainfo
  29815. res.WarnMsg = resSeven10265Two.WarnMsg
  29816. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29817. res.Infcode = infocode
  29818. }
  29819. }
  29820. }
  29821. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29822. psn_info, _ := service.GetPsnByPatientId(id)
  29823. var verify_number string
  29824. if psn_info.IdCardType == 4 {
  29825. verify_number = psn_info.VerifyNumber
  29826. } else if psn_info.IdCardType == 1 {
  29827. bas := strings.Split(psn_info.CardInfo, "|")
  29828. cardNumber := bas[2]
  29829. verify_number = cardNumber
  29830. } else {
  29831. psn_info.IdCardType = 2
  29832. verify_number = psn_info.Certno
  29833. }
  29834. var api string
  29835. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29836. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  29837. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29838. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29839. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29840. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29841. "&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
  29842. resp, requestErr := http.Get(api)
  29843. if requestErr != nil {
  29844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29845. return
  29846. }
  29847. body, ioErr := ioutil.ReadAll(resp.Body)
  29848. if ioErr != nil {
  29849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29851. return
  29852. }
  29853. var respJSON map[string]interface{}
  29854. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29857. return
  29858. }
  29859. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29860. result, _ := json.Marshal(respJSON)
  29861. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29862. utils.ErrorLog("解析失败:%v", err)
  29863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29864. return
  29865. }
  29866. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29867. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  29868. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  29869. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29870. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  29871. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  29872. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  29873. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  29874. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  29875. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  29876. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  29877. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  29878. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  29879. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29880. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  29881. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  29882. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  29883. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  29884. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  29885. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  29886. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29887. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  29888. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  29889. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  29890. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  29891. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  29892. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  29893. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  29894. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  29895. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  29896. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  29897. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  29898. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  29899. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  29900. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29901. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  29902. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  29903. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  29904. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  29905. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  29906. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  29907. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  29908. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  29909. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  29910. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  29911. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  29912. res.ErrMsg = resSeven10265.ErrMsg
  29913. res.Cainfo = resSeven10265.Cainfo
  29914. res.WarnMsg = resSeven10265.WarnMsg
  29915. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29916. res.Infcode = infocode
  29917. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29918. acct_used_flag := "1"
  29919. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  29920. var result string
  29921. var request_log string
  29922. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  29923. 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)
  29924. } else {
  29925. 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)
  29926. }
  29927. var dat map[string]interface{}
  29928. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29929. fmt.Println(dat)
  29930. } else {
  29931. fmt.Println(err)
  29932. }
  29933. saveLog(result, request_log, "2206", "预结算")
  29934. userJSONBytes, _ := json.Marshal(dat)
  29935. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29936. utils.ErrorLog("解析失败:%v", err)
  29937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29938. return
  29939. }
  29940. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29941. var result string
  29942. var request_log string
  29943. if his.IdCardType == 2 {
  29944. 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, "")
  29945. } else if his.IdCardType == 1 {
  29946. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29947. bas := strings.Split(psn_info.CardInfo, "|")
  29948. basNumber := bas[2]
  29949. card_sn := bas[3]
  29950. var rf []*ResultFive
  29951. json.Unmarshal([]byte(his.Iinfo), &rf)
  29952. var psn_type string
  29953. for _, item := range rf {
  29954. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29955. psn_type = item.PsnType
  29956. }
  29957. }
  29958. 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)
  29959. } else {
  29960. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29961. //bas := strings.Split(psn_info.CardInfo, "|")
  29962. //basNumber := bas[2]
  29963. //card_sn := bas[3]
  29964. var rf []*ResultFive
  29965. json.Unmarshal([]byte(his.Iinfo), &rf)
  29966. var psn_type string
  29967. for _, item := range rf {
  29968. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29969. psn_type = item.PsnType
  29970. }
  29971. }
  29972. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29973. 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)
  29974. }
  29975. var dat map[string]interface{}
  29976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29977. fmt.Println(dat)
  29978. } else {
  29979. fmt.Println(err)
  29980. }
  29981. saveLog(result, request_log, "2206", "预结算")
  29982. userJSONBytes, _ := json.Marshal(dat)
  29983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29984. utils.ErrorLog("解析失败:%v", err)
  29985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29986. return
  29987. }
  29988. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29989. var result string
  29990. var request_log string
  29991. if his.IdCardType == 2 {
  29992. 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, "")
  29993. } else if his.IdCardType == 1 {
  29994. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29995. bas := strings.Split(psn_info.CardInfo, "|")
  29996. basNumber := bas[0]
  29997. card_sn := ""
  29998. var rf []*ResultFive
  29999. json.Unmarshal([]byte(his.Iinfo), &rf)
  30000. var psn_type string
  30001. for _, item := range rf {
  30002. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30003. psn_type = item.PsnType
  30004. }
  30005. }
  30006. 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)
  30007. } else {
  30008. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30009. //bas := strings.Split(psn_info.CardInfo, "|")
  30010. //basNumber := bas[2]
  30011. //card_sn := bas[3]
  30012. var rf []*ResultFive
  30013. json.Unmarshal([]byte(his.Iinfo), &rf)
  30014. var psn_type string
  30015. for _, item := range rf {
  30016. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30017. psn_type = item.PsnType
  30018. }
  30019. }
  30020. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30021. 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)
  30022. }
  30023. var dat map[string]interface{}
  30024. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30025. fmt.Println(dat)
  30026. } else {
  30027. fmt.Println(err)
  30028. }
  30029. saveLog(result, request_log, "2206", "预结算")
  30030. userJSONBytes, _ := json.Marshal(dat)
  30031. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30032. utils.ErrorLog("解析失败:%v", err)
  30033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30034. return
  30035. }
  30036. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30037. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30038. if his.IdCardType == 4 {
  30039. psn_info.VerifyNumber = psn_info.VerifyNumber
  30040. cert_no = psn_info.VerifyNumber
  30041. } else if his.IdCardType == 2 {
  30042. cert_no = psn_info.Certno
  30043. psn_info.VerifyNumber = psn_info.Certno
  30044. } else {
  30045. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30046. bas := strings.Split(psn_info.CardInfo, "|")
  30047. if his.IdCardType == 1 {
  30048. cert_no = bas[2]
  30049. } else {
  30050. cert_no = bas[1]
  30051. }
  30052. }
  30053. var api string
  30054. var med_type string
  30055. if his.Insutype == "390" {
  30056. if reg_type == 992102 {
  30057. med_type = "992102"
  30058. }
  30059. if reg_type == 140104 {
  30060. med_type = "140104"
  30061. }
  30062. if reg_type == 140201 {
  30063. med_type = "140201"
  30064. }
  30065. if reg_type == 14 {
  30066. med_type = "140104"
  30067. }
  30068. } else if his.Insutype == "310" {
  30069. if reg_type == 992102 {
  30070. med_type = "992102"
  30071. }
  30072. if reg_type == 140104 {
  30073. med_type = "140104"
  30074. }
  30075. if reg_type == 140201 {
  30076. med_type = "140201"
  30077. }
  30078. if reg_type == 14 {
  30079. med_type = "140104"
  30080. }
  30081. }
  30082. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30083. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30084. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30085. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30086. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30087. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30088. "&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
  30089. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30090. resp, requestErr := http.Get(api)
  30091. if requestErr != nil {
  30092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30093. return
  30094. }
  30095. body, ioErr := ioutil.ReadAll(resp.Body)
  30096. if ioErr != nil {
  30097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30099. return
  30100. }
  30101. var respJSON map[string]interface{}
  30102. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30105. return
  30106. }
  30107. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30108. if status == "0" {
  30109. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30110. c.ServeSuccessJSON(map[string]interface{}{
  30111. "failed_code": -10,
  30112. "msg": err_msg,
  30113. })
  30114. return
  30115. }
  30116. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30117. result, _ := json.Marshal(respJSON)
  30118. fmt.Println("log")
  30119. fmt.Println(string(result))
  30120. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30121. utils.ErrorLog("解析失败:%v", err)
  30122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30123. return
  30124. }
  30125. res.InfRefmsgid = ahres.InfRefmsgid
  30126. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30127. // 创建对应的Time类型
  30128. t := time.UnixMilli(timestamp)
  30129. // 格式化成指定的日期字符串
  30130. str := t.Format("2006-01-02 15:04:05")
  30131. res.Output.Setlinfo.SetlTime = str
  30132. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30133. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30134. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30135. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30136. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30137. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30138. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30139. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30140. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30141. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30142. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30143. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30144. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30145. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30146. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30147. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30148. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30149. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30150. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30151. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30152. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30153. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30154. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30155. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30156. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30157. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30158. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30159. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30160. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30161. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30162. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30163. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30164. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30165. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30166. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30167. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30168. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30169. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30170. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30171. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30172. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30173. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30174. //res.Output.Setldetail = ahres.Output.Setldetail
  30175. res.ErrMsg = ahres.ErrMsg
  30176. res.Cainfo = ahres.Cainfo
  30177. res.WarnMsg = ahres.WarnMsg
  30178. res.Infcode = ahres.Infcode
  30179. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30180. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30181. if his.IdCardType == 4 {
  30182. psn_info.VerifyNumber = psn_info.VerifyNumber
  30183. cert_no = psn_info.Certno
  30184. } else if his.IdCardType == 2 {
  30185. cert_no = psn_info.Certno
  30186. psn_info.VerifyNumber = psn_info.Certno
  30187. } else {
  30188. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30189. bas := strings.Split(psn_info.CardInfo, "|")
  30190. if his.IdCardType == 1 {
  30191. cert_no = bas[2]
  30192. } else {
  30193. cert_no = bas[1]
  30194. }
  30195. }
  30196. var api string
  30197. var med_type string
  30198. if his.Insutype == "390" {
  30199. if reg_type == 992102 {
  30200. med_type = "992102"
  30201. }
  30202. if reg_type == 140104 {
  30203. med_type = "140104"
  30204. }
  30205. if reg_type == 140201 {
  30206. med_type = "140201"
  30207. }
  30208. if reg_type == 14 {
  30209. med_type = "14"
  30210. }
  30211. } else if his.Insutype == "310" {
  30212. if reg_type == 992102 {
  30213. med_type = "992102"
  30214. }
  30215. if reg_type == 140104 {
  30216. med_type = "140104"
  30217. }
  30218. if reg_type == 140201 {
  30219. med_type = "140201"
  30220. }
  30221. if reg_type == 14 {
  30222. med_type = "14"
  30223. }
  30224. }
  30225. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30226. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30227. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30228. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30229. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30230. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30231. "&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
  30232. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30233. resp, requestErr := http.Get(api)
  30234. if requestErr != nil {
  30235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30236. return
  30237. }
  30238. body, ioErr := ioutil.ReadAll(resp.Body)
  30239. if ioErr != nil {
  30240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30242. return
  30243. }
  30244. var respJSON map[string]interface{}
  30245. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30248. return
  30249. }
  30250. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30251. if status == "0" {
  30252. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30253. c.ServeSuccessJSON(map[string]interface{}{
  30254. "failed_code": -10,
  30255. "msg": err_msg,
  30256. })
  30257. return
  30258. }
  30259. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30260. result, _ := json.Marshal(respJSON)
  30261. fmt.Println("log")
  30262. fmt.Println(string(result))
  30263. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30264. utils.ErrorLog("解析失败:%v", err)
  30265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30266. return
  30267. }
  30268. res.InfRefmsgid = ahres.InfRefmsgid
  30269. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30270. // 创建对应的Time类型
  30271. t := time.UnixMilli(timestamp)
  30272. // 格式化成指定的日期字符串
  30273. str := t.Format("2006-01-02 15:04:05")
  30274. res.Output.Setlinfo.SetlTime = str
  30275. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30276. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30277. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30278. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30279. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30280. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30281. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30282. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30283. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30284. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30285. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30286. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30287. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30288. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30289. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30290. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30291. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30292. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30293. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30294. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30295. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30296. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30297. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30298. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30299. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30300. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30301. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30302. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30303. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30304. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30305. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30306. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30307. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30308. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30309. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30310. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30311. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30312. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30313. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30314. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30315. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30316. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30317. //res.Output.Setldetail = ahres.Output.Setldetail
  30318. res.ErrMsg = ahres.ErrMsg
  30319. res.Cainfo = ahres.Cainfo
  30320. res.WarnMsg = ahres.WarnMsg
  30321. res.Infcode = ahres.Infcode
  30322. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30323. var result string
  30324. var request_log string
  30325. if his.IdCardType == 2 {
  30326. 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")
  30327. } else if his.IdCardType == 1 {
  30328. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30329. bas := strings.Split(psn_info.CardInfo, "|")
  30330. basNumber := bas[2]
  30331. card_sn := bas[3]
  30332. 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")
  30333. } else {
  30334. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30335. 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")
  30336. }
  30337. var dat map[string]interface{}
  30338. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30339. fmt.Println(dat)
  30340. } else {
  30341. fmt.Println(err)
  30342. }
  30343. saveLog(result, request_log, "2206", "预结算")
  30344. userJSONBytes, _ := json.Marshal(dat)
  30345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30346. utils.ErrorLog("解析失败:%v", err)
  30347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30348. return
  30349. }
  30350. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30351. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30352. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30353. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30354. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30355. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30356. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30357. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30358. resp, requestErr := http.Get(api)
  30359. if requestErr != nil {
  30360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30361. return
  30362. }
  30363. body, ioErr := ioutil.ReadAll(resp.Body)
  30364. if ioErr != nil {
  30365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30367. return
  30368. }
  30369. var respJSON map[string]interface{}
  30370. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30373. return
  30374. }
  30375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30376. result, _ := json.Marshal(respJSON)
  30377. fmt.Println("log")
  30378. fmt.Println(string(result))
  30379. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30380. utils.ErrorLog("解析失败:%v", err)
  30381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30382. return
  30383. }
  30384. } else {
  30385. if miConfig.MdtrtareaAdmvs == "441202" {
  30386. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30387. if result3101.Infcode == 0 {
  30388. if len(result3101.Output.Result) > 0 {
  30389. var errMsgs []string
  30390. for _, item := range result3101.Output.Result {
  30391. errMsgs = append(errMsgs, item.VolaCont)
  30392. }
  30393. c.ServeSuccessJSON(map[string]interface{}{
  30394. "failed_code": -10,
  30395. "msg": errMsgs,
  30396. })
  30397. return
  30398. } else {
  30399. var result string
  30400. var request_log string
  30401. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30402. allTotal = fmt.Sprintf("%.2f", total_two)
  30403. if his.IdCardType == 4 {
  30404. 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)
  30405. } else {
  30406. 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)
  30407. }
  30408. var dat map[string]interface{}
  30409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30410. fmt.Println(dat)
  30411. } else {
  30412. fmt.Println(err)
  30413. }
  30414. saveLog(result, request_log, "2206", "预结算")
  30415. //userJSONBytes, _ := json.Marshal(dat)
  30416. //
  30417. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30418. // utils.ErrorLog("解析失败:%v", err)
  30419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30420. // return
  30421. //}
  30422. userJSONBytes, _ := json.Marshal(dat)
  30423. if miConfig.Code == "H15049901371" {
  30424. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30425. utils.ErrorLog("解析失败:%v", err)
  30426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30427. return
  30428. }
  30429. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30430. res.Output = resSeven10265.Output
  30431. res.ErrMsg = resSeven10265.ErrMsg
  30432. res.Cainfo = resSeven10265.Cainfo
  30433. res.WarnMsg = resSeven10265.WarnMsg
  30434. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30435. res.Infcode = infocode
  30436. } else {
  30437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30438. utils.ErrorLog("解析失败:%v", err)
  30439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30440. return
  30441. }
  30442. }
  30443. }
  30444. } else {
  30445. c.ServeSuccessJSON(map[string]interface{}{
  30446. "failed_code": -10,
  30447. "msg": result3101.ErrMsg,
  30448. })
  30449. return
  30450. }
  30451. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30452. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30453. if result3101.Infcode == 0 {
  30454. if len(result3101.Output.Result) > 0 {
  30455. var errMsgs []string
  30456. for _, item := range result3101.Output.Result {
  30457. errMsgs = append(errMsgs, item.VolaCont)
  30458. }
  30459. c.ServeSuccessJSON(map[string]interface{}{
  30460. "failed_code": -10,
  30461. "msg": errMsgs,
  30462. })
  30463. return
  30464. } else {
  30465. var result string
  30466. var request_log string
  30467. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30468. allTotal = fmt.Sprintf("%.2f", total_two)
  30469. if his.IdCardType == 4 {
  30470. 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)
  30471. } else {
  30472. 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)
  30473. }
  30474. var dat map[string]interface{}
  30475. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30476. fmt.Println(dat)
  30477. } else {
  30478. fmt.Println(err)
  30479. }
  30480. saveLog(result, request_log, "2206", "预结算")
  30481. //userJSONBytes, _ := json.Marshal(dat)
  30482. //
  30483. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30484. // utils.ErrorLog("解析失败:%v", err)
  30485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30486. // return
  30487. //}
  30488. userJSONBytes, _ := json.Marshal(dat)
  30489. if miConfig.Code == "H15049901371" {
  30490. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30491. utils.ErrorLog("解析失败:%v", err)
  30492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30493. return
  30494. }
  30495. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30496. res.Output = resSeven10265.Output
  30497. res.ErrMsg = resSeven10265.ErrMsg
  30498. res.Cainfo = resSeven10265.Cainfo
  30499. res.WarnMsg = resSeven10265.WarnMsg
  30500. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30501. res.Infcode = infocode
  30502. } else {
  30503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30504. utils.ErrorLog("解析失败:%v", err)
  30505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30506. return
  30507. }
  30508. }
  30509. }
  30510. } else {
  30511. c.ServeSuccessJSON(map[string]interface{}{
  30512. "failed_code": -10,
  30513. "msg": result3101.ErrMsg,
  30514. })
  30515. return
  30516. }
  30517. } else {
  30518. var result string
  30519. var request_log string
  30520. var dat map[string]interface{}
  30521. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30522. allTotal = fmt.Sprintf("%.2f", total_two)
  30523. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  30524. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30525. if result3101.Infcode == 0 {
  30526. if len(result3101.Output.Result) > 0 {
  30527. var errMsgs []string
  30528. for _, item := range result3101.Output.Result {
  30529. errMsgs = append(errMsgs, item.VolaCont)
  30530. }
  30531. c.ServeSuccessJSON(map[string]interface{}{
  30532. "failed_code": -10,
  30533. "msg": errMsgs,
  30534. })
  30535. return
  30536. } else {
  30537. var result string
  30538. var request_log string
  30539. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30540. allTotal = fmt.Sprintf("%.2f", total_two)
  30541. if his.IdCardType == 4 {
  30542. 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)
  30543. } else {
  30544. 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)
  30545. }
  30546. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30547. fmt.Println(dat)
  30548. } else {
  30549. fmt.Println(err)
  30550. }
  30551. saveLog(result, request_log, "2206", "预结算")
  30552. }
  30553. } else {
  30554. c.ServeSuccessJSON(map[string]interface{}{
  30555. "failed_code": -10,
  30556. "msg": result3101.ErrMsg,
  30557. })
  30558. return
  30559. }
  30560. } else {
  30561. if his.IdCardType == 4 {
  30562. 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)
  30563. } else {
  30564. 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)
  30565. }
  30566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30567. fmt.Println(dat)
  30568. } else {
  30569. fmt.Println(err)
  30570. }
  30571. saveLog(result, request_log, "2206", "预结算")
  30572. }
  30573. //userJSONBytes, _ := json.Marshal(dat)
  30574. //
  30575. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30576. // utils.ErrorLog("解析失败:%v", err)
  30577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30578. // return
  30579. //}
  30580. userJSONBytes, _ := json.Marshal(dat)
  30581. if miConfig.Code == "H15049901371" {
  30582. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30583. utils.ErrorLog("解析失败:%v", err)
  30584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30585. return
  30586. }
  30587. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30588. res.Output = resSeven10265.Output
  30589. res.ErrMsg = resSeven10265.ErrMsg
  30590. res.Cainfo = resSeven10265.Cainfo
  30591. res.WarnMsg = resSeven10265.WarnMsg
  30592. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30593. res.Infcode = infocode
  30594. } else {
  30595. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30596. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30597. utils.ErrorLog("解析失败:%v", err)
  30598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30599. return
  30600. }
  30601. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30602. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30603. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30604. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30605. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30606. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30607. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30608. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30609. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30610. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30611. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30612. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30613. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30614. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30615. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30616. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30617. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30618. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30619. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30620. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30621. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30622. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30623. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30624. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30625. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30626. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30627. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30628. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30629. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30630. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30631. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30632. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30633. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30634. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30635. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30636. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30637. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30638. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30639. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30640. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30641. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30642. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30643. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30644. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30645. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30646. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30647. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30648. res.Cainfo = gzresSeven10265Two.Cainfo
  30649. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30650. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30651. //res.Infcode = infocode
  30652. } else {
  30653. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30654. utils.ErrorLog("解析失败:%v", err)
  30655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30656. return
  30657. }
  30658. }
  30659. }
  30660. }
  30661. }
  30662. utils.ErrorLog("解析失败:%v", res.Infcode)
  30663. if res.Infcode == -1 {
  30664. errlog := &models.HisOrderError{
  30665. UserOrgId: adminUser.CurrentOrgId,
  30666. Ctime: time.Now().Unix(),
  30667. Mtime: time.Now().Unix(),
  30668. Number: chrg_bchno,
  30669. ErrMsg: res.ErrMsg,
  30670. Status: 1,
  30671. PatientId: id,
  30672. RecordTime: recordDateTime,
  30673. Stage: 20,
  30674. }
  30675. service.CreateErrMsgLog(errlog)
  30676. c.ServeSuccessJSON(map[string]interface{}{
  30677. "failed_code": -10,
  30678. "msg": res.ErrMsg,
  30679. })
  30680. return
  30681. }
  30682. if res.Infcode != 0 {
  30683. errlog := &models.HisOrderError{
  30684. UserOrgId: adminUser.CurrentOrgId,
  30685. Ctime: time.Now().Unix(),
  30686. Mtime: time.Now().Unix(),
  30687. Number: chrg_bchno,
  30688. ErrMsg: res.ErrMsg,
  30689. Status: 1,
  30690. PatientId: id,
  30691. RecordTime: recordDateTime,
  30692. Stage: 20,
  30693. }
  30694. service.CreateErrMsgLog(errlog)
  30695. c.ServeSuccessJSON(map[string]interface{}{
  30696. "failed_code": -10,
  30697. "msg": res.ErrMsg,
  30698. })
  30699. return
  30700. } else {
  30701. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30702. order.OrderStatus = 1
  30703. order.IsPre = 1
  30704. order.Status = 1
  30705. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30706. order.SetlId = res.Output.Setlinfo.SetlID
  30707. order.PsnNo = res.Output.Setlinfo.PsnNo
  30708. order.PsnName = res.Output.Setlinfo.PsnName
  30709. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30710. order.Certno = res.Output.Setlinfo.Certno
  30711. order.Gend = res.Output.Setlinfo.Gend
  30712. order.Naty = res.Output.Setlinfo.Naty
  30713. order.Age = res.Output.Setlinfo.Age
  30714. order.Insutype = res.Output.Setlinfo.Insutype
  30715. order.PsnType = res.Output.Setlinfo.PsnType
  30716. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30717. order.SetlTime = res.Output.Setlinfo.SetlTime
  30718. order.AcctUsedFlag = acct_used_flag
  30719. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30720. if res.Output.Setlinfo.MedType == "140101" {
  30721. order.MedType = "14"
  30722. } else {
  30723. if res.Output.Setlinfo.MedType == "110104" {
  30724. order.MedType = "11"
  30725. } else {
  30726. order.MedType = res.Output.Setlinfo.MedType
  30727. }
  30728. }
  30729. if res.Output.Setlinfo.MedType == "992102" {
  30730. order.MedType = "992102"
  30731. }
  30732. if res.Output.Setlinfo.MedType == "140104" {
  30733. order.MedType = "140104"
  30734. }
  30735. if res.Output.Setlinfo.MedType == "140201" {
  30736. order.MedType = "140201"
  30737. }
  30738. if res.Output.Setlinfo.MedType == "14" {
  30739. order.MedType = "14"
  30740. }
  30741. if reg_type == 1112 {
  30742. order.MedType = "1112"
  30743. }
  30744. if reg_type == 1111 {
  30745. order.MedType = "1111"
  30746. }
  30747. order.ClrType = res.Output.Setlinfo.ClrType
  30748. if adminUser.CurrentOrgId == 10480 {
  30749. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30750. order.ClrType = "11"
  30751. } else {
  30752. order.ClrType = "9903"
  30753. }
  30754. }
  30755. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30756. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30757. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30758. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30759. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30760. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30761. order.HifpPay = res.Output.Setlinfo.HifpPay
  30762. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30763. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30764. order.HifesPay = res.Output.Setlinfo.HifesPay
  30765. order.HifobPay = res.Output.Setlinfo.HifobPay
  30766. order.MafPay = res.Output.Setlinfo.MafPay
  30767. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30768. order.OthPay = res.Output.Setlinfo.OthPay
  30769. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30770. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30771. order.AcctPay = res.Output.Setlinfo.AcctPay
  30772. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30773. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30774. order.Balc = res.Output.Setlinfo.Balc
  30775. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30776. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30777. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30778. order.ClrWay = res.Output.Setlinfo.ClrWay
  30779. order.Creator = order.Creator
  30780. order.Modify = roles.AdminUserId
  30781. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30782. //detailStr := string(setlDetail)
  30783. //order.SetlDetail = detailStr
  30784. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30785. err = service.UpDateOrder(order)
  30786. if err == nil {
  30787. c.ServeSuccessJSON(map[string]interface{}{
  30788. "msg": "预结算成功",
  30789. })
  30790. } else {
  30791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30792. return
  30793. }
  30794. }
  30795. } else {
  30796. adminUser := c.GetAdminUserInfo()
  30797. errlog := &models.HisOrderError{
  30798. UserOrgId: adminUser.CurrentOrgId,
  30799. Ctime: time.Now().Unix(),
  30800. Mtime: time.Now().Unix(),
  30801. ErrMsg: res.ErrMsg,
  30802. Status: 1,
  30803. PatientId: id,
  30804. RecordTime: recordDateTime,
  30805. Stage: 4,
  30806. }
  30807. service.CreateErrMsgLog(errlog)
  30808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  30809. return
  30810. }
  30811. } else {
  30812. if miConfig.MdtrtareaAdmvs == "150499" {
  30813. order := &models.HisOrder{
  30814. UserOrgId: adminUser.CurrentOrgId,
  30815. HisPatientId: his.ID,
  30816. PatientId: his.PatientId,
  30817. SettleAccountsDate: recordDateTime,
  30818. Ctime: time.Now().Unix(),
  30819. Mtime: time.Now().Unix(),
  30820. MdtrtId: his.Number,
  30821. PsnNo: his.PsnNo,
  30822. MedType: strconv.FormatInt(reg_type, 10),
  30823. Status: 1,
  30824. Number: chrg_bchno,
  30825. Infcode: res.Infcode,
  30826. WarnMsg: res.WarnMsg,
  30827. Cainfo: res.Cainfo,
  30828. ErrMsg: res.ErrMsg,
  30829. RespondTime: res.RefmsgTime,
  30830. InfRefmsgid: res.InfRefmsgid,
  30831. OrderStatus: 1,
  30832. IsMedicineInsurance: 1,
  30833. SettleType: settle_accounts_type,
  30834. SettleStartTime: start_time,
  30835. SettleEndTime: end_time,
  30836. Creator: roles.AdminUserId,
  30837. Modify: roles.AdminUserId,
  30838. PType: 2,
  30839. Diagnosis: diagnosis_id,
  30840. }
  30841. err = service.CreateOrder(order)
  30842. if err != nil {
  30843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30844. return
  30845. }
  30846. }
  30847. adminUser := c.GetAdminUserInfo()
  30848. errlog := &models.HisOrderError{
  30849. UserOrgId: adminUser.CurrentOrgId,
  30850. Ctime: time.Now().Unix(),
  30851. Mtime: time.Now().Unix(),
  30852. ErrMsg: res.ErrMsg,
  30853. Status: 1,
  30854. PatientId: id,
  30855. RecordTime: recordDateTime,
  30856. Stage: 4,
  30857. }
  30858. service.CreateErrMsgLog(errlog)
  30859. c.ServeSuccessJSON(map[string]interface{}{
  30860. "failed_code": -10,
  30861. "msg": res.ErrMsg,
  30862. })
  30863. return
  30864. }
  30865. }
  30866. }
  30867. }
  30868. // 退款
  30869. func (c *HisApiController) Refund() {
  30870. order_id, _ := c.GetInt64("order_id")
  30871. admin_user_id, _ := c.GetInt64("admin_user_id")
  30872. adminUser := c.GetAdminUserInfo()
  30873. var order models.HisOrder
  30874. order, _ = service.GetHisOrderByID(order_id)
  30875. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  30876. if fapiao.ID > 0 {
  30877. c.ServeSuccessJSON(map[string]interface{}{
  30878. "failed_code": -10,
  30879. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  30880. })
  30881. return
  30882. }
  30883. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30884. if order.ID == 0 {
  30885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30886. return
  30887. }
  30888. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30889. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30890. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30891. if config.IsOpen == 1 { //对接了医保,走医保流程
  30892. var res ResultSixteen
  30893. var ahres ResultSevenAH
  30894. var resSixteen10265 ResultSixteen10265
  30895. var resSixteen10265Two ResultSixteen10265Two
  30896. var gz ResultgzSixteen10265Two
  30897. var src_resquest string
  30898. var result string
  30899. if miConfig.MdtrtareaAdmvs == "421300" {
  30900. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30901. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30902. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30903. resp3, requestErr3 := http.Get(api3)
  30904. if requestErr3 != nil {
  30905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30906. return
  30907. }
  30908. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30909. if ioErr3 != nil {
  30910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30912. return
  30913. }
  30914. var respJSON3 map[string]interface{}
  30915. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30918. return
  30919. }
  30920. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30921. userJSONBytes3, _ := json.Marshal(respJSON3)
  30922. fmt.Println("log")
  30923. fmt.Println(string(userJSONBytes3))
  30924. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30925. utils.ErrorLog("解析失败:%v", err)
  30926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30927. return
  30928. }
  30929. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30930. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30931. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30932. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30933. resp3, requestErr3 := http.Get(api3)
  30934. if requestErr3 != nil {
  30935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30936. return
  30937. }
  30938. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30939. if ioErr3 != nil {
  30940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30942. return
  30943. }
  30944. var respJSON3 map[string]interface{}
  30945. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30948. return
  30949. }
  30950. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30951. userJSONBytes3, _ := json.Marshal(respJSON3)
  30952. fmt.Println("log")
  30953. fmt.Println(string(userJSONBytes3))
  30954. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30955. utils.ErrorLog("解析失败:%v", err)
  30956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30957. return
  30958. }
  30959. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30960. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30961. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30962. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30963. resp3, requestErr3 := http.Get(api3)
  30964. if requestErr3 != nil {
  30965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30966. return
  30967. }
  30968. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30969. if ioErr3 != nil {
  30970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30972. return
  30973. }
  30974. var respJSON3 map[string]interface{}
  30975. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30978. return
  30979. }
  30980. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30981. userJSONBytes3, _ := json.Marshal(respJSON3)
  30982. fmt.Println("log")
  30983. fmt.Println(string(userJSONBytes3))
  30984. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30985. utils.ErrorLog("解析失败:%v", err)
  30986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30987. return
  30988. }
  30989. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30990. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30991. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30992. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30993. resp3, requestErr3 := http.Get(api3)
  30994. if requestErr3 != nil {
  30995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30996. return
  30997. }
  30998. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30999. if ioErr3 != nil {
  31000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31002. return
  31003. }
  31004. var respJSON3 map[string]interface{}
  31005. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31008. return
  31009. }
  31010. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31011. userJSONBytes3, _ := json.Marshal(respJSON3)
  31012. fmt.Println("log")
  31013. fmt.Println(string(userJSONBytes3))
  31014. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31015. utils.ErrorLog("解析失败:%v", err)
  31016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31017. return
  31018. }
  31019. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31020. var api3 string
  31021. if miConfig.MdtrtareaAdmvs == "320921" {
  31022. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31023. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31024. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31025. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31026. } else {
  31027. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31028. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31029. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31030. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31031. }
  31032. resp3, requestErr3 := http.Get(api3)
  31033. if requestErr3 != nil {
  31034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31035. return
  31036. }
  31037. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31038. if ioErr3 != nil {
  31039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31041. return
  31042. }
  31043. var respJSON3 map[string]interface{}
  31044. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31047. return
  31048. }
  31049. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31050. userJSONBytes3, _ := json.Marshal(respJSON3)
  31051. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31052. utils.ErrorLog("解析失败:%v", err)
  31053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31054. return
  31055. }
  31056. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31057. res.Output = resSixteen10265.Output
  31058. res.ErrMsg = resSixteen10265.ErrMsg
  31059. res.Cainfo = resSixteen10265.Cainfo
  31060. res.WarnMsg = resSixteen10265.WarnMsg
  31061. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31062. res.Infcode = infocode
  31063. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31064. var api3 string
  31065. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31066. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31067. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31068. resp3, requestErr3 := http.Get(api3)
  31069. if requestErr3 != nil {
  31070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31071. return
  31072. }
  31073. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31074. if ioErr3 != nil {
  31075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31077. return
  31078. }
  31079. var respJSON3 map[string]interface{}
  31080. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31083. return
  31084. }
  31085. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31086. userJSONBytes3, _ := json.Marshal(respJSON3)
  31087. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31088. utils.ErrorLog("解析失败:%v", err)
  31089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31090. return
  31091. }
  31092. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31093. res.Output = resSixteen10265.Output
  31094. res.ErrMsg = resSixteen10265.ErrMsg
  31095. res.Cainfo = resSixteen10265.Cainfo
  31096. res.WarnMsg = resSixteen10265.WarnMsg
  31097. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31098. res.Infcode = infocode
  31099. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31100. 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)
  31101. var dat map[string]interface{}
  31102. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31103. fmt.Println(dat)
  31104. } else {
  31105. fmt.Println(err)
  31106. }
  31107. saveLog(result, src_resquest, "2208", "退费")
  31108. userJSONBytes, _ := json.Marshal(dat)
  31109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31110. utils.ErrorLog("解析失败:%v", err)
  31111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31112. return
  31113. }
  31114. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31115. 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, "")
  31116. var dat map[string]interface{}
  31117. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31118. fmt.Println(dat)
  31119. } else {
  31120. fmt.Println(err)
  31121. }
  31122. saveLog(result, src_resquest, "2208", "退费")
  31123. userJSONBytes, _ := json.Marshal(dat)
  31124. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31125. utils.ErrorLog("解析失败:%v", err)
  31126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31127. return
  31128. }
  31129. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31130. 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, "")
  31131. var dat map[string]interface{}
  31132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31133. fmt.Println(dat)
  31134. } else {
  31135. fmt.Println(err)
  31136. }
  31137. saveLog(result, src_resquest, "2208", "退费")
  31138. userJSONBytes, _ := json.Marshal(dat)
  31139. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31140. utils.ErrorLog("解析失败:%v", err)
  31141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31142. return
  31143. }
  31144. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31145. var api3 string
  31146. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31147. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31148. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31149. resp3, requestErr3 := http.Get(api3)
  31150. if requestErr3 != nil {
  31151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31152. return
  31153. }
  31154. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31155. if ioErr3 != nil {
  31156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31158. return
  31159. }
  31160. var respJSON3 map[string]interface{}
  31161. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31164. return
  31165. }
  31166. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31167. if status == "0" {
  31168. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31169. c.ServeSuccessJSON(map[string]interface{}{
  31170. "failed_code": -10,
  31171. "msg": err_msg,
  31172. })
  31173. return
  31174. }
  31175. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31176. userJSONBytes3, _ := json.Marshal(respJSON3)
  31177. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31178. // utils.ErrorLog("解析失败:%v", err)
  31179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31180. // return
  31181. //}
  31182. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31183. utils.ErrorLog("解析失败:%v", err)
  31184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31185. return
  31186. }
  31187. res.InfRefmsgid = ahres.InfRefmsgid
  31188. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31189. // 创建对应的Time类型
  31190. t := time.UnixMilli(timestamp)
  31191. // 格式化成指定的日期字符串
  31192. str := t.Format("2006-01-02 15:04:05")
  31193. res.Output.Setlinfo.SetlTime = str
  31194. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31195. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31196. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31197. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31198. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31199. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31200. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31201. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31202. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31203. //
  31204. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31205. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31206. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31207. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31208. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31209. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31210. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31211. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31212. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31213. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31214. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31215. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31216. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31217. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31218. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31219. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31220. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31221. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31222. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31223. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31224. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31225. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31226. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31227. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31228. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31229. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31230. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31231. //res.Output.Setldetail = ahres.Output.Setldetail
  31232. res.ErrMsg = ahres.ErrMsg
  31233. res.Cainfo = ahres.Cainfo
  31234. res.WarnMsg = ahres.WarnMsg
  31235. res.Infcode = ahres.Infcode
  31236. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31237. var api3 string
  31238. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31239. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31240. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31241. resp3, requestErr3 := http.Get(api3)
  31242. if requestErr3 != nil {
  31243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31244. return
  31245. }
  31246. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31247. if ioErr3 != nil {
  31248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31250. return
  31251. }
  31252. var respJSON3 map[string]interface{}
  31253. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31256. return
  31257. }
  31258. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31259. if status == "0" {
  31260. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31261. c.ServeSuccessJSON(map[string]interface{}{
  31262. "failed_code": -10,
  31263. "msg": err_msg,
  31264. })
  31265. return
  31266. }
  31267. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31268. userJSONBytes3, _ := json.Marshal(respJSON3)
  31269. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31270. // utils.ErrorLog("解析失败:%v", err)
  31271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31272. // return
  31273. //}
  31274. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31275. utils.ErrorLog("解析失败:%v", err)
  31276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31277. return
  31278. }
  31279. res.InfRefmsgid = ahres.InfRefmsgid
  31280. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31281. // 创建对应的Time类型
  31282. t := time.UnixMilli(timestamp)
  31283. // 格式化成指定的日期字符串
  31284. str := t.Format("2006-01-02 15:04:05")
  31285. res.Output.Setlinfo.SetlTime = str
  31286. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31287. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31288. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31289. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31290. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31291. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31292. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31293. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31294. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31295. //
  31296. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31297. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31298. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31299. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31300. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31301. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31302. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31303. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31304. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31305. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31306. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31307. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31308. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31309. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31310. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31311. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31312. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31313. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31314. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31315. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31316. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31317. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31318. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31319. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31320. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31321. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31322. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31323. //res.Output.Setldetail = ahres.Output.Setldetail
  31324. res.ErrMsg = ahres.ErrMsg
  31325. res.Cainfo = ahres.Cainfo
  31326. res.WarnMsg = ahres.WarnMsg
  31327. res.Infcode = ahres.Infcode
  31328. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31329. 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, "")
  31330. var dat map[string]interface{}
  31331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31332. fmt.Println(dat)
  31333. } else {
  31334. fmt.Println(err)
  31335. }
  31336. saveLog(result, src_resquest, "2208", "退费")
  31337. userJSONBytes, _ := json.Marshal(dat)
  31338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31339. utils.ErrorLog("解析失败:%v", err)
  31340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31341. return
  31342. }
  31343. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31344. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31345. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31346. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31347. resp3, requestErr3 := http.Get(api3)
  31348. if requestErr3 != nil {
  31349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31350. return
  31351. }
  31352. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31353. if ioErr3 != nil {
  31354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31356. return
  31357. }
  31358. var respJSON3 map[string]interface{}
  31359. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31362. return
  31363. }
  31364. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31365. userJSONBytes3, _ := json.Marshal(respJSON3)
  31366. fmt.Println("log")
  31367. fmt.Println(string(userJSONBytes3))
  31368. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31369. utils.ErrorLog("解析失败:%v", err)
  31370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31371. return
  31372. }
  31373. } else {
  31374. if miConfig.Code == "H15049901371" {
  31375. 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)
  31376. var dat map[string]interface{}
  31377. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31378. fmt.Println(dat)
  31379. } else {
  31380. fmt.Println(err)
  31381. }
  31382. saveLog(result, src_resquest, "2208", "退费")
  31383. if strings.Contains(result, "Post") {
  31384. res.Infcode = -1
  31385. res.ErrMsg = result
  31386. }
  31387. userJSONBytes, _ := json.Marshal(dat)
  31388. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31389. utils.ErrorLog("解析失败:%v", err)
  31390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31391. return
  31392. }
  31393. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31394. res.Output = resSixteen10265.Output
  31395. res.ErrMsg = resSixteen10265.ErrMsg
  31396. res.Cainfo = resSixteen10265.Cainfo
  31397. res.WarnMsg = resSixteen10265.WarnMsg
  31398. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31399. res.Infcode = infocode
  31400. } else {
  31401. 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)
  31402. var dat map[string]interface{}
  31403. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31404. fmt.Println(dat)
  31405. } else {
  31406. fmt.Println(err)
  31407. }
  31408. saveLog(result, src_resquest, "2208", "退费")
  31409. userJSONBytes, _ := json.Marshal(dat)
  31410. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31411. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31412. utils.ErrorLog("解析失败:%v", err)
  31413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31414. return
  31415. }
  31416. res.Infcode = gz.Infcode
  31417. } else {
  31418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31419. utils.ErrorLog("解析失败:%v", err)
  31420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31421. return
  31422. }
  31423. }
  31424. if strings.Contains(result, "Post") {
  31425. res.Infcode = -1
  31426. res.ErrMsg = result
  31427. }
  31428. }
  31429. }
  31430. if res.Infcode == -1 {
  31431. c.ServeSuccessJSON(map[string]interface{}{
  31432. "failed_code": -10,
  31433. "msg": res.ErrMsg,
  31434. })
  31435. return
  31436. }
  31437. if res.Infcode != -1 {
  31438. var res2 ResultSix
  31439. var resSix10265 ResultSix10265
  31440. if miConfig.MdtrtareaAdmvs == "421300" {
  31441. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31442. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31443. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31444. resp3, requestErr3 := http.Get(api3)
  31445. if requestErr3 != nil {
  31446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31447. return
  31448. }
  31449. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31450. if ioErr3 != nil {
  31451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31453. return
  31454. }
  31455. var respJSON3 map[string]interface{}
  31456. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31459. return
  31460. }
  31461. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31462. userJSONBytes3, _ := json.Marshal(respJSON3)
  31463. fmt.Println("log")
  31464. fmt.Println(string(userJSONBytes3))
  31465. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31466. utils.ErrorLog("解析失败:%v", err)
  31467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31468. return
  31469. }
  31470. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31471. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31472. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31473. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31474. resp3, requestErr3 := http.Get(api3)
  31475. if requestErr3 != nil {
  31476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31477. return
  31478. }
  31479. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31480. if ioErr3 != nil {
  31481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31483. return
  31484. }
  31485. var respJSON3 map[string]interface{}
  31486. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31489. return
  31490. }
  31491. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31492. userJSONBytes3, _ := json.Marshal(respJSON3)
  31493. fmt.Println("log")
  31494. fmt.Println(string(userJSONBytes3))
  31495. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31496. utils.ErrorLog("解析失败:%v", err)
  31497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31498. return
  31499. }
  31500. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31501. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31502. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31503. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31504. resp3, requestErr3 := http.Get(api3)
  31505. if requestErr3 != nil {
  31506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31507. return
  31508. }
  31509. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31510. if ioErr3 != nil {
  31511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31513. return
  31514. }
  31515. var respJSON3 map[string]interface{}
  31516. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31519. return
  31520. }
  31521. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31522. userJSONBytes3, _ := json.Marshal(respJSON3)
  31523. fmt.Println("log")
  31524. fmt.Println(string(userJSONBytes3))
  31525. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31526. utils.ErrorLog("解析失败:%v", err)
  31527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31528. return
  31529. }
  31530. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31531. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31532. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31533. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31534. resp3, requestErr3 := http.Get(api3)
  31535. if requestErr3 != nil {
  31536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31537. return
  31538. }
  31539. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31540. if ioErr3 != nil {
  31541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31543. return
  31544. }
  31545. var respJSON3 map[string]interface{}
  31546. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31549. return
  31550. }
  31551. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31552. userJSONBytes3, _ := json.Marshal(respJSON3)
  31553. fmt.Println("log")
  31554. fmt.Println(string(userJSONBytes3))
  31555. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31556. utils.ErrorLog("解析失败:%v", err)
  31557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31558. return
  31559. }
  31560. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31561. var api3 string
  31562. if miConfig.MdtrtareaAdmvs == "320921" {
  31563. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31564. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31565. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31566. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31567. } else {
  31568. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31569. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31570. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31571. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31572. }
  31573. resp3, requestErr3 := http.Get(api3)
  31574. if requestErr3 != nil {
  31575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31576. return
  31577. }
  31578. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31579. if ioErr3 != nil {
  31580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31582. return
  31583. }
  31584. var respJSON3 map[string]interface{}
  31585. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31588. return
  31589. }
  31590. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31591. userJSONBytes3, _ := json.Marshal(respJSON3)
  31592. fmt.Println("log")
  31593. fmt.Println(string(userJSONBytes3))
  31594. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31595. utils.ErrorLog("解析失败:%v", err)
  31596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31597. return
  31598. }
  31599. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31600. res2.Output = resSix10265.Output
  31601. res2.ErrMsg = resSix10265.ErrMsg
  31602. res2.Cainfo = resSix10265.Cainfo
  31603. res2.WarnMsg = resSix10265.WarnMsg
  31604. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31605. res2.Infcode = infocode
  31606. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31607. var api3 string
  31608. new_chrg_bchno := order.Number
  31609. if adminUser.CurrentOrgId == 10265 {
  31610. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31611. new_chrg_bchno = "0000"
  31612. }
  31613. }
  31614. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31615. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31616. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31617. resp3, requestErr3 := http.Get(api3)
  31618. if requestErr3 != nil {
  31619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31620. return
  31621. }
  31622. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31623. if ioErr3 != nil {
  31624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31626. return
  31627. }
  31628. var respJSON3 map[string]interface{}
  31629. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31632. return
  31633. }
  31634. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31635. userJSONBytes3, _ := json.Marshal(respJSON3)
  31636. fmt.Println("log")
  31637. fmt.Println(string(userJSONBytes3))
  31638. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31639. utils.ErrorLog("解析失败:%v", err)
  31640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31641. return
  31642. }
  31643. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31644. res2.Output = resSix10265.Output
  31645. res2.ErrMsg = resSix10265.ErrMsg
  31646. res2.Cainfo = resSix10265.Cainfo
  31647. res2.WarnMsg = resSix10265.WarnMsg
  31648. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31649. res2.Infcode = infocode
  31650. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31651. 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)
  31652. var dat map[string]interface{}
  31653. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31654. fmt.Println(dat)
  31655. } else {
  31656. fmt.Println(err)
  31657. }
  31658. saveLog(result2, src_request, "2205", "撤销明细")
  31659. userJSONBytes, _ := json.Marshal(dat)
  31660. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31661. utils.ErrorLog("解析失败:%v", err)
  31662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31663. return
  31664. }
  31665. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31666. 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, "")
  31667. var dat map[string]interface{}
  31668. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31669. fmt.Println(dat)
  31670. } else {
  31671. fmt.Println(err)
  31672. }
  31673. saveLog(result2, src_request, "2205", "撤销明细")
  31674. userJSONBytes, _ := json.Marshal(dat)
  31675. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31676. utils.ErrorLog("解析失败:%v", err)
  31677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31678. return
  31679. }
  31680. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31681. 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, "")
  31682. var dat map[string]interface{}
  31683. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31684. fmt.Println(dat)
  31685. } else {
  31686. fmt.Println(err)
  31687. }
  31688. saveLog(result2, src_request, "2205", "撤销明细")
  31689. userJSONBytes, _ := json.Marshal(dat)
  31690. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31691. utils.ErrorLog("解析失败:%v", err)
  31692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31693. return
  31694. }
  31695. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31696. var api3 string
  31697. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31698. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31699. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31700. resp3, requestErr3 := http.Get(api3)
  31701. if requestErr3 != nil {
  31702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31703. return
  31704. }
  31705. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31706. if ioErr3 != nil {
  31707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31709. return
  31710. }
  31711. var respJSON3 map[string]interface{}
  31712. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31715. return
  31716. }
  31717. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31718. if status == "0" {
  31719. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31720. c.ServeSuccessJSON(map[string]interface{}{
  31721. "failed_code": -10,
  31722. "msg": err_msg,
  31723. })
  31724. return
  31725. }
  31726. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31727. userJSONBytes3, _ := json.Marshal(respJSON3)
  31728. fmt.Println("log")
  31729. fmt.Println(string(userJSONBytes3))
  31730. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31731. utils.ErrorLog("解析失败:%v", err)
  31732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31733. return
  31734. }
  31735. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31736. 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, "")
  31737. var dat map[string]interface{}
  31738. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31739. fmt.Println(dat)
  31740. } else {
  31741. fmt.Println(err)
  31742. }
  31743. saveLog(result2, src_request, "2205", "撤销明细")
  31744. userJSONBytes, _ := json.Marshal(dat)
  31745. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31746. utils.ErrorLog("解析失败:%v", err)
  31747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31748. return
  31749. }
  31750. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31751. 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, "")
  31752. var dat map[string]interface{}
  31753. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31754. fmt.Println(dat)
  31755. } else {
  31756. fmt.Println(err)
  31757. }
  31758. saveLog(result2, src_request, "2205", "撤销明细")
  31759. userJSONBytes, _ := json.Marshal(dat)
  31760. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31761. utils.ErrorLog("解析失败:%v", err)
  31762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31763. return
  31764. }
  31765. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31766. var api3 string
  31767. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31768. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31769. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31770. resp3, requestErr3 := http.Get(api3)
  31771. if requestErr3 != nil {
  31772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31773. return
  31774. }
  31775. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31776. if ioErr3 != nil {
  31777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31779. return
  31780. }
  31781. var respJSON3 map[string]interface{}
  31782. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31785. return
  31786. }
  31787. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31788. if status == "0" {
  31789. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31790. c.ServeSuccessJSON(map[string]interface{}{
  31791. "failed_code": -10,
  31792. "msg": err_msg,
  31793. })
  31794. return
  31795. }
  31796. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31797. userJSONBytes3, _ := json.Marshal(respJSON3)
  31798. fmt.Println("log")
  31799. fmt.Println(string(userJSONBytes3))
  31800. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31801. utils.ErrorLog("解析失败:%v", err)
  31802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31803. return
  31804. }
  31805. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31806. 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, "")
  31807. var dat map[string]interface{}
  31808. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31809. fmt.Println(dat)
  31810. } else {
  31811. fmt.Println(err)
  31812. }
  31813. saveLog(result2, src_request, "2205", "撤销明细")
  31814. userJSONBytes, _ := json.Marshal(dat)
  31815. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31816. utils.ErrorLog("解析失败:%v", err)
  31817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31818. return
  31819. }
  31820. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31821. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  31822. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31823. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31824. resp3, requestErr3 := http.Get(api3)
  31825. if requestErr3 != nil {
  31826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31827. return
  31828. }
  31829. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31830. if ioErr3 != nil {
  31831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31833. return
  31834. }
  31835. var respJSON3 map[string]interface{}
  31836. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31839. return
  31840. }
  31841. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31842. userJSONBytes3, _ := json.Marshal(respJSON3)
  31843. fmt.Println("log")
  31844. fmt.Println(string(userJSONBytes3))
  31845. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31846. utils.ErrorLog("解析失败:%v", err)
  31847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31848. return
  31849. }
  31850. } else {
  31851. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31852. res2.Infcode = 0
  31853. } else {
  31854. 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)
  31855. var dat map[string]interface{}
  31856. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31857. fmt.Println(dat)
  31858. } else {
  31859. fmt.Println(err)
  31860. }
  31861. saveLog(result2, src_request, "2205", "撤销明细")
  31862. userJSONBytes, _ := json.Marshal(dat)
  31863. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31864. utils.ErrorLog("解析失败:%v", err)
  31865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31866. return
  31867. }
  31868. }
  31869. }
  31870. if res2.Infcode == -1 {
  31871. c.ServeSuccessJSON(map[string]interface{}{
  31872. "failed_code": -10,
  31873. "msg": res2.ErrMsg,
  31874. })
  31875. return
  31876. }
  31877. if res2.Infcode == 0 {
  31878. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  31879. if err == nil {
  31880. //当押金不为零时产生退费记录
  31881. if order.Decimal != 0 {
  31882. tmp := strconv.FormatInt(order.ID, 10)
  31883. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  31884. if err != nil {
  31885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31886. return
  31887. }
  31888. }
  31889. c.ServeSuccessJSON(map[string]interface{}{
  31890. "msg": "退费成功",
  31891. })
  31892. } else {
  31893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31894. return
  31895. }
  31896. } else {
  31897. c.ServeSuccessJSON(map[string]interface{}{
  31898. "failed_code": -10,
  31899. "msg": res2.ErrMsg,
  31900. })
  31901. }
  31902. } else {
  31903. c.ServeSuccessJSON(map[string]interface{}{
  31904. "failed_code": -10,
  31905. "msg": res.ErrMsg,
  31906. })
  31907. }
  31908. }
  31909. }
  31910. func (c *HisApiController) RefundNumber() {
  31911. record_time := c.GetString("record_time")
  31912. //patient_id, _ := c.GetInt64("patient_id")
  31913. admin_user_id, _ := c.GetInt64("admin_user_id")
  31914. his_patient_id, _ := c.GetInt64("id")
  31915. timeLayout := "2006-01-02"
  31916. loc, _ := time.LoadLocation("Local")
  31917. adminUser := c.GetAdminUserInfo()
  31918. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31919. fmt.Println(err)
  31920. if err != nil {
  31921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31922. return
  31923. }
  31924. recordDateTime := theTime.Unix()
  31925. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31926. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  31927. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31928. //order, _ := service.GetHisOrderByID(order_id)
  31929. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31930. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31931. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31932. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  31933. if count > 0 {
  31934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  31935. return
  31936. }
  31937. if config.IsOpen == 1 { //对接了医保,走医保流程
  31938. var res2 ResultSix
  31939. var res3 GZResultSix
  31940. var resSix10265 ResultSix10265
  31941. if miConfig.MdtrtareaAdmvs == "421300" {
  31942. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31943. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31944. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31945. resp3, requestErr3 := http.Get(api3)
  31946. if requestErr3 != nil {
  31947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31948. return
  31949. }
  31950. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31951. if ioErr3 != nil {
  31952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31954. return
  31955. }
  31956. var respJSON3 map[string]interface{}
  31957. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31960. return
  31961. }
  31962. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31963. userJSONBytes3, _ := json.Marshal(respJSON3)
  31964. fmt.Println("log")
  31965. fmt.Println(string(userJSONBytes3))
  31966. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31967. utils.ErrorLog("解析失败:%v", err)
  31968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31969. return
  31970. }
  31971. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31972. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31973. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31974. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31975. resp3, requestErr3 := http.Get(api3)
  31976. if requestErr3 != nil {
  31977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31978. return
  31979. }
  31980. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31981. if ioErr3 != nil {
  31982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31984. return
  31985. }
  31986. var respJSON3 map[string]interface{}
  31987. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31990. return
  31991. }
  31992. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31993. userJSONBytes3, _ := json.Marshal(respJSON3)
  31994. fmt.Println("log")
  31995. fmt.Println(string(userJSONBytes3))
  31996. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31997. utils.ErrorLog("解析失败:%v", err)
  31998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31999. return
  32000. }
  32001. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32002. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32003. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32004. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32005. resp3, requestErr3 := http.Get(api3)
  32006. if requestErr3 != nil {
  32007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32008. return
  32009. }
  32010. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32011. if ioErr3 != nil {
  32012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32014. return
  32015. }
  32016. var respJSON3 map[string]interface{}
  32017. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32020. return
  32021. }
  32022. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32023. userJSONBytes3, _ := json.Marshal(respJSON3)
  32024. fmt.Println("log")
  32025. fmt.Println(string(userJSONBytes3))
  32026. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32027. utils.ErrorLog("解析失败:%v", err)
  32028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32029. return
  32030. }
  32031. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32032. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32033. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32034. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32035. resp3, requestErr3 := http.Get(api3)
  32036. if requestErr3 != nil {
  32037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32038. return
  32039. }
  32040. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32041. if ioErr3 != nil {
  32042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32044. return
  32045. }
  32046. var respJSON3 map[string]interface{}
  32047. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32050. return
  32051. }
  32052. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32053. userJSONBytes3, _ := json.Marshal(respJSON3)
  32054. fmt.Println("log")
  32055. fmt.Println(string(userJSONBytes3))
  32056. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32057. utils.ErrorLog("解析失败:%v", err)
  32058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32059. return
  32060. }
  32061. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32062. var api3 string
  32063. if miConfig.MdtrtareaAdmvs == "320921" {
  32064. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32065. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32066. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32067. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32068. } else {
  32069. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32070. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32071. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32072. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32073. }
  32074. resp3, requestErr3 := http.Get(api3)
  32075. if requestErr3 != nil {
  32076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32077. return
  32078. }
  32079. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32080. if ioErr3 != nil {
  32081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32083. return
  32084. }
  32085. var respJSON3 map[string]interface{}
  32086. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32089. return
  32090. }
  32091. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32092. userJSONBytes3, _ := json.Marshal(respJSON3)
  32093. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32094. utils.ErrorLog("解析失败:%v", err)
  32095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32096. return
  32097. }
  32098. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32099. res2.Output = resSix10265.Output
  32100. res2.ErrMsg = resSix10265.ErrMsg
  32101. res2.Cainfo = resSix10265.Cainfo
  32102. res2.WarnMsg = resSix10265.WarnMsg
  32103. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32104. res2.Infcode = infocode
  32105. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32106. var api3 string
  32107. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32108. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32109. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32110. resp3, requestErr3 := http.Get(api3)
  32111. if requestErr3 != nil {
  32112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32113. return
  32114. }
  32115. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32116. if ioErr3 != nil {
  32117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32119. return
  32120. }
  32121. var respJSON3 map[string]interface{}
  32122. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32125. return
  32126. }
  32127. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32128. userJSONBytes3, _ := json.Marshal(respJSON3)
  32129. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32130. utils.ErrorLog("解析失败:%v", err)
  32131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32132. return
  32133. }
  32134. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32135. res2.Output = resSix10265.Output
  32136. res2.ErrMsg = resSix10265.ErrMsg
  32137. res2.Cainfo = resSix10265.Cainfo
  32138. res2.WarnMsg = resSix10265.WarnMsg
  32139. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32140. res2.Infcode = infocode
  32141. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32142. 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)
  32143. var dat map[string]interface{}
  32144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32145. fmt.Println(dat)
  32146. } else {
  32147. fmt.Println(err)
  32148. }
  32149. saveLog(result, request, "2202", "退号")
  32150. userJSONBytes, _ := json.Marshal(dat)
  32151. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32152. utils.ErrorLog("解析失败:%v", err)
  32153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32154. return
  32155. }
  32156. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32157. 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, "")
  32158. var dat map[string]interface{}
  32159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32160. fmt.Println(dat)
  32161. } else {
  32162. fmt.Println(err)
  32163. }
  32164. saveLog(result, request, "2202", "退号")
  32165. userJSONBytes, _ := json.Marshal(dat)
  32166. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32167. utils.ErrorLog("解析失败:%v", err)
  32168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32169. return
  32170. }
  32171. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32172. 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, "")
  32173. var dat map[string]interface{}
  32174. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32175. fmt.Println(dat)
  32176. } else {
  32177. fmt.Println(err)
  32178. }
  32179. saveLog(result, request, "2202", "退号")
  32180. userJSONBytes, _ := json.Marshal(dat)
  32181. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32182. utils.ErrorLog("解析失败:%v", err)
  32183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32184. return
  32185. }
  32186. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32187. var api3 string
  32188. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32189. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32190. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32191. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32192. resp3, requestErr3 := http.Get(api3)
  32193. if requestErr3 != nil {
  32194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32195. return
  32196. }
  32197. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32198. if ioErr3 != nil {
  32199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32201. return
  32202. }
  32203. var respJSON3 map[string]interface{}
  32204. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32207. return
  32208. }
  32209. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32210. if status == "0" {
  32211. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32212. c.ServeSuccessJSON(map[string]interface{}{
  32213. "failed_code": -10,
  32214. "msg": err_msg,
  32215. })
  32216. return
  32217. }
  32218. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32219. userJSONBytes3, _ := json.Marshal(respJSON3)
  32220. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32221. utils.ErrorLog("解析失败:%v", err)
  32222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32223. return
  32224. }
  32225. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32226. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32227. var api3 string
  32228. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32229. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32230. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32231. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32232. resp3, requestErr3 := http.Get(api3)
  32233. if requestErr3 != nil {
  32234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32235. return
  32236. }
  32237. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32238. if ioErr3 != nil {
  32239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32241. return
  32242. }
  32243. var respJSON3 map[string]interface{}
  32244. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32247. return
  32248. }
  32249. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32250. if status == "0" {
  32251. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32252. c.ServeSuccessJSON(map[string]interface{}{
  32253. "failed_code": -10,
  32254. "msg": err_msg,
  32255. })
  32256. return
  32257. }
  32258. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32259. userJSONBytes3, _ := json.Marshal(respJSON3)
  32260. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32261. utils.ErrorLog("解析失败:%v", err)
  32262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32263. return
  32264. }
  32265. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32266. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32267. 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, "")
  32268. var dat map[string]interface{}
  32269. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32270. fmt.Println(dat)
  32271. } else {
  32272. fmt.Println(err)
  32273. }
  32274. saveLog(result, request, "2202", "退号")
  32275. userJSONBytes, _ := json.Marshal(dat)
  32276. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32277. utils.ErrorLog("解析失败:%v", err)
  32278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32279. return
  32280. }
  32281. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32282. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32283. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32284. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32285. resp3, requestErr3 := http.Get(api3)
  32286. if requestErr3 != nil {
  32287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32288. return
  32289. }
  32290. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32291. if ioErr3 != nil {
  32292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32294. return
  32295. }
  32296. var respJSON3 map[string]interface{}
  32297. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32300. return
  32301. }
  32302. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32303. userJSONBytes3, _ := json.Marshal(respJSON3)
  32304. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32305. utils.ErrorLog("解析失败:%v", err)
  32306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32307. return
  32308. }
  32309. } else {
  32310. var api3 string
  32311. if miConfig.Code == "H15049901371" {
  32312. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32313. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32314. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32315. } else {
  32316. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32317. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32318. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32319. }
  32320. resp3, requestErr3 := http.Get(api3)
  32321. if requestErr3 != nil {
  32322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32323. return
  32324. }
  32325. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32326. if ioErr3 != nil {
  32327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32329. return
  32330. }
  32331. var respJSON3 map[string]interface{}
  32332. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32335. return
  32336. }
  32337. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32338. userJSONBytes3, _ := json.Marshal(respJSON3)
  32339. if miConfig.Code == "H15049901371" {
  32340. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32341. utils.ErrorLog("解析失败:%v", err)
  32342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32343. return
  32344. }
  32345. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32346. res2.Output = resSix10265.Output
  32347. res2.ErrMsg = resSix10265.ErrMsg
  32348. res2.Cainfo = resSix10265.Cainfo
  32349. res2.WarnMsg = resSix10265.WarnMsg
  32350. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32351. res2.Infcode = infocode
  32352. } else {
  32353. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32354. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32355. utils.ErrorLog("解析失败:%v", err)
  32356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32357. return
  32358. }
  32359. res2.Infcode = res3.Infcode
  32360. } else {
  32361. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32362. utils.ErrorLog("解析失败:%v", err)
  32363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32364. return
  32365. }
  32366. }
  32367. }
  32368. }
  32369. if res2.Infcode == -1 {
  32370. c.ServeSuccessJSON(map[string]interface{}{
  32371. "failed_code": -10,
  32372. "msg": res2.ErrMsg,
  32373. })
  32374. return
  32375. }
  32376. if res2.Infcode == 0 {
  32377. if err == nil {
  32378. c.ServeSuccessJSON(map[string]interface{}{
  32379. "msg": "退号成功",
  32380. })
  32381. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32382. } else {
  32383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32384. return
  32385. }
  32386. }
  32387. } else {
  32388. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32389. //if err == nil {
  32390. // c.ServeSuccessJSON(map[string]interface{}{
  32391. // "msg": "退费成功",
  32392. // })
  32393. //} else {
  32394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32395. // return
  32396. //}
  32397. }
  32398. }
  32399. func (c *HisApiController) RefundDetail() {
  32400. order_id, _ := c.GetInt64("order_id")
  32401. admin_user_id, _ := c.GetInt64("admin_user_id")
  32402. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32403. number := c.GetString("number")
  32404. record_time := c.GetString("record_time")
  32405. patient_id, _ := c.GetInt64("patient_id")
  32406. //med_type, _ := c.GetInt64("med_type")
  32407. timeLayout := "2006-01-02"
  32408. loc, _ := time.LoadLocation("Local")
  32409. adminUser := c.GetAdminUserInfo()
  32410. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32411. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32412. fmt.Println(err)
  32413. if err != nil {
  32414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32415. return
  32416. }
  32417. recordDateTime := theTime.Unix()
  32418. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32419. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32420. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32421. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32422. var order models.HisOrder
  32423. order, _ = service.GetHisOrderByID(order_id)
  32424. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32425. if config.IsOpen == 1 { //对接了医保,走医保流程
  32426. var res2 ResultSix
  32427. if miConfig.MdtrtareaAdmvs == "421300" {
  32428. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32429. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32430. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  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. fmt.Println("log")
  32451. fmt.Println(string(userJSONBytes3))
  32452. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32453. utils.ErrorLog("解析失败:%v", err)
  32454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32455. return
  32456. }
  32457. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32458. if err == nil {
  32459. c.ServeSuccessJSON(map[string]interface{}{
  32460. "msg": "撤销明细成功",
  32461. })
  32462. return
  32463. } else {
  32464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32465. return
  32466. }
  32467. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32468. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32469. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32470. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32471. resp3, requestErr3 := http.Get(api3)
  32472. if requestErr3 != nil {
  32473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32474. return
  32475. }
  32476. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32477. if ioErr3 != nil {
  32478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32480. return
  32481. }
  32482. var respJSON3 map[string]interface{}
  32483. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32486. return
  32487. }
  32488. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32489. userJSONBytes3, _ := json.Marshal(respJSON3)
  32490. fmt.Println("log")
  32491. fmt.Println(string(userJSONBytes3))
  32492. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32493. utils.ErrorLog("解析失败:%v", err)
  32494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32495. return
  32496. }
  32497. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32498. if err == nil {
  32499. c.ServeSuccessJSON(map[string]interface{}{
  32500. "msg": "撤销明细成功",
  32501. })
  32502. return
  32503. } else {
  32504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32505. return
  32506. }
  32507. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32508. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32509. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32510. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32511. resp3, requestErr3 := http.Get(api3)
  32512. if requestErr3 != nil {
  32513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32514. return
  32515. }
  32516. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32517. if ioErr3 != nil {
  32518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32520. return
  32521. }
  32522. var respJSON3 map[string]interface{}
  32523. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32526. return
  32527. }
  32528. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32529. userJSONBytes3, _ := json.Marshal(respJSON3)
  32530. fmt.Println("log")
  32531. fmt.Println(string(userJSONBytes3))
  32532. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32533. utils.ErrorLog("解析失败:%v", err)
  32534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32535. return
  32536. }
  32537. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32538. if err == nil {
  32539. c.ServeSuccessJSON(map[string]interface{}{
  32540. "msg": "撤销明细成功",
  32541. })
  32542. return
  32543. } else {
  32544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32545. return
  32546. }
  32547. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32548. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32549. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32550. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32551. resp3, requestErr3 := http.Get(api3)
  32552. if requestErr3 != nil {
  32553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32554. return
  32555. }
  32556. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32557. if ioErr3 != nil {
  32558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32560. return
  32561. }
  32562. var respJSON3 map[string]interface{}
  32563. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32566. return
  32567. }
  32568. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32569. userJSONBytes3, _ := json.Marshal(respJSON3)
  32570. fmt.Println("log")
  32571. fmt.Println(string(userJSONBytes3))
  32572. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32573. utils.ErrorLog("解析失败:%v", err)
  32574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32575. return
  32576. }
  32577. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32578. if err == nil {
  32579. c.ServeSuccessJSON(map[string]interface{}{
  32580. "msg": "撤销明细成功",
  32581. })
  32582. return
  32583. } else {
  32584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32585. return
  32586. }
  32587. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32588. var resSix10265 ResultSix10265
  32589. var api3 string
  32590. if miConfig.MdtrtareaAdmvs == "320921" {
  32591. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32592. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32593. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32594. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32595. } else {
  32596. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32597. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32598. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32599. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32600. }
  32601. resp3, requestErr3 := http.Get(api3)
  32602. utils.ErrorLog("接口: %v", requestErr3)
  32603. if requestErr3 != nil {
  32604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32605. return
  32606. }
  32607. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32608. if ioErr3 != nil {
  32609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32611. return
  32612. }
  32613. var respJSON3 map[string]interface{}
  32614. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32617. return
  32618. }
  32619. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32620. userJSONBytes3, _ := json.Marshal(respJSON3)
  32621. fmt.Println("log")
  32622. fmt.Println(string(userJSONBytes3))
  32623. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32624. utils.ErrorLog("解析失败:%v", err)
  32625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32626. return
  32627. }
  32628. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32629. res2.Output = resSix10265.Output
  32630. res2.ErrMsg = resSix10265.ErrMsg
  32631. res2.Cainfo = resSix10265.Cainfo
  32632. res2.WarnMsg = resSix10265.WarnMsg
  32633. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32634. res2.Infcode = infocode
  32635. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32636. if err == nil {
  32637. c.ServeSuccessJSON(map[string]interface{}{
  32638. "msg": "撤销明细成功",
  32639. })
  32640. return
  32641. } else {
  32642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32643. return
  32644. }
  32645. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32646. var api3 string
  32647. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32648. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32649. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32650. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32651. resp3, requestErr3 := http.Get(api3)
  32652. utils.ErrorLog("接口: %v", requestErr3)
  32653. if requestErr3 != nil {
  32654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32655. return
  32656. }
  32657. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32658. if ioErr3 != nil {
  32659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32661. return
  32662. }
  32663. var respJSON3 map[string]interface{}
  32664. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32667. return
  32668. }
  32669. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32670. if status == "0" {
  32671. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32672. c.ServeSuccessJSON(map[string]interface{}{
  32673. "failed_code": -10,
  32674. "msg": err_msg,
  32675. })
  32676. return
  32677. }
  32678. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32679. userJSONBytes3, _ := json.Marshal(respJSON3)
  32680. fmt.Println("log")
  32681. fmt.Println(string(userJSONBytes3))
  32682. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32683. utils.ErrorLog("解析失败:%v", err)
  32684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32685. return
  32686. }
  32687. fmt.Println(res2.Infcode)
  32688. if res2.Infcode == -1 {
  32689. c.ServeSuccessJSON(map[string]interface{}{
  32690. "failed_code": -10,
  32691. "msg": res2.ErrMsg,
  32692. })
  32693. return
  32694. }
  32695. if res2.Infcode == 0 {
  32696. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32697. if err == nil {
  32698. c.ServeSuccessJSON(map[string]interface{}{
  32699. "msg": "撤销明细成功",
  32700. })
  32701. return
  32702. } else {
  32703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32704. return
  32705. }
  32706. } else {
  32707. c.ServeSuccessJSON(map[string]interface{}{
  32708. "failed_code": -10,
  32709. "msg": res2.ErrMsg,
  32710. })
  32711. }
  32712. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32713. if err == nil {
  32714. c.ServeSuccessJSON(map[string]interface{}{
  32715. "msg": "撤销明细成功",
  32716. })
  32717. return
  32718. } else {
  32719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32720. return
  32721. }
  32722. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32723. var api3 string
  32724. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32725. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32726. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32727. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32728. resp3, requestErr3 := http.Get(api3)
  32729. utils.ErrorLog("接口: %v", requestErr3)
  32730. if requestErr3 != nil {
  32731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32732. return
  32733. }
  32734. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32735. if ioErr3 != nil {
  32736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32738. return
  32739. }
  32740. var respJSON3 map[string]interface{}
  32741. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32744. return
  32745. }
  32746. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32747. if status == "0" {
  32748. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32749. c.ServeSuccessJSON(map[string]interface{}{
  32750. "failed_code": -10,
  32751. "msg": err_msg,
  32752. })
  32753. return
  32754. }
  32755. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32756. userJSONBytes3, _ := json.Marshal(respJSON3)
  32757. fmt.Println("log")
  32758. fmt.Println(string(userJSONBytes3))
  32759. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32760. utils.ErrorLog("解析失败:%v", err)
  32761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32762. return
  32763. }
  32764. fmt.Println(res2.Infcode)
  32765. if res2.Infcode == -1 {
  32766. c.ServeSuccessJSON(map[string]interface{}{
  32767. "failed_code": -10,
  32768. "msg": res2.ErrMsg,
  32769. })
  32770. return
  32771. }
  32772. if res2.Infcode == 0 {
  32773. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32774. if err == nil {
  32775. c.ServeSuccessJSON(map[string]interface{}{
  32776. "msg": "撤销明细成功",
  32777. })
  32778. return
  32779. } else {
  32780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32781. return
  32782. }
  32783. } else {
  32784. c.ServeSuccessJSON(map[string]interface{}{
  32785. "failed_code": -10,
  32786. "msg": res2.ErrMsg,
  32787. })
  32788. }
  32789. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32790. if err == nil {
  32791. c.ServeSuccessJSON(map[string]interface{}{
  32792. "msg": "撤销明细成功",
  32793. })
  32794. return
  32795. } else {
  32796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32797. return
  32798. }
  32799. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32800. var resSix10265 ResultSix10265
  32801. new_chrg_bchno := order.Number
  32802. if adminUser.CurrentOrgId == 10265 {
  32803. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32804. new_chrg_bchno = "0000"
  32805. }
  32806. }
  32807. var api3 string
  32808. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32809. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32810. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32811. resp3, requestErr3 := http.Get(api3)
  32812. if requestErr3 != nil {
  32813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32814. return
  32815. }
  32816. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32817. if ioErr3 != nil {
  32818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32820. return
  32821. }
  32822. var respJSON3 map[string]interface{}
  32823. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32826. return
  32827. }
  32828. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32829. userJSONBytes3, _ := json.Marshal(respJSON3)
  32830. fmt.Println("log")
  32831. fmt.Println(string(userJSONBytes3))
  32832. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32833. utils.ErrorLog("解析失败:%v", err)
  32834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32835. return
  32836. }
  32837. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32838. res2.Output = resSix10265.Output
  32839. res2.ErrMsg = resSix10265.ErrMsg
  32840. res2.Cainfo = resSix10265.Cainfo
  32841. res2.WarnMsg = resSix10265.WarnMsg
  32842. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32843. res2.Infcode = infocode
  32844. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32845. if err == nil {
  32846. c.ServeSuccessJSON(map[string]interface{}{
  32847. "msg": "撤销明细成功",
  32848. })
  32849. return
  32850. } else {
  32851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32852. return
  32853. }
  32854. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32855. 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)
  32856. var dat map[string]interface{}
  32857. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32858. fmt.Println(dat)
  32859. } else {
  32860. fmt.Println(err)
  32861. }
  32862. saveLog(result2, src_request, "2205", "撤销明细")
  32863. userJSONBytes, _ := json.Marshal(dat)
  32864. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32865. utils.ErrorLog("解析失败:%v", err)
  32866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32867. return
  32868. }
  32869. if res2.Infcode == 0 {
  32870. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32871. if err == nil {
  32872. c.ServeSuccessJSON(map[string]interface{}{
  32873. "msg": "撤销明细成功",
  32874. })
  32875. return
  32876. } else {
  32877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32878. return
  32879. }
  32880. } else {
  32881. c.ServeSuccessJSON(map[string]interface{}{
  32882. "failed_code": -10,
  32883. "msg": res2.ErrMsg,
  32884. })
  32885. }
  32886. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32887. 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, "")
  32888. var dat map[string]interface{}
  32889. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32890. fmt.Println(dat)
  32891. } else {
  32892. fmt.Println(err)
  32893. }
  32894. saveLog(result2, src_request, "2205", "撤销明细")
  32895. userJSONBytes, _ := json.Marshal(dat)
  32896. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32897. utils.ErrorLog("解析失败:%v", err)
  32898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32899. return
  32900. }
  32901. if res2.Infcode == 0 {
  32902. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32903. if err == nil {
  32904. c.ServeSuccessJSON(map[string]interface{}{
  32905. "msg": "撤销明细成功",
  32906. })
  32907. return
  32908. } else {
  32909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32910. return
  32911. }
  32912. } else {
  32913. c.ServeSuccessJSON(map[string]interface{}{
  32914. "failed_code": -10,
  32915. "msg": res2.ErrMsg,
  32916. })
  32917. }
  32918. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32919. 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, "")
  32920. var dat map[string]interface{}
  32921. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32922. fmt.Println(dat)
  32923. } else {
  32924. fmt.Println(err)
  32925. }
  32926. saveLog(result2, src_request, "2205", "撤销明细")
  32927. userJSONBytes, _ := json.Marshal(dat)
  32928. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32929. utils.ErrorLog("解析失败:%v", err)
  32930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32931. return
  32932. }
  32933. if res2.Infcode == 0 {
  32934. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32935. if err == nil {
  32936. c.ServeSuccessJSON(map[string]interface{}{
  32937. "msg": "撤销明细成功",
  32938. })
  32939. return
  32940. } else {
  32941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32942. return
  32943. }
  32944. } else {
  32945. c.ServeSuccessJSON(map[string]interface{}{
  32946. "failed_code": -10,
  32947. "msg": res2.ErrMsg,
  32948. })
  32949. }
  32950. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32951. 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, "")
  32952. var dat map[string]interface{}
  32953. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32954. fmt.Println(dat)
  32955. } else {
  32956. fmt.Println(err)
  32957. }
  32958. saveLog(result2, src_request, "2205", "撤销明细")
  32959. userJSONBytes, _ := json.Marshal(dat)
  32960. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32961. utils.ErrorLog("解析失败:%v", err)
  32962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32963. return
  32964. }
  32965. if res2.Infcode == 0 {
  32966. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32967. if err == nil {
  32968. c.ServeSuccessJSON(map[string]interface{}{
  32969. "msg": "撤销明细成功",
  32970. })
  32971. return
  32972. } else {
  32973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32974. return
  32975. }
  32976. } else {
  32977. c.ServeSuccessJSON(map[string]interface{}{
  32978. "failed_code": -10,
  32979. "msg": res2.ErrMsg,
  32980. })
  32981. }
  32982. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32983. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  32984. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32985. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32986. resp2, requestErr2 := http.Get(api2)
  32987. if requestErr2 != nil {
  32988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32989. return
  32990. }
  32991. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32992. if ioErr2 != nil {
  32993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32995. return
  32996. }
  32997. var respJSON2 map[string]interface{}
  32998. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33001. return
  33002. }
  33003. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33004. userJSONBytes3, _ := json.Marshal(respJSON2)
  33005. fmt.Println("log")
  33006. fmt.Println(string(userJSONBytes3))
  33007. if err := json.Unmarshal(userJSONBytes3, &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 {
  33030. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33031. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33032. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33033. resp2, requestErr2 := http.Get(api2)
  33034. if requestErr2 != nil {
  33035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33036. return
  33037. }
  33038. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33039. if ioErr2 != nil {
  33040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33042. return
  33043. }
  33044. var respJSON2 map[string]interface{}
  33045. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33048. return
  33049. }
  33050. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33051. userJSONBytes3, _ := json.Marshal(respJSON2)
  33052. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33053. utils.ErrorLog("解析失败:%v", err)
  33054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33055. return
  33056. }
  33057. if res2.Infcode == -1 {
  33058. c.ServeSuccessJSON(map[string]interface{}{
  33059. "failed_code": -10,
  33060. "msg": res2.ErrMsg,
  33061. })
  33062. return
  33063. } else {
  33064. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33065. if err == nil {
  33066. c.ServeSuccessJSON(map[string]interface{}{
  33067. "msg": "撤销明细成功",
  33068. })
  33069. return
  33070. } else {
  33071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33072. return
  33073. }
  33074. }
  33075. }
  33076. } else {
  33077. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33078. if err == nil {
  33079. c.ServeSuccessJSON(map[string]interface{}{
  33080. "msg": "退费成功",
  33081. })
  33082. } else {
  33083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33084. return
  33085. }
  33086. }
  33087. }
  33088. // 对账
  33089. func (c *HisApiController) GetCheckAccount() {
  33090. start_time := c.GetString("start_time")
  33091. end_time := c.GetString("end_time")
  33092. insutype := c.GetString("insutype")
  33093. clr_type := c.GetString("clr_type")
  33094. clr_org := c.GetString("clr_optins")
  33095. admin_user_id, _ := c.GetInt64("admin_user_id")
  33096. adminUser := c.GetAdminUserInfo()
  33097. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33098. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33099. if len(clr_org) == 0 {
  33100. clr_org = miConfig.InsuplcAdmdvs
  33101. }
  33102. timeLayout := "2006-01-02"
  33103. loc, _ := time.LoadLocation("Local")
  33104. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33105. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33106. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33107. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33108. fixmedins_setl_cnt := int64(len(orders))
  33109. var medfee_sumamt float64
  33110. var acct_pay float64
  33111. var fund_pay_sumamt float64
  33112. for _, item := range orders {
  33113. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33114. acct_pay = acct_pay + item.AcctPay
  33115. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33116. }
  33117. var user_name string
  33118. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33119. if role.ID == 0 {
  33120. user_name = "xxx"
  33121. } else {
  33122. user_name = role.UserName
  33123. }
  33124. var res ResultEight
  33125. var res10188 ResultEightFor10188
  33126. if config.IsOpen == 1 {
  33127. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33128. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33129. "insutype=" + insutype +
  33130. "&clr_type=" + clr_type +
  33131. "&setl_optins=" + clr_org +
  33132. "&stmt_begndate=" + start_time +
  33133. "&stm_enddate=" + end_time +
  33134. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33135. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33136. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33137. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33138. "&fixmedins_code=" + miConfig.Code +
  33139. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33140. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33141. "&secret_key=" + miConfig.SecretKey +
  33142. "&org_name=" + miConfig.OrgName +
  33143. "&doctor=" + user_name +
  33144. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33145. fmt.Println(api)
  33146. resp, requestErr := http.Get(api)
  33147. if requestErr != nil {
  33148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33149. return
  33150. }
  33151. body, ioErr := ioutil.ReadAll(resp.Body)
  33152. fmt.Println(body)
  33153. if ioErr != nil {
  33154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33156. return
  33157. }
  33158. var respJSON map[string]interface{}
  33159. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33162. return
  33163. }
  33164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33165. userJSONBytes, _ := json.Marshal(respJSON)
  33166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33167. utils.ErrorLog("解析失败:%v", err)
  33168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33169. return
  33170. }
  33171. res.InfRefmsgid = res10188.InfRefmsgid
  33172. res.Output = res10188.Output
  33173. res.ErrMsg = res10188.ErrMsg
  33174. res.Cainfo = res10188.Cainfo
  33175. res.WarnMsg = res10188.WarnMsg
  33176. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33177. res.Infcode = infocode
  33178. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33179. if clr_type != "9903" {
  33180. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33181. }
  33182. if clr_type == "9903" {
  33183. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33184. }
  33185. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33186. "insutype=" + insutype +
  33187. "&clr_type=" + clr_type +
  33188. "&setl_optins=" + clr_org +
  33189. "&stmt_begndate=" + start_time +
  33190. "&stm_enddate=" + end_time +
  33191. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33192. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33193. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33194. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33195. "&fixmedins_code=" + miConfig.Code +
  33196. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33197. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33198. "&secret_key=" + miConfig.SecretKey +
  33199. "&org_name=" + miConfig.OrgName +
  33200. "&doctor=" + user_name
  33201. resp, requestErr := http.Get(api)
  33202. if requestErr != nil {
  33203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33204. return
  33205. }
  33206. body, ioErr := ioutil.ReadAll(resp.Body)
  33207. if ioErr != nil {
  33208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33210. return
  33211. }
  33212. var respJSON map[string]interface{}
  33213. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33216. return
  33217. }
  33218. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33219. result, _ := json.Marshal(respJSON)
  33220. fmt.Println("log")
  33221. fmt.Println(string(result))
  33222. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33223. utils.ErrorLog("解析失败:%v", err)
  33224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33225. return
  33226. }
  33227. res.InfRefmsgid = res10188.InfRefmsgid
  33228. res.Output = res10188.Output
  33229. res.ErrMsg = res10188.ErrMsg
  33230. res.Cainfo = res10188.Cainfo
  33231. res.WarnMsg = res10188.WarnMsg
  33232. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33233. res.Infcode = infocode
  33234. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33235. var baseParams models.BaseParams
  33236. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33237. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33238. baseParams.SecretKey = miConfig.SecretKey
  33239. baseParams.OrgName = miConfig.OrgName
  33240. baseParams.FixmedinsCode = miConfig.Code
  33241. baseParams.EncKey = miConfig.EncKey
  33242. baseParams.AppSecret = miConfig.AppSecret
  33243. baseParams.SignKey = miConfig.SignKey
  33244. baseParams.AppID = miConfig.Code
  33245. baseParams.Doctor = role.UserName
  33246. baseParams.RequestUrl = miConfig.Url
  33247. businessParams := models.BusinessParams{
  33248. Insutype: insutype,
  33249. ClrType: clr_type,
  33250. SetlOptins: clr_org,
  33251. StmtBegndate: start_time,
  33252. StmtEnddate: end_time,
  33253. MedfeeSumamt: medfee_sumamt,
  33254. FundPaySumamt: fund_pay_sumamt,
  33255. AcctPay: acct_pay,
  33256. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33257. }
  33258. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33259. fmt.Println(requestLog)
  33260. fmt.Println(result)
  33261. fmt.Println(err_msg)
  33262. var dat map[string]interface{}
  33263. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33264. fmt.Println(dat)
  33265. } else {
  33266. fmt.Println(err)
  33267. }
  33268. userJSONBytes, _ := json.Marshal(dat)
  33269. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33270. utils.ErrorLog("解析失败:%v", err)
  33271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33272. return
  33273. }
  33274. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33275. var baseParams models.BaseParams
  33276. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33277. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33278. baseParams.SecretKey = miConfig.SecretKey
  33279. baseParams.OrgName = miConfig.OrgName
  33280. baseParams.FixmedinsCode = miConfig.Code
  33281. baseParams.EncKey = miConfig.EncKey
  33282. baseParams.AppSecret = miConfig.AppSecret
  33283. baseParams.SignKey = miConfig.SignKey
  33284. baseParams.AppID = miConfig.Code
  33285. baseParams.Doctor = role.UserName
  33286. baseParams.RequestUrl = miConfig.Url
  33287. baseParams.AccessKey = miConfig.AccessKey
  33288. businessParams := models.BusinessParams{
  33289. Insutype: insutype,
  33290. ClrType: clr_type,
  33291. SetlOptins: "430822",
  33292. StmtBegndate: start_time,
  33293. StmtEnddate: end_time,
  33294. MedfeeSumamt: medfee_sumamt,
  33295. FundPaySumamt: fund_pay_sumamt,
  33296. AcctPay: acct_pay,
  33297. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33298. }
  33299. 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)
  33300. fmt.Println(requestLog)
  33301. fmt.Println(result)
  33302. var dat map[string]interface{}
  33303. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33304. fmt.Println(dat)
  33305. } else {
  33306. fmt.Println(err)
  33307. }
  33308. userJSONBytes, _ := json.Marshal(dat)
  33309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33310. utils.ErrorLog("解析失败:%v", err)
  33311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33312. return
  33313. }
  33314. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33315. var baseParams models.BaseParams
  33316. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33317. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33318. baseParams.SecretKey = miConfig.SecretKey
  33319. baseParams.OrgName = miConfig.OrgName
  33320. baseParams.FixmedinsCode = miConfig.Code
  33321. baseParams.EncKey = miConfig.EncKey
  33322. baseParams.AppSecret = miConfig.AppSecret
  33323. baseParams.SignKey = miConfig.SignKey
  33324. baseParams.AppID = miConfig.Code
  33325. baseParams.Doctor = role.UserName
  33326. baseParams.RequestUrl = miConfig.Url
  33327. businessParams := models.BusinessParams{
  33328. Insutype: insutype,
  33329. ClrType: clr_type,
  33330. SetlOptins: clr_org,
  33331. StmtBegndate: start_time,
  33332. StmtEnddate: end_time,
  33333. MedfeeSumamt: medfee_sumamt,
  33334. FundPaySumamt: fund_pay_sumamt,
  33335. AcctPay: acct_pay,
  33336. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33337. }
  33338. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33339. fmt.Println(requestLog)
  33340. fmt.Println(result)
  33341. fmt.Println(err_msg)
  33342. var dat map[string]interface{}
  33343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33344. fmt.Println(dat)
  33345. } else {
  33346. fmt.Println(err)
  33347. }
  33348. userJSONBytes, _ := json.Marshal(dat)
  33349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33350. utils.ErrorLog("解析失败:%v", err)
  33351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33352. return
  33353. }
  33354. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33355. if len(clr_type) == 0 {
  33356. clr_type = "11"
  33357. }
  33358. api := miConfig.Url + "gdyb/ten?" +
  33359. "insutype=" + insutype +
  33360. "&clr_type=" + clr_type +
  33361. "&setl_optins=" + clr_org +
  33362. "&stmt_begndate=" + start_time +
  33363. "&stm_enddate=" + end_time +
  33364. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33365. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33366. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33367. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33368. "&fixmedins_code=" + miConfig.Code +
  33369. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33370. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33371. "&secret_key=" + miConfig.SecretKey +
  33372. "&org_name=" + miConfig.OrgName +
  33373. "&doctor=" + user_name
  33374. fmt.Println(api)
  33375. resp, requestErr := http.Get(api)
  33376. if requestErr != nil {
  33377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33378. return
  33379. }
  33380. body, ioErr := ioutil.ReadAll(resp.Body)
  33381. fmt.Println(body)
  33382. if ioErr != nil {
  33383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33385. return
  33386. }
  33387. var respJSON map[string]interface{}
  33388. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33391. return
  33392. }
  33393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33394. userJSONBytes, _ := json.Marshal(respJSON)
  33395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33396. utils.ErrorLog("解析失败:%v", err)
  33397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33398. return
  33399. }
  33400. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33401. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33402. //fixmedins_setl_cnt := int64(len(orders_two))
  33403. //var medfee_sumamt float64
  33404. //var acct_pay float64
  33405. //var fund_pay_sumamt float64
  33406. //for _, item := range orders_two {
  33407. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33408. // acct_pay = acct_pay + item.AcctPay
  33409. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33410. //}
  33411. var baseParams models.BaseParams
  33412. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33413. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33414. baseParams.SecretKey = miConfig.SecretKey
  33415. baseParams.OrgName = miConfig.OrgName
  33416. baseParams.FixmedinsCode = miConfig.Code
  33417. baseParams.EncKey = miConfig.EncKey
  33418. baseParams.AppSecret = miConfig.AppSecret
  33419. baseParams.SignKey = miConfig.SignKey
  33420. baseParams.AppID = miConfig.Code
  33421. baseParams.Doctor = role.UserName
  33422. baseParams.RequestUrl = miConfig.Url
  33423. if clr_type == "9903" {
  33424. clr_type = "9994"
  33425. }
  33426. businessParams := models.BusinessParams{
  33427. Insutype: insutype,
  33428. ClrType: clr_type,
  33429. SetlOptins: "360302",
  33430. StmtBegndate: start_time,
  33431. StmtEnddate: end_time,
  33432. MedfeeSumamt: 0,
  33433. FundPaySumamt: 0,
  33434. AcctPay: 0,
  33435. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33436. }
  33437. 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))
  33438. fmt.Println(requestLog)
  33439. fmt.Println(result)
  33440. var dat map[string]interface{}
  33441. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33442. fmt.Println(dat)
  33443. } else {
  33444. fmt.Println(err)
  33445. }
  33446. userJSONBytes, _ := json.Marshal(dat)
  33447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33448. utils.ErrorLog("解析失败:%v", err)
  33449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33450. return
  33451. }
  33452. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33453. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33454. fixmedins_setl_cnt := int64(len(orders_two))
  33455. var medfee_sumamt float64
  33456. var acct_pay float64
  33457. var fund_pay_sumamt float64
  33458. for _, item := range orders_two {
  33459. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33460. acct_pay = acct_pay + item.AcctPay
  33461. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33462. }
  33463. var baseParams models.BaseParams
  33464. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33465. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33466. baseParams.SecretKey = miConfig.SecretKey
  33467. baseParams.OrgName = miConfig.OrgName
  33468. baseParams.FixmedinsCode = miConfig.Code
  33469. baseParams.EncKey = miConfig.EncKey
  33470. baseParams.AppSecret = miConfig.AppSecret
  33471. baseParams.SignKey = miConfig.SignKey
  33472. baseParams.AppID = miConfig.Code
  33473. baseParams.Doctor = role.UserName
  33474. baseParams.RequestUrl = miConfig.Url
  33475. if clr_type == "9903" {
  33476. clr_type = "9994"
  33477. }
  33478. businessParams := models.BusinessParams{
  33479. Insutype: insutype,
  33480. ClrType: clr_type,
  33481. SetlOptins: "361025",
  33482. StmtBegndate: start_time,
  33483. StmtEnddate: end_time,
  33484. MedfeeSumamt: 0,
  33485. FundPaySumamt: 0,
  33486. AcctPay: 0,
  33487. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33488. }
  33489. 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))
  33490. fmt.Println(requestLog)
  33491. fmt.Println(result)
  33492. var dat map[string]interface{}
  33493. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33494. fmt.Println(dat)
  33495. } else {
  33496. fmt.Println(err)
  33497. }
  33498. userJSONBytes, _ := json.Marshal(dat)
  33499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33500. utils.ErrorLog("解析失败:%v", err)
  33501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33502. return
  33503. }
  33504. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33505. var api string
  33506. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33507. "&clr_type=" + clr_type +
  33508. "&setl_optins=" + clr_org +
  33509. "&stmt_begndate=" + start_time +
  33510. "&stm_enddate=" + end_time +
  33511. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33512. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33513. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33514. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33515. "&fixmedins_code=" + miConfig.Code +
  33516. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33517. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33518. "&secret_key=" + miConfig.SecretKey +
  33519. "&org_name=" + miConfig.OrgName +
  33520. "&doctor=" + user_name + "&url=" + miConfig.Url
  33521. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33522. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33523. resp, requestErr := http.Get(api)
  33524. if requestErr != nil {
  33525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33526. return
  33527. }
  33528. body, ioErr := ioutil.ReadAll(resp.Body)
  33529. if ioErr != nil {
  33530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33532. return
  33533. }
  33534. var respJSON map[string]interface{}
  33535. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33538. return
  33539. }
  33540. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33541. if status == "0" {
  33542. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33543. c.ServeSuccessJSON(map[string]interface{}{
  33544. "failed_code": -10,
  33545. "msg": err_msg,
  33546. })
  33547. return
  33548. }
  33549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33550. userJSONBytes, _ := json.Marshal(respJSON)
  33551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33552. utils.ErrorLog("解析失败:%v", err)
  33553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33554. return
  33555. }
  33556. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33557. var api string
  33558. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33559. "&clr_type=" + clr_type +
  33560. "&setl_optins=" + clr_org +
  33561. "&stmt_begndate=" + start_time +
  33562. "&stm_enddate=" + end_time +
  33563. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33564. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33565. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33566. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33567. "&fixmedins_code=" + miConfig.Code +
  33568. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33569. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33570. "&secret_key=" + miConfig.SecretKey +
  33571. "&org_name=" + miConfig.OrgName +
  33572. "&doctor=" + user_name + "&url=" + miConfig.Url
  33573. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33574. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33575. resp, requestErr := http.Get(api)
  33576. if requestErr != nil {
  33577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33578. return
  33579. }
  33580. body, ioErr := ioutil.ReadAll(resp.Body)
  33581. if ioErr != nil {
  33582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33584. return
  33585. }
  33586. var respJSON map[string]interface{}
  33587. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33590. return
  33591. }
  33592. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33593. if status == "0" {
  33594. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33595. c.ServeSuccessJSON(map[string]interface{}{
  33596. "failed_code": -10,
  33597. "msg": err_msg,
  33598. })
  33599. return
  33600. }
  33601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33602. userJSONBytes, _ := json.Marshal(respJSON)
  33603. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33604. utils.ErrorLog("解析失败:%v", err)
  33605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33606. return
  33607. }
  33608. } else {
  33609. if len(clr_type) == 0 {
  33610. clr_type = "11"
  33611. }
  33612. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33613. "insutype=" + insutype +
  33614. "&clr_type=" + clr_type +
  33615. "&setl_optins=" + clr_org +
  33616. "&stmt_begndate=" + start_time +
  33617. "&stm_enddate=" + end_time +
  33618. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33619. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33620. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33621. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33622. "&fixmedins_code=" + miConfig.Code +
  33623. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33624. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33625. "&secret_key=" + miConfig.SecretKey +
  33626. "&org_name=" + miConfig.OrgName +
  33627. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33628. fmt.Println(api)
  33629. resp, requestErr := http.Get(api)
  33630. if requestErr != nil {
  33631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33632. return
  33633. }
  33634. body, ioErr := ioutil.ReadAll(resp.Body)
  33635. fmt.Println(body)
  33636. if ioErr != nil {
  33637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33639. return
  33640. }
  33641. var respJSON map[string]interface{}
  33642. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33645. return
  33646. }
  33647. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33648. userJSONBytes, _ := json.Marshal(respJSON)
  33649. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33650. utils.ErrorLog("解析失败:%v", err)
  33651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33652. return
  33653. }
  33654. }
  33655. if res.Infcode == 0 {
  33656. if res.Output.Stmtinfo.StmtRslt == "0" {
  33657. micc := &models.MedicalInsuranceCostCompare{
  33658. StartTime: startime.Unix(),
  33659. EndTime: endtime.Unix(),
  33660. Insutype: insutype,
  33661. CheckType: 1,
  33662. Num: fixmedins_setl_cnt,
  33663. Mtime: time.Now().Unix(),
  33664. Status: 1,
  33665. UserOrgId: adminUser.CurrentOrgId,
  33666. CostTotal: medfee_sumamt,
  33667. FuncTotal: fund_pay_sumamt,
  33668. PsnPay: acct_pay,
  33669. Creator: admin_user_id,
  33670. Ctime: time.Now().Unix(),
  33671. ClrType: clr_type,
  33672. }
  33673. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33674. if err == nil {
  33675. c.ServeSuccessJSON(map[string]interface{}{
  33676. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33677. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33678. })
  33679. } else {
  33680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33681. }
  33682. } else {
  33683. c.ServeSuccessJSON(map[string]interface{}{
  33684. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33685. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33686. })
  33687. }
  33688. } else {
  33689. c.ServeSuccessJSON(map[string]interface{}{
  33690. "failed_code": -10,
  33691. "msg": res.ErrMsg,
  33692. })
  33693. }
  33694. }
  33695. }
  33696. func (c *HisApiController) Check310() {
  33697. adminUser := c.GetAdminUserInfo()
  33698. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33699. var user_name string
  33700. user_name = "高慧裕"
  33701. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33702. "insutype=" + "310" +
  33703. "&clr_type=" + "" +
  33704. "&setl_optins=" + "441202" +
  33705. "&stmt_begndate=" + "2022-03-01" +
  33706. "&stm_enddate=" + "2022-03-31" +
  33707. "&medfee_sumamt=" + "194930.12" +
  33708. "&fund_pay_sumamt=" + "188741.46" +
  33709. "&acct_pay=" + "0" +
  33710. "&fixmedins_setl_cnt=" + "452" +
  33711. "&fixmedins_code=" + miConfig.Code +
  33712. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33713. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33714. "&secret_key=" + miConfig.SecretKey +
  33715. "&org_name=" + miConfig.OrgName +
  33716. "&doctor=" + user_name
  33717. fmt.Println(api)
  33718. resp, requestErr := http.Get(api)
  33719. if requestErr != nil {
  33720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33721. return
  33722. }
  33723. body, ioErr := ioutil.ReadAll(resp.Body)
  33724. fmt.Println(body)
  33725. if ioErr != nil {
  33726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33728. return
  33729. }
  33730. var respJSON map[string]interface{}
  33731. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33734. return
  33735. }
  33736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33737. userJSONBytes, _ := json.Marshal(respJSON)
  33738. var res ResultEight
  33739. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33740. utils.ErrorLog("解析失败:%v", err)
  33741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33742. return
  33743. }
  33744. }
  33745. func (c *HisApiController) Check390() {
  33746. adminUser := c.GetAdminUserInfo()
  33747. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33748. var user_name string
  33749. user_name = "高慧裕"
  33750. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33751. "insutype=" + "390" +
  33752. "&clr_type=" + "" +
  33753. "&setl_optins=" + "441202" +
  33754. "&stmt_begndate=" + "2022-03-01" +
  33755. "&stm_enddate=" + "2022-03-31" +
  33756. "&medfee_sumamt=" + "1068448.89" +
  33757. "&fund_pay_sumamt=" + "1014677.62" +
  33758. "&acct_pay=" + "0" +
  33759. "&fixmedins_setl_cnt=" + "1950" +
  33760. "&fixmedins_code=" + miConfig.Code +
  33761. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33762. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33763. "&secret_key=" + miConfig.SecretKey +
  33764. "&org_name=" + miConfig.OrgName +
  33765. "&doctor=" + user_name
  33766. fmt.Println(api)
  33767. resp, requestErr := http.Get(api)
  33768. if requestErr != nil {
  33769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33770. return
  33771. }
  33772. body, ioErr := ioutil.ReadAll(resp.Body)
  33773. fmt.Println(body)
  33774. if ioErr != nil {
  33775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33777. return
  33778. }
  33779. var respJSON map[string]interface{}
  33780. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33783. return
  33784. }
  33785. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33786. userJSONBytes, _ := json.Marshal(respJSON)
  33787. var res ResultEight
  33788. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33789. utils.ErrorLog("解析失败:%v", err)
  33790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33791. return
  33792. }
  33793. }
  33794. // 对账明细
  33795. func (c *HisApiController) GetCheckDetailAccount() {
  33796. start_time := c.GetString("start_time")
  33797. end_time := c.GetString("end_time")
  33798. admin_user_id, _ := c.GetInt64("admin_user_id")
  33799. adminUser := c.GetAdminUserInfo()
  33800. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33801. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33802. timeLayout := "2006-01-02"
  33803. loc, _ := time.LoadLocation("Local")
  33804. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33805. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33806. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33807. rand.Seed(time.Now().UnixNano())
  33808. num := rand.Intn(30000)
  33809. Mkdir(miConfig.OrgName)
  33810. file := strconv.FormatInt(int64(num), 10)
  33811. file_name := file + ".txt"
  33812. zip_name := file + ".zip"
  33813. zip_path := miConfig.OrgName + "/" + zip_name
  33814. file_path := miConfig.OrgName + "/" + file_name
  33815. decimal.DivisionPrecision = 2
  33816. var medfee_sumamt float64
  33817. var psn_cash_pay float64
  33818. var fund_pay_sumamt float64
  33819. fixmedins_setl_cnt := int64(len(orders))
  33820. for _, item := range orders {
  33821. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33822. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  33823. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33824. }
  33825. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  33826. defer f.Close()
  33827. if err != nil {
  33828. fmt.Println(err.Error())
  33829. } else {
  33830. for _, item := range orders {
  33831. var refd_setl_flag string
  33832. if item.OrderStatus == 2 {
  33833. refd_setl_flag = "0"
  33834. var str string
  33835. str = item.SetlId + " " +
  33836. item.MdtrtId + " " +
  33837. item.PsnNo + " " +
  33838. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33839. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33840. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  33841. _, err = f.Write([]byte(str))
  33842. }
  33843. if item.OrderStatus == 3 {
  33844. var str string
  33845. str = item.SetlId + " " +
  33846. item.MdtrtId + " " +
  33847. item.PsnNo + " " +
  33848. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33849. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33850. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  33851. _, err = f.Write([]byte(str))
  33852. var str2 string
  33853. str2 = item.SetlId + " " +
  33854. item.MdtrtId + " " +
  33855. item.PsnNo + " " +
  33856. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  33857. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  33858. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  33859. _, err = f.Write([]byte(str2))
  33860. }
  33861. }
  33862. }
  33863. Zip(file_path, zip_path)
  33864. fmt.Println(ReadFile(zip_path))
  33865. fmt.Println(string(ReadFile(zip_path)))
  33866. if config.IsOpen == 1 {
  33867. var user_name string
  33868. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33869. if role.ID == 0 {
  33870. user_name = "管理员"
  33871. } else {
  33872. user_name = role.UserName
  33873. }
  33874. baseParams := models.BaseParams{
  33875. SecretKey: miConfig.SecretKey,
  33876. FixmedinsCode: miConfig.Code,
  33877. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33878. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33879. OrgName: miConfig.OrgName,
  33880. Doctor: user_name,
  33881. }
  33882. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  33883. var dat map[string]interface{}
  33884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33885. fmt.Println(dat)
  33886. } else {
  33887. fmt.Println(err)
  33888. }
  33889. userJSONBytes, _ := json.Marshal(dat)
  33890. var res ResultNine
  33891. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33892. utils.ErrorLog("解析失败:%v", err)
  33893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33894. return
  33895. }
  33896. if res.Infcode == 0 {
  33897. fileNo := res.Output.FileQuryNo
  33898. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  33899. "file_qury_no=" + fileNo +
  33900. "&setl_optins=" + "定点医保中心" +
  33901. "&stmt_begndate=" + start_time +
  33902. "&stm_enddate=" + end_time +
  33903. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33904. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33905. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  33906. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33907. "&fixmedins_code=" + miConfig.Code +
  33908. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33909. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33910. "&secret_key=" + miConfig.SecretKey +
  33911. "&org_name=" + miConfig.OrgName +
  33912. "&doctor=" + user_name
  33913. resp, requestErr := http.Get(api)
  33914. if requestErr != nil {
  33915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33916. return
  33917. }
  33918. body, ioErr := ioutil.ReadAll(resp.Body)
  33919. if ioErr != nil {
  33920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33922. return
  33923. }
  33924. var respJSON map[string]interface{}
  33925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33928. return
  33929. }
  33930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33931. userJSONBytes, _ := json.Marshal(respJSON)
  33932. var res ResultTen
  33933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33934. utils.ErrorLog("解析失败:%v", err)
  33935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33936. return
  33937. }
  33938. if res.Infcode == 0 {
  33939. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  33940. micc := &models.MedicalInsuranceCostCompare{
  33941. StartTime: startime.Unix(),
  33942. EndTime: endtime.Unix(),
  33943. Insutype: "0",
  33944. CheckType: 2,
  33945. Num: fixmedins_setl_cnt,
  33946. Mtime: time.Now().Unix(),
  33947. Status: 1,
  33948. UserOrgId: adminUser.CurrentOrgId,
  33949. CostTotal: medfee_sumamt,
  33950. FuncTotal: fund_pay_sumamt,
  33951. PsnPay: psn_cash_pay,
  33952. Creator: admin_user_id,
  33953. Ctime: time.Now().Unix(),
  33954. }
  33955. service.CreateMedicalInsuranceCostCompareRecord(micc)
  33956. c.ServeSuccessJSON(map[string]interface{}{
  33957. "msg": "明细对账成功",
  33958. })
  33959. }
  33960. } else {
  33961. }
  33962. }
  33963. }
  33964. type CustomOrderInfo struct {
  33965. Name string
  33966. Spec string
  33967. Unit string
  33968. Count float64
  33969. Price float64
  33970. Total float64
  33971. }
  33972. func (c *HisApiController) GetBatchSettleAccounts() {
  33973. admin_user_id, _ := c.GetInt64("admin_user_id")
  33974. order_ids := c.GetString("order_ids")
  33975. order_ids_arr := strings.Split(order_ids, ",")
  33976. data3 := []map[string]interface{}{}
  33977. for _, item := range order_ids_arr {
  33978. id, _ := strconv.ParseInt(item, 10, 64)
  33979. order_id := id
  33980. adminUser := c.GetAdminUserInfo()
  33981. order, _ := service.GetHisOrderByID(order_id)
  33982. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33983. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  33984. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  33985. orderInfos = append(orderInfos, orderInfos_two...)
  33986. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  33987. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  33988. var diagnosis_ids []string
  33989. if his.ID > 0 {
  33990. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  33991. } else {
  33992. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  33993. }
  33994. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  33995. var dia_config []*models.HisXtDiagnoseConfig
  33996. var name string
  33997. for _, item := range diagnosis_ids {
  33998. id, _ := strconv.ParseInt(item, 10, 64)
  33999. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34000. dia_config = append(dia_config, &diagnosisConfig)
  34001. if len(name) == 0 {
  34002. name = diagnosisConfig.ClassName
  34003. }
  34004. //} else {
  34005. // name = name + "," + diagnosisConfig.ClassName
  34006. //}
  34007. }
  34008. var bedCostTotal float64 = 0 //床位总费
  34009. var bedCostSelfTotal float64 = 0 //床位自费
  34010. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34011. var bedSelfTotal float64 = 0 //床位部分项目自费
  34012. var bedInscpTotal float64 = 0 //床位部分项目自费
  34013. var operationCostTotal float64 = 0 //手术费
  34014. var operationCostSelfTotal float64 = 0 //手术费
  34015. var operationCostPartSelfTotal float64 = 0 //手术费
  34016. var operationSelfTotal float64 = 0 //床位部分项目自费
  34017. var operationInscpTotal float64 = 0 //床位部分项目自费
  34018. var otherCostTotal float64 = 0 //其他费用
  34019. var otherCostSelfTotal float64 = 0 //其他费用
  34020. var otherCostPartSelfTotal float64 = 0 //其他费用
  34021. var otherSelfTotal float64 = 0 //床位部分项目自费
  34022. var otherInscpTotal float64 = 0 //床位部分项目自费
  34023. var materialCostTotal float64 = 0 //材料费
  34024. var materialCostSelfTotal float64 = 0 //材料费
  34025. var materialCostPartSelfTotal float64 = 0 //材料费
  34026. var materialSelfTotal float64 = 0 //床位部分项目自费
  34027. var materialInscpTotal float64 = 0 //床位部分项目自费
  34028. var westernMedicineCostTotal float64 = 0 //西药费
  34029. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34030. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34031. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34032. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34033. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34034. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34035. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34036. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34037. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34038. var checkCostTotal float64 = 0 //检查费
  34039. var checkCostSelfTotal float64 = 0 //检查费
  34040. var checkCostPartSelfTotal float64 = 0 //检查费
  34041. var checkSelfTotal float64 = 0 //床位部分项目自费
  34042. var checkInscpTotal float64 = 0 //床位部分项目自费
  34043. var laboratoryCostTotal float64 = 0 //化验费
  34044. var laboratoryCostSelfTotal float64 = 0 //化验费
  34045. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34046. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34047. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34048. var treatCostTotal float64 = 0 //治疗费用
  34049. var treatCostSelfTotal float64 = 0 //治疗费用
  34050. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34051. var treatSelfTotal float64 = 0 //床位部分项目自费
  34052. var treatInscpTotal float64 = 0 //床位部分项目自费
  34053. decimal.DivisionPrecision = 2
  34054. for _, item := range orderInfos {
  34055. if item.MedChrgitmType == "01" { //床位费
  34056. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34057. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34058. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34059. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34060. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34061. }
  34062. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34063. if item.MedChrgitmType == "03" { //检查费
  34064. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34065. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34066. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34067. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34068. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34069. }
  34070. } else {
  34071. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34072. fmt.Println("------------")
  34073. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34074. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34075. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34076. }
  34077. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34078. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34079. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34080. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34081. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34082. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34083. }
  34084. }
  34085. if item.MedChrgitmType == "04" { //化验费
  34086. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34087. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34088. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34089. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34090. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34091. }
  34092. if item.MedChrgitmType == "05" { //治疗费
  34093. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34094. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34095. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34096. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34097. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34098. }
  34099. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34100. fmt.Println("------------")
  34101. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34102. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34103. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34104. }
  34105. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34106. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34107. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34108. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34109. }
  34110. //if item.MedChrgitmType == "06" { //手术费
  34111. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34112. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34113. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34114. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34115. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34116. //
  34117. //}
  34118. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34119. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34120. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34121. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34122. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34123. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34124. }
  34125. if item.MedChrgitmType == "09" { //西药费
  34126. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34127. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34128. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34129. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34130. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34131. }
  34132. if item.MedChrgitmType == "11" { //中成费
  34133. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34134. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34135. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34136. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34137. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34138. }
  34139. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34140. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34141. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34142. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34143. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34144. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34145. }
  34146. }
  34147. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34148. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34149. var user_name string
  34150. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34151. if role.ID == 0 {
  34152. user_name = "管理员"
  34153. } else {
  34154. user_name = role.UserName
  34155. }
  34156. baseParams := models.BaseParams{
  34157. SecretKey: miConfig.SecretKey,
  34158. FixmedinsCode: miConfig.Code,
  34159. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34160. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34161. OrgName: miConfig.OrgName,
  34162. Doctor: user_name,
  34163. RequestUrl: miConfig.Url,
  34164. AccessKey: miConfig.AccessKey,
  34165. }
  34166. businessParams := models.BusinessParams{
  34167. PsnNo: order.PsnNo,
  34168. MdtrtId: order.MdtrtId,
  34169. SetlId: order.SetlId,
  34170. }
  34171. var res ResultEleven
  34172. var resEleven10265 ResultEleven10265
  34173. if config.IsOpen == 1 {
  34174. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34175. result := service.Gdyb5203(baseParams, businessParams)
  34176. service.Gdyb5204(baseParams, businessParams)
  34177. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34178. var dat map[string]interface{}
  34179. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34180. fmt.Println(dat)
  34181. } else {
  34182. fmt.Println(err)
  34183. }
  34184. userJSONBytes, _ := json.Marshal(dat)
  34185. if miConfig.Code == "H15049901371" {
  34186. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34187. utils.ErrorLog("解析失败:%v", err)
  34188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34189. return
  34190. }
  34191. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34192. res.Output = resEleven10265.Output
  34193. res.ErrMsg = resEleven10265.ErrMsg
  34194. res.Cainfo = resEleven10265.Cainfo
  34195. res.WarnMsg = resEleven10265.WarnMsg
  34196. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34197. res.Infcode = infocode
  34198. } else {
  34199. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34200. utils.ErrorLog("解析失败:%v", err)
  34201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34202. return
  34203. }
  34204. }
  34205. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34206. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34207. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34208. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34209. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34210. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34211. var doctor_name string
  34212. if roles.ID == 0 {
  34213. doctor_name = "管理员"
  34214. } else {
  34215. doctor_name = roles.UserName
  34216. }
  34217. yiliao_leibie := ""
  34218. switch order.MedType {
  34219. case "11":
  34220. yiliao_leibie = "普通门诊"
  34221. break
  34222. case "12":
  34223. yiliao_leibie = "门诊挂号"
  34224. break
  34225. case "13":
  34226. yiliao_leibie = "急诊"
  34227. break
  34228. case "14":
  34229. yiliao_leibie = "门诊特殊病"
  34230. break
  34231. case "15":
  34232. yiliao_leibie = "门诊统筹"
  34233. break
  34234. case "16":
  34235. yiliao_leibie = "门诊慢性病"
  34236. break
  34237. case "21":
  34238. yiliao_leibie = "普通住院"
  34239. break
  34240. }
  34241. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34242. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34243. if res.Infcode == 0 {
  34244. data2 := map[string]interface{}{
  34245. "diagnosis": name,
  34246. "order_infos": orderInfos,
  34247. "number": order.MdtrtId,
  34248. "date": order.SettleAccountsDate,
  34249. "charge_admin": charge_admin,
  34250. "printor_admin": printor_admin,
  34251. "info": res.Output.Setlinfo,
  34252. "order": order,
  34253. "bedCostTotal": bedCostTotal,
  34254. "bedCostSelfTotal": bedCostSelfTotal,
  34255. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34256. "bedSelfTotal": bedSelfTotal,
  34257. "bedInscpTotal": bedInscpTotal,
  34258. "operationCostTotal": operationCostTotal,
  34259. "operationCostSelfTotal": operationCostSelfTotal,
  34260. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34261. "operationSelfTotal": operationSelfTotal,
  34262. "operationInscpTotal": operationInscpTotal,
  34263. "otherCostTotal": otherCostTotal,
  34264. "otherCostSelfTotal": otherCostSelfTotal,
  34265. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34266. "otherSelfTotal": otherSelfTotal,
  34267. "otherInscpTotal": otherInscpTotal,
  34268. "materialCostTotal": materialCostTotal,
  34269. "materialCostSelfTotal": materialCostSelfTotal,
  34270. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34271. "materialSelfTotal": materialSelfTotal,
  34272. "materialInscpTotal": materialInscpTotal,
  34273. "westernMedicineCostTotal": westernMedicineCostTotal,
  34274. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34275. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34276. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34277. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34278. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34279. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34280. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34281. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34282. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34283. "checkCostTotal": checkCostTotal,
  34284. "checkCostSelfTotal": checkCostSelfTotal,
  34285. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34286. "checkSelfTotal": checkSelfTotal,
  34287. "checkInscpTotal": checkInscpTotal,
  34288. "laboratoryCostTotal": laboratoryCostTotal,
  34289. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34290. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34291. "laboratorySelfTotal": laboratorySelfTotal,
  34292. "laboratoryInscpTotal": laboratoryInscpTotal,
  34293. "treatCostTotal": treatCostTotal,
  34294. "treatCostSelfTotal": treatCostSelfTotal,
  34295. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34296. "treatSelfTotal": treatSelfTotal,
  34297. "treatInscpTotal": treatInscpTotal,
  34298. "doctor_info": doctor_info,
  34299. "doctor_code": adminRole_two.DoctorCode,
  34300. "doctor_name": doctor_name,
  34301. "health_card_no": order.PsnNo,
  34302. "department": departments.Name,
  34303. "yiliao_leibie": yiliao_leibie,
  34304. "after_money": order.AccountPrice,
  34305. "patient": patient,
  34306. "org_name": miConfig.OrgName,
  34307. "org_code": miConfig.Code,
  34308. "order_number": order.Number,
  34309. "his_hospital": his_hospital,
  34310. "his": his,
  34311. "dia_config": dia_config,
  34312. "psn_cash_pay": order.PsnCashPay,
  34313. //"check_order_info": cus_slice,
  34314. }
  34315. data3 = append(data3, data2)
  34316. }
  34317. }
  34318. }
  34319. c.ServeSuccessJSON(map[string]interface{}{
  34320. "infos": data3,
  34321. })
  34322. }
  34323. func (c *HisApiController) GetSettleAccounts() {
  34324. //id, _ := c.GetInt64("id")
  34325. //record_time := c.GetString("record_time")
  34326. order_id, _ := c.GetInt64("order_id")
  34327. admin_user_id, _ := c.GetInt64("admin_user_id")
  34328. //timeLayout := "2006-01-02"
  34329. //loc, _ := time.LoadLocation("Local")
  34330. //
  34331. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34332. //if err != nil {
  34333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34334. // return
  34335. //}Hbyb5203
  34336. //recordDateTime := theTime.Unix()
  34337. adminUser := c.GetAdminUserInfo()
  34338. order, _ := service.GetHisOrderByID(order_id)
  34339. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34340. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34341. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34342. orderInfos = append(orderInfos, orderInfos_two...)
  34343. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34344. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34345. var diagnosis_ids []string
  34346. if his.ID > 0 {
  34347. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34348. } else {
  34349. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34350. }
  34351. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34352. var dia_config []*models.HisXtDiagnoseConfig
  34353. var name string
  34354. for _, item := range diagnosis_ids {
  34355. id, _ := strconv.ParseInt(item, 10, 64)
  34356. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34357. dia_config = append(dia_config, &diagnosisConfig)
  34358. if len(name) == 0 {
  34359. name = diagnosisConfig.ClassName
  34360. } else {
  34361. name = name + "," + diagnosisConfig.ClassName
  34362. }
  34363. }
  34364. if patient.UserOrgId == 10215 {
  34365. name = "慢性肾功能不全(血透治疗)"
  34366. }
  34367. var bedCostTotal float64 = 0 //床位总费
  34368. var bedCostSelfTotal float64 = 0 //床位自费
  34369. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34370. var bedSelfTotal float64 = 0 //床位部分项目自费
  34371. var bedInscpTotal float64 = 0 //床位部分项目自费
  34372. var operationCostTotal float64 = 0 //手术费
  34373. var operationCostSelfTotal float64 = 0 //手术费
  34374. var operationCostPartSelfTotal float64 = 0 //手术费
  34375. var operationSelfTotal float64 = 0 //床位部分项目自费
  34376. var operationInscpTotal float64 = 0 //床位部分项目自费
  34377. var otherCostTotal float64 = 0 //其他费用
  34378. var otherCostSelfTotal float64 = 0 //其他费用
  34379. var otherCostPartSelfTotal float64 = 0 //其他费用
  34380. var otherSelfTotal float64 = 0 //床位部分项目自费
  34381. var otherInscpTotal float64 = 0 //床位部分项目自费
  34382. var materialCostTotal float64 = 0 //材料费
  34383. var materialCostSelfTotal float64 = 0 //材料费
  34384. var materialCostPartSelfTotal float64 = 0 //材料费
  34385. var materialSelfTotal float64 = 0 //床位部分项目自费
  34386. var materialInscpTotal float64 = 0 //床位部分项目自费
  34387. var westernMedicineCostTotal float64 = 0 //西药费
  34388. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34389. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34390. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34391. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34392. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34393. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34394. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34395. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34396. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34397. var checkCostTotal float64 = 0 //检查费
  34398. var checkCostSelfTotal float64 = 0 //检查费
  34399. var checkCostPartSelfTotal float64 = 0 //检查费
  34400. var checkSelfTotal float64 = 0 //床位部分项目自费
  34401. var checkInscpTotal float64 = 0 //床位部分项目自费
  34402. var laboratoryCostTotal float64 = 0 //化验费
  34403. var laboratoryCostSelfTotal float64 = 0 //化验费
  34404. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34405. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34406. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34407. var treatCostTotal float64 = 0 //治疗费用
  34408. var treatCostSelfTotal float64 = 0 //治疗费用
  34409. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34410. var treatSelfTotal float64 = 0 //床位部分项目自费
  34411. var treatInscpTotal float64 = 0 //床位部分项目自费
  34412. var zcCostTotal float64 = 0 //治疗费用
  34413. var zcCostSelfTotal float64 = 0 //治疗费用
  34414. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34415. var zcSelfTotal float64 = 0 //床位部分项目自费
  34416. var zcInscpTotal float64 = 0 //床位部分项目自费
  34417. var huliCostTotal float64 = 0 //治疗费用
  34418. var huliCostSelfTotal float64 = 0 //治疗费用
  34419. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34420. var huliSelfTotal float64 = 0 //床位部分项目自费
  34421. var huliInscpTotal float64 = 0 //床位部分项目自费
  34422. decimal.DivisionPrecision = 2
  34423. for _, item := range orderInfos {
  34424. if item.MedChrgitmType == "01" { //床位费
  34425. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34426. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34427. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34428. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34429. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34430. }
  34431. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34432. if item.MedChrgitmType == "03" { //检查费
  34433. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34434. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34435. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34436. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34437. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34438. }
  34439. } else {
  34440. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34441. fmt.Println("------------")
  34442. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34443. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34444. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34445. }
  34446. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34447. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34448. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34449. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34450. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34451. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34452. }
  34453. }
  34454. if item.MedChrgitmType == "04" { //化验费
  34455. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34456. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34457. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34458. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34459. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34460. }
  34461. if item.MedChrgitmType == "05" { //治疗费
  34462. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34463. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34464. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34465. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34466. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34467. }
  34468. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34469. fmt.Println("------------")
  34470. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34471. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34472. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34473. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34474. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34475. }
  34476. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34477. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34478. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34479. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34480. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34481. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34482. }
  34483. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34484. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34485. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34486. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34487. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34488. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34489. }
  34490. if item.MedChrgitmType == "09" { //西药费
  34491. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34492. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34493. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34494. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34495. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34496. }
  34497. if item.MedChrgitmType == "11" { //中成费
  34498. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34499. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34500. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34501. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34502. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34503. }
  34504. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34505. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34506. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34507. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34508. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34509. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34510. }
  34511. if item.MedChrgitmType == "02" { //其他费
  34512. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34513. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34514. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34515. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34516. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34517. }
  34518. if item.MedChrgitmType == "07" { //其他费
  34519. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34520. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34521. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34522. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34523. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34524. }
  34525. }
  34526. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34527. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34528. var user_name string
  34529. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34530. if role.ID == 0 {
  34531. user_name = "管理员"
  34532. } else {
  34533. user_name = role.UserName
  34534. }
  34535. baseParams := models.BaseParams{
  34536. SecretKey: miConfig.SecretKey,
  34537. FixmedinsCode: miConfig.Code,
  34538. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34539. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34540. OrgName: miConfig.OrgName,
  34541. Doctor: user_name,
  34542. RequestUrl: miConfig.Url,
  34543. AccessKey: miConfig.AccessKey,
  34544. }
  34545. businessParams := models.BusinessParams{
  34546. PsnNo: order.PsnNo,
  34547. MdtrtId: order.MdtrtId,
  34548. SetlId: order.SetlId,
  34549. }
  34550. var res ResultEleven
  34551. var resah ResultElevenah
  34552. var resEleven10265 ResultEleven10265
  34553. if config.IsOpen == 1 {
  34554. if miConfig.MdtrtareaAdmvs == "421300" {
  34555. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34556. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34557. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34558. resp, requestErr := http.Get(api)
  34559. if requestErr != nil {
  34560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34561. return
  34562. }
  34563. body, ioErr := ioutil.ReadAll(resp.Body)
  34564. if ioErr != nil {
  34565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34567. return
  34568. }
  34569. var respJSON map[string]interface{}
  34570. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34573. return
  34574. }
  34575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34576. result, _ := json.Marshal(respJSON)
  34577. fmt.Println("log")
  34578. fmt.Println(string(result))
  34579. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34580. utils.ErrorLog("解析失败:%v", err)
  34581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34582. return
  34583. }
  34584. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34585. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34586. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34587. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34588. resp, requestErr := http.Get(api)
  34589. if requestErr != nil {
  34590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34591. return
  34592. }
  34593. body, ioErr := ioutil.ReadAll(resp.Body)
  34594. if ioErr != nil {
  34595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34597. return
  34598. }
  34599. var respJSON map[string]interface{}
  34600. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34603. return
  34604. }
  34605. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34606. result, _ := json.Marshal(respJSON)
  34607. fmt.Println("log")
  34608. fmt.Println(string(result))
  34609. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34610. utils.ErrorLog("解析失败:%v", err)
  34611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34612. return
  34613. }
  34614. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34615. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34616. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34617. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34618. resp, requestErr := http.Get(api)
  34619. if requestErr != nil {
  34620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34621. return
  34622. }
  34623. body, ioErr := ioutil.ReadAll(resp.Body)
  34624. if ioErr != nil {
  34625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34627. return
  34628. }
  34629. var respJSON map[string]interface{}
  34630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34633. return
  34634. }
  34635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34636. result, _ := json.Marshal(respJSON)
  34637. fmt.Println("log")
  34638. fmt.Println(string(result))
  34639. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34640. utils.ErrorLog("解析失败:%v", err)
  34641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34642. return
  34643. }
  34644. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34645. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34646. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34647. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34648. resp, requestErr := http.Get(api)
  34649. if requestErr != nil {
  34650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34651. return
  34652. }
  34653. body, ioErr := ioutil.ReadAll(resp.Body)
  34654. if ioErr != nil {
  34655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34657. return
  34658. }
  34659. var respJSON map[string]interface{}
  34660. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34663. return
  34664. }
  34665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34666. result, _ := json.Marshal(respJSON)
  34667. fmt.Println("log")
  34668. fmt.Println(string(result))
  34669. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34670. utils.ErrorLog("解析失败:%v", err)
  34671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34672. return
  34673. }
  34674. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34675. var api string
  34676. if miConfig.MdtrtareaAdmvs == "320921" {
  34677. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34678. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34679. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34680. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34681. } else {
  34682. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34683. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34684. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34685. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34686. }
  34687. resp, requestErr := http.Get(api)
  34688. if requestErr != nil {
  34689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34690. return
  34691. }
  34692. body, ioErr := ioutil.ReadAll(resp.Body)
  34693. if ioErr != nil {
  34694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34696. return
  34697. }
  34698. var respJSON map[string]interface{}
  34699. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34702. return
  34703. }
  34704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34705. result, _ := json.Marshal(respJSON)
  34706. fmt.Println("log")
  34707. fmt.Println(string(result))
  34708. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34709. utils.ErrorLog("解析失败:%v", err)
  34710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34711. return
  34712. }
  34713. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34714. res.Output = resEleven10265.Output
  34715. res.ErrMsg = resEleven10265.ErrMsg
  34716. res.Cainfo = resEleven10265.Cainfo
  34717. res.WarnMsg = resEleven10265.WarnMsg
  34718. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34719. res.Infcode = infocode
  34720. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34721. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34722. saveLog(result, requestLog, "5203", "结算单")
  34723. var dat map[string]interface{}
  34724. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34725. fmt.Println(dat)
  34726. } else {
  34727. fmt.Println(err)
  34728. }
  34729. userJSONBytes, _ := json.Marshal(dat)
  34730. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34731. utils.ErrorLog("解析失败:%v", err)
  34732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34733. return
  34734. }
  34735. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34736. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34737. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34738. saveLog(result, requestLog, "5203", "结算单")
  34739. var dat map[string]interface{}
  34740. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34741. fmt.Println(dat)
  34742. } else {
  34743. fmt.Println(err)
  34744. }
  34745. userJSONBytes, _ := json.Marshal(dat)
  34746. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34747. utils.ErrorLog("解析失败:%v", err)
  34748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34749. return
  34750. }
  34751. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34752. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34753. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34754. saveLog(result, requestLog, "5203", "结算单")
  34755. var dat map[string]interface{}
  34756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34757. fmt.Println(dat)
  34758. } else {
  34759. fmt.Println(err)
  34760. }
  34761. userJSONBytes, _ := json.Marshal(dat)
  34762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34763. utils.ErrorLog("解析失败:%v", err)
  34764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34765. return
  34766. }
  34767. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34768. var api string
  34769. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34770. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34771. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34772. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34773. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34774. resp, requestErr := http.Get(api)
  34775. if requestErr != nil {
  34776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34777. return
  34778. }
  34779. body, ioErr := ioutil.ReadAll(resp.Body)
  34780. if ioErr != nil {
  34781. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34783. return
  34784. }
  34785. var respJSON map[string]interface{}
  34786. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34789. return
  34790. }
  34791. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34792. if status == "0" {
  34793. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34794. c.ServeSuccessJSON(map[string]interface{}{
  34795. "failed_code": -10,
  34796. "msg": err_msg,
  34797. })
  34798. return
  34799. }
  34800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34801. result, _ := json.Marshal(respJSON)
  34802. fmt.Println("log")
  34803. fmt.Println(string(result))
  34804. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34805. utils.ErrorLog("解析失败:%v", err)
  34806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34807. return
  34808. }
  34809. res.InfRefmsgid = resah.InfRefmsgid
  34810. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34811. // 创建对应的Time类型
  34812. t := time.UnixMilli(timestamp)
  34813. // 格式化成指定的日期字符串
  34814. str := t.Format("2006-01-02 15:04:05")
  34815. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34816. // 创建对应的Time类型
  34817. t3 := time.UnixMilli(timestamp2)
  34818. // 格式化成指定的日期字符串
  34819. str2 := t3.Format("2006-01-02 15:04:05")
  34820. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34821. // 创建对应的Time类型
  34822. t4 := time.UnixMilli(timestamp3)
  34823. // 格式化成指定的日期字符串
  34824. str3 := t4.Format("2006-01-02 15:04:05")
  34825. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34826. // 创建对应的Time类型
  34827. t5 := time.UnixMilli(timestamp4)
  34828. // 格式化成指定的日期字符串
  34829. str5 := t5.Format("2006-01-02 15:04:05")
  34830. res.Output.Setlinfo.Brdy = str2
  34831. res.Output.Setlinfo.SetlTime = str
  34832. res.Output.Setlinfo.Begndate = str3
  34833. res.Output.Setlinfo.Enddate = str5
  34834. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34835. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34836. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34837. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34838. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34839. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34840. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34841. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34842. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34843. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34844. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34845. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34846. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34847. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34848. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34849. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34850. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34851. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34852. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34853. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34854. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34855. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34856. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34857. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34858. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34859. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34860. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34861. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34862. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34863. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34864. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34865. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34866. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34867. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34868. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34869. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34870. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34871. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34872. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34873. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34874. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34875. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34876. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34877. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34878. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34879. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34880. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34881. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34882. //res.Output.Setldetail = resah.Output.Setldetail
  34883. res.ErrMsg = resah.ErrMsg
  34884. res.Cainfo = resah.Cainfo
  34885. res.WarnMsg = resah.WarnMsg
  34886. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34887. var api string
  34888. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34889. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34890. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34891. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34892. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34893. resp, requestErr := http.Get(api)
  34894. if requestErr != nil {
  34895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34896. return
  34897. }
  34898. body, ioErr := ioutil.ReadAll(resp.Body)
  34899. if ioErr != nil {
  34900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34902. return
  34903. }
  34904. var respJSON map[string]interface{}
  34905. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34908. return
  34909. }
  34910. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34911. if status == "0" {
  34912. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34913. c.ServeSuccessJSON(map[string]interface{}{
  34914. "failed_code": -10,
  34915. "msg": err_msg,
  34916. })
  34917. return
  34918. }
  34919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34920. result, _ := json.Marshal(respJSON)
  34921. fmt.Println("log")
  34922. fmt.Println(string(result))
  34923. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34924. utils.ErrorLog("解析失败:%v", err)
  34925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34926. return
  34927. }
  34928. res.InfRefmsgid = resah.InfRefmsgid
  34929. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34930. // 创建对应的Time类型
  34931. t := time.UnixMilli(timestamp)
  34932. // 格式化成指定的日期字符串
  34933. str := t.Format("2006-01-02 15:04:05")
  34934. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34935. // 创建对应的Time类型
  34936. t3 := time.UnixMilli(timestamp2)
  34937. // 格式化成指定的日期字符串
  34938. str2 := t3.Format("2006-01-02 15:04:05")
  34939. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34940. // 创建对应的Time类型
  34941. t4 := time.UnixMilli(timestamp3)
  34942. // 格式化成指定的日期字符串
  34943. str3 := t4.Format("2006-01-02 15:04:05")
  34944. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34945. // 创建对应的Time类型
  34946. t5 := time.UnixMilli(timestamp4)
  34947. // 格式化成指定的日期字符串
  34948. str5 := t5.Format("2006-01-02 15:04:05")
  34949. res.Output.Setlinfo.Brdy = str2
  34950. res.Output.Setlinfo.SetlTime = str
  34951. res.Output.Setlinfo.Begndate = str3
  34952. res.Output.Setlinfo.Enddate = str5
  34953. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34954. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34955. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34956. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34957. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34958. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34959. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34960. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34961. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34962. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34963. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34964. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34965. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34966. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34967. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34968. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34969. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34970. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34971. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34972. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34973. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34974. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34975. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34976. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34977. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34978. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34979. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34980. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34981. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34982. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34983. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34984. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34985. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34986. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34987. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34988. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34989. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34990. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34991. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34992. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34993. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34994. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34995. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34996. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34997. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34998. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34999. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35000. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35001. //res.Output.Setldetail = resah.Output.Setldetail
  35002. res.ErrMsg = resah.ErrMsg
  35003. res.Cainfo = resah.Cainfo
  35004. res.WarnMsg = resah.WarnMsg
  35005. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35006. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35007. saveLog(result, requestLog, "5203", "结算单")
  35008. var dat map[string]interface{}
  35009. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35010. fmt.Println(dat)
  35011. } else {
  35012. fmt.Println(err)
  35013. }
  35014. userJSONBytes, _ := json.Marshal(dat)
  35015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35016. utils.ErrorLog("解析失败:%v", err)
  35017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35018. return
  35019. }
  35020. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35021. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35022. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35023. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35024. resp, requestErr := http.Get(api)
  35025. if requestErr != nil {
  35026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35027. return
  35028. }
  35029. body, ioErr := ioutil.ReadAll(resp.Body)
  35030. if ioErr != nil {
  35031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35033. return
  35034. }
  35035. var respJSON map[string]interface{}
  35036. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35039. return
  35040. }
  35041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35042. result, _ := json.Marshal(respJSON)
  35043. fmt.Println("log")
  35044. fmt.Println(string(result))
  35045. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35046. utils.ErrorLog("解析失败:%v", err)
  35047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35048. return
  35049. }
  35050. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35051. res.Output = resEleven10265.Output
  35052. res.ErrMsg = resEleven10265.ErrMsg
  35053. res.Cainfo = resEleven10265.Cainfo
  35054. res.WarnMsg = resEleven10265.WarnMsg
  35055. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35056. res.Infcode = infocode
  35057. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35058. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35059. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35060. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35061. resp, requestErr := http.Get(api)
  35062. if requestErr != nil {
  35063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35064. return
  35065. }
  35066. body, ioErr := ioutil.ReadAll(resp.Body)
  35067. if ioErr != nil {
  35068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35070. return
  35071. }
  35072. var respJSON map[string]interface{}
  35073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35076. return
  35077. }
  35078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35079. result, _ := json.Marshal(respJSON)
  35080. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35081. utils.ErrorLog("解析失败:%v", err)
  35082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35083. return
  35084. }
  35085. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35086. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35087. //return
  35088. } else {
  35089. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35090. if len(his.InsuplcAdmdvs) == 0 {
  35091. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35092. } else {
  35093. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35094. }
  35095. result := service.Gdyb5203(baseParams, businessParams)
  35096. //service.Gdyb5204(baseParams, businessParams)
  35097. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35098. var dat map[string]interface{}
  35099. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35100. fmt.Println(dat)
  35101. } else {
  35102. fmt.Println(err)
  35103. }
  35104. userJSONBytes, _ := json.Marshal(dat)
  35105. if miConfig.Code == "H15049901371" {
  35106. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35107. utils.ErrorLog("解析失败:%v", err)
  35108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35109. return
  35110. }
  35111. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35112. res.Output = resEleven10265.Output
  35113. res.ErrMsg = resEleven10265.ErrMsg
  35114. res.Cainfo = resEleven10265.Cainfo
  35115. res.WarnMsg = resEleven10265.WarnMsg
  35116. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35117. res.Infcode = infocode
  35118. } else {
  35119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35120. utils.ErrorLog("解析失败:%v", err)
  35121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35122. return
  35123. }
  35124. }
  35125. }
  35126. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35127. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35128. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35129. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35130. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35131. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35132. var doctor_name string
  35133. if roles.ID == 0 {
  35134. doctor_name = "管理员"
  35135. } else {
  35136. doctor_name = roles.UserName
  35137. }
  35138. yiliao_leibie := ""
  35139. switch order.MedType {
  35140. case "11":
  35141. yiliao_leibie = "普通门诊"
  35142. break
  35143. case "12":
  35144. yiliao_leibie = "门诊挂号"
  35145. break
  35146. case "13":
  35147. yiliao_leibie = "急诊"
  35148. break
  35149. case "14":
  35150. yiliao_leibie = "门诊特殊病"
  35151. break
  35152. case "15":
  35153. yiliao_leibie = "门诊统筹"
  35154. break
  35155. case "16":
  35156. yiliao_leibie = "门诊慢性病"
  35157. break
  35158. case "21":
  35159. yiliao_leibie = "普通住院"
  35160. break
  35161. }
  35162. //var rf []CustomFundPay
  35163. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35164. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35165. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35166. if res.Infcode == 0 {
  35167. 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 {
  35168. c.ServeSuccessJSON(map[string]interface{}{
  35169. "diagnosis": name,
  35170. "order_infos": orderInfos,
  35171. "number": order.MdtrtId,
  35172. "date": order.SettleAccountsDate,
  35173. "charge_admin": charge_admin,
  35174. "printor_admin": printor_admin,
  35175. "info": res.Output.Setlinfo,
  35176. "order": order,
  35177. "bedCostTotal": bedCostTotal,
  35178. "bedCostSelfTotal": bedCostSelfTotal,
  35179. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35180. "bedSelfTotal": bedSelfTotal,
  35181. "bedInscpTotal": bedInscpTotal,
  35182. "operationCostTotal": operationCostTotal,
  35183. "operationCostSelfTotal": operationCostSelfTotal,
  35184. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35185. "operationSelfTotal": operationSelfTotal,
  35186. "operationInscpTotal": operationInscpTotal,
  35187. "otherCostTotal": otherCostTotal,
  35188. "otherCostSelfTotal": otherCostSelfTotal,
  35189. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35190. "otherSelfTotal": otherSelfTotal,
  35191. "otherInscpTotal": otherInscpTotal,
  35192. "materialCostTotal": materialCostTotal,
  35193. "materialCostSelfTotal": materialCostSelfTotal,
  35194. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35195. "materialSelfTotal": materialSelfTotal,
  35196. "materialInscpTotal": materialInscpTotal,
  35197. "westernMedicineCostTotal": westernMedicineCostTotal,
  35198. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35199. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35200. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35201. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35202. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35203. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35204. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35205. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35206. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35207. "checkCostTotal": checkCostTotal,
  35208. "checkCostSelfTotal": checkCostSelfTotal,
  35209. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35210. "checkSelfTotal": checkSelfTotal,
  35211. "checkInscpTotal": checkInscpTotal,
  35212. "laboratoryCostTotal": laboratoryCostTotal,
  35213. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35214. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35215. "laboratorySelfTotal": laboratorySelfTotal,
  35216. "laboratoryInscpTotal": laboratoryInscpTotal,
  35217. "treatCostTotal": treatCostTotal,
  35218. "treatCostSelfTotal": treatCostSelfTotal,
  35219. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35220. "treatSelfTotal": treatSelfTotal,
  35221. "treatInscpTotal": treatInscpTotal,
  35222. "doctor_info": doctor_info,
  35223. "doctor_code": adminRole_two.DoctorCode,
  35224. "doctor_name": doctor_name,
  35225. "health_card_no": order.PsnNo,
  35226. "department": departments.Name,
  35227. "yiliao_leibie": yiliao_leibie,
  35228. "after_money": order.AccountPrice,
  35229. "patient": patient,
  35230. "org_name": miConfig.OrgName,
  35231. "org_code": miConfig.Code,
  35232. "order_number": order.Number,
  35233. "his_hospital": his_hospital,
  35234. "his": his,
  35235. "dia_config": dia_config,
  35236. "psn_cash_pay": order.PsnCashPay,
  35237. "zcCostTotal": zcCostTotal,
  35238. "zcCostSelfTotal": zcCostSelfTotal,
  35239. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35240. "zcSelfTotal": zcSelfTotal,
  35241. "zcInscpTotal": zcInscpTotal,
  35242. "huliCostTotal": huliCostTotal,
  35243. "huliCostSelfTotal": huliCostSelfTotal,
  35244. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35245. "huliSelfTotal": huliSelfTotal,
  35246. "huliInscpTotal": huliInscpTotal,
  35247. //"funds": rf,
  35248. //"check_order_info": cus_slice,
  35249. })
  35250. } else {
  35251. c.ServeSuccessJSON(map[string]interface{}{
  35252. "diagnosis": name,
  35253. "order_infos": orderInfos,
  35254. "number": order.MdtrtId,
  35255. "date": order.SettleAccountsDate,
  35256. "charge_admin": charge_admin,
  35257. "printor_admin": printor_admin,
  35258. "info": order,
  35259. "order": order,
  35260. "bedCostTotal": bedCostTotal,
  35261. "bedCostSelfTotal": bedCostSelfTotal,
  35262. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35263. "bedSelfTotal": bedSelfTotal,
  35264. "bedInscpTotal": bedInscpTotal,
  35265. "operationCostTotal": operationCostTotal,
  35266. "operationCostSelfTotal": operationCostSelfTotal,
  35267. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35268. "operationSelfTotal": operationSelfTotal,
  35269. "operationInscpTotal": operationInscpTotal,
  35270. "otherCostTotal": otherCostTotal,
  35271. "otherCostSelfTotal": otherCostSelfTotal,
  35272. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35273. "otherSelfTotal": otherSelfTotal,
  35274. "otherInscpTotal": otherInscpTotal,
  35275. "materialCostTotal": materialCostTotal,
  35276. "materialCostSelfTotal": materialCostSelfTotal,
  35277. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35278. "materialSelfTotal": materialSelfTotal,
  35279. "materialInscpTotal": materialInscpTotal,
  35280. "westernMedicineCostTotal": westernMedicineCostTotal,
  35281. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35282. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35283. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35284. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35285. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35286. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35287. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35288. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35289. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35290. "checkCostTotal": checkCostTotal,
  35291. "checkCostSelfTotal": checkCostSelfTotal,
  35292. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35293. "checkSelfTotal": checkSelfTotal,
  35294. "checkInscpTotal": checkInscpTotal,
  35295. "laboratoryCostTotal": laboratoryCostTotal,
  35296. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35297. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35298. "laboratorySelfTotal": laboratorySelfTotal,
  35299. "laboratoryInscpTotal": laboratoryInscpTotal,
  35300. "treatCostTotal": treatCostTotal,
  35301. "treatCostSelfTotal": treatCostSelfTotal,
  35302. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35303. "treatSelfTotal": treatSelfTotal,
  35304. "treatInscpTotal": treatInscpTotal,
  35305. "doctor_info": doctor_info,
  35306. "doctor_code": adminRole_two.DoctorCode,
  35307. "doctor_name": doctor_name,
  35308. "health_card_no": order.PsnNo,
  35309. "department": departments.Name,
  35310. "yiliao_leibie": yiliao_leibie,
  35311. "after_money": order.AccountPrice,
  35312. "patient": patient,
  35313. "org_name": miConfig.OrgName,
  35314. "org_code": miConfig.Code,
  35315. "order_number": order.Number,
  35316. "his_hospital": his_hospital,
  35317. "his": his,
  35318. "dia_config": dia_config,
  35319. "psn_cash_pay": order.PsnCashPay,
  35320. "zcCostTotal": zcCostTotal,
  35321. "zcCostSelfTotal": zcCostSelfTotal,
  35322. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35323. "zcSelfTotal": zcSelfTotal,
  35324. "zcInscpTotal": zcInscpTotal,
  35325. "huliCostTotal": huliCostTotal,
  35326. "huliCostSelfTotal": huliCostSelfTotal,
  35327. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35328. "huliSelfTotal": huliSelfTotal,
  35329. "huliInscpTotal": huliInscpTotal,
  35330. //"funds": rf,
  35331. //"check_order_info": cus_slice,
  35332. })
  35333. }
  35334. }
  35335. }
  35336. }
  35337. //func (c *HisApiController) CheckTreatment() {
  35338. // patient_id, _ := c.GetInt64("patient_id")
  35339. // id_card_no := c.GetString("id_card_no")
  35340. // insutype := c.GetString("insutype")
  35341. // med_type := c.GetString("med_type")
  35342. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35343. //
  35344. // adminUser := c.GetAdminUserInfo()
  35345. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35346. //
  35347. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35348. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35349. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35350. //
  35351. // if miConfig.MdtrtareaAdmvs == "421300" {
  35352. // var res ResultTwo
  35353. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35354. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35355. // "&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)
  35356. // resp, requestErr := http.Get(api)
  35357. // if requestErr != nil {
  35358. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35359. // return
  35360. // }
  35361. //
  35362. // body, ioErr := ioutil.ReadAll(resp.Body)
  35363. // if ioErr != nil {
  35364. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35366. // return
  35367. // }
  35368. // var respJSON map[string]interface{}
  35369. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35370. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35371. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35372. // return
  35373. // }
  35374. //
  35375. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35376. // result, _ := json.Marshal(respJSON)
  35377. //
  35378. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35379. // utils.ErrorLog("解析失败:%v", err)
  35380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35381. // return
  35382. // }
  35383. //
  35384. // if res.Infcode == 0 {
  35385. //
  35386. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35387. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35388. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35389. // resp, requestErr := http.Get(api)
  35390. // if requestErr != nil {
  35391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35392. // return
  35393. // }
  35394. //
  35395. // body, ioErr := ioutil.ReadAll(resp.Body)
  35396. // if ioErr != nil {
  35397. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35398. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35399. // return
  35400. // }
  35401. // var respJSON map[string]interface{}
  35402. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35403. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35404. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35405. // return
  35406. // }
  35407. // var res Result2001
  35408. //
  35409. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35410. // result2, _ := json.Marshal(respJSON)
  35411. //
  35412. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35413. // utils.ErrorLog("解析失败:%v", err)
  35414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35415. // return
  35416. // }
  35417. //
  35418. // if res.Infcode == 0 {
  35419. // c.ServeSuccessJSON(map[string]interface{}{
  35420. // "msg": res.Output.Trtinfo,
  35421. // })
  35422. // }
  35423. //
  35424. // } else {
  35425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35426. // return
  35427. // }
  35428. //
  35429. // } else {
  35430. //
  35431. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35432. // var dat map[string]interface{}
  35433. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35434. // fmt.Println(dat)
  35435. // } else {
  35436. // fmt.Println(err)
  35437. // }
  35438. // userJSONBytes, _ := json.Marshal(dat)
  35439. // var res ResultTwo
  35440. // var res10265 ResultTwo10265
  35441. // if miConfig.Code == "H15049901371" {
  35442. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35443. // utils.ErrorLog("解析失败:%v", err)
  35444. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35445. // return
  35446. // }
  35447. // res.ErrMsg = res10265.ErrMsg
  35448. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35449. // res.Infcode = infocode
  35450. // res.Output = res10265.Output
  35451. // res.InfRefmsgid = res10265.InfRefmsgid
  35452. // } else {
  35453. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35454. // utils.ErrorLog("解析失败:%v", err)
  35455. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35456. // return
  35457. // }
  35458. // }
  35459. //
  35460. // var user_name string
  35461. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35462. // if role.ID == 0 {
  35463. // user_name = "xxx"
  35464. // } else {
  35465. // user_name = role.UserName
  35466. // }
  35467. //
  35468. // baseParams := models.BaseParams{
  35469. // SecretKey: miConfig.SecretKey,
  35470. // FixmedinsCode: miConfig.Code,
  35471. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35472. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35473. // OrgName: miConfig.OrgName,
  35474. // Doctor: user_name,
  35475. // }
  35476. //
  35477. // if config.IsOpen == 1 {
  35478. // if miConfig.Code == "H15049901371" {
  35479. // if med_type == "14" {
  35480. // if insutype == "390" {
  35481. // med_type = "9933"
  35482. // } else if insutype == "310" {
  35483. // med_type = "990502"
  35484. // }
  35485. // } else if med_type == "11" {
  35486. // med_type = "11"
  35487. // }
  35488. // }
  35489. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35490. // var dat map[string]interface{}
  35491. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35492. // fmt.Println(dat)
  35493. // } else {
  35494. // fmt.Println(err)
  35495. // }
  35496. // var res Result2001
  35497. // var res10265 Result2001Org10265
  35498. // if miConfig.Code == "H15049901371" {
  35499. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35500. // utils.ErrorLog("解析失败:%v", err)
  35501. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35502. // return
  35503. // }
  35504. // res.ErrMsg = res10265.ErrMsg
  35505. // res.Output = res10265.Output
  35506. // res.InfRefmsgid = res10265.InfRefmsgid
  35507. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35508. // res.Infcode = infocode
  35509. // } else {
  35510. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35511. // utils.ErrorLog("解析失败:%v", err)
  35512. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35513. // return
  35514. // }
  35515. // }
  35516. // if res.Infcode == 0 {
  35517. // c.ServeSuccessJSON(map[string]interface{}{
  35518. // "msg": res.Output.Trtinfo,
  35519. // })
  35520. // }
  35521. // }
  35522. // }
  35523. //}
  35524. //func (c *HisApiController) PutRecord() {
  35525. // id, _ := c.GetInt64("id")
  35526. // record_time := c.GetString("record_time")
  35527. // timeLayout := "2006-01-02"
  35528. // loc, _ := time.LoadLocation("Local")
  35529. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35530. // if err != nil {
  35531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35532. // return
  35533. // }
  35534. // recordDateTime := theTime.Unix()
  35535. //
  35536. // adminInfo := c.GetAdminUserInfo()
  35537. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35538. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35539. //
  35540. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35541. //
  35542. // fmt.Println(miConfig.SecretKey)
  35543. //
  35544. // if patient == nil {
  35545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35546. // return
  35547. // }
  35548. // if len(patient.IdCardNo) == 0 {
  35549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35550. // return
  35551. // }
  35552. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35553. // if config.IsOpen == 1 {
  35554. // 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
  35555. // resp, requestErr := http.Get(api)
  35556. // if requestErr != nil {
  35557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35558. // return
  35559. // }
  35560. // defer resp.Body.Close()
  35561. // body, ioErr := ioutil.ReadAll(resp.Body)
  35562. // if ioErr != nil {
  35563. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35565. // return
  35566. // }
  35567. // var respJSON map[string]interface{}
  35568. //
  35569. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35570. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35572. // return
  35573. // }
  35574. //
  35575. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35576. // userJSONBytes, _ := json.Marshal(userJSON)
  35577. // var res ResultTwo
  35578. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35579. // utils.ErrorLog("解析失败:%v", err)
  35580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35581. // return
  35582. // }
  35583. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35584. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35585. // infoStr := string(Iinfos)
  35586. // idetinfoStr := string(Idetinfos)
  35587. //
  35588. // if res.Infcode == 0 {
  35589. // his := models.VMHisPatient{
  35590. // Status: 1,
  35591. // Ctime: time.Now().Unix(),
  35592. // Mtime: time.Now().Unix(),
  35593. // PsnNo: res.Output.Baseinfo.PsnNo,
  35594. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35595. // Certno: res.Output.Baseinfo.Certno,
  35596. // PsnName: res.Output.Baseinfo.PsnName,
  35597. // Gend: res.Output.Baseinfo.Gend,
  35598. // Naty: res.Output.Baseinfo.Naty,
  35599. // Brdy: res.Output.Baseinfo.Brdy,
  35600. // Age: res.Output.Baseinfo.Age,
  35601. // Iinfo: infoStr,
  35602. // Idetinfo: idetinfoStr,
  35603. // PatientId: patient.ID,
  35604. // RecordDate: theTime.Unix(),
  35605. // UserOrgId: adminInfo.CurrentOrgId,
  35606. // AdminUserId: adminInfo.AdminUser.Id,
  35607. // IsReturn: 1,
  35608. // }
  35609. //
  35610. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35611. // //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")
  35612. // //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")
  35613. //
  35614. // //var dat map[string]interface{}
  35615. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35616. // // fmt.Println(dat)
  35617. // //} else {
  35618. // // fmt.Println(err)
  35619. // //}
  35620. //
  35621. // var dat2 map[string]interface{}
  35622. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35623. // fmt.Println(dat2)
  35624. // } else {
  35625. // fmt.Println(err)
  35626. // }
  35627. //
  35628. // } else {
  35629. // adminUser := c.GetAdminUserInfo()
  35630. // errlog := &models.HisOrderError{
  35631. // UserOrgId: adminUser.CurrentOrgId,
  35632. // Ctime: time.Now().Unix(),
  35633. // Mtime: time.Now().Unix(),
  35634. // ErrMsg: res.ErrMsg,
  35635. // Status: 1,
  35636. // PatientId: id,
  35637. // RecordTime: recordDateTime,
  35638. // Stage: 1,
  35639. // }
  35640. // service.CreateErrMsgLog(errlog)
  35641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35642. // return
  35643. // }
  35644. // }
  35645. //
  35646. //}
  35647. //func (c *HisApiController) GetUploadDiag() {
  35648. // id, _ := c.GetInt64("id")
  35649. // record_time := c.GetString("record_time")
  35650. //
  35651. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35652. // sick_type, _ := c.GetInt64("sick_type")
  35653. // reg_type, _ := c.GetInt64("reg_type")
  35654. //
  35655. // timeLayout := "2006-01-02"
  35656. // loc, _ := time.LoadLocation("Local")
  35657. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35658. // if err != nil {
  35659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35660. // return
  35661. // }
  35662. //
  35663. // var patientPrescription models.HisPrescriptionInfo
  35664. // recordDateTime := theTime.Unix()
  35665. // adminInfo := c.GetAdminUserInfo()
  35666. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35667. //
  35668. // if patientPrescription.ID == 0 {
  35669. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35670. // }
  35671. //
  35672. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35673. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35674. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35675. // sickConfig, _ := service.FindSickById(sick_type)
  35676. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35677. //
  35678. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35679. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35680. // "&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 +
  35681. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35682. // resp2, requestErr2 := http.Get(api2)
  35683. // if requestErr2 != nil {
  35684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35685. // return
  35686. // }
  35687. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35688. // if ioErr2 != nil {
  35689. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35691. // return
  35692. // }
  35693. // var respJSON2 map[string]interface{}
  35694. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35695. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35697. // return
  35698. // }
  35699. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35700. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35701. //
  35702. // var res2 ResultSix
  35703. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35704. // utils.ErrorLog("解析失败:%v", err)
  35705. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35706. // return
  35707. // }
  35708. // if res2.Infcode != 0 {
  35709. // adminUser := c.GetAdminUserInfo()
  35710. // errlog := &models.HisOrderError{
  35711. // UserOrgId: adminUser.CurrentOrgId,
  35712. // Ctime: time.Now().Unix(),
  35713. // Mtime: time.Now().Unix(),
  35714. // ErrMsg: res2.ErrMsg,
  35715. // Status: 1,
  35716. // PatientId: id,
  35717. // RecordTime: recordDateTime,
  35718. // Stage: 3,
  35719. // }
  35720. // service.CreateErrMsgLog(errlog)
  35721. //
  35722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35723. // return
  35724. // }
  35725. //
  35726. // c.ServeSuccessJSON(map[string]interface{}{
  35727. // "msg": "上传成功",
  35728. // })
  35729. //
  35730. //}
  35731. type QueryResult struct {
  35732. ID int64
  35733. Name string
  35734. Code string
  35735. List_type_code string
  35736. }
  35737. func (c *HisApiController) GetCheckCode() {
  35738. ids_str := c.GetString("ids")
  35739. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35740. ids_arr := strings.Split(ids_str, ",")
  35741. var queryResult []QueryResult
  35742. ids := make([]int64, 0)
  35743. for _, item := range ids_arr {
  35744. id, _ := strconv.ParseInt(item, 10, 64)
  35745. ids = append(ids, id)
  35746. }
  35747. if record_type == 1 {
  35748. drugs, _ := service.GetBatchDrugList(ids)
  35749. for _, item := range drugs {
  35750. result := QueryResult{
  35751. ID: item.ID,
  35752. Name: item.DrugName,
  35753. Code: item.MedicalInsuranceNumber,
  35754. List_type_code: "101",
  35755. }
  35756. queryResult = append(queryResult, result)
  35757. }
  35758. } else if record_type == 2 {
  35759. goods, _ := service.GetBatchGoodInformationList(ids)
  35760. fmt.Println(goods)
  35761. for _, item := range goods {
  35762. result := QueryResult{
  35763. ID: item.ID,
  35764. Name: item.GoodName,
  35765. Code: item.SocialSecurityDirectoryCode,
  35766. List_type_code: "301",
  35767. }
  35768. queryResult = append(queryResult, result)
  35769. }
  35770. } else if record_type == 3 {
  35771. projects, _ := service.GetBathchMyPorjecgList(ids)
  35772. for _, item := range projects {
  35773. result := QueryResult{
  35774. ID: item.ID,
  35775. Name: item.ProjectName,
  35776. Code: item.MedicalCode,
  35777. List_type_code: "201",
  35778. }
  35779. queryResult = append(queryResult, result)
  35780. }
  35781. }
  35782. admin_user_id, _ := c.GetInt64("admin_user_id")
  35783. adminUser := c.GetAdminUserInfo()
  35784. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35785. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35786. var user_name string
  35787. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35788. if role.ID == 0 {
  35789. user_name = "管理员"
  35790. } else {
  35791. user_name = role.UserName
  35792. }
  35793. baseParams := models.BaseParams{
  35794. SecretKey: miConfig.SecretKey,
  35795. FixmedinsCode: miConfig.Code,
  35796. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35797. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35798. OrgName: miConfig.OrgName,
  35799. Doctor: user_name,
  35800. }
  35801. var result string
  35802. if miConfig.MdtrtareaAdmvs == "430800" {
  35803. for _, item := range queryResult {
  35804. if record_type == 1 {
  35805. 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)
  35806. } else if record_type == 2 {
  35807. fmt.Println(item.Code)
  35808. 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)
  35809. } else if record_type == 3 {
  35810. 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)
  35811. }
  35812. var dat map[string]interface{}
  35813. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35814. fmt.Println(dat)
  35815. } else {
  35816. fmt.Println(err)
  35817. }
  35818. userJSONBytes, _ := json.Marshal(dat)
  35819. var res ResultSix
  35820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35821. utils.ErrorLog("解析失败:%v", err)
  35822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35823. return
  35824. }
  35825. if res.Infcode == 0 {
  35826. if record_type == 1 {
  35827. service.UpdateBaseDrugById(item.ID)
  35828. } else if record_type == 2 {
  35829. service.UpdateGoodInformaitonByDetail(item.ID)
  35830. } else if record_type == 3 {
  35831. service.UpdateProjectById(item.ID)
  35832. }
  35833. c.ServeSuccessJSON(map[string]interface{}{
  35834. "failed_code": 0,
  35835. "msg": "目录对照成功",
  35836. })
  35837. } else {
  35838. c.ServeSuccessJSON(map[string]interface{}{
  35839. "failed_code": -10,
  35840. "msg": res.ErrMsg,
  35841. })
  35842. }
  35843. }
  35844. } else {
  35845. for _, item := range queryResult {
  35846. var result string
  35847. if record_type == 1 {
  35848. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35849. } else if record_type == 2 {
  35850. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35851. } else if record_type == 3 {
  35852. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35853. }
  35854. var dat map[string]interface{}
  35855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35856. fmt.Println(dat)
  35857. } else {
  35858. fmt.Println(err)
  35859. }
  35860. userJSONBytes, _ := json.Marshal(dat)
  35861. var res ResultSix
  35862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35863. utils.ErrorLog("解析失败:%v", err)
  35864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35865. return
  35866. }
  35867. if res.Infcode == 0 {
  35868. if record_type == 1 {
  35869. service.UpdateBaseDrugById(item.ID)
  35870. } else if record_type == 2 {
  35871. service.UpdateGoodInformaitonByDetail(item.ID)
  35872. } else if record_type == 3 {
  35873. service.UpdateProjectById(item.ID)
  35874. }
  35875. c.ServeSuccessJSON(map[string]interface{}{
  35876. "failed_code": 0,
  35877. "msg": "目录对照成功",
  35878. })
  35879. } else {
  35880. c.ServeSuccessJSON(map[string]interface{}{
  35881. "failed_code": -10,
  35882. "msg": res.ErrMsg,
  35883. })
  35884. }
  35885. }
  35886. }
  35887. }
  35888. func (c *HisApiController) UnCheckCode() {
  35889. ids_str := c.GetString("ids")
  35890. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35891. admin_user_id, _ := c.GetInt64("admin_user_id")
  35892. ids_arr := strings.Split(ids_str, ",")
  35893. var queryResult []QueryResult
  35894. ids := make([]int64, 0)
  35895. for _, item := range ids_arr {
  35896. id, _ := strconv.ParseInt(item, 10, 64)
  35897. ids = append(ids, id)
  35898. }
  35899. if record_type == 1 {
  35900. drugs, _ := service.GetBatchDrugList(ids)
  35901. for _, item := range drugs {
  35902. result := QueryResult{
  35903. ID: item.ID,
  35904. Name: item.DrugName,
  35905. Code: item.MedicalInsuranceNumber,
  35906. List_type_code: "101",
  35907. }
  35908. queryResult = append(queryResult, result)
  35909. }
  35910. } else if record_type == 2 {
  35911. goods, _ := service.GetBatchGoodInformationList(ids)
  35912. for _, item := range goods {
  35913. result := QueryResult{
  35914. ID: item.ID,
  35915. Name: item.GoodName,
  35916. Code: item.SocialSecurityDirectoryCode,
  35917. List_type_code: "301",
  35918. }
  35919. queryResult = append(queryResult, result)
  35920. }
  35921. } else if record_type == 3 {
  35922. projects, _ := service.GetBathchMyPorjecgList(ids)
  35923. for _, item := range projects {
  35924. result := QueryResult{
  35925. ID: item.ID,
  35926. Name: item.ProjectName,
  35927. Code: item.MedicalCode,
  35928. List_type_code: "201",
  35929. }
  35930. queryResult = append(queryResult, result)
  35931. }
  35932. }
  35933. adminUser := c.GetAdminUserInfo()
  35934. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35935. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35936. var user_name string
  35937. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35938. if role.ID == 0 {
  35939. user_name = "xxx"
  35940. } else {
  35941. user_name = role.UserName
  35942. }
  35943. baseParams := &models.BaseParams{
  35944. SecretKey: miConfig.SecretKey,
  35945. FixmedinsCode: miConfig.Code,
  35946. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35947. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35948. OrgName: miConfig.OrgName,
  35949. Doctor: user_name,
  35950. }
  35951. if config.IsOpen == 1 {
  35952. if miConfig.MdtrtareaAdmvs == "430800" {
  35953. for _, item := range queryResult {
  35954. var result string
  35955. if record_type == 1 {
  35956. 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)
  35957. } else if record_type == 2 {
  35958. fmt.Println(item.Code)
  35959. 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)
  35960. } else if record_type == 3 {
  35961. 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)
  35962. }
  35963. var dat map[string]interface{}
  35964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35965. fmt.Println(dat)
  35966. } else {
  35967. fmt.Println(err)
  35968. }
  35969. userJSONBytes, _ := json.Marshal(dat)
  35970. var res ResultSix
  35971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35972. utils.ErrorLog("解析失败:%v", err)
  35973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35974. return
  35975. }
  35976. if res.Infcode == 0 {
  35977. if record_type == 1 {
  35978. service.UpdateBaseDrugById(item.ID)
  35979. } else if record_type == 2 {
  35980. service.UpdateGoodInformaitonByDetail(item.ID)
  35981. } else if record_type == 3 {
  35982. service.UpdateProjectById(item.ID)
  35983. }
  35984. c.ServeSuccessJSON(map[string]interface{}{
  35985. "failed_code": 0,
  35986. "msg": "目录对照成功",
  35987. })
  35988. } else {
  35989. c.ServeSuccessJSON(map[string]interface{}{
  35990. "failed_code": -10,
  35991. "msg": res.ErrMsg,
  35992. })
  35993. }
  35994. }
  35995. } else {
  35996. for _, item := range queryResult {
  35997. var result string
  35998. if record_type == 1 {
  35999. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36000. } else if record_type == 2 {
  36001. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36002. } else if record_type == 3 {
  36003. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36004. }
  36005. var dat2 map[string]interface{}
  36006. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36007. fmt.Println(dat2)
  36008. } else {
  36009. fmt.Println(err)
  36010. }
  36011. userJSONBytes, _ := json.Marshal(dat2)
  36012. var res ResultSix
  36013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36014. utils.ErrorLog("解析失败:%v", err)
  36015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36016. return
  36017. }
  36018. if res.Infcode == 0 {
  36019. if record_type == 1 {
  36020. service.UpdateDrugByIdDetail(item.ID)
  36021. } else if record_type == 2 {
  36022. service.UpdateGoodInfoById(item.ID)
  36023. } else if record_type == 3 {
  36024. service.UpdateMyProjectById(item.ID)
  36025. }
  36026. c.ServeSuccessJSON(map[string]interface{}{
  36027. "failed_code": 0,
  36028. "msg": "撤销目录对照成功",
  36029. })
  36030. } else {
  36031. c.ServeSuccessJSON(map[string]interface{}{
  36032. "failed_code": -10,
  36033. "msg": res.ErrMsg,
  36034. })
  36035. }
  36036. }
  36037. }
  36038. }
  36039. }
  36040. func (c *HisApiController) GetPatientInfo() {
  36041. id_card_no := c.GetString("id_card_no")
  36042. admin_user_id, _ := c.GetInt64("admin_user_id")
  36043. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36044. if patient.ID == 0 {
  36045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36046. return
  36047. }
  36048. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36049. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36050. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36051. var res ResultTwo
  36052. var res10265 ResultTwo10265
  36053. if config.IsOpen == 1 {
  36054. if miConfig.MdtrtareaAdmvs == "150499" {
  36055. //请求内网数据
  36056. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36057. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36058. "&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
  36059. resp, requestErr := http.Get(api)
  36060. if requestErr != nil {
  36061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36062. return
  36063. }
  36064. body, ioErr := ioutil.ReadAll(resp.Body)
  36065. if ioErr != nil {
  36066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36068. return
  36069. }
  36070. var respJSON map[string]interface{}
  36071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36074. return
  36075. }
  36076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36077. result_byte, _ := json.Marshal(respJSON)
  36078. result := string(result_byte)
  36079. var dat map[string]interface{}
  36080. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36081. fmt.Println(dat)
  36082. } else {
  36083. fmt.Println(err)
  36084. }
  36085. userJSONBytes, _ := json.Marshal(dat)
  36086. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36087. utils.ErrorLog("解析失败:%v", err)
  36088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36089. return
  36090. }
  36091. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36092. res.Infcode = Infcode
  36093. res.ErrMsg = res10265.ErrMsg
  36094. res.Output = res10265.Output
  36095. res.InfRefmsgid = res10265.InfRefmsgid
  36096. res.RespondTime = res10265.RespondTime
  36097. res.WarnInfo = res10265.WarnInfo
  36098. } else {
  36099. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36100. var dat map[string]interface{}
  36101. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36102. fmt.Println(dat)
  36103. } else {
  36104. fmt.Println(err)
  36105. }
  36106. userJSONBytes, _ := json.Marshal(dat)
  36107. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36108. utils.ErrorLog("解析失败:%v", err)
  36109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36110. return
  36111. }
  36112. }
  36113. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36114. // utils.ErrorLog("解析失败:%v", err)
  36115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36116. // return
  36117. //}
  36118. for index, item := range res.Output.Iinfo {
  36119. if item.PsnInsuStas == "2" {
  36120. fmt.Println("--------")
  36121. res.Output.Iinfo[index].Insutype = "300"
  36122. res.Output.Iinfo[index].PsnInsuStas = "1"
  36123. }
  36124. }
  36125. fmt.Println(res.Output.Iinfo)
  36126. if res.Infcode != 0 {
  36127. c.ServeSuccessJSON(map[string]interface{}{
  36128. "failed_code": -10,
  36129. "msg": res.ErrMsg,
  36130. })
  36131. } else {
  36132. c.ServeSuccessJSON(map[string]interface{}{
  36133. "failed_code": 0,
  36134. "info": res,
  36135. })
  36136. }
  36137. }
  36138. }
  36139. func (c *HisApiController) PsnPutOnRecord() {
  36140. record_type, _ := c.GetInt64("type")
  36141. patient_id, _ := c.GetInt64("patient_id")
  36142. admin_user_id, _ := c.GetInt64("admin_user_id")
  36143. start_time := c.GetString("start_time")
  36144. end_time := c.GetString("end_time")
  36145. adminUser := c.GetAdminUserInfo()
  36146. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36147. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36148. var patients []*models.Patients
  36149. if record_type == 1 { //全部备案
  36150. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36151. patients = append(patients, patient...)
  36152. } else { //单个备案
  36153. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36154. patients = append(patients, patient)
  36155. }
  36156. var user_name string
  36157. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36158. if role.ID == 0 {
  36159. user_name = "xxx"
  36160. } else {
  36161. user_name = role.UserName
  36162. }
  36163. if config.IsOpen == 1 {
  36164. for _, item := range patients {
  36165. 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
  36166. resp, requestErr := http.Get(api)
  36167. if requestErr != nil {
  36168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36169. return
  36170. }
  36171. defer resp.Body.Close()
  36172. body, ioErr := ioutil.ReadAll(resp.Body)
  36173. if ioErr != nil {
  36174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36176. return
  36177. }
  36178. var respJSON map[string]interface{}
  36179. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36182. return
  36183. }
  36184. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36185. userJSONBytes, _ := json.Marshal(userJSON)
  36186. var res ResultTwo
  36187. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36188. utils.ErrorLog("解析失败:%v", err)
  36189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36190. return
  36191. }
  36192. if res.Infcode == 0 {
  36193. 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)
  36194. var dat map[string]interface{}
  36195. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36196. fmt.Println(dat)
  36197. } else {
  36198. fmt.Println(err)
  36199. }
  36200. userJSONBytes, _ := json.Marshal(dat)
  36201. var res2 ResultThirteen
  36202. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36203. utils.ErrorLog("解析失败:%v", err)
  36204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36205. return
  36206. }
  36207. if res2.Infcode == 0 {
  36208. psnResult := &models.GdybPsnRecord{
  36209. UserOrgId: adminUser.CurrentOrgId,
  36210. PatientId: item.ID,
  36211. PsnNo: res.Output.Baseinfo.PsnNo,
  36212. Ctime: time.Now().Unix(),
  36213. Mtime: time.Now().Unix(),
  36214. Status: 1,
  36215. IsCancel: 1,
  36216. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36217. }
  36218. service.CreatePsnRecord(psnResult)
  36219. } else {
  36220. c.ServeSuccessJSON(map[string]interface{}{
  36221. "failed_code": -10,
  36222. "msg": res2.ErrMsg,
  36223. })
  36224. return
  36225. }
  36226. }
  36227. }
  36228. }
  36229. }
  36230. func (c *HisApiController) PsnUnPutOnRecord() {
  36231. id, _ := c.GetInt64("id")
  36232. //record_type, _ := c.GetInt64("type")
  36233. admin_user_id, _ := c.GetInt64("admin_user_id")
  36234. adminUser := c.GetAdminUserInfo()
  36235. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36236. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36237. var user_name string
  36238. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36239. if role.ID == 0 {
  36240. user_name = "xxx"
  36241. } else {
  36242. user_name = role.UserName
  36243. }
  36244. psn_record, _ := service.GetPsnRecordById(id)
  36245. if psn_record.ID == 0 {
  36246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36247. return
  36248. }
  36249. if config.IsOpen == 1 {
  36250. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36251. var dat map[string]interface{}
  36252. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36253. fmt.Println(dat)
  36254. } else {
  36255. fmt.Println(err)
  36256. }
  36257. userJSONBytes, _ := json.Marshal(dat)
  36258. var res ResultFourteen
  36259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36260. utils.ErrorLog("解析失败:%v", err)
  36261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36262. return
  36263. }
  36264. if res.Infcode == 0 {
  36265. psn_record.IsCancel = 2
  36266. service.CreatePsnRecord(&psn_record)
  36267. } else {
  36268. c.ServeSuccessJSON(map[string]interface{}{
  36269. "failed_code": -10,
  36270. "msg": res.ErrMsg,
  36271. })
  36272. return
  36273. }
  36274. }
  36275. }
  36276. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36277. patient_id, _ := c.GetInt64("patient_id")
  36278. insutype_two := c.GetString("insutype")
  36279. psn_no := c.GetString("psn_no")
  36280. doctor_id, _ := c.GetInt64("doctor_id")
  36281. sick_id, _ := c.GetInt64("sick_id")
  36282. department_id, _ := c.GetInt64("department_id")
  36283. start_time := c.GetString("start_time")
  36284. end_time := c.GetString("end_time")
  36285. check_time := c.GetString("check_time")
  36286. hospital_code := c.GetString("hospital_code")
  36287. hospital_name := c.GetString("hospital_name")
  36288. adminUser := c.GetAdminUserInfo()
  36289. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36290. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36291. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36292. sick, _ := service.FindSickById(sick_id)
  36293. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36294. if len(hospital_code) == 0 {
  36295. hospital_code = miConfig.Code
  36296. }
  36297. if len(hospital_name) == 0 {
  36298. hospital_name = miConfig.OrgName
  36299. }
  36300. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36301. var res ResultTwo
  36302. var res10265 ResultTwo10265
  36303. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36304. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36305. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36306. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36307. "&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
  36308. resp, requestErr := http.Get(api)
  36309. if requestErr != nil {
  36310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36311. return
  36312. }
  36313. body, ioErr := ioutil.ReadAll(resp.Body)
  36314. if ioErr != nil {
  36315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36317. return
  36318. }
  36319. var respJSON map[string]interface{}
  36320. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36323. return
  36324. }
  36325. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36326. result, _ := json.Marshal(respJSON)
  36327. fmt.Println("log")
  36328. fmt.Println(string(result))
  36329. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36330. utils.ErrorLog("解析失败:%v", err)
  36331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36332. return
  36333. }
  36334. res.ErrMsg = res10265.ErrMsg
  36335. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36336. res.Infcode = infocode
  36337. res.Output = res10265.Output
  36338. res.InfRefmsgid = res10265.InfRefmsgid
  36339. } else {
  36340. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36341. if miConfig.Code == "H15049901371" {
  36342. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36343. utils.ErrorLog("解析失败:%v", err)
  36344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36345. return
  36346. }
  36347. res.ErrMsg = res10265.ErrMsg
  36348. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36349. res.Infcode = infocode
  36350. res.Output = res10265.Output
  36351. res.InfRefmsgid = res10265.InfRefmsgid
  36352. } else {
  36353. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36354. utils.ErrorLog("解析失败:%v", err)
  36355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36356. return
  36357. }
  36358. }
  36359. }
  36360. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36361. infoStr := string(Iinfos)
  36362. var rf []*ResultFive
  36363. json.Unmarshal([]byte(infoStr), &rf)
  36364. var insuplc_admdvs string
  36365. var insutype string
  36366. var is390 int = 0
  36367. var is310 int = 0
  36368. var insutypes []*ResultFive
  36369. for _, item := range rf {
  36370. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36371. insutypes = append(insutypes, item)
  36372. }
  36373. }
  36374. if len(insutypes) == 1 {
  36375. insutype = insutypes[0].Insutype
  36376. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36377. } else {
  36378. for _, i := range insutypes {
  36379. if i.Insutype == "390" {
  36380. is390 = 1
  36381. }
  36382. if i.Insutype == "310" {
  36383. is310 = 1
  36384. }
  36385. }
  36386. }
  36387. if is390 == 1 {
  36388. insutype = "390"
  36389. }
  36390. if is310 == 1 {
  36391. insutype = "310"
  36392. }
  36393. if len(insutypes) == 2 {
  36394. insutype = insutype_two
  36395. }
  36396. if len(insutypes) == 0 {
  36397. insutype = "310"
  36398. }
  36399. insutype = insutype_two
  36400. fmt.Println(insutype)
  36401. for _, item := range rf {
  36402. fmt.Println(item.Insutype)
  36403. fmt.Println(insutype)
  36404. if item.Insutype == insutype {
  36405. fmt.Println(item.Insutype)
  36406. fmt.Println(insutype)
  36407. insuplc_admdvs = item.InsuplcAdmdvs
  36408. }
  36409. }
  36410. fmt.Println(insuplc_admdvs)
  36411. var res2 ResultThirteen
  36412. var res10265_2 ResultThirteen10265
  36413. if config.IsOpen == 1 {
  36414. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36415. } else {
  36416. if miConfig.MdtrtareaAdmvs == "150499" {
  36417. //
  36418. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36419. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36420. // "&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
  36421. //resp, requestErr := http.Get(api)
  36422. //if requestErr != nil {
  36423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36424. // return
  36425. //}
  36426. //
  36427. //body, ioErr := ioutil.ReadAll(resp.Body)
  36428. //if ioErr != nil {
  36429. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36430. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36431. // return
  36432. //}
  36433. //var respJSON map[string]interface{}
  36434. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36435. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36437. // return
  36438. //}
  36439. //
  36440. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36441. //result, _ := json.Marshal(respJSON)
  36442. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36443. // utils.ErrorLog("解析失败:%v", err)
  36444. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36445. // return
  36446. //}
  36447. //infocode = resThree.Infcode
  36448. //result, _ := json.Marshal(respJSON)
  36449. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36450. // utils.ErrorLog("解析失败:%v", err)
  36451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36452. // return
  36453. //}
  36454. //
  36455. //resThree.ErrMsg = resThree10265.ErrMsg
  36456. //
  36457. //resThree.Output = resThree10265.Output
  36458. //
  36459. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36460. //
  36461. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36462. //
  36463. } else {
  36464. 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)
  36465. var dat map[string]interface{}
  36466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36467. fmt.Println(dat)
  36468. } else {
  36469. fmt.Println(err)
  36470. }
  36471. userJSONBytes, _ := json.Marshal(dat)
  36472. if miConfig.Code == "H15049901371" {
  36473. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36474. utils.ErrorLog("解析失败:%v", err)
  36475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36476. return
  36477. }
  36478. res2.ErrMsg = res10265_2.ErrMsg
  36479. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36480. res2.Infcode = infocode
  36481. res2.Output = res10265_2.Output
  36482. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36483. } else {
  36484. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36485. utils.ErrorLog("解析失败:%v", err)
  36486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36487. return
  36488. }
  36489. }
  36490. }
  36491. }
  36492. if res2.Infcode == 0 {
  36493. psnResult := &models.GdybPsnNcdsRecord{
  36494. UserOrgId: adminUser.CurrentOrgId,
  36495. PatientId: patient.ID,
  36496. PsnNo: psn_no,
  36497. DoctorId: doctor.AdminUserId,
  36498. DepartmentId: department_id,
  36499. SickType: sick_id,
  36500. Insutype: insutype,
  36501. Ctime: time.Now().Unix(),
  36502. Mtime: time.Now().Unix(),
  36503. Status: 1,
  36504. IsCancel: 1,
  36505. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36506. }
  36507. service.CreatePsnNCDSRecord(psnResult)
  36508. c.ServeSuccessJSON(map[string]interface{}{
  36509. "failed_code": 0,
  36510. "msg": "备案成功",
  36511. "result": psnResult,
  36512. })
  36513. } else {
  36514. c.ServeSuccessJSON(map[string]interface{}{
  36515. "failed_code": -10,
  36516. "msg": res2.ErrMsg,
  36517. })
  36518. return
  36519. }
  36520. }
  36521. }
  36522. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36523. id, _ := c.GetInt64("id")
  36524. admin_user_id, _ := c.GetInt64("admin_user_id")
  36525. adminUser := c.GetAdminUserInfo()
  36526. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36527. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36528. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36529. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36530. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36531. //var user_name string
  36532. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36533. //if role.ID == 0 {
  36534. // user_name = "xxx"
  36535. //} else {
  36536. // user_name = role.UserName
  36537. //}
  36538. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36539. if psn_record.ID == 0 {
  36540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36541. return
  36542. }
  36543. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36544. var res ResultTwo
  36545. var res10265 ResultTwo10265
  36546. if miConfig.Code == "H15049901371" {
  36547. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36548. utils.ErrorLog("解析失败:%v", err)
  36549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36550. return
  36551. }
  36552. res.ErrMsg = res10265.ErrMsg
  36553. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36554. res.Infcode = infocode
  36555. res.Output = res10265.Output
  36556. res.InfRefmsgid = res10265.InfRefmsgid
  36557. } else {
  36558. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36559. utils.ErrorLog("解析失败:%v", err)
  36560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36561. return
  36562. }
  36563. }
  36564. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36565. infoStr := string(Iinfos)
  36566. var rf []*ResultFive
  36567. json.Unmarshal([]byte(infoStr), &rf)
  36568. var insuplc_admdvs string
  36569. var insutype string
  36570. var is390 int = 0
  36571. var is310 int = 0
  36572. var insutypes []*ResultFive
  36573. for _, item := range rf {
  36574. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36575. insutypes = append(insutypes, item)
  36576. }
  36577. }
  36578. if len(insutypes) == 1 {
  36579. insutype = insutypes[0].Insutype
  36580. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36581. } else {
  36582. for _, i := range insutypes {
  36583. if i.Insutype == "390" {
  36584. is390 = 1
  36585. }
  36586. if i.Insutype == "310" {
  36587. is310 = 1
  36588. }
  36589. }
  36590. }
  36591. if is390 == 1 {
  36592. insutype = "390"
  36593. }
  36594. if is310 == 1 {
  36595. insutype = "310"
  36596. }
  36597. if len(insutypes) == 0 {
  36598. insutype = "310"
  36599. }
  36600. insutype = psn_record.Insutype
  36601. for _, item := range rf {
  36602. if item.Insutype == insutype {
  36603. insuplc_admdvs = item.InsuplcAdmdvs
  36604. }
  36605. }
  36606. if config.IsOpen == 1 {
  36607. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36608. var dat map[string]interface{}
  36609. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36610. fmt.Println(dat)
  36611. } else {
  36612. fmt.Println(err)
  36613. }
  36614. userJSONBytes, _ := json.Marshal(dat)
  36615. var res ResultFourteen
  36616. var res10265 ResultFourteen10265
  36617. if miConfig.Code == "H15049901371" {
  36618. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36619. utils.ErrorLog("解析失败:%v", err)
  36620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36621. return
  36622. }
  36623. res.ErrMsg = res10265.ErrMsg
  36624. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36625. res.Infcode = infocode
  36626. res.Output = res10265.Output
  36627. res.InfRefmsgid = res10265.InfRefmsgid
  36628. } else {
  36629. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36630. utils.ErrorLog("解析失败:%v", err)
  36631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36632. return
  36633. }
  36634. }
  36635. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36636. // utils.ErrorLog("解析失败:%v", err)
  36637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36638. // return
  36639. //}
  36640. if res.Infcode == 0 {
  36641. psn_record.IsCancel = 2
  36642. service.CreatePsnNCDSRecord(&psn_record)
  36643. c.ServeSuccessJSON(map[string]interface{}{
  36644. "failed_code": 0,
  36645. "msg": "撤销备案成功",
  36646. })
  36647. } else {
  36648. c.ServeSuccessJSON(map[string]interface{}{
  36649. "failed_code": -10,
  36650. "msg": res.ErrMsg,
  36651. })
  36652. return
  36653. }
  36654. }
  36655. }
  36656. func (c *HisApiController) TestTest() {
  36657. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36658. fmt.Println(patient.Iinfo)
  36659. }
  36660. type CustomData struct {
  36661. MsgId string
  36662. PsnNo string
  36663. Info string
  36664. }
  36665. func (c *HisApiController) ReversalData() {
  36666. var customData []*CustomData
  36667. custom := &CustomData{
  36668. MsgId: "H44022900158202103301714472004",
  36669. PsnNo: "44020000001101329945",
  36670. Info: "2207",
  36671. }
  36672. customData = append(customData, custom)
  36673. custom1 := &CustomData{
  36674. MsgId: "H4402290015820210330172057803",
  36675. PsnNo: "44020000001101161813",
  36676. Info: "2207",
  36677. }
  36678. customData = append(customData, custom1)
  36679. custom2 := &CustomData{
  36680. MsgId: "H44022900158202103301705198813",
  36681. PsnNo: "44190000133097375417",
  36682. Info: "2207",
  36683. }
  36684. customData = append(customData, custom2)
  36685. custom3 := &CustomData{
  36686. MsgId: "H44022900158202103301715524756",
  36687. PsnNo: "44020000001100187221",
  36688. Info: "2207",
  36689. }
  36690. customData = append(customData, custom3)
  36691. custom4 := &CustomData{
  36692. MsgId: "H44022900158202103301730376224",
  36693. PsnNo: "44020000001101959155",
  36694. Info: "2207",
  36695. }
  36696. customData = append(customData, custom4)
  36697. custom5 := &CustomData{
  36698. MsgId: "H44022900158202103301748008725",
  36699. PsnNo: "44020000001104246641",
  36700. Info: "2207",
  36701. }
  36702. customData = append(customData, custom5)
  36703. custom6 := &CustomData{
  36704. MsgId: "H44022900158202103301718096755",
  36705. PsnNo: "44020000001102211860",
  36706. Info: "2207",
  36707. }
  36708. customData = append(customData, custom6)
  36709. custom7 := &CustomData{
  36710. MsgId: "H44022900158202103301736551640",
  36711. PsnNo: "44020000001102687718",
  36712. Info: "2207",
  36713. }
  36714. customData = append(customData, custom7)
  36715. custom8 := &CustomData{
  36716. MsgId: "H44022900158202103301743097676",
  36717. PsnNo: "44020000001102127785",
  36718. Info: "2207",
  36719. }
  36720. customData = append(customData, custom8)
  36721. custom9 := &CustomData{
  36722. MsgId: "H44022900158202103301712304203",
  36723. PsnNo: "44020000001101518097",
  36724. Info: "2207",
  36725. }
  36726. customData = append(customData, custom9)
  36727. custom10 := &CustomData{
  36728. MsgId: "H44022900158202103301738448785",
  36729. PsnNo: "44020000001100500813",
  36730. Info: "2207",
  36731. }
  36732. customData = append(customData, custom10)
  36733. custom11 := &CustomData{
  36734. MsgId: "H44022900158202103301732455843",
  36735. PsnNo: "44020000001102690557",
  36736. Info: "2207",
  36737. }
  36738. customData = append(customData, custom11)
  36739. custom12 := &CustomData{
  36740. MsgId: "H44022900158202103301745421708",
  36741. PsnNo: "44020000001102211928",
  36742. Info: "2207",
  36743. }
  36744. customData = append(customData, custom12)
  36745. custom1212 := &CustomData{
  36746. MsgId: "H440229001582021033017351627",
  36747. PsnNo: "44020000001102481733",
  36748. Info: "2207",
  36749. }
  36750. customData = append(customData, custom1212)
  36751. custom13 := &CustomData{
  36752. MsgId: "H44022900158202103301740327951",
  36753. PsnNo: "44020000001103174866",
  36754. Info: "2207",
  36755. }
  36756. customData = append(customData, custom13)
  36757. custom14 := &CustomData{
  36758. MsgId: "H4402290015820210330174922668",
  36759. PsnNo: "44020000001102927272",
  36760. Info: "2207",
  36761. }
  36762. customData = append(customData, custom14)
  36763. custom15 := &CustomData{
  36764. MsgId: "H44022900158202103301752362273",
  36765. PsnNo: "44020000001102942890",
  36766. Info: "2207",
  36767. }
  36768. customData = append(customData, custom15)
  36769. custom16 := &CustomData{
  36770. MsgId: "H44022900158202103301751082917",
  36771. PsnNo: "44020000001101662162",
  36772. Info: "2207",
  36773. }
  36774. customData = append(customData, custom16)
  36775. custom17 := &CustomData{
  36776. MsgId: "H44022900158202103301754147728",
  36777. PsnNo: "44020000000229014511",
  36778. Info: "2207",
  36779. }
  36780. customData = append(customData, custom17)
  36781. adminUser := c.GetAdminUserInfo()
  36782. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36783. for _, item := range customData {
  36784. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36785. fmt.Println(result)
  36786. }
  36787. }
  36788. func (c *HisApiController) GetAllopatry() {
  36789. year := c.GetString("year")
  36790. month := c.GetString("month")
  36791. admin_user_id, _ := c.GetInt64("admin_user_id")
  36792. adminUser := c.GetAdminUserInfo()
  36793. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36794. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36795. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36796. var dat map[string]interface{}
  36797. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36798. fmt.Println(dat)
  36799. } else {
  36800. fmt.Println(err)
  36801. }
  36802. userJSONBytes, _ := json.Marshal(dat)
  36803. var res models.Result9001
  36804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36805. utils.ErrorLog("解析失败:%v", err)
  36806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36807. return
  36808. }
  36809. fmt.Println(res.Output.Signinoutb)
  36810. fmt.Println(res.Output.Signinoutb.SignNo)
  36811. fmt.Println(string(userJSONBytes))
  36812. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36813. var dat3 map[string]interface{}
  36814. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  36815. fmt.Println(dat3)
  36816. } else {
  36817. fmt.Println(err)
  36818. }
  36819. userJSONBytes3, _ := json.Marshal(dat3)
  36820. var res3 models.Result3260
  36821. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  36822. utils.ErrorLog("解析失败:%v", err)
  36823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36824. return
  36825. }
  36826. var curpage int
  36827. var pagesize int = 100
  36828. var start int = 1
  36829. //var stop int
  36830. //pagecount := 10
  36831. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  36832. var res22 []models.Result3260
  36833. for curpage = 1; curpage <= pagecount; curpage++ {
  36834. if curpage == 1 {
  36835. start = 0
  36836. } else {
  36837. start = (curpage-1)*pagesize + 1
  36838. }
  36839. fmt.Println(start)
  36840. //stop = curpage * pagesize
  36841. //if stop > int(res3.Output.Totalrow) {
  36842. // stop =int(res3.Output.Totalrow)
  36843. //}
  36844. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  36845. var dat2 map[string]interface{}
  36846. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36847. fmt.Println(dat)
  36848. } else {
  36849. fmt.Println(err)
  36850. }
  36851. userJSONBytes2, _ := json.Marshal(dat2)
  36852. var res2 models.Result3260
  36853. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36854. utils.ErrorLog("解析失败:%v", err)
  36855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36856. return
  36857. }
  36858. if res2.Infcode == 0 {
  36859. res22 = append(res22, res2)
  36860. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36861. //var dat2 map[string]interface{}
  36862. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36863. // fmt.Println(dat)
  36864. //} else {
  36865. // fmt.Println(err)
  36866. //}
  36867. //c.ServeSuccessJSON(map[string]interface{}{
  36868. // "list": res2.Output.Data,
  36869. //})
  36870. //continue
  36871. }
  36872. }
  36873. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36874. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36875. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  36876. //var dat2 map[string]interface{}
  36877. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36878. // fmt.Println(dat)
  36879. //} else {
  36880. // fmt.Println(err)
  36881. //}
  36882. //userJSONBytes2, _ := json.Marshal(dat2)
  36883. //var res2 models.Result3260
  36884. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36885. // utils.ErrorLog("解析失败:%v", err)
  36886. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36887. // return
  36888. //}
  36889. //if res2.Infcode == 0 {
  36890. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36891. // var dat2 map[string]interface{}
  36892. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36893. // fmt.Println(dat)
  36894. // } else {
  36895. // fmt.Println(err)
  36896. // }
  36897. // c.ServeSuccessJSON(map[string]interface{}{
  36898. // "list": res2.Output.Data,
  36899. // })
  36900. //}
  36901. }
  36902. func (c *HisApiController) ComfirmAllopatry() {
  36903. year := c.GetString("year")
  36904. month := c.GetString("month")
  36905. admin_user_id, _ := c.GetInt64("admin_user_id")
  36906. adminUser := c.GetAdminUserInfo()
  36907. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36908. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36909. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36910. var dat map[string]interface{}
  36911. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36912. fmt.Println(dat)
  36913. } else {
  36914. fmt.Println(err)
  36915. }
  36916. userJSONBytes, _ := json.Marshal(dat)
  36917. var res models.Result9001
  36918. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36919. utils.ErrorLog("解析失败:%v", err)
  36920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36921. return
  36922. }
  36923. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36924. var dat2 map[string]interface{}
  36925. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36926. fmt.Println(dat)
  36927. } else {
  36928. fmt.Println(err)
  36929. }
  36930. userJSONBytes2, _ := json.Marshal(dat2)
  36931. var res2 models.Result3260
  36932. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36933. utils.ErrorLog("解析失败:%v", err)
  36934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36935. return
  36936. }
  36937. //if res2.Infcode == 0 {
  36938. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36939. // var dat map[string]interface{}
  36940. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36941. // fmt.Println(dat)
  36942. // } else {
  36943. // fmt.Println(err)
  36944. // }
  36945. // userJSONBytes, _ := json.Marshal(dat)
  36946. // var res3 models.Result3261
  36947. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  36948. // utils.ErrorLog("解析失败:%v", err)
  36949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36950. // return
  36951. // }
  36952. //
  36953. // if res3.Infcode == 0 {
  36954. // record := &models.HisYidiClearRecord{
  36955. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  36956. // Ctime: time.Now().Unix(),
  36957. // Mtime: time.Now().Unix(),
  36958. // Status: 1,
  36959. // MsgId: msgId,
  36960. // }
  36961. // service.SaveClearRecord(record)
  36962. // c.ServeSuccessJSON(map[string]interface{}{
  36963. // "msg": "提取成功",
  36964. // })
  36965. // }
  36966. //}
  36967. }
  36968. func (c *HisApiController) RefundAllopatry() {
  36969. year := c.GetString("year")
  36970. month := c.GetString("month")
  36971. //id, _ := c.GetInt64("id")
  36972. admin_user_id, _ := c.GetInt64("admin_user_id")
  36973. adminUser := c.GetAdminUserInfo()
  36974. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36975. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36976. //record, _ := service.GetClearRecordById(id)
  36977. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36978. var dat map[string]interface{}
  36979. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  36980. fmt.Println(dat)
  36981. } else {
  36982. fmt.Println(err)
  36983. }
  36984. userJSONBytes, _ := json.Marshal(dat)
  36985. var res models.Result9001
  36986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36987. utils.ErrorLog("解析失败:%v", err)
  36988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36989. return
  36990. }
  36991. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  36992. var dat2 map[string]interface{}
  36993. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36994. fmt.Println(dat)
  36995. } else {
  36996. fmt.Println(err)
  36997. }
  36998. userJSONBytes2, _ := json.Marshal(dat2)
  36999. var empty ResultFourteen
  37000. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37001. utils.ErrorLog("解析失败:%v", err)
  37002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37003. return
  37004. }
  37005. if empty.Infcode == 0 {
  37006. c.ServeSuccessJSON(map[string]interface{}{
  37007. "msg": "撤销成功",
  37008. })
  37009. return
  37010. }
  37011. }
  37012. func (c *HisApiController) ReversalOtherData() {
  37013. var customData []*CustomData
  37014. custom := &CustomData{
  37015. MsgId: "H44022900158202103301714472004",
  37016. PsnNo: "44020000001101329945",
  37017. Info: "2208",
  37018. }
  37019. customData = append(customData, custom)
  37020. custom1 := &CustomData{
  37021. MsgId: "H4402290015820210330172057803",
  37022. PsnNo: "44020000001101161813",
  37023. Info: "2208",
  37024. }
  37025. customData = append(customData, custom1)
  37026. custom2 := &CustomData{
  37027. MsgId: "H44022900158202103301705198813",
  37028. PsnNo: "44190000133097375417",
  37029. Info: "2208",
  37030. }
  37031. customData = append(customData, custom2)
  37032. custom3 := &CustomData{
  37033. MsgId: "H44022900158202103301715524756",
  37034. PsnNo: "44020000001100187221",
  37035. Info: "2208",
  37036. }
  37037. customData = append(customData, custom3)
  37038. custom4 := &CustomData{
  37039. MsgId: "H44022900158202103301730376224",
  37040. PsnNo: "44020000001101959155",
  37041. Info: "2208",
  37042. }
  37043. customData = append(customData, custom4)
  37044. custom5 := &CustomData{
  37045. MsgId: "H44022900158202103301748008725",
  37046. PsnNo: "44020000001104246641",
  37047. Info: "2208",
  37048. }
  37049. customData = append(customData, custom5)
  37050. custom6 := &CustomData{
  37051. MsgId: "H44022900158202103301718096755",
  37052. PsnNo: "44020000001102211860",
  37053. Info: "2208",
  37054. }
  37055. customData = append(customData, custom6)
  37056. custom7 := &CustomData{
  37057. MsgId: "H44022900158202103301736551640",
  37058. PsnNo: "44020000001102687718",
  37059. Info: "2208",
  37060. }
  37061. customData = append(customData, custom7)
  37062. custom8 := &CustomData{
  37063. MsgId: "H44022900158202103301743097676",
  37064. PsnNo: "44020000001102127785",
  37065. Info: "2208",
  37066. }
  37067. customData = append(customData, custom8)
  37068. custom9 := &CustomData{
  37069. MsgId: "H44022900158202103301712304203",
  37070. PsnNo: "44020000001101518097",
  37071. Info: "2208",
  37072. }
  37073. customData = append(customData, custom9)
  37074. custom10 := &CustomData{
  37075. MsgId: "H44022900158202103301738448785",
  37076. PsnNo: "44020000001100500813",
  37077. Info: "2208",
  37078. }
  37079. customData = append(customData, custom10)
  37080. custom11 := &CustomData{
  37081. MsgId: "H44022900158202103301732455843",
  37082. PsnNo: "44020000001102690557",
  37083. Info: "2208",
  37084. }
  37085. customData = append(customData, custom11)
  37086. custom12 := &CustomData{
  37087. MsgId: "H44022900158202103301745421708",
  37088. PsnNo: "44020000001102211928",
  37089. Info: "2208",
  37090. }
  37091. customData = append(customData, custom12)
  37092. custom1212 := &CustomData{
  37093. MsgId: "H440229001582021033017351627",
  37094. PsnNo: "44020000001102481733",
  37095. Info: "2208",
  37096. }
  37097. customData = append(customData, custom1212)
  37098. custom13 := &CustomData{
  37099. MsgId: "H44022900158202103301740327951",
  37100. PsnNo: "44020000001103174866",
  37101. Info: "2208",
  37102. }
  37103. customData = append(customData, custom13)
  37104. custom14 := &CustomData{
  37105. MsgId: "H4402290015820210330174922668",
  37106. PsnNo: "44020000001102927272",
  37107. Info: "2208",
  37108. }
  37109. customData = append(customData, custom14)
  37110. custom15 := &CustomData{
  37111. MsgId: "H44022900158202103301752362273",
  37112. PsnNo: "44020000001102942890",
  37113. Info: "2208",
  37114. }
  37115. customData = append(customData, custom15)
  37116. custom16 := &CustomData{
  37117. MsgId: "H44022900158202103301751082917",
  37118. PsnNo: "44020000001101662162",
  37119. Info: "2208",
  37120. }
  37121. customData = append(customData, custom16)
  37122. custom17 := &CustomData{
  37123. MsgId: "H44022900158202103301754147728",
  37124. PsnNo: "44020000000229014511",
  37125. Info: "2208",
  37126. }
  37127. customData = append(customData, custom17)
  37128. adminUser := c.GetAdminUserInfo()
  37129. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37130. for _, item := range customData {
  37131. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37132. fmt.Println(result)
  37133. }
  37134. }
  37135. func PathExists(path string) (bool, error) {
  37136. _, err := os.Stat(path)
  37137. if err == nil {
  37138. return true, nil
  37139. }
  37140. if os.IsNotExist(err) {
  37141. return false, nil
  37142. }
  37143. return false, err
  37144. }
  37145. // 创建文件夹
  37146. func Mkdir(dir string) {
  37147. // 创建文件夹
  37148. exist, err := PathExists(dir)
  37149. if err != nil {
  37150. fmt.Println(err.Error())
  37151. } else {
  37152. if exist {
  37153. fmt.Println(dir + "文件夹已存在!")
  37154. } else {
  37155. // 文件夹名称,权限
  37156. err := os.Mkdir(dir, os.ModePerm)
  37157. if err != nil {
  37158. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37159. } else {
  37160. fmt.Println(dir + "文件夹创建成功!")
  37161. }
  37162. }
  37163. }
  37164. }
  37165. // 压缩文件
  37166. func Zip(srcFile string, destZip string) error {
  37167. zipfile, err := os.Create(destZip)
  37168. if err != nil {
  37169. return err
  37170. }
  37171. defer zipfile.Close()
  37172. archive := zip.NewWriter(zipfile)
  37173. defer archive.Close()
  37174. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37175. if err != nil {
  37176. return err
  37177. }
  37178. header, err := zip.FileInfoHeader(info)
  37179. if err != nil {
  37180. return err
  37181. }
  37182. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37183. // header.Name = path
  37184. if info.IsDir() {
  37185. header.Name += "/"
  37186. } else {
  37187. header.Method = zip.Deflate
  37188. }
  37189. writer, err := archive.CreateHeader(header)
  37190. if err != nil {
  37191. return err
  37192. }
  37193. if !info.IsDir() {
  37194. file, err := os.Open(path)
  37195. if err != nil {
  37196. return err
  37197. }
  37198. defer file.Close()
  37199. _, err = io.Copy(writer, file)
  37200. }
  37201. return err
  37202. })
  37203. return err
  37204. }
  37205. func ReadFile(filePath string) []byte {
  37206. f, err := os.Open(filePath)
  37207. if err != nil {
  37208. fmt.Println("read file fail", err)
  37209. return nil
  37210. }
  37211. defer f.Close()
  37212. fd, err := ioutil.ReadAll(f)
  37213. if err != nil {
  37214. fmt.Println("read to fd fail", err)
  37215. return nil
  37216. }
  37217. return fd
  37218. }
  37219. func saveLogq(result string, request string, infno string, desc string) {
  37220. dir := "日志"
  37221. utils.Mkdir(dir)
  37222. month := time.Unix(1557042972, 0).Format("1")
  37223. year := time.Now().Format("2006")
  37224. month = time.Now().Format("01")
  37225. day := time.Now().Format("02")
  37226. hour := time.Now().Format("15")
  37227. min := time.Now().Format("04")
  37228. sec := time.Now().Format("05")
  37229. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37230. file := year + month + day + "_log"
  37231. file_name := file + ".txt"
  37232. file_path := "日志" + "/" + file_name
  37233. exist, _ := utils.PathExists(file_path)
  37234. if exist { //存在
  37235. fmt.Println("存在")
  37236. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37237. if err != nil {
  37238. fmt.Println("read fail")
  37239. }
  37240. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37241. n, _ := f.Seek(0, 2)
  37242. _, err = f.WriteAt([]byte(content), n)
  37243. } else { //不存在
  37244. fmt.Println("文件不存在,创建文件")
  37245. f, err := os.Create("日志" + "/" + file_name)
  37246. defer f.Close()
  37247. if err != nil {
  37248. } else {
  37249. _, err = f.Write([]byte("记录日志"))
  37250. }
  37251. }
  37252. }
  37253. func saveLog(result string, request string, infno string, desc string) {
  37254. org_id, _ := beego.AppConfig.Int64("org_id")
  37255. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37256. dir := miConfig.OrgName + "日志"
  37257. utils.Mkdir(dir)
  37258. month := time.Unix(1557042972, 0).Format("1")
  37259. year := time.Now().Format("2006")
  37260. month = time.Now().Format("01")
  37261. day := time.Now().Format("02")
  37262. hour := time.Now().Format("15")
  37263. min := time.Now().Format("04")
  37264. sec := time.Now().Format("05")
  37265. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37266. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37267. file_name := file + ".txt"
  37268. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37269. exist, _ := utils.PathExists(file_path)
  37270. if exist { //存在
  37271. fmt.Println("存在")
  37272. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37273. if err != nil {
  37274. fmt.Println("read fail")
  37275. }
  37276. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37277. n, _ := f.Seek(0, 2)
  37278. _, err = f.WriteAt([]byte(content), n)
  37279. } else { //不存在
  37280. fmt.Println("文件不存在,创建文件")
  37281. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37282. defer f.Close()
  37283. if err != nil {
  37284. } else {
  37285. _, err = f.Write([]byte("记录日志"))
  37286. }
  37287. }
  37288. }
  37289. type Charset string
  37290. const (
  37291. UTF8 = Charset("UTF-8")
  37292. GB18030 = Charset("GB18030")
  37293. )
  37294. func ConvertToString(src string, srcCode string, tagCode string) string {
  37295. srcCoder := mahonia.NewDecoder(srcCode)
  37296. srcResult := srcCoder.ConvertString(src)
  37297. tagCoder := mahonia.NewDecoder(tagCode)
  37298. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37299. result := string(cdata)
  37300. return result
  37301. }
  37302. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37303. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37304. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37305. var token string
  37306. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37307. var api string
  37308. if miConfig.MdtrtareaAdmvs == "320921" {
  37309. 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 +
  37310. "&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
  37311. fmt.Println(api)
  37312. } else {
  37313. 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 +
  37314. "&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
  37315. }
  37316. resp, requestErr := http.Get(api)
  37317. if requestErr != nil {
  37318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37319. return ""
  37320. }
  37321. body, ioErr := ioutil.ReadAll(resp.Body)
  37322. if ioErr != nil {
  37323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37325. return ""
  37326. }
  37327. var respJSON map[string]interface{}
  37328. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37331. return ""
  37332. }
  37333. var status string
  37334. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37335. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37336. var res ResultTwo //1101结果
  37337. var res10265 ResultTwo10265 //1101结果
  37338. if status == "0" { //读卡成功
  37339. var card_info string //卡信息
  37340. var busi_card_info string
  37341. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37342. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37343. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37344. fmt.Println(card_info)
  37345. fmt.Println(busi_card_info)
  37346. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37347. result, _ := json.Marshal(respJSON)
  37348. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37349. utils.ErrorLog("解析失败:%v", err)
  37350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37351. return ""
  37352. }
  37353. res.ErrMsg = res10265.ErrMsg
  37354. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37355. res.Infcode = infocode
  37356. res.Output = res10265.Output
  37357. res.InfRefmsgid = res10265.InfRefmsgid
  37358. if res.Infcode == 0 {
  37359. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37360. if err == gorm.ErrRecordNotFound {
  37361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37362. return ""
  37363. } else if err != nil {
  37364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37365. return ""
  37366. } else {
  37367. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37368. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37369. infoStr := string(Iinfos)
  37370. idetinfoStr := string(Idetinfos)
  37371. psn := &models.HisPsn{
  37372. PsnNo: res.Output.Baseinfo.PsnNo,
  37373. PatientId: patient.ID,
  37374. Certno: res.Output.Baseinfo.Certno,
  37375. Gend: res.Output.Baseinfo.Gend,
  37376. Naty: res.Output.Baseinfo.Naty,
  37377. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37378. PsnName: res.Output.Baseinfo.PsnName,
  37379. Idetinfo: idetinfoStr,
  37380. Insuinfo: infoStr,
  37381. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37382. CardInfo: card_info,
  37383. VerifyNumber: token,
  37384. }
  37385. service.CreateHisPsn(psn)
  37386. return token
  37387. }
  37388. }
  37389. } else {
  37390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37391. return ""
  37392. }
  37393. } else { //读卡失败
  37394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37395. return ""
  37396. }
  37397. return token
  37398. }
  37399. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37400. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37401. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37402. var token string
  37403. var api string
  37404. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37405. "&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
  37406. fmt.Println(api)
  37407. resp, requestErr := http.Get(api)
  37408. if requestErr != nil {
  37409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37410. return ""
  37411. }
  37412. body, ioErr := ioutil.ReadAll(resp.Body)
  37413. if ioErr != nil {
  37414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37416. return ""
  37417. }
  37418. var respJSON map[string]interface{}
  37419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37422. return ""
  37423. }
  37424. var status string
  37425. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37426. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37427. var res ResultTwo //1101结果
  37428. if status == "1" { //读卡成功
  37429. var card_info string //卡信息
  37430. var busi_card_info string
  37431. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37432. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37433. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37434. fmt.Println(card_info)
  37435. fmt.Println(busi_card_info)
  37436. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37437. result, _ := json.Marshal(respJSON)
  37438. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37439. utils.ErrorLog("解析失败:%v", err)
  37440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37441. return ""
  37442. }
  37443. if res.Infcode == 0 {
  37444. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37445. if err == gorm.ErrRecordNotFound {
  37446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37447. return ""
  37448. } else if err != nil {
  37449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37450. return ""
  37451. } else {
  37452. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37453. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37454. infoStr := string(Iinfos)
  37455. idetinfoStr := string(Idetinfos)
  37456. psn := &models.HisPsn{
  37457. PsnNo: res.Output.Baseinfo.PsnNo,
  37458. PatientId: patient.ID,
  37459. Certno: res.Output.Baseinfo.Certno,
  37460. Gend: res.Output.Baseinfo.Gend,
  37461. Naty: res.Output.Baseinfo.Naty,
  37462. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37463. PsnName: res.Output.Baseinfo.PsnName,
  37464. Idetinfo: idetinfoStr,
  37465. Insuinfo: infoStr,
  37466. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37467. CardInfo: card_info,
  37468. VerifyNumber: token,
  37469. }
  37470. service.CreateHisPsn(psn)
  37471. return token
  37472. }
  37473. }
  37474. } else {
  37475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37476. return ""
  37477. }
  37478. return token
  37479. }
  37480. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37481. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37482. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37483. var token string
  37484. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37485. var api string
  37486. if miConfig.MdtrtareaAdmvs == "320921" {
  37487. 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 +
  37488. "&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
  37489. fmt.Println(api)
  37490. } else {
  37491. 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 +
  37492. "&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
  37493. }
  37494. resp, requestErr := http.Get(api)
  37495. if requestErr != nil {
  37496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37497. return ""
  37498. }
  37499. body, ioErr := ioutil.ReadAll(resp.Body)
  37500. if ioErr != nil {
  37501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37503. return ""
  37504. }
  37505. var respJSON map[string]interface{}
  37506. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37509. return ""
  37510. }
  37511. var status string
  37512. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37513. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37514. var res ResultTwo //1101结果
  37515. var res10265 ResultTwo10265 //1101结果
  37516. if status == "0" { //读卡成功
  37517. var card_info string //卡信息
  37518. var busi_card_info string
  37519. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37520. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37521. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37522. fmt.Println(card_info)
  37523. fmt.Println(busi_card_info)
  37524. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37525. result, _ := json.Marshal(respJSON)
  37526. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37527. utils.ErrorLog("解析失败:%v", err)
  37528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37529. return ""
  37530. }
  37531. res.ErrMsg = res10265.ErrMsg
  37532. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37533. res.Infcode = infocode
  37534. res.Output = res10265.Output
  37535. res.InfRefmsgid = res10265.InfRefmsgid
  37536. if res.Infcode == 0 {
  37537. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37538. if err == gorm.ErrRecordNotFound {
  37539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37540. return ""
  37541. } else if err != nil {
  37542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37543. return ""
  37544. } else {
  37545. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37546. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37547. infoStr := string(Iinfos)
  37548. idetinfoStr := string(Idetinfos)
  37549. psn := &models.HisPsn{
  37550. PsnNo: res.Output.Baseinfo.PsnNo,
  37551. PatientId: patient.ID,
  37552. Certno: res.Output.Baseinfo.Certno,
  37553. Gend: res.Output.Baseinfo.Gend,
  37554. Naty: res.Output.Baseinfo.Naty,
  37555. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37556. PsnName: res.Output.Baseinfo.PsnName,
  37557. Idetinfo: idetinfoStr,
  37558. Insuinfo: infoStr,
  37559. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37560. CardInfo: card_info,
  37561. VerifyNumber: token,
  37562. }
  37563. service.CreateHisPsn(psn)
  37564. return token
  37565. }
  37566. }
  37567. } else {
  37568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37569. return ""
  37570. }
  37571. } else { //读卡失败
  37572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37573. return ""
  37574. }
  37575. return token
  37576. }
  37577. func DeleteExtraSpaceTwo(s string) string {
  37578. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37579. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37580. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37581. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37582. s2 := make([]byte, len(s1)) //定义字符数组切片
  37583. copy(s2, s1) //将字符串复制到切片
  37584. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37585. for len(spc_index) > 0 { //找到适配项
  37586. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37587. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37588. }
  37589. return string(s2)
  37590. }
  37591. func Remove0000(s string) string {
  37592. str := make([]rune, 0, len(s))
  37593. for _, v := range []rune(s) {
  37594. if v == 0 {
  37595. continue
  37596. }
  37597. str = append(str, v)
  37598. }
  37599. return string(str)
  37600. }
  37601. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37602. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37603. readCard := DllDef.MustFindProc("EcQuery")
  37604. pCardInfo := make([]byte, 8192)
  37605. pBusiCardInfo := make([]byte, 8192)
  37606. data := make(map[string]interface{})
  37607. //pData := make(map[string]interface{})
  37608. inputData := make(map[string]interface{})
  37609. inputData["orgId"] = code
  37610. inputData["businessType"] = "01101"
  37611. inputData["operatorId"] = operator_id
  37612. inputData["operatorName"] = operator_name
  37613. inputData["officeId"] = "001"
  37614. inputData["officeName"] = "血透室"
  37615. //
  37616. data["data"] = inputData
  37617. data["transType"] = "ec.query"
  37618. data["orgId"] = code
  37619. bytesData, _ := json.Marshal(data)
  37620. pCardInfo = bytesData
  37621. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37622. fmt.Println(ret2)
  37623. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37624. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37625. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37626. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37627. if ret2 != 0 {
  37628. return "", ""
  37629. }
  37630. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37631. }
  37632. func DeleteExtraSpace(s string) string {
  37633. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37634. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37635. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37636. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37637. s2 := make([]byte, len(s1)) //定义字符数组切片
  37638. copy(s2, s1) //将字符串复制到切片
  37639. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37640. for len(spc_index) > 0 { //找到适配项
  37641. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37642. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37643. }
  37644. return string(s2)
  37645. }
  37646. // 对账
  37647. func (c *HisApiController) Post3202() {
  37648. start_time := c.GetString("start_time")
  37649. end_time := c.GetString("end_time")
  37650. //insutype := c.GetString("insutype")
  37651. clr_type := c.GetString("clr_type")
  37652. clr_org := c.GetString("clr_optins")
  37653. admin_user_id, _ := c.GetInt64("admin_user_id")
  37654. adminUser := c.GetAdminUserInfo()
  37655. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37656. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37657. if len(clr_org) == 0 {
  37658. clr_org = miConfig.MdtrtareaAdmvs
  37659. }
  37660. timeLayout := "2006-01-02"
  37661. loc, _ := time.LoadLocation("Local")
  37662. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37663. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37664. var orders []*models.HisOrder
  37665. if clr_org == "421300" {
  37666. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37667. } else if clr_org == "420902" {
  37668. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37669. } else {
  37670. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37671. }
  37672. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37673. //fixmedins_setl_cnt := int64(len(orders))
  37674. var medfee_sumamt float64
  37675. var acct_pay float64
  37676. var fund_pay_sumamt float64
  37677. for _, item := range orders {
  37678. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37679. acct_pay = acct_pay + item.AcctPay
  37680. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37681. }
  37682. //var medfee_sumamt_two float64
  37683. //var acct_pay_two float64
  37684. //var fund_pay_sumamt_two float64
  37685. //for _, item := range orders_two {
  37686. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37687. // acct_pay_two = acct_pay_two + item.AcctPay
  37688. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37689. //}
  37690. //var user_name string
  37691. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37692. //if role.ID == 0 {
  37693. // user_name = "xxx"
  37694. //} else {
  37695. // user_name = role.UserName
  37696. //}
  37697. var res ResultSix
  37698. if config.IsOpen == 1 {
  37699. var bps []*models.BusinessParamsTwo
  37700. var bp models.BusinessParamsTwo
  37701. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37702. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37703. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37704. bp.MedfeeSumamt = medfee_sumamt_str
  37705. bp.AcctPay = acct_pay_str
  37706. bp.FundPaySumamt = fund_pay_sumamt_str
  37707. bp.Insutype = ""
  37708. bp.StmtBegndate = start_time
  37709. bp.ClrType = clr_type
  37710. bp.SetlOptins = clr_org
  37711. bp.StmtEnddate = end_time
  37712. bps = append(bps, &bp)
  37713. data := make(map[string]interface{})
  37714. data["bps"] = bps
  37715. data["org_name"] = miConfig.OrgName
  37716. data["doctor"] = role.UserName
  37717. data["fixmedins_code"] = miConfig.Code
  37718. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37719. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37720. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37721. if miConfig.MdtrtareaAdmvs == "421300" {
  37722. client := &http.Client{}
  37723. bytesData, _ := json.Marshal(data)
  37724. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37725. resp, _ := client.Do(req)
  37726. defer resp.Body.Close()
  37727. body, ioErr := ioutil.ReadAll(resp.Body)
  37728. if ioErr != nil {
  37729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37731. return
  37732. }
  37733. var respJSON map[string]interface{}
  37734. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37737. return
  37738. }
  37739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37740. userJSONBytes, _ := json.Marshal(respJSON)
  37741. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37742. utils.ErrorLog("解析失败:%v", err)
  37743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37744. return
  37745. }
  37746. }
  37747. if miConfig.MdtrtareaAdmvs == "420200" {
  37748. client := &http.Client{}
  37749. bytesData, _ := json.Marshal(data)
  37750. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37751. resp, _ := client.Do(req)
  37752. defer resp.Body.Close()
  37753. body, ioErr := ioutil.ReadAll(resp.Body)
  37754. if ioErr != nil {
  37755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37757. return
  37758. }
  37759. var respJSON map[string]interface{}
  37760. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37763. return
  37764. }
  37765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37766. userJSONBytes, _ := json.Marshal(respJSON)
  37767. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37768. utils.ErrorLog("解析失败:%v", err)
  37769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37770. return
  37771. }
  37772. }
  37773. if miConfig.MdtrtareaAdmvs == "421182" {
  37774. client := &http.Client{}
  37775. bytesData, _ := json.Marshal(data)
  37776. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37777. resp, _ := client.Do(req)
  37778. defer resp.Body.Close()
  37779. body, ioErr := ioutil.ReadAll(resp.Body)
  37780. if ioErr != nil {
  37781. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37783. return
  37784. }
  37785. var respJSON map[string]interface{}
  37786. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37789. return
  37790. }
  37791. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37792. userJSONBytes, _ := json.Marshal(respJSON)
  37793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37794. utils.ErrorLog("解析失败:%v", err)
  37795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37796. return
  37797. }
  37798. }
  37799. if miConfig.MdtrtareaAdmvs == "420902" {
  37800. client := &http.Client{}
  37801. bytesData, _ := json.Marshal(data)
  37802. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37803. resp, _ := client.Do(req)
  37804. defer resp.Body.Close()
  37805. body, ioErr := ioutil.ReadAll(resp.Body)
  37806. if ioErr != nil {
  37807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37809. return
  37810. }
  37811. var respJSON map[string]interface{}
  37812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37815. return
  37816. }
  37817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37818. userJSONBytes, _ := json.Marshal(respJSON)
  37819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37820. utils.ErrorLog("解析失败:%v", err)
  37821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37822. return
  37823. }
  37824. }
  37825. if res.Infcode == 0 {
  37826. c.ServeSuccessJSON(map[string]interface{}{
  37827. "msg": "发起成功",
  37828. })
  37829. } else {
  37830. c.ServeSuccessJSON(map[string]interface{}{
  37831. "failed_code": -10,
  37832. "msg": res.ErrMsg,
  37833. })
  37834. }
  37835. }
  37836. }
  37837. func (c *HisApiController) Post3204a() {
  37838. start_time := c.GetString("start_time")
  37839. end_time := c.GetString("end_time")
  37840. //insutype := c.GetString("insutype")
  37841. clr_type := c.GetString("clr_type")
  37842. clr_org := c.GetString("clr_optins")
  37843. admin_user_id, _ := c.GetInt64("admin_user_id")
  37844. adminUser := c.GetAdminUserInfo()
  37845. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37846. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37847. if len(clr_org) == 0 {
  37848. clr_org = miConfig.MdtrtareaAdmvs
  37849. }
  37850. timeLayout := "2006-01-02"
  37851. loc, _ := time.LoadLocation("Local")
  37852. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37853. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37854. var orders []*models.HisOrder
  37855. if clr_org == "421300" {
  37856. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37857. } else if clr_org == "420902" {
  37858. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37859. } else {
  37860. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37861. }
  37862. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37863. //fixmedins_setl_cnt := int64(len(orders))
  37864. var medfee_sumamt float64
  37865. var acct_pay float64
  37866. var fund_pay_sumamt float64
  37867. for _, item := range orders {
  37868. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37869. acct_pay = acct_pay + item.AcctPay
  37870. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37871. }
  37872. //var medfee_sumamt_two float64
  37873. //var acct_pay_two float64
  37874. //var fund_pay_sumamt_two float64
  37875. //for _, item := range orders_two {
  37876. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37877. // acct_pay_two = acct_pay_two + item.AcctPay
  37878. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37879. //}
  37880. //var user_name string
  37881. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37882. //if role.ID == 0 {
  37883. // user_name = "xxx"
  37884. //} else {
  37885. // user_name = role.UserName
  37886. //}
  37887. var res ResultSix
  37888. if config.IsOpen == 1 {
  37889. var bps []*models.BusinessParamsTwo
  37890. var bp models.BusinessParamsTwo
  37891. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37892. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37893. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37894. bp.MedfeeSumamt = medfee_sumamt_str
  37895. bp.AcctPay = acct_pay_str
  37896. bp.FundPaySumamt = fund_pay_sumamt_str
  37897. bp.Insutype = ""
  37898. bp.StmtBegndate = start_time
  37899. bp.ClrType = clr_type
  37900. bp.SetlOptins = clr_org
  37901. bp.StmtEnddate = end_time
  37902. bps = append(bps, &bp)
  37903. data := make(map[string]interface{})
  37904. data["bps"] = bps
  37905. data["org_name"] = miConfig.OrgName
  37906. data["doctor"] = role.UserName
  37907. data["fixmedins_code"] = miConfig.Code
  37908. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37909. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37910. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37911. if miConfig.MdtrtareaAdmvs == "421300" {
  37912. client := &http.Client{}
  37913. bytesData, _ := json.Marshal(data)
  37914. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37915. resp, _ := client.Do(req)
  37916. defer resp.Body.Close()
  37917. body, ioErr := ioutil.ReadAll(resp.Body)
  37918. if ioErr != nil {
  37919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37921. return
  37922. }
  37923. var respJSON map[string]interface{}
  37924. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37927. return
  37928. }
  37929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37930. userJSONBytes, _ := json.Marshal(respJSON)
  37931. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37932. utils.ErrorLog("解析失败:%v", err)
  37933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37934. return
  37935. }
  37936. }
  37937. if miConfig.MdtrtareaAdmvs == "420200" {
  37938. client := &http.Client{}
  37939. bytesData, _ := json.Marshal(data)
  37940. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37941. resp, _ := client.Do(req)
  37942. defer resp.Body.Close()
  37943. body, ioErr := ioutil.ReadAll(resp.Body)
  37944. if ioErr != nil {
  37945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37947. return
  37948. }
  37949. var respJSON map[string]interface{}
  37950. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37953. return
  37954. }
  37955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37956. userJSONBytes, _ := json.Marshal(respJSON)
  37957. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37958. utils.ErrorLog("解析失败:%v", err)
  37959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37960. return
  37961. }
  37962. }
  37963. if miConfig.MdtrtareaAdmvs == "421182" {
  37964. client := &http.Client{}
  37965. bytesData, _ := json.Marshal(data)
  37966. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37967. resp, _ := client.Do(req)
  37968. defer resp.Body.Close()
  37969. body, ioErr := ioutil.ReadAll(resp.Body)
  37970. if ioErr != nil {
  37971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37973. return
  37974. }
  37975. var respJSON map[string]interface{}
  37976. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37979. return
  37980. }
  37981. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37982. userJSONBytes, _ := json.Marshal(respJSON)
  37983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37984. utils.ErrorLog("解析失败:%v", err)
  37985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37986. return
  37987. }
  37988. }
  37989. if miConfig.MdtrtareaAdmvs == "420902" {
  37990. client := &http.Client{}
  37991. bytesData, _ := json.Marshal(data)
  37992. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37993. resp, _ := client.Do(req)
  37994. defer resp.Body.Close()
  37995. body, ioErr := ioutil.ReadAll(resp.Body)
  37996. if ioErr != nil {
  37997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37999. return
  38000. }
  38001. var respJSON map[string]interface{}
  38002. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38005. return
  38006. }
  38007. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38008. userJSONBytes, _ := json.Marshal(respJSON)
  38009. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38010. utils.ErrorLog("解析失败:%v", err)
  38011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38012. return
  38013. }
  38014. }
  38015. if res.Infcode == 0 {
  38016. c.ServeSuccessJSON(map[string]interface{}{
  38017. "msg": "撤销成功",
  38018. })
  38019. } else {
  38020. c.ServeSuccessJSON(map[string]interface{}{
  38021. "failed_code": -10,
  38022. "msg": res.ErrMsg,
  38023. })
  38024. }
  38025. }
  38026. }
  38027. func (c *HisApiController) Post3204() {
  38028. admin_user_id, _ := c.GetInt64("admin_user_id")
  38029. id := c.GetString("id")
  38030. adminUser := c.GetAdminUserInfo()
  38031. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38032. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38033. //clr_org := miConfig.MdtrtareaAdmvs
  38034. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38035. var res ResultSix
  38036. if config.IsOpen == 1 {
  38037. data := make(map[string]interface{})
  38038. data["id"] = id
  38039. data["org_name"] = miConfig.OrgName
  38040. data["doctor"] = role.UserName
  38041. data["fixmedins_code"] = miConfig.Code
  38042. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38043. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38044. client := &http.Client{}
  38045. bytesData, _ := json.Marshal(data)
  38046. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38047. resp, _ := client.Do(req)
  38048. defer resp.Body.Close()
  38049. body, ioErr := ioutil.ReadAll(resp.Body)
  38050. if ioErr != nil {
  38051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38053. return
  38054. }
  38055. var respJSON map[string]interface{}
  38056. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38059. return
  38060. }
  38061. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38062. userJSONBytes, _ := json.Marshal(respJSON)
  38063. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38064. utils.ErrorLog("解析失败:%v", err)
  38065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38066. return
  38067. }
  38068. if res.Infcode == 0 {
  38069. c.ServeSuccessJSON(map[string]interface{}{
  38070. "msg": "发起成功",
  38071. })
  38072. } else {
  38073. c.ServeSuccessJSON(map[string]interface{}{
  38074. "failed_code": -10,
  38075. "msg": res.ErrMsg,
  38076. })
  38077. }
  38078. }
  38079. }
  38080. func (c *HisApiController) Post8404() {
  38081. admin_user_id, _ := c.GetInt64("admin_user_id")
  38082. month := c.GetString("month")
  38083. adminUser := c.GetAdminUserInfo()
  38084. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38085. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38086. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38087. var res ResultSix
  38088. if config.IsOpen == 1 {
  38089. data := make(map[string]interface{})
  38090. data["month"] = month
  38091. data["org_name"] = miConfig.OrgName
  38092. data["doctor"] = role.UserName
  38093. data["fixmedins_code"] = miConfig.Code
  38094. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38095. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38096. client := &http.Client{}
  38097. bytesData, _ := json.Marshal(data)
  38098. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38099. resp, _ := client.Do(req)
  38100. defer resp.Body.Close()
  38101. body, ioErr := ioutil.ReadAll(resp.Body)
  38102. if ioErr != nil {
  38103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38105. return
  38106. }
  38107. var respJSON map[string]interface{}
  38108. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38111. return
  38112. }
  38113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38114. userJSONBytes, _ := json.Marshal(respJSON)
  38115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38116. utils.ErrorLog("解析失败:%v", err)
  38117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38118. return
  38119. }
  38120. if res.Infcode == 0 {
  38121. c.ServeSuccessJSON(map[string]interface{}{
  38122. "msg": "查询成功",
  38123. })
  38124. } else {
  38125. c.ServeSuccessJSON(map[string]interface{}{
  38126. "failed_code": -10,
  38127. "msg": res.ErrMsg,
  38128. })
  38129. }
  38130. }
  38131. }
  38132. func (c *HisApiController) Post3202b() {
  38133. start_time := c.GetString("start_time")
  38134. end_time := c.GetString("end_time")
  38135. //insutype := c.GetString("insutype")
  38136. clr_type := c.GetString("clr_type")
  38137. clr_org := c.GetString("clr_optins")
  38138. admin_user_id, _ := c.GetInt64("admin_user_id")
  38139. adminUser := c.GetAdminUserInfo()
  38140. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38141. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38142. if len(clr_org) == 0 {
  38143. clr_org = miConfig.MdtrtareaAdmvs
  38144. }
  38145. timeLayout := "2006-01-02"
  38146. loc, _ := time.LoadLocation("Local")
  38147. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38148. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38149. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38150. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38151. //fixmedins_setl_cnt := int64(len(orders))
  38152. var medfee_sumamt float64
  38153. var acct_pay float64
  38154. var fund_pay_sumamt float64
  38155. for _, item := range orders {
  38156. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38157. acct_pay = acct_pay + item.AcctPay
  38158. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38159. }
  38160. //var medfee_sumamt_two float64
  38161. //var acct_pay_two float64
  38162. //var fund_pay_sumamt_two float64
  38163. //for _, item := range orders_two {
  38164. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38165. // acct_pay_two = acct_pay_two + item.AcctPay
  38166. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38167. //}
  38168. //var user_name string
  38169. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38170. //if role.ID == 0 {
  38171. // user_name = "xxx"
  38172. //} else {
  38173. // user_name = role.UserName
  38174. //}
  38175. var res ResultSix
  38176. if config.IsOpen == 1 {
  38177. var bps []*models.BusinessParamsTwo
  38178. var bp models.BusinessParamsTwo
  38179. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38180. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38181. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38182. bp.MedfeeSumamt = medfee_sumamt_str
  38183. bp.AcctPay = acct_pay_str
  38184. bp.FundPaySumamt = fund_pay_sumamt_str
  38185. bp.Insutype = "390"
  38186. bp.StmtBegndate = start_time
  38187. bp.ClrType = clr_type
  38188. bp.SetlOptins = clr_org
  38189. bp.StmtEnddate = end_time
  38190. bps = append(bps, &bp)
  38191. data := make(map[string]interface{})
  38192. data["bps"] = bps
  38193. data["org_name"] = miConfig.OrgName
  38194. data["doctor"] = role.UserName
  38195. data["fixmedins_code"] = miConfig.Code
  38196. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38197. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38198. if miConfig.MdtrtareaAdmvs == "421300" {
  38199. client := &http.Client{}
  38200. bytesData, _ := json.Marshal(data)
  38201. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38202. resp, _ := client.Do(req)
  38203. defer resp.Body.Close()
  38204. body, ioErr := ioutil.ReadAll(resp.Body)
  38205. if ioErr != nil {
  38206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38208. return
  38209. }
  38210. var respJSON map[string]interface{}
  38211. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38214. return
  38215. }
  38216. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38217. userJSONBytes, _ := json.Marshal(respJSON)
  38218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38219. utils.ErrorLog("解析失败:%v", err)
  38220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38221. return
  38222. }
  38223. }
  38224. if miConfig.MdtrtareaAdmvs == "420200" {
  38225. client := &http.Client{}
  38226. bytesData, _ := json.Marshal(data)
  38227. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38228. resp, _ := client.Do(req)
  38229. defer resp.Body.Close()
  38230. body, ioErr := ioutil.ReadAll(resp.Body)
  38231. if ioErr != nil {
  38232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38234. return
  38235. }
  38236. var respJSON map[string]interface{}
  38237. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38240. return
  38241. }
  38242. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38243. userJSONBytes, _ := json.Marshal(respJSON)
  38244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38245. utils.ErrorLog("解析失败:%v", err)
  38246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38247. return
  38248. }
  38249. }
  38250. if miConfig.MdtrtareaAdmvs == "421182" {
  38251. client := &http.Client{}
  38252. bytesData, _ := json.Marshal(data)
  38253. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38254. resp, _ := client.Do(req)
  38255. defer resp.Body.Close()
  38256. body, ioErr := ioutil.ReadAll(resp.Body)
  38257. if ioErr != nil {
  38258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38260. return
  38261. }
  38262. var respJSON map[string]interface{}
  38263. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38266. return
  38267. }
  38268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38269. userJSONBytes, _ := json.Marshal(respJSON)
  38270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38271. utils.ErrorLog("解析失败:%v", err)
  38272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38273. return
  38274. }
  38275. }
  38276. if res.Infcode == 0 {
  38277. c.ServeSuccessJSON(map[string]interface{}{
  38278. "msg": "发起成功",
  38279. })
  38280. } else {
  38281. c.ServeSuccessJSON(map[string]interface{}{
  38282. "failed_code": -10,
  38283. "msg": res.ErrMsg,
  38284. })
  38285. }
  38286. }
  38287. }
  38288. func (c *HisApiController) Post1608() {
  38289. start_time := c.GetString("start_time")
  38290. end_time := c.GetString("end_time")
  38291. admin_user_id, _ := c.GetInt64("admin_user_id")
  38292. adminUser := c.GetAdminUserInfo()
  38293. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38294. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38295. timeLayout := "2006-01-02"
  38296. loc, _ := time.LoadLocation("Local")
  38297. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38298. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38299. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38300. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38301. fixmedins_setl_cnt := int64(len(orders))
  38302. var medfee_sumamt float64
  38303. var func_smamt float64
  38304. for _, item := range orders {
  38305. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38306. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38307. }
  38308. times := strings.Split(start_time, "-")
  38309. time_tows := strings.Split(end_time, "-")
  38310. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38311. var res ResultSix
  38312. if config.IsOpen == 1 {
  38313. //var bps []*models.BusinessParamsTwo
  38314. //var bp models.BusinessParamsTwo
  38315. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38316. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38317. data := make(map[string]interface{})
  38318. data["org_name"] = miConfig.OrgName
  38319. data["doctor"] = role.UserName
  38320. data["func_smamt"] = func_smamt_str
  38321. data["fixmedins_code"] = miConfig.Code
  38322. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38323. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38324. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38325. data["medfee_sumamt"] = medfee_sumamt_str
  38326. data["start_time"] = times[0] + times[1] + times[2]
  38327. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38328. if miConfig.MdtrtareaAdmvs == "421300" {
  38329. client := &http.Client{}
  38330. bytesData, _ := json.Marshal(data)
  38331. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38332. resp, _ := client.Do(req)
  38333. defer resp.Body.Close()
  38334. body, ioErr := ioutil.ReadAll(resp.Body)
  38335. if ioErr != nil {
  38336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38338. return
  38339. }
  38340. var respJSON map[string]interface{}
  38341. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38344. return
  38345. }
  38346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38347. userJSONBytes, _ := json.Marshal(respJSON)
  38348. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38349. utils.ErrorLog("解析失败:%v", err)
  38350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38351. return
  38352. }
  38353. }
  38354. if miConfig.MdtrtareaAdmvs == "420200" {
  38355. client := &http.Client{}
  38356. bytesData, _ := json.Marshal(data)
  38357. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38358. resp, _ := client.Do(req)
  38359. defer resp.Body.Close()
  38360. body, ioErr := ioutil.ReadAll(resp.Body)
  38361. if ioErr != nil {
  38362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38364. return
  38365. }
  38366. var respJSON map[string]interface{}
  38367. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38370. return
  38371. }
  38372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38373. userJSONBytes, _ := json.Marshal(respJSON)
  38374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38375. utils.ErrorLog("解析失败:%v", err)
  38376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38377. return
  38378. }
  38379. }
  38380. if miConfig.MdtrtareaAdmvs == "421182" {
  38381. client := &http.Client{}
  38382. bytesData, _ := json.Marshal(data)
  38383. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38384. resp, _ := client.Do(req)
  38385. defer resp.Body.Close()
  38386. body, ioErr := ioutil.ReadAll(resp.Body)
  38387. if ioErr != nil {
  38388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38390. return
  38391. }
  38392. var respJSON map[string]interface{}
  38393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38396. return
  38397. }
  38398. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38399. userJSONBytes, _ := json.Marshal(respJSON)
  38400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38401. utils.ErrorLog("解析失败:%v", err)
  38402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38403. return
  38404. }
  38405. }
  38406. if res.Infcode == 0 {
  38407. c.ServeSuccessJSON(map[string]interface{}{
  38408. "msg": "发起成功",
  38409. })
  38410. } else {
  38411. c.ServeSuccessJSON(map[string]interface{}{
  38412. "failed_code": -10,
  38413. "msg": res.ErrMsg,
  38414. })
  38415. }
  38416. }
  38417. }
  38418. // 5.11.1.1【5262】结算信息按时间段查询
  38419. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38420. admin_user_id, _ := c.GetInt64("admin_user_id")
  38421. adminUser := c.GetAdminUserInfo()
  38422. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38423. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38424. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38425. var res Result5262
  38426. if config.IsOpen == 1 {
  38427. if miConfig.MdtrtareaAdmvs == "421300" {
  38428. data := make(map[string]interface{})
  38429. data["bps"] = bp
  38430. data["org_name"] = miConfig.OrgName
  38431. data["doctor"] = role.UserName
  38432. data["fixmedins_code"] = miConfig.Code
  38433. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38434. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38435. data["page"] = strconv.FormatInt(page, 10)
  38436. data["limit"] = strconv.FormatInt(limit, 10)
  38437. fmt.Println(data)
  38438. client := &http.Client{}
  38439. bytesData, _ := json.Marshal(data)
  38440. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38441. resp, _ := client.Do(req)
  38442. defer resp.Body.Close()
  38443. body, ioErr := ioutil.ReadAll(resp.Body)
  38444. if ioErr != nil {
  38445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38447. return
  38448. }
  38449. var respJSON map[string]interface{}
  38450. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38453. return
  38454. }
  38455. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38456. userJSONBytes, _ := json.Marshal(respJSON)
  38457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38458. utils.ErrorLog("解析失败:%v", err)
  38459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38460. return
  38461. }
  38462. }
  38463. if miConfig.MdtrtareaAdmvs == "420200" {
  38464. data := make(map[string]interface{})
  38465. data["bps"] = bp
  38466. data["org_name"] = miConfig.OrgName
  38467. data["doctor"] = role.UserName
  38468. data["fixmedins_code"] = miConfig.Code
  38469. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38470. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38471. data["page"] = strconv.FormatInt(page, 10)
  38472. data["limit"] = strconv.FormatInt(limit, 10)
  38473. fmt.Println(data)
  38474. client := &http.Client{}
  38475. bytesData, _ := json.Marshal(data)
  38476. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38477. resp, _ := client.Do(req)
  38478. defer resp.Body.Close()
  38479. body, ioErr := ioutil.ReadAll(resp.Body)
  38480. if ioErr != nil {
  38481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38483. return
  38484. }
  38485. var respJSON map[string]interface{}
  38486. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38489. return
  38490. }
  38491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38492. userJSONBytes, _ := json.Marshal(respJSON)
  38493. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38494. utils.ErrorLog("解析失败:%v", err)
  38495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38496. return
  38497. }
  38498. }
  38499. if miConfig.MdtrtareaAdmvs == "421182" {
  38500. data := make(map[string]interface{})
  38501. data["bps"] = bp
  38502. data["org_name"] = miConfig.OrgName
  38503. data["doctor"] = role.UserName
  38504. data["fixmedins_code"] = miConfig.Code
  38505. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38506. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38507. data["page"] = strconv.FormatInt(page, 10)
  38508. data["limit"] = strconv.FormatInt(limit, 10)
  38509. fmt.Println(data)
  38510. client := &http.Client{}
  38511. bytesData, _ := json.Marshal(data)
  38512. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38513. resp, _ := client.Do(req)
  38514. defer resp.Body.Close()
  38515. body, ioErr := ioutil.ReadAll(resp.Body)
  38516. if ioErr != nil {
  38517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38519. return
  38520. }
  38521. var respJSON map[string]interface{}
  38522. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38525. return
  38526. }
  38527. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38528. userJSONBytes, _ := json.Marshal(respJSON)
  38529. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38530. utils.ErrorLog("解析失败:%v", err)
  38531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38532. return
  38533. }
  38534. }
  38535. if miConfig.MdtrtareaAdmvs == "420902" {
  38536. data := make(map[string]interface{})
  38537. data["bps"] = bp
  38538. data["org_name"] = miConfig.OrgName
  38539. data["doctor"] = role.UserName
  38540. data["fixmedins_code"] = miConfig.Code
  38541. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38542. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38543. data["page"] = strconv.FormatInt(page, 10)
  38544. data["limit"] = strconv.FormatInt(limit, 10)
  38545. fmt.Println(data)
  38546. client := &http.Client{}
  38547. bytesData, _ := json.Marshal(data)
  38548. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38549. resp, _ := client.Do(req)
  38550. defer resp.Body.Close()
  38551. body, ioErr := ioutil.ReadAll(resp.Body)
  38552. if ioErr != nil {
  38553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38555. return
  38556. }
  38557. var respJSON map[string]interface{}
  38558. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38561. return
  38562. }
  38563. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38564. userJSONBytes, _ := json.Marshal(respJSON)
  38565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38566. utils.ErrorLog("解析失败:%v", err)
  38567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38568. return
  38569. }
  38570. }
  38571. if res.Infcode == 0 {
  38572. c.ServeSuccessJSON(map[string]interface{}{
  38573. "order": res.Output.Result,
  38574. "total": res.Output.PageInfo.RecordCounts,
  38575. })
  38576. } else {
  38577. c.ServeSuccessJSON(map[string]interface{}{
  38578. "failed_code": -10,
  38579. "msg": res.ErrMsg,
  38580. })
  38581. }
  38582. }
  38583. }
  38584. // 5.11.1.2【5267】异地结算信息时间段查询
  38585. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38586. admin_user_id, _ := c.GetInt64("admin_user_id")
  38587. adminUser := c.GetAdminUserInfo()
  38588. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38589. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38590. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38591. var res Result5267
  38592. if config.IsOpen == 1 {
  38593. if miConfig.MdtrtareaAdmvs == "421300" {
  38594. data := make(map[string]interface{})
  38595. data["bps"] = bp
  38596. data["org_name"] = miConfig.OrgName
  38597. data["doctor"] = role.UserName
  38598. data["fixmedins_code"] = miConfig.Code
  38599. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38600. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38601. data["page"] = page
  38602. data["limit"] = limit
  38603. fmt.Println(data)
  38604. client := &http.Client{}
  38605. bytesData, _ := json.Marshal(data)
  38606. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38607. resp, _ := client.Do(req)
  38608. defer resp.Body.Close()
  38609. body, ioErr := ioutil.ReadAll(resp.Body)
  38610. if ioErr != nil {
  38611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38613. return
  38614. }
  38615. var respJSON map[string]interface{}
  38616. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38619. return
  38620. }
  38621. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38622. userJSONBytes, _ := json.Marshal(respJSON)
  38623. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38624. utils.ErrorLog("解析失败:%v", err)
  38625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38626. return
  38627. }
  38628. }
  38629. if miConfig.MdtrtareaAdmvs == "420200" {
  38630. data := make(map[string]interface{})
  38631. data["bps"] = bp
  38632. data["org_name"] = miConfig.OrgName
  38633. data["doctor"] = role.UserName
  38634. data["fixmedins_code"] = miConfig.Code
  38635. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38636. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38637. data["page"] = page
  38638. data["limit"] = limit
  38639. fmt.Println(data)
  38640. client := &http.Client{}
  38641. bytesData, _ := json.Marshal(data)
  38642. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38643. resp, _ := client.Do(req)
  38644. defer resp.Body.Close()
  38645. body, ioErr := ioutil.ReadAll(resp.Body)
  38646. if ioErr != nil {
  38647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38649. return
  38650. }
  38651. var respJSON map[string]interface{}
  38652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38655. return
  38656. }
  38657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38658. userJSONBytes, _ := json.Marshal(respJSON)
  38659. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38660. utils.ErrorLog("解析失败:%v", err)
  38661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38662. return
  38663. }
  38664. }
  38665. if miConfig.MdtrtareaAdmvs == "421182" {
  38666. data := make(map[string]interface{})
  38667. data["bps"] = bp
  38668. data["org_name"] = miConfig.OrgName
  38669. data["doctor"] = role.UserName
  38670. data["fixmedins_code"] = miConfig.Code
  38671. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38672. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38673. data["page"] = page
  38674. data["limit"] = limit
  38675. fmt.Println(data)
  38676. client := &http.Client{}
  38677. bytesData, _ := json.Marshal(data)
  38678. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38679. resp, _ := client.Do(req)
  38680. defer resp.Body.Close()
  38681. body, ioErr := ioutil.ReadAll(resp.Body)
  38682. if ioErr != nil {
  38683. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38685. return
  38686. }
  38687. var respJSON map[string]interface{}
  38688. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38691. return
  38692. }
  38693. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38694. userJSONBytes, _ := json.Marshal(respJSON)
  38695. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38696. utils.ErrorLog("解析失败:%v", err)
  38697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38698. return
  38699. }
  38700. }
  38701. if res.Infcode == 0 {
  38702. c.ServeSuccessJSON(map[string]interface{}{
  38703. "order": res.Output.Result,
  38704. "total": res.Output.PageInfo.RecordCounts,
  38705. })
  38706. } else {
  38707. c.ServeSuccessJSON(map[string]interface{}{
  38708. "failed_code": -10,
  38709. "msg": res.ErrMsg,
  38710. })
  38711. }
  38712. }
  38713. }
  38714. func (c *HisApiController) Post3501() {
  38715. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38716. data := make(map[string]interface{})
  38717. var struct3501s []models.Struct3501
  38718. var struct3501 models.Struct3501
  38719. struct3501.OrgName = miConfig.OrgName
  38720. struct3501.AccessKey = miConfig.AccessKey
  38721. struct3501.RequestUrl = miConfig.Url
  38722. struct3501.SecretKey = miConfig.SecretKey
  38723. struct3501.ManuDate = "2022-08-17"
  38724. struct3501.FixmedinsBchno = ""
  38725. struct3501.ManuLotnum = ""
  38726. struct3501.RxFlag = "0"
  38727. struct3501.ExpyEnd = "2022-08-17"
  38728. struct3501.Invdate = "2022-08-17"
  38729. struct3501.InvCnt = "20.25"
  38730. struct3501.Memo = ""
  38731. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38732. struct3501.FixmedinsHilistId = miConfig.Code
  38733. struct3501.FixmedinsHilistName = miConfig.OrgName
  38734. struct3501s = append(struct3501s, struct3501)
  38735. data["struct_3501s"] = struct3501s
  38736. client := &http.Client{}
  38737. bytesData, _ := json.Marshal(data)
  38738. var req *http.Request
  38739. if miConfig.MdtrtareaAdmvs == "320921" {
  38740. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38741. } else {
  38742. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38743. }
  38744. resp, _ := client.Do(req)
  38745. defer resp.Body.Close()
  38746. body, ioErr := ioutil.ReadAll(resp.Body)
  38747. if ioErr != nil {
  38748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38750. return
  38751. }
  38752. var respJSON map[string]interface{}
  38753. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38756. return
  38757. }
  38758. var res ResultSix
  38759. var resSix10265 ResultSix10265 //1101结果
  38760. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38761. result, _ := json.Marshal(respJSON)
  38762. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38763. utils.ErrorLog("解析失败:%v", err)
  38764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38765. return
  38766. }
  38767. res.InfRefmsgid = resSix10265.InfRefmsgid
  38768. res.Output = resSix10265.Output
  38769. res.ErrMsg = resSix10265.ErrMsg
  38770. res.Cainfo = resSix10265.Cainfo
  38771. res.WarnMsg = resSix10265.WarnMsg
  38772. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38773. res.Infcode = infocode
  38774. if infocode == 0 {
  38775. c.ServeSuccessJSON(map[string]interface{}{
  38776. "msg": "上传成功",
  38777. })
  38778. return
  38779. } else {
  38780. c.ServeSuccessJSON(map[string]interface{}{
  38781. "failed_code": -10,
  38782. "msg": res.ErrMsg,
  38783. })
  38784. return
  38785. }
  38786. }
  38787. func (c *HisApiController) Post3502() {
  38788. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38789. data := make(map[string]interface{})
  38790. var struct3502s []models.Struct3502
  38791. var struct3502 models.Struct3502
  38792. struct3502.OrgName = miConfig.OrgName
  38793. struct3502.AccessKey = miConfig.AccessKey
  38794. struct3502.RequestUrl = miConfig.Url
  38795. struct3502.SecretKey = miConfig.SecretKey
  38796. struct3502.ManuDate = "2022-08-15"
  38797. struct3502.FixmedinsBchno = ""
  38798. struct3502.ManuLotnum = ""
  38799. struct3502.RxFlag = "0"
  38800. struct3502.ExpyEnd = "2022-08-15"
  38801. struct3502.Invdate = "2022-08-15"
  38802. struct3502.InvCnt = "20.25"
  38803. struct3502.Memo = ""
  38804. struct3502.MedListCodg = "XB01ABD056B002020200517"
  38805. struct3502.FixmedinsHilistId = miConfig.Code
  38806. struct3502.FixmedinsHilistName = miConfig.OrgName
  38807. struct3502s = append(struct3502s, struct3502)
  38808. data["struct_3502s"] = struct3502s
  38809. client := &http.Client{}
  38810. bytesData, _ := json.Marshal(data)
  38811. var req *http.Request
  38812. if miConfig.MdtrtareaAdmvs == "320921" {
  38813. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38814. } else {
  38815. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38816. }
  38817. resp, _ := client.Do(req)
  38818. defer resp.Body.Close()
  38819. body, ioErr := ioutil.ReadAll(resp.Body)
  38820. if ioErr != nil {
  38821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38823. return
  38824. }
  38825. var respJSON map[string]interface{}
  38826. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38829. return
  38830. }
  38831. var res ResultSix
  38832. var resSix10265 ResultSix10265 //1101结果
  38833. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38834. result, _ := json.Marshal(respJSON)
  38835. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38836. utils.ErrorLog("解析失败:%v", err)
  38837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38838. return
  38839. }
  38840. res.InfRefmsgid = resSix10265.InfRefmsgid
  38841. res.Output = resSix10265.Output
  38842. res.ErrMsg = resSix10265.ErrMsg
  38843. res.Cainfo = resSix10265.Cainfo
  38844. res.WarnMsg = resSix10265.WarnMsg
  38845. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38846. res.Infcode = infocode
  38847. if infocode == 0 {
  38848. c.ServeSuccessJSON(map[string]interface{}{
  38849. "msg": "上传成功",
  38850. })
  38851. return
  38852. } else {
  38853. c.ServeSuccessJSON(map[string]interface{}{
  38854. "failed_code": -10,
  38855. "msg": res.ErrMsg,
  38856. })
  38857. return
  38858. }
  38859. }
  38860. func (c *HisApiController) Post3503() {
  38861. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38862. data := make(map[string]interface{})
  38863. var struct3501s []models.Struct3501
  38864. var struct3501 models.Struct3501
  38865. struct3501.OrgName = miConfig.OrgName
  38866. struct3501.AccessKey = miConfig.AccessKey
  38867. struct3501.RequestUrl = miConfig.Url
  38868. struct3501.SecretKey = miConfig.SecretKey
  38869. struct3501.ManuDate = "2022-08-15"
  38870. struct3501.FixmedinsBchno = ""
  38871. struct3501.ManuLotnum = ""
  38872. struct3501.RxFlag = "0"
  38873. struct3501.ExpyEnd = "2022-08-15"
  38874. struct3501.Invdate = "2022-08-15"
  38875. struct3501.InvCnt = "20.25"
  38876. struct3501.Memo = ""
  38877. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38878. struct3501.FixmedinsHilistId = miConfig.Code
  38879. struct3501.FixmedinsHilistName = miConfig.OrgName
  38880. struct3501s = append(struct3501s, struct3501)
  38881. data["struct_3501s"] = struct3501s
  38882. client := &http.Client{}
  38883. bytesData, _ := json.Marshal(data)
  38884. var req *http.Request
  38885. if miConfig.MdtrtareaAdmvs == "320921" {
  38886. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38887. } else {
  38888. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38889. }
  38890. resp, _ := client.Do(req)
  38891. defer resp.Body.Close()
  38892. body, ioErr := ioutil.ReadAll(resp.Body)
  38893. if ioErr != nil {
  38894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38896. return
  38897. }
  38898. var respJSON map[string]interface{}
  38899. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38902. return
  38903. }
  38904. var res ResultSix
  38905. var resSix10265 ResultSix10265 //1101结果
  38906. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38907. result, _ := json.Marshal(respJSON)
  38908. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38909. utils.ErrorLog("解析失败:%v", err)
  38910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38911. return
  38912. }
  38913. res.InfRefmsgid = resSix10265.InfRefmsgid
  38914. res.Output = resSix10265.Output
  38915. res.ErrMsg = resSix10265.ErrMsg
  38916. res.Cainfo = resSix10265.Cainfo
  38917. res.WarnMsg = resSix10265.WarnMsg
  38918. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38919. res.Infcode = infocode
  38920. if infocode == 0 {
  38921. c.ServeSuccessJSON(map[string]interface{}{
  38922. "msg": "上传成功",
  38923. })
  38924. return
  38925. } else {
  38926. c.ServeSuccessJSON(map[string]interface{}{
  38927. "failed_code": -10,
  38928. "msg": res.ErrMsg,
  38929. })
  38930. return
  38931. }
  38932. }
  38933. func (c *HisApiController) Post3504() {
  38934. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38935. data := make(map[string]interface{})
  38936. var struct3501s []models.Struct3501
  38937. var struct3501 models.Struct3501
  38938. struct3501.OrgName = miConfig.OrgName
  38939. struct3501.AccessKey = miConfig.AccessKey
  38940. struct3501.RequestUrl = miConfig.Url
  38941. struct3501.SecretKey = miConfig.SecretKey
  38942. struct3501.ManuDate = "2022-08-15"
  38943. struct3501.FixmedinsBchno = ""
  38944. struct3501.ManuLotnum = ""
  38945. struct3501.RxFlag = "0"
  38946. struct3501.ExpyEnd = "2022-08-15"
  38947. struct3501.Invdate = "2022-08-15"
  38948. struct3501.InvCnt = "20.25"
  38949. struct3501.Memo = ""
  38950. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38951. struct3501.FixmedinsHilistId = miConfig.Code
  38952. struct3501.FixmedinsHilistName = miConfig.OrgName
  38953. struct3501s = append(struct3501s, struct3501)
  38954. data["struct_3501s"] = struct3501s
  38955. client := &http.Client{}
  38956. bytesData, _ := json.Marshal(data)
  38957. var req *http.Request
  38958. if miConfig.MdtrtareaAdmvs == "320921" {
  38959. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38960. } else {
  38961. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38962. }
  38963. resp, _ := client.Do(req)
  38964. defer resp.Body.Close()
  38965. body, ioErr := ioutil.ReadAll(resp.Body)
  38966. if ioErr != nil {
  38967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38969. return
  38970. }
  38971. var respJSON map[string]interface{}
  38972. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38975. return
  38976. }
  38977. var res ResultSix
  38978. var resSix10265 ResultSix10265 //1101结果
  38979. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38980. result, _ := json.Marshal(respJSON)
  38981. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38982. utils.ErrorLog("解析失败:%v", err)
  38983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38984. return
  38985. }
  38986. res.InfRefmsgid = resSix10265.InfRefmsgid
  38987. res.Output = resSix10265.Output
  38988. res.ErrMsg = resSix10265.ErrMsg
  38989. res.Cainfo = resSix10265.Cainfo
  38990. res.WarnMsg = resSix10265.WarnMsg
  38991. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38992. res.Infcode = infocode
  38993. if infocode == 0 {
  38994. c.ServeSuccessJSON(map[string]interface{}{
  38995. "msg": "上传成功",
  38996. })
  38997. return
  38998. } else {
  38999. c.ServeSuccessJSON(map[string]interface{}{
  39000. "failed_code": -10,
  39001. "msg": res.ErrMsg,
  39002. })
  39003. return
  39004. }
  39005. }
  39006. func (c *HisApiController) Post3505() {
  39007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39008. data := make(map[string]interface{})
  39009. var struct3501s []models.Struct3501
  39010. var struct3501 models.Struct3501
  39011. struct3501.OrgName = miConfig.OrgName
  39012. struct3501.AccessKey = miConfig.AccessKey
  39013. struct3501.RequestUrl = miConfig.Url
  39014. struct3501.SecretKey = miConfig.SecretKey
  39015. struct3501.ManuDate = "2022-08-15"
  39016. struct3501.FixmedinsBchno = ""
  39017. struct3501.ManuLotnum = ""
  39018. struct3501.RxFlag = "0"
  39019. struct3501.ExpyEnd = "2022-08-15"
  39020. struct3501.Invdate = "2022-08-15"
  39021. struct3501.InvCnt = "20.25"
  39022. struct3501.Memo = ""
  39023. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39024. struct3501.FixmedinsHilistId = miConfig.Code
  39025. struct3501.FixmedinsHilistName = miConfig.OrgName
  39026. struct3501s = append(struct3501s, struct3501)
  39027. data["struct_3501s"] = struct3501s
  39028. client := &http.Client{}
  39029. bytesData, _ := json.Marshal(data)
  39030. var req *http.Request
  39031. if miConfig.MdtrtareaAdmvs == "320921" {
  39032. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39033. } else {
  39034. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39035. }
  39036. resp, _ := client.Do(req)
  39037. defer resp.Body.Close()
  39038. body, ioErr := ioutil.ReadAll(resp.Body)
  39039. if ioErr != nil {
  39040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39042. return
  39043. }
  39044. var respJSON map[string]interface{}
  39045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39048. return
  39049. }
  39050. var res ResultSix
  39051. var resSix10265 ResultSix10265 //1101结果
  39052. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39053. result, _ := json.Marshal(respJSON)
  39054. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39055. utils.ErrorLog("解析失败:%v", err)
  39056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39057. return
  39058. }
  39059. res.InfRefmsgid = resSix10265.InfRefmsgid
  39060. res.Output = resSix10265.Output
  39061. res.ErrMsg = resSix10265.ErrMsg
  39062. res.Cainfo = resSix10265.Cainfo
  39063. res.WarnMsg = resSix10265.WarnMsg
  39064. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39065. res.Infcode = infocode
  39066. if infocode == 0 {
  39067. c.ServeSuccessJSON(map[string]interface{}{
  39068. "msg": "上传成功",
  39069. })
  39070. return
  39071. } else {
  39072. c.ServeSuccessJSON(map[string]interface{}{
  39073. "failed_code": -10,
  39074. "msg": res.ErrMsg,
  39075. })
  39076. return
  39077. }
  39078. }
  39079. func (c *HisApiController) Post3506() {
  39080. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39081. data := make(map[string]interface{})
  39082. var struct3501s []models.Struct3501
  39083. var struct3501 models.Struct3501
  39084. struct3501.OrgName = miConfig.OrgName
  39085. struct3501.AccessKey = miConfig.AccessKey
  39086. struct3501.RequestUrl = miConfig.Url
  39087. struct3501.SecretKey = miConfig.SecretKey
  39088. struct3501.ManuDate = "2022-08-15"
  39089. struct3501.FixmedinsBchno = ""
  39090. struct3501.ManuLotnum = ""
  39091. struct3501.RxFlag = "0"
  39092. struct3501.ExpyEnd = "2022-08-15"
  39093. struct3501.Invdate = "2022-08-15"
  39094. struct3501.InvCnt = "20.25"
  39095. struct3501.Memo = ""
  39096. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39097. struct3501.FixmedinsHilistId = miConfig.Code
  39098. struct3501.FixmedinsHilistName = miConfig.OrgName
  39099. struct3501s = append(struct3501s, struct3501)
  39100. data["struct_3501s"] = struct3501s
  39101. client := &http.Client{}
  39102. bytesData, _ := json.Marshal(data)
  39103. var req *http.Request
  39104. if miConfig.MdtrtareaAdmvs == "320921" {
  39105. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39106. } else {
  39107. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39108. }
  39109. resp, _ := client.Do(req)
  39110. defer resp.Body.Close()
  39111. body, ioErr := ioutil.ReadAll(resp.Body)
  39112. if ioErr != nil {
  39113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39115. return
  39116. }
  39117. var respJSON map[string]interface{}
  39118. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39121. return
  39122. }
  39123. var res ResultSix
  39124. var resSix10265 ResultSix10265 //1101结果
  39125. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39126. result, _ := json.Marshal(respJSON)
  39127. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39128. utils.ErrorLog("解析失败:%v", err)
  39129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39130. return
  39131. }
  39132. res.InfRefmsgid = resSix10265.InfRefmsgid
  39133. res.Output = resSix10265.Output
  39134. res.ErrMsg = resSix10265.ErrMsg
  39135. res.Cainfo = resSix10265.Cainfo
  39136. res.WarnMsg = resSix10265.WarnMsg
  39137. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39138. res.Infcode = infocode
  39139. if infocode == 0 {
  39140. c.ServeSuccessJSON(map[string]interface{}{
  39141. "msg": "上传成功",
  39142. })
  39143. return
  39144. } else {
  39145. c.ServeSuccessJSON(map[string]interface{}{
  39146. "failed_code": -10,
  39147. "msg": res.ErrMsg,
  39148. })
  39149. return
  39150. }
  39151. }
  39152. func (c *HisApiController) Post3507() {
  39153. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39154. data := make(map[string]interface{})
  39155. var struct3501s []models.Struct3501
  39156. var struct3501 models.Struct3501
  39157. struct3501.OrgName = miConfig.OrgName
  39158. struct3501.AccessKey = miConfig.AccessKey
  39159. struct3501.RequestUrl = miConfig.Url
  39160. struct3501.SecretKey = miConfig.SecretKey
  39161. struct3501.ManuDate = "2022-08-15"
  39162. struct3501.FixmedinsBchno = ""
  39163. struct3501.ManuLotnum = ""
  39164. struct3501.RxFlag = "0"
  39165. struct3501.ExpyEnd = "2022-08-15"
  39166. struct3501.Invdate = "2022-08-15"
  39167. struct3501.InvCnt = "20.25"
  39168. struct3501.Memo = ""
  39169. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39170. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39171. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39172. struct3501s = append(struct3501s, struct3501)
  39173. data["struct_3501s"] = struct3501s
  39174. client := &http.Client{}
  39175. bytesData, _ := json.Marshal(data)
  39176. var req *http.Request
  39177. if miConfig.MdtrtareaAdmvs == "320921" {
  39178. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39179. } else {
  39180. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39181. }
  39182. resp, _ := client.Do(req)
  39183. defer resp.Body.Close()
  39184. body, ioErr := ioutil.ReadAll(resp.Body)
  39185. if ioErr != nil {
  39186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39188. return
  39189. }
  39190. var respJSON map[string]interface{}
  39191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39194. return
  39195. }
  39196. var res ResultSix
  39197. var resSix10265 ResultSix10265 //1101结果
  39198. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39199. result, _ := json.Marshal(respJSON)
  39200. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39201. utils.ErrorLog("解析失败:%v", err)
  39202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39203. return
  39204. }
  39205. res.InfRefmsgid = resSix10265.InfRefmsgid
  39206. res.Output = resSix10265.Output
  39207. res.ErrMsg = resSix10265.ErrMsg
  39208. res.Cainfo = resSix10265.Cainfo
  39209. res.WarnMsg = resSix10265.WarnMsg
  39210. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39211. res.Infcode = infocode
  39212. if infocode == 0 {
  39213. c.ServeSuccessJSON(map[string]interface{}{
  39214. "msg": "上传成功",
  39215. })
  39216. return
  39217. } else {
  39218. c.ServeSuccessJSON(map[string]interface{}{
  39219. "failed_code": -10,
  39220. "msg": res.ErrMsg,
  39221. })
  39222. return
  39223. }
  39224. }
  39225. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39226. // WebSocket服务器地址
  39227. serverURL := "ws://127.0.0.1:8899"
  39228. // 解析WebSocket服务器地址
  39229. u, err := url.Parse(serverURL)
  39230. if err != nil {
  39231. }
  39232. // 建立WebSocket连接
  39233. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39234. if err != nil {
  39235. }
  39236. defer conn.Close()
  39237. input2 := make(map[string]interface{})
  39238. input := make(map[string]interface{})
  39239. inputData := make(map[string]interface{})
  39240. inputData["orgId"] = code
  39241. inputData["businessType"] = "01101"
  39242. inputData["operatorId"] = operator_id
  39243. inputData["operatorName"] = operator_name
  39244. inputData["officeId"] = "001"
  39245. inputData["officeName"] = "血透室"
  39246. inputData["deviceType"] = ""
  39247. input["data"] = inputData
  39248. input["orgId"] = code
  39249. input["transType"] = "ec.query"
  39250. //if md == ""
  39251. if md[:4] == "4403" {
  39252. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39253. } else if md[:4] == "4401" {
  39254. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39255. } else {
  39256. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39257. }
  39258. input2["indata"] = input
  39259. fmt.Println(input2)
  39260. bytesData, _ := json.Marshal(input2)
  39261. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39262. if err != nil {
  39263. fmt.Println(err)
  39264. }
  39265. // 接收消息
  39266. _, receivedMessage, err := conn.ReadMessage()
  39267. if err != nil {
  39268. fmt.Println(err)
  39269. }
  39270. return "", string(receivedMessage)
  39271. }
  39272. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39273. // WebSocket服务器地址
  39274. serverURL := "ws://127.0.0.1:8899"
  39275. // 解析WebSocket服务器地址
  39276. u, err := url.Parse(serverURL)
  39277. if err != nil {
  39278. }
  39279. // 建立WebSocket连接
  39280. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39281. if err != nil {
  39282. }
  39283. defer conn.Close()
  39284. input2 := make(map[string]interface{})
  39285. input := make(map[string]interface{})
  39286. inputData := make(map[string]interface{})
  39287. inputData["orgId"] = code
  39288. inputData["businessType"] = "01101"
  39289. inputData["operatorId"] = operator_id
  39290. inputData["operatorName"] = operator_name
  39291. inputData["officeId"] = "001"
  39292. inputData["officeName"] = "血透室"
  39293. inputData["deviceType"] = ""
  39294. input["data"] = inputData
  39295. input["orgId"] = code
  39296. input["transType"] = "ec.query"
  39297. //if md == ""
  39298. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39299. input2["indata"] = input
  39300. fmt.Println(input2)
  39301. bytesData, _ := json.Marshal(input2)
  39302. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39303. if err != nil {
  39304. fmt.Println(err)
  39305. }
  39306. // 接收消息
  39307. _, receivedMessage, err := conn.ReadMessage()
  39308. if err != nil {
  39309. fmt.Println(err)
  39310. }
  39311. return "", string(receivedMessage)
  39312. }
  39313. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39314. // WebSocket服务器地址
  39315. serverURL := "ws://127.0.0.1:8899"
  39316. // 解析WebSocket服务器地址
  39317. u, err := url.Parse(serverURL)
  39318. if err != nil {
  39319. }
  39320. // 建立WebSocket连接
  39321. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39322. if err != nil {
  39323. }
  39324. defer conn.Close()
  39325. input2 := make(map[string]interface{})
  39326. input := make(map[string]interface{})
  39327. inputData := make(map[string]interface{})
  39328. inputData["orgId"] = code
  39329. inputData["businessType"] = "01301"
  39330. inputData["operatorId"] = operator_id
  39331. inputData["operatorName"] = operator_name
  39332. inputData["officeId"] = "001"
  39333. inputData["officeName"] = "血透室"
  39334. inputData["deviceType"] = ""
  39335. input["data"] = inputData
  39336. input["orgId"] = code
  39337. input["transType"] = "ec.query"
  39338. //if md == ""
  39339. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39340. input2["indata"] = input
  39341. fmt.Println(input2)
  39342. bytesData, _ := json.Marshal(input2)
  39343. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39344. if err != nil {
  39345. fmt.Println(err)
  39346. }
  39347. // 接收消息
  39348. _, receivedMessage, err := conn.ReadMessage()
  39349. if err != nil {
  39350. fmt.Println(err)
  39351. }
  39352. return "", string(receivedMessage)
  39353. }
  39354. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39355. // WebSocket服务器地址
  39356. serverURL := "ws://127.0.0.1:8899"
  39357. // 解析WebSocket服务器地址
  39358. u, err := url.Parse(serverURL)
  39359. if err != nil {
  39360. }
  39361. // 建立WebSocket连接
  39362. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39363. if err != nil {
  39364. }
  39365. defer conn.Close()
  39366. input2 := make(map[string]interface{})
  39367. input := make(map[string]interface{})
  39368. inputData := make(map[string]interface{})
  39369. inputData["orgId"] = code
  39370. inputData["businessType"] = "01103"
  39371. inputData["operatorId"] = operator_id
  39372. inputData["operatorName"] = operator_name
  39373. inputData["officeId"] = "001"
  39374. inputData["officeName"] = "血透室"
  39375. inputData["deviceType"] = ""
  39376. input["data"] = inputData
  39377. input["orgId"] = code
  39378. input["transType"] = "ec.query"
  39379. //if md ==
  39380. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39381. input2["indata"] = input
  39382. fmt.Println(input2)
  39383. bytesData, _ := json.Marshal(input2)
  39384. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39385. if err != nil {
  39386. fmt.Println(err)
  39387. }
  39388. // 接收消息
  39389. _, receivedMessage, err := conn.ReadMessage()
  39390. if err != nil {
  39391. fmt.Println(err)
  39392. }
  39393. return "", string(receivedMessage)
  39394. }
  39395. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39396. // WebSocket服务器地址
  39397. serverURL := "ws://127.0.0.1:8899"
  39398. // 解析WebSocket服务器地址
  39399. u, err := url.Parse(serverURL)
  39400. if err != nil {
  39401. }
  39402. // 建立WebSocket连接
  39403. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39404. if err != nil {
  39405. }
  39406. defer conn.Close()
  39407. input2 := make(map[string]interface{})
  39408. input := make(map[string]interface{})
  39409. inputData := make(map[string]interface{})
  39410. inputData["orgId"] = code
  39411. inputData["businessType"] = "01101"
  39412. inputData["operatorId"] = operator_id
  39413. inputData["operatorName"] = operator_name
  39414. inputData["officeId"] = "001"
  39415. inputData["officeName"] = "血透室"
  39416. inputData["deviceType"] = ""
  39417. input["data"] = inputData
  39418. input["orgId"] = code
  39419. input["transType"] = "ec.query"
  39420. //if md == ""
  39421. if md[:4] == "4403" {
  39422. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39423. } else if md[:4] == "4401" {
  39424. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39425. } else {
  39426. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39427. }
  39428. input2["indata"] = input
  39429. fmt.Println(input2)
  39430. bytesData, _ := json.Marshal(input2)
  39431. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39432. if err != nil {
  39433. fmt.Println(err)
  39434. }
  39435. // 接收消息
  39436. _, receivedMessage, err := conn.ReadMessage()
  39437. if err != nil {
  39438. fmt.Println(err)
  39439. }
  39440. return "", string(receivedMessage)
  39441. }
  39442. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39443. // WebSocket服务器地址
  39444. serverURL := "ws://127.0.0.1:8899"
  39445. // 解析WebSocket服务器地址
  39446. u, err := url.Parse(serverURL)
  39447. if err != nil {
  39448. }
  39449. // 建立WebSocket连接
  39450. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39451. if err != nil {
  39452. }
  39453. defer conn.Close()
  39454. input2 := make(map[string]interface{})
  39455. input := make(map[string]interface{})
  39456. inputData := make(map[string]interface{})
  39457. inputData["orgId"] = code
  39458. inputData["businessType"] = "01301"
  39459. inputData["operatorId"] = operator_id
  39460. inputData["operatorName"] = operator_name
  39461. inputData["officeId"] = "001"
  39462. inputData["officeName"] = "血透室"
  39463. inputData["deviceType"] = ""
  39464. input["data"] = inputData
  39465. input["orgId"] = code
  39466. input["transType"] = "ec.query"
  39467. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39468. input2["indata"] = input
  39469. bytesData, _ := json.Marshal(input2)
  39470. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39471. if err != nil {
  39472. fmt.Println(err)
  39473. }
  39474. // 接收消息
  39475. _, receivedMessage, err := conn.ReadMessage()
  39476. if err != nil {
  39477. fmt.Println(err)
  39478. }
  39479. return "", string(receivedMessage)
  39480. }
  39481. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39482. newArr = make([]string, 0)
  39483. for i := 0; i < len(arr); i++ {
  39484. repeat := false
  39485. for j := i + 1; j < len(arr); j++ {
  39486. if arr[i] == arr[j] {
  39487. repeat = true
  39488. break
  39489. }
  39490. }
  39491. if !repeat {
  39492. newArr = append(newArr, arr[i])
  39493. }
  39494. }
  39495. return
  39496. }
  39497. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39498. if len(idNumber) != 18 {
  39499. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39500. }
  39501. // 提取出生日期
  39502. year, err := strconv.Atoi(idNumber[6:10])
  39503. if err != nil {
  39504. return "", 0, err
  39505. }
  39506. month, err := strconv.Atoi(idNumber[10:12])
  39507. if err != nil {
  39508. return "", 0, err
  39509. }
  39510. day, err := strconv.Atoi(idNumber[12:14])
  39511. if err != nil {
  39512. return "", 0, err
  39513. }
  39514. // 格式化生日字符串
  39515. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39516. birthdateFormatted := birthdate.Format("2006-01-02")
  39517. // 计算年龄
  39518. today := time.Now()
  39519. age := today.Year() - birthdate.Year()
  39520. if today.YearDay() < birthdate.YearDay() {
  39521. age--
  39522. }
  39523. return birthdateFormatted, age, nil
  39524. }
  39525. // 从身份证号码中提取出生年月日
  39526. func getBirthDateFromIDCard(idCard string) (string, error) {
  39527. // 身份证号码长度应为18位
  39528. if len(idCard) != 18 {
  39529. return "", fmt.Errorf("身份证号码长度应为18位")
  39530. }
  39531. // 提取出生日期部分 (YYYYMMDD)
  39532. birthDateStr := idCard[6:14]
  39533. // 解析出生日期
  39534. birthDate, err := time.Parse("20060102", birthDateStr)
  39535. if err != nil {
  39536. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39537. }
  39538. // 格式化出生日期为 YYYY-MM-DD
  39539. formattedDate := birthDate.Format("2006-01-02")
  39540. return formattedDate, nil
  39541. }