his_api_controller.go 1.6MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. "strings"
  10. //"crypto/x509/pkix"
  11. "encoding/json"
  12. "fmt"
  13. "gdyb/controllers"
  14. "gdyb/enums"
  15. "gdyb/models"
  16. "gdyb/service"
  17. "gdyb/utils"
  18. "github.com/astaxie/beego"
  19. "github.com/axgle/mahonia"
  20. "github.com/go-ole/go-ole/oleutil"
  21. "github.com/gorilla/websocket"
  22. "github.com/jinzhu/gorm"
  23. "github.com/shopspring/decimal"
  24. "io"
  25. "io/ioutil"
  26. "math/rand"
  27. "net/http"
  28. "net/url"
  29. "os"
  30. "path/filepath"
  31. "regexp"
  32. "strconv"
  33. "syscall"
  34. "time"
  35. "unsafe"
  36. "github.com/go-ole/go-ole"
  37. )
  38. type HisApiController struct {
  39. controllers.BaseAuthAPIController
  40. }
  41. func HisManagerApiRegistRouters() {
  42. //挂号
  43. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  44. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  45. //上传就诊信息-上传明细-结算
  46. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  47. //查询
  48. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  49. //对总账
  50. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  51. //对明细
  52. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  53. //退费,退明细
  54. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  55. //退号
  56. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  57. //退明细
  58. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  59. //上传就诊信息-上传明细-预结算
  60. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  61. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  62. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  63. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  64. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  65. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  66. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  67. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  68. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  69. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  70. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  71. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  72. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  73. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  74. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  75. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  76. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  77. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  78. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  79. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  80. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  81. beego.Router("/api/check", &HisApiController{}, "get:Check")
  82. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  83. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  84. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  85. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  86. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  87. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  88. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  89. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  90. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  91. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  92. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  93. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  94. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  95. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  96. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  97. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  98. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  99. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  100. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  101. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  102. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  103. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  104. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  105. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  108. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  109. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  110. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  111. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  112. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  113. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  114. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  115. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  116. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  117. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  159. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  160. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  161. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  162. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  163. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  164. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  165. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  166. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  167. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  168. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  169. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  170. //beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  171. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  172. }
  173. func (c *HisApiController)Get3201(){
  174. adminUser := c.GetAdminUserInfo()
  175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  176. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code,"360399", "360399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  177. var response Response
  178. if err := json.Unmarshal([]byte(result), &response); err != nil {
  179. fmt.Println("Error decoding JSON:", err)
  180. return
  181. }
  182. }
  183. func (c *HisApiController) TestNet() {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "msg": "成功",
  186. })
  187. }
  188. func (c *HisApiController) Get3508() {
  189. admin_user_id, _ := c.GetInt64("admin_user_id")
  190. drug_id, _ := c.GetInt64("id")
  191. start_time := c.GetString("start_time")
  192. end_time := c.GetString("end_time")
  193. adminUser := c.GetAdminUserInfo()
  194. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  195. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  196. drug, _ := service.GetDrugByID(drug_id)
  197. var struct3508 models.Struct3508
  198. struct3508.OrgName = miConfig.OrgName
  199. struct3508.FixmedinsCode = miConfig.Code
  200. struct3508.AccessKey = miConfig.AccessKey
  201. struct3508.Opter = curRoles.UserName
  202. struct3508.RequestUrl = miConfig.Url
  203. struct3508.Url = miConfig.Url
  204. struct3508.AppId = miConfig.Cainfo
  205. struct3508.AppSecret = miConfig.AppSecret
  206. struct3508.Enckey = miConfig.EncKey
  207. struct3508.SignKey = miConfig.SignKey
  208. struct3508.SecretKey = miConfig.SecretKey
  209. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  210. struct3508.Begndate = start_time
  211. struct3508.Enddate = end_time
  212. result1, result2, _ := service.FJyb3508(struct3508)
  213. saveLog(result1, result2, "3508", "3508")
  214. var res models.Result3508
  215. var respJSON2 map[string]interface{}
  216. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  219. return
  220. }
  221. userJSONBytes2, _ := json.Marshal(respJSON2)
  222. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  223. utils.ErrorLog("解析失败:%v", err)
  224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  225. return
  226. }
  227. if res.Infcode == -1 {
  228. c.ServeSuccessJSON(map[string]interface{}{
  229. "failed_code": -10,
  230. "msg": res.ErrMsg,
  231. })
  232. } else {
  233. c.ServeSuccessJSON(map[string]interface{}{
  234. "info": res.Output,
  235. })
  236. }
  237. }
  238. func (c *HisApiController) Get3509() {
  239. admin_user_id, _ := c.GetInt64("admin_user_id")
  240. drug_id, _ := c.GetInt64("id")
  241. start_time := c.GetString("start_time")
  242. end_time := c.GetString("end_time")
  243. adminUser := c.GetAdminUserInfo()
  244. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  245. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  246. drug, _ := service.GetDrugByID(drug_id)
  247. var struct3508 models.Struct3509
  248. struct3508.OrgName = miConfig.OrgName
  249. struct3508.FixmedinsCode = miConfig.Code
  250. struct3508.AccessKey = miConfig.AccessKey
  251. struct3508.Opter = curRoles.UserName
  252. struct3508.RequestUrl = miConfig.Url
  253. struct3508.Url = miConfig.Url
  254. struct3508.AppId = miConfig.Cainfo
  255. struct3508.AppSecret = miConfig.AppSecret
  256. struct3508.Enckey = miConfig.EncKey
  257. struct3508.SignKey = miConfig.SignKey
  258. struct3508.SecretKey = miConfig.SecretKey
  259. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  260. struct3508.Begndate = start_time
  261. struct3508.Enddate = end_time
  262. result1, result2, _ := service.FJyb3509(struct3508)
  263. saveLog(result1, result2, "3509", "3509")
  264. var res models.Result3509
  265. var respJSON2 map[string]interface{}
  266. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  269. return
  270. }
  271. userJSONBytes2, _ := json.Marshal(respJSON2)
  272. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  273. utils.ErrorLog("解析失败:%v", err)
  274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  275. return
  276. }
  277. if res.Infcode == -1 {
  278. c.ServeSuccessJSON(map[string]interface{}{
  279. "failed_code": -10,
  280. "msg": res.ErrMsg,
  281. })
  282. } else {
  283. c.ServeSuccessJSON(map[string]interface{}{
  284. "info": res.Output,
  285. })
  286. }
  287. }
  288. func (c *HisApiController) Get3510() {
  289. admin_user_id, _ := c.GetInt64("admin_user_id")
  290. drug_id, _ := c.GetInt64("id")
  291. start_time := c.GetString("start_time")
  292. end_time := c.GetString("end_time")
  293. adminUser := c.GetAdminUserInfo()
  294. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  295. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  296. drug, _ := service.GetDrugByID(drug_id)
  297. var struct3508 models.Struct3510
  298. struct3508.FixmedinsCode = miConfig.Code
  299. struct3508.OrgName = miConfig.OrgName
  300. struct3508.AccessKey = miConfig.AccessKey
  301. struct3508.Opter = curRoles.UserName
  302. struct3508.RequestUrl = miConfig.Url
  303. struct3508.Url = miConfig.Url
  304. struct3508.AppId = miConfig.Cainfo
  305. struct3508.AppSecret = miConfig.AppSecret
  306. struct3508.Enckey = miConfig.EncKey
  307. struct3508.SignKey = miConfig.SignKey
  308. struct3508.SecretKey = miConfig.SecretKey
  309. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  310. struct3508.Begndate = start_time
  311. struct3508.Enddate = end_time
  312. result1, result2, _ := service.FJyb3510(struct3508)
  313. saveLog(result1, result2, "3510", "3510")
  314. var res models.Result3510
  315. var respJSON2 map[string]interface{}
  316. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  319. return
  320. }
  321. userJSONBytes2, _ := json.Marshal(respJSON2)
  322. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  323. utils.ErrorLog("解析失败:%v", err)
  324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  325. return
  326. }
  327. if res.Infcode == -1 {
  328. c.ServeSuccessJSON(map[string]interface{}{
  329. "failed_code": -10,
  330. "msg": res.ErrMsg,
  331. })
  332. } else {
  333. c.ServeSuccessJSON(map[string]interface{}{
  334. "info": res.Output,
  335. })
  336. }
  337. }
  338. func (c *HisApiController) Get3511() {
  339. admin_user_id, _ := c.GetInt64("admin_user_id")
  340. drug_id, _ := c.GetInt64("id")
  341. start_time := c.GetString("start_time")
  342. end_time := c.GetString("end_time")
  343. adminUser := c.GetAdminUserInfo()
  344. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  345. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  346. drug, _ := service.GetDrugByID(drug_id)
  347. var struct3508 models.Struct3511
  348. struct3508.FixmedinsCode = miConfig.Code
  349. struct3508.OrgName = miConfig.OrgName
  350. struct3508.AccessKey = miConfig.AccessKey
  351. struct3508.Opter = curRoles.UserName
  352. struct3508.RequestUrl = miConfig.Url
  353. struct3508.Url = miConfig.Url
  354. struct3508.AppId = miConfig.Cainfo
  355. struct3508.AppSecret = miConfig.AppSecret
  356. struct3508.Enckey = miConfig.EncKey
  357. struct3508.SignKey = miConfig.SignKey
  358. struct3508.SecretKey = miConfig.SecretKey
  359. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  360. struct3508.Begndate = start_time
  361. struct3508.Enddate = end_time
  362. result1, result2, _ := service.FJyb3511(struct3508)
  363. saveLog(result1, result2, "3511", "3511")
  364. var res models.Result3511
  365. var respJSON2 map[string]interface{}
  366. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  369. return
  370. }
  371. userJSONBytes2, _ := json.Marshal(respJSON2)
  372. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  373. utils.ErrorLog("解析失败:%v", err)
  374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  375. return
  376. }
  377. if res.Infcode == -1 {
  378. c.ServeSuccessJSON(map[string]interface{}{
  379. "failed_code": -10,
  380. "msg": res.ErrMsg,
  381. })
  382. } else {
  383. c.ServeSuccessJSON(map[string]interface{}{
  384. "info": res.Output,
  385. })
  386. }
  387. }
  388. func (c *HisApiController) Get3512() {
  389. admin_user_id, _ := c.GetInt64("admin_user_id")
  390. drug_id, _ := c.GetInt64("id")
  391. start_time := c.GetString("start_time")
  392. end_time := c.GetString("end_time")
  393. adminUser := c.GetAdminUserInfo()
  394. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  395. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  396. drug, _ := service.GetDrugByID(drug_id)
  397. var struct3508 models.Struct3512
  398. struct3508.FixmedinsCode = miConfig.Code
  399. struct3508.OrgName = miConfig.OrgName
  400. struct3508.AccessKey = miConfig.AccessKey
  401. struct3508.Opter = curRoles.UserName
  402. struct3508.RequestUrl = miConfig.Url
  403. struct3508.Url = miConfig.Url
  404. struct3508.AppId = miConfig.Cainfo
  405. struct3508.AppSecret = miConfig.AppSecret
  406. struct3508.Enckey = miConfig.EncKey
  407. struct3508.SignKey = miConfig.SignKey
  408. struct3508.SecretKey = miConfig.SecretKey
  409. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  410. struct3508.Begndate = start_time
  411. struct3508.Enddate = end_time
  412. result1, result2, _ := service.FJyb3512(struct3508)
  413. saveLog(result1, result2, "3512", "3512")
  414. var res models.Result3512
  415. var respJSON2 map[string]interface{}
  416. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  419. return
  420. }
  421. userJSONBytes2, _ := json.Marshal(respJSON2)
  422. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  423. utils.ErrorLog("解析失败:%v", err)
  424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  425. return
  426. }
  427. if res.Infcode == -1 {
  428. c.ServeSuccessJSON(map[string]interface{}{
  429. "failed_code": -10,
  430. "msg": res.ErrMsg,
  431. })
  432. } else {
  433. c.ServeSuccessJSON(map[string]interface{}{
  434. "info": res.Output,
  435. })
  436. }
  437. }
  438. func (c *HisApiController) Get3513() {
  439. admin_user_id, _ := c.GetInt64("admin_user_id")
  440. drug_id, _ := c.GetInt64("id")
  441. start_time := c.GetString("start_time")
  442. end_time := c.GetString("end_time")
  443. adminUser := c.GetAdminUserInfo()
  444. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  445. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  446. drug, _ := service.GetDrugByID(drug_id)
  447. var struct3508 models.Struct3513
  448. struct3508.FixmedinsCode = miConfig.Code
  449. struct3508.OrgName = miConfig.OrgName
  450. struct3508.AccessKey = miConfig.AccessKey
  451. struct3508.Opter = curRoles.UserName
  452. struct3508.RequestUrl = miConfig.Url
  453. struct3508.Url = miConfig.Url
  454. struct3508.AppId = miConfig.Cainfo
  455. struct3508.AppSecret = miConfig.AppSecret
  456. struct3508.Enckey = miConfig.EncKey
  457. struct3508.SignKey = miConfig.SignKey
  458. struct3508.SecretKey = miConfig.SecretKey
  459. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  460. struct3508.Begndate = start_time
  461. struct3508.Enddate = end_time
  462. result1, result2, _ := service.FJyb3513(struct3508)
  463. saveLog(result1, result2, "3513", "3513")
  464. var res models.Result3513
  465. var respJSON2 map[string]interface{}
  466. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. return
  470. }
  471. userJSONBytes2, _ := json.Marshal(respJSON2)
  472. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  473. utils.ErrorLog("解析失败:%v", err)
  474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  475. return
  476. }
  477. if res.Infcode == -1 {
  478. c.ServeSuccessJSON(map[string]interface{}{
  479. "failed_code": -10,
  480. "msg": res.ErrMsg,
  481. })
  482. } else {
  483. c.ServeSuccessJSON(map[string]interface{}{
  484. "info": res.Output,
  485. })
  486. }
  487. }
  488. func (c *HisApiController) Get35081() {
  489. admin_user_id, _ := c.GetInt64("admin_user_id")
  490. drug_id, _ := c.GetInt64("id")
  491. //start_time := c.GetString("start_time")
  492. //end_time := c.GetString("end_time")
  493. page, _ := c.GetInt("page")
  494. adminUser := c.GetAdminUserInfo()
  495. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  496. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  497. drug, _ := service.GetDrugByID(drug_id)
  498. var struct3508 models.Struct35081
  499. struct3508.FixmedinsCode = miConfig.Code
  500. struct3508.OrgName = miConfig.OrgName
  501. struct3508.AccessKey = miConfig.AccessKey
  502. struct3508.Opter = curRoles.UserName
  503. struct3508.RequestUrl = miConfig.Url
  504. struct3508.Url = miConfig.Url
  505. struct3508.AppId = miConfig.Cainfo
  506. struct3508.AppSecret = miConfig.AppSecret
  507. struct3508.Enckey = miConfig.EncKey
  508. struct3508.SignKey = miConfig.SignKey
  509. struct3508.SecretKey = miConfig.SecretKey
  510. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  511. struct3508.PageNum = page
  512. struct3508.PageSize = 10
  513. result1, result2, _ := service.FJyb35081(struct3508)
  514. saveLog(result1, result2, "35081", "35081")
  515. var res models.Result35081
  516. var respJSON2 map[string]interface{}
  517. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  520. return
  521. }
  522. userJSONBytes2, _ := json.Marshal(respJSON2)
  523. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  524. utils.ErrorLog("解析失败:%v", err)
  525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  526. return
  527. }
  528. if res.Infcode == -1 {
  529. c.ServeSuccessJSON(map[string]interface{}{
  530. "failed_code": -10,
  531. "msg": res.ErrMsg,
  532. })
  533. } else {
  534. c.ServeSuccessJSON(map[string]interface{}{
  535. "info": res.Output,
  536. })
  537. }
  538. }
  539. func (c *HisApiController) Get35082() {
  540. admin_user_id, _ := c.GetInt64("admin_user_id")
  541. drug_id, _ := c.GetInt64("id")
  542. //start_time := c.GetString("start_time")
  543. //end_time := c.GetString("end_time")
  544. page, _ := c.GetInt("page")
  545. adminUser := c.GetAdminUserInfo()
  546. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  547. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  548. drug, _ := service.GetDrugByID(drug_id)
  549. var struct3508 models.Struct35082
  550. struct3508.FixmedinsCode = miConfig.Code
  551. struct3508.OrgName = miConfig.OrgName
  552. struct3508.AccessKey = miConfig.AccessKey
  553. struct3508.Opter = curRoles.UserName
  554. struct3508.RequestUrl = miConfig.Url
  555. struct3508.Url = miConfig.Url
  556. struct3508.AppId = miConfig.Cainfo
  557. struct3508.AppSecret = miConfig.AppSecret
  558. struct3508.Enckey = miConfig.EncKey
  559. struct3508.SignKey = miConfig.SignKey
  560. struct3508.SecretKey = miConfig.SecretKey
  561. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  562. struct3508.PageNum = page
  563. struct3508.PageSize = 10
  564. result1, result2, _ := service.FJyb35082(struct3508)
  565. saveLog(result1, result2, "35082", "35082")
  566. var res models.Result35082
  567. var respJSON2 map[string]interface{}
  568. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  571. return
  572. }
  573. userJSONBytes2, _ := json.Marshal(respJSON2)
  574. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  575. utils.ErrorLog("解析失败:%v", err)
  576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  577. return
  578. }
  579. if res.Infcode == -1 {
  580. c.ServeSuccessJSON(map[string]interface{}{
  581. "failed_code": -10,
  582. "msg": res.ErrMsg,
  583. })
  584. } else {
  585. c.ServeSuccessJSON(map[string]interface{}{
  586. "info": res.Output,
  587. })
  588. }
  589. }
  590. func (c *HisApiController) FJ3501AND3502() {
  591. ids := c.GetString("ids")
  592. admin_user_id, _ := c.GetInt64("admin_user_id")
  593. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  594. id_arr := strings.Split(ids, ",")
  595. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  596. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  597. //库盘
  598. var errs []string
  599. for _, drug := range drugs {
  600. if drug.IsPc == 0 && drug.IsBg == 0 {
  601. var res2 ResultSix
  602. var res3 ResultSix
  603. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  604. var struct3501 models.Struct3501
  605. struct3501.Code = miConfig.Code
  606. struct3501.OrgName = miConfig.OrgName
  607. struct3501.AccessKey = miConfig.AccessKey
  608. struct3501.Opter = roles.UserName
  609. struct3501.RequestUrl = miConfig.Url
  610. struct3501.Url = miConfig.Url
  611. struct3501.AppId = miConfig.Cainfo
  612. struct3501.AppSecret = miConfig.AppSecret
  613. struct3501.Enckey = miConfig.EncKey
  614. struct3501.SignKey = miConfig.SignKey
  615. struct3501.SecretKey = miConfig.SecretKey
  616. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  617. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  618. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  619. struct3501.RxFlag = "1"
  620. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  621. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  622. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  623. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  624. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  625. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  626. struct3501.FixmedinsBchno = number
  627. struct3501.DrugTracCodg = drug.DrugCode
  628. memo := make(map[string]interface{})
  629. memo["pric"] = drug.Price
  630. bytesData, _ := json.Marshal(memo)
  631. struct3501.Memo = string(bytesData)
  632. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  633. result1, result2, _ := service.FJyb3501(struct3501)
  634. saveLog(result1, result2, "3501", "3501")
  635. //saveLog(result, requestLog, "2201", "挂号")
  636. var respJSON2 map[string]interface{}
  637. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  640. return
  641. }
  642. userJSONBytes2, _ := json.Marshal(respJSON2)
  643. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  644. utils.ErrorLog("解析失败:%v", err)
  645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  646. return
  647. }
  648. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  649. data := make(map[string]interface{})
  650. data["struct_3501s"] = struct3501
  651. client := &http.Client{}
  652. bytesData, _ := json.Marshal(data)
  653. var req *http.Request
  654. if miConfig.MdtrtareaAdmvs == "320921" {
  655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  656. } else {
  657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  658. }
  659. resp, _ := client.Do(req)
  660. defer resp.Body.Close()
  661. body, ioErr := ioutil.ReadAll(resp.Body)
  662. if ioErr != nil {
  663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  664. }
  665. var respJSON map[string]interface{}
  666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  669. return
  670. }
  671. var resSix10265 ResultSix10265 //1101结果
  672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  673. result, _ := json.Marshal(respJSON)
  674. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  675. utils.ErrorLog("解析失败:%v", err)
  676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  677. return
  678. }
  679. res2.InfRefmsgid = resSix10265.InfRefmsgid
  680. res2.Output = resSix10265.Output
  681. res2.ErrMsg = resSix10265.ErrMsg
  682. res2.Cainfo = resSix10265.Cainfo
  683. res2.WarnMsg = resSix10265.WarnMsg
  684. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  685. res2.Infcode = infocode
  686. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  687. data := make(map[string]interface{})
  688. data["struct_3501s"] = struct3501
  689. client := &http.Client{}
  690. bytesData, _ := json.Marshal(data)
  691. var req *http.Request
  692. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  693. resp, _ := client.Do(req)
  694. defer resp.Body.Close()
  695. body, ioErr := ioutil.ReadAll(resp.Body)
  696. if ioErr != nil {
  697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  698. }
  699. var respJSON map[string]interface{}
  700. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  703. return
  704. }
  705. var resSix10265 ResultSix10265 //1101结果
  706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  707. result, _ := json.Marshal(respJSON)
  708. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  709. utils.ErrorLog("解析失败:%v", err)
  710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  711. return
  712. }
  713. res2.InfRefmsgid = resSix10265.InfRefmsgid
  714. res2.Output = resSix10265.Output
  715. res2.ErrMsg = resSix10265.ErrMsg
  716. res2.Cainfo = resSix10265.Cainfo
  717. res2.WarnMsg = resSix10265.WarnMsg
  718. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  719. res2.Infcode = infocode
  720. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  721. data := make(map[string]interface{})
  722. data["struct_3501s"] = struct3501
  723. client := &http.Client{}
  724. bytesData, _ := json.Marshal(data)
  725. var req *http.Request
  726. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  727. resp, _ := client.Do(req)
  728. defer resp.Body.Close()
  729. body, ioErr := ioutil.ReadAll(resp.Body)
  730. if ioErr != nil {
  731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  732. }
  733. var respJSON map[string]interface{}
  734. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  737. return
  738. }
  739. var resSix10265 ResultSix10265 //1101结果
  740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  741. result, _ := json.Marshal(respJSON)
  742. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  743. utils.ErrorLog("解析失败:%v", err)
  744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  745. return
  746. }
  747. res2.InfRefmsgid = resSix10265.InfRefmsgid
  748. res2.Output = resSix10265.Output
  749. res2.ErrMsg = resSix10265.ErrMsg
  750. res2.Cainfo = resSix10265.Cainfo
  751. res2.WarnMsg = resSix10265.WarnMsg
  752. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  753. res2.Infcode = infocode
  754. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  755. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  756. saveLog(result1, result2, "3501", "3501")
  757. //saveLog(result, requestLog, "2201", "挂号")
  758. var respJSON2 map[string]interface{}
  759. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  762. return
  763. }
  764. userJSONBytes2, _ := json.Marshal(respJSON2)
  765. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  766. utils.ErrorLog("解析失败:%v", err)
  767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  768. return
  769. }
  770. }
  771. if res2.Infcode != -1 {
  772. drug.IsPc = 1
  773. drug.Bchno = number
  774. drug.PcDate = time.Now().Unix()
  775. err := service.SaveW(drug)
  776. if err == nil {
  777. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  778. var struct3502 models.Struct3502
  779. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  780. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  781. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  782. struct3502.FixmedinsCode = miConfig.Code
  783. struct3502.Code = miConfig.Code
  784. struct3502.RxFlag = "0"
  785. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  786. struct3502.OrgName = miConfig.OrgName
  787. struct3502.Opter = roles.UserName
  788. struct3502.AccessKey = miConfig.AccessKey
  789. struct3502.RequestUrl = miConfig.Url
  790. struct3502.SecretKey = miConfig.SecretKey
  791. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  792. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  793. struct3502.Url = miConfig.Url
  794. struct3502.AppId = miConfig.Cainfo
  795. struct3502.AppSecret = miConfig.AppSecret
  796. struct3502.Enckey = miConfig.EncKey
  797. struct3502.SignKey = miConfig.SignKey
  798. struct3502.SecretKey = miConfig.SecretKey
  799. struct3502.DrugTracCodg = drug.DrugCode
  800. struct3502.Memo = ""
  801. struct3502.InvChgType = "108"
  802. struct3502.FixmedinsBchno = bg_number
  803. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  804. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  805. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  806. result11, result22, _ := service.FJyb3502(struct3502)
  807. saveLog(result11, result22, "3502", "3502")
  808. var respJSON3 map[string]interface{}
  809. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  812. return
  813. }
  814. userJSONBytes3, _ := json.Marshal(respJSON3)
  815. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  816. utils.ErrorLog("解析失败:%v", err)
  817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  818. return
  819. }
  820. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  821. data := make(map[string]interface{})
  822. data["struct_3502s"] = struct3502
  823. client := &http.Client{}
  824. bytesData, _ := json.Marshal(data)
  825. var req *http.Request
  826. if miConfig.MdtrtareaAdmvs == "320921" {
  827. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  828. } else {
  829. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  830. }
  831. resp, _ := client.Do(req)
  832. defer resp.Body.Close()
  833. body, ioErr := ioutil.ReadAll(resp.Body)
  834. if ioErr != nil {
  835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  836. }
  837. var respJSON map[string]interface{}
  838. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  841. return
  842. }
  843. var resSix10265 ResultSix10265 //1101结果
  844. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  845. result, _ := json.Marshal(respJSON)
  846. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  847. utils.ErrorLog("解析失败:%v", err)
  848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  849. return
  850. }
  851. res3.InfRefmsgid = resSix10265.InfRefmsgid
  852. res3.Output = resSix10265.Output
  853. res3.ErrMsg = resSix10265.ErrMsg
  854. res3.Cainfo = resSix10265.Cainfo
  855. res3.WarnMsg = resSix10265.WarnMsg
  856. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  857. res3.Infcode = infocode
  858. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  859. data := make(map[string]interface{})
  860. data["struct_3502s"] = struct3502
  861. client := &http.Client{}
  862. bytesData, _ := json.Marshal(data)
  863. var req *http.Request
  864. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  865. resp, _ := client.Do(req)
  866. defer resp.Body.Close()
  867. body, ioErr := ioutil.ReadAll(resp.Body)
  868. if ioErr != nil {
  869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  870. }
  871. var respJSON map[string]interface{}
  872. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  875. return
  876. }
  877. var resSix10265 ResultSix10265 //1101结果
  878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  879. result, _ := json.Marshal(respJSON)
  880. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  881. utils.ErrorLog("解析失败:%v", err)
  882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  883. return
  884. }
  885. res3.InfRefmsgid = resSix10265.InfRefmsgid
  886. res3.Output = resSix10265.Output
  887. res3.ErrMsg = resSix10265.ErrMsg
  888. res3.Cainfo = resSix10265.Cainfo
  889. res3.WarnMsg = resSix10265.WarnMsg
  890. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  891. res3.Infcode = infocode
  892. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  893. data := make(map[string]interface{})
  894. data["struct_3501s"] = struct3501
  895. client := &http.Client{}
  896. bytesData, _ := json.Marshal(data)
  897. var req *http.Request
  898. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  899. resp, _ := client.Do(req)
  900. defer resp.Body.Close()
  901. body, ioErr := ioutil.ReadAll(resp.Body)
  902. if ioErr != nil {
  903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  904. }
  905. var respJSON map[string]interface{}
  906. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  909. return
  910. }
  911. var resSix10265 ResultSix10265 //1101结果
  912. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  913. result, _ := json.Marshal(respJSON)
  914. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  915. utils.ErrorLog("解析失败:%v", err)
  916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  917. return
  918. }
  919. res2.InfRefmsgid = resSix10265.InfRefmsgid
  920. res2.Output = resSix10265.Output
  921. res2.ErrMsg = resSix10265.ErrMsg
  922. res2.Cainfo = resSix10265.Cainfo
  923. res2.WarnMsg = resSix10265.WarnMsg
  924. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  925. res2.Infcode = infocode
  926. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  927. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  928. saveLog(result11, result22, "3502", "3502")
  929. var respJSON3 map[string]interface{}
  930. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  933. return
  934. }
  935. userJSONBytes3, _ := json.Marshal(respJSON3)
  936. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  937. utils.ErrorLog("解析失败:%v", err)
  938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  939. return
  940. }
  941. }
  942. if res3.Infcode == -1 {
  943. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  944. c.ServeSuccessJSON(map[string]interface{}{
  945. "failed_code": -10,
  946. "msg": res3.ErrMsg,
  947. })
  948. } else {
  949. drug.IsBg = 1
  950. drug.BgBchno = bg_number
  951. service.SaveW(drug)
  952. }
  953. }
  954. } else {
  955. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  956. }
  957. }
  958. //变更
  959. if drug.IsPc == 1 && drug.IsBg == 0 {
  960. var res3 ResultSix
  961. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  962. var struct3502 models.Struct3502
  963. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  964. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  965. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  966. struct3502.FixmedinsCode = miConfig.Code
  967. struct3502.Code = miConfig.Code
  968. struct3502.Opter = roles.UserName
  969. struct3502.RxFlag = "0"
  970. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  971. struct3502.OrgName = miConfig.OrgName
  972. struct3502.AccessKey = miConfig.AccessKey
  973. struct3502.RequestUrl = miConfig.Url
  974. struct3502.SecretKey = miConfig.SecretKey
  975. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  976. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  977. struct3502.InvChgType = "108"
  978. struct3502.DrugTracCodg = drug.DrugCode
  979. struct3502.Url = miConfig.Url
  980. struct3502.AppId = miConfig.Cainfo
  981. struct3502.AppSecret = miConfig.AppSecret
  982. struct3502.Enckey = miConfig.EncKey
  983. struct3502.SignKey = miConfig.SignKey
  984. struct3502.SecretKey = miConfig.SecretKey
  985. struct3502.FixmedinsBchno = bg_number
  986. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  987. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  988. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  989. result1, result2, _ := service.FJyb3502(struct3502)
  990. saveLog(result1, result2, "3502", "3502")
  991. var respJSON3 map[string]interface{}
  992. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  995. return
  996. }
  997. userJSONBytes3, _ := json.Marshal(respJSON3)
  998. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  999. utils.ErrorLog("解析失败:%v", err)
  1000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1001. return
  1002. }
  1003. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1004. data := make(map[string]interface{})
  1005. data["struct_3502s"] = struct3502
  1006. client := &http.Client{}
  1007. bytesData, _ := json.Marshal(data)
  1008. var req *http.Request
  1009. if miConfig.MdtrtareaAdmvs == "320921" {
  1010. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1011. } else {
  1012. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1013. }
  1014. resp, _ := client.Do(req)
  1015. defer resp.Body.Close()
  1016. body, ioErr := ioutil.ReadAll(resp.Body)
  1017. if ioErr != nil {
  1018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1019. }
  1020. var respJSON map[string]interface{}
  1021. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. var resSix10265 ResultSix10265 //1101结果
  1027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1028. result, _ := json.Marshal(respJSON)
  1029. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1030. utils.ErrorLog("解析失败:%v", err)
  1031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1032. return
  1033. }
  1034. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1035. res3.Output = resSix10265.Output
  1036. res3.ErrMsg = resSix10265.ErrMsg
  1037. res3.Cainfo = resSix10265.Cainfo
  1038. res3.WarnMsg = resSix10265.WarnMsg
  1039. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1040. res3.Infcode = infocode
  1041. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1042. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1043. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  1044. }
  1045. if res3.Infcode == -1 {
  1046. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1047. } else {
  1048. drug.IsBg = 1
  1049. drug.BgBchno = bg_number
  1050. service.SaveW(drug)
  1051. }
  1052. }
  1053. }
  1054. if len(errs) == 0 {
  1055. c.ServeSuccessJSON(map[string]interface{}{
  1056. "msg": "盘存变更成功",
  1057. })
  1058. } else {
  1059. c.ServeSuccessJSON(map[string]interface{}{
  1060. "failed_code": -10,
  1061. "msg": errs,
  1062. })
  1063. }
  1064. }
  1065. func (c *HisApiController) DeletePCandBG() {
  1066. ids := c.GetString("ids")
  1067. id_arr := strings.Split(ids, ",")
  1068. admin_user_id, _ := c.GetInt64("admin_user_id")
  1069. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1070. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1071. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1072. var err []string
  1073. for _, item := range drugs {
  1074. if item.IsPc == 1 && item.IsBg == 1 {
  1075. var res FJ3507Result
  1076. var res2 FJ3507Result
  1077. var struct3507 models.Struct3507
  1078. struct3507.FixmedinsBchno = item.Bchno
  1079. struct3507.InvDataType = "1"
  1080. struct3507.Opter = roles.UserName
  1081. struct3507.OrgName = miConfig.OrgName
  1082. struct3507.AccessKey = miConfig.AccessKey
  1083. struct3507.RequestUrl = miConfig.Url
  1084. struct3507.FixmedinsCode = miConfig.Code
  1085. struct3507.Code = miConfig.Code
  1086. struct3507.SecretKey = miConfig.SecretKey
  1087. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1088. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1089. struct3507.Url = miConfig.Url
  1090. struct3507.AppId = miConfig.Cainfo
  1091. struct3507.AppSecret = miConfig.AppSecret
  1092. struct3507.Enckey = miConfig.EncKey
  1093. struct3507.SignKey = miConfig.SignKey
  1094. struct3507.SecretKey = miConfig.SecretKey
  1095. if miConfig.MdtrtareaAdmvs == "350500" {
  1096. result, result1, _ := service.FJyb3507(struct3507)
  1097. saveLog(result, result1, "3507", "3507")
  1098. var respJSON2 map[string]interface{}
  1099. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1102. return
  1103. }
  1104. userJSONBytes2, _ := json.Marshal(respJSON2)
  1105. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1106. utils.ErrorLog("解析失败:%v", err)
  1107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1108. return
  1109. }
  1110. } else {
  1111. data := make(map[string]interface{})
  1112. data["struct_3507s"] = struct3507
  1113. client := &http.Client{}
  1114. bytesData, _ := json.Marshal(data)
  1115. var req *http.Request
  1116. if miConfig.MdtrtareaAdmvs == "320921" {
  1117. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1118. } else {
  1119. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1120. }
  1121. resp, _ := client.Do(req)
  1122. defer resp.Body.Close()
  1123. body, ioErr := ioutil.ReadAll(resp.Body)
  1124. if ioErr != nil {
  1125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1126. }
  1127. var respJSON map[string]interface{}
  1128. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1131. return
  1132. }
  1133. var resSix10265 ResultSix10265 //1101结果
  1134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1135. result, _ := json.Marshal(respJSON)
  1136. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1137. utils.ErrorLog("解析失败:%v", err)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. res.InfRefmsgid = resSix10265.InfRefmsgid
  1142. //res.Output = resSix10265.Output
  1143. res.ErrMsg = resSix10265.ErrMsg
  1144. res.Cainfo = resSix10265.Cainfo
  1145. res.WarnMsg = resSix10265.WarnMsg
  1146. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1147. res.Infcode = infocode
  1148. }
  1149. if res.Infcode == 0 {
  1150. item.IsPc = 0
  1151. err2 := service.SaveW(item)
  1152. if err2 == nil {
  1153. var struct3507_2 models.Struct3507
  1154. struct3507_2.OrgName = miConfig.OrgName
  1155. struct3507_2.AccessKey = miConfig.AccessKey
  1156. struct3507_2.RequestUrl = miConfig.Url
  1157. struct3507_2.Opter = roles.UserName
  1158. struct3507_2.FixmedinsCode = miConfig.Code
  1159. struct3507_2.Code = miConfig.Code
  1160. struct3507_2.SecretKey = miConfig.SecretKey
  1161. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1162. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1163. struct3507_2.Url = miConfig.Url
  1164. struct3507_2.AppId = miConfig.Cainfo
  1165. struct3507_2.AppSecret = miConfig.AppSecret
  1166. struct3507_2.Enckey = miConfig.EncKey
  1167. struct3507_2.SignKey = miConfig.SignKey
  1168. struct3507_2.SecretKey = miConfig.SecretKey
  1169. struct3507_2.FixmedinsBchno = item.BgBchno
  1170. struct3507_2.InvDataType = "2"
  1171. if miConfig.MdtrtareaAdmvs == "350500" {
  1172. result11, result22, _ := service.FJyb3507(struct3507_2)
  1173. saveLog(result11, result22, "3507", "3507")
  1174. var respJSON3 map[string]interface{}
  1175. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1178. return
  1179. }
  1180. userJSONBytes3, _ := json.Marshal(respJSON3)
  1181. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1182. utils.ErrorLog("解析失败:%v", err)
  1183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1184. return
  1185. }
  1186. } else {
  1187. data := make(map[string]interface{})
  1188. data["struct_3507s"] = struct3507_2
  1189. client := &http.Client{}
  1190. bytesData, _ := json.Marshal(data)
  1191. var req *http.Request
  1192. if miConfig.MdtrtareaAdmvs == "320921" {
  1193. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1194. } else {
  1195. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1196. }
  1197. resp, _ := client.Do(req)
  1198. defer resp.Body.Close()
  1199. body, ioErr := ioutil.ReadAll(resp.Body)
  1200. if ioErr != nil {
  1201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1202. }
  1203. var respJSON map[string]interface{}
  1204. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1207. return
  1208. }
  1209. var resSix10265 ResultSix10265 //1101结果
  1210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1211. result, _ := json.Marshal(respJSON)
  1212. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1213. utils.ErrorLog("解析失败:%v", err)
  1214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1215. return
  1216. }
  1217. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1218. //res2.Output = resSix10265.Output
  1219. res2.ErrMsg = resSix10265.ErrMsg
  1220. res2.Cainfo = resSix10265.Cainfo
  1221. res2.WarnMsg = resSix10265.WarnMsg
  1222. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1223. res2.Infcode = infocode
  1224. }
  1225. if res2.Infcode != -1 {
  1226. item.IsBg = 0
  1227. item.Bchno = ""
  1228. item.BgBchno = ""
  1229. item.PcDate = 0
  1230. service.SaveW(item)
  1231. } else {
  1232. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1233. }
  1234. }
  1235. } else {
  1236. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1237. }
  1238. }
  1239. if item.IsPc == 1 && item.IsBg == 0 {
  1240. var res FJ3507Result
  1241. var struct3507 models.Struct3507
  1242. struct3507.FixmedinsBchno = item.Bchno
  1243. struct3507.InvDataType = "1"
  1244. struct3507.Opter = roles.UserName
  1245. struct3507.FixmedinsCode = miConfig.Code
  1246. struct3507.Code = miConfig.Code
  1247. struct3507.OrgName = miConfig.OrgName
  1248. struct3507.AccessKey = miConfig.AccessKey
  1249. struct3507.RequestUrl = miConfig.Url
  1250. struct3507.SecretKey = miConfig.SecretKey
  1251. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1252. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1253. struct3507.Url = miConfig.Url
  1254. struct3507.AppId = miConfig.Cainfo
  1255. struct3507.AppSecret = miConfig.AppSecret
  1256. struct3507.Enckey = miConfig.EncKey
  1257. struct3507.SignKey = miConfig.SignKey
  1258. struct3507.SecretKey = miConfig.SecretKey
  1259. //result, result1, _ := service.FJyb3507(struct3507)
  1260. //saveLog(result, result1, "3507", "3507")
  1261. if miConfig.MdtrtareaAdmvs == "350500" {
  1262. result, result1, _ := service.FJyb3507(struct3507)
  1263. saveLog(result, result1, "3507", "3507")
  1264. var respJSON2 map[string]interface{}
  1265. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1268. return
  1269. }
  1270. userJSONBytes2, _ := json.Marshal(respJSON2)
  1271. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1272. utils.ErrorLog("解析失败:%v", err)
  1273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1274. return
  1275. }
  1276. } else {
  1277. data := make(map[string]interface{})
  1278. data["struct_3507s"] = struct3507
  1279. client := &http.Client{}
  1280. bytesData, _ := json.Marshal(data)
  1281. var req *http.Request
  1282. if miConfig.MdtrtareaAdmvs == "320921" {
  1283. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1284. } else {
  1285. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1286. }
  1287. resp, _ := client.Do(req)
  1288. defer resp.Body.Close()
  1289. body, ioErr := ioutil.ReadAll(resp.Body)
  1290. if ioErr != nil {
  1291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1292. }
  1293. var respJSON map[string]interface{}
  1294. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1297. return
  1298. }
  1299. var resSix10265 ResultSix10265 //1101结果
  1300. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1301. result, _ := json.Marshal(respJSON)
  1302. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1303. utils.ErrorLog("解析失败:%v", err)
  1304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1305. return
  1306. }
  1307. res.InfRefmsgid = resSix10265.InfRefmsgid
  1308. //res.Output = resSix10265.Output
  1309. res.ErrMsg = resSix10265.ErrMsg
  1310. res.Cainfo = resSix10265.Cainfo
  1311. res.WarnMsg = resSix10265.WarnMsg
  1312. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1313. res.Infcode = infocode
  1314. }
  1315. if res.Infcode == 0 {
  1316. item.IsPc = 0
  1317. item.Bchno = ""
  1318. item.BgBchno = ""
  1319. item.PcDate = 0
  1320. service.SaveW(item)
  1321. } else {
  1322. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1323. }
  1324. }
  1325. if item.IsPc == 0 && item.IsBg == 1 {
  1326. var res FJ3507Result
  1327. var struct3507 models.Struct3507
  1328. struct3507.FixmedinsBchno = item.BgBchno
  1329. struct3507.InvDataType = "2"
  1330. struct3507.Opter = roles.UserName
  1331. struct3507.FixmedinsCode = miConfig.Code
  1332. struct3507.OrgName = miConfig.OrgName
  1333. struct3507.AccessKey = miConfig.AccessKey
  1334. struct3507.RequestUrl = miConfig.Url
  1335. struct3507.SecretKey = miConfig.SecretKey
  1336. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1337. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1338. struct3507.Url = miConfig.Url
  1339. struct3507.AppId = miConfig.Cainfo
  1340. struct3507.AppSecret = miConfig.AppSecret
  1341. struct3507.Enckey = miConfig.EncKey
  1342. struct3507.SignKey = miConfig.SignKey
  1343. struct3507.SecretKey = miConfig.SecretKey
  1344. //result, result1, _ := service.FJyb3507(struct3507)
  1345. //saveLog(result, result1, "3507", "3507")
  1346. if miConfig.MdtrtareaAdmvs == "350500" {
  1347. result, result1, _ := service.FJyb3507(struct3507)
  1348. saveLog(result, result1, "3507", "3507")
  1349. var respJSON2 map[string]interface{}
  1350. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1353. return
  1354. }
  1355. userJSONBytes2, _ := json.Marshal(respJSON2)
  1356. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1357. utils.ErrorLog("解析失败:%v", err)
  1358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1359. return
  1360. }
  1361. } else {
  1362. data := make(map[string]interface{})
  1363. data["struct_3507s"] = struct3507
  1364. client := &http.Client{}
  1365. bytesData, _ := json.Marshal(data)
  1366. var req *http.Request
  1367. if miConfig.MdtrtareaAdmvs == "320921" {
  1368. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1369. } else {
  1370. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1371. }
  1372. resp, _ := client.Do(req)
  1373. defer resp.Body.Close()
  1374. body, ioErr := ioutil.ReadAll(resp.Body)
  1375. if ioErr != nil {
  1376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1377. }
  1378. var respJSON map[string]interface{}
  1379. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1382. return
  1383. }
  1384. var resSix10265 ResultSix10265 //1101结果
  1385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1386. result, _ := json.Marshal(respJSON)
  1387. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1388. utils.ErrorLog("解析失败:%v", err)
  1389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1390. return
  1391. }
  1392. res.InfRefmsgid = resSix10265.InfRefmsgid
  1393. //res.Output = resSix10265.Output
  1394. res.ErrMsg = resSix10265.ErrMsg
  1395. res.Cainfo = resSix10265.Cainfo
  1396. res.WarnMsg = resSix10265.WarnMsg
  1397. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1398. res.Infcode = infocode
  1399. }
  1400. if res.Infcode == 0 {
  1401. item.IsBg = 0
  1402. item.Bchno = ""
  1403. item.BgBchno = ""
  1404. item.PcDate = 0
  1405. service.SaveW(item)
  1406. } else {
  1407. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1408. }
  1409. }
  1410. }
  1411. if len(err) == 0 {
  1412. c.ServeSuccessJSON(map[string]interface{}{
  1413. "msg": "删除盘存变更成功",
  1414. })
  1415. } else {
  1416. c.ServeSuccessJSON(map[string]interface{}{
  1417. "failed_code": -10,
  1418. "msg": err,
  1419. })
  1420. }
  1421. }
  1422. func (c *HisApiController) DeleteXSandBG() {
  1423. ids := c.GetString("ids")
  1424. id_arr := strings.Split(ids, ",")
  1425. admin_user_id, _ := c.GetInt64("admin_user_id")
  1426. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1427. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1428. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1429. var err []string
  1430. for _, item := range flows {
  1431. if item.IsSale == 1 && item.IsChange == 1 {
  1432. var res FJ3507Result
  1433. var res2 FJ3507Result
  1434. var struct3507 models.Struct3507
  1435. struct3507.FixmedinsBchno = item.Bchno
  1436. struct3507.InvDataType = "4"
  1437. struct3507.Opter = roles.UserName
  1438. struct3507.OrgName = miConfig.OrgName
  1439. struct3507.AccessKey = miConfig.AccessKey
  1440. struct3507.RequestUrl = miConfig.Url
  1441. struct3507.FixmedinsCode = miConfig.Code
  1442. struct3507.SecretKey = miConfig.SecretKey
  1443. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1444. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1445. struct3507.Url = miConfig.Url
  1446. struct3507.AppId = miConfig.Cainfo
  1447. struct3507.AppSecret = miConfig.AppSecret
  1448. struct3507.Enckey = miConfig.EncKey
  1449. struct3507.SignKey = miConfig.SignKey
  1450. struct3507.SecretKey = miConfig.SecretKey
  1451. //result, result1, _ := service.FJyb3507(struct3507)
  1452. //saveLog(result, result1, "3507", "3507")
  1453. if miConfig.MdtrtareaAdmvs == "350500" {
  1454. result, result1, _ := service.FJyb3507(struct3507)
  1455. saveLog(result, result1, "3507", "3507")
  1456. var respJSON2 map[string]interface{}
  1457. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. return
  1461. }
  1462. userJSONBytes2, _ := json.Marshal(respJSON2)
  1463. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1464. utils.ErrorLog("解析失败:%v", err)
  1465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1466. return
  1467. }
  1468. } else {
  1469. data := make(map[string]interface{})
  1470. data["struct_3507s"] = struct3507
  1471. client := &http.Client{}
  1472. bytesData, _ := json.Marshal(data)
  1473. var req *http.Request
  1474. if miConfig.MdtrtareaAdmvs == "320921" {
  1475. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1476. } else {
  1477. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1478. }
  1479. resp, _ := client.Do(req)
  1480. defer resp.Body.Close()
  1481. body, ioErr := ioutil.ReadAll(resp.Body)
  1482. if ioErr != nil {
  1483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1484. }
  1485. var respJSON map[string]interface{}
  1486. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1489. return
  1490. }
  1491. var resSix10265 ResultSix10265 //1101结果
  1492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1493. result, _ := json.Marshal(respJSON)
  1494. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1495. utils.ErrorLog("解析失败:%v", err)
  1496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1497. return
  1498. }
  1499. res.InfRefmsgid = resSix10265.InfRefmsgid
  1500. //res.Output = resSix10265.Output
  1501. res.ErrMsg = resSix10265.ErrMsg
  1502. res.Cainfo = resSix10265.Cainfo
  1503. res.WarnMsg = resSix10265.WarnMsg
  1504. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1505. res.Infcode = infocode
  1506. }
  1507. if res.Infcode == 0 {
  1508. item.IsSale = 0
  1509. item.SaleDate = ""
  1510. item.Bchno = ""
  1511. err2 := service.SaveDF(item)
  1512. if err2 == nil {
  1513. var struct3507_2 models.Struct3507
  1514. struct3507_2.OrgName = miConfig.OrgName
  1515. struct3507_2.AccessKey = miConfig.AccessKey
  1516. struct3507_2.RequestUrl = miConfig.Url
  1517. struct3507_2.Opter = roles.UserName
  1518. struct3507_2.FixmedinsCode = miConfig.Code
  1519. struct3507_2.Code = miConfig.Code
  1520. struct3507_2.SecretKey = miConfig.SecretKey
  1521. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1522. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1523. struct3507_2.Url = miConfig.Url
  1524. struct3507_2.AppId = miConfig.Cainfo
  1525. struct3507_2.AppSecret = miConfig.AppSecret
  1526. struct3507_2.Enckey = miConfig.EncKey
  1527. struct3507_2.SignKey = miConfig.SignKey
  1528. struct3507_2.SecretKey = miConfig.SecretKey
  1529. struct3507_2.FixmedinsBchno = item.BgBchno
  1530. struct3507_2.InvDataType = "2"
  1531. if miConfig.MdtrtareaAdmvs == "350500" {
  1532. result11, result22, _ := service.FJyb3507(struct3507_2)
  1533. saveLog(result11, result22, "3507", "3507")
  1534. var respJSON3 map[string]interface{}
  1535. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1538. return
  1539. }
  1540. userJSONBytes3, _ := json.Marshal(respJSON3)
  1541. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1542. utils.ErrorLog("解析失败:%v", err)
  1543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1544. return
  1545. }
  1546. } else {
  1547. data := make(map[string]interface{})
  1548. data["struct_3507s"] = struct3507_2
  1549. client := &http.Client{}
  1550. bytesData, _ := json.Marshal(data)
  1551. var req *http.Request
  1552. if miConfig.MdtrtareaAdmvs == "320921" {
  1553. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1554. } else {
  1555. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1556. }
  1557. resp, _ := client.Do(req)
  1558. defer resp.Body.Close()
  1559. body, ioErr := ioutil.ReadAll(resp.Body)
  1560. if ioErr != nil {
  1561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1562. }
  1563. var respJSON map[string]interface{}
  1564. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1567. return
  1568. }
  1569. var resSix10265 ResultSix10265 //1101结果
  1570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1571. result, _ := json.Marshal(respJSON)
  1572. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1573. utils.ErrorLog("解析失败:%v", err)
  1574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1575. return
  1576. }
  1577. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1578. //res.Output = resSix10265.Output
  1579. res2.ErrMsg = resSix10265.ErrMsg
  1580. res2.Cainfo = resSix10265.Cainfo
  1581. res2.WarnMsg = resSix10265.WarnMsg
  1582. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1583. res2.Infcode = infocode
  1584. }
  1585. if res2.Infcode == 0 {
  1586. item.IsChange = 0
  1587. item.BgBchno = ""
  1588. service.SaveDF2(item)
  1589. } else {
  1590. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1591. }
  1592. }
  1593. } else {
  1594. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1595. }
  1596. }
  1597. if item.IsSale == 2 && item.IsChange == 1 {
  1598. var res FJ3507Result
  1599. var res2 FJ3507Result
  1600. var struct3507 models.Struct3507
  1601. struct3507.FixmedinsBchno = item.Bchno
  1602. struct3507.InvDataType = "4"
  1603. struct3507.Opter = roles.UserName
  1604. struct3507.OrgName = miConfig.OrgName
  1605. struct3507.AccessKey = miConfig.AccessKey
  1606. struct3507.RequestUrl = miConfig.Url
  1607. struct3507.FixmedinsCode = miConfig.Code
  1608. struct3507.Code = miConfig.Code
  1609. struct3507.SecretKey = miConfig.SecretKey
  1610. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1611. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1612. struct3507.Url = miConfig.Url
  1613. struct3507.AppId = miConfig.Cainfo
  1614. struct3507.AppSecret = miConfig.AppSecret
  1615. struct3507.Enckey = miConfig.EncKey
  1616. struct3507.SignKey = miConfig.SignKey
  1617. struct3507.SecretKey = miConfig.SecretKey
  1618. //result, result1, _ := service.FJyb3507(struct3507)
  1619. //saveLog(result, result1, "3507", "3507")
  1620. //
  1621. //var respJSON2 map[string]interface{}
  1622. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1623. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1625. // return
  1626. //}
  1627. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1628. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1629. // utils.ErrorLog("解析失败:%v", err)
  1630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. // return
  1632. //}
  1633. if miConfig.MdtrtareaAdmvs == "350500" {
  1634. result, result1, _ := service.FJyb3507(struct3507)
  1635. saveLog(result, result1, "3507", "3507")
  1636. var respJSON2 map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. userJSONBytes2, _ := json.Marshal(respJSON2)
  1643. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1644. utils.ErrorLog("解析失败:%v", err)
  1645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1646. return
  1647. }
  1648. } else {
  1649. data := make(map[string]interface{})
  1650. data["struct_3507s"] = struct3507
  1651. client := &http.Client{}
  1652. bytesData, _ := json.Marshal(data)
  1653. var req *http.Request
  1654. if miConfig.MdtrtareaAdmvs == "320921" {
  1655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. } else {
  1657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1658. }
  1659. resp, _ := client.Do(req)
  1660. defer resp.Body.Close()
  1661. body, ioErr := ioutil.ReadAll(resp.Body)
  1662. if ioErr != nil {
  1663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1664. }
  1665. var respJSON map[string]interface{}
  1666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1669. return
  1670. }
  1671. var resSix10265 ResultSix10265 //1101结果
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1675. utils.ErrorLog("解析失败:%v", err)
  1676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1677. return
  1678. }
  1679. res.InfRefmsgid = resSix10265.InfRefmsgid
  1680. //res.Output = resSix10265.Output
  1681. res.ErrMsg = resSix10265.ErrMsg
  1682. res.Cainfo = resSix10265.Cainfo
  1683. res.WarnMsg = resSix10265.WarnMsg
  1684. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1685. res.Infcode = infocode
  1686. }
  1687. if res.Infcode == 0 {
  1688. item.IsSale = 0
  1689. item.SaleDate = ""
  1690. item.Bchno = ""
  1691. err2 := service.SaveDF(item)
  1692. if err2 == nil {
  1693. var struct3507_2 models.Struct3507
  1694. struct3507_2.OrgName = miConfig.OrgName
  1695. struct3507_2.AccessKey = miConfig.AccessKey
  1696. struct3507_2.RequestUrl = miConfig.Url
  1697. struct3507_2.Opter = roles.UserName
  1698. struct3507_2.FixmedinsCode = miConfig.Code
  1699. struct3507_2.Code = miConfig.Code
  1700. struct3507_2.SecretKey = miConfig.SecretKey
  1701. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1702. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1703. struct3507_2.Url = miConfig.Url
  1704. struct3507_2.AppId = miConfig.Cainfo
  1705. struct3507_2.AppSecret = miConfig.AppSecret
  1706. struct3507_2.Enckey = miConfig.EncKey
  1707. struct3507_2.SignKey = miConfig.SignKey
  1708. struct3507_2.SecretKey = miConfig.SecretKey
  1709. struct3507_2.FixmedinsBchno = item.BgBchno
  1710. struct3507_2.InvDataType = "2"
  1711. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1712. //saveLog(result11, result22, "3507", "3507")
  1713. //var respJSON3 map[string]interface{}
  1714. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1715. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1716. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1717. // return
  1718. //}
  1719. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1720. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1721. // utils.ErrorLog("解析失败:%v", err)
  1722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1723. // return
  1724. //}
  1725. if miConfig.MdtrtareaAdmvs == "350500" {
  1726. result11, result22, _ := service.FJyb3507(struct3507_2)
  1727. saveLog(result11, result22, "3507", "3507")
  1728. var respJSON3 map[string]interface{}
  1729. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. return
  1733. }
  1734. userJSONBytes3, _ := json.Marshal(respJSON3)
  1735. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1736. utils.ErrorLog("解析失败:%v", err)
  1737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1738. return
  1739. }
  1740. } else {
  1741. data := make(map[string]interface{})
  1742. data["struct_3507s"] = struct3507_2
  1743. client := &http.Client{}
  1744. bytesData, _ := json.Marshal(data)
  1745. var req *http.Request
  1746. if miConfig.MdtrtareaAdmvs == "320921" {
  1747. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1748. } else {
  1749. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1750. }
  1751. resp, _ := client.Do(req)
  1752. defer resp.Body.Close()
  1753. body, ioErr := ioutil.ReadAll(resp.Body)
  1754. if ioErr != nil {
  1755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1756. }
  1757. var respJSON map[string]interface{}
  1758. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1761. return
  1762. }
  1763. var resSix10265 ResultSix10265 //1101结果
  1764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1765. result, _ := json.Marshal(respJSON)
  1766. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1767. utils.ErrorLog("解析失败:%v", err)
  1768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1769. return
  1770. }
  1771. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1772. //res.Output = resSix10265.Output
  1773. res2.ErrMsg = resSix10265.ErrMsg
  1774. res2.Cainfo = resSix10265.Cainfo
  1775. res2.WarnMsg = resSix10265.WarnMsg
  1776. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1777. res2.Infcode = infocode
  1778. }
  1779. if res2.Infcode == 0 {
  1780. item.IsChange = 0
  1781. item.BgBchno = ""
  1782. service.SaveDF2(item)
  1783. } else {
  1784. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1785. }
  1786. }
  1787. } else {
  1788. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1789. }
  1790. }
  1791. if item.IsSale == 1 && item.IsChange == 0 {
  1792. var res FJ3507Result
  1793. var struct3507 models.Struct3507
  1794. struct3507.FixmedinsBchno = item.Bchno
  1795. struct3507.InvDataType = "4"
  1796. struct3507.Opter = roles.UserName
  1797. struct3507.FixmedinsCode = miConfig.Code
  1798. struct3507.Code = miConfig.Code
  1799. struct3507.OrgName = miConfig.OrgName
  1800. struct3507.AccessKey = miConfig.AccessKey
  1801. struct3507.RequestUrl = miConfig.Url
  1802. struct3507.SecretKey = miConfig.SecretKey
  1803. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1804. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1805. struct3507.Url = miConfig.Url
  1806. struct3507.AppId = miConfig.Cainfo
  1807. struct3507.AppSecret = miConfig.AppSecret
  1808. struct3507.Enckey = miConfig.EncKey
  1809. struct3507.SignKey = miConfig.SignKey
  1810. struct3507.SecretKey = miConfig.SecretKey
  1811. //result, result1, _ := service.FJyb3507(struct3507)
  1812. //saveLog(result, result1, "3507", "3507")
  1813. //
  1814. //var respJSON3 map[string]interface{}
  1815. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1816. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1818. // return
  1819. //}
  1820. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1821. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1822. // utils.ErrorLog("解析失败:%v", err)
  1823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1824. // return
  1825. //}
  1826. if miConfig.MdtrtareaAdmvs == "350500" {
  1827. result, result1, _ := service.FJyb3507(struct3507)
  1828. saveLog(result, result1, "3507", "3507")
  1829. var respJSON2 map[string]interface{}
  1830. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1833. return
  1834. }
  1835. userJSONBytes2, _ := json.Marshal(respJSON2)
  1836. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1837. utils.ErrorLog("解析失败:%v", err)
  1838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1839. return
  1840. }
  1841. } else {
  1842. data := make(map[string]interface{})
  1843. data["struct_3507s"] = struct3507
  1844. client := &http.Client{}
  1845. bytesData, _ := json.Marshal(data)
  1846. var req *http.Request
  1847. if miConfig.MdtrtareaAdmvs == "320921" {
  1848. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1849. } else {
  1850. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1851. }
  1852. resp, _ := client.Do(req)
  1853. defer resp.Body.Close()
  1854. body, ioErr := ioutil.ReadAll(resp.Body)
  1855. if ioErr != nil {
  1856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1857. }
  1858. var respJSON map[string]interface{}
  1859. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1862. return
  1863. }
  1864. var resSix10265 ResultSix10265 //1101结果
  1865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1866. result, _ := json.Marshal(respJSON)
  1867. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1868. utils.ErrorLog("解析失败:%v", err)
  1869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1870. return
  1871. }
  1872. res.InfRefmsgid = resSix10265.InfRefmsgid
  1873. //res.Output = resSix10265.Output
  1874. res.ErrMsg = resSix10265.ErrMsg
  1875. res.Cainfo = resSix10265.Cainfo
  1876. res.WarnMsg = resSix10265.WarnMsg
  1877. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1878. res.Infcode = infocode
  1879. }
  1880. if res.Infcode == 0 {
  1881. item.IsSale = 0
  1882. item.SaleDate = ""
  1883. service.SaveDF(item)
  1884. } else {
  1885. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1886. }
  1887. }
  1888. if item.IsSale == 2 && item.IsChange == 0 {
  1889. var res FJ3507Result
  1890. var struct3507 models.Struct3507
  1891. struct3507.FixmedinsBchno = item.Bchno
  1892. struct3507.InvDataType = "4"
  1893. struct3507.Opter = roles.UserName
  1894. struct3507.FixmedinsCode = miConfig.Code
  1895. struct3507.Code = miConfig.Code
  1896. struct3507.OrgName = miConfig.OrgName
  1897. struct3507.AccessKey = miConfig.AccessKey
  1898. struct3507.RequestUrl = miConfig.Url
  1899. struct3507.SecretKey = miConfig.SecretKey
  1900. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1901. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1902. struct3507.Url = miConfig.Url
  1903. struct3507.AppId = miConfig.Cainfo
  1904. struct3507.AppSecret = miConfig.AppSecret
  1905. struct3507.Enckey = miConfig.EncKey
  1906. struct3507.SignKey = miConfig.SignKey
  1907. struct3507.SecretKey = miConfig.SecretKey
  1908. //result, result1, _ := service.FJyb3507(struct3507)
  1909. //saveLog(result, result1, "3507", "3507")
  1910. //
  1911. //var respJSON3 map[string]interface{}
  1912. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1913. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1915. // return
  1916. //}
  1917. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1918. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1919. // utils.ErrorLog("解析失败:%v", err)
  1920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. // return
  1922. //}
  1923. if miConfig.MdtrtareaAdmvs == "350500" {
  1924. result, result1, _ := service.FJyb3507(struct3507)
  1925. saveLog(result, result1, "3507", "3507")
  1926. var respJSON2 map[string]interface{}
  1927. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1930. return
  1931. }
  1932. userJSONBytes2, _ := json.Marshal(respJSON2)
  1933. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1934. utils.ErrorLog("解析失败:%v", err)
  1935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1936. return
  1937. }
  1938. } else {
  1939. data := make(map[string]interface{})
  1940. data["struct_3507s"] = struct3507
  1941. client := &http.Client{}
  1942. bytesData, _ := json.Marshal(data)
  1943. var req *http.Request
  1944. if miConfig.MdtrtareaAdmvs == "320921" {
  1945. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1946. } else {
  1947. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1948. }
  1949. resp, _ := client.Do(req)
  1950. defer resp.Body.Close()
  1951. body, ioErr := ioutil.ReadAll(resp.Body)
  1952. if ioErr != nil {
  1953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1954. }
  1955. var respJSON map[string]interface{}
  1956. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1959. return
  1960. }
  1961. var resSix10265 ResultSix10265 //1101结果
  1962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1963. result, _ := json.Marshal(respJSON)
  1964. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1965. utils.ErrorLog("解析失败:%v", err)
  1966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1967. return
  1968. }
  1969. res.InfRefmsgid = resSix10265.InfRefmsgid
  1970. //res.Output = resSix10265.Output
  1971. res.ErrMsg = resSix10265.ErrMsg
  1972. res.Cainfo = resSix10265.Cainfo
  1973. res.WarnMsg = resSix10265.WarnMsg
  1974. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1975. res.Infcode = infocode
  1976. }
  1977. if res.Infcode == 0 {
  1978. item.IsSale = 0
  1979. item.SaleDate = ""
  1980. item.Bchno = ""
  1981. service.SaveDF(item)
  1982. } else {
  1983. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1984. }
  1985. }
  1986. if item.IsSale == 0 && item.IsChange == 1 {
  1987. var res FJ3507Result
  1988. var struct3507 models.Struct3507
  1989. struct3507.FixmedinsBchno = item.BgBchno
  1990. struct3507.InvDataType = "2"
  1991. struct3507.Opter = roles.UserName
  1992. struct3507.FixmedinsCode = miConfig.Code
  1993. struct3507.Code = miConfig.Code
  1994. struct3507.OrgName = miConfig.OrgName
  1995. struct3507.AccessKey = miConfig.AccessKey
  1996. struct3507.RequestUrl = miConfig.Url
  1997. struct3507.SecretKey = miConfig.SecretKey
  1998. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1999. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2000. struct3507.Url = miConfig.Url
  2001. struct3507.AppId = miConfig.Cainfo
  2002. struct3507.AppSecret = miConfig.AppSecret
  2003. struct3507.Enckey = miConfig.EncKey
  2004. struct3507.SignKey = miConfig.SignKey
  2005. struct3507.SecretKey = miConfig.SecretKey
  2006. //result, result1, _ := service.FJyb3507(struct3507)
  2007. //saveLog(result, result1, "3507", "3507")
  2008. //
  2009. //var respJSON3 map[string]interface{}
  2010. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2011. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2013. // return
  2014. //}
  2015. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2016. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2017. // utils.ErrorLog("解析失败:%v", err)
  2018. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2019. // return
  2020. //}
  2021. if miConfig.MdtrtareaAdmvs == "350500" {
  2022. result, result1, _ := service.FJyb3507(struct3507)
  2023. saveLog(result, result1, "3507", "3507")
  2024. var respJSON2 map[string]interface{}
  2025. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2028. return
  2029. }
  2030. userJSONBytes2, _ := json.Marshal(respJSON2)
  2031. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2032. utils.ErrorLog("解析失败:%v", err)
  2033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2034. return
  2035. }
  2036. } else {
  2037. data := make(map[string]interface{})
  2038. data["struct_3507s"] = struct3507
  2039. client := &http.Client{}
  2040. bytesData, _ := json.Marshal(data)
  2041. var req *http.Request
  2042. if miConfig.MdtrtareaAdmvs == "320921" {
  2043. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2044. } else {
  2045. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2046. }
  2047. resp, _ := client.Do(req)
  2048. defer resp.Body.Close()
  2049. body, ioErr := ioutil.ReadAll(resp.Body)
  2050. if ioErr != nil {
  2051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2052. }
  2053. var respJSON map[string]interface{}
  2054. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2057. return
  2058. }
  2059. var resSix10265 ResultSix10265 //1101结果
  2060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2061. result, _ := json.Marshal(respJSON)
  2062. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2063. utils.ErrorLog("解析失败:%v", err)
  2064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2065. return
  2066. }
  2067. res.InfRefmsgid = resSix10265.InfRefmsgid
  2068. //res.Output = resSix10265.Output
  2069. res.ErrMsg = resSix10265.ErrMsg
  2070. res.Cainfo = resSix10265.Cainfo
  2071. res.WarnMsg = resSix10265.WarnMsg
  2072. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2073. res.Infcode = infocode
  2074. }
  2075. if res.Infcode == 0 {
  2076. item.IsChange = 0
  2077. item.BgBchno = ""
  2078. service.SaveDF2(item)
  2079. } else {
  2080. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2081. }
  2082. }
  2083. }
  2084. if len(err) == 0 {
  2085. c.ServeSuccessJSON(map[string]interface{}{
  2086. "msg": "删除销售变更成功",
  2087. })
  2088. } else {
  2089. c.ServeSuccessJSON(map[string]interface{}{
  2090. "failed_code": -10,
  2091. "msg": err,
  2092. })
  2093. }
  2094. }
  2095. //func (c *HisApiController) DeleteXSandBGTwo() {
  2096. // patient_id, _ := c.GetInt64("patient_id")
  2097. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2098. // //id_arr := strings.Split(ids, ",")
  2099. // times := c.GetString("time", "")
  2100. // timeLayout := "2006-01-02"
  2101. // loc, _ := time.LoadLocation("Local")
  2102. // var stime, etime int64
  2103. // if times == "" {
  2104. // stime, etime = GetNowTime()
  2105. // } else {
  2106. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2107. // stime = stmp.Unix()
  2108. // etime = stime + 86399
  2109. // }
  2110. // advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2111. // var flows []*models.DrugFlow
  2112. // for _, item := range advicelist {
  2113. // flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2114. // flows = append(flows, flow...)
  2115. // }
  2116. //
  2117. // //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2118. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2119. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2120. //
  2121. // var err []string
  2122. // for _, item := range flows {
  2123. // if item.IsSale == 1 && item.IsChange == 1 {
  2124. // var res FJ3507Result
  2125. // var res2 FJ3507Result
  2126. //
  2127. // var struct3507 models.Struct3507
  2128. // struct3507.FixmedinsBchno = item.Bchno
  2129. // struct3507.InvDataType = "4"
  2130. // struct3507.Opter = roles.UserName
  2131. // struct3507.OrgName = miConfig.OrgName
  2132. // struct3507.AccessKey = miConfig.AccessKey
  2133. // struct3507.RequestUrl = miConfig.Url
  2134. // struct3507.FixmedinsCode = miConfig.Code
  2135. // struct3507.SecretKey = miConfig.SecretKey
  2136. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2137. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2138. // struct3507.Url = miConfig.Url
  2139. // struct3507.AppId = miConfig.Cainfo
  2140. // struct3507.AppSecret = miConfig.AppSecret
  2141. // struct3507.Enckey = miConfig.EncKey
  2142. // struct3507.SignKey = miConfig.SignKey
  2143. // struct3507.SecretKey = miConfig.SecretKey
  2144. //
  2145. // //result, result1, _ := service.FJyb3507(struct3507)
  2146. // //saveLog(result, result1, "3507", "3507")
  2147. //
  2148. // if miConfig.MdtrtareaAdmvs == "350500" {
  2149. // result, result1, _ := service.FJyb3507(struct3507)
  2150. // saveLog(result, result1, "3507", "3507")
  2151. // var respJSON2 map[string]interface{}
  2152. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2153. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2154. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2155. // return
  2156. // }
  2157. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2158. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2159. // utils.ErrorLog("解析失败:%v", err)
  2160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2161. // return
  2162. // }
  2163. // } else {
  2164. // data := make(map[string]interface{})
  2165. // data["struct_3507s"] = struct3507
  2166. // client := &http.Client{}
  2167. // bytesData, _ := json.Marshal(data)
  2168. // var req *http.Request
  2169. // if miConfig.MdtrtareaAdmvs == "320921" {
  2170. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2171. // } else {
  2172. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2173. // }
  2174. //
  2175. // resp, _ := client.Do(req)
  2176. // defer resp.Body.Close()
  2177. // body, ioErr := ioutil.ReadAll(resp.Body)
  2178. // if ioErr != nil {
  2179. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2180. // }
  2181. // var respJSON map[string]interface{}
  2182. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2183. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2184. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2185. // return
  2186. // }
  2187. // var resSix10265 ResultSix10265 //1101结果
  2188. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2189. // result, _ := json.Marshal(respJSON)
  2190. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2191. // utils.ErrorLog("解析失败:%v", err)
  2192. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2193. // return
  2194. // }
  2195. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2196. // //res.Output = resSix10265.Output
  2197. // res.ErrMsg = resSix10265.ErrMsg
  2198. // res.Cainfo = resSix10265.Cainfo
  2199. // res.WarnMsg = resSix10265.WarnMsg
  2200. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2201. // res.Infcode = infocode
  2202. // }
  2203. //
  2204. // if res.Infcode == 0 {
  2205. // item.IsSale = 0
  2206. // item.SaleDate = ""
  2207. // item.Bchno = ""
  2208. //
  2209. // err2 := service.SaveDF(item)
  2210. // if err2 == nil {
  2211. // var struct3507_2 models.Struct3507
  2212. // struct3507_2.OrgName = miConfig.OrgName
  2213. // struct3507_2.AccessKey = miConfig.AccessKey
  2214. // struct3507_2.RequestUrl = miConfig.Url
  2215. // struct3507_2.Opter = roles.UserName
  2216. // struct3507_2.FixmedinsCode = miConfig.Code
  2217. // struct3507_2.Code = miConfig.Code
  2218. //
  2219. // struct3507_2.SecretKey = miConfig.SecretKey
  2220. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2221. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2222. // struct3507_2.Url = miConfig.Url
  2223. // struct3507_2.AppId = miConfig.Cainfo
  2224. // struct3507_2.AppSecret = miConfig.AppSecret
  2225. // struct3507_2.Enckey = miConfig.EncKey
  2226. // struct3507_2.SignKey = miConfig.SignKey
  2227. // struct3507_2.SecretKey = miConfig.SecretKey
  2228. // struct3507_2.FixmedinsBchno = item.BgBchno
  2229. // struct3507_2.InvDataType = "2"
  2230. //
  2231. // if miConfig.MdtrtareaAdmvs == "350500" {
  2232. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2233. // saveLog(result11, result22, "3507", "3507")
  2234. //
  2235. // var respJSON3 map[string]interface{}
  2236. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2237. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2239. // return
  2240. // }
  2241. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2242. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2243. // utils.ErrorLog("解析失败:%v", err)
  2244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2245. // return
  2246. // }
  2247. // } else {
  2248. //
  2249. // data := make(map[string]interface{})
  2250. // data["struct_3507s"] = struct3507_2
  2251. // client := &http.Client{}
  2252. // bytesData, _ := json.Marshal(data)
  2253. // var req *http.Request
  2254. // if miConfig.MdtrtareaAdmvs == "320921" {
  2255. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2256. // } else {
  2257. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2258. // }
  2259. //
  2260. // resp, _ := client.Do(req)
  2261. // defer resp.Body.Close()
  2262. // body, ioErr := ioutil.ReadAll(resp.Body)
  2263. // if ioErr != nil {
  2264. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2265. // }
  2266. // var respJSON map[string]interface{}
  2267. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2268. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2269. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2270. // return
  2271. // }
  2272. // var resSix10265 ResultSix10265 //1101结果
  2273. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2274. // result, _ := json.Marshal(respJSON)
  2275. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2276. // utils.ErrorLog("解析失败:%v", err)
  2277. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2278. // return
  2279. // }
  2280. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2281. // //res.Output = resSix10265.Output
  2282. // res2.ErrMsg = resSix10265.ErrMsg
  2283. // res2.Cainfo = resSix10265.Cainfo
  2284. // res2.WarnMsg = resSix10265.WarnMsg
  2285. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2286. // res2.Infcode = infocode
  2287. // }
  2288. //
  2289. // if res2.Infcode == 0 {
  2290. // item.IsChange = 0
  2291. // item.BgBchno = ""
  2292. // service.SaveDF2(item)
  2293. // } else {
  2294. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2295. // }
  2296. // }
  2297. // } else {
  2298. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2299. // }
  2300. //
  2301. // }
  2302. // if item.IsSale == 2 && item.IsChange == 1 {
  2303. // var res FJ3507Result
  2304. // var res2 FJ3507Result
  2305. //
  2306. // var struct3507 models.Struct3507
  2307. // struct3507.FixmedinsBchno = item.Bchno
  2308. // struct3507.InvDataType = "4"
  2309. // struct3507.Opter = roles.UserName
  2310. // struct3507.OrgName = miConfig.OrgName
  2311. // struct3507.AccessKey = miConfig.AccessKey
  2312. // struct3507.RequestUrl = miConfig.Url
  2313. // struct3507.FixmedinsCode = miConfig.Code
  2314. // struct3507.Code = miConfig.Code
  2315. //
  2316. // struct3507.SecretKey = miConfig.SecretKey
  2317. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2318. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2319. // struct3507.Url = miConfig.Url
  2320. // struct3507.AppId = miConfig.Cainfo
  2321. // struct3507.AppSecret = miConfig.AppSecret
  2322. // struct3507.Enckey = miConfig.EncKey
  2323. // struct3507.SignKey = miConfig.SignKey
  2324. // struct3507.SecretKey = miConfig.SecretKey
  2325. // //result, result1, _ := service.FJyb3507(struct3507)
  2326. // //saveLog(result, result1, "3507", "3507")
  2327. // //
  2328. // //var respJSON2 map[string]interface{}
  2329. // //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2330. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2331. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2332. // // return
  2333. // //}
  2334. // //userJSONBytes2, _ := json.Marshal(respJSON2)
  2335. // //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2336. // // utils.ErrorLog("解析失败:%v", err)
  2337. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2338. // // return
  2339. // //}
  2340. //
  2341. // if miConfig.MdtrtareaAdmvs == "350500" {
  2342. // result, result1, _ := service.FJyb3507(struct3507)
  2343. // saveLog(result, result1, "3507", "3507")
  2344. // var respJSON2 map[string]interface{}
  2345. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2346. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2348. // return
  2349. // }
  2350. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2351. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2352. // utils.ErrorLog("解析失败:%v", err)
  2353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2354. // return
  2355. // }
  2356. // } else {
  2357. // data := make(map[string]interface{})
  2358. // data["struct_3507s"] = struct3507
  2359. // client := &http.Client{}
  2360. // bytesData, _ := json.Marshal(data)
  2361. // var req *http.Request
  2362. // if miConfig.MdtrtareaAdmvs == "320921" {
  2363. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2364. // } else {
  2365. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2366. // }
  2367. //
  2368. // resp, _ := client.Do(req)
  2369. // defer resp.Body.Close()
  2370. // body, ioErr := ioutil.ReadAll(resp.Body)
  2371. // if ioErr != nil {
  2372. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2373. // }
  2374. // var respJSON map[string]interface{}
  2375. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2376. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2378. // return
  2379. // }
  2380. // var resSix10265 ResultSix10265 //1101结果
  2381. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2382. // result, _ := json.Marshal(respJSON)
  2383. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2384. // utils.ErrorLog("解析失败:%v", err)
  2385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2386. // return
  2387. // }
  2388. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2389. // //res.Output = resSix10265.Output
  2390. // res.ErrMsg = resSix10265.ErrMsg
  2391. // res.Cainfo = resSix10265.Cainfo
  2392. // res.WarnMsg = resSix10265.WarnMsg
  2393. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2394. // res.Infcode = infocode
  2395. // }
  2396. //
  2397. // if res.Infcode == 0 {
  2398. // item.IsSale = 0
  2399. // item.SaleDate = ""
  2400. // item.Bchno = ""
  2401. // err2 := service.SaveDF(item)
  2402. // if err2 == nil {
  2403. // var struct3507_2 models.Struct3507
  2404. // struct3507_2.OrgName = miConfig.OrgName
  2405. // struct3507_2.AccessKey = miConfig.AccessKey
  2406. // struct3507_2.RequestUrl = miConfig.Url
  2407. // struct3507_2.Opter = roles.UserName
  2408. // struct3507_2.FixmedinsCode = miConfig.Code
  2409. // struct3507_2.Code = miConfig.Code
  2410. //
  2411. // struct3507_2.SecretKey = miConfig.SecretKey
  2412. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2413. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2414. // struct3507_2.Url = miConfig.Url
  2415. // struct3507_2.AppId = miConfig.Cainfo
  2416. // struct3507_2.AppSecret = miConfig.AppSecret
  2417. // struct3507_2.Enckey = miConfig.EncKey
  2418. // struct3507_2.SignKey = miConfig.SignKey
  2419. // struct3507_2.SecretKey = miConfig.SecretKey
  2420. // struct3507_2.FixmedinsBchno = item.BgBchno
  2421. // struct3507_2.InvDataType = "2"
  2422. //
  2423. // //result11, result22, _ := service.FJyb3507(struct3507_2)
  2424. // //saveLog(result11, result22, "3507", "3507")
  2425. // //var respJSON3 map[string]interface{}
  2426. // //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2427. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2428. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2429. // // return
  2430. // //}
  2431. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2432. // //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2433. // // utils.ErrorLog("解析失败:%v", err)
  2434. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2435. // // return
  2436. // //}
  2437. //
  2438. // if miConfig.MdtrtareaAdmvs == "350500" {
  2439. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2440. // saveLog(result11, result22, "3507", "3507")
  2441. //
  2442. // var respJSON3 map[string]interface{}
  2443. // if err := json.Unmarshal([]byte(string(result11)), &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, &res2); err != nil {
  2450. // utils.ErrorLog("解析失败:%v", err)
  2451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2452. // return
  2453. // }
  2454. // } else {
  2455. //
  2456. // data := make(map[string]interface{})
  2457. // data["struct_3507s"] = struct3507_2
  2458. // client := &http.Client{}
  2459. // bytesData, _ := json.Marshal(data)
  2460. // var req *http.Request
  2461. // if miConfig.MdtrtareaAdmvs == "320921" {
  2462. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2463. // } else {
  2464. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2465. // }
  2466. //
  2467. // resp, _ := client.Do(req)
  2468. // defer resp.Body.Close()
  2469. // body, ioErr := ioutil.ReadAll(resp.Body)
  2470. // if ioErr != nil {
  2471. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2472. // }
  2473. // var respJSON map[string]interface{}
  2474. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2475. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2477. // return
  2478. // }
  2479. // var resSix10265 ResultSix10265 //1101结果
  2480. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2481. // result, _ := json.Marshal(respJSON)
  2482. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2483. // utils.ErrorLog("解析失败:%v", err)
  2484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2485. // return
  2486. // }
  2487. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2488. // //res.Output = resSix10265.Output
  2489. // res2.ErrMsg = resSix10265.ErrMsg
  2490. // res2.Cainfo = resSix10265.Cainfo
  2491. // res2.WarnMsg = resSix10265.WarnMsg
  2492. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2493. // res2.Infcode = infocode
  2494. // }
  2495. // if res2.Infcode == 0 {
  2496. // item.IsChange = 0
  2497. // item.BgBchno = ""
  2498. // service.SaveDF2(item)
  2499. // } else {
  2500. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2501. // }
  2502. // }
  2503. // } else {
  2504. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2505. // }
  2506. //
  2507. // }
  2508. // if item.IsSale == 1 && item.IsChange == 0 {
  2509. //
  2510. // var res FJ3507Result
  2511. // var struct3507 models.Struct3507
  2512. // struct3507.FixmedinsBchno = item.Bchno
  2513. // struct3507.InvDataType = "4"
  2514. // struct3507.Opter = roles.UserName
  2515. // struct3507.FixmedinsCode = miConfig.Code
  2516. // struct3507.Code = miConfig.Code
  2517. //
  2518. // struct3507.OrgName = miConfig.OrgName
  2519. // struct3507.AccessKey = miConfig.AccessKey
  2520. // struct3507.RequestUrl = miConfig.Url
  2521. // struct3507.SecretKey = miConfig.SecretKey
  2522. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2523. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2524. // struct3507.Url = miConfig.Url
  2525. // struct3507.AppId = miConfig.Cainfo
  2526. // struct3507.AppSecret = miConfig.AppSecret
  2527. // struct3507.Enckey = miConfig.EncKey
  2528. // struct3507.SignKey = miConfig.SignKey
  2529. // struct3507.SecretKey = miConfig.SecretKey
  2530. // //result, result1, _ := service.FJyb3507(struct3507)
  2531. // //saveLog(result, result1, "3507", "3507")
  2532. // //
  2533. // //var respJSON3 map[string]interface{}
  2534. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2535. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2536. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2537. // // return
  2538. // //}
  2539. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2540. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2541. // // utils.ErrorLog("解析失败:%v", err)
  2542. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2543. // // return
  2544. // //}
  2545. // if miConfig.MdtrtareaAdmvs == "350500" {
  2546. // result, result1, _ := service.FJyb3507(struct3507)
  2547. // saveLog(result, result1, "3507", "3507")
  2548. // var respJSON2 map[string]interface{}
  2549. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2550. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2552. // return
  2553. // }
  2554. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2555. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2556. // utils.ErrorLog("解析失败:%v", err)
  2557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2558. // return
  2559. // }
  2560. // } else {
  2561. // data := make(map[string]interface{})
  2562. // data["struct_3507s"] = struct3507
  2563. // client := &http.Client{}
  2564. // bytesData, _ := json.Marshal(data)
  2565. // var req *http.Request
  2566. // if miConfig.MdtrtareaAdmvs == "320921" {
  2567. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2568. // } else {
  2569. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2570. // }
  2571. //
  2572. // resp, _ := client.Do(req)
  2573. // defer resp.Body.Close()
  2574. // body, ioErr := ioutil.ReadAll(resp.Body)
  2575. // if ioErr != nil {
  2576. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2577. // }
  2578. // var respJSON map[string]interface{}
  2579. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2580. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2581. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2582. // return
  2583. // }
  2584. // var resSix10265 ResultSix10265 //1101结果
  2585. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2586. // result, _ := json.Marshal(respJSON)
  2587. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2588. // utils.ErrorLog("解析失败:%v", err)
  2589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2590. // return
  2591. // }
  2592. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2593. // //res.Output = resSix10265.Output
  2594. // res.ErrMsg = resSix10265.ErrMsg
  2595. // res.Cainfo = resSix10265.Cainfo
  2596. // res.WarnMsg = resSix10265.WarnMsg
  2597. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2598. // res.Infcode = infocode
  2599. // }
  2600. //
  2601. // if res.Infcode == 0 {
  2602. // item.IsSale = 0
  2603. // item.SaleDate = ""
  2604. // service.SaveDF(item)
  2605. // } else {
  2606. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2607. // }
  2608. // }
  2609. // if item.IsSale == 2 && item.IsChange == 0 {
  2610. //
  2611. // var res FJ3507Result
  2612. // var struct3507 models.Struct3507
  2613. // struct3507.FixmedinsBchno = item.Bchno
  2614. // struct3507.InvDataType = "4"
  2615. // struct3507.Opter = roles.UserName
  2616. // struct3507.FixmedinsCode = miConfig.Code
  2617. // struct3507.Code = miConfig.Code
  2618. //
  2619. // struct3507.OrgName = miConfig.OrgName
  2620. // struct3507.AccessKey = miConfig.AccessKey
  2621. // struct3507.RequestUrl = miConfig.Url
  2622. // struct3507.SecretKey = miConfig.SecretKey
  2623. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2624. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2625. // struct3507.Url = miConfig.Url
  2626. // struct3507.AppId = miConfig.Cainfo
  2627. // struct3507.AppSecret = miConfig.AppSecret
  2628. // struct3507.Enckey = miConfig.EncKey
  2629. // struct3507.SignKey = miConfig.SignKey
  2630. // struct3507.SecretKey = miConfig.SecretKey
  2631. // //result, result1, _ := service.FJyb3507(struct3507)
  2632. // //saveLog(result, result1, "3507", "3507")
  2633. // //
  2634. // //var respJSON3 map[string]interface{}
  2635. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2636. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2637. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2638. // // return
  2639. // //}
  2640. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2641. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2642. // // utils.ErrorLog("解析失败:%v", err)
  2643. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. // // return
  2645. // //}
  2646. // if miConfig.MdtrtareaAdmvs == "350500" {
  2647. // result, result1, _ := service.FJyb3507(struct3507)
  2648. // saveLog(result, result1, "3507", "3507")
  2649. // var respJSON2 map[string]interface{}
  2650. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2651. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2653. // return
  2654. // }
  2655. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2656. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2657. // utils.ErrorLog("解析失败:%v", err)
  2658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. // return
  2660. // }
  2661. // } else {
  2662. // data := make(map[string]interface{})
  2663. // data["struct_3507s"] = struct3507
  2664. // client := &http.Client{}
  2665. // bytesData, _ := json.Marshal(data)
  2666. // var req *http.Request
  2667. // if miConfig.MdtrtareaAdmvs == "320921" {
  2668. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2669. // } else {
  2670. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2671. // }
  2672. //
  2673. // resp, _ := client.Do(req)
  2674. // defer resp.Body.Close()
  2675. // body, ioErr := ioutil.ReadAll(resp.Body)
  2676. // if ioErr != nil {
  2677. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2678. // }
  2679. // var respJSON map[string]interface{}
  2680. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2681. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2682. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2683. // return
  2684. // }
  2685. // var resSix10265 ResultSix10265 //1101结果
  2686. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2687. // result, _ := json.Marshal(respJSON)
  2688. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2689. // utils.ErrorLog("解析失败:%v", err)
  2690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2691. // return
  2692. // }
  2693. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2694. // //res.Output = resSix10265.Output
  2695. // res.ErrMsg = resSix10265.ErrMsg
  2696. // res.Cainfo = resSix10265.Cainfo
  2697. // res.WarnMsg = resSix10265.WarnMsg
  2698. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2699. // res.Infcode = infocode
  2700. // }
  2701. //
  2702. // if res.Infcode == 0 {
  2703. // item.IsSale = 0
  2704. // item.SaleDate = ""
  2705. // item.Bchno = ""
  2706. //
  2707. // service.SaveDF(item)
  2708. // } else {
  2709. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2710. // }
  2711. // }
  2712. // if item.IsSale == 0 && item.IsChange == 1 {
  2713. //
  2714. // var res FJ3507Result
  2715. // var struct3507 models.Struct3507
  2716. // struct3507.FixmedinsBchno = item.BgBchno
  2717. // struct3507.InvDataType = "2"
  2718. // struct3507.Opter = roles.UserName
  2719. // struct3507.FixmedinsCode = miConfig.Code
  2720. // struct3507.Code = miConfig.Code
  2721. //
  2722. // struct3507.OrgName = miConfig.OrgName
  2723. // struct3507.AccessKey = miConfig.AccessKey
  2724. // struct3507.RequestUrl = miConfig.Url
  2725. // struct3507.SecretKey = miConfig.SecretKey
  2726. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2727. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2728. // struct3507.Url = miConfig.Url
  2729. // struct3507.AppId = miConfig.Cainfo
  2730. // struct3507.AppSecret = miConfig.AppSecret
  2731. // struct3507.Enckey = miConfig.EncKey
  2732. // struct3507.SignKey = miConfig.SignKey
  2733. // struct3507.SecretKey = miConfig.SecretKey
  2734. // //result, result1, _ := service.FJyb3507(struct3507)
  2735. // //saveLog(result, result1, "3507", "3507")
  2736. // //
  2737. // //var respJSON3 map[string]interface{}
  2738. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2739. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2740. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2741. // // return
  2742. // //}
  2743. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2744. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2745. // // utils.ErrorLog("解析失败:%v", err)
  2746. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2747. // // return
  2748. // //}
  2749. // if miConfig.MdtrtareaAdmvs == "350500" {
  2750. // result, result1, _ := service.FJyb3507(struct3507)
  2751. // saveLog(result, result1, "3507", "3507")
  2752. // var respJSON2 map[string]interface{}
  2753. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2754. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2755. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2756. // return
  2757. // }
  2758. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2759. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2760. // utils.ErrorLog("解析失败:%v", err)
  2761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2762. // return
  2763. // }
  2764. // } else {
  2765. // data := make(map[string]interface{})
  2766. // data["struct_3507s"] = struct3507
  2767. // client := &http.Client{}
  2768. // bytesData, _ := json.Marshal(data)
  2769. // var req *http.Request
  2770. // if miConfig.MdtrtareaAdmvs == "320921" {
  2771. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2772. // } else {
  2773. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2774. // }
  2775. //
  2776. // resp, _ := client.Do(req)
  2777. // defer resp.Body.Close()
  2778. // body, ioErr := ioutil.ReadAll(resp.Body)
  2779. // if ioErr != nil {
  2780. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2781. // }
  2782. // var respJSON map[string]interface{}
  2783. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2784. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2786. // return
  2787. // }
  2788. // var resSix10265 ResultSix10265 //1101结果
  2789. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2790. // result, _ := json.Marshal(respJSON)
  2791. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2792. // utils.ErrorLog("解析失败:%v", err)
  2793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2794. // return
  2795. // }
  2796. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2797. // //res.Output = resSix10265.Output
  2798. // res.ErrMsg = resSix10265.ErrMsg
  2799. // res.Cainfo = resSix10265.Cainfo
  2800. // res.WarnMsg = resSix10265.WarnMsg
  2801. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2802. // res.Infcode = infocode
  2803. // }
  2804. //
  2805. // if res.Infcode == 0 {
  2806. // item.IsChange = 0
  2807. // item.BgBchno = ""
  2808. // service.SaveDF2(item)
  2809. // } else {
  2810. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2811. // }
  2812. // }
  2813. // }
  2814. // if len(err) == 0 {
  2815. // c.ServeSuccessJSON(map[string]interface{}{
  2816. // "msg": "删除销售变更成功",
  2817. // })
  2818. //
  2819. // } else {
  2820. // c.ServeSuccessJSON(map[string]interface{}{
  2821. // "failed_code": -10,
  2822. // "msg": err,
  2823. // })
  2824. //
  2825. // }
  2826. //
  2827. //}
  2828. // 获取当天起止时间戳
  2829. func GetNowTime() (int64, int64) {
  2830. t := time.Now()
  2831. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2832. timesamp := addTime.Unix()
  2833. return timesamp, timesamp + 86399
  2834. }
  2835. func (c *HisApiController) ChangeDrugfour() {
  2836. patient_id, _ := c.GetInt64("patient_id")
  2837. admin_user_id, _ := c.GetInt64("admin_user_id")
  2838. //id_arr := strings.Split(ids, ",")
  2839. times := c.GetString("time", "")
  2840. timeLayout := "2006-01-02"
  2841. loc, _ := time.LoadLocation("Local")
  2842. var stime, etime int64
  2843. if times == "" {
  2844. stime, etime = GetNowTime()
  2845. } else {
  2846. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2847. stime = stmp.Unix()
  2848. etime = stime + 86399
  2849. }
  2850. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2851. var flows []*models.DrugFlow
  2852. for _, item := range advicelist {
  2853. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.ID, stime, c.GetAdminUserInfo().CurrentOrgId)
  2854. flows = append(flows, flow...)
  2855. }
  2856. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2857. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2858. var err []string
  2859. for _, item := range flows {
  2860. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2861. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2862. if prescription.OrderStatus == 2 {
  2863. //已经结算
  2864. //判断是否已经销售
  2865. if item.IsSale == 1 { //是否已经销售,1是 0否
  2866. //是否已经变更 1是 0否
  2867. //if item.IsChange == 0 { //没变更,进行变更操作
  2868. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2869. //
  2870. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2871. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  2872. // var respJSON3 map[string]interface{}
  2873. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2874. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2875. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2876. // return
  2877. // }
  2878. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2879. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2880. // utils.ErrorLog("解析失败:%v", err)
  2881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2882. // return
  2883. // }
  2884. // if res3.Infcode == 0 {
  2885. // item.IsChange = 1
  2886. // item.BgBchno = bg_number
  2887. // service.SaveDF2(item)
  2888. // } else {
  2889. //
  2890. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2891. // }
  2892. //}
  2893. } else { //没销售,
  2894. var res FJ3507Result
  2895. var res3507for10188 FJ3507ResultFor10188
  2896. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2897. //进行商品销售接口
  2898. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2899. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2900. var respJSON3 map[string]interface{}
  2901. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2904. return
  2905. }
  2906. userJSONBytes3, _ := json.Marshal(respJSON3)
  2907. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2908. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2909. utils.ErrorLog("解析失败:%v", err)
  2910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2911. return
  2912. }
  2913. //if res3507for10188.Infcode
  2914. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2915. //res.Output = resSix10265.Output
  2916. res.ErrMsg = res3507for10188.ErrMsg
  2917. res.Cainfo = res3507for10188.Cainfo
  2918. res.WarnMsg = res3507for10188.WarnMsg
  2919. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2920. res.Infcode = infocode
  2921. } else {
  2922. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2923. utils.ErrorLog("解析失败:%v", err)
  2924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2925. return
  2926. }
  2927. }
  2928. if res.Infcode == 0 {
  2929. item.IsSale = 1
  2930. item.Bchno = number
  2931. item.SaleDate = time.Now().Format("2006-01-02")
  2932. service.SaveDF(item)
  2933. //if err5 == nil {
  2934. // if item.IsChange == 0 { //没变更,进行变更操作
  2935. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2936. //
  2937. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2938. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  2939. //
  2940. // var respJSON3 map[string]interface{}
  2941. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2942. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2944. // return
  2945. // }
  2946. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2947. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2948. // utils.ErrorLog("解析失败:%v", err)
  2949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2950. // return
  2951. // }
  2952. // //if res3507for10188.Infcode
  2953. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2954. // //res.Output = resSix10265.Output
  2955. // res3.ErrMsg = res3507for10188.ErrMsg
  2956. // res3.Cainfo = res3507for10188.Cainfo
  2957. // res3.WarnMsg = res3507for10188.WarnMsg
  2958. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2959. // res3.Infcode = infocode
  2960. // } else {
  2961. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2962. // utils.ErrorLog("解析失败:%v", err)
  2963. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2964. // return
  2965. // }
  2966. // }
  2967. // if res3.Infcode == 0 {
  2968. // item.IsChange = 1
  2969. // item.BgBchno = bg_number
  2970. // service.SaveDF2(item)
  2971. // } else {
  2972. //
  2973. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2974. // }
  2975. // }
  2976. //}
  2977. } else {
  2978. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2979. }
  2980. }
  2981. } else { //还没结,提示用户去结算,并药品追溯上传
  2982. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  2983. }
  2984. }
  2985. }
  2986. if len(err) == 0 {
  2987. c.ServeSuccessJSON(map[string]interface{}{
  2988. "msg": "销售成功",
  2989. })
  2990. } else {
  2991. c.ServeSuccessJSON(map[string]interface{}{
  2992. "failed_code": -10,
  2993. "msg": err,
  2994. })
  2995. }
  2996. }
  2997. //func (c *HisApiController) ChangeDrugfour() {
  2998. // patient_id, _ := c.GetInt64("patient_id")
  2999. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3000. // //id_arr := strings.Split(ids, ",")
  3001. // times := c.GetString("time", "")
  3002. // timeLayout := "2006-01-02"
  3003. // loc, _ := time.LoadLocation("Local")
  3004. // var stime, etime int64
  3005. // if times == "" {
  3006. // stime, etime = GetNowTime()
  3007. // } else {
  3008. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3009. // stime = stmp.Unix()
  3010. // etime = stime + 86399
  3011. // }
  3012. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3013. // var flows []*models.DrugFlow
  3014. // for _, item := range advicelist {
  3015. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3016. // flows = append(flows, flow...)
  3017. // }
  3018. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3019. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3020. // var err []string
  3021. //
  3022. // for _, item := range flows {
  3023. // var res3 ResultSix
  3024. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3025. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3026. // if prescription.OrderStatus == 2 {
  3027. // //已经结算
  3028. // //判断是否已经销售
  3029. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3030. // //是否已经变更 1是 0否
  3031. // if item.IsChange == 0 { //没变更,进行变更操作
  3032. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3033. //
  3034. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3035. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3036. // var respJSON3 map[string]interface{}
  3037. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3038. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3040. // return
  3041. // }
  3042. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3043. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3044. // utils.ErrorLog("解析失败:%v", err)
  3045. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3046. // return
  3047. // }
  3048. // if res3.Infcode == 0 {
  3049. // item.IsChange = 1
  3050. // item.BgBchno = bg_number
  3051. // service.SaveDF2(item)
  3052. // } else {
  3053. //
  3054. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3055. // }
  3056. // }
  3057. // } else { //没销售,
  3058. // var res FJ3507Result
  3059. // var res3507for10188 FJ3507ResultFor10188
  3060. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3061. //
  3062. // //进行商品销售接口
  3063. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3064. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3065. // var respJSON3 map[string]interface{}
  3066. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3067. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3068. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3069. // return
  3070. // }
  3071. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3072. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3073. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3074. // utils.ErrorLog("解析失败:%v", err)
  3075. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3076. // return
  3077. // }
  3078. // //if res3507for10188.Infcode
  3079. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3080. // //res.Output = resSix10265.Output
  3081. // res.ErrMsg = res3507for10188.ErrMsg
  3082. // res.Cainfo = res3507for10188.Cainfo
  3083. // res.WarnMsg = res3507for10188.WarnMsg
  3084. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3085. // res.Infcode = infocode
  3086. // } else {
  3087. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3088. // utils.ErrorLog("解析失败:%v", err)
  3089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3090. // return
  3091. // }
  3092. //
  3093. // }
  3094. // if res.Infcode == 0 {
  3095. // item.IsSale = 1
  3096. // item.Bchno = number
  3097. // item.SaleDate = time.Now().Format("2006-01-02")
  3098. //
  3099. // err5 := service.SaveDF(item)
  3100. // if err5 == nil {
  3101. // if item.IsChange == 0 { //没变更,进行变更操作
  3102. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3103. //
  3104. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3105. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3106. //
  3107. // var respJSON3 map[string]interface{}
  3108. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3109. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3111. // return
  3112. // }
  3113. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3114. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3115. // utils.ErrorLog("解析失败:%v", err)
  3116. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3117. // return
  3118. // }
  3119. // //if res3507for10188.Infcode
  3120. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3121. // //res.Output = resSix10265.Output
  3122. // res3.ErrMsg = res3507for10188.ErrMsg
  3123. // res3.Cainfo = res3507for10188.Cainfo
  3124. // res3.WarnMsg = res3507for10188.WarnMsg
  3125. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3126. // res3.Infcode = infocode
  3127. // } else {
  3128. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3129. // utils.ErrorLog("解析失败:%v", err)
  3130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3131. // return
  3132. // }
  3133. // }
  3134. // if res3.Infcode == 0 {
  3135. // item.IsChange = 1
  3136. // item.BgBchno = bg_number
  3137. // service.SaveDF2(item)
  3138. // } else {
  3139. //
  3140. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3141. // }
  3142. // }
  3143. // }
  3144. // } else {
  3145. //
  3146. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3147. // }
  3148. // }
  3149. //
  3150. // } else { //还没结,提示用户去结算,并药品追溯上传
  3151. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3152. // }
  3153. // }
  3154. // }
  3155. // if len(err) == 0 {
  3156. // c.ServeSuccessJSON(map[string]interface{}{
  3157. // "msg": "销售变更成功",
  3158. // })
  3159. // } else {
  3160. // c.ServeSuccessJSON(map[string]interface{}{
  3161. // "failed_code": -10,
  3162. // "msg": err,
  3163. // })
  3164. // }
  3165. //}
  3166. func (c *HisApiController) ChangeDrug() {
  3167. ids := c.GetString("ids")
  3168. id_arr := strings.Split(ids, ",")
  3169. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3170. admin_user_id, _ := c.GetInt64("admin_user_id")
  3171. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3172. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3173. var err []string
  3174. for _, item := range flows {
  3175. var res3 ResultSix
  3176. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3177. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3178. if prescription.OrderStatus == 2 {
  3179. //已经结算
  3180. //判断是否已经销售
  3181. if item.IsSale == 1 { //是否已经销售,1是 0否
  3182. //是否已经变更 1是 0否
  3183. if item.IsChange == 0 { //没变更,进行变更操作
  3184. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3185. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3186. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3187. var respJSON3 map[string]interface{}
  3188. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3191. return
  3192. }
  3193. userJSONBytes3, _ := json.Marshal(respJSON3)
  3194. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3195. utils.ErrorLog("解析失败:%v", err)
  3196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3197. return
  3198. }
  3199. if res3.Infcode == 0 {
  3200. item.IsChange = 1
  3201. item.BgBchno = bg_number
  3202. service.SaveDF2(item)
  3203. } else {
  3204. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3205. }
  3206. }
  3207. } else { //没销售,
  3208. var res FJ3507Result
  3209. var res3507for10188 FJ3507ResultFor10188
  3210. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3211. //进行商品销售接口
  3212. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3213. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3214. var respJSON3 map[string]interface{}
  3215. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3218. return
  3219. }
  3220. userJSONBytes3, _ := json.Marshal(respJSON3)
  3221. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3222. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3223. utils.ErrorLog("解析失败:%v", err)
  3224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3225. return
  3226. }
  3227. //if res3507for10188.Infcode
  3228. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3229. //res.Output = resSix10265.Output
  3230. res.ErrMsg = res3507for10188.ErrMsg
  3231. res.Cainfo = res3507for10188.Cainfo
  3232. res.WarnMsg = res3507for10188.WarnMsg
  3233. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3234. res.Infcode = infocode
  3235. } else {
  3236. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3237. utils.ErrorLog("解析失败:%v", err)
  3238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3239. return
  3240. }
  3241. }
  3242. if res.Infcode == 0 {
  3243. item.IsSale = 1
  3244. item.Bchno = number
  3245. item.SaleDate = time.Now().Format("2006-01-02")
  3246. err5 := service.SaveDF(item)
  3247. if err5 == nil {
  3248. if item.IsChange == 0 { //没变更,进行变更操作
  3249. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3250. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3251. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3252. var respJSON3 map[string]interface{}
  3253. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3256. return
  3257. }
  3258. userJSONBytes3, _ := json.Marshal(respJSON3)
  3259. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3260. utils.ErrorLog("解析失败:%v", err)
  3261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3262. return
  3263. }
  3264. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3265. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3266. utils.ErrorLog("解析失败:%v", err)
  3267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3268. return
  3269. }
  3270. //if res3507for10188.Infcode
  3271. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3272. //res.Output = resSix10265.Output
  3273. res3.ErrMsg = res3507for10188.ErrMsg
  3274. res3.Cainfo = res3507for10188.Cainfo
  3275. res3.WarnMsg = res3507for10188.WarnMsg
  3276. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3277. res3.Infcode = infocode
  3278. } else {
  3279. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3280. utils.ErrorLog("解析失败:%v", err)
  3281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3282. return
  3283. }
  3284. }
  3285. if res3.Infcode == 0 {
  3286. item.IsChange = 1
  3287. item.BgBchno = bg_number
  3288. service.SaveDF2(item)
  3289. } else {
  3290. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3291. }
  3292. }
  3293. }
  3294. } else {
  3295. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3296. }
  3297. }
  3298. } else { //还没结算
  3299. var res3507for10188 FJ3507ResultFor10188
  3300. if item.IsChange == 0 { //没变更,进行变更操作
  3301. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3302. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3303. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3304. var respJSON3 map[string]interface{}
  3305. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3308. return
  3309. }
  3310. userJSONBytes3, _ := json.Marshal(respJSON3)
  3311. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3312. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3313. utils.ErrorLog("解析失败:%v", err)
  3314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3315. return
  3316. }
  3317. //if res3507for10188.Infcode
  3318. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3319. //res.Output = resSix10265.Output
  3320. res3.ErrMsg = res3507for10188.ErrMsg
  3321. res3.Cainfo = res3507for10188.Cainfo
  3322. res3.WarnMsg = res3507for10188.WarnMsg
  3323. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3324. res3.Infcode = infocode
  3325. } else {
  3326. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3327. utils.ErrorLog("解析失败:%v", err)
  3328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3329. return
  3330. }
  3331. }
  3332. if res3.Infcode == 0 {
  3333. item.IsChange = 1
  3334. item.BgBchno = bg_number
  3335. service.SaveDF2(item)
  3336. } else {
  3337. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3338. }
  3339. }
  3340. }
  3341. } else if item.ConsumableType == 7 {
  3342. var res3507for10188 FJ3507ResultFor10188
  3343. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3344. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3345. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3346. //判断是否已经销售
  3347. if item.IsSale == 2 { //是否已经销售,1是 0否
  3348. //是否已经变更 1是 0否
  3349. if item.IsChange == 0 { //没变更,进行变更操作
  3350. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3351. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3352. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3353. var respJSON3 map[string]interface{}
  3354. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3357. return
  3358. }
  3359. userJSONBytes3, _ := json.Marshal(respJSON3)
  3360. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3361. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3362. utils.ErrorLog("解析失败:%v", err)
  3363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3364. return
  3365. }
  3366. //if res3507for10188.Infcode
  3367. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3368. //res.Output = resSix10265.Output
  3369. res3.ErrMsg = res3507for10188.ErrMsg
  3370. res3.Cainfo = res3507for10188.Cainfo
  3371. res3.WarnMsg = res3507for10188.WarnMsg
  3372. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3373. res3.Infcode = infocode
  3374. } else {
  3375. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3376. utils.ErrorLog("解析失败:%v", err)
  3377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3378. return
  3379. }
  3380. }
  3381. if res3.Infcode == 0 {
  3382. item.IsChange = 1
  3383. item.BgBchno = bg_number
  3384. service.SaveDF2(item)
  3385. } else {
  3386. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3387. }
  3388. }
  3389. } else { //没销售,
  3390. //进行商品销售退货接口
  3391. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3392. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3393. saveLog(result111, result222, "3506", "销售退货")
  3394. var res7 FJ3507Result
  3395. //进行商品销售接口
  3396. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3397. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3398. var respJSON3 map[string]interface{}
  3399. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3402. return
  3403. }
  3404. userJSONBytes3, _ := json.Marshal(respJSON3)
  3405. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3406. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3407. utils.ErrorLog("解析失败:%v", err)
  3408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3409. return
  3410. }
  3411. //if res3507for10188.Infcode
  3412. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3413. //res.Output = resSix10265.Output
  3414. res7.ErrMsg = res3507for10188.ErrMsg
  3415. res7.Cainfo = res3507for10188.Cainfo
  3416. res7.WarnMsg = res3507for10188.WarnMsg
  3417. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3418. res7.Infcode = infocode
  3419. } else {
  3420. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3421. utils.ErrorLog("解析失败:%v", err)
  3422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3423. return
  3424. }
  3425. }
  3426. if res7.Infcode == 0 {
  3427. item.IsSale = 2
  3428. item.SaleDate = item.SaleDate
  3429. item.Bchno = number
  3430. service.SaveDF(item)
  3431. if item.IsChange == 0 { //没变更,进行变更操作
  3432. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3433. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3434. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3435. var respJSON3 map[string]interface{}
  3436. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3439. return
  3440. }
  3441. userJSONBytes3, _ := json.Marshal(respJSON3)
  3442. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3443. // utils.ErrorLog("解析失败:%v", err)
  3444. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3445. // return
  3446. //}
  3447. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3448. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3449. utils.ErrorLog("解析失败:%v", err)
  3450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3451. return
  3452. }
  3453. //if res3507for10188.Infcode
  3454. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3455. //res.Output = resSix10265.Output
  3456. res3.ErrMsg = res3507for10188.ErrMsg
  3457. res3.Cainfo = res3507for10188.Cainfo
  3458. res3.WarnMsg = res3507for10188.WarnMsg
  3459. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3460. res3.Infcode = infocode
  3461. } else {
  3462. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3463. utils.ErrorLog("解析失败:%v", err)
  3464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3465. return
  3466. }
  3467. }
  3468. if res3.Infcode == 0 {
  3469. item.IsChange = 1
  3470. item.BgBchno = bg_number
  3471. service.SaveDF2(item)
  3472. } else {
  3473. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3474. }
  3475. }
  3476. } else {
  3477. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3478. }
  3479. }
  3480. } else { //还没结算
  3481. if item.IsChange == 0 { //没变更,进行变更操作
  3482. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3483. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3484. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3485. var respJSON3 map[string]interface{}
  3486. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3489. return
  3490. }
  3491. userJSONBytes3, _ := json.Marshal(respJSON3)
  3492. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3493. // utils.ErrorLog("解析失败:%v", err)
  3494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3495. // return
  3496. //}
  3497. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3498. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3499. utils.ErrorLog("解析失败:%v", err)
  3500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3501. return
  3502. }
  3503. //if res3507for10188.Infcode
  3504. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3505. //res.Output = resSix10265.Output
  3506. res3.ErrMsg = res3507for10188.ErrMsg
  3507. res3.Cainfo = res3507for10188.Cainfo
  3508. res3.WarnMsg = res3507for10188.WarnMsg
  3509. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3510. res3.Infcode = infocode
  3511. } else {
  3512. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3513. utils.ErrorLog("解析失败:%v", err)
  3514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3515. return
  3516. }
  3517. }
  3518. if res3.Infcode == 0 {
  3519. item.IsChange = 1
  3520. item.BgBchno = bg_number
  3521. service.SaveDF2(item)
  3522. } else {
  3523. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3524. }
  3525. }
  3526. }
  3527. }
  3528. }
  3529. if len(err) == 0 {
  3530. c.ServeSuccessJSON(map[string]interface{}{
  3531. "msg": "销售变更成功",
  3532. })
  3533. } else {
  3534. c.ServeSuccessJSON(map[string]interface{}{
  3535. "failed_code": -10,
  3536. "msg": err,
  3537. })
  3538. }
  3539. }
  3540. func (c *HisApiController) ChangeDrugtwo() {
  3541. //ids := c.GetString("ids")
  3542. //id_arr := strings.Split(ids, ",")
  3543. flows, _ := service.GetNewDrugFlowInfothree123()
  3544. admin_user_id, _ := c.GetInt64("admin_user_id")
  3545. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3546. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3547. var err []string
  3548. for _, item := range flows {
  3549. var res3 ResultSix
  3550. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3551. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3552. if prescription.OrderStatus == 2 {
  3553. //已经结算
  3554. //判断是否已经销售
  3555. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3556. // //是否已经变更 1是 0否
  3557. // if item.IsChange == 0 { //没变更,进行变更操作
  3558. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3559. //
  3560. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3561. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3562. // var respJSON3 map[string]interface{}
  3563. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3564. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3565. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3566. // return
  3567. // }
  3568. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3569. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3570. // utils.ErrorLog("解析失败:%v", err)
  3571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3572. // return
  3573. // }
  3574. // if res3.Infcode == 0 {
  3575. // item.IsChange = 1
  3576. // item.BgBchno = bg_number
  3577. // service.SaveDF2(item)
  3578. // } else {
  3579. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3580. // }
  3581. // }
  3582. //}
  3583. //else
  3584. { //没销售,
  3585. var res FJ3507Result
  3586. var res3507for10188 FJ3507ResultFor10188
  3587. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3588. //进行商品销售接口
  3589. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3590. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3591. var respJSON3 map[string]interface{}
  3592. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3595. return
  3596. }
  3597. userJSONBytes3, _ := json.Marshal(respJSON3)
  3598. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3599. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3600. utils.ErrorLog("解析失败:%v", err)
  3601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3602. return
  3603. }
  3604. //if res3507for10188.Infcode
  3605. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3606. //res.Output = resSix10265.Output
  3607. res.ErrMsg = res3507for10188.ErrMsg
  3608. res.Cainfo = res3507for10188.Cainfo
  3609. res.WarnMsg = res3507for10188.WarnMsg
  3610. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3611. res.Infcode = infocode
  3612. } else {
  3613. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3614. utils.ErrorLog("解析失败:%v", err)
  3615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3616. return
  3617. }
  3618. }
  3619. if res.Infcode == 0 {
  3620. item.IsSale = 1
  3621. item.Bchno = number
  3622. item.SaleDate = time.Now().Format("2006-01-02")
  3623. service.SaveDF(item)
  3624. //if err5 == nil {
  3625. // if item.IsChange == 0 { //没变更,进行变更操作
  3626. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3627. //
  3628. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3629. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3630. //
  3631. // var respJSON3 map[string]interface{}
  3632. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3633. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3635. // return
  3636. // }
  3637. //
  3638. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3639. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3640. // utils.ErrorLog("解析失败:%v", err)
  3641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3642. // return
  3643. // }
  3644. // //if res3507for10188.Infcode
  3645. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3646. // //res.Output = resSix10265.Output
  3647. // res3.ErrMsg = res3507for10188.ErrMsg
  3648. // res3.Cainfo = res3507for10188.Cainfo
  3649. // res3.WarnMsg = res3507for10188.WarnMsg
  3650. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3651. // res3.Infcode = infocode
  3652. // } else {
  3653. //
  3654. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3655. // utils.ErrorLog("解析失败:%v", err)
  3656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3657. // return
  3658. // }
  3659. //
  3660. // }
  3661. //
  3662. // if res3.Infcode == 0 {
  3663. // item.IsChange = 1
  3664. // item.BgBchno = bg_number
  3665. // service.SaveDF2(item)
  3666. // } else {
  3667. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3668. // }
  3669. // }
  3670. //}
  3671. } else {
  3672. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3673. }
  3674. }
  3675. } else
  3676. { //还没结算
  3677. var res3507for10188 FJ3507ResultFor10188
  3678. if item.IsChange == 0 { //没变更,进行变更操作
  3679. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3680. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3681. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3682. var respJSON3 map[string]interface{}
  3683. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3686. return
  3687. }
  3688. userJSONBytes3, _ := json.Marshal(respJSON3)
  3689. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3690. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3691. utils.ErrorLog("解析失败:%v", err)
  3692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3693. return
  3694. }
  3695. //if res3507for10188.Infcode
  3696. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3697. //res.Output = resSix10265.Output
  3698. res3.ErrMsg = res3507for10188.ErrMsg
  3699. res3.Cainfo = res3507for10188.Cainfo
  3700. res3.WarnMsg = res3507for10188.WarnMsg
  3701. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3702. res3.Infcode = infocode
  3703. } else {
  3704. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3705. utils.ErrorLog("解析失败:%v", err)
  3706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3707. return
  3708. }
  3709. }
  3710. if res3.Infcode == 0 {
  3711. item.IsChange = 1
  3712. item.BgBchno = bg_number
  3713. service.SaveDF2(item)
  3714. } else {
  3715. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3716. }
  3717. }
  3718. }
  3719. }
  3720. //if item.ConsumableType == 7 {
  3721. // var res3507for10188 FJ3507ResultFor10188
  3722. //
  3723. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3724. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3725. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3726. // //判断是否已经销售
  3727. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3728. // //是否已经变更 1是 0否
  3729. // if item.IsChange == 0 { //没变更,进行变更操作
  3730. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3731. //
  3732. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3733. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3734. //
  3735. // var respJSON3 map[string]interface{}
  3736. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3737. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3738. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3739. // return
  3740. // }
  3741. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3742. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3743. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3744. // utils.ErrorLog("解析失败:%v", err)
  3745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3746. // return
  3747. // }
  3748. // //if res3507for10188.Infcode
  3749. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3750. // //res.Output = resSix10265.Output
  3751. // res3.ErrMsg = res3507for10188.ErrMsg
  3752. // res3.Cainfo = res3507for10188.Cainfo
  3753. // res3.WarnMsg = res3507for10188.WarnMsg
  3754. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3755. // res3.Infcode = infocode
  3756. // } else {
  3757. //
  3758. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3759. // utils.ErrorLog("解析失败:%v", err)
  3760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3761. // return
  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. // } else { //没销售,
  3774. // //进行商品销售退货接口
  3775. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3776. //
  3777. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3778. // saveLog(result111, result222, "3506", "销售退货")
  3779. // var res7 FJ3507Result
  3780. //
  3781. // //进行商品销售接口
  3782. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3783. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3784. // var respJSON3 map[string]interface{}
  3785. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3786. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3788. // return
  3789. // }
  3790. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3791. //
  3792. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3793. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3794. // utils.ErrorLog("解析失败:%v", err)
  3795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3796. // return
  3797. // }
  3798. // //if res3507for10188.Infcode
  3799. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3800. // //res.Output = resSix10265.Output
  3801. // res7.ErrMsg = res3507for10188.ErrMsg
  3802. // res7.Cainfo = res3507for10188.Cainfo
  3803. // res7.WarnMsg = res3507for10188.WarnMsg
  3804. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3805. // res7.Infcode = infocode
  3806. // } else {
  3807. //
  3808. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3809. // utils.ErrorLog("解析失败:%v", err)
  3810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3811. // return
  3812. // }
  3813. //
  3814. // }
  3815. // if res7.Infcode == 0 {
  3816. // item.IsSale = 2
  3817. // item.SaleDate = item.SaleDate
  3818. // item.Bchno = number
  3819. // service.SaveDF(item)
  3820. // if item.IsChange == 0 { //没变更,进行变更操作
  3821. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3822. //
  3823. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3824. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3825. //
  3826. // var respJSON3 map[string]interface{}
  3827. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3828. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3830. // return
  3831. // }
  3832. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3833. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3834. // // utils.ErrorLog("解析失败:%v", err)
  3835. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3836. // // return
  3837. // //}
  3838. //
  3839. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3840. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3841. // utils.ErrorLog("解析失败:%v", err)
  3842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. // return
  3844. // }
  3845. // //if res3507for10188.Infcode
  3846. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3847. // //res.Output = resSix10265.Output
  3848. // res3.ErrMsg = res3507for10188.ErrMsg
  3849. // res3.Cainfo = res3507for10188.Cainfo
  3850. // res3.WarnMsg = res3507for10188.WarnMsg
  3851. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3852. // res3.Infcode = infocode
  3853. // } else {
  3854. //
  3855. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3856. // utils.ErrorLog("解析失败:%v", err)
  3857. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3858. // return
  3859. // }
  3860. //
  3861. // }
  3862. // if res3.Infcode == 0 {
  3863. // item.IsChange = 1
  3864. // item.BgBchno = bg_number
  3865. // service.SaveDF2(item)
  3866. // } else {
  3867. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3868. // }
  3869. // }
  3870. // } else {
  3871. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3872. // }
  3873. // }
  3874. // } else { //还没结算
  3875. // if item.IsChange == 0 { //没变更,进行变更操作
  3876. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3877. //
  3878. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3879. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3880. //
  3881. // var respJSON3 map[string]interface{}
  3882. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3883. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3884. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3885. // return
  3886. // }
  3887. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3888. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3889. // // utils.ErrorLog("解析失败:%v", err)
  3890. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3891. // // return
  3892. // //}
  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. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3902. // //res.Output = resSix10265.Output
  3903. // res3.ErrMsg = res3507for10188.ErrMsg
  3904. // res3.Cainfo = res3507for10188.Cainfo
  3905. // res3.WarnMsg = res3507for10188.WarnMsg
  3906. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3907. // res3.Infcode = infocode
  3908. // } else {
  3909. //
  3910. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3911. // utils.ErrorLog("解析失败:%v", err)
  3912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3913. // return
  3914. // }
  3915. //
  3916. // }
  3917. // if res3.Infcode == 0 {
  3918. // item.IsChange = 1
  3919. // item.BgBchno = bg_number
  3920. // service.SaveDF2(item)
  3921. // } else {
  3922. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3923. // }
  3924. // }
  3925. // }
  3926. //}
  3927. }
  3928. if len(err) == 0 {
  3929. c.ServeSuccessJSON(map[string]interface{}{
  3930. "msg": "销售变更成功",
  3931. })
  3932. } else {
  3933. c.ServeSuccessJSON(map[string]interface{}{
  3934. "failed_code": -10,
  3935. "msg": err,
  3936. })
  3937. }
  3938. }
  3939. func (c *HisApiController) ChangeDrugthree() {
  3940. //ids := c.GetString("ids")
  3941. //id_arr := strings.Split(ids, ",")
  3942. flows, _ := service.GetNewDrugFlowInfothree()
  3943. admin_user_id, _ := c.GetInt64("admin_user_id")
  3944. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3945. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3946. var err []string
  3947. for _, item := range flows {
  3948. var res3 ResultSix
  3949. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3950. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3951. if prescription.OrderStatus == 2 {
  3952. //已经结算
  3953. //判断是否已经销售
  3954. if item.IsSale == 1 { //是否已经销售,1是 0否
  3955. //是否已经变更 1是 0否
  3956. if item.IsChange == 0 { //没变更,进行变更操作
  3957. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3958. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3959. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3960. var respJSON3 map[string]interface{}
  3961. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3964. return
  3965. }
  3966. userJSONBytes3, _ := json.Marshal(respJSON3)
  3967. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3968. utils.ErrorLog("解析失败:%v", err)
  3969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3970. return
  3971. }
  3972. if res3.Infcode == 0 {
  3973. item.IsChange = 1
  3974. item.BgBchno = bg_number
  3975. service.SaveDF2(item)
  3976. } else {
  3977. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3978. }
  3979. }
  3980. } else { //没销售,
  3981. var res FJ3507Result
  3982. var res3507for10188 FJ3507ResultFor10188
  3983. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3984. //进行商品销售接口
  3985. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3986. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3987. var respJSON3 map[string]interface{}
  3988. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3991. return
  3992. }
  3993. userJSONBytes3, _ := json.Marshal(respJSON3)
  3994. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3995. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3996. utils.ErrorLog("解析失败:%v", err)
  3997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3998. return
  3999. }
  4000. //if res3507for10188.Infcode
  4001. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4002. //res.Output = resSix10265.Output
  4003. res.ErrMsg = res3507for10188.ErrMsg
  4004. res.Cainfo = res3507for10188.Cainfo
  4005. res.WarnMsg = res3507for10188.WarnMsg
  4006. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4007. res.Infcode = infocode
  4008. } else {
  4009. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4010. utils.ErrorLog("解析失败:%v", err)
  4011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4012. return
  4013. }
  4014. }
  4015. if res.Infcode == 0 {
  4016. item.IsSale = 1
  4017. item.Bchno = number
  4018. item.SaleDate = time.Now().Format("2006-01-02")
  4019. err5 := service.SaveDF(item)
  4020. if err5 == nil {
  4021. if item.IsChange == 0 { //没变更,进行变更操作
  4022. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4023. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4024. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4025. var respJSON3 map[string]interface{}
  4026. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4029. return
  4030. }
  4031. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4032. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4033. utils.ErrorLog("解析失败:%v", err)
  4034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4035. return
  4036. }
  4037. //if res3507for10188.Infcode
  4038. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4039. //res.Output = resSix10265.Output
  4040. res3.ErrMsg = res3507for10188.ErrMsg
  4041. res3.Cainfo = res3507for10188.Cainfo
  4042. res3.WarnMsg = res3507for10188.WarnMsg
  4043. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4044. res3.Infcode = infocode
  4045. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4046. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4047. utils.ErrorLog("解析失败:%v", err)
  4048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4049. return
  4050. }
  4051. //if res3507for10188.Infcode
  4052. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4053. //res.Output = resSix10265.Output
  4054. res3.ErrMsg = res3507for10188.ErrMsg
  4055. res3.Cainfo = res3507for10188.Cainfo
  4056. res3.WarnMsg = res3507for10188.WarnMsg
  4057. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4058. res3.Infcode = infocode
  4059. } else {
  4060. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4061. utils.ErrorLog("解析失败:%v", err)
  4062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4063. return
  4064. }
  4065. }
  4066. if res3.Infcode == 0 {
  4067. item.IsChange = 1
  4068. item.BgBchno = bg_number
  4069. service.SaveDF2(item)
  4070. } else {
  4071. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4072. }
  4073. }
  4074. }
  4075. } else {
  4076. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4077. }
  4078. }
  4079. } else { //还没结算
  4080. var res3507for10188 FJ3507ResultFor10188
  4081. if item.IsChange == 0 { //没变更,进行变更操作
  4082. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4083. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4084. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4085. var respJSON3 map[string]interface{}
  4086. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4089. return
  4090. }
  4091. userJSONBytes3, _ := json.Marshal(respJSON3)
  4092. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4093. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4094. utils.ErrorLog("解析失败:%v", err)
  4095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4096. return
  4097. }
  4098. //if res3507for10188.Infcode
  4099. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4100. //res.Output = resSix10265.Output
  4101. res3.ErrMsg = res3507for10188.ErrMsg
  4102. res3.Cainfo = res3507for10188.Cainfo
  4103. res3.WarnMsg = res3507for10188.WarnMsg
  4104. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4105. res3.Infcode = infocode
  4106. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4107. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4108. utils.ErrorLog("解析失败:%v", err)
  4109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4110. return
  4111. }
  4112. //if res3507for10188.Infcode
  4113. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4114. //res.Output = resSix10265.Output
  4115. res3.ErrMsg = res3507for10188.ErrMsg
  4116. res3.Cainfo = res3507for10188.Cainfo
  4117. res3.WarnMsg = res3507for10188.WarnMsg
  4118. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4119. res3.Infcode = infocode
  4120. } else {
  4121. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4122. utils.ErrorLog("解析失败:%v", err)
  4123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4124. return
  4125. }
  4126. }
  4127. if res3.Infcode == 0 {
  4128. item.IsChange = 1
  4129. item.BgBchno = bg_number
  4130. service.SaveDF2(item)
  4131. } else {
  4132. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4133. }
  4134. }
  4135. }
  4136. } else if item.ConsumableType == 7 {
  4137. var res3507for10188 FJ3507ResultFor10188
  4138. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4139. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4140. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4141. //判断是否已经销售
  4142. if item.IsSale == 2 { //是否已经销售,1是 0否
  4143. //是否已经变更 1是 0否
  4144. if item.IsChange == 0 { //没变更,进行变更操作
  4145. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4146. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4147. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4148. var respJSON3 map[string]interface{}
  4149. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4152. return
  4153. }
  4154. userJSONBytes3, _ := json.Marshal(respJSON3)
  4155. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4156. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4157. utils.ErrorLog("解析失败:%v", err)
  4158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4159. return
  4160. }
  4161. //if res3507for10188.Infcode
  4162. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4163. //res.Output = resSix10265.Output
  4164. res3.ErrMsg = res3507for10188.ErrMsg
  4165. res3.Cainfo = res3507for10188.Cainfo
  4166. res3.WarnMsg = res3507for10188.WarnMsg
  4167. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4168. res3.Infcode = infocode
  4169. } else {
  4170. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4171. utils.ErrorLog("解析失败:%v", err)
  4172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4173. return
  4174. }
  4175. }
  4176. if res3.Infcode == 0 {
  4177. item.IsChange = 1
  4178. item.BgBchno = bg_number
  4179. service.SaveDF2(item)
  4180. } else {
  4181. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4182. }
  4183. }
  4184. } else { //没销售,
  4185. //进行商品销售退货接口
  4186. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4187. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4188. saveLog(result111, result222, "3506", "销售退货")
  4189. var res7 FJ3507Result
  4190. //进行商品销售接口
  4191. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4192. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4193. var respJSON3 map[string]interface{}
  4194. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4197. return
  4198. }
  4199. userJSONBytes3, _ := json.Marshal(respJSON3)
  4200. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4201. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4202. utils.ErrorLog("解析失败:%v", err)
  4203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4204. return
  4205. }
  4206. //if res3507for10188.Infcode
  4207. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4208. //res.Output = resSix10265.Output
  4209. res7.ErrMsg = res3507for10188.ErrMsg
  4210. res7.Cainfo = res3507for10188.Cainfo
  4211. res7.WarnMsg = res3507for10188.WarnMsg
  4212. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4213. res7.Infcode = infocode
  4214. } else {
  4215. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4216. utils.ErrorLog("解析失败:%v", err)
  4217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4218. return
  4219. }
  4220. }
  4221. if res7.Infcode == 0 {
  4222. item.IsSale = 2
  4223. item.SaleDate = item.SaleDate
  4224. item.Bchno = number
  4225. service.SaveDF(item)
  4226. if item.IsChange == 0 { //没变更,进行变更操作
  4227. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4228. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4229. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4230. var respJSON3 map[string]interface{}
  4231. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4234. return
  4235. }
  4236. userJSONBytes3, _ := json.Marshal(respJSON3)
  4237. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4238. // utils.ErrorLog("解析失败:%v", err)
  4239. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4240. // return
  4241. //}
  4242. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4243. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4244. utils.ErrorLog("解析失败:%v", err)
  4245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4246. return
  4247. }
  4248. //if res3507for10188.Infcode
  4249. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4250. //res.Output = resSix10265.Output
  4251. res3.ErrMsg = res3507for10188.ErrMsg
  4252. res3.Cainfo = res3507for10188.Cainfo
  4253. res3.WarnMsg = res3507for10188.WarnMsg
  4254. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4255. res3.Infcode = infocode
  4256. } else {
  4257. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4258. utils.ErrorLog("解析失败:%v", err)
  4259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4260. return
  4261. }
  4262. }
  4263. if res3.Infcode == 0 {
  4264. item.IsChange = 1
  4265. item.BgBchno = bg_number
  4266. service.SaveDF2(item)
  4267. } else {
  4268. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4269. }
  4270. }
  4271. } else {
  4272. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4273. }
  4274. }
  4275. } else { //还没结算
  4276. if item.IsChange == 0 { //没变更,进行变更操作
  4277. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4278. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4279. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4280. var respJSON3 map[string]interface{}
  4281. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4284. return
  4285. }
  4286. userJSONBytes3, _ := json.Marshal(respJSON3)
  4287. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4288. // utils.ErrorLog("解析失败:%v", err)
  4289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4290. // return
  4291. //}
  4292. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4293. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4294. utils.ErrorLog("解析失败:%v", err)
  4295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4296. return
  4297. }
  4298. //if res3507for10188.Infcode
  4299. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4300. //res.Output = resSix10265.Output
  4301. res3.ErrMsg = res3507for10188.ErrMsg
  4302. res3.Cainfo = res3507for10188.Cainfo
  4303. res3.WarnMsg = res3507for10188.WarnMsg
  4304. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4305. res3.Infcode = infocode
  4306. } else {
  4307. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4308. utils.ErrorLog("解析失败:%v", err)
  4309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4310. return
  4311. }
  4312. }
  4313. if res3.Infcode == 0 {
  4314. item.IsChange = 1
  4315. item.BgBchno = bg_number
  4316. service.SaveDF2(item)
  4317. } else {
  4318. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4319. }
  4320. }
  4321. }
  4322. }
  4323. }
  4324. if len(err) == 0 {
  4325. c.ServeSuccessJSON(map[string]interface{}{
  4326. "msg": "销售变更成功",
  4327. })
  4328. } else {
  4329. c.ServeSuccessJSON(map[string]interface{}{
  4330. "failed_code": -10,
  4331. "msg": err,
  4332. })
  4333. }
  4334. }
  4335. func (c *HisApiController) ChangeDrugTen() {
  4336. start_time_str := c.GetString("start_time")
  4337. end_time_str := c.GetString("end_time")
  4338. //ids := c.GetString("ids")
  4339. //id_arr := strings.Split(ids, ",")
  4340. timeLayout := "2006-01-02"
  4341. loc, _ := time.LoadLocation("Local")
  4342. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4343. recordStartTime := theStartTime.Unix()
  4344. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4345. recordEndTime := theEndTime.Unix()
  4346. //timestamp := int64(1729612800)
  4347. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime,recordEndTime,c.GetAdminUserInfo().CurrentOrgId)
  4348. admin_user_id, _ := c.GetInt64("admin_user_id")
  4349. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4350. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4351. var err []string
  4352. for _, item := range flows {
  4353. var res3 ResultSix
  4354. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4355. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4356. continue
  4357. }
  4358. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4359. continue
  4360. }
  4361. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4362. if prescription.OrderStatus == 2 {
  4363. //已经结算
  4364. //判断 是否已经销售
  4365. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4366. ////是否已经变更 1是 0否
  4367. //if item.IsChange == 0 { //没变更,进行变更操作
  4368. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4369. //
  4370. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4371. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4372. // var respJSON3 map[string]interface{}
  4373. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4374. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4376. // return
  4377. // }
  4378. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4379. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4380. // utils.ErrorLog("解析失败:%v", err)
  4381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4382. // return
  4383. // }
  4384. // if res3.Infcode == 0 {
  4385. // item.IsChange = 1
  4386. // item.BgBchno = bg_number
  4387. // service.SaveDF2(item)
  4388. // } else {
  4389. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4390. // }
  4391. //}
  4392. //} else
  4393. if item.IsSale == 0{ //没销售,
  4394. var res FJ3507Result
  4395. var res3507for10188 FJ3507ResultFor10188
  4396. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4397. //进行商品销售接口
  4398. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4399. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4400. var respJSON3 map[string]interface{}
  4401. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. return
  4405. }
  4406. userJSONBytes3, _ := json.Marshal(respJSON3)
  4407. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4408. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4409. utils.ErrorLog("解析失败:%v", err)
  4410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4411. return
  4412. }
  4413. //if res3507for10188.Infcode
  4414. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4415. //res.Output = resSix10265.Output
  4416. res.ErrMsg = res3507for10188.ErrMsg
  4417. res.Cainfo = res3507for10188.Cainfo
  4418. res.WarnMsg = res3507for10188.WarnMsg
  4419. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4420. res.Infcode = infocode
  4421. } else {
  4422. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4423. utils.ErrorLog("解析失败:%v", err)
  4424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4425. return
  4426. }
  4427. }
  4428. if res.Infcode == 0 {
  4429. item.IsSale = 1
  4430. item.Bchno = number
  4431. item.SaleDate = time.Now().Format("2006-01-02")
  4432. err5 := service.SaveDF(item)
  4433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4434. //if err5 == nil {
  4435. //
  4436. // if item.IsChange == 1 { //没变更,进行变更操作
  4437. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4438. //
  4439. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4440. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4441. //
  4442. // var respJSON3 map[string]interface{}
  4443. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4444. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4446. // return
  4447. // }
  4448. //
  4449. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4450. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4451. // utils.ErrorLog("解析失败:%v", err)
  4452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4453. // return
  4454. // }
  4455. // //if res3507for10188.Infcode
  4456. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4457. // //res.Output = resSix10265.Output
  4458. // res3.ErrMsg = res3507for10188.ErrMsg
  4459. // res3.Cainfo = res3507for10188.Cainfo
  4460. // res3.WarnMsg = res3507for10188.WarnMsg
  4461. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4462. // res3.Infcode = infocode
  4463. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4464. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4465. // utils.ErrorLog("解析失败:%v", err)
  4466. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4467. // return
  4468. // }
  4469. // //if res3507for10188.Infcode
  4470. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4471. // //res.Output = resSix10265.Output
  4472. // res3.ErrMsg = res3507for10188.ErrMsg
  4473. // res3.Cainfo = res3507for10188.Cainfo
  4474. // res3.WarnMsg = res3507for10188.WarnMsg
  4475. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4476. // res3.Infcode = infocode
  4477. //
  4478. // } else {
  4479. //
  4480. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4481. // utils.ErrorLog("解析失败:%v", err)
  4482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4483. // return
  4484. // }
  4485. //
  4486. // }
  4487. //
  4488. // if res3.Infcode == 0 {
  4489. // item.IsChange = 1
  4490. // item.BgBchno = bg_number
  4491. // service.SaveDF2(item)
  4492. // return
  4493. // } else {
  4494. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4495. // }
  4496. // }
  4497. //}
  4498. } else {
  4499. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4500. }
  4501. }
  4502. }
  4503. } else if item.ConsumableType == 7 {
  4504. var res3507for10188 FJ3507ResultFor10188
  4505. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4506. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4507. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4508. //判断是否已经销售
  4509. if item.IsSale == 2 { //是否已经销售,1是 0否
  4510. //是否已经变更 1是 0否
  4511. if item.IsChange == 0 { //没变更,进行变更操作
  4512. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4513. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4514. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4515. var respJSON3 map[string]interface{}
  4516. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4519. return
  4520. }
  4521. userJSONBytes3, _ := json.Marshal(respJSON3)
  4522. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4523. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4524. utils.ErrorLog("解析失败:%v", err)
  4525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4526. return
  4527. }
  4528. //if res3507for10188.Infcode
  4529. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4530. //res.Output = resSix10265.Output
  4531. res3.ErrMsg = res3507for10188.ErrMsg
  4532. res3.Cainfo = res3507for10188.Cainfo
  4533. res3.WarnMsg = res3507for10188.WarnMsg
  4534. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4535. res3.Infcode = infocode
  4536. } else {
  4537. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4538. utils.ErrorLog("解析失败:%v", err)
  4539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4540. return
  4541. }
  4542. }
  4543. if res3.Infcode == 0 {
  4544. item.IsChange = 1
  4545. item.BgBchno = bg_number
  4546. service.SaveDF2(item)
  4547. } else {
  4548. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4549. }
  4550. }
  4551. } else { //没销售,
  4552. //进行商品销售退货接口
  4553. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4554. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4555. saveLog(result111, result222, "3506", "销售退货")
  4556. var res7 FJ3507Result
  4557. //进行商品销售接口
  4558. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4559. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4560. var respJSON3 map[string]interface{}
  4561. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4564. return
  4565. }
  4566. userJSONBytes3, _ := json.Marshal(respJSON3)
  4567. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4568. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4569. utils.ErrorLog("解析失败:%v", err)
  4570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. return
  4572. }
  4573. //if res3507for10188.Infcode
  4574. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4575. //res.Output = resSix10265.Output
  4576. res7.ErrMsg = res3507for10188.ErrMsg
  4577. res7.Cainfo = res3507for10188.Cainfo
  4578. res7.WarnMsg = res3507for10188.WarnMsg
  4579. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4580. res7.Infcode = infocode
  4581. } else {
  4582. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4583. utils.ErrorLog("解析失败:%v", err)
  4584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4585. return
  4586. }
  4587. }
  4588. if res7.Infcode == 0 {
  4589. item.IsSale = 2
  4590. item.SaleDate = item.SaleDate
  4591. item.Bchno = number
  4592. service.SaveDF(item)
  4593. if item.IsChange == 0 { //没变更,进行变更操作
  4594. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4595. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4596. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4597. var respJSON3 map[string]interface{}
  4598. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4601. return
  4602. }
  4603. userJSONBytes3, _ := json.Marshal(respJSON3)
  4604. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4605. // utils.ErrorLog("解析失败:%v", err)
  4606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4607. // return
  4608. //}
  4609. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4610. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4611. utils.ErrorLog("解析失败:%v", err)
  4612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4613. return
  4614. }
  4615. //if res3507for10188.Infcode
  4616. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4617. //res.Output = resSix10265.Output
  4618. res3.ErrMsg = res3507for10188.ErrMsg
  4619. res3.Cainfo = res3507for10188.Cainfo
  4620. res3.WarnMsg = res3507for10188.WarnMsg
  4621. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4622. res3.Infcode = infocode
  4623. } else {
  4624. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4625. utils.ErrorLog("解析失败:%v", err)
  4626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4627. return
  4628. }
  4629. }
  4630. if res3.Infcode == 0 {
  4631. item.IsChange = 1
  4632. item.BgBchno = bg_number
  4633. service.SaveDF2(item)
  4634. } else {
  4635. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4636. }
  4637. }
  4638. } else {
  4639. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4640. }
  4641. }
  4642. } else { //还没结算
  4643. if item.IsChange == 0 { //没变更,进行变更操作
  4644. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4645. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4646. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4647. var respJSON3 map[string]interface{}
  4648. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4651. return
  4652. }
  4653. userJSONBytes3, _ := json.Marshal(respJSON3)
  4654. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4655. // utils.ErrorLog("解析失败:%v", err)
  4656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4657. // return
  4658. //}
  4659. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4660. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4661. utils.ErrorLog("解析失败:%v", err)
  4662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4663. return
  4664. }
  4665. //if res3507for10188.Infcode
  4666. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4667. //res.Output = resSix10265.Output
  4668. res3.ErrMsg = res3507for10188.ErrMsg
  4669. res3.Cainfo = res3507for10188.Cainfo
  4670. res3.WarnMsg = res3507for10188.WarnMsg
  4671. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4672. res3.Infcode = infocode
  4673. } else {
  4674. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4675. utils.ErrorLog("解析失败:%v", err)
  4676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4677. return
  4678. }
  4679. }
  4680. if res3.Infcode == 0 {
  4681. item.IsChange = 1
  4682. item.BgBchno = bg_number
  4683. service.SaveDF2(item)
  4684. } else {
  4685. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4686. }
  4687. }
  4688. }
  4689. }
  4690. }
  4691. if len(err) == 0 {
  4692. c.ServeSuccessJSON(map[string]interface{}{
  4693. "msg": "销售变更成功",
  4694. })
  4695. } else {
  4696. c.ServeSuccessJSON(map[string]interface{}{
  4697. "failed_code": -10,
  4698. "msg": err,
  4699. })
  4700. }
  4701. }
  4702. func ChangeDrugTenone() {
  4703. //ids := c.GetString("ids")
  4704. //id_arr := strings.Split(ids, ",")
  4705. now := time.Now()
  4706. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4707. //timestamp := int64(1729612800)
  4708. flows, _ := service.GetNewDrugFlowInforTen(timestamp,10188)
  4709. admin_user_id := int64(2463)
  4710. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4711. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4712. var err []string
  4713. for _, item := range flows {
  4714. var res3 ResultSix
  4715. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4716. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4717. continue
  4718. }
  4719. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4720. continue
  4721. }
  4722. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4723. if prescription.OrderStatus == 2 {
  4724. //已经结算
  4725. //判断是否已经销售
  4726. if item.IsSale == 1 { //是否已经销售,1是 0否
  4727. //是否已经变更 1是 0否
  4728. if item.IsChange == 0 { //没变更,进行变更操作
  4729. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4730. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4731. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4732. var respJSON3 map[string]interface{}
  4733. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4735. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4736. return
  4737. }
  4738. userJSONBytes3, _ := json.Marshal(respJSON3)
  4739. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4740. utils.ErrorLog("解析失败:%v", err)
  4741. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4742. return
  4743. }
  4744. if res3.Infcode == 0 {
  4745. item.IsChange = 1
  4746. item.BgBchno = bg_number
  4747. service.SaveDF2(item)
  4748. } else {
  4749. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4750. }
  4751. }
  4752. } else { //没销售,
  4753. var res FJ3507Result
  4754. var res3507for10188 FJ3507ResultFor10188
  4755. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4756. //进行商品销售接口
  4757. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4758. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4759. var respJSON3 map[string]interface{}
  4760. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4762. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4763. return
  4764. }
  4765. userJSONBytes3, _ := json.Marshal(respJSON3)
  4766. {
  4767. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4768. utils.ErrorLog("解析失败:%v", err)
  4769. return
  4770. }
  4771. //if res3507for10188.Infcode
  4772. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4773. //res.Output = resSix10265.Output
  4774. res.ErrMsg = res3507for10188.ErrMsg
  4775. res.Cainfo = res3507for10188.Cainfo
  4776. res.WarnMsg = res3507for10188.WarnMsg
  4777. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4778. res.Infcode = infocode
  4779. }
  4780. if res.Infcode == 0 {
  4781. item.IsSale = 1
  4782. item.Bchno = number
  4783. item.SaleDate = time.Now().Format("2006-01-02")
  4784. err5 := service.SaveDF(item)
  4785. if err5 == nil {
  4786. if item.IsChange == 1 { //没变更,进行变更操作
  4787. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4788. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4789. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4790. var respJSON3 map[string]interface{}
  4791. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4793. return
  4794. }
  4795. {
  4796. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4797. utils.ErrorLog("解析失败:%v", err)
  4798. return
  4799. }
  4800. //if res3507for10188.Infcode
  4801. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4802. //res.Output = resSix10265.Output
  4803. res3.ErrMsg = res3507for10188.ErrMsg
  4804. res3.Cainfo = res3507for10188.Cainfo
  4805. res3.WarnMsg = res3507for10188.WarnMsg
  4806. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4807. res3.Infcode = infocode
  4808. }
  4809. if res3.Infcode == 0 {
  4810. item.IsChange = 1
  4811. item.BgBchno = bg_number
  4812. service.SaveDF2(item)
  4813. } else {
  4814. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4815. }
  4816. }
  4817. }
  4818. } else {
  4819. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4820. }
  4821. }
  4822. }
  4823. }
  4824. }
  4825. }
  4826. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4827. var struct3502 models.Struct3502
  4828. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4829. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4830. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4831. struct3502.FixmedinsCode = miConfig.Code
  4832. struct3502.Code = miConfig.Code
  4833. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4834. struct3502.Opter = role.UserName
  4835. struct3502.RxFlag = "1"
  4836. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4837. struct3502.OrgName = miConfig.OrgName
  4838. struct3502.AccessKey = miConfig.AccessKey
  4839. struct3502.RequestUrl = miConfig.Url
  4840. struct3502.SecretKey = miConfig.SecretKey
  4841. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4842. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4843. struct3502.Url = miConfig.Url
  4844. struct3502.AppId = miConfig.Cainfo
  4845. struct3502.AppSecret = miConfig.AppSecret
  4846. struct3502.Enckey = miConfig.EncKey
  4847. struct3502.SignKey = miConfig.SignKey
  4848. struct3502.SecretKey = miConfig.SecretKey
  4849. struct3502.InvChgType = chgType
  4850. struct3502.FixmedinsBchno = number
  4851. struct3502.Cnt = strconv.FormatInt(count, 10)
  4852. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4853. //result1, result2, _ := service.FJyb3502(struct3502)
  4854. if miConfig.MdtrtareaAdmvs == "350500" {
  4855. result1, result2, _ := service.FJyb3502(struct3502)
  4856. //saveLog(result1, result2, "3502", "3502")
  4857. return result1, result2
  4858. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4859. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4860. return result1, result2
  4861. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4862. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4863. return result1, result2
  4864. } else {
  4865. data := make(map[string]interface{})
  4866. data["struct_3502s"] = struct3502
  4867. client := &http.Client{}
  4868. bytesData, _ := json.Marshal(data)
  4869. var req *http.Request
  4870. if miConfig.MdtrtareaAdmvs == "320921" {
  4871. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4872. } else {
  4873. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4874. }
  4875. resp, _ := client.Do(req)
  4876. defer resp.Body.Close()
  4877. body, ioErr := ioutil.ReadAll(resp.Body)
  4878. if ioErr != nil {
  4879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4880. }
  4881. var respJSON map[string]interface{}
  4882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4884. }
  4885. //var resSix10265 ResultSix10265 //1101结果
  4886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4887. result, _ := json.Marshal(respJSON)
  4888. return string(result), ""
  4889. }
  4890. }
  4891. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4892. var struct3505 models.Struct3505
  4893. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4894. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4895. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4896. struct3505.FixmedinsBchno = number
  4897. struct3505.Opter = role.UserName
  4898. struct3505.Bchno = "---"
  4899. struct3505.FixmedinsCode = miConfig.Code
  4900. struct3505.Code = miConfig.Code
  4901. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  4902. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  4903. struct3505.PrscDrName = roles.UserName
  4904. if org_id == 10191 {
  4905. struct3505.PharName = "刘水山"
  4906. struct3505.PharPracCertNo = "2015026350260000002611351127"
  4907. }
  4908. if org_id == 10188 {
  4909. struct3505.PharName = "李汉清"
  4910. struct3505.PharPracCertNo = "30220200932022010034"
  4911. }
  4912. if org_id == 10217 {
  4913. struct3505.PharName = "张敏"
  4914. struct3505.PharPracCertNo = "30220230432090100108"
  4915. }
  4916. if org_id == 10318 {
  4917. struct3505.PharName = "邹刘阳"
  4918. struct3505.PharPracCertNo = "210441200001378"
  4919. }
  4920. if org_id == 10402 {
  4921. struct3505.PharName = "刘韶健"
  4922. struct3505.PharPracCertNo = "2015026440262015440501001198"
  4923. }
  4924. if org_id == 9919 {
  4925. struct3505.PharName = "周君权"
  4926. struct3505.PharPracCertNo = "089644396094401375"
  4927. }
  4928. if org_id == 10644 {
  4929. struct3505.PharName = "陈金娣"
  4930. struct3505.PharPracCertNo = "20181441500320100066"
  4931. }
  4932. if org_id == 10567 {
  4933. struct3505.PharName = "范小兰"
  4934. struct3505.PharPracCertNo = "0200102079485"
  4935. }
  4936. if org_id == 10721 {
  4937. struct3505.PharName = "孙莉侠"
  4938. struct3505.PharPracCertNo = "060399"
  4939. }
  4940. if org_id == 10726 {
  4941. struct3505.PharName = "彭建福"
  4942. struct3505.PharPracCertNo = "D445281006261"
  4943. }
  4944. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4945. struct3505.SetlId = order.SetlId
  4946. struct3505.MdtrtSn = order.MdtrtId
  4947. struct3505.ManuLotnum = drug.Number
  4948. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4949. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  4950. struct3505.RxFlag = "1"
  4951. struct3505.TrdnFlag = "0"
  4952. struct3505.RtalDocno = order.Number
  4953. struct3505.PsnCertType = "01"
  4954. struct3505.CertNo = order.Certno
  4955. struct3505.PsnNo = order.PsnNo
  4956. struct3505.PsnName = order.PsnName
  4957. struct3505.Url = miConfig.Url
  4958. struct3505.AppId = miConfig.Cainfo
  4959. struct3505.AppSecret = miConfig.AppSecret
  4960. struct3505.Enckey = miConfig.EncKey
  4961. struct3505.SignKey = miConfig.SignKey
  4962. struct3505.SecretKey = miConfig.SecretKey
  4963. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4964. struct3505.SelRetnCnt = strValue
  4965. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4966. struct3505.SelRetnOpterName = role.UserName
  4967. if order.IsMedicineInsurance == 1 {
  4968. struct3505.MdtrtSetlType = "1"
  4969. } else {
  4970. struct3505.MdtrtSetlType = "2"
  4971. }
  4972. struct3505.OrgName = miConfig.OrgName
  4973. struct3505.AccessKey = miConfig.AccessKey
  4974. struct3505.RequestUrl = miConfig.Url
  4975. struct3505.SecretKey = miConfig.SecretKey
  4976. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4977. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4978. struct3505.Cainfo = miConfig.Cainfo
  4979. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4980. if miConfig.MdtrtareaAdmvs == "350500" {
  4981. result1, result2, _ := service.FJyb3505(struct3505)
  4982. return result1, result2
  4983. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4984. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  4985. return result1, result2
  4986. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4987. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  4988. return result1, result2
  4989. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  4990. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey,struct3505.AccessKey,struct3505.RequestUrl)
  4991. return result1, result2
  4992. }else if miConfig.MdtrtareaAdmvs == "340699" {
  4993. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey,struct3505.RequestUrl)
  4994. return result1, result2
  4995. } else {
  4996. data := make(map[string]interface{})
  4997. data["struct_3505s"] = struct3505
  4998. client := &http.Client{}
  4999. bytesData, _ := json.Marshal(data)
  5000. var req *http.Request
  5001. if miConfig.MdtrtareaAdmvs == "320921" {
  5002. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5003. } else {
  5004. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5005. }
  5006. resp, _ := client.Do(req)
  5007. defer resp.Body.Close()
  5008. body, ioErr := ioutil.ReadAll(resp.Body)
  5009. if ioErr != nil {
  5010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5011. }
  5012. var respJSON map[string]interface{}
  5013. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5015. }
  5016. //var resSix10265 ResultSix10265 //1101结果
  5017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5018. result, _ := json.Marshal(respJSON)
  5019. return string(result), ""
  5020. }
  5021. }
  5022. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5023. var struct3505 models.Struct3505
  5024. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5025. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5026. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5027. struct3505.FixmedinsBchno = number
  5028. struct3505.Opter = role.UserName
  5029. struct3505.FixmedinsCode = miConfig.Code
  5030. struct3505.Code = miConfig.Code
  5031. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5032. struct3505.PrscDrName = roles.UserName
  5033. if org_id == 10191 {
  5034. struct3505.PharName = "刘水山"
  5035. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5036. }
  5037. if org_id == 10188 {
  5038. struct3505.PharName = "李汉清"
  5039. struct3505.PharPracCertNo = "30220200932022010034"
  5040. }
  5041. if org_id == 10217 {
  5042. struct3505.PharName = "张敏"
  5043. struct3505.PharPracCertNo = "30220230432090100108"
  5044. }
  5045. if org_id == 10318 {
  5046. struct3505.PharName = "邹刘阳"
  5047. struct3505.PharPracCertNo = "210441200001378"
  5048. }
  5049. if org_id == 10402 {
  5050. struct3505.PharName = "刘韶健"
  5051. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5052. }
  5053. if org_id == 9919 {
  5054. struct3505.PharName = "周君权"
  5055. struct3505.PharPracCertNo = "089644396094401375"
  5056. }
  5057. if org_id == 10644 {
  5058. struct3505.PharName = "陈金娣"
  5059. struct3505.PharPracCertNo = "20181441500320100066"
  5060. }
  5061. if org_id == 10567 {
  5062. struct3505.PharName = "范小兰"
  5063. struct3505.PharPracCertNo = "0200102079485"
  5064. }
  5065. if org_id == 10721 {
  5066. struct3505.PharName = "孙莉侠"
  5067. struct3505.PharPracCertNo = "060399"
  5068. }
  5069. if org_id == 10726 {
  5070. struct3505.PharName = "彭建福"
  5071. struct3505.PharPracCertNo = "D445281006261"
  5072. }
  5073. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5074. struct3505.SetlId = order.SetlId
  5075. struct3505.MdtrtSn = order.MdtrtId
  5076. struct3505.ManuLotnum = drug.Number
  5077. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5078. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5079. struct3505.RxFlag = "1"
  5080. struct3505.TrdnFlag = "0"
  5081. struct3505.RtalDocno = order.Number
  5082. struct3505.PsnCertType = "01"
  5083. struct3505.CertNo = order.Certno
  5084. struct3505.PsnNo = order.PsnNo
  5085. struct3505.PsnName = order.PsnName
  5086. struct3505.Url = miConfig.Url
  5087. struct3505.AppId = miConfig.Cainfo
  5088. struct3505.AppSecret = miConfig.AppSecret
  5089. struct3505.Enckey = miConfig.EncKey
  5090. struct3505.SignKey = miConfig.SignKey
  5091. struct3505.SecretKey = miConfig.SecretKey
  5092. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5093. struct3505.SelRetnCnt = strValue
  5094. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5095. struct3505.SelRetnOpterName = role.UserName
  5096. if order.IsMedicineInsurance == 1 {
  5097. struct3505.MdtrtSetlType = "1"
  5098. } else {
  5099. struct3505.MdtrtSetlType = "2"
  5100. }
  5101. struct3505.OrgName = miConfig.OrgName
  5102. struct3505.AccessKey = miConfig.AccessKey
  5103. struct3505.RequestUrl = miConfig.Url
  5104. struct3505.SecretKey = miConfig.SecretKey
  5105. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5106. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5107. struct3505.Cainfo = miConfig.Cainfo
  5108. struct3505.DrugTracCodg = drug.DrugCode
  5109. if miConfig.MdtrtareaAdmvs == "350500" {
  5110. result1, result2, _ := service.FJyb3505(struct3505)
  5111. return result1, result2
  5112. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5113. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5114. return result1, result2
  5115. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5116. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5117. return result1, result2
  5118. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5119. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey,struct3505.AccessKey,struct3505.RequestUrl)
  5120. return result1, result2
  5121. }else if miConfig.MdtrtareaAdmvs == "340699" {
  5122. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey,struct3505.RequestUrl)
  5123. return result1, result2
  5124. } else {
  5125. data := make(map[string]interface{})
  5126. data["struct_3505s"] = struct3505
  5127. client := &http.Client{}
  5128. bytesData, _ := json.Marshal(data)
  5129. var req *http.Request
  5130. if miConfig.MdtrtareaAdmvs == "320921" {
  5131. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5132. } else {
  5133. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5134. }
  5135. resp, _ := client.Do(req)
  5136. defer resp.Body.Close()
  5137. body, ioErr := ioutil.ReadAll(resp.Body)
  5138. if ioErr != nil {
  5139. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5140. }
  5141. var respJSON map[string]interface{}
  5142. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5144. }
  5145. //var resSix10265 ResultSix10265 //1101结果
  5146. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5147. result, _ := json.Marshal(respJSON)
  5148. return string(result), ""
  5149. }
  5150. }
  5151. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5152. var struct3506 models.Struct3506
  5153. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5154. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5155. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5156. struct3506.FixmedinsCode = miConfig.Code
  5157. struct3506.Code = miConfig.Code
  5158. struct3506.FixmedinsBchno = number
  5159. struct3506.Opter = role.UserName
  5160. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5161. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5162. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5163. struct3506.MdtrtSn = order.MdtrtId
  5164. struct3506.ExpyEnd = ""
  5165. struct3506.RxFlag = "0"
  5166. struct3506.TrdnFlag = "1"
  5167. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5168. struct3506.SelRetnCnt = strValue
  5169. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5170. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5171. struct3506.SelRetnOpterName = role.UserName
  5172. struct3506.OrgName = miConfig.OrgName
  5173. struct3506.AccessKey = miConfig.AccessKey
  5174. struct3506.RequestUrl = miConfig.Url
  5175. struct3506.SecretKey = miConfig.SecretKey
  5176. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5177. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5178. struct3506.Url = miConfig.Url
  5179. struct3506.AppId = miConfig.Cainfo
  5180. struct3506.AppSecret = miConfig.AppSecret
  5181. struct3506.Enckey = miConfig.EncKey
  5182. struct3506.SignKey = miConfig.SignKey
  5183. struct3506.SecretKey = miConfig.SecretKey
  5184. struct3506.DrugTracCodg = drug.DrugCode
  5185. if miConfig.MdtrtareaAdmvs == "350500" {
  5186. result1, result2, _ := service.FJyb3506(struct3506)
  5187. return result1, result2
  5188. } else {
  5189. data := make(map[string]interface{})
  5190. data["struct_3506s"] = struct3506
  5191. client := &http.Client{}
  5192. bytesData, _ := json.Marshal(data)
  5193. var req *http.Request
  5194. if miConfig.MdtrtareaAdmvs == "320921" {
  5195. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5196. } else {
  5197. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5198. }
  5199. resp, _ := client.Do(req)
  5200. defer resp.Body.Close()
  5201. body, ioErr := ioutil.ReadAll(resp.Body)
  5202. if ioErr != nil {
  5203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5204. }
  5205. var respJSON map[string]interface{}
  5206. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5208. }
  5209. //var resSix10265 ResultSix10265 //1101结果
  5210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5211. result, _ := json.Marshal(respJSON)
  5212. return string(result), ""
  5213. }
  5214. }
  5215. func (c *HisApiController) Get1318() {
  5216. adminUser := c.GetAdminUserInfo()
  5217. admin_user_id, _ := c.GetInt64("admin_user_id")
  5218. code := c.GetString("code")
  5219. code = ""
  5220. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5221. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5222. api := ""
  5223. if miConfig.MdtrtareaAdmvs == "320921" {
  5224. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5225. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5226. } else {
  5227. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5228. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5229. }
  5230. resp, requestErr := http.Get(api)
  5231. if requestErr != nil {
  5232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5233. return
  5234. }
  5235. body, ioErr := ioutil.ReadAll(resp.Body)
  5236. if ioErr != nil {
  5237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5239. return
  5240. }
  5241. var respJSON map[string]interface{}
  5242. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5245. return
  5246. }
  5247. //var res Result2406
  5248. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5249. result, _ := json.Marshal(respJSON)
  5250. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5251. utils.ErrorLog("解析失败:%v", err)
  5252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5253. return
  5254. }
  5255. if res.Infcode == "0" {
  5256. c.ServeSuccessJSON(map[string]interface{}{
  5257. "result": "",
  5258. })
  5259. } else {
  5260. c.ServeSuccessJSON(map[string]interface{}{
  5261. "failed_code": -10,
  5262. "msg": res.ErrMsg,
  5263. })
  5264. */return
  5265. //}
  5266. }
  5267. func (c *HisApiController) Get2503() {
  5268. adminUser := c.GetAdminUserInfo()
  5269. admin_user_id, _ := c.GetInt64("admin_user_id")
  5270. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5271. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5272. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5273. }
  5274. func (c *HisApiController) Get2406() {
  5275. id, _ := c.GetInt64("id")
  5276. record_time := c.GetString("record_time")
  5277. his_patient_id, _ := c.GetInt64("his_patient_id")
  5278. admin_user_id, _ := c.GetInt64("admin_user_id")
  5279. diagnosis_id := c.GetString("diagnosis")
  5280. timeLayout := "2006-01-02"
  5281. loc, _ := time.LoadLocation("Local")
  5282. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5283. if err != nil {
  5284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5285. return
  5286. }
  5287. recordDateTime := theTime.Unix()
  5288. adminUser := c.GetAdminUserInfo()
  5289. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5290. var config []*models.HisXtDiagnoseConfig
  5291. for _, item := range diagnosis_ids {
  5292. id, _ := strconv.ParseInt(item, 10, 64)
  5293. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5294. config = append(config, &diagnosisConfig)
  5295. }
  5296. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5297. fmt.Println(his_patient_id)
  5298. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5299. //timestamp := time.Now().Unix()
  5300. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5301. var patientPrescription models.HisPrescriptionInfo
  5302. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5303. if patientPrescription.ID == 0 {
  5304. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5305. }
  5306. var res2 Result2406
  5307. if miConfig.MdtrtareaAdmvs == "341203" {
  5308. data := make(map[string]interface{})
  5309. client := &http.Client{}
  5310. data["psn_no"] = his.PsnNo
  5311. data["mdtrt_id"] = his.Number
  5312. data["operator"] = roles.UserName
  5313. data["cert_no"] = his.IdCardNo
  5314. data["org_name"] = miConfig.OrgName
  5315. data["psn_name"] = his.Name
  5316. data["ipt_otp_no"] = his.IptOtpNo
  5317. data["ipt_psn_sp_flag_type"] = "0901"
  5318. data["ipt_psn_sp_flag"] = "1"
  5319. data["fixmedins_code"] = miConfig.Code
  5320. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5321. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5322. data["url"] = miConfig.Url
  5323. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5324. bytesData, _ := json.Marshal(data)
  5325. var req *http.Request
  5326. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5327. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5328. resp, _ := client.Do(req)
  5329. defer resp.Body.Close()
  5330. body, ioErr := ioutil.ReadAll(resp.Body)
  5331. if ioErr != nil {
  5332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5334. return
  5335. }
  5336. var respJSON map[string]interface{}
  5337. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5340. return
  5341. }
  5342. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5343. if status == "0" {
  5344. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5345. c.ServeSuccessJSON(map[string]interface{}{
  5346. "failed_code": -10,
  5347. "msg": err_msg,
  5348. })
  5349. return
  5350. }
  5351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5352. userJSONBytes, _ := json.Marshal(respJSON)
  5353. fmt.Println("log")
  5354. fmt.Println(string(userJSONBytes))
  5355. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5356. utils.ErrorLog("解析失败:%v", err)
  5357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5358. return
  5359. }
  5360. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5361. data := make(map[string]interface{})
  5362. client := &http.Client{}
  5363. data["psn_no"] = his.PsnNo
  5364. data["mdtrt_id"] = his.Number
  5365. data["operator"] = roles.UserName
  5366. data["cert_no"] = his.IdCardNo
  5367. data["org_name"] = miConfig.OrgName
  5368. data["psn_name"] = his.Name
  5369. data["ipt_otp_no"] = his.IptOtpNo
  5370. data["ipt_psn_sp_flag_type"] = "0901"
  5371. data["ipt_psn_sp_flag"] = "1"
  5372. data["fixmedins_code"] = miConfig.Code
  5373. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5374. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5375. data["url"] = miConfig.Url
  5376. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5377. bytesData, _ := json.Marshal(data)
  5378. var req *http.Request
  5379. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5380. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5381. resp, _ := client.Do(req)
  5382. defer resp.Body.Close()
  5383. body, ioErr := ioutil.ReadAll(resp.Body)
  5384. if ioErr != nil {
  5385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5387. return
  5388. }
  5389. var respJSON map[string]interface{}
  5390. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5393. return
  5394. }
  5395. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5396. if status == "0" {
  5397. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5398. c.ServeSuccessJSON(map[string]interface{}{
  5399. "failed_code": -10,
  5400. "msg": err_msg,
  5401. })
  5402. return
  5403. }
  5404. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5405. userJSONBytes, _ := json.Marshal(respJSON)
  5406. fmt.Println("log")
  5407. fmt.Println(string(userJSONBytes))
  5408. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5409. utils.ErrorLog("解析失败:%v", err)
  5410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5411. return
  5412. }
  5413. }
  5414. if res2.Infcode != 0 {
  5415. adminUser := c.GetAdminUserInfo()
  5416. errlog := &models.HisOrderError{
  5417. UserOrgId: adminUser.CurrentOrgId,
  5418. Ctime: time.Now().Unix(),
  5419. Mtime: time.Now().Unix(),
  5420. ErrMsg: res2.ErrMsg,
  5421. Status: 1,
  5422. PatientId: id,
  5423. RecordTime: recordDateTime,
  5424. Stage: 3,
  5425. }
  5426. service.CreateErrMsgLog(errlog)
  5427. c.ServeSuccessJSON(map[string]interface{}{
  5428. "failed_code": -10,
  5429. "msg": res2.ErrMsg,
  5430. })
  5431. return
  5432. } else {
  5433. c.ServeSuccessJSON(map[string]interface{}{
  5434. "msg": "上传成功",
  5435. })
  5436. return
  5437. }
  5438. }
  5439. func (c *HisApiController) Get4105() {
  5440. }
  5441. func (c *HisApiController) Post5302() {
  5442. patient_id, _ := c.GetInt64("id")
  5443. admin_user_id, _ := c.GetInt64("admin_user_id")
  5444. p, _ := service.GetHisPatientById(patient_id)
  5445. adminUser := c.GetAdminUserInfo()
  5446. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5447. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5448. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5449. }
  5450. func (c *HisApiController) Get4104() {
  5451. }
  5452. type Output struct {
  5453. CertNo string `json:"certno"`
  5454. PsnName string `json:"psn_name"`
  5455. CardNo string `json:"card_no"`
  5456. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5457. CardSN string `json:"card_sn"`
  5458. PsnCertType string `json:"psn_cert_type"`
  5459. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5460. MdtrtCertType string `json:"mdtrt_cert_type"`
  5461. QRCode string `json:"qrCode"`
  5462. EcToken string `json:"ecToken"`
  5463. }
  5464. type AHResponse struct {
  5465. Body AHBody `json:"body"`
  5466. Code int `json:"code"`
  5467. CSBCode int `json:"csbCode"`
  5468. Message string `json:"message"`
  5469. RequestID string `json:"requestId"`
  5470. State struct{} `json:"state"`
  5471. }
  5472. type AHBody struct {
  5473. ErrMsg string `json:"err_msg"`
  5474. InfRefMsgID string `json:"inf_refmsgid"`
  5475. InfCode int `json:"infcode"`
  5476. Output struct {
  5477. Result []struct {
  5478. BasMednFlag string `json:"bas_medn_flag"`
  5479. ChldMedcFlag string `json:"chld_medc_flag"`
  5480. ChrgitmLv string `json:"chrgitm_lv"`
  5481. Cnt float64 `json:"cnt"`
  5482. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5483. DrtReimFlag string `json:"drt_reim_flag"`
  5484. FeedetlSn string `json:"feedetl_sn"`
  5485. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5486. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5487. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5488. ListSpItemFlag string `json:"list_sp_item_flag"`
  5489. LmtUsedFlag string `json:"lmt_used_flag"`
  5490. MedChrgitmType string `json:"med_chrgitm_type"`
  5491. Memo string `json:"memo"`
  5492. OverlmtAmt float64 `json:"overlmt_amt"`
  5493. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5494. Pric float64 `json:"pric"`
  5495. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5496. SelfpayProp float64 `json:"selfpay_prop"`
  5497. } `json:"result"`
  5498. } `json:"output"`
  5499. }
  5500. type Response struct {
  5501. Output Output `json:"output"`
  5502. Infcode int `json:"infcode"`
  5503. InfRefMsgID string `json:"inf_refmsgid"`
  5504. RefMsgTime string `json:"refmsg_time"`
  5505. RespondTime string `json:"respond_time"`
  5506. ErrMsg string `json:"err_msg"`
  5507. WarnMsg string `json:"warn_msg"`
  5508. SignType string `json:"signtype"`
  5509. CAInfo string `json:"cainfo"`
  5510. }
  5511. func (c *HisApiController) Getquerydata() {
  5512. query_type, _ := c.GetInt64("type")
  5513. refd_setl_flag := c.GetString("refd_setl_flag")
  5514. med_type := c.GetString("med_type")
  5515. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5516. cert_no := c.GetString("cert_no")
  5517. psn_no := c.GetString("psn_no")
  5518. start_time := c.GetString("start_time")
  5519. end_time := c.GetString("end_time")
  5520. page, _ := c.GetInt64("page")
  5521. limit, _ := c.GetInt64("limit")
  5522. var bp models.BusinessParams5262
  5523. bp.RefdSetlFlag = refd_setl_flag
  5524. bp.MedType = med_type
  5525. bp.Certno = cert_no
  5526. bp.Psnno = psn_no
  5527. bp.QBegntime = start_time
  5528. bp.QEndtime = end_time
  5529. if query_type == 1 { //本地
  5530. Post5262(c, bp, page, limit)
  5531. } else { //异地
  5532. Post5267(c, bp, page, limit)
  5533. }
  5534. }
  5535. func (c *HisApiController) Drugscheck() {
  5536. admin_user_id, _ := c.GetInt64("admin_user_id")
  5537. adminUser := c.GetAdminUserInfo()
  5538. var queryResult []QueryResult
  5539. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5540. for _, item := range drugs {
  5541. result := QueryResult{
  5542. ID: item.ID,
  5543. Name: item.DrugName,
  5544. Code: item.MedicalInsuranceNumber,
  5545. List_type_code: "101",
  5546. }
  5547. queryResult = append(queryResult, result)
  5548. }
  5549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5550. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5551. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5552. for _, item := range queryResult {
  5553. 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)
  5554. }
  5555. }
  5556. func (c *HisApiController) Goodcheck() {
  5557. admin_user_id, _ := c.GetInt64("admin_user_id")
  5558. adminUser := c.GetAdminUserInfo()
  5559. var queryResult []QueryResult
  5560. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5561. for _, item := range goods {
  5562. result := QueryResult{
  5563. ID: item.ID,
  5564. Name: item.GoodName,
  5565. Code: item.SocialSecurityDirectoryCode,
  5566. List_type_code: "301",
  5567. }
  5568. queryResult = append(queryResult, result)
  5569. }
  5570. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5571. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5572. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5573. for _, item := range queryResult {
  5574. 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)
  5575. //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)
  5576. }
  5577. }
  5578. func (c *HisApiController) Projectcheck() {
  5579. admin_user_id, _ := c.GetInt64("admin_user_id")
  5580. adminUser := c.GetAdminUserInfo()
  5581. var queryResult []QueryResult
  5582. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5583. for _, item := range projects {
  5584. result := QueryResult{
  5585. ID: item.ID,
  5586. Name: item.ProjectName,
  5587. Code: item.MedicalCode,
  5588. List_type_code: "201",
  5589. }
  5590. queryResult = append(queryResult, result)
  5591. }
  5592. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5593. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5594. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5595. for _, item := range queryResult {
  5596. 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)
  5597. }
  5598. }
  5599. //func (c *HisApiController)CancleDia(){
  5600. //
  5601. // id, _ := c.GetInt64("id")
  5602. // record_time := c.GetString("record_time")
  5603. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5604. //
  5605. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5606. //
  5607. // diagnosis_id := c.GetString("diagnosis")
  5608. // sick_type, _ := c.GetInt64("sick_type")
  5609. // reg_type, _ := c.GetInt64("p_type")
  5610. // begin_time := c.GetString("begin_time")
  5611. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5612. //
  5613. //
  5614. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5615. //
  5616. // fmt.Println(acct_used_flag)
  5617. //
  5618. //
  5619. // timeLayout := "2006-01-02"
  5620. // loc, _ := time.LoadLocation("Local")
  5621. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5622. // if err != nil {
  5623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5624. // return
  5625. // }
  5626. // recordDateTime := theTime.Unix()
  5627. // adminUser := c.GetAdminUserInfo()
  5628. //
  5629. //
  5630. //
  5631. //
  5632. //
  5633. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5634. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5635. // var patientPrescription models.HisPrescriptionInfo
  5636. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5637. // if patientPrescription.ID == 0 {
  5638. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5639. // }
  5640. // //if patientPrescription.Do
  5641. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5642. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5643. //
  5644. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5645. //
  5646. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5647. //
  5648. // var config []*models.HisXtDiagnoseConfig
  5649. // for _, item := range diagnosis_ids {
  5650. // id, _ := strconv.ParseInt(item, 10, 64)
  5651. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5652. // config = append(config, &diagnosisConfig)
  5653. // }
  5654. //
  5655. // sickConfig, _ := service.FindSickById(sick_type)
  5656. //
  5657. //
  5658. // data := make(map[string]interface{})
  5659. // client := &http.Client{}
  5660. // data["psn_no"] = his.PsnNo
  5661. // data["mdtrt_id"] = his.Number
  5662. // data["doctor"] = roles.UserName
  5663. // data["department"] = department.Name
  5664. // data["org_name"] = miConfig.OrgName
  5665. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5666. // data["doctor_id"] = doctor_info.DoctorNumber
  5667. // data["new_doctor_name"] = doctor_info.UserName
  5668. // data["fixmedins_code"] = miConfig.Code
  5669. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5670. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5671. // data["secret_key"] = miConfig.SecretKey
  5672. // data["sick_code"] = sickConfig.CountryCode
  5673. // data["sick_name"] = sickConfig.ClassName
  5674. // data["url"] = miConfig.Url
  5675. // data["ak"] = miConfig.AccessKey
  5676. // data["begin_time"] = begin_time
  5677. // data["cainfo"] = miConfig.Cainfo
  5678. // data["is_vaild"] = "0"
  5679. //
  5680. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5681. // data["config"] = config
  5682. // bytesData, _ := json.Marshal(data)
  5683. //
  5684. // var req *http.Request
  5685. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5686. // resp, _ := client.Do(req)
  5687. // defer resp.Body.Close()
  5688. // body, ioErr := ioutil.ReadAll(resp.Body)
  5689. // if ioErr != nil {
  5690. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5692. // return
  5693. // }
  5694. // var respJSON map[string]interface{}
  5695. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5696. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5698. // return
  5699. // }
  5700. //
  5701. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5702. // userJSONBytes, _ := json.Marshal(respJSON)
  5703. // fmt.Println("log")
  5704. // fmt.Println(string(userJSONBytes))
  5705. //
  5706. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5707. // utils.ErrorLog("解析失败:%v", err)
  5708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5709. // return
  5710. // }
  5711. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5712. // res2.Output = ressix10265.Output
  5713. // res2.ErrMsg = ressix10265.ErrMsg
  5714. // res2.Cainfo = ressix10265.Cainfo
  5715. // res2.WarnMsg = ressix10265.WarnMsg
  5716. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5717. // res2.Infcode = infocode
  5718. //
  5719. //}
  5720. func (c *HisApiController) Get4102() {
  5721. order_id, _ := c.GetInt64("order_id")
  5722. admin_user_id, _ := c.GetInt64("admin_user_id")
  5723. stas_type := c.GetString("stas_type")
  5724. order, _ := service.GetHisOrderByIDTwo(order_id)
  5725. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5726. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5727. var pp models.PublicParams
  5728. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5729. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5730. pp.FixmedinsName = miConfig.OrgName
  5731. pp.FixmedinsCode = miConfig.Code
  5732. pp.RequestUrl = miConfig.Url
  5733. pp.Cainfo = miConfig.Cainfo
  5734. pp.SecretKey = miConfig.SecretKey
  5735. pp.AccessKey = miConfig.AccessKey
  5736. pp.OpterName = curRoles.UserName
  5737. if miConfig.MdtrtareaAdmvs == "350500" {
  5738. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5739. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5740. saveLog(result, request, "4102", "清单确认")
  5741. var dat map[string]interface{}
  5742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5743. fmt.Println(dat)
  5744. } else {
  5745. fmt.Println(err)
  5746. }
  5747. var empty ResultFourteen
  5748. userJSONBytes, _ := json.Marshal(dat)
  5749. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5750. utils.ErrorLog("解析失败:%v", err)
  5751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5752. return
  5753. }
  5754. if empty.Infcode == 0 {
  5755. c.ServeSuccessJSON(map[string]interface{}{
  5756. "msg": "确认成功",
  5757. })
  5758. return
  5759. }
  5760. } else {
  5761. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5762. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5763. result3, request3 := service.Jxyb4105(pp)
  5764. saveLog(result, request, "4102", "清单确认")
  5765. saveLog(result2, request2, "4103", "清单确认")
  5766. saveLog(result3, request3, "4105", "清单统计")
  5767. var dat map[string]interface{}
  5768. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5769. fmt.Println(dat)
  5770. } else {
  5771. fmt.Println(err)
  5772. }
  5773. var empty ResultFourteen
  5774. userJSONBytes, _ := json.Marshal(dat)
  5775. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5776. utils.ErrorLog("解析失败:%v", err)
  5777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5778. return
  5779. }
  5780. if empty.Infcode == 0 {
  5781. c.ServeSuccessJSON(map[string]interface{}{
  5782. "msg": "确认成功",
  5783. })
  5784. return
  5785. }
  5786. }
  5787. }
  5788. // 对账权限查询
  5789. func (c *HisApiController) Get3260() {
  5790. admin_user_id, _ := c.GetInt64("admin_user_id")
  5791. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5792. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5793. var api string
  5794. var res models.JSResult3260
  5795. if miConfig.MdtrtareaAdmvs == "320921" {
  5796. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5797. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5798. } else {
  5799. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5800. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5801. }
  5802. resp, requestErr := http.Get(api)
  5803. if requestErr != nil {
  5804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5805. return
  5806. }
  5807. body, ioErr := ioutil.ReadAll(resp.Body)
  5808. if ioErr != nil {
  5809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5811. return
  5812. }
  5813. var respJSON map[string]interface{}
  5814. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5817. return
  5818. }
  5819. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5820. result, _ := json.Marshal(respJSON)
  5821. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5822. utils.ErrorLog("解析失败:%v", err)
  5823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5824. return
  5825. }
  5826. if res.Infcode == "0" {
  5827. c.ServeSuccessJSON(map[string]interface{}{
  5828. "result": res.Output.Data,
  5829. })
  5830. } else {
  5831. c.ServeSuccessJSON(map[string]interface{}{
  5832. "failed_code": -10,
  5833. "msg": res.ErrMsg,
  5834. })
  5835. return
  5836. }
  5837. }
  5838. func (c *HisApiController) Get3261() {
  5839. admin_user_id, _ := c.GetInt64("admin_user_id")
  5840. //month := c.GetString("month")
  5841. startTime := c.GetString("start_time")
  5842. //endTime, _ := c.GetString("end_time")
  5843. times := strings.Split(startTime, "-")
  5844. stmt_mon := times[0] + times[1]
  5845. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5846. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5847. var api string
  5848. var res models.JSResult3261
  5849. //var res10265 Result5301For10265
  5850. if miConfig.MdtrtareaAdmvs == "320921" {
  5851. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5852. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5853. } else {
  5854. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5855. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5856. }
  5857. resp, requestErr := http.Get(api)
  5858. if requestErr != nil {
  5859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5860. return
  5861. }
  5862. body, ioErr := ioutil.ReadAll(resp.Body)
  5863. if ioErr != nil {
  5864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5866. return
  5867. }
  5868. var respJSON map[string]interface{}
  5869. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5872. return
  5873. }
  5874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5875. result, _ := json.Marshal(respJSON)
  5876. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5877. utils.ErrorLog("解析失败:%v", err)
  5878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5879. return
  5880. }
  5881. if res.Infcode == "0" {
  5882. c.ServeSuccessJSON(map[string]interface{}{
  5883. "result": res.Output,
  5884. })
  5885. } else {
  5886. c.ServeSuccessJSON(map[string]interface{}{
  5887. "failed_code": -10,
  5888. "msg": res.ErrMsg,
  5889. })
  5890. return
  5891. }
  5892. }
  5893. type TempFun struct {
  5894. FundKey string
  5895. FundCode string
  5896. }
  5897. func (c *HisApiController) Get3262() {
  5898. admin_user_id, _ := c.GetInt64("admin_user_id")
  5899. startTime := c.GetString("start_time")
  5900. endTime := c.GetString("end_time")
  5901. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5902. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5903. //timeLayout := "2006-01-02"
  5904. //loc, _ := time.LoadLocation("Local")
  5905. //var theStartTIme int64
  5906. //if len(startTime) > 0 {
  5907. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  5908. // if err != nil {
  5909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5910. // return
  5911. // }
  5912. // theStartTIme = theTime.Unix()
  5913. //}
  5914. //var theEndtTIme int64
  5915. //if len(endTime) > 0 {
  5916. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  5917. // if err != nil {
  5918. // utils.ErrorLog(err.Error())
  5919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5920. // return
  5921. // }
  5922. // theEndtTIme = theTime.Unix()
  5923. //}
  5924. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5925. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5926. for _, team := range datas {
  5927. fmt.Println(team.PsnTime)
  5928. for _, team_two := range datas_two {
  5929. fmt.Println(team_two.PsnTime)
  5930. if team.FundKey == team_two.FundKey {
  5931. fmt.Println(team_two.PsnTime)
  5932. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  5933. fmt.Println(team.PsnTime)
  5934. }
  5935. }
  5936. }
  5937. fmt.Println("1111")
  5938. fmt.Println(datas)
  5939. fmt.Println("1111")
  5940. var twos []models.FixMonRecDetailFileInTwo
  5941. for _, team := range datas {
  5942. var two models.FixMonRecDetailFileInTwo
  5943. two.MedType = team.MedType
  5944. two.Insutype = team.Insutype
  5945. two.PsnType = team.PsnType
  5946. two.MedType = team.MedType
  5947. two.FixBlngAdmdvs = "999999"
  5948. two.InsuAdmdvs = "555555"
  5949. two.PsnTime = team.PsnTime
  5950. two.PsnCnt = team.PsnCnt
  5951. two.FundKey = team.FundKey
  5952. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  5953. fps, _ := strconv.ParseFloat(team.Fund, 64)
  5954. ia, _ := strconv.ParseFloat(team.Amt, 64)
  5955. two.MedfeeSumAmt = ms
  5956. two.InscpAmt = ia
  5957. two.FundPaySumAmt = fps
  5958. twos = append(twos, two)
  5959. }
  5960. //startTime := c.GetString("start_time")
  5961. //endTime, _ := c.GetString("end_time")
  5962. times := strings.Split(startTime, "-")
  5963. stmt_mon := times[0] + times[1]
  5964. var funs []models.FundDetail
  5965. for _, item := range datas {
  5966. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  5967. funs = append(funs, fun...)
  5968. }
  5969. var funInfos []models.Fund
  5970. //for _, item := range funs {
  5971. // var rf []models.FundInfo
  5972. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  5973. // for _, subitem := range rf {
  5974. // var fund models.Fund
  5975. // fund.FundCode = subitem.FundPayType
  5976. // fund.FundName = subitem.FundPayTypeName
  5977. // fund.FundAmt = subitem.FundPayAmt
  5978. // fund.FundKey = item.FundKey
  5979. // fund.InsuAdmdvs = "555555"
  5980. // fund.FixBlngAdmdvs = "999999"
  5981. // funInfos = append(funInfos, fund)
  5982. // }
  5983. //}
  5984. var tempFuns []TempFun
  5985. for _, funInfo := range funInfos {
  5986. var tempFun TempFun
  5987. tempFun.FundKey = funInfo.FundKey
  5988. tempFun.FundCode = funInfo.FundCode
  5989. tempFuns = append(tempFuns, tempFun)
  5990. }
  5991. tempFuns = RemoveRepeatedFunElement(tempFuns)
  5992. fmt.Println(tempFuns)
  5993. var funInfosTwo []models.Fund
  5994. decimal.DivisionPrecision = 2
  5995. for _, item := range tempFuns {
  5996. var fund models.Fund
  5997. for _, subItem := range funInfos {
  5998. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  5999. fund.FundKey = subItem.FundKey
  6000. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6001. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6002. fund.FundName = subItem.FundName
  6003. fund.FundCode = subItem.FundCode
  6004. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6005. }
  6006. }
  6007. funInfosTwo = append(funInfosTwo, fund)
  6008. }
  6009. fmt.Println("funInfosTwo")
  6010. fmt.Println(funInfosTwo)
  6011. var upld_btch string
  6012. var empty models.JSResultEmpty
  6013. data := make(map[string]interface{})
  6014. data["org_name"] = miConfig.OrgName
  6015. data["doctor"] = curRoles.UserName
  6016. data["doctor_name"] = curRoles.UserName
  6017. data["fixmedins_code"] = miConfig.Code
  6018. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6019. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6020. data["secret_key"] = miConfig.SecretKey
  6021. data["url"] = miConfig.Url
  6022. data["ak"] = miConfig.AccessKey
  6023. data["cainfo"] = miConfig.Cainfo
  6024. data["datas"] = twos
  6025. data["fund"] = funInfosTwo
  6026. fmt.Println(twos)
  6027. month := time.Unix(1557042972, 0).Format("1")
  6028. year := time.Now().Format("2006")
  6029. month = time.Now().Format("01")
  6030. day := time.Now().Format("02")
  6031. hour := time.Now().Format("15")
  6032. min := time.Now().Format("04")
  6033. sec := time.Now().Format("05")
  6034. fix_fill_date := year + month + day + hour + min + sec
  6035. data["fix_fill_dept"] = miConfig.OrgName
  6036. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6037. data["fix_fill_psn"] = curRoles.UserName
  6038. data["fix_fill_date"] = fix_fill_date
  6039. data["stmt_loc"] = "2"
  6040. data["setl_mon"] = stmt_mon
  6041. upld_btch = "0"
  6042. data["upld_btch"] = upld_btch
  6043. //fmt.Println(data)
  6044. client := &http.Client{}
  6045. bytesData, _ := json.Marshal(data)
  6046. var req *http.Request
  6047. if miConfig.MdtrtareaAdmvs == "320921" {
  6048. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6049. } else {
  6050. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6051. }
  6052. resp, _ := client.Do(req)
  6053. defer resp.Body.Close()
  6054. body, ioErr := ioutil.ReadAll(resp.Body)
  6055. if ioErr != nil {
  6056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6058. }
  6059. var respJSON map[string]interface{}
  6060. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6063. }
  6064. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6065. //fmt.Println(respJSON)
  6066. result, _ := json.Marshal(respJSON)
  6067. //fmt.Println(result)
  6068. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6069. utils.ErrorLog("解析失败:%v", err)
  6070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6071. }
  6072. if empty.Infcode != "0" {
  6073. c.ServeSuccessJSON(map[string]interface{}{
  6074. "failed_code": -10,
  6075. "msg": empty.ErrMsg,
  6076. })
  6077. return
  6078. } else {
  6079. c.ServeSuccessJSON(map[string]interface{}{
  6080. "msg": "上传成功",
  6081. })
  6082. return
  6083. }
  6084. }
  6085. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6086. newArr = make([]TempFun, 0)
  6087. for i := 0; i < len(arr); i++ {
  6088. repeat := false
  6089. for j := i + 1; j < len(arr); j++ {
  6090. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6091. repeat = true
  6092. break
  6093. }
  6094. }
  6095. if !repeat {
  6096. newArr = append(newArr, arr[i])
  6097. }
  6098. }
  6099. return
  6100. }
  6101. func (c *HisApiController) Get3263() {
  6102. admin_user_id, _ := c.GetInt64("admin_user_id")
  6103. startTime := c.GetString("start_time")
  6104. //endTime, _ := c.GetString("end_time")
  6105. times := strings.Split(startTime, "-")
  6106. setl_mon := times[0] + times[1]
  6107. upld_btch := "0"
  6108. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6109. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6110. var result3263 models.JSResult3263
  6111. data := make(map[string]interface{})
  6112. data["org_name"] = miConfig.OrgName
  6113. data["doctor"] = curRoles.UserName
  6114. data["doctor_name"] = curRoles.UserName
  6115. data["fixmedins_code"] = miConfig.Code
  6116. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6117. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6118. data["secret_key"] = miConfig.SecretKey
  6119. data["url"] = miConfig.Url
  6120. data["ak"] = miConfig.AccessKey
  6121. data["cainfo"] = miConfig.Cainfo
  6122. data["setl_mon"] = setl_mon
  6123. data["stmt_loc"] = "2"
  6124. data["upld_btch"] = upld_btch
  6125. client := &http.Client{}
  6126. bytesData, _ := json.Marshal(data)
  6127. var req *http.Request
  6128. if miConfig.MdtrtareaAdmvs == "320921" {
  6129. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6130. } else {
  6131. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6132. }
  6133. resp, _ := client.Do(req)
  6134. defer resp.Body.Close()
  6135. body, ioErr := ioutil.ReadAll(resp.Body)
  6136. if ioErr != nil {
  6137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6139. }
  6140. var respJSON map[string]interface{}
  6141. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6144. }
  6145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6146. fmt.Println(respJSON)
  6147. result, _ := json.Marshal(respJSON)
  6148. fmt.Println(result)
  6149. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6150. utils.ErrorLog("解析失败:%v", err)
  6151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6152. }
  6153. if result3263.Infcode != "0" {
  6154. c.ServeSuccessJSON(map[string]interface{}{
  6155. "failed_code": -10,
  6156. "msg": result3263.ErrMsg,
  6157. })
  6158. return
  6159. } else {
  6160. c.ServeSuccessJSON(map[string]interface{}{
  6161. "list": result3263.Output,
  6162. })
  6163. return
  6164. }
  6165. }
  6166. func (c *HisApiController) Get3264() {
  6167. admin_user_id, _ := c.GetInt64("admin_user_id")
  6168. startTime := c.GetString("start_time")
  6169. //endTime, _ := c.GetString("end_time")
  6170. times := strings.Split(startTime, "-")
  6171. setl_mon := times[0] + times[1]
  6172. upld_btch := "0"
  6173. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6174. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6175. //solidify_id := []
  6176. var result3263 models.JSResult3263
  6177. data := make(map[string]interface{})
  6178. data["org_name"] = miConfig.OrgName
  6179. data["doctor"] = curRoles.UserName
  6180. data["doctor_name"] = curRoles.UserName
  6181. data["fixmedins_code"] = miConfig.Code
  6182. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6183. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6184. data["secret_key"] = miConfig.SecretKey
  6185. data["url"] = miConfig.Url
  6186. data["ak"] = miConfig.AccessKey
  6187. data["cainfo"] = miConfig.Cainfo
  6188. data["setl_mon"] = setl_mon
  6189. data["stmt_loc"] = "2"
  6190. data["upld_btch"] = upld_btch
  6191. client := &http.Client{}
  6192. bytesData, _ := json.Marshal(data)
  6193. var req3263 *http.Request
  6194. if miConfig.MdtrtareaAdmvs == "320921" {
  6195. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6196. } else {
  6197. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6198. }
  6199. resp, _ := client.Do(req3263)
  6200. defer resp.Body.Close()
  6201. body, ioErr := ioutil.ReadAll(resp.Body)
  6202. if ioErr != nil {
  6203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6205. }
  6206. var respJSON3263 map[string]interface{}
  6207. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6210. }
  6211. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6212. fmt.Println(respJSON3263)
  6213. result, _ := json.Marshal(respJSON3263)
  6214. fmt.Println(result)
  6215. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6216. utils.ErrorLog("解析失败:%v", err)
  6217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6218. }
  6219. var ids []string
  6220. for _, item := range result3263.Output {
  6221. ids = append(ids, item.SolidifyID)
  6222. }
  6223. var empty models.JSResultEmpty
  6224. data2 := make(map[string]interface{})
  6225. data2["org_name"] = miConfig.OrgName
  6226. data2["doctor"] = curRoles.UserName
  6227. data2["doctor_name"] = curRoles.UserName
  6228. data2["fixmedins_code"] = miConfig.Code
  6229. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6230. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6231. data2["secret_key"] = miConfig.SecretKey
  6232. data2["url"] = miConfig.Url
  6233. data2["ak"] = miConfig.AccessKey
  6234. data2["cainfo"] = miConfig.Cainfo
  6235. data2["setl_mon"] = setl_mon
  6236. data2["stmt_loc"] = "2"
  6237. data2["upld_btch"] = upld_btch
  6238. data2["solidify_id"] = ids
  6239. client2 := &http.Client{}
  6240. bytesData2, _ := json.Marshal(data2)
  6241. var req *http.Request
  6242. if miConfig.MdtrtareaAdmvs == "320921" {
  6243. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6244. } else {
  6245. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6246. }
  6247. resp2, _ := client2.Do(req)
  6248. defer resp.Body.Close()
  6249. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6250. if ioErr2 != nil {
  6251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6253. }
  6254. var respJSON map[string]interface{}
  6255. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6258. }
  6259. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6260. fmt.Println(respJSON)
  6261. result2, _ := json.Marshal(respJSON)
  6262. fmt.Println(result2)
  6263. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6264. utils.ErrorLog("解析失败:%v", err)
  6265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6266. }
  6267. if empty.Infcode != "0" {
  6268. c.ServeSuccessJSON(map[string]interface{}{
  6269. "failed_code": -10,
  6270. "msg": empty.ErrMsg,
  6271. })
  6272. return
  6273. } else {
  6274. c.ServeSuccessJSON(map[string]interface{}{
  6275. "msg": "",
  6276. })
  6277. return
  6278. }
  6279. }
  6280. func (c *HisApiController) Get3265() {
  6281. admin_user_id, _ := c.GetInt64("admin_user_id")
  6282. startTime := c.GetString("start_time")
  6283. //endTime, _ := c.GetString("end_time")
  6284. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6285. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6286. times := strings.Split(startTime, "-")
  6287. setl_mon := times[0] + times[1]
  6288. var upld_btch string
  6289. upld_btch = "0"
  6290. //var empty models.JSResultEmpty
  6291. var result3265 models.JSResult3264
  6292. var result3263 models.JSResult3263
  6293. data2 := make(map[string]interface{})
  6294. data2["org_name"] = miConfig.OrgName
  6295. data2["doctor"] = curRoles.UserName
  6296. data2["doctor_name"] = curRoles.UserName
  6297. data2["fixmedins_code"] = miConfig.Code
  6298. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6299. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6300. data2["secret_key"] = miConfig.SecretKey
  6301. data2["url"] = miConfig.Url
  6302. data2["ak"] = miConfig.AccessKey
  6303. data2["cainfo"] = miConfig.Cainfo
  6304. data2["setl_mon"] = setl_mon
  6305. data2["stmt_loc"] = "2"
  6306. data2["upld_btch"] = upld_btch
  6307. client2 := &http.Client{}
  6308. bytesData2, _ := json.Marshal(data2)
  6309. var req3263 *http.Request
  6310. if miConfig.MdtrtareaAdmvs == "320921" {
  6311. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6312. } else {
  6313. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6314. }
  6315. resp2, _ := client2.Do(req3263)
  6316. defer resp2.Body.Close()
  6317. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6318. if ioErr2 != nil {
  6319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6321. }
  6322. var respJSON3263 map[string]interface{}
  6323. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6326. }
  6327. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6328. fmt.Println(respJSON3263)
  6329. result2, _ := json.Marshal(respJSON3263)
  6330. fmt.Println(result2)
  6331. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6332. utils.ErrorLog("解析失败:%v", err)
  6333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6334. }
  6335. var ids []string
  6336. for _, item := range result3263.Output {
  6337. ids = append(ids, item.SolidifyID)
  6338. }
  6339. data := make(map[string]interface{})
  6340. data["org_name"] = miConfig.OrgName
  6341. data["doctor"] = curRoles.UserName
  6342. data["doctor_name"] = curRoles.UserName
  6343. data["fixmedins_code"] = miConfig.Code
  6344. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6345. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6346. data["secret_key"] = miConfig.SecretKey
  6347. data["url"] = miConfig.Url
  6348. data["ak"] = miConfig.AccessKey
  6349. data["cainfo"] = miConfig.Cainfo
  6350. data["setl_mon"] = setl_mon
  6351. data["solidify_id"] = ids
  6352. month := time.Unix(1557042972, 0).Format("1")
  6353. year := time.Now().Format("2006")
  6354. month = time.Now().Format("01")
  6355. day := time.Now().Format("02")
  6356. hour := time.Now().Format("15")
  6357. min := time.Now().Format("04")
  6358. sec := time.Now().Format("05")
  6359. fix_fill_date := year + month + day + hour + min + sec
  6360. data["fix_fill_dept"] = miConfig.OrgName
  6361. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6362. data["fix_fill_psn"] = curRoles.UserName
  6363. data["fix_fill_date"] = fix_fill_date
  6364. data["stmt_loc"] = "2"
  6365. data["upld_btch"] = upld_btch
  6366. client := &http.Client{}
  6367. bytesData, _ := json.Marshal(data)
  6368. var req *http.Request
  6369. if miConfig.MdtrtareaAdmvs == "320921" {
  6370. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6371. } else {
  6372. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6373. }
  6374. resp, _ := client.Do(req)
  6375. defer resp.Body.Close()
  6376. body, ioErr := ioutil.ReadAll(resp.Body)
  6377. if ioErr != nil {
  6378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6380. }
  6381. var respJSON map[string]interface{}
  6382. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6385. }
  6386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6387. fmt.Println(respJSON)
  6388. result, _ := json.Marshal(respJSON)
  6389. fmt.Println(result)
  6390. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6391. utils.ErrorLog("解析失败:%v", err)
  6392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6393. }
  6394. if result3265.Infcode != "0" {
  6395. c.ServeSuccessJSON(map[string]interface{}{
  6396. "failed_code": -10,
  6397. "msg": result3265.ErrMsg,
  6398. })
  6399. return
  6400. } else {
  6401. c.ServeSuccessJSON(map[string]interface{}{
  6402. "info": result3265.Output,
  6403. })
  6404. return
  6405. }
  6406. }
  6407. func (c *HisApiController) Get3266() {
  6408. admin_user_id, _ := c.GetInt64("admin_user_id")
  6409. startTime := c.GetString("start_time")
  6410. //endTime, _ := c.GetString("end_time")
  6411. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6412. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6413. times := strings.Split(startTime, "-")
  6414. stmt_mon := times[0] + times[1]
  6415. var upld_btch string
  6416. //var empty models.JSResultEmpty
  6417. var result3265 models.JSResult3264
  6418. data := make(map[string]interface{})
  6419. data["org_name"] = miConfig.OrgName
  6420. data["doctor"] = curRoles.UserName
  6421. data["doctor_name"] = curRoles.UserName
  6422. data["fixmedins_code"] = miConfig.Code
  6423. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6424. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6425. data["secret_key"] = miConfig.SecretKey
  6426. data["url"] = miConfig.Url
  6427. data["ak"] = miConfig.AccessKey
  6428. data["cainfo"] = miConfig.Cainfo
  6429. data["setl_mon"] = stmt_mon
  6430. month := time.Unix(1557042972, 0).Format("1")
  6431. year := time.Now().Format("2006")
  6432. month = time.Now().Format("01")
  6433. day := time.Now().Format("02")
  6434. hour := time.Now().Format("15")
  6435. min := time.Now().Format("04")
  6436. sec := time.Now().Format("05")
  6437. fix_fill_date := year + month + day + hour + min + sec
  6438. data["fix_fill_dept"] = miConfig.OrgName
  6439. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6440. data["fix_fill_psn"] = curRoles.UserName
  6441. data["fix_fill_date"] = fix_fill_date
  6442. data["stmt_loc"] = "2"
  6443. upld_btch = "0"
  6444. data["upld_btch"] = upld_btch
  6445. client := &http.Client{}
  6446. bytesData, _ := json.Marshal(data)
  6447. var req *http.Request
  6448. if miConfig.MdtrtareaAdmvs == "320921" {
  6449. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6450. } else {
  6451. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6452. }
  6453. resp, _ := client.Do(req)
  6454. defer resp.Body.Close()
  6455. body, ioErr := ioutil.ReadAll(resp.Body)
  6456. if ioErr != nil {
  6457. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6459. }
  6460. var respJSON map[string]interface{}
  6461. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6464. }
  6465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6466. fmt.Println(respJSON)
  6467. result, _ := json.Marshal(respJSON)
  6468. fmt.Println(result)
  6469. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6470. utils.ErrorLog("解析失败:%v", err)
  6471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6472. }
  6473. if result3265.Infcode != "0" {
  6474. c.ServeSuccessJSON(map[string]interface{}{
  6475. "failed_code": -10,
  6476. "msg": result3265.ErrMsg,
  6477. })
  6478. return
  6479. } else {
  6480. c.ServeSuccessJSON(map[string]interface{}{
  6481. "info": result3265.Output,
  6482. })
  6483. return
  6484. }
  6485. }
  6486. func (c *HisApiController) Get3267() {
  6487. admin_user_id, _ := c.GetInt64("admin_user_id")
  6488. startTime := c.GetString("start_time")
  6489. //endTime, _ := c.GetString("end_time")
  6490. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6491. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6492. times := strings.Split(startTime, "-")
  6493. setl_mon := times[0] + times[1]
  6494. var upld_btch string
  6495. //var empty models.JSResultEmpty
  6496. var result3265 models.JSResult3264
  6497. upld_btch = "0"
  6498. data := make(map[string]interface{})
  6499. data["org_name"] = miConfig.OrgName
  6500. data["doctor"] = curRoles.UserName
  6501. data["doctor_name"] = curRoles.UserName
  6502. data["fixmedins_code"] = miConfig.Code
  6503. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6504. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6505. data["secret_key"] = miConfig.SecretKey
  6506. data["url"] = miConfig.Url
  6507. data["ak"] = miConfig.AccessKey
  6508. data["cainfo"] = miConfig.Cainfo
  6509. data["setl_mon"] = setl_mon
  6510. data["stmt_loc"] = "2"
  6511. data["upld_btch"] = upld_btch
  6512. client := &http.Client{}
  6513. bytesData, _ := json.Marshal(data)
  6514. var req *http.Request
  6515. if miConfig.MdtrtareaAdmvs == "320921" {
  6516. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6517. } else {
  6518. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6519. }
  6520. resp, _ := client.Do(req)
  6521. defer resp.Body.Close()
  6522. body, ioErr := ioutil.ReadAll(resp.Body)
  6523. if ioErr != nil {
  6524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6526. }
  6527. var respJSON map[string]interface{}
  6528. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6531. }
  6532. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6533. fmt.Println(respJSON)
  6534. result, _ := json.Marshal(respJSON)
  6535. fmt.Println(result)
  6536. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6537. utils.ErrorLog("解析失败:%v", err)
  6538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6539. }
  6540. if result3265.Infcode != "0" {
  6541. c.ServeSuccessJSON(map[string]interface{}{
  6542. "failed_code": -10,
  6543. "msg": result3265.ErrMsg,
  6544. })
  6545. return
  6546. } else {
  6547. c.ServeSuccessJSON(map[string]interface{}{
  6548. "info": result3265.Output.Data,
  6549. })
  6550. return
  6551. }
  6552. }
  6553. func (c *HisApiController) Get3268() {
  6554. admin_user_id, _ := c.GetInt64("admin_user_id")
  6555. startTime := c.GetString("start_time")
  6556. endTime := c.GetString("end_time")
  6557. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6558. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6559. times := strings.Split(startTime, "-")
  6560. setl_mon := times[0] + times[1]
  6561. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6562. var twos []models.FixMonRecDetailFileInTwo
  6563. var funs []models.FundDetail
  6564. for _, item := range datas {
  6565. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6566. funs = append(funs, fun...)
  6567. }
  6568. var funInfos []models.Fund
  6569. //for _, item := range funs {
  6570. // var rf []models.FundInfo
  6571. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6572. // for _, subitem := range rf {
  6573. // var fund models.Fund
  6574. // fund.FundCode = subitem.FundPayType
  6575. // fund.FundName = subitem.FundPayTypeName
  6576. // fund.FundAmt = subitem.FundPayAmt
  6577. // fund.FundKey = item.FundKey
  6578. // fund.InsuAdmdvs = "555555"
  6579. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6580. // funInfos = append(funInfos, fund)
  6581. // }
  6582. //}
  6583. for _, team := range datas {
  6584. var two models.FixMonRecDetailFileInTwo
  6585. two.SetlDate = time.Now().Format("2006-01-02")
  6586. two.MedType = team.MedType
  6587. two.Insutype = team.Insutype
  6588. two.PsnType = team.PsnType
  6589. two.MedType = team.MedType
  6590. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6591. two.InsuAdmdvs = team.InsuAdmdvs
  6592. two.PsnTime = team.PsnTime
  6593. two.PsnCnt = team.PsnCnt
  6594. two.FundKey = team.FundKey
  6595. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6596. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6597. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6598. two.MedfeeSumAmt = ms
  6599. two.InscpAmt = ia
  6600. two.FundPaySumAmt = fps
  6601. twos = append(twos, two)
  6602. }
  6603. var upld_btch string
  6604. upld_btch = "0"
  6605. var empty models.JSResultEmpty
  6606. data := make(map[string]interface{})
  6607. data["org_name"] = miConfig.OrgName
  6608. data["doctor"] = curRoles.UserName
  6609. data["doctor_name"] = curRoles.UserName
  6610. data["fixmedins_code"] = miConfig.Code
  6611. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6612. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6613. data["secret_key"] = miConfig.SecretKey
  6614. data["url"] = miConfig.Url
  6615. data["ak"] = miConfig.AccessKey
  6616. data["cainfo"] = miConfig.Cainfo
  6617. data["datas"] = twos
  6618. data["fund"] = funInfos
  6619. data["setl_mon"] = setl_mon
  6620. month := time.Unix(1557042972, 0).Format("1")
  6621. year := time.Now().Format("2006")
  6622. month = time.Now().Format("01")
  6623. day := time.Now().Format("02")
  6624. hour := time.Now().Format("15")
  6625. min := time.Now().Format("04")
  6626. sec := time.Now().Format("05")
  6627. fix_fill_date := year + month + day + hour + min + sec
  6628. data["fix_fill_dept"] = miConfig.OrgName
  6629. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6630. data["fix_fill_psn"] = curRoles.UserName
  6631. data["fix_fill_date"] = fix_fill_date
  6632. data["stmt_loc"] = "2"
  6633. data["upld_btch"] = upld_btch
  6634. client := &http.Client{}
  6635. bytesData, _ := json.Marshal(data)
  6636. var req *http.Request
  6637. if miConfig.MdtrtareaAdmvs == "320921" {
  6638. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6639. } else {
  6640. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6641. }
  6642. resp, _ := client.Do(req)
  6643. defer resp.Body.Close()
  6644. body, ioErr := ioutil.ReadAll(resp.Body)
  6645. if ioErr != nil {
  6646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6648. }
  6649. var respJSON map[string]interface{}
  6650. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6653. }
  6654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6655. fmt.Println(respJSON)
  6656. result, _ := json.Marshal(respJSON)
  6657. fmt.Println(result)
  6658. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6659. utils.ErrorLog("解析失败:%v", err)
  6660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6661. }
  6662. if empty.Infcode != "0" {
  6663. c.ServeSuccessJSON(map[string]interface{}{
  6664. "failed_code": -10,
  6665. "msg": empty.ErrMsg,
  6666. })
  6667. return
  6668. } else {
  6669. c.ServeSuccessJSON(map[string]interface{}{
  6670. "msg": "上传成功",
  6671. })
  6672. return
  6673. }
  6674. }
  6675. func (c *HisApiController) Get3269() {
  6676. admin_user_id, _ := c.GetInt64("admin_user_id")
  6677. startTime := c.GetString("start_time")
  6678. //endTime, _ := c.GetString("end_time")
  6679. times := strings.Split(startTime, "-")
  6680. setl_mon := times[0] + times[1]
  6681. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6682. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6683. var result3263 models.JSResult3263
  6684. data := make(map[string]interface{})
  6685. data["org_name"] = miConfig.OrgName
  6686. data["doctor"] = curRoles.UserName
  6687. data["doctor_name"] = curRoles.UserName
  6688. data["fixmedins_code"] = miConfig.Code
  6689. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6690. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6691. data["secret_key"] = miConfig.SecretKey
  6692. data["url"] = miConfig.Url
  6693. data["ak"] = miConfig.AccessKey
  6694. data["cainfo"] = miConfig.Cainfo
  6695. data["setl_mon"] = setl_mon
  6696. data["stmt_loc"] = "2"
  6697. client := &http.Client{}
  6698. bytesData, _ := json.Marshal(data)
  6699. var req *http.Request
  6700. if miConfig.MdtrtareaAdmvs == "320921" {
  6701. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6702. } else {
  6703. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6704. }
  6705. resp, _ := client.Do(req)
  6706. defer resp.Body.Close()
  6707. body, ioErr := ioutil.ReadAll(resp.Body)
  6708. if ioErr != nil {
  6709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6711. }
  6712. var respJSON map[string]interface{}
  6713. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6716. }
  6717. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6718. fmt.Println(respJSON)
  6719. result, _ := json.Marshal(respJSON)
  6720. fmt.Println(result)
  6721. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6722. utils.ErrorLog("解析失败:%v", err)
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6724. }
  6725. if result3263.Infcode != "0" {
  6726. c.ServeSuccessJSON(map[string]interface{}{
  6727. "failed_code": -10,
  6728. "msg": result3263.ErrMsg,
  6729. })
  6730. return
  6731. } else {
  6732. c.ServeSuccessJSON(map[string]interface{}{
  6733. "msg": "上传成功",
  6734. })
  6735. return
  6736. }
  6737. }
  6738. func (c *HisApiController) Get3270() {
  6739. admin_user_id, _ := c.GetInt64("admin_user_id")
  6740. startTime := c.GetString("start_time")
  6741. //endTime, _ := c.GetString("end_time")
  6742. times := strings.Split(startTime, "-")
  6743. setl_mon := times[0] + times[1]
  6744. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6745. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6746. var result3263 models.JSResult3263
  6747. data2 := make(map[string]interface{})
  6748. data2["org_name"] = miConfig.OrgName
  6749. data2["doctor"] = curRoles.UserName
  6750. data2["doctor_name"] = curRoles.UserName
  6751. data2["fixmedins_code"] = miConfig.Code
  6752. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6753. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6754. data2["secret_key"] = miConfig.SecretKey
  6755. data2["url"] = miConfig.Url
  6756. data2["ak"] = miConfig.AccessKey
  6757. data2["cainfo"] = miConfig.Cainfo
  6758. data2["setl_mon"] = setl_mon
  6759. data2["stmt_loc"] = "2"
  6760. client2 := &http.Client{}
  6761. bytesData2, _ := json.Marshal(data2)
  6762. var req3263 *http.Request
  6763. if miConfig.MdtrtareaAdmvs == "320921" {
  6764. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6765. } else {
  6766. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6767. }
  6768. resp2, _ := client2.Do(req3263)
  6769. defer resp2.Body.Close()
  6770. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6771. if ioErr2 != nil {
  6772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6774. }
  6775. var respJSON3263 map[string]interface{}
  6776. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6779. }
  6780. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6781. fmt.Println(respJSON3263)
  6782. result2, _ := json.Marshal(respJSON3263)
  6783. fmt.Println(result2)
  6784. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6785. utils.ErrorLog("解析失败:%v", err)
  6786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6787. }
  6788. var ids []string
  6789. for _, item := range result3263.Output {
  6790. ids = append(ids, item.SolidifyID)
  6791. }
  6792. var result3264 models.JSResult3264
  6793. data := make(map[string]interface{})
  6794. data["org_name"] = miConfig.OrgName
  6795. data["doctor"] = curRoles.UserName
  6796. data["doctor_name"] = curRoles.UserName
  6797. data["fixmedins_code"] = miConfig.Code
  6798. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6799. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6800. data["secret_key"] = miConfig.SecretKey
  6801. data["url"] = miConfig.Url
  6802. data["ak"] = miConfig.AccessKey
  6803. data["cainfo"] = miConfig.Cainfo
  6804. data["setl_mon"] = setl_mon
  6805. data["stmt_loc"] = "2"
  6806. data["solidify_id"] = ids
  6807. client := &http.Client{}
  6808. bytesData, _ := json.Marshal(data)
  6809. var req *http.Request
  6810. if miConfig.MdtrtareaAdmvs == "320921" {
  6811. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6812. } else {
  6813. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6814. }
  6815. resp, _ := client.Do(req)
  6816. defer resp.Body.Close()
  6817. body, ioErr := ioutil.ReadAll(resp.Body)
  6818. if ioErr != nil {
  6819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6821. }
  6822. var respJSON map[string]interface{}
  6823. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6826. }
  6827. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6828. fmt.Println(respJSON)
  6829. result, _ := json.Marshal(respJSON)
  6830. fmt.Println(result)
  6831. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  6832. utils.ErrorLog("解析失败:%v", err)
  6833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6834. }
  6835. if result3264.Infcode != "0" {
  6836. c.ServeSuccessJSON(map[string]interface{}{
  6837. "failed_code": -10,
  6838. "msg": result3264.ErrMsg,
  6839. })
  6840. return
  6841. } else {
  6842. c.ServeSuccessJSON(map[string]interface{}{
  6843. "info": result3264.Output,
  6844. })
  6845. return
  6846. }
  6847. }
  6848. func (c *HisApiController) Get3271() {
  6849. admin_user_id, _ := c.GetInt64("admin_user_id")
  6850. startTime := c.GetString("start_time")
  6851. //endTime, _ := c.GetString("end_time")
  6852. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6854. times := strings.Split(startTime, "-")
  6855. setl_mon := times[0] + times[1]
  6856. //var empty models.JSResultEmpty
  6857. var result3265 models.JSResult3264
  6858. var result3263 models.JSResult3263
  6859. data2 := make(map[string]interface{})
  6860. data2["org_name"] = miConfig.OrgName
  6861. data2["doctor"] = curRoles.UserName
  6862. data2["doctor_name"] = curRoles.UserName
  6863. data2["fixmedins_code"] = miConfig.Code
  6864. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6865. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6866. data2["secret_key"] = miConfig.SecretKey
  6867. data2["url"] = miConfig.Url
  6868. data2["ak"] = miConfig.AccessKey
  6869. data2["cainfo"] = miConfig.Cainfo
  6870. data2["setl_mon"] = setl_mon
  6871. data2["stmt_loc"] = "2"
  6872. client2 := &http.Client{}
  6873. bytesData2, _ := json.Marshal(data2)
  6874. var req3263 *http.Request
  6875. if miConfig.MdtrtareaAdmvs == "320921" {
  6876. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6877. } else {
  6878. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6879. }
  6880. resp2, _ := client2.Do(req3263)
  6881. defer resp2.Body.Close()
  6882. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6883. if ioErr2 != nil {
  6884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6886. }
  6887. var respJSON3263 map[string]interface{}
  6888. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6891. }
  6892. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6893. fmt.Println(respJSON3263)
  6894. result2, _ := json.Marshal(respJSON3263)
  6895. fmt.Println(result2)
  6896. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6897. utils.ErrorLog("解析失败:%v", err)
  6898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6899. }
  6900. var ids []string
  6901. for _, item := range result3263.Output {
  6902. ids = append(ids, item.SolidifyID)
  6903. }
  6904. data := make(map[string]interface{})
  6905. data["org_name"] = miConfig.OrgName
  6906. data["doctor"] = curRoles.UserName
  6907. data["doctor_name"] = curRoles.UserName
  6908. data["fixmedins_code"] = miConfig.Code
  6909. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6910. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6911. data["secret_key"] = miConfig.SecretKey
  6912. data["url"] = miConfig.Url
  6913. data["ak"] = miConfig.AccessKey
  6914. data["cainfo"] = miConfig.Cainfo
  6915. data["setl_mon"] = setl_mon
  6916. data["solidify_id"] = ids
  6917. month := time.Unix(1557042972, 0).Format("1")
  6918. year := time.Now().Format("2006")
  6919. month = time.Now().Format("01")
  6920. day := time.Now().Format("02")
  6921. hour := time.Now().Format("15")
  6922. min := time.Now().Format("04")
  6923. sec := time.Now().Format("05")
  6924. fix_fill_date := year + month + day + hour + min + sec
  6925. data["fix_fill_dept"] = miConfig.OrgName
  6926. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6927. data["fix_fill_psn"] = curRoles.UserName
  6928. data["fix_fill_date"] = fix_fill_date
  6929. data["stmt_loc"] = "2"
  6930. client := &http.Client{}
  6931. bytesData, _ := json.Marshal(data)
  6932. var req *http.Request
  6933. if miConfig.MdtrtareaAdmvs == "320921" {
  6934. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6935. } else {
  6936. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6937. }
  6938. resp, _ := client.Do(req)
  6939. defer resp.Body.Close()
  6940. body, ioErr := ioutil.ReadAll(resp.Body)
  6941. if ioErr != nil {
  6942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6944. }
  6945. var respJSON map[string]interface{}
  6946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6949. }
  6950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6951. fmt.Println(respJSON)
  6952. result, _ := json.Marshal(respJSON)
  6953. fmt.Println(result)
  6954. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6955. utils.ErrorLog("解析失败:%v", err)
  6956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6957. }
  6958. if result3265.Infcode != "0" {
  6959. c.ServeSuccessJSON(map[string]interface{}{
  6960. "failed_code": -10,
  6961. "msg": result3265.ErrMsg,
  6962. })
  6963. return
  6964. } else {
  6965. c.ServeSuccessJSON(map[string]interface{}{
  6966. "info": result3265.Output.Data,
  6967. })
  6968. return
  6969. }
  6970. }
  6971. func (c *HisApiController) Get3272() {
  6972. admin_user_id, _ := c.GetInt64("admin_user_id")
  6973. startTime := c.GetString("start_time")
  6974. //endTime, _ := c.GetString("end_time")
  6975. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6976. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6977. times := strings.Split(startTime, "-")
  6978. setl_mon := times[0] + times[1]
  6979. var upld_btch string
  6980. //var empty models.JSResultEmpty
  6981. var result3265 models.JSResult3264
  6982. data := make(map[string]interface{})
  6983. data["org_name"] = miConfig.OrgName
  6984. data["doctor"] = curRoles.UserName
  6985. data["doctor_name"] = curRoles.UserName
  6986. data["fixmedins_code"] = miConfig.Code
  6987. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6988. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6989. data["secret_key"] = miConfig.SecretKey
  6990. data["url"] = miConfig.Url
  6991. data["ak"] = miConfig.AccessKey
  6992. data["cainfo"] = miConfig.Cainfo
  6993. data["setl_mon"] = setl_mon
  6994. month := time.Unix(1557042972, 0).Format("1")
  6995. year := time.Now().Format("2006")
  6996. month = time.Now().Format("01")
  6997. day := time.Now().Format("02")
  6998. hour := time.Now().Format("15")
  6999. min := time.Now().Format("04")
  7000. sec := time.Now().Format("05")
  7001. fix_fill_date := year + month + day + hour + min + sec
  7002. data["fix_fill_dept"] = miConfig.OrgName
  7003. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7004. data["fix_fill_psn"] = curRoles.UserName
  7005. data["fix_fill_date"] = fix_fill_date
  7006. data["stmt_loc"] = "2"
  7007. data["upld_btch"] = upld_btch
  7008. client := &http.Client{}
  7009. bytesData, _ := json.Marshal(data)
  7010. var req *http.Request
  7011. if miConfig.MdtrtareaAdmvs == "320921" {
  7012. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7013. } else {
  7014. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7015. }
  7016. resp, _ := client.Do(req)
  7017. defer resp.Body.Close()
  7018. body, ioErr := ioutil.ReadAll(resp.Body)
  7019. if ioErr != nil {
  7020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7022. }
  7023. var respJSON map[string]interface{}
  7024. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7027. }
  7028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7029. fmt.Println(respJSON)
  7030. result, _ := json.Marshal(respJSON)
  7031. fmt.Println(result)
  7032. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7033. utils.ErrorLog("解析失败:%v", err)
  7034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7035. }
  7036. if result3265.Infcode != "0" {
  7037. c.ServeSuccessJSON(map[string]interface{}{
  7038. "failed_code": -10,
  7039. "msg": result3265.ErrMsg,
  7040. })
  7041. return
  7042. } else {
  7043. c.ServeSuccessJSON(map[string]interface{}{
  7044. "info": result3265.Output,
  7045. })
  7046. return
  7047. }
  7048. }
  7049. func (c *HisApiController) Get3273() {
  7050. admin_user_id, _ := c.GetInt64("admin_user_id")
  7051. startTime := c.GetString("start_time")
  7052. //endTime, _ := c.GetString("end_time")
  7053. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7054. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7055. times := strings.Split(startTime, "-")
  7056. setl_mon := times[0] + times[1]
  7057. var result3265 models.JSResult3264
  7058. data := make(map[string]interface{})
  7059. data["org_name"] = miConfig.OrgName
  7060. data["doctor"] = curRoles.UserName
  7061. data["doctor_name"] = curRoles.UserName
  7062. data["fixmedins_code"] = miConfig.Code
  7063. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7064. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7065. data["secret_key"] = miConfig.SecretKey
  7066. data["url"] = miConfig.Url
  7067. data["ak"] = miConfig.AccessKey
  7068. data["cainfo"] = miConfig.Cainfo
  7069. data["setl_mon"] = setl_mon
  7070. data["stmt_loc"] = "2"
  7071. client := &http.Client{}
  7072. bytesData, _ := json.Marshal(data)
  7073. var req *http.Request
  7074. if miConfig.MdtrtareaAdmvs == "320921" {
  7075. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7076. } else {
  7077. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7078. }
  7079. resp, _ := client.Do(req)
  7080. defer resp.Body.Close()
  7081. body, ioErr := ioutil.ReadAll(resp.Body)
  7082. if ioErr != nil {
  7083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7085. }
  7086. var respJSON map[string]interface{}
  7087. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7090. }
  7091. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7092. fmt.Println(respJSON)
  7093. result, _ := json.Marshal(respJSON)
  7094. fmt.Println(result)
  7095. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7096. utils.ErrorLog("解析失败:%v", err)
  7097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7098. }
  7099. if result3265.Infcode != "0" {
  7100. c.ServeSuccessJSON(map[string]interface{}{
  7101. "failed_code": -10,
  7102. "msg": result3265.ErrMsg,
  7103. })
  7104. return
  7105. } else {
  7106. c.ServeSuccessJSON(map[string]interface{}{
  7107. "info": result3265.Output.Data,
  7108. })
  7109. return
  7110. }
  7111. }
  7112. func (c *HisApiController) Get3274() {
  7113. //if miConfig.MdtrtareaAdmvs == "320921" {
  7114. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7115. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7116. // "&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
  7117. //
  7118. //} else {
  7119. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7120. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7121. // "&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
  7122. //
  7123. //}
  7124. }
  7125. func (c *HisApiController) Get3275() {
  7126. //if miConfig.MdtrtareaAdmvs == "320921" {
  7127. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7128. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7129. // "&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
  7130. //
  7131. //} else {
  7132. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7133. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7134. // "&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
  7135. //
  7136. //}
  7137. }
  7138. func (c *HisApiController) Get3276() {
  7139. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7140. //month := c.GetString("month")
  7141. //
  7142. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7143. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7144. //var api string
  7145. //var res Result5301
  7146. //
  7147. //if miConfig.MdtrtareaAdmvs == "320921" {
  7148. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7149. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7150. //} else {
  7151. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7152. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7153. //}
  7154. //
  7155. //resp, requestErr := http.Get(api)
  7156. //if requestErr != nil {
  7157. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7158. // return
  7159. //}
  7160. //
  7161. //body, ioErr := ioutil.ReadAll(resp.Body)
  7162. //if ioErr != nil {
  7163. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7164. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7165. // return
  7166. //}
  7167. //var respJSON map[string]interface{}
  7168. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7169. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7170. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7171. // return
  7172. //}
  7173. //
  7174. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7175. //result, _ := json.Marshal(respJSON)
  7176. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7177. // utils.ErrorLog("解析失败:%v", err)
  7178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7179. // return
  7180. //}
  7181. }
  7182. func (c *HisApiController) Get3277() {
  7183. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7184. //month := c.GetString("month")
  7185. //
  7186. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7187. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7188. //var api string
  7189. //var res Result5301
  7190. //
  7191. //if miConfig.MdtrtareaAdmvs == "320921" {
  7192. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7193. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7194. //} else {
  7195. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7196. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7197. //}
  7198. //
  7199. //resp, requestErr := http.Get(api)
  7200. //if requestErr != nil {
  7201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7202. // return
  7203. //}
  7204. //
  7205. //body, ioErr := ioutil.ReadAll(resp.Body)
  7206. //if ioErr != nil {
  7207. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7208. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7209. // return
  7210. //}
  7211. //var respJSON map[string]interface{}
  7212. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7213. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7215. // return
  7216. //}
  7217. //
  7218. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7219. //result, _ := json.Marshal(respJSON)
  7220. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7221. // utils.ErrorLog("解析失败:%v", err)
  7222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7223. // return
  7224. //}
  7225. }
  7226. func (c *HisApiController) GetCFYLJG001() {
  7227. admin_user_id, _ := c.GetInt64("admin_user_id")
  7228. patient_id, _ := c.GetInt64("patient_id")
  7229. his_patient_id, _ := c.GetInt64("his_patient_id")
  7230. record_time := c.GetString("record_time")
  7231. admin_user_id = 3626
  7232. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7233. psn, _ := service.GetPsnByPatientId(patient_id)
  7234. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7235. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7236. var cFYLJG001 models.CFYLJG001
  7237. timeLayout := "2006-01-02"
  7238. loc, _ := time.LoadLocation("Local")
  7239. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7240. if err != nil {
  7241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7242. return
  7243. }
  7244. recordDateTime := theTime.Unix()
  7245. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7246. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7247. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7248. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7249. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7250. for _, item := range prescriptions {
  7251. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7252. if his.IdCardType == 1 {
  7253. bas := strings.Split(psn.CardInfo, "|")
  7254. basNumber := bas[1]
  7255. fmt.Println(basNumber)
  7256. card_sn := bas[3]
  7257. card_no := bas[2]
  7258. cFYLJG001.MdtrtCertType = "03"
  7259. cFYLJG001.CardSn = card_sn
  7260. cFYLJG001.MdtrtCertNo = card_no
  7261. cFYLJG001.EcToken = ""
  7262. cFYLJG001.AuthNo = ""
  7263. } else if his.IdCardType == 2 {
  7264. cFYLJG001.MdtrtCertType = "02"
  7265. cFYLJG001.CardSn = ""
  7266. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7267. cFYLJG001.EcToken = ""
  7268. cFYLJG001.AuthNo = ""
  7269. } else if his.IdCardType == 4 {
  7270. cFYLJG001.MdtrtCertType = "01"
  7271. cFYLJG001.CardSn = ""
  7272. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7273. cFYLJG001.EcToken = psn.VerifyNumber
  7274. cFYLJG001.AuthNo = ""
  7275. }
  7276. cFYLJG001.BizTypeCode = "01"
  7277. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7278. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7279. cFYLJG001.RxTypeCode = "1"
  7280. tempTime := time.Unix(item.PreTime, 0)
  7281. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7282. cFYLJG001.PrscTime = timeFormatOne
  7283. var count float64
  7284. if item.Type == 1 {
  7285. for _, sumItem := range item.HisDoctorAdviceInfo {
  7286. count = count + sumItem.PrescribingNumber
  7287. }
  7288. }
  7289. cFYLJG001.RxDrugCnt = count
  7290. cFYLJG001.ValiDays = "5"
  7291. ts := time.Unix(item.PreTime, 0)
  7292. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7293. tempTime3 := time.Unix(record_time2, 0)
  7294. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7295. cFYLJG001.ValiEndTime = timeFormat3
  7296. cFYLJG001.RxCotnFlag = "0"
  7297. for _, subItem := range item.HisDoctorAdviceInfo {
  7298. var drug models.RxDrug
  7299. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7300. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7301. drug.RxItemTypeCode = "11"
  7302. drug.DrugDosform = "乳膏剂" //TODO
  7303. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7304. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7305. }
  7306. drug.MedcWayDscr = subItem.DeliveryWay
  7307. tempTime2 := time.Unix(subItem.StartTime, 0)
  7308. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7309. drug.MedcBegntime = timeFormatTwo
  7310. if subItem.Day > 0 {
  7311. ts := time.Unix(subItem.StartTime, 0)
  7312. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7313. tempTime4 := time.Unix(record_time, 0)
  7314. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7315. drug.MedcEndtime = timeFormat5
  7316. } else {
  7317. tempTime2 := time.Unix(subItem.StartTime, 0)
  7318. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7319. drug.MedcEndtime = timeFormatTwo
  7320. }
  7321. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7322. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7323. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7324. drug.DrugCnt = subItem.PrescribingNumber
  7325. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7326. drug.DrugGenname = subItem.AdviceName
  7327. drug.MedcWayCodg = subItem.DeliveryWay
  7328. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7329. drug.SinDoscnt = subItem.SingleDose
  7330. drug.SinDosunt = subItem.SingleDoseUnit
  7331. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7332. drug.UsedFrquName = subItem.ExecutionFrequency
  7333. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7334. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7335. drug.HospApprFlag = "1"
  7336. cFYLJG001.List = append(cFYLJG001.List, drug)
  7337. }
  7338. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7339. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7340. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7341. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7342. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7343. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7344. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7345. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7346. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7347. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7348. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7349. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7350. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7351. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7352. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7353. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7354. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7355. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7356. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7357. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7358. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7359. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7360. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7361. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7362. tempTime2 := time.Now().Unix()
  7363. tempTime6 := time.Unix(tempTime2, 0)
  7364. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7365. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7366. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7367. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7368. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7369. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7370. //memo := make(map[string]interface{})
  7371. //inputData := make(map[string]interface{}, 0)
  7372. //type MyData struct {
  7373. // Insutype string `json:"insutype"`
  7374. //}
  7375. //
  7376. // data := MyData{
  7377. // Insutype: his.Insutype,
  7378. //}
  7379. //
  7380. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7381. var config []*models.HisXtDiagnoseConfig
  7382. for _, item := range diagnosis_ids {
  7383. id, _ := strconv.ParseInt(item, 10, 64)
  7384. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7385. config = append(config, &diagnosisConfig)
  7386. }
  7387. for index, subitem := range config {
  7388. if index == 0 {
  7389. var dia models.DiseInfo
  7390. dia.DiagType = "1"
  7391. dia.MaindiagFlag = "1"
  7392. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7393. dia.DiagCode = subitem.CountryCode
  7394. dia.DiagName = subitem.ClassName
  7395. dia.DiagDept = "肾内科"
  7396. dia.DiagDrNo = doctor.DoctorNumber
  7397. dia.DiagDrName = doctor.UserName
  7398. tempTime3 := time.Unix(item.PreTime, 0)
  7399. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7400. dia.DiagTime = timeFormatTwo
  7401. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7402. } else {
  7403. var dia models.DiseInfo
  7404. dia.DiagType = "1"
  7405. dia.MaindiagFlag = "0"
  7406. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7407. dia.DiagCode = subitem.CountryCode
  7408. dia.DiagName = subitem.ClassName
  7409. dia.DiagDept = "肾内科"
  7410. dia.DiagDrNo = doctor.DoctorNumber
  7411. dia.DiagDrName = doctor.UserName
  7412. tempTime3 := time.Unix(item.PreTime, 0)
  7413. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7414. dia.DiagTime = timeFormatTwo
  7415. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7416. }
  7417. }
  7418. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7419. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7420. var res ResultCFYLJG001
  7421. var respJSON2 map[string]interface{}
  7422. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7425. return
  7426. }
  7427. userJSONBytes2, _ := json.Marshal(respJSON2)
  7428. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7429. utils.ErrorLog("解析失败:%v", err)
  7430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7431. return
  7432. }
  7433. if res.Infcode == -1 {
  7434. c.ServeSuccessJSON(map[string]interface{}{
  7435. "failed_code": -10,
  7436. "msg": res.ErrMsg,
  7437. })
  7438. return
  7439. } else {
  7440. var flow models.HisPrescriptionFlow
  7441. flow.Ctime = time.Now().Unix()
  7442. flow.SignDigest = ""
  7443. flow.RxTraceCode = res.Output.RxTraceCode
  7444. flow.HiRxno = res.Output.HiRxno
  7445. flow.MID = his.Number
  7446. flow.Status = 1
  7447. flow.DCode = doctor_info.DoctorNumber
  7448. flow.OriginalRxFile = ""
  7449. flow.OriginalValue = ""
  7450. flow.SignCertDn = ""
  7451. flow.UserOrgId = 10454
  7452. flow.SignCertSn = ""
  7453. flow.Mtime = time.Now().Unix()
  7454. service.Createflow(&flow)
  7455. c.ServeSuccessJSON(map[string]interface{}{
  7456. "msg": "上传成功",
  7457. })
  7458. }
  7459. }
  7460. }
  7461. func (c *HisApiController) GetCFYLJG002() {
  7462. admin_user_id, _ := c.GetInt64("admin_user_id")
  7463. his_patient_id, _ := c.GetInt64("his_patient_id")
  7464. record_time := c.GetString("record_time")
  7465. admin_user_id = 3626
  7466. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7467. //id, _ := c.GetInt64("id")
  7468. admin_user_id = 3626
  7469. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7470. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7471. flow, _ := service.Getflowtwo(his.Number)
  7472. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7473. //record_time := c.GetString("record_time")
  7474. patient_id, _ := c.GetInt64("patient_id")
  7475. //patient_id = 23834
  7476. //record_time = "2023-09-18"
  7477. timeLayout := "2006-01-02"
  7478. loc, _ := time.LoadLocation("Local")
  7479. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7480. if err != nil {
  7481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7482. return
  7483. }
  7484. recordDateTime := theTime.Unix()
  7485. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7486. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7487. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7488. dept, _ := service.GetDepartMentDetail(info.Departments)
  7489. inputData := make(map[string]interface{})
  7490. inputData["rxTraceCode"] = flow.RxTraceCode
  7491. inputData["hiRxno"] = flow.HiRxno
  7492. inputData["mdtrtId"] = flow.MID
  7493. inputData["patnName"] = his.PsnName
  7494. inputData["psnCertType"] = his.PsnCertType
  7495. inputData["certno"] = his.Certno
  7496. inputData["fixmedinsName"] = miConfig.OrgName
  7497. inputData["fixmedinsCode"] = miConfig.Code
  7498. inputData["drCode"] = doctor_info.DoctorNumber
  7499. inputData["prscDrName"] = doctor_info.UserName
  7500. inputData["pharDeptName"] = dept.Name
  7501. inputData["pharDeptCode"] = dept.Number
  7502. inputData["pharProfttlCodg"] = dept.Name
  7503. inputData["pharProfttlName"] = ""
  7504. inputData["pharCode"] = "HY440309002107"
  7505. inputData["pharCertType"] = "01"
  7506. inputData["pharCertno"] = "430482199408260023"
  7507. inputData["pharName"] = "彭斯遥"
  7508. inputData["pharPracCertNo"] = ""
  7509. tempTime2 := time.Unix(info.Ctime, 0)
  7510. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7511. inputData["pharChkTime"] = timeFormatTwo
  7512. bytesData, _ := json.Marshal(inputData)
  7513. fmt.Println(string(bytesData))
  7514. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7515. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7516. if err != nil {
  7517. fmt.Println("Error reading PDF file:", err)
  7518. return
  7519. }
  7520. // 将 PDF 文件内容进行 Base64 编码
  7521. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7522. fmt.Println(err)
  7523. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7524. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7525. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7526. var res2 Result002
  7527. var respJSON2 map[string]interface{}
  7528. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7531. return
  7532. }
  7533. userJSONBytes2, _ := json.Marshal(respJSON2)
  7534. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7535. utils.ErrorLog("解析失败:%v", err)
  7536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7537. return
  7538. }
  7539. if res2.Infcode == 0 {
  7540. flow.Ctime = time.Now().Unix()
  7541. flow.SignDigest = res2.Output.SignDigest
  7542. flow.RxFile = res2.Output.RxFile
  7543. flow.MID = his.Number
  7544. flow.Status = 1
  7545. flow.DCode = doctor_info.DoctorNumber
  7546. flow.OriginalRxFile = rx_encoded
  7547. flow.OriginalValue = encoded
  7548. flow.SignCertDn = res2.Output.SignCertDn
  7549. flow.SignCertSn = res2.Output.SignCertSn
  7550. flow.Mtime = time.Now().Unix()
  7551. service.Saveflow(flow)
  7552. c.ServeSuccessJSON(map[string]interface{}{
  7553. "msg": "预签名成功",
  7554. })
  7555. } else {
  7556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7557. return
  7558. }
  7559. }
  7560. func (c *HisApiController) GetCFYLJG003() {
  7561. admin_user_id, _ := c.GetInt64("admin_user_id")
  7562. his_patient_id, _ := c.GetInt64("his_patient_id")
  7563. record_time := c.GetString("record_time")
  7564. admin_user_id = 3626
  7565. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7566. //id, _ := c.GetInt64("id")
  7567. admin_user_id = 3626
  7568. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7569. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7570. flow, _ := service.Getflowtwo(his.Number)
  7571. //id = 3
  7572. patient_id, _ := c.GetInt64("patient_id")
  7573. //patient_id = 23834
  7574. //record_time = "2023-09-18"
  7575. timeLayout := "2006-01-02"
  7576. loc, _ := time.LoadLocation("Local")
  7577. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7578. if err != nil {
  7579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7580. return
  7581. }
  7582. recordDateTime := theTime.Unix()
  7583. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7584. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7585. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7586. dept, _ := service.GetDepartMentDetail(info.Departments)
  7587. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7588. var cFYLJG003 models.CFYLJG003
  7589. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7590. cFYLJG003.HiRxno = flow.HiRxno
  7591. cFYLJG003.MdtrtID = flow.MID
  7592. cFYLJG003.PatnName = his.Name
  7593. cFYLJG003.Certno = his.Certno
  7594. cFYLJG003.FixmedinsName = miConfig.OrgName
  7595. cFYLJG003.FixmedinsCode = miConfig.Code
  7596. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7597. cFYLJG003.PrscDrName = doctor_info.UserName
  7598. cFYLJG003.PharDeptName = dept.Name
  7599. cFYLJG003.PharDeptCode = dept.Number
  7600. cFYLJG003.PharCode = "HY440309002107"
  7601. cFYLJG003.PharCertType = "01"
  7602. cFYLJG003.PharCertno = "430482199408260023"
  7603. cFYLJG003.PharName = "彭斯遥"
  7604. cFYLJG003.PsnCertType = "01"
  7605. cFYLJG003.RxFile = flow.RxFile
  7606. cFYLJG003.SignDigest = flow.SignDigest
  7607. cFYLJG003.FixmedinsCode = miConfig.Code
  7608. cFYLJG003.PsnCertType = "01"
  7609. cFYLJG003.PharProfttlCodg = dept.Name
  7610. //inputData["pharProfttlCodg"] =dept.Name
  7611. tempTime2 := time.Unix(info.Ctime, 0)
  7612. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7613. cFYLJG003.PharChkTime = timeFormatTwo
  7614. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7615. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7616. var res ResultCFYLJG003
  7617. var respJSON2 map[string]interface{}
  7618. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7621. return
  7622. }
  7623. userJSONBytes2, _ := json.Marshal(respJSON2)
  7624. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7625. utils.ErrorLog("解析失败:%v", err)
  7626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7627. return
  7628. }
  7629. if res.Infcode == -1 {
  7630. c.ServeSuccessJSON(map[string]interface{}{
  7631. "failed_code": -10,
  7632. "msg": res.ErrMsg,
  7633. })
  7634. return
  7635. } else {
  7636. c.ServeSuccessJSON(map[string]interface{}{
  7637. "info": res.Output,
  7638. })
  7639. }
  7640. }
  7641. func (c *HisApiController) GetCFYLJG004() {
  7642. admin_user_id, _ := c.GetInt64("admin_user_id")
  7643. his_patient_id, _ := c.GetInt64("his_patient_id")
  7644. record_time := c.GetString("record_time")
  7645. admin_user_id = 3626
  7646. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7647. //id, _ := c.GetInt64("id")
  7648. admin_user_id = 3626
  7649. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7650. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7651. flow, _ := service.Getflowtwo(his.Number)
  7652. //id = 3
  7653. patient_id, _ := c.GetInt64("patient_id")
  7654. //patient_id = 23834
  7655. //record_time = "2023-09-18"
  7656. timeLayout := "2006-01-02"
  7657. loc, _ := time.LoadLocation("Local")
  7658. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7659. if err != nil {
  7660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7661. return
  7662. }
  7663. recordDateTime := theTime.Unix()
  7664. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7665. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7666. var cFYLJG004 models.CFYLJG004
  7667. cFYLJG004.HiRxno = flow.HiRxno
  7668. cFYLJG004.FixmedinsCode = miConfig.Code
  7669. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7670. cFYLJG004.UndoDrCertType = "01"
  7671. cFYLJG004.UndoRea = "撤销处方"
  7672. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7673. cFYLJG004.UndoDrName = doctor_info.UserName
  7674. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7675. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7676. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7677. var res ResultCFYLJG004
  7678. var respJSON2 map[string]interface{}
  7679. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7682. return
  7683. }
  7684. userJSONBytes2, _ := json.Marshal(respJSON2)
  7685. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7686. utils.ErrorLog("解析失败:%v", err)
  7687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7688. return
  7689. }
  7690. if res.Infcode == -1 {
  7691. c.ServeSuccessJSON(map[string]interface{}{
  7692. "failed_code": -10,
  7693. "msg": res.ErrMsg,
  7694. })
  7695. return
  7696. } else {
  7697. flow.Status = 0
  7698. service.Saveflow(flow)
  7699. c.ServeSuccessJSON(map[string]interface{}{
  7700. "msg": "撤销成功",
  7701. })
  7702. return
  7703. }
  7704. }
  7705. func (c *HisApiController) GetCFYLJG005() {
  7706. admin_user_id, _ := c.GetInt64("admin_user_id")
  7707. his_patient_id, _ := c.GetInt64("his_patient_id")
  7708. //record_time := c.GetString("record_time")
  7709. admin_user_id = 3626
  7710. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7711. //id, _ := c.GetInt64("id")
  7712. admin_user_id = 3626
  7713. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7714. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7715. flow, _ := service.Getflowtwo(his.Number)
  7716. //id = 3
  7717. var cFYLJG005 models.CFYLJG005
  7718. //patient_id, _ := c.GetInt64("patient_id")
  7719. cFYLJG005.HiRxno = flow.HiRxno
  7720. cFYLJG005.MdtrtID = flow.MID
  7721. cFYLJG005.EcToken = ""
  7722. cFYLJG005.PsnName = his.Name
  7723. cFYLJG005.PsnCertType = "01"
  7724. cFYLJG005.Certno = his.IdCardNo
  7725. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7726. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7727. var res ResultCFYLJG005
  7728. var respJSON2 map[string]interface{}
  7729. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7732. return
  7733. }
  7734. userJSONBytes2, _ := json.Marshal(respJSON2)
  7735. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7736. utils.ErrorLog("解析失败:%v", err)
  7737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7738. return
  7739. }
  7740. if res.Infcode == -1 {
  7741. c.ServeSuccessJSON(map[string]interface{}{
  7742. "failed_code": -10,
  7743. "msg": res.ErrMsg,
  7744. })
  7745. return
  7746. } else {
  7747. c.ServeSuccessJSON(map[string]interface{}{
  7748. "info": res.Output,
  7749. })
  7750. return
  7751. }
  7752. }
  7753. func (c *HisApiController) GetCFYLJG006() {
  7754. admin_user_id, _ := c.GetInt64("admin_user_id")
  7755. his_patient_id, _ := c.GetInt64("his_patient_id")
  7756. admin_user_id = 3626
  7757. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7758. //id, _ := c.GetInt64("id")
  7759. admin_user_id = 3626
  7760. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7761. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7762. flow, _ := service.Getflowtwo(his.Number)
  7763. //id = 3
  7764. patient_id, _ := c.GetInt64("patient_id")
  7765. var cFYLJG006 models.CFYLJG006
  7766. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7767. cFYLJG006.HiRxno = flow.HiRxno
  7768. cFYLJG006.MdtrtID = flow.MID
  7769. cFYLJG006.PsnName = patient.Name
  7770. cFYLJG006.PsnCertType = "01"
  7771. cFYLJG006.Certno = patient.IdCardNo
  7772. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7773. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7774. var res ResultCFYLJG006
  7775. var respJSON2 map[string]interface{}
  7776. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7779. return
  7780. }
  7781. userJSONBytes2, _ := json.Marshal(respJSON2)
  7782. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7783. utils.ErrorLog("解析失败:%v", err)
  7784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. return
  7786. }
  7787. if res.Infcode == -1 {
  7788. c.ServeSuccessJSON(map[string]interface{}{
  7789. "failed_code": -10,
  7790. "msg": res.ErrMsg,
  7791. })
  7792. return
  7793. } else {
  7794. c.ServeSuccessJSON(map[string]interface{}{
  7795. "info": res.Output,
  7796. })
  7797. return
  7798. }
  7799. }
  7800. func (c *HisApiController) GetCFYLJG007() {
  7801. admin_user_id, _ := c.GetInt64("admin_user_id")
  7802. his_patient_id, _ := c.GetInt64("his_patient_id")
  7803. admin_user_id = 3626
  7804. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7805. //id, _ := c.GetInt64("id")
  7806. admin_user_id = 3626
  7807. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7808. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7809. flow, _ := service.Getflowtwo(his.Number)
  7810. //id = 3
  7811. patient_id, _ := c.GetInt64("patient_id")
  7812. var cFYLJG007 models.CFYLJG007
  7813. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7814. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7815. cFYLJG007.HiRxno = flow.HiRxno
  7816. cFYLJG007.MdtrtID = flow.MID
  7817. cFYLJG007.PsnNo = his.PsnNo
  7818. cFYLJG007.PsnCertType = "01"
  7819. cFYLJG007.Certno = patient.IdCardNo
  7820. cFYLJG007.PsnName = patient.Name
  7821. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7822. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7823. var res ResultCFYLJG007
  7824. var respJSON2 map[string]interface{}
  7825. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7828. return
  7829. }
  7830. userJSONBytes2, _ := json.Marshal(respJSON2)
  7831. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7832. utils.ErrorLog("解析失败:%v", err)
  7833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7834. return
  7835. }
  7836. if res.Infcode == -1 {
  7837. c.ServeSuccessJSON(map[string]interface{}{
  7838. "failed_code": -10,
  7839. "msg": res.ErrMsg,
  7840. })
  7841. return
  7842. } else {
  7843. c.ServeSuccessJSON(map[string]interface{}{
  7844. "info": res,
  7845. })
  7846. return
  7847. }
  7848. }
  7849. func (c *HisApiController) GetCFYLJG008() {
  7850. admin_user_id, _ := c.GetInt64("admin_user_id")
  7851. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7852. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7853. var cFYLJG008 models.CFYLJG008
  7854. //id, _ := c.GetInt64("id")
  7855. patient_id, _ := c.GetInt64("patient_id")
  7856. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7857. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7858. //id = 3
  7859. //flow, _ := service.Getflow(id)
  7860. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7861. //
  7862. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7863. //patient_id, _ := c.GetInt64("patient_id")
  7864. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7865. record_time := c.GetString("record_time")
  7866. admin_user_id = 3626
  7867. patient_id = 19424
  7868. //his_patient_id = 263947
  7869. record_time = "2023-08-29"
  7870. timeLayout := "2006-01-02"
  7871. loc, _ := time.LoadLocation("Local")
  7872. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7873. if err != nil {
  7874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7875. return
  7876. }
  7877. recordDateTime := theTime.Unix()
  7878. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7879. cFYLJG008.FixmedinsName = ""
  7880. cFYLJG008.Lat = ""
  7881. cFYLJG008.Lng = ""
  7882. cFYLJG008.OrderType = "1"
  7883. cFYLJG008.PoolareaNo = ""
  7884. cFYLJG008.Lng = ""
  7885. cFYLJG008.PageNum = 1
  7886. cFYLJG008.PageSize = 10
  7887. var MPI models.MedinsProdInvChgDDTO
  7888. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  7889. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  7890. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  7891. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  7892. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  7893. var res ResultCFYLJG008
  7894. var respJSON2 map[string]interface{}
  7895. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7898. return
  7899. }
  7900. userJSONBytes2, _ := json.Marshal(respJSON2)
  7901. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7902. utils.ErrorLog("解析失败:%v", err)
  7903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7904. return
  7905. }
  7906. if res.Infcode == -1 {
  7907. c.ServeSuccessJSON(map[string]interface{}{
  7908. "failed_code": -10,
  7909. "msg": res.ErrMsg,
  7910. })
  7911. return
  7912. } else {
  7913. c.ServeSuccessJSON(map[string]interface{}{
  7914. "info": res.Output,
  7915. })
  7916. return
  7917. }
  7918. }
  7919. func (c *HisApiController) GetBL4201A() {
  7920. order_id, _ := c.GetInt64("order_id")
  7921. admin_user_id, _ := c.GetInt64("admin_user_id")
  7922. order, _ := service.GetHisOrderByIDTwo(order_id)
  7923. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7924. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7925. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7926. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7927. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7928. department, _ := service.GetDepartMentDetail(his.Departments)
  7929. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7930. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7931. if order.ID == 0 {
  7932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7933. return
  7934. }
  7935. var struct4201A models.Struct4201A
  7936. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7937. for _, items := range order_info {
  7938. memo := make(map[string]interface{})
  7939. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7940. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7941. fsiOPFLD.MedType = "14"
  7942. fsiOPFLD.BkkpSn = items.FeedetlSn
  7943. fsiOPFLD.FixmedinsCode = miConfig.Code
  7944. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7945. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7946. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7947. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7948. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7949. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7950. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7951. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7952. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7953. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7954. fsiOPFLD.BilgDeptName = department.Name
  7955. fsiOPFLD.BilgDeptCodg = department.Number
  7956. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7957. fsiOPFLD.BilgDrName = doctor.UserName
  7958. fsiOPFLD.MedChrgitmType = "09"
  7959. memo["hosp_appr_flag"] = "1"
  7960. memo["invoice_no"] = order.MdtrtId
  7961. memo["memo"] = "自费"
  7962. bytesData, _ := json.Marshal(memo)
  7963. fsiOPFLD.Memo = string(bytesData)
  7964. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7965. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7966. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7967. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7968. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7969. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7970. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7971. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7972. fsiOPFLD.BilgDeptName = department.Name
  7973. fsiOPFLD.BilgDeptCodg = department.Number
  7974. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7975. fsiOPFLD.BilgDrName = doctor.UserName
  7976. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7977. case 0:
  7978. break
  7979. case 1:
  7980. fsiOPFLD.MedChrgitmType = "14"
  7981. break
  7982. case 2:
  7983. fsiOPFLD.MedChrgitmType = "05"
  7984. break
  7985. case 3:
  7986. fsiOPFLD.MedChrgitmType = "03"
  7987. break
  7988. case 4:
  7989. fsiOPFLD.MedChrgitmType = "03"
  7990. break
  7991. case 5:
  7992. fsiOPFLD.MedChrgitmType = "08"
  7993. break
  7994. case 6:
  7995. fsiOPFLD.MedChrgitmType = "14"
  7996. break
  7997. case 7:
  7998. fsiOPFLD.MedChrgitmType = "14"
  7999. break
  8000. case 8:
  8001. fsiOPFLD.MedChrgitmType = "03"
  8002. break
  8003. case 9:
  8004. fsiOPFLD.MedChrgitmType = "14"
  8005. break
  8006. case 10:
  8007. fsiOPFLD.MedChrgitmType = "14"
  8008. break
  8009. case 11:
  8010. fsiOPFLD.MedChrgitmType = "06"
  8011. break
  8012. case 12:
  8013. fsiOPFLD.MedChrgitmType = "12"
  8014. break
  8015. case 13:
  8016. fsiOPFLD.MedChrgitmType = "01"
  8017. break
  8018. case 14:
  8019. fsiOPFLD.MedChrgitmType = "04"
  8020. break
  8021. case 15:
  8022. fsiOPFLD.MedChrgitmType = "14"
  8023. break
  8024. }
  8025. memo["hosp_appr_flag"] = "1"
  8026. memo["invoice_no"] = order.MdtrtId
  8027. memo["memo"] = "自费"
  8028. bytesData, _ := json.Marshal(memo)
  8029. fsiOPFLD.Memo = string(bytesData)
  8030. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8031. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8032. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8033. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8034. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8035. fsiOPFLD.BilgDeptName = department.Name
  8036. fsiOPFLD.BilgDeptCodg = department.Number
  8037. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8038. fsiOPFLD.BilgDrName = doctor.UserName
  8039. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8040. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8041. fsiOPFLD.MedChrgitmType = "08"
  8042. memo["hosp_appr_flag"] = "1"
  8043. memo["invoice_no"] = order.MdtrtId
  8044. memo["memo"] = "自费"
  8045. bytesData, _ := json.Marshal(memo)
  8046. fsiOPFLD.Memo = string(bytesData)
  8047. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8048. }
  8049. }
  8050. }
  8051. for _, items := range order_info_two {
  8052. memo := make(map[string]interface{})
  8053. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8054. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8055. fsiOPFLD.MedType = "14"
  8056. fsiOPFLD.BkkpSn = items.FeedetlSn
  8057. fsiOPFLD.FixmedinsCode = miConfig.Code
  8058. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8059. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8060. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8061. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8062. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8063. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8064. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8065. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8066. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8067. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8068. fsiOPFLD.BilgDeptName = department.Name
  8069. fsiOPFLD.BilgDeptCodg = department.Number
  8070. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8071. fsiOPFLD.BilgDrName = doctor.UserName
  8072. fsiOPFLD.MedChrgitmType = "09"
  8073. memo["hosp_appr_flag"] = "1"
  8074. memo["invoice_no"] = order.MdtrtId
  8075. memo["memo"] = "自费"
  8076. bytesData, _ := json.Marshal(memo)
  8077. fsiOPFLD.Memo = string(bytesData)
  8078. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8079. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8080. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8081. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8082. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8083. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8084. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8085. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8086. fsiOPFLD.BilgDeptName = department.Name
  8087. fsiOPFLD.BilgDeptCodg = department.Number
  8088. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8089. fsiOPFLD.BilgDrName = doctor.UserName
  8090. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8091. case 0:
  8092. break
  8093. case 1:
  8094. fsiOPFLD.MedChrgitmType = "14"
  8095. break
  8096. case 2:
  8097. fsiOPFLD.MedChrgitmType = "05"
  8098. break
  8099. case 3:
  8100. fsiOPFLD.MedChrgitmType = "03"
  8101. break
  8102. case 4:
  8103. fsiOPFLD.MedChrgitmType = "03"
  8104. break
  8105. case 5:
  8106. fsiOPFLD.MedChrgitmType = "08"
  8107. break
  8108. case 6:
  8109. fsiOPFLD.MedChrgitmType = "14"
  8110. break
  8111. case 7:
  8112. fsiOPFLD.MedChrgitmType = "14"
  8113. break
  8114. case 8:
  8115. fsiOPFLD.MedChrgitmType = "03"
  8116. break
  8117. case 9:
  8118. fsiOPFLD.MedChrgitmType = "14"
  8119. break
  8120. case 10:
  8121. fsiOPFLD.MedChrgitmType = "14"
  8122. break
  8123. case 11:
  8124. fsiOPFLD.MedChrgitmType = "06"
  8125. break
  8126. case 12:
  8127. fsiOPFLD.MedChrgitmType = "12"
  8128. break
  8129. case 13:
  8130. fsiOPFLD.MedChrgitmType = "01"
  8131. break
  8132. case 14:
  8133. fsiOPFLD.MedChrgitmType = "04"
  8134. break
  8135. case 15:
  8136. fsiOPFLD.MedChrgitmType = "14"
  8137. break
  8138. }
  8139. memo["hosp_appr_flag"] = "1"
  8140. memo["invoice_no"] = order.MdtrtId
  8141. memo["memo"] = "自费"
  8142. bytesData, _ := json.Marshal(memo)
  8143. fsiOPFLD.Memo = string(bytesData)
  8144. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8145. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8146. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8147. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8148. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8149. fsiOPFLD.BilgDeptName = department.Name
  8150. fsiOPFLD.BilgDeptCodg = department.Number
  8151. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8152. fsiOPFLD.BilgDrName = doctor.UserName
  8153. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8154. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8155. fsiOPFLD.MedChrgitmType = "08"
  8156. memo["hosp_appr_flag"] = "1"
  8157. memo["invoice_no"] = order.MdtrtId
  8158. memo["memo"] = "自费"
  8159. bytesData, _ := json.Marshal(memo)
  8160. fsiOPFLD.Memo = string(bytesData)
  8161. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8162. }
  8163. }
  8164. }
  8165. fmt.Println(fsiOPFLDs)
  8166. struct4201A.Fopfd = fsiOPFLDs
  8167. fmt.Println(struct4201A.Fopfd)
  8168. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8169. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8170. var res2 ResultSix
  8171. var respJSON2 map[string]interface{}
  8172. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8175. return
  8176. }
  8177. userJSONBytes2, _ := json.Marshal(respJSON2)
  8178. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8179. utils.ErrorLog("解析失败:%v", err)
  8180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8181. return
  8182. }
  8183. if res2.Infcode != 0 {
  8184. c.ServeSuccessJSON(map[string]interface{}{
  8185. "failed_code": -10,
  8186. "msg": res2.ErrMsg,
  8187. })
  8188. return
  8189. } else {
  8190. order.IsUploadOrderInfo = 1
  8191. service.UpdateOrder(order)
  8192. c.ServeSuccessJSON(map[string]interface{}{
  8193. "msg": "上传成功",
  8194. })
  8195. }
  8196. }
  8197. func (c *HisApiController) Get2505() {
  8198. admin_user_id, _ := c.GetInt64("admin_user_id")
  8199. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8200. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8201. 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)
  8202. }
  8203. func (c *HisApiController) Get4201A() {
  8204. order_id, _ := c.GetInt64("order_id")
  8205. admin_user_id, _ := c.GetInt64("admin_user_id")
  8206. order, _ := service.GetHisOrderByIDTwo(order_id)
  8207. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8208. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8209. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8210. //order_info = append(order_info, order_info_two...)
  8211. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8212. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8213. department, _ := service.GetDepartMentDetail(his.Departments)
  8214. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8215. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8216. if order.ID == 0 {
  8217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8218. return
  8219. }
  8220. var struct4201A models.Struct4201A
  8221. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8222. for _, items := range order_info {
  8223. memo := make(map[string]interface{})
  8224. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8225. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8226. fsiOPFLD.MedType = "14"
  8227. fsiOPFLD.BkkpSn = items.FeedetlSn
  8228. fsiOPFLD.FixmedinsCode = miConfig.Code
  8229. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8230. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8231. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8232. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8233. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8234. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8235. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8236. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8237. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8238. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8239. fsiOPFLD.BilgDeptName = department.Name
  8240. fsiOPFLD.BilgDeptCodg = department.Number
  8241. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8242. fsiOPFLD.BilgDrName = doctor.UserName
  8243. fsiOPFLD.MedChrgitmType = "09"
  8244. memo["hosp_appr_flag"] = "1"
  8245. memo["invoice_no"] = order.MdtrtId
  8246. memo["memo"] = "自费"
  8247. bytesData, _ := json.Marshal(memo)
  8248. fsiOPFLD.Memo = string(bytesData)
  8249. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8250. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8251. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8252. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8253. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8254. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8255. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8256. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8257. fsiOPFLD.BilgDeptName = department.Name
  8258. fsiOPFLD.BilgDeptCodg = department.Number
  8259. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8260. fsiOPFLD.BilgDrName = doctor.UserName
  8261. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8262. case 0:
  8263. break
  8264. case 1:
  8265. fsiOPFLD.MedChrgitmType = "14"
  8266. break
  8267. case 2:
  8268. fsiOPFLD.MedChrgitmType = "05"
  8269. break
  8270. case 3:
  8271. fsiOPFLD.MedChrgitmType = "03"
  8272. break
  8273. case 4:
  8274. fsiOPFLD.MedChrgitmType = "03"
  8275. break
  8276. case 5:
  8277. fsiOPFLD.MedChrgitmType = "08"
  8278. break
  8279. case 6:
  8280. fsiOPFLD.MedChrgitmType = "14"
  8281. break
  8282. case 7:
  8283. fsiOPFLD.MedChrgitmType = "14"
  8284. break
  8285. case 8:
  8286. fsiOPFLD.MedChrgitmType = "03"
  8287. break
  8288. case 9:
  8289. fsiOPFLD.MedChrgitmType = "14"
  8290. break
  8291. case 10:
  8292. fsiOPFLD.MedChrgitmType = "14"
  8293. break
  8294. case 11:
  8295. fsiOPFLD.MedChrgitmType = "06"
  8296. break
  8297. case 12:
  8298. fsiOPFLD.MedChrgitmType = "12"
  8299. break
  8300. case 13:
  8301. fsiOPFLD.MedChrgitmType = "01"
  8302. break
  8303. case 14:
  8304. fsiOPFLD.MedChrgitmType = "04"
  8305. break
  8306. case 15:
  8307. fsiOPFLD.MedChrgitmType = "14"
  8308. break
  8309. }
  8310. memo["hosp_appr_flag"] = "1"
  8311. memo["invoice_no"] = order.MdtrtId
  8312. memo["memo"] = "自费"
  8313. bytesData, _ := json.Marshal(memo)
  8314. fsiOPFLD.Memo = string(bytesData)
  8315. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8316. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8317. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8318. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8319. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8320. fsiOPFLD.BilgDeptName = department.Name
  8321. fsiOPFLD.BilgDeptCodg = department.Number
  8322. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8323. fsiOPFLD.BilgDrName = doctor.UserName
  8324. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8325. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8326. fsiOPFLD.MedChrgitmType = "08"
  8327. memo["hosp_appr_flag"] = "1"
  8328. memo["invoice_no"] = order.MdtrtId
  8329. memo["memo"] = "自费"
  8330. bytesData, _ := json.Marshal(memo)
  8331. fsiOPFLD.Memo = string(bytesData)
  8332. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8333. }
  8334. }
  8335. }
  8336. for _, items := range order_info_two {
  8337. memo := make(map[string]interface{})
  8338. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8339. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8340. fsiOPFLD.MedType = "14"
  8341. fsiOPFLD.BkkpSn = items.FeedetlSn
  8342. fsiOPFLD.FixmedinsCode = miConfig.Code
  8343. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8344. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8345. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8346. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8347. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8348. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8349. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8350. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8351. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8352. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8353. fsiOPFLD.BilgDeptName = department.Name
  8354. fsiOPFLD.BilgDeptCodg = department.Number
  8355. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8356. fsiOPFLD.BilgDrName = doctor.UserName
  8357. fsiOPFLD.MedChrgitmType = "09"
  8358. memo["hosp_appr_flag"] = "1"
  8359. memo["invoice_no"] = order.MdtrtId
  8360. memo["memo"] = "自费"
  8361. bytesData, _ := json.Marshal(memo)
  8362. fsiOPFLD.Memo = string(bytesData)
  8363. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8364. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8365. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8366. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8367. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8368. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8369. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8370. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8371. fsiOPFLD.BilgDeptName = department.Name
  8372. fsiOPFLD.BilgDeptCodg = department.Number
  8373. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8374. fsiOPFLD.BilgDrName = doctor.UserName
  8375. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8376. case 0:
  8377. break
  8378. case 1:
  8379. fsiOPFLD.MedChrgitmType = "14"
  8380. break
  8381. case 2:
  8382. fsiOPFLD.MedChrgitmType = "05"
  8383. break
  8384. case 3:
  8385. fsiOPFLD.MedChrgitmType = "03"
  8386. break
  8387. case 4:
  8388. fsiOPFLD.MedChrgitmType = "03"
  8389. break
  8390. case 5:
  8391. fsiOPFLD.MedChrgitmType = "08"
  8392. break
  8393. case 6:
  8394. fsiOPFLD.MedChrgitmType = "14"
  8395. break
  8396. case 7:
  8397. fsiOPFLD.MedChrgitmType = "14"
  8398. break
  8399. case 8:
  8400. fsiOPFLD.MedChrgitmType = "03"
  8401. break
  8402. case 9:
  8403. fsiOPFLD.MedChrgitmType = "14"
  8404. break
  8405. case 10:
  8406. fsiOPFLD.MedChrgitmType = "14"
  8407. break
  8408. case 11:
  8409. fsiOPFLD.MedChrgitmType = "06"
  8410. break
  8411. case 12:
  8412. fsiOPFLD.MedChrgitmType = "12"
  8413. break
  8414. case 13:
  8415. fsiOPFLD.MedChrgitmType = "01"
  8416. break
  8417. case 14:
  8418. fsiOPFLD.MedChrgitmType = "04"
  8419. break
  8420. case 15:
  8421. fsiOPFLD.MedChrgitmType = "14"
  8422. break
  8423. }
  8424. memo["hosp_appr_flag"] = "1"
  8425. memo["invoice_no"] = order.MdtrtId
  8426. memo["memo"] = "自费"
  8427. bytesData, _ := json.Marshal(memo)
  8428. fsiOPFLD.Memo = string(bytesData)
  8429. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8430. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8431. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8432. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8433. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8434. fsiOPFLD.BilgDeptName = department.Name
  8435. fsiOPFLD.BilgDeptCodg = department.Number
  8436. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8437. fsiOPFLD.BilgDrName = doctor.UserName
  8438. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8439. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8440. fsiOPFLD.MedChrgitmType = "08"
  8441. memo["hosp_appr_flag"] = "1"
  8442. memo["invoice_no"] = order.MdtrtId
  8443. memo["memo"] = "自费"
  8444. bytesData, _ := json.Marshal(memo)
  8445. fsiOPFLD.Memo = string(bytesData)
  8446. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8447. }
  8448. }
  8449. }
  8450. fmt.Println(fsiOPFLDs)
  8451. struct4201A.Fopfd = fsiOPFLDs
  8452. fmt.Println(struct4201A.Fopfd)
  8453. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8454. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8455. var res2 ResultSix
  8456. var respJSON2 map[string]interface{}
  8457. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8460. return
  8461. }
  8462. userJSONBytes2, _ := json.Marshal(respJSON2)
  8463. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8464. utils.ErrorLog("解析失败:%v", err)
  8465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8466. return
  8467. }
  8468. if res2.Infcode != 0 {
  8469. c.ServeSuccessJSON(map[string]interface{}{
  8470. "failed_code": -10,
  8471. "msg": res2.ErrMsg,
  8472. })
  8473. return
  8474. } else {
  8475. order.IsUploadOrderInfo = 1
  8476. service.UpdateOrder(order)
  8477. c.ServeSuccessJSON(map[string]interface{}{
  8478. "msg": "上传成功",
  8479. })
  8480. }
  8481. }
  8482. func (c *HisApiController) Get4202() {
  8483. order_id, _ := c.GetInt64("order_id")
  8484. admin_user_id, _ := c.GetInt64("admin_user_id")
  8485. order, _ := service.GetHisOrderByIDTwo(order_id)
  8486. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8487. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8488. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8489. if order.ID == 0 {
  8490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8491. return
  8492. }
  8493. var struct4202 models.Struct4202
  8494. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8495. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8496. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8497. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8498. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8499. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8500. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8501. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8502. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8503. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8504. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8505. var config []*models.HisXtDiagnoseConfig
  8506. for _, item := range diagnosis_ids {
  8507. id, _ := strconv.ParseInt(item, 10, 64)
  8508. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8509. config = append(config, &diagnosisConfig)
  8510. }
  8511. var tempDiaginfos []models.OwnPayPatnDiagListD
  8512. for index, item := range config {
  8513. if index == 0 {
  8514. var tempDiaginfo models.OwnPayPatnDiagListD
  8515. tempDiaginfo.InoutDiagType = "1"
  8516. tempDiaginfo.DiagCode = item.CountryCode
  8517. tempDiaginfo.DiagName = item.CountryContentName
  8518. tempDiaginfo.DiagType = "1"
  8519. tempDiaginfo.DiagSrtNo = "1"
  8520. tempDiaginfo.MaindiagFlag = "1"
  8521. tempDiaginfo.ValiFlag = "1"
  8522. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8523. } else {
  8524. var tempDiaginfo models.OwnPayPatnDiagListD
  8525. tempDiaginfo.DiagCode = item.CountryCode
  8526. tempDiaginfo.DiagName = item.CountryContentName
  8527. tempDiaginfo.DiagType = "2"
  8528. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8529. tempDiaginfo.MaindiagFlag = "0"
  8530. tempDiaginfo.ValiFlag = "1"
  8531. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8532. }
  8533. }
  8534. struct4202.ODiagListD = tempDiaginfos
  8535. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8536. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8537. var res2 ResultSix
  8538. var respJSON2 map[string]interface{}
  8539. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8542. return
  8543. }
  8544. userJSONBytes2, _ := json.Marshal(respJSON2)
  8545. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8546. utils.ErrorLog("解析失败:%v", err)
  8547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8548. return
  8549. }
  8550. if res2.Infcode != 0 {
  8551. c.ServeSuccessJSON(map[string]interface{}{
  8552. "failed_code": -10,
  8553. "msg": res2.ErrMsg,
  8554. })
  8555. return
  8556. } else {
  8557. order.IsUploadDiagnose = 1
  8558. service.UpdateOrder(order)
  8559. c.ServeSuccessJSON(map[string]interface{}{
  8560. "msg": "上传成功",
  8561. })
  8562. }
  8563. }
  8564. func (c *HisApiController) Get4203() {
  8565. admin_user_id, _ := c.GetInt64("admin_user_id")
  8566. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8567. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8568. order_id, _ := c.GetInt64("order_id")
  8569. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8570. number := ""
  8571. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8572. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8573. if his.ID == 0 {
  8574. number = hospital.Number
  8575. } else {
  8576. number = his.Number
  8577. }
  8578. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8579. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8580. var res2 ResultSix
  8581. var respJSON2 map[string]interface{}
  8582. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8585. return
  8586. }
  8587. userJSONBytes2, _ := json.Marshal(respJSON2)
  8588. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8589. utils.ErrorLog("解析失败:%v", err)
  8590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8591. return
  8592. }
  8593. if res2.Infcode != 0 {
  8594. c.ServeSuccessJSON(map[string]interface{}{
  8595. "failed_code": -10,
  8596. "msg": res2.ErrMsg,
  8597. })
  8598. return
  8599. } else {
  8600. order.IsUploadSuccess = 1
  8601. service.UpdateOrderTwo(order)
  8602. c.ServeSuccessJSON(map[string]interface{}{
  8603. "msg": "上传成功",
  8604. })
  8605. }
  8606. }
  8607. func (c *HisApiController) Get4205() {
  8608. order_id, _ := c.GetInt64("order_id")
  8609. admin_user_id, _ := c.GetInt64("admin_user_id")
  8610. fapiao_code := c.GetString("fapiao_code")
  8611. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8612. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8613. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8614. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8615. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8616. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8617. //order_info = append(order_info, order_info_two...)
  8618. department, _ := service.GetDepartMentDetail(his.Departments)
  8619. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8620. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8621. if order.ID == 0 {
  8622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8623. return
  8624. }
  8625. var struct4201A models.Struct4201A
  8626. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8627. for _, items := range order_info {
  8628. memo := make(map[string]interface{})
  8629. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8630. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8631. fsiOPFLD.MedType = pre.MedType
  8632. fsiOPFLD.FixmedinsCode = miConfig.Code
  8633. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8634. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8635. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8636. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8637. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8638. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8639. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8640. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8641. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8642. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8643. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8644. fsiOPFLD.BilgDeptName = department.Name
  8645. fsiOPFLD.BilgDeptCodg = department.Number
  8646. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8647. fsiOPFLD.BilgDrName = doctor.UserName
  8648. fsiOPFLD.MedChrgitmType = "09"
  8649. memo["hosp_appr_flag"] = "1"
  8650. memo["invoice_no"] = fapiao_code
  8651. memo["memo"] = "自费"
  8652. bytesData, _ := json.Marshal(memo)
  8653. fsiOPFLD.Memo = string(bytesData)
  8654. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8655. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8656. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8657. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8658. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8659. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8660. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8661. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8662. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8663. fsiOPFLD.BilgDeptName = department.Name
  8664. fsiOPFLD.BilgDeptCodg = department.Number
  8665. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8666. fsiOPFLD.BilgDrName = doctor.UserName
  8667. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8668. case 0:
  8669. break
  8670. case 1:
  8671. fsiOPFLD.MedChrgitmType = "14"
  8672. break
  8673. case 2:
  8674. fsiOPFLD.MedChrgitmType = "05"
  8675. break
  8676. case 3:
  8677. fsiOPFLD.MedChrgitmType = "03"
  8678. break
  8679. case 4:
  8680. fsiOPFLD.MedChrgitmType = "03"
  8681. break
  8682. case 5:
  8683. fsiOPFLD.MedChrgitmType = "08"
  8684. break
  8685. case 6:
  8686. fsiOPFLD.MedChrgitmType = "14"
  8687. break
  8688. case 7:
  8689. fsiOPFLD.MedChrgitmType = "14"
  8690. break
  8691. case 8:
  8692. fsiOPFLD.MedChrgitmType = "03"
  8693. break
  8694. case 9:
  8695. fsiOPFLD.MedChrgitmType = "14"
  8696. break
  8697. case 10:
  8698. fsiOPFLD.MedChrgitmType = "14"
  8699. break
  8700. case 11:
  8701. fsiOPFLD.MedChrgitmType = "06"
  8702. break
  8703. case 12:
  8704. fsiOPFLD.MedChrgitmType = "12"
  8705. break
  8706. case 13:
  8707. fsiOPFLD.MedChrgitmType = "01"
  8708. break
  8709. case 14:
  8710. fsiOPFLD.MedChrgitmType = "04"
  8711. break
  8712. case 15:
  8713. fsiOPFLD.MedChrgitmType = "14"
  8714. break
  8715. }
  8716. memo["hosp_appr_flag"] = "1"
  8717. memo["invoice_no"] = fapiao_code
  8718. memo["memo"] = "自费"
  8719. bytesData, _ := json.Marshal(memo)
  8720. fsiOPFLD.Memo = string(bytesData)
  8721. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8722. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8723. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8724. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8725. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8726. fsiOPFLD.BilgDeptName = department.Name
  8727. fsiOPFLD.BilgDeptCodg = department.Number
  8728. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8729. fsiOPFLD.BilgDrName = doctor.UserName
  8730. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8731. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8732. fsiOPFLD.MedChrgitmType = "08"
  8733. memo["hosp_appr_flag"] = "1"
  8734. memo["invoice_no"] = fapiao_code
  8735. memo["memo"] = "自费"
  8736. bytesData, _ := json.Marshal(memo)
  8737. fsiOPFLD.Memo = string(bytesData)
  8738. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8739. }
  8740. }
  8741. }
  8742. for _, items := range order_info_two {
  8743. memo := make(map[string]interface{})
  8744. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8745. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8746. fsiOPFLD.MedType = pre.MedType
  8747. fsiOPFLD.BkkpSn = items.FeedetlSn
  8748. fsiOPFLD.FixmedinsCode = miConfig.Code
  8749. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8750. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8751. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8752. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8753. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8754. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8755. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8756. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8757. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8758. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8759. fsiOPFLD.BilgDeptName = department.Name
  8760. fsiOPFLD.BilgDeptCodg = department.Number
  8761. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8762. fsiOPFLD.BilgDrName = doctor.UserName
  8763. fsiOPFLD.MedChrgitmType = "09"
  8764. memo["hosp_appr_flag"] = "1"
  8765. memo["invoice_no"] = fapiao_code
  8766. memo["memo"] = "自费"
  8767. bytesData, _ := json.Marshal(memo)
  8768. fsiOPFLD.Memo = string(bytesData)
  8769. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8770. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8771. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8772. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8773. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8774. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8775. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8776. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8777. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8778. fsiOPFLD.BilgDeptName = department.Name
  8779. fsiOPFLD.BilgDeptCodg = department.Number
  8780. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8781. fsiOPFLD.BilgDrName = doctor.UserName
  8782. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8783. case 0:
  8784. break
  8785. case 1:
  8786. fsiOPFLD.MedChrgitmType = "14"
  8787. break
  8788. case 2:
  8789. fsiOPFLD.MedChrgitmType = "05"
  8790. break
  8791. case 3:
  8792. fsiOPFLD.MedChrgitmType = "03"
  8793. break
  8794. case 4:
  8795. fsiOPFLD.MedChrgitmType = "03"
  8796. break
  8797. case 5:
  8798. fsiOPFLD.MedChrgitmType = "08"
  8799. break
  8800. case 6:
  8801. fsiOPFLD.MedChrgitmType = "14"
  8802. break
  8803. case 7:
  8804. fsiOPFLD.MedChrgitmType = "14"
  8805. break
  8806. case 8:
  8807. fsiOPFLD.MedChrgitmType = "03"
  8808. break
  8809. case 9:
  8810. fsiOPFLD.MedChrgitmType = "14"
  8811. break
  8812. case 10:
  8813. fsiOPFLD.MedChrgitmType = "14"
  8814. break
  8815. case 11:
  8816. fsiOPFLD.MedChrgitmType = "06"
  8817. break
  8818. case 12:
  8819. fsiOPFLD.MedChrgitmType = "12"
  8820. break
  8821. case 13:
  8822. fsiOPFLD.MedChrgitmType = "01"
  8823. break
  8824. case 14:
  8825. fsiOPFLD.MedChrgitmType = "04"
  8826. break
  8827. case 15:
  8828. fsiOPFLD.MedChrgitmType = "14"
  8829. break
  8830. }
  8831. memo["hosp_appr_flag"] = "1"
  8832. memo["invoice_no"] = fapiao_code
  8833. memo["memo"] = "自费"
  8834. bytesData, _ := json.Marshal(memo)
  8835. fsiOPFLD.Memo = string(bytesData)
  8836. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8837. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8838. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8839. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8840. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8841. fsiOPFLD.BilgDeptName = department.Name
  8842. fsiOPFLD.BilgDeptCodg = department.Number
  8843. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8844. fsiOPFLD.BilgDrName = doctor.UserName
  8845. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8846. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8847. fsiOPFLD.MedChrgitmType = "08"
  8848. memo["hosp_appr_flag"] = "1"
  8849. memo["invoice_no"] = fapiao_code
  8850. memo["memo"] = "自费"
  8851. bytesData, _ := json.Marshal(memo)
  8852. fsiOPFLD.Memo = string(bytesData)
  8853. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8854. }
  8855. }
  8856. }
  8857. fmt.Println(fsiOPFLDs)
  8858. struct4201A.Fopfd = fsiOPFLDs
  8859. fmt.Println(struct4201A.Fopfd)
  8860. var struct4202 models.Struct4202
  8861. timeLayout := "2006-01-02 15:04:05"
  8862. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  8863. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8864. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8865. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8866. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8867. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8868. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8869. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  8870. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  8871. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8872. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8873. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8874. var config []*models.HisXtDiagnoseConfig
  8875. for _, item := range diagnosis_ids {
  8876. id, _ := strconv.ParseInt(item, 10, 64)
  8877. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8878. config = append(config, &diagnosisConfig)
  8879. }
  8880. var tempDiaginfos []models.OwnPayPatnDiagListD
  8881. for index, item := range config {
  8882. if index == 0 {
  8883. var tempDiaginfo models.OwnPayPatnDiagListD
  8884. tempDiaginfo.InoutDiagType = "1"
  8885. tempDiaginfo.DiagCode = item.CountryCode
  8886. tempDiaginfo.DiagName = item.CountryContentName
  8887. tempDiaginfo.DiagType = "1"
  8888. tempDiaginfo.DiagSrtNo = "1"
  8889. tempDiaginfo.MaindiagFlag = "1"
  8890. tempDiaginfo.ValiFlag = "1"
  8891. tempDiaginfo.DiagDrName = doctor.UserName
  8892. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8893. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8894. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8895. } else {
  8896. var tempDiaginfo models.OwnPayPatnDiagListD
  8897. tempDiaginfo.DiagCode = item.CountryCode
  8898. tempDiaginfo.DiagName = item.CountryContentName
  8899. tempDiaginfo.DiagType = "2"
  8900. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8901. tempDiaginfo.MaindiagFlag = "0"
  8902. tempDiaginfo.ValiFlag = "1"
  8903. tempDiaginfo.DiagDrName = doctor.UserName
  8904. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8905. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8906. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8907. }
  8908. }
  8909. struct4202.ODiagListD = tempDiaginfos
  8910. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  8911. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  8912. var res2 ResultSix
  8913. var respJSON2 map[string]interface{}
  8914. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8917. return
  8918. }
  8919. userJSONBytes2, _ := json.Marshal(respJSON2)
  8920. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8921. utils.ErrorLog("解析失败:%v", err)
  8922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8923. return
  8924. }
  8925. if res2.Infcode != 0 {
  8926. c.ServeSuccessJSON(map[string]interface{}{
  8927. "failed_code": -10,
  8928. "msg": res2.ErrMsg,
  8929. })
  8930. return
  8931. } else {
  8932. order.IsUploadDiagnose = 1
  8933. order.IsUploadOrderInfo = 1
  8934. service.UpdateOrderTwo(order)
  8935. c.ServeSuccessJSON(map[string]interface{}{
  8936. "msg": "上传成功",
  8937. })
  8938. }
  8939. }
  8940. func (c *HisApiController) Get4207() {
  8941. admin_user_id, _ := c.GetInt64("admin_user_id")
  8942. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8943. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8944. order_id, _ := c.GetInt64("order_id")
  8945. order, _ := service.GetHisOrderByIDTwo(order_id)
  8946. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8947. var struct4207 models.Struct4207
  8948. struct4207.PageNum = "1"
  8949. struct4207.PageSize = "1000"
  8950. struct4207.FixmedinsCode = miConfig.Code
  8951. struct4207.FixmedinsMdtrtID = order.Number
  8952. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  8953. saveLog(result, requestLog, "4207", "查询")
  8954. var res2 ResultSix
  8955. var respJSON2 map[string]interface{}
  8956. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8959. return
  8960. }
  8961. userJSONBytes2, _ := json.Marshal(respJSON2)
  8962. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8963. utils.ErrorLog("解析失败:%v", err)
  8964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8965. return
  8966. }
  8967. if res2.Infcode != 0 {
  8968. c.ServeSuccessJSON(map[string]interface{}{
  8969. "failed_code": -10,
  8970. "msg": res2.ErrMsg,
  8971. })
  8972. return
  8973. } else {
  8974. c.ServeSuccessJSON(map[string]interface{}{
  8975. "msg": "查询成功",
  8976. })
  8977. }
  8978. }
  8979. func (c *HisApiController) Get4208() {
  8980. admin_user_id, _ := c.GetInt64("admin_user_id")
  8981. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8982. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8983. order_id, _ := c.GetInt64("order_id")
  8984. order, _ := service.GetHisOrderByIDTwo(order_id)
  8985. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8986. var struct4208 models.Struct4208
  8987. struct4208.PageNum = "1"
  8988. struct4208.PageSize = "1000"
  8989. struct4208.PsnCertType = "01"
  8990. struct4208.Certno = his.Certno
  8991. struct4208.MedType = order.MedType
  8992. struct4208.PsnName = his.Name
  8993. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  8994. saveLog(result, requestLog, "4208", "查询")
  8995. var res2 ResultSix
  8996. var respJSON2 map[string]interface{}
  8997. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9000. return
  9001. }
  9002. userJSONBytes2, _ := json.Marshal(respJSON2)
  9003. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9004. utils.ErrorLog("解析失败:%v", err)
  9005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9006. return
  9007. }
  9008. if res2.Infcode != 0 {
  9009. c.ServeSuccessJSON(map[string]interface{}{
  9010. "failed_code": -10,
  9011. "msg": res2.ErrMsg,
  9012. })
  9013. return
  9014. } else {
  9015. c.ServeSuccessJSON(map[string]interface{}{
  9016. "msg": "查询成功",
  9017. })
  9018. }
  9019. }
  9020. func (c *HisApiController) Get4209() {
  9021. admin_user_id, _ := c.GetInt64("admin_user_id")
  9022. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9023. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9024. order_id, _ := c.GetInt64("order_id")
  9025. order, _ := service.GetHisOrderByIDTwo(order_id)
  9026. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9027. var struct4209 models.Struct4209
  9028. struct4209.FixmedinsMdtrtID = order.Number
  9029. struct4209.FixmedinsCode = miConfig.Code
  9030. struct4209.PageSize = "1000"
  9031. struct4209.PageNum = "1"
  9032. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9033. saveLog(result, requestLog, "4209", "查询")
  9034. var res2 ResultSix
  9035. var respJSON2 map[string]interface{}
  9036. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9039. return
  9040. }
  9041. userJSONBytes2, _ := json.Marshal(respJSON2)
  9042. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9043. utils.ErrorLog("解析失败:%v", err)
  9044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9045. return
  9046. }
  9047. if res2.Infcode != 0 {
  9048. c.ServeSuccessJSON(map[string]interface{}{
  9049. "failed_code": -10,
  9050. "msg": res2.ErrMsg,
  9051. })
  9052. return
  9053. } else {
  9054. c.ServeSuccessJSON(map[string]interface{}{
  9055. "msg": "查询成功",
  9056. })
  9057. }
  9058. }
  9059. type Result3101 struct {
  9060. Infcode string `json:"infcode"`
  9061. InfRefmsgid string `json:"inf_refmsgid"`
  9062. RefmsgTime string `json:"refmsg_time"`
  9063. RespondTime string `json:"respond_time"`
  9064. Enctype string `json:"enctype"`
  9065. Signtype string `json:"signtype"`
  9066. ErrMsg string `json:"err_msg"`
  9067. Output struct {
  9068. Result []struct {
  9069. JudgeResultDetailDtos []struct {
  9070. VolaItemType string `json:"vola_item_type"`
  9071. MdtrtID string `json:"mdtrt_id"`
  9072. JrdID string `json:"jrd_id"`
  9073. PatnID string `json:"patn_id"`
  9074. RxID string `json:"rx_id"`
  9075. VolaAmt interface{} `json:"vola_amt"`
  9076. } `json:"judge_result_detail_dtos"`
  9077. RuleID string `json:"rule_id"`
  9078. VolaEvid string `json:"vola_evid"`
  9079. MdtrtID string `json:"mdtrt_id"`
  9080. RuleName string `json:"rule_name"`
  9081. VolaAmtStas string `json:"vola_amt_stas"`
  9082. JrID string `json:"jr_id"`
  9083. PatnID string `json:"patn_id"`
  9084. SevDeg string `json:"sev_deg"`
  9085. VolaAmt float64 `json:"vola_amt"`
  9086. VolaBhvrType string `json:"vola_bhvr_type"`
  9087. VolaCont string `json:"vola_cont"`
  9088. } `json:"result"`
  9089. } `json:"output"`
  9090. }
  9091. type Resultgd3101 struct {
  9092. Infcode int64 `json:"infcode"`
  9093. InfRefmsgid string `json:"inf_refmsgid"`
  9094. RefmsgTime string `json:"refmsg_time"`
  9095. RespondTime string `json:"respond_time"`
  9096. Enctype string `json:"enctype"`
  9097. Signtype string `json:"signtype"`
  9098. ErrMsg string `json:"err_msg"`
  9099. Output struct {
  9100. Result []struct {
  9101. JudgeResultDetailDtos []struct {
  9102. VolaItemType string `json:"vola_item_type"`
  9103. MdtrtID string `json:"mdtrt_id"`
  9104. JrdID string `json:"jrd_id"`
  9105. PatnID string `json:"patn_id"`
  9106. RxID string `json:"rx_id"`
  9107. VolaAmt interface{} `json:"vola_amt"`
  9108. } `json:"judge_result_detail_dtos"`
  9109. RuleID string `json:"rule_id"`
  9110. VolaEvid string `json:"vola_evid"`
  9111. MdtrtID string `json:"mdtrt_id"`
  9112. RuleName string `json:"rule_name"`
  9113. VolaAmtStas string `json:"vola_amt_stas"`
  9114. JrID string `json:"jr_id"`
  9115. PatnID string `json:"patn_id"`
  9116. SevDeg string `json:"sev_deg"`
  9117. VolaAmt float64 `json:"vola_amt"`
  9118. VolaBhvrType string `json:"vola_bhvr_type"`
  9119. VolaCont string `json:"vola_cont"`
  9120. } `json:"result"`
  9121. } `json:"output"`
  9122. }
  9123. func (c *HisApiController) ReadEleToken() {
  9124. admin_user_id, _ := c.GetInt64("admin_user_id")
  9125. his_patient_id, _ := c.GetInt64("his_patient_id")
  9126. adminUser := c.GetAdminUserInfo()
  9127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9128. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9129. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9130. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9131. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9132. if len(tokens) > 0 {
  9133. c.ServeSuccessJSON(map[string]interface{}{
  9134. "msg": "读取成功",
  9135. })
  9136. } else {
  9137. c.ServeSuccessJSON(map[string]interface{}{
  9138. "failed_code": -10,
  9139. "msg": "读取失败",
  9140. })
  9141. }
  9142. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9143. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9144. if len(tokens) > 0 {
  9145. c.ServeSuccessJSON(map[string]interface{}{
  9146. "msg": "读取成功",
  9147. })
  9148. } else {
  9149. c.ServeSuccessJSON(map[string]interface{}{
  9150. "failed_code": -10,
  9151. "msg": "读取失败",
  9152. })
  9153. }
  9154. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9155. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9156. if len(tokens) > 0 {
  9157. c.ServeSuccessJSON(map[string]interface{}{
  9158. "msg": "读取成功",
  9159. })
  9160. } else {
  9161. c.ServeSuccessJSON(map[string]interface{}{
  9162. "failed_code": -10,
  9163. "msg": "读取失败",
  9164. })
  9165. }
  9166. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9167. var api string
  9168. 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 +
  9169. "&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"
  9170. resp, requestErr := http.Get(api)
  9171. if requestErr != nil {
  9172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9173. }
  9174. body, ioErr := ioutil.ReadAll(resp.Body)
  9175. if ioErr != nil {
  9176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9178. }
  9179. var respJSON map[string]interface{}
  9180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9183. return
  9184. }
  9185. var status string
  9186. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9187. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9188. var token string
  9189. var res ResultTwo //1101结果
  9190. var res10265 ResultTwo10265 //1101结果
  9191. if status == "0" { //读卡成功
  9192. var card_info string //卡信息
  9193. var busi_card_info string
  9194. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9195. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9196. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9197. fmt.Println(card_info)
  9198. fmt.Println(busi_card_info)
  9199. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9200. result, _ := json.Marshal(respJSON)
  9201. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9202. utils.ErrorLog("解析失败:%v", err)
  9203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9204. return
  9205. }
  9206. res.ErrMsg = res10265.ErrMsg
  9207. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9208. res.Infcode = infocode
  9209. res.Output = res10265.Output
  9210. res.InfRefmsgid = res10265.InfRefmsgid
  9211. if res.Infcode == 0 {
  9212. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9213. if err == gorm.ErrRecordNotFound {
  9214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9215. return
  9216. } else if err != nil {
  9217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9218. return
  9219. } else {
  9220. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9221. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9222. infoStr := string(Iinfos)
  9223. idetinfoStr := string(Idetinfos)
  9224. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9225. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9226. psn := &models.HisPsn{
  9227. PsnNo: res.Output.Baseinfo.PsnNo,
  9228. PatientId: patient.ID,
  9229. Certno: res.Output.Baseinfo.Certno,
  9230. Gend: res.Output.Baseinfo.Gend,
  9231. Naty: res.Output.Baseinfo.Naty,
  9232. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9233. PsnName: res.Output.Baseinfo.PsnName,
  9234. Age: float64(age),
  9235. Brdy: b,
  9236. Idetinfo: idetinfoStr,
  9237. Insuinfo: infoStr,
  9238. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9239. CardInfo: card_info,
  9240. VerifyNumber: token,
  9241. IdCardType: 4,
  9242. }
  9243. var rf []*ResultFive
  9244. json.Unmarshal([]byte(infoStr), &rf)
  9245. var insutypes []*ResultFive
  9246. var insutype string
  9247. var is390 int = 0
  9248. var is310 int = 0
  9249. for _, item := range rf {
  9250. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9251. insutypes = append(insutypes, item)
  9252. }
  9253. }
  9254. if len(insutypes) == 1 {
  9255. insutype = insutypes[0].Insutype
  9256. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9257. } else {
  9258. for _, i := range insutypes {
  9259. if i.Insutype == "390" {
  9260. is390 = 1
  9261. }
  9262. if i.Insutype == "310" {
  9263. is310 = 1
  9264. }
  9265. }
  9266. }
  9267. if is390 == 1 {
  9268. insutype = "390"
  9269. }
  9270. if is310 == 1 {
  9271. insutype = "310"
  9272. }
  9273. if len(insutypes) == 0 {
  9274. insutype = "310"
  9275. }
  9276. service.CreateHisPsn(psn)
  9277. c.ServeSuccessJSON(map[string]interface{}{
  9278. "patient": patient,
  9279. "number": token,
  9280. "insutype": insutype,
  9281. })
  9282. }
  9283. } else {
  9284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9285. return
  9286. }
  9287. } else { //读卡失败
  9288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9289. return
  9290. }
  9291. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9292. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9293. if len(errMsg) == 0 {
  9294. type ELeData struct {
  9295. Data struct {
  9296. IdNo string `json:"idNo"`
  9297. IdType string `json:"idType"`
  9298. UserName string `json:"userName"`
  9299. EcToken string `json:"ecToken"`
  9300. InsuOrg string `json:"insuOrg"`
  9301. Gender string `json:"gender"`
  9302. Birthday string `json:"birthday"`
  9303. Nationality string `json:"nationality"`
  9304. Email string `json:"email"`
  9305. Extra string `json:"extra"`
  9306. } `json:"data"`
  9307. Code int `json:"code"`
  9308. Message string `json:"message"`
  9309. }
  9310. var ele ELeData
  9311. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9312. if err != nil {
  9313. utils.ErrorLog("解析失败:%v", err)
  9314. }
  9315. token := ele.Data.EcToken
  9316. if len(token) > 0 {
  9317. psn := &models.HisPsn{
  9318. PsnNo: his.PsnNo,
  9319. Age: 0,
  9320. PatientId: his.PatientId,
  9321. Certno: his.Certno,
  9322. Brdy: his.Brdy,
  9323. Gend: his.Gend,
  9324. Naty: his.Naty,
  9325. PsnCertType: his.PsnCertType,
  9326. PsnName: his.PsnName,
  9327. Idetinfo: his.Idetinfo,
  9328. Insuinfo: his.Iinfo,
  9329. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9330. CardInfo: outPutInfo,
  9331. VerifyNumber: token,
  9332. }
  9333. service.CreateHisPsn(psn)
  9334. }
  9335. if len(token) > 0 {
  9336. c.ServeSuccessJSON(map[string]interface{}{
  9337. "msg": "读取成功",
  9338. })
  9339. } else {
  9340. c.ServeSuccessJSON(map[string]interface{}{
  9341. "failed_code": -10,
  9342. "msg": "读取失败",
  9343. })
  9344. }
  9345. }
  9346. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9347. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9348. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9349. type ELeData struct {
  9350. Data struct {
  9351. IdNo string `json:"idNo"`
  9352. IdType string `json:"idType"`
  9353. UserName string `json:"userName"`
  9354. EcToken string `json:"ecToken"`
  9355. InsuOrg string `json:"insuOrg"`
  9356. Gender string `json:"gender"`
  9357. Birthday string `json:"birthday"`
  9358. Nationality string `json:"nationality"`
  9359. Email string `json:"email"`
  9360. Extra string `json:"extra"`
  9361. } `json:"data"`
  9362. Code int `json:"code"`
  9363. Message string `json:"message"`
  9364. }
  9365. var ele ELeData
  9366. err := json.Unmarshal([]byte(result), &ele)
  9367. if err != nil {
  9368. utils.ErrorLog("解析失败:%v", err)
  9369. }
  9370. token := ele.Data.EcToken
  9371. token = Remove0000(token)
  9372. fmt.Println(ele.Data.UserName)
  9373. 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)
  9374. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9375. var res ResultTwo
  9376. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9377. utils.ErrorLog("解析失败:%v", err)
  9378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9379. return
  9380. }
  9381. if res.Infcode == 0 {
  9382. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9383. if err == gorm.ErrRecordNotFound {
  9384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9385. return
  9386. } else if err != nil {
  9387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9388. return
  9389. } else {
  9390. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9391. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9392. infoStr := string(Iinfos)
  9393. idetinfoStr := string(Idetinfos)
  9394. psn := &models.HisPsn{
  9395. PsnNo: res.Output.Baseinfo.PsnNo,
  9396. PatientId: patient.ID,
  9397. Certno: res.Output.Baseinfo.Certno,
  9398. Gend: res.Output.Baseinfo.Gend,
  9399. Naty: res.Output.Baseinfo.Naty,
  9400. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9401. PsnName: res.Output.Baseinfo.PsnName,
  9402. Idetinfo: idetinfoStr,
  9403. Insuinfo: infoStr,
  9404. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9405. CardInfo: "",
  9406. VerifyNumber: token,
  9407. }
  9408. service.CreateHisPsn(psn)
  9409. c.ServeSuccessJSON(map[string]interface{}{
  9410. "patient": patient,
  9411. "number": token,
  9412. })
  9413. }
  9414. } else {
  9415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9416. return
  9417. }
  9418. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9419. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9420. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9421. type ELeData struct {
  9422. Data struct {
  9423. IdNo string `json:"idNo"`
  9424. IdType string `json:"idType"`
  9425. UserName string `json:"userName"`
  9426. EcToken string `json:"ecToken"`
  9427. InsuOrg string `json:"insuOrg"`
  9428. Gender string `json:"gender"`
  9429. Birthday string `json:"birthday"`
  9430. Nationality string `json:"nationality"`
  9431. Email string `json:"email"`
  9432. Extra string `json:"extra"`
  9433. } `json:"data"`
  9434. Code int `json:"code"`
  9435. Message string `json:"message"`
  9436. }
  9437. var ele ELeData
  9438. err := json.Unmarshal([]byte(result), &ele)
  9439. if err != nil {
  9440. utils.ErrorLog("解析失败:%v", err)
  9441. }
  9442. token := ele.Data.EcToken
  9443. token = Remove0000(token)
  9444. fmt.Println(ele.Data.UserName)
  9445. 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)
  9446. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9447. var res ResultTwo
  9448. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9449. utils.ErrorLog("解析失败:%v", err)
  9450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9451. return
  9452. }
  9453. if res.Infcode == 0 {
  9454. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9455. if err == gorm.ErrRecordNotFound {
  9456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9457. return
  9458. } else if err != nil {
  9459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9460. return
  9461. } else {
  9462. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9463. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9464. infoStr := string(Iinfos)
  9465. idetinfoStr := string(Idetinfos)
  9466. psn := &models.HisPsn{
  9467. PsnNo: res.Output.Baseinfo.PsnNo,
  9468. PatientId: patient.ID,
  9469. Certno: res.Output.Baseinfo.Certno,
  9470. Gend: res.Output.Baseinfo.Gend,
  9471. Naty: res.Output.Baseinfo.Naty,
  9472. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9473. PsnName: res.Output.Baseinfo.PsnName,
  9474. Idetinfo: idetinfoStr,
  9475. Insuinfo: infoStr,
  9476. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9477. CardInfo: "",
  9478. VerifyNumber: token,
  9479. }
  9480. service.CreateHisPsn(psn)
  9481. c.ServeSuccessJSON(map[string]interface{}{
  9482. "patient": patient,
  9483. "number": token,
  9484. })
  9485. }
  9486. } else {
  9487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9488. return
  9489. }
  9490. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9491. //if initFlag == 0 {
  9492. //c.TestGetJiangXiBasBaseInit()
  9493. //}
  9494. //if initEleFlag == 0 {
  9495. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9496. //}
  9497. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9498. utils.ErrorLog("解析失败:%v", json_result)
  9499. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9500. type ELeData struct {
  9501. Data struct {
  9502. IdNo string `json:"idNo"`
  9503. IdType string `json:"idType"`
  9504. UserName string `json:"userName"`
  9505. EcToken string `json:"ecToken"`
  9506. InsuOrg string `json:"insuOrg"`
  9507. Gender string `json:"gender"`
  9508. Birthday string `json:"birthday"`
  9509. Nationality string `json:"nationality"`
  9510. Email string `json:"email"`
  9511. Extra string `json:"extra"`
  9512. } `json:"data"`
  9513. Code int `json:"code"`
  9514. Message string `json:"message"`
  9515. }
  9516. var ele ELeData
  9517. err := json.Unmarshal([]byte(json_result), &ele)
  9518. if err != nil {
  9519. utils.ErrorLog("解析失败:%v", err)
  9520. }
  9521. token := ele.Data.EcToken
  9522. token = Remove0000(token)
  9523. //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)
  9524. 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)
  9525. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9526. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9527. var res ResultTwo
  9528. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9529. utils.ErrorLog("解析失败:%v", err)
  9530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9531. return
  9532. }
  9533. if res.Infcode == 0 {
  9534. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9535. if err == gorm.ErrRecordNotFound {
  9536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9537. return
  9538. } else if err != nil {
  9539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9540. return
  9541. } else {
  9542. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9543. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9544. infoStr := string(Iinfos)
  9545. idetinfoStr := string(Idetinfos)
  9546. psn := &models.HisPsn{
  9547. PsnNo: res.Output.Baseinfo.PsnNo,
  9548. PatientId: patient.ID,
  9549. Certno: res.Output.Baseinfo.Certno,
  9550. Gend: res.Output.Baseinfo.Gend,
  9551. Naty: res.Output.Baseinfo.Naty,
  9552. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9553. PsnName: res.Output.Baseinfo.PsnName,
  9554. Idetinfo: idetinfoStr,
  9555. Insuinfo: infoStr,
  9556. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9557. CardInfo: "",
  9558. VerifyNumber: token,
  9559. InsuplcAdmdvs: ele.Data.InsuOrg,
  9560. }
  9561. service.CreateHisPsn(psn)
  9562. c.ServeSuccessJSON(map[string]interface{}{
  9563. "patient": patient,
  9564. "number": token,
  9565. })
  9566. }
  9567. } else {
  9568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9569. return
  9570. }
  9571. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9572. res := c.GetoleInfo()
  9573. if res.Infcode == 0 {
  9574. var result string
  9575. if res.Output.MdtrtCertType == "01" {
  9576. 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)
  9577. } else if res.Output.MdtrtCertType == "02" {
  9578. 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)
  9579. } else if res.Output.MdtrtCertType == "03" {
  9580. 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)
  9581. }
  9582. var dat map[string]interface{}
  9583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9584. fmt.Println(dat)
  9585. } else {
  9586. fmt.Println(err)
  9587. }
  9588. userJSONBytes, _ := json.Marshal(dat)
  9589. var res2 ResultTwo
  9590. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9591. utils.ErrorLog("解析失败:%v", err)
  9592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9593. return
  9594. }
  9595. if res2.Infcode == 0 {
  9596. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9597. if err == gorm.ErrRecordNotFound {
  9598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9599. return
  9600. } else if err != nil {
  9601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9602. return
  9603. } else {
  9604. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9605. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9606. infoStr := string(Iinfos)
  9607. idetinfoStr := string(Idetinfos)
  9608. var rf []*ResultFive
  9609. json.Unmarshal([]byte(infoStr), &rf)
  9610. var insutypes []*ResultFive
  9611. var insutype string
  9612. var is390 int = 0
  9613. var is310 int = 0
  9614. //var insuplc_admdvs string
  9615. for _, item := range rf {
  9616. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9617. insutypes = append(insutypes, item)
  9618. }
  9619. }
  9620. if len(insutypes) == 1 {
  9621. insutype = insutypes[0].Insutype
  9622. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9623. } else {
  9624. for _, i := range insutypes {
  9625. if i.Insutype == "390" {
  9626. is390 = 1
  9627. }
  9628. if i.Insutype == "310" {
  9629. is310 = 1
  9630. }
  9631. }
  9632. }
  9633. if is390 == 1 {
  9634. insutype = "390"
  9635. }
  9636. if is310 == 1 {
  9637. insutype = "310"
  9638. }
  9639. if len(insutypes) == 0 {
  9640. insutype = "310"
  9641. }
  9642. psn := &models.HisPsn{
  9643. PsnNo: res2.Output.Baseinfo.PsnNo,
  9644. PatientId: patient.ID,
  9645. Certno: res2.Output.Baseinfo.Certno,
  9646. Gend: res2.Output.Baseinfo.Gend,
  9647. Naty: res2.Output.Baseinfo.Naty,
  9648. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9649. PsnName: res2.Output.Baseinfo.PsnName,
  9650. Idetinfo: idetinfoStr,
  9651. Insuinfo: infoStr,
  9652. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9653. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9654. VerifyNumber: res.Output.EcToken,
  9655. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9656. }
  9657. service.CreateHisPsn(psn)
  9658. c.ServeSuccessJSON(map[string]interface{}{
  9659. "patient": patient,
  9660. "number": res.Output.CardNo,
  9661. "insutype": insutype,
  9662. })
  9663. }
  9664. } else {
  9665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9666. return
  9667. }
  9668. } else {
  9669. c.ServeSuccessJSON(map[string]interface{}{
  9670. "failed_code": -10,
  9671. "msg": res.ErrMsg,
  9672. })
  9673. }
  9674. } else {
  9675. //if initFlag == 0 {
  9676. // c.TestGetBasBaseInit()
  9677. //}
  9678. //token := c.GetEleBaseInfo()
  9679. //token = Remove0000(token)
  9680. type ELeData struct {
  9681. Code string `json:"code"`
  9682. Data struct {
  9683. Aac002 string `json:"aac002"`
  9684. Aaz500 string `json:"aaz500"`
  9685. ActCardNo string `json:"actCardNo"`
  9686. Bab520 string `json:"bab520"`
  9687. Bkz543 string `json:"bkz543"`
  9688. BusinessType string `json:"businessType"`
  9689. CertfCodg string `json:"certfCodg"`
  9690. EcIndexNo string `json:"ecIndexNo"`
  9691. EcToken string `json:"ecToken"`
  9692. ID0000 string `json:"id0000"`
  9693. IDNo string `json:"idNo"`
  9694. IDType string `json:"idType"`
  9695. Idcode string `json:"idcode"`
  9696. IdentityToken string `json:"identity_token"`
  9697. InsuOrg string `json:"insuOrg"`
  9698. OfficeID string `json:"officeId"`
  9699. OfficeName string `json:"officeName"`
  9700. OperatorID string `json:"operatorId"`
  9701. OperatorName string `json:"operatorName"`
  9702. OrgID string `json:"orgId"`
  9703. UserName string `json:"userName"`
  9704. } `json:"data"`
  9705. Infno interface{} `json:"infno"`
  9706. Message string `json:"message"`
  9707. OrgID string `json:"orgId"`
  9708. TransType string `json:"transType"`
  9709. }
  9710. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9711. fmt.Println(result)
  9712. outPutInfo := Remove0000(result)
  9713. fmt.Println(outPutInfo)
  9714. var ele ELeData
  9715. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9716. if err != nil {
  9717. utils.ErrorLog("解析失败:%v", err)
  9718. }
  9719. token := ele.Data.EcToken
  9720. var result2 string
  9721. var requestLog2 string
  9722. if len(token) > 0 {
  9723. if strings.Contains(ele.Data.IDNo, "HKG") {
  9724. 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)
  9725. } else {
  9726. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9727. }
  9728. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9729. var res ResultTwo
  9730. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9731. utils.ErrorLog("解析失败:%v", err)
  9732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9733. return
  9734. }
  9735. if res.Infcode == 0 {
  9736. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9737. if err == gorm.ErrRecordNotFound {
  9738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9739. return
  9740. } else if err != nil {
  9741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9742. return
  9743. } else {
  9744. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9745. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9746. infoStr := string(Iinfos)
  9747. idetinfoStr := string(Idetinfos)
  9748. psn := &models.HisPsn{
  9749. PsnNo: res.Output.Baseinfo.PsnNo,
  9750. PatientId: patient.ID,
  9751. Certno: res.Output.Baseinfo.Certno,
  9752. Gend: res.Output.Baseinfo.Gend,
  9753. Naty: res.Output.Baseinfo.Naty,
  9754. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9755. PsnName: res.Output.Baseinfo.PsnName,
  9756. Idetinfo: idetinfoStr,
  9757. Insuinfo: infoStr,
  9758. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9759. CardInfo: "",
  9760. VerifyNumber: token,
  9761. }
  9762. service.CreateHisPsn(psn)
  9763. c.ServeSuccessJSON(map[string]interface{}{
  9764. "msg": "读取成功",
  9765. })
  9766. }
  9767. } else {
  9768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9769. return
  9770. }
  9771. } else {
  9772. c.ServeSuccessJSON(map[string]interface{}{
  9773. "failed_code": -10,
  9774. "msg": "读取失败",
  9775. })
  9776. }
  9777. }
  9778. }
  9779. func (c *HisApiController) ReadEleFace() {
  9780. admin_user_id, _ := c.GetInt64("admin_user_id")
  9781. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9782. adminUser := c.GetAdminUserInfo()
  9783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9784. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9785. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9786. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9787. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9788. if len(tokens) > 0 {
  9789. c.ServeSuccessJSON(map[string]interface{}{
  9790. "msg": "读取成功",
  9791. })
  9792. } else {
  9793. c.ServeSuccessJSON(map[string]interface{}{
  9794. "failed_code": -10,
  9795. "msg": "读取失败",
  9796. })
  9797. }
  9798. }
  9799. }
  9800. func (c *HisApiController) Get9001() {
  9801. adminUser := c.GetAdminUserInfo()
  9802. admin_user_id, _ := c.GetInt64("admin_user_id")
  9803. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9804. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9805. if miConfig.MdtrtareaAdmvs == "350500" {
  9806. service.GetFjAuthorizationInfo(miConfig.Code)
  9807. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9808. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9809. var dat map[string]interface{}
  9810. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9811. fmt.Println(dat)
  9812. } else {
  9813. fmt.Println(err)
  9814. }
  9815. userJSONBytes, _ := json.Marshal(dat)
  9816. var res models.Result9001
  9817. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9818. utils.ErrorLog("解析失败:%v", err)
  9819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9820. return
  9821. }
  9822. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9823. fmt.Println(miConfig.SecretKey)
  9824. var res models.Result9001Two
  9825. 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 +
  9826. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9827. resp, requestErr := http.Get(api)
  9828. if requestErr != nil {
  9829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9830. return
  9831. }
  9832. body, ioErr := ioutil.ReadAll(resp.Body)
  9833. if ioErr != nil {
  9834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9836. return
  9837. }
  9838. var respJSON map[string]interface{}
  9839. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9842. return
  9843. }
  9844. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9845. if status == "0" {
  9846. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9847. c.ServeSuccessJSON(map[string]interface{}{
  9848. "failed_code": -10,
  9849. "msg": err_msg,
  9850. })
  9851. return
  9852. }
  9853. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9854. result, _ := json.Marshal(respJSON)
  9855. fmt.Println("log")
  9856. fmt.Println(string(result))
  9857. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9858. utils.ErrorLog("解析失败:%v", err)
  9859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9860. return
  9861. }
  9862. if res.Infcode == 0 {
  9863. sign := models.HisSignIn{
  9864. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9865. SignNo: res.Output.Signinoutb.SignNo,
  9866. SignTime: "",
  9867. Ctime: time.Now().Unix(),
  9868. Mtime: time.Now().Unix(),
  9869. Status: 1,
  9870. InputLog: "",
  9871. OutputLog: "",
  9872. FixmedinsCode: miConfig.Code,
  9873. }
  9874. err := service.CreateSignIn(&sign)
  9875. if err == nil {
  9876. c.ServeSuccessJSON(map[string]interface{}{
  9877. "msg": "签到成功",
  9878. })
  9879. }
  9880. } else {
  9881. c.ServeSuccessJSON(map[string]interface{}{
  9882. "failed_code": -10,
  9883. "msg": res.ErrMsg,
  9884. })
  9885. return
  9886. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9887. //return
  9888. }
  9889. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9890. fmt.Println(miConfig.SecretKey)
  9891. var res models.Result9001Two
  9892. 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 +
  9893. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9894. resp, requestErr := http.Get(api)
  9895. if requestErr != nil {
  9896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9897. return
  9898. }
  9899. body, ioErr := ioutil.ReadAll(resp.Body)
  9900. if ioErr != nil {
  9901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9903. return
  9904. }
  9905. var respJSON map[string]interface{}
  9906. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9909. return
  9910. }
  9911. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9912. if status == "0" {
  9913. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9914. c.ServeSuccessJSON(map[string]interface{}{
  9915. "failed_code": -10,
  9916. "msg": err_msg,
  9917. })
  9918. return
  9919. }
  9920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9921. result, _ := json.Marshal(respJSON)
  9922. fmt.Println("log")
  9923. fmt.Println(string(result))
  9924. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9925. utils.ErrorLog("解析失败:%v", err)
  9926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9927. return
  9928. }
  9929. if res.Infcode == 0 {
  9930. sign := models.HisSignIn{
  9931. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9932. SignNo: res.Output.Signinoutb.SignNo,
  9933. SignTime: "",
  9934. Ctime: time.Now().Unix(),
  9935. Mtime: time.Now().Unix(),
  9936. Status: 1,
  9937. InputLog: "",
  9938. OutputLog: "",
  9939. FixmedinsCode: miConfig.Code,
  9940. }
  9941. err := service.CreateSignIn(&sign)
  9942. if err == nil {
  9943. c.ServeSuccessJSON(map[string]interface{}{
  9944. "msg": "签到成功",
  9945. })
  9946. }
  9947. } else {
  9948. c.ServeSuccessJSON(map[string]interface{}{
  9949. "failed_code": -10,
  9950. "msg": res.ErrMsg,
  9951. })
  9952. return
  9953. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9954. //return
  9955. }
  9956. } else {
  9957. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  9958. var dat map[string]interface{}
  9959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9960. fmt.Println(dat)
  9961. } else {
  9962. fmt.Println(err)
  9963. }
  9964. userJSONBytes, _ := json.Marshal(dat)
  9965. var res models.Result9001
  9966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9967. utils.ErrorLog("解析失败:%v", err)
  9968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9969. return
  9970. }
  9971. if res.Infcode == 0 {
  9972. sign := models.HisSignIn{
  9973. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9974. SignNo: res.Output.Signinoutb.SignNo,
  9975. SignTime: res.Output.Signinoutb.SignTime,
  9976. Ctime: time.Now().Unix(),
  9977. Mtime: time.Now().Unix(),
  9978. Status: 1,
  9979. InputLog: "",
  9980. OutputLog: "",
  9981. FixmedinsCode: miConfig.Code,
  9982. }
  9983. err := service.CreateSignIn(&sign)
  9984. if err == nil {
  9985. c.ServeSuccessJSON(map[string]interface{}{
  9986. "msg": "签到成功",
  9987. })
  9988. }
  9989. }
  9990. }
  9991. }
  9992. 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) {
  9993. var res Result3101
  9994. adminUser := c.GetAdminUserInfo()
  9995. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9996. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9997. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9998. //record_time := c.GetString("record_time")
  9999. //trig_scen := c.GetString("trig_scen")
  10000. timeLayout := "2006-01-02"
  10001. loc, _ := time.LoadLocation("Local")
  10002. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10003. if err != nil {
  10004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10005. return res
  10006. }
  10007. recordDateTime := theTime.Unix()
  10008. var patientPrescription models.HisPrescriptionInfo
  10009. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10010. //if patientPrescription.ID == 0 {
  10011. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10012. //}
  10013. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10014. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10015. //
  10016. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10017. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10018. var pp models.PublicParams
  10019. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10020. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10021. pp.FixmedinsName = miConfig.OrgName
  10022. pp.FixmedinsCode = miConfig.Code
  10023. pp.RequestUrl = miConfig.Url
  10024. pp.Cainfo = miConfig.Cainfo
  10025. pp.SecretKey = miConfig.SecretKey
  10026. pp.AccessKey = miConfig.AccessKey
  10027. pp.OpterName = roles.UserName
  10028. var config []*models.HisXtDiagnoseConfig
  10029. for _, item := range diagnosis_ids {
  10030. id, _ := strconv.ParseInt(item, 10, 64)
  10031. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10032. config = append(config, &diagnosisConfig)
  10033. }
  10034. var pd models.PatientDtos
  10035. pd.PatnID = his.PsnNo
  10036. pd.PatnName = his.Name
  10037. pd.Gend = his.Gend
  10038. pd.Brdy = his.Brdy
  10039. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10040. pd.CurrMdtrtID = his.Number
  10041. var fed models.FsiEncounterDtos
  10042. fed.MdtrtID = his.Number
  10043. fed.MedinsID = miConfig.Code
  10044. fed.MedinsName = miConfig.OrgName
  10045. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10046. fed.MedMdtrtType = "1"
  10047. fed.MedinsType = "1"
  10048. fed.MedinsLv = "11"
  10049. tm := time.Unix(his.RecordDate, 0)
  10050. s_tm := tm.Format("2006-01-02 15:04:05")
  10051. fed.AdmDate = s_tm
  10052. fed.DscgDate = s_tm
  10053. fed.DscgMainDiseCodg = config[0].CountryCode
  10054. fed.DscgMainDiseName = config[0].CountryContentName
  10055. //诊断信息
  10056. var fdds []*models.FsiDiagnoseDtos
  10057. for index, item := range config {
  10058. if index == 0 {
  10059. var fdd models.FsiDiagnoseDtos
  10060. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10061. fdd.InoutDiseType = "1"
  10062. fdd.MaindiseFlag = "1"
  10063. fdd.DiseDate = s_tm
  10064. fdd.DiasSrtNo = "1"
  10065. fdd.DiseName = item.CountryContentName
  10066. fdd.DiseCodg = item.CountryCode
  10067. fdds = append(fdds, &fdd)
  10068. } else {
  10069. var fdd models.FsiDiagnoseDtos
  10070. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10071. fdd.InoutDiseType = "1"
  10072. fdd.MaindiseFlag = "1"
  10073. fdd.DiseDate = s_tm
  10074. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10075. fdd.DiseName = item.CountryContentName
  10076. fdd.DiseCodg = item.CountryCode
  10077. fdds = append(fdds, &fdd)
  10078. }
  10079. }
  10080. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10081. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10082. fed.AdmDeptName = de.Name
  10083. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10084. fed.DscgDeptName = de.Name
  10085. fed.MedMdtrtType = "1"
  10086. fed.MedType = "11"
  10087. //if his.Insutype == "390" {
  10088. // fed.MedType = "1402"
  10089. //} else {
  10090. // fed.MedType = "9933"
  10091. //}
  10092. var orders []*models.FsiOrderDtos
  10093. if trig_scen == "2" {
  10094. //处方医嘱信息
  10095. for _, item := range prescriptions {
  10096. for _, subItem := range item.HisDoctorAdviceInfo {
  10097. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10098. var order models.FsiOrderDtos
  10099. order.RxID = strconv.FormatInt(item.ID, 10)
  10100. order.Rxno = strconv.FormatInt(item.ID, 10)
  10101. order.LongDrordFlag = "0"
  10102. order.HilistType = "1"
  10103. order.ChrgType = "1"
  10104. order.DrordBhvr = "-"
  10105. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10106. order.HosplistName = subItem.BaseDrugLib.DrugName
  10107. order.HilistLv = "1"
  10108. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10109. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10110. order.HosplistName = subItem.BaseDrugLib.DrugName
  10111. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10112. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10113. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10114. order.OwnpayAmt = ""
  10115. order.SelfpayAmt = ""
  10116. order.Spec = ""
  10117. order.SpecUnt = ""
  10118. order.DrordBegnDate = s_tm
  10119. order.DrordStopDate = ""
  10120. order.DrordDrCodg = doctor_info.DoctorNumber
  10121. order.DrordDeptName = department.Name
  10122. order.DrordDeptCodg = department.Number
  10123. order.DrordDrName = doctor_info.UserName
  10124. order.DrordDrProfttl = "234"
  10125. order.CurrDrordFlag = "1"
  10126. orders = append(orders, &order)
  10127. }
  10128. }
  10129. for _, subItem := range item.HisPrescriptionProject {
  10130. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10131. var order models.FsiOrderDtos
  10132. order.RxID = strconv.FormatInt(item.ID, 10)
  10133. order.Rxno = strconv.FormatInt(item.ID, 10)
  10134. order.LongDrordFlag = "0"
  10135. order.HilistType = "1"
  10136. order.ChrgType = "1"
  10137. order.DrordBhvr = "-"
  10138. order.HilistCode = subItem.HisProject.MedicalCode
  10139. order.HosplistName = subItem.HisProject.ProjectName
  10140. order.HilistLv = "1"
  10141. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10142. order.HosplistCode = subItem.HisProject.MedicalCode
  10143. order.HosplistName = subItem.HisProject.ProjectName
  10144. order.Cnt = subItem.Count
  10145. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10146. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10147. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10148. order.OwnpayAmt = ""
  10149. order.SelfpayAmt = ""
  10150. order.Spec = ""
  10151. order.SpecUnt = ""
  10152. order.DrordBegnDate = s_tm
  10153. order.DrordStopDate = ""
  10154. order.DrordDrCodg = doctor_info.DoctorNumber
  10155. order.DrordDeptName = department.Name
  10156. order.DrordDeptCodg = department.Number
  10157. order.DrordDrName = doctor_info.UserName
  10158. order.DrordDrProfttl = "234"
  10159. order.CurrDrordFlag = "1"
  10160. orders = append(orders, &order)
  10161. }
  10162. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10163. var order models.FsiOrderDtos
  10164. order.RxID = strconv.FormatInt(item.ID, 10)
  10165. order.Rxno = strconv.FormatInt(item.ID, 10)
  10166. order.LongDrordFlag = "0"
  10167. order.HilistType = "1"
  10168. order.ChrgType = "1"
  10169. order.DrordBhvr = "-"
  10170. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10171. order.HosplistName = subItem.GoodInfo.GoodName
  10172. order.HilistLv = "1"
  10173. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10174. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10175. order.HosplistName = subItem.GoodInfo.GoodName
  10176. order.Cnt = subItem.Count
  10177. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10178. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10179. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10180. order.OwnpayAmt = ""
  10181. order.SelfpayAmt = ""
  10182. order.Spec = ""
  10183. order.SpecUnt = ""
  10184. order.DrordBegnDate = s_tm
  10185. order.DrordStopDate = ""
  10186. order.DrordDrCodg = doctor_info.DoctorNumber
  10187. order.DrordDeptName = department.Name
  10188. order.DrordDeptCodg = department.Number
  10189. order.DrordDrName = doctor_info.UserName
  10190. order.DrordDrProfttl = "234"
  10191. order.CurrDrordFlag = "1"
  10192. orders = append(orders, &order)
  10193. }
  10194. }
  10195. }
  10196. //处方医嘱信息
  10197. }
  10198. fed.MatnStas = "0"
  10199. fed.MedfeeSumamt = "0"
  10200. fed.OwnpayAmt = "0"
  10201. fed.SelfpayAmt = "0"
  10202. fed.AcctPayamt = "0"
  10203. fed.MaAmt = "0"
  10204. fed.HifpPayamt = "0"
  10205. fed.SetlTotlnum = "1"
  10206. fed.Insutype = his.Insutype
  10207. fed.ReimFlag = "0"
  10208. fed.OutSetlFlag = "0"
  10209. var fopd []*models.FsiOperationDtosData
  10210. data := make(map[string]interface{})
  10211. data["fed"] = fed
  10212. data["fdd"] = fdds
  10213. data["fod"] = orders
  10214. data["pd"] = pd
  10215. data["pp"] = pp
  10216. data["fopd"] = fopd
  10217. data["trig_scen"] = trig_scen
  10218. fmt.Println(data)
  10219. fmt.Println(fed)
  10220. fmt.Println(fdds)
  10221. fmt.Println(orders)
  10222. fmt.Println(pd)
  10223. fmt.Println(pp)
  10224. fmt.Println(fopd)
  10225. client := &http.Client{}
  10226. bytesData, _ := json.Marshal(data)
  10227. var req *http.Request
  10228. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10229. if miConfig.MdtrtareaAdmvs == "320921" {
  10230. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10231. } else {
  10232. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10233. }
  10234. resp, _ := client.Do(req)
  10235. defer resp.Body.Close()
  10236. body, ioErr := ioutil.ReadAll(resp.Body)
  10237. if ioErr != nil {
  10238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10240. return res
  10241. }
  10242. var respJSON map[string]interface{}
  10243. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10246. return res
  10247. }
  10248. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10249. fmt.Println(respJSON)
  10250. result, _ := json.Marshal(respJSON)
  10251. fmt.Println(result)
  10252. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10253. utils.ErrorLog("解析失败:%v", err)
  10254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10255. return res
  10256. }
  10257. return res
  10258. } else {
  10259. //if miConfig.MdtrtareaAdmvs == "441202" {
  10260. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10261. saveLog(output, input, "3101", "事前")
  10262. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10263. utils.ErrorLog("解析失败:%v", err)
  10264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10265. return
  10266. }
  10267. return res
  10268. //}
  10269. }
  10270. }
  10271. 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) {
  10272. adminUser := c.GetAdminUserInfo()
  10273. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10274. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10275. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10276. //record_time := c.GetString("record_time")
  10277. //trig_scen := c.GetString("trig_scen")
  10278. timeLayout := "2006-01-02"
  10279. loc, _ := time.LoadLocation("Local")
  10280. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10281. if err != nil {
  10282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10283. return res
  10284. }
  10285. recordDateTime := theTime.Unix()
  10286. var patientPrescription models.HisPrescriptionInfo
  10287. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10288. if patientPrescription.ID == 0 {
  10289. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10290. }
  10291. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10292. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10293. //
  10294. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10295. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10296. var pp models.PublicParams
  10297. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10298. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10299. pp.FixmedinsName = miConfig.OrgName
  10300. pp.FixmedinsCode = miConfig.Code
  10301. pp.RequestUrl = miConfig.Url
  10302. pp.Cainfo = miConfig.Cainfo
  10303. pp.SecretKey = miConfig.SecretKey
  10304. pp.AccessKey = miConfig.AccessKey
  10305. pp.OpterName = roles.UserName
  10306. var config []*models.HisXtDiagnoseConfig
  10307. for _, item := range diagnosis_ids {
  10308. id, _ := strconv.ParseInt(item, 10, 64)
  10309. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10310. config = append(config, &diagnosisConfig)
  10311. }
  10312. var pd models.PatientDtos
  10313. pd.PatnID = his.PsnNo
  10314. pd.PatnName = his.Name
  10315. pd.Gend = his.Gend
  10316. pd.Brdy = his.Brdy
  10317. pd.Poolarea = his.InsuplcAdmdvs
  10318. pd.CurrMdtrtID = his.Number
  10319. var fed models.FsiEncounterDtos
  10320. fed.MdtrtID = his.Number
  10321. fed.MedinsID = miConfig.Code
  10322. fed.MedinsName = miConfig.OrgName
  10323. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10324. fed.MedMdtrtType = "1"
  10325. fed.MedinsType = "1"
  10326. fed.MedinsLv = "11"
  10327. tm := time.Unix(his.RecordDate, 0)
  10328. s_tm := tm.Format("2006-01-02 15:04:05")
  10329. fed.AdmDate = s_tm
  10330. fed.DscgDate = s_tm
  10331. fed.DscgMainDiseCodg = config[0].CountryCode
  10332. fed.DscgMainDiseName = config[0].CountryContentName
  10333. //诊断信息
  10334. var fdds []*models.FsiDiagnoseDtos
  10335. for index, item := range config {
  10336. if index == 0 {
  10337. var fdd models.FsiDiagnoseDtos
  10338. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10339. fdd.InoutDiseType = "1"
  10340. fdd.MaindiseFlag = "1"
  10341. fdd.DiseDate = s_tm
  10342. fdd.DiasSrtNo = "1"
  10343. fdd.DiseName = item.CountryContentName
  10344. fdd.DiseCodg = item.CountryCode
  10345. fdds = append(fdds, &fdd)
  10346. } else {
  10347. var fdd models.FsiDiagnoseDtos
  10348. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10349. fdd.InoutDiseType = "1"
  10350. fdd.MaindiseFlag = "1"
  10351. fdd.DiseDate = s_tm
  10352. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10353. fdd.DiseName = item.CountryContentName
  10354. fdd.DiseCodg = item.CountryCode
  10355. fdds = append(fdds, &fdd)
  10356. }
  10357. }
  10358. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10359. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10360. fed.AdmDeptName = department.Name
  10361. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10362. fed.DscgDeptName = department.Name
  10363. fed.MedMdtrtType = "1"
  10364. fed.MedType = "11"
  10365. //if his.Insutype == "390" {
  10366. // fed.MedType = "1402"
  10367. //} else {
  10368. // fed.MedType = "9933"
  10369. //}
  10370. var orders []*models.FsiOrderDtos
  10371. if trig_scen == "2" {
  10372. //处方医嘱信息
  10373. for _, item := range prescriptions {
  10374. for _, subItem := range item.HisDoctorAdviceInfo {
  10375. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10376. var order models.FsiOrderDtos
  10377. order.RxID = strconv.FormatInt(item.ID, 10)
  10378. order.Rxno = strconv.FormatInt(item.ID, 10)
  10379. order.LongDrordFlag = "0"
  10380. order.HilistType = "1"
  10381. order.ChrgType = "1"
  10382. order.DrordBhvr = "-"
  10383. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10384. order.HosplistName = subItem.BaseDrugLib.DrugName
  10385. order.HilistLv = "1"
  10386. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10387. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10388. order.HosplistName = subItem.BaseDrugLib.DrugName
  10389. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10390. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10391. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10392. order.OwnpayAmt = ""
  10393. order.SelfpayAmt = ""
  10394. order.Spec = ""
  10395. order.SpecUnt = ""
  10396. order.DrordBegnDate = s_tm
  10397. order.DrordStopDate = ""
  10398. order.DrordDrCodg = doctor_info.DoctorNumber
  10399. order.DrordDeptName = department.Name
  10400. order.DrordDeptCodg = department.Number
  10401. order.DrordDrName = doctor_info.UserName
  10402. order.DrordDrProfttl = "234"
  10403. order.CurrDrordFlag = "1"
  10404. orders = append(orders, &order)
  10405. }
  10406. }
  10407. for _, subItem := range item.HisPrescriptionProject {
  10408. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10409. var order models.FsiOrderDtos
  10410. order.RxID = strconv.FormatInt(item.ID, 10)
  10411. order.Rxno = strconv.FormatInt(item.ID, 10)
  10412. order.LongDrordFlag = "0"
  10413. order.HilistType = "1"
  10414. order.ChrgType = "1"
  10415. order.DrordBhvr = "-"
  10416. order.HilistCode = subItem.HisProject.MedicalCode
  10417. order.HosplistName = subItem.HisProject.ProjectName
  10418. order.HilistLv = "1"
  10419. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10420. order.HosplistCode = subItem.HisProject.MedicalCode
  10421. order.HosplistName = subItem.HisProject.ProjectName
  10422. order.Cnt = subItem.Count
  10423. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10424. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10425. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10426. order.OwnpayAmt = ""
  10427. order.SelfpayAmt = ""
  10428. order.Spec = ""
  10429. order.SpecUnt = ""
  10430. order.DrordBegnDate = s_tm
  10431. order.DrordStopDate = ""
  10432. order.DrordDrCodg = doctor_info.DoctorNumber
  10433. order.DrordDeptName = department.Name
  10434. order.DrordDeptCodg = department.Number
  10435. order.DrordDrName = doctor_info.UserName
  10436. order.DrordDrProfttl = "234"
  10437. order.CurrDrordFlag = "1"
  10438. orders = append(orders, &order)
  10439. }
  10440. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10441. var order models.FsiOrderDtos
  10442. order.RxID = strconv.FormatInt(item.ID, 10)
  10443. order.Rxno = strconv.FormatInt(item.ID, 10)
  10444. order.LongDrordFlag = "0"
  10445. order.HilistType = "1"
  10446. order.ChrgType = "1"
  10447. order.DrordBhvr = "-"
  10448. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10449. order.HosplistName = subItem.GoodInfo.GoodName
  10450. order.HilistLv = "1"
  10451. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10452. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10453. order.HosplistName = subItem.GoodInfo.GoodName
  10454. order.Cnt = subItem.Count
  10455. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10456. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10457. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10458. order.OwnpayAmt = ""
  10459. order.SelfpayAmt = ""
  10460. order.Spec = ""
  10461. order.SpecUnt = ""
  10462. order.DrordBegnDate = s_tm
  10463. order.DrordStopDate = ""
  10464. order.DrordDrCodg = doctor_info.DoctorNumber
  10465. order.DrordDeptName = department.Name
  10466. order.DrordDeptCodg = department.Number
  10467. order.DrordDrName = doctor_info.UserName
  10468. order.DrordDrProfttl = "234"
  10469. order.CurrDrordFlag = "1"
  10470. orders = append(orders, &order)
  10471. }
  10472. }
  10473. }
  10474. //处方医嘱信息
  10475. }
  10476. fed.MatnStas = "0"
  10477. fed.MedfeeSumamt = "0"
  10478. fed.OwnpayAmt = "0"
  10479. fed.SelfpayAmt = "0"
  10480. fed.AcctPayamt = "0"
  10481. fed.MaAmt = "0"
  10482. fed.HifpPayamt = "0"
  10483. fed.SetlTotlnum = "1"
  10484. fed.Insutype = his.Insutype
  10485. fed.ReimFlag = "0"
  10486. fed.OutSetlFlag = "0"
  10487. var fopd []*models.FsiOperationDtosData
  10488. data := make(map[string]interface{})
  10489. data["fed"] = fed
  10490. data["fdd"] = fdds
  10491. data["fod"] = orders
  10492. data["pd"] = pd
  10493. data["pp"] = pp
  10494. data["fopd"] = fopd
  10495. data["trig_scen"] = trig_scen
  10496. fmt.Println(data)
  10497. fmt.Println(fed)
  10498. fmt.Println(fdds)
  10499. fmt.Println(orders)
  10500. fmt.Println(pd)
  10501. fmt.Println(pp)
  10502. fmt.Println(fopd)
  10503. client := &http.Client{}
  10504. bytesData, _ := json.Marshal(data)
  10505. var req *http.Request
  10506. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10507. if miConfig.MdtrtareaAdmvs == "320921" {
  10508. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10509. } else {
  10510. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10511. }
  10512. resp, _ := client.Do(req)
  10513. defer resp.Body.Close()
  10514. body, ioErr := ioutil.ReadAll(resp.Body)
  10515. if ioErr != nil {
  10516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10518. return res
  10519. }
  10520. var respJSON map[string]interface{}
  10521. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10524. return res
  10525. }
  10526. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10527. fmt.Println(respJSON)
  10528. result, _ := json.Marshal(respJSON)
  10529. fmt.Println(result)
  10530. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10531. utils.ErrorLog("解析失败:%v", err)
  10532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10533. return res
  10534. }
  10535. return res
  10536. } else {
  10537. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10538. saveLog(output, input, "3101", "事前")
  10539. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10540. utils.ErrorLog("解析失败:%v", err)
  10541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10542. return
  10543. }
  10544. return res
  10545. }
  10546. return res
  10547. }
  10548. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10549. ////patient_id, _ := c.GetInt64("patient_id")
  10550. //order_id, _ := c.GetInt64("order_id")
  10551. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10552. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10553. //trig_scen := c.GetString("trig_scen")
  10554. adminUser := c.GetAdminUserInfo()
  10555. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10556. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10557. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10558. record_time := c.GetString("record_time")
  10559. order, _ := service.GetHisOrderByID(order_id)
  10560. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10561. timeLayout := "2006-01-02"
  10562. loc, _ := time.LoadLocation("Local")
  10563. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10564. if err != nil {
  10565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10566. return
  10567. }
  10568. recordDateTime := theTime.Unix()
  10569. var patientPrescription models.HisPrescriptionInfo
  10570. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10571. if patientPrescription.ID == 0 {
  10572. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10573. }
  10574. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10575. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10576. //
  10577. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10578. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10579. var pp models.PublicParams
  10580. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10581. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10582. pp.FixmedinsName = miConfig.OrgName
  10583. pp.FixmedinsCode = miConfig.Code
  10584. pp.RequestUrl = miConfig.Url
  10585. pp.Cainfo = miConfig.Cainfo
  10586. pp.SecretKey = miConfig.SecretKey
  10587. pp.AccessKey = miConfig.AccessKey
  10588. pp.OpterName = roles.UserName
  10589. var config []*models.HisXtDiagnoseConfig
  10590. for _, item := range diagnosis_ids {
  10591. id, _ := strconv.ParseInt(item, 10, 64)
  10592. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10593. config = append(config, &diagnosisConfig)
  10594. }
  10595. var pd models.PatientDtos
  10596. pd.PatnID = his.PsnNo
  10597. pd.PatnName = his.Name
  10598. pd.Gend = his.Gend
  10599. pd.Brdy = psn_info.Brdy
  10600. pd.Poolarea = his.InsuplcAdmdvs
  10601. pd.CurrMdtrtID = his.Number
  10602. var fed models.FsiEncounterDtos
  10603. fed.MdtrtID = his.Number
  10604. fed.MedinsID = miConfig.Code
  10605. fed.MedinsName = miConfig.OrgName
  10606. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10607. fed.MedMdtrtType = "1"
  10608. fed.MedinsType = "1"
  10609. fed.MedinsLv = "11"
  10610. tm := time.Unix(his.RecordDate, 0)
  10611. s_tm := tm.Format("2006-01-02 15:04:05")
  10612. fed.AdmDate = s_tm
  10613. fed.DscgDate = s_tm
  10614. fed.DscgMainDiseCodg = config[0].CountryCode
  10615. fed.DscgMainDiseName = config[0].CountryContentName
  10616. //诊断信息
  10617. var fdds []*models.FsiDiagnoseDtos
  10618. for index, item := range config {
  10619. if index == 0 {
  10620. var fdd models.FsiDiagnoseDtos
  10621. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10622. fdd.InoutDiseType = "1"
  10623. fdd.MaindiseFlag = "1"
  10624. fdd.DiseDate = s_tm
  10625. fdd.DiasSrtNo = "1"
  10626. fdd.DiseName = item.CountryContentName
  10627. fdd.DiseCodg = item.CountryCode
  10628. fdds = append(fdds, &fdd)
  10629. } else {
  10630. var fdd models.FsiDiagnoseDtos
  10631. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10632. fdd.InoutDiseType = "1"
  10633. fdd.MaindiseFlag = "1"
  10634. fdd.DiseDate = s_tm
  10635. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10636. fdd.DiseName = item.CountryContentName
  10637. fdd.DiseCodg = item.CountryCode
  10638. fdds = append(fdds, &fdd)
  10639. }
  10640. }
  10641. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10642. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10643. fed.AdmDeptName = department.Name
  10644. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10645. fed.DscgDeptName = department.Name
  10646. fed.MedType = order.MedType
  10647. //处方医嘱信息
  10648. var orders []*models.FsiOrderDtos
  10649. //for _, item := range prescriptions {
  10650. // for _, subItem := range item.HisDoctorAdviceInfo {
  10651. // var order models.FsiOrderDtos
  10652. // order.RxID = strconv.FormatInt(item.ID, 10)
  10653. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10654. // order.LongDrordFlag = "0"
  10655. // order.HilistType = "1"
  10656. // order.ChrgType = "1"
  10657. // order.DrordBhvr = "-"
  10658. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10659. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10660. // order.HilistLv = "1"
  10661. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10662. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10663. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10664. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10665. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10666. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10667. // order.OwnpayAmt = ""
  10668. // order.SelfpayAmt = ""
  10669. // order.Spec = ""
  10670. // order.SpecUnt = ""
  10671. // order.DrordBegnDate = s_tm
  10672. // order.DrordStopDate = ""
  10673. // order.DrordDrCodg = "1"
  10674. // order.DrordDeptName = department.Name
  10675. // order.DrordDrCodg = "1"
  10676. // order.DrordDrName = doctor_info.UserName
  10677. // order.DrordDrProfttl = ""
  10678. // order.CurrDrordFlag = "1"
  10679. // orders = append(orders, &order)
  10680. // }
  10681. // for _, subItem := range item.HisPrescriptionProject {
  10682. // if subItem.Type == 2 {
  10683. // var order models.FsiOrderDtos
  10684. // order.RxID = strconv.FormatInt(item.ID, 10)
  10685. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10686. // order.LongDrordFlag = "0"
  10687. // order.HilistType = "1"
  10688. // order.ChrgType = "1"
  10689. // order.DrordBhvr = "-"
  10690. // order.HilistCode = subItem.HisProject.MedicalCode
  10691. // order.HosplistName = subItem.HisProject.ProjectName
  10692. // order.HilistLv = "1"
  10693. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10694. // order.HosplistCode = subItem.HisProject.MedicalCode
  10695. // order.HosplistName = subItem.HisProject.ProjectName
  10696. // order.Cnt = subItem.Count
  10697. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10698. //
  10699. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10700. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10701. // order.OwnpayAmt = ""
  10702. // order.SelfpayAmt = ""
  10703. // order.Spec = ""
  10704. // order.SpecUnt = ""
  10705. // order.DrordBegnDate = s_tm
  10706. // order.DrordStopDate = ""
  10707. // order.DrordDrCodg = "1"
  10708. // order.DrordDeptName = department.Name
  10709. // order.DrordDrCodg = "1"
  10710. // order.DrordDrName = doctor_info.UserName
  10711. // order.DrordDrProfttl = ""
  10712. // order.CurrDrordFlag = "1"
  10713. // orders = append(orders, &order)
  10714. //
  10715. // }
  10716. // if subItem.Type == 3 {
  10717. //
  10718. // var order models.FsiOrderDtos
  10719. // order.RxID = strconv.FormatInt(item.ID, 10)
  10720. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10721. // order.LongDrordFlag = "0"
  10722. // order.HilistType = "1"
  10723. // order.ChrgType = "1"
  10724. // order.DrordBhvr = "-"
  10725. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10726. // order.HosplistName = subItem.GoodInfo.GoodName
  10727. // order.HilistLv = "1"
  10728. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10729. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10730. // order.HosplistName = subItem.GoodInfo.GoodName
  10731. // order.Cnt = subItem.Count
  10732. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10733. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10734. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10735. // order.OwnpayAmt = ""
  10736. // order.SelfpayAmt = ""
  10737. // order.Spec = ""
  10738. // order.SpecUnt = ""
  10739. // order.DrordBegnDate = s_tm
  10740. // order.DrordStopDate = ""
  10741. // order.DrordDrCodg = "1"
  10742. // order.DrordDeptName = department.Name
  10743. // order.DrordDrCodg = "1"
  10744. // order.DrordDrName = doctor_info.UserName
  10745. // order.DrordDrProfttl = ""
  10746. // order.CurrDrordFlag = "1"
  10747. // orders = append(orders, &order)
  10748. //
  10749. // }
  10750. // }
  10751. //}
  10752. for _, item := range prescriptions {
  10753. for _, subItem := range item.HisDoctorAdviceInfo {
  10754. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10755. var order models.FsiOrderDtos
  10756. order.RxID = strconv.FormatInt(item.ID, 10)
  10757. order.Rxno = strconv.FormatInt(item.ID, 10)
  10758. order.LongDrordFlag = "0"
  10759. order.HilistType = "1"
  10760. order.ChrgType = "1"
  10761. order.DrordBhvr = "-"
  10762. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10763. order.HosplistName = subItem.BaseDrugLib.DrugName
  10764. order.HilistLv = "1"
  10765. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10766. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10767. order.HosplistName = subItem.BaseDrugLib.DrugName
  10768. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10769. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10770. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10771. order.OwnpayAmt = ""
  10772. order.SelfpayAmt = ""
  10773. order.Spec = ""
  10774. order.SpecUnt = ""
  10775. order.DrordBegnDate = s_tm
  10776. order.DrordStopDate = ""
  10777. order.DrordDrCodg = doctor_info.DoctorNumber
  10778. order.DrordDeptName = department.Name
  10779. order.DrordDeptCodg = department.Number
  10780. order.DrordDrName = doctor_info.UserName
  10781. order.DrordDrProfttl = "234"
  10782. order.CurrDrordFlag = "1"
  10783. orders = append(orders, &order)
  10784. }
  10785. }
  10786. for _, subItem := range item.HisPrescriptionProject {
  10787. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10788. var order models.FsiOrderDtos
  10789. order.RxID = strconv.FormatInt(item.ID, 10)
  10790. order.Rxno = strconv.FormatInt(item.ID, 10)
  10791. order.LongDrordFlag = "0"
  10792. order.HilistType = "1"
  10793. order.ChrgType = "1"
  10794. order.DrordBhvr = "-"
  10795. order.HilistCode = subItem.HisProject.MedicalCode
  10796. order.HosplistName = subItem.HisProject.ProjectName
  10797. order.HilistLv = "1"
  10798. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10799. order.HosplistCode = subItem.HisProject.MedicalCode
  10800. order.HosplistName = subItem.HisProject.ProjectName
  10801. order.Cnt = subItem.Count
  10802. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10803. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10804. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10805. order.OwnpayAmt = ""
  10806. order.SelfpayAmt = ""
  10807. order.Spec = ""
  10808. order.SpecUnt = ""
  10809. order.DrordBegnDate = s_tm
  10810. order.DrordStopDate = ""
  10811. order.DrordDrCodg = doctor_info.DoctorNumber
  10812. order.DrordDeptName = department.Name
  10813. order.DrordDeptCodg = department.Number
  10814. order.DrordDrName = doctor_info.UserName
  10815. order.DrordDrProfttl = "234"
  10816. order.CurrDrordFlag = "1"
  10817. orders = append(orders, &order)
  10818. }
  10819. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10820. var order models.FsiOrderDtos
  10821. order.RxID = strconv.FormatInt(item.ID, 10)
  10822. order.Rxno = strconv.FormatInt(item.ID, 10)
  10823. order.LongDrordFlag = "0"
  10824. order.HilistType = "1"
  10825. order.ChrgType = "1"
  10826. order.DrordBhvr = "0"
  10827. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10828. order.HosplistName = subItem.GoodInfo.GoodName
  10829. order.HilistLv = "1"
  10830. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10831. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10832. order.HosplistName = subItem.GoodInfo.GoodName
  10833. order.Cnt = subItem.Count
  10834. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10835. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10836. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10837. order.OwnpayAmt = ""
  10838. order.SelfpayAmt = ""
  10839. order.Spec = ""
  10840. order.SpecUnt = ""
  10841. order.DrordBegnDate = s_tm
  10842. order.DrordStopDate = ""
  10843. order.DrordDrCodg = doctor_info.DoctorNumber
  10844. order.DrordDeptName = department.Name
  10845. order.DrordDeptCodg = department.Number
  10846. order.DrordDrName = doctor_info.UserName
  10847. order.DrordDrProfttl = "234"
  10848. order.CurrDrordFlag = "1"
  10849. orders = append(orders, &order)
  10850. }
  10851. }
  10852. }
  10853. //处方医嘱信息
  10854. fed.MatnStas = "0"
  10855. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  10856. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  10857. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  10858. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  10859. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  10860. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  10861. fed.SetlTotlnum = "1"
  10862. fed.Insutype = his.Insutype
  10863. fed.ReimFlag = "0"
  10864. fed.OutSetlFlag = "0"
  10865. var fopd []*models.FsiOperationDtosData
  10866. data := make(map[string]interface{})
  10867. data["fed"] = fed
  10868. data["fdd"] = fdds
  10869. data["fod"] = orders
  10870. data["pd"] = pd
  10871. data["pp"] = pp
  10872. data["fopd"] = fopd
  10873. data["trig_scen"] = trig_scen
  10874. client := &http.Client{}
  10875. bytesData, _ := json.Marshal(data)
  10876. var req *http.Request
  10877. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10878. if miConfig.MdtrtareaAdmvs == "320921" {
  10879. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10880. } else {
  10881. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10882. }
  10883. resp, _ := client.Do(req)
  10884. defer resp.Body.Close()
  10885. body, ioErr := ioutil.ReadAll(resp.Body)
  10886. if ioErr != nil {
  10887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10889. return res
  10890. }
  10891. var respJSON map[string]interface{}
  10892. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10895. return res
  10896. }
  10897. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10898. result, _ := json.Marshal(respJSON)
  10899. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10900. utils.ErrorLog("解析失败:%v", err)
  10901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10902. return res
  10903. }
  10904. return res
  10905. } else {
  10906. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10907. saveLog(output, input, "3102", "事中")
  10908. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10909. utils.ErrorLog("解析失败:%v", err)
  10910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10911. return
  10912. }
  10913. return res
  10914. }
  10915. return res
  10916. }
  10917. 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) {
  10918. var res Resultgd3101
  10919. adminUser := c.GetAdminUserInfo()
  10920. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10921. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10922. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10923. //record_time := c.GetString("record_time")
  10924. //trig_scen := c.GetString("trig_scen")
  10925. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10926. //psn_info, _ := service.GetPatientId(patient_id)
  10927. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10928. timeLayout := "2006-01-02"
  10929. loc, _ := time.LoadLocation("Local")
  10930. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10931. if err != nil {
  10932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10933. return res
  10934. }
  10935. recordDateTime := theTime.Unix()
  10936. var patientPrescription models.HisPrescriptionInfo
  10937. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10938. //if patientPrescription.ID == 0 {
  10939. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10940. //}
  10941. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10942. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10943. //
  10944. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10945. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10946. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10947. var pp models.PublicParams
  10948. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10949. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10950. pp.FixmedinsName = miConfig.OrgName
  10951. pp.FixmedinsCode = miConfig.Code
  10952. pp.RequestUrl = miConfig.Url
  10953. pp.Cainfo = miConfig.Cainfo
  10954. pp.SecretKey = miConfig.SecretKey
  10955. pp.AccessKey = miConfig.AccessKey
  10956. pp.OpterName = roles.UserName
  10957. var config []*models.HisXtDiagnoseConfig
  10958. for _, item := range diagnosis_ids {
  10959. id, _ := strconv.ParseInt(item, 10, 64)
  10960. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10961. config = append(config, &diagnosisConfig)
  10962. }
  10963. var pd models.PatientDtos
  10964. pd.PatnID = his.PsnNo
  10965. pd.PatnName = his.Name
  10966. pd.Gend = his.Gend
  10967. pd.Brdy = str
  10968. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10969. pd.CurrMdtrtID = his.Number
  10970. var fed models.FsiEncounterDtos
  10971. fed.MdtrtID = his.Number
  10972. fed.MedinsID = miConfig.Code
  10973. fed.MedinsName = miConfig.OrgName
  10974. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10975. fed.MedMdtrtType = "1"
  10976. fed.MedinsType = "1"
  10977. fed.MedinsLv = "11"
  10978. tm := time.Unix(his.RecordDate, 0)
  10979. s_tm := tm.Format("2006-01-02 15:04:05")
  10980. fed.AdmDate = s_tm
  10981. fed.DscgDate = s_tm
  10982. fed.DscgMainDiseCodg = config[0].CountryCode
  10983. fed.DscgMainDiseName = config[0].CountryContentName
  10984. //诊断信息
  10985. var fdds []*models.FsiDiagnoseDtos
  10986. for index, item := range config {
  10987. if index == 0 {
  10988. var fdd models.FsiDiagnoseDtos
  10989. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10990. fdd.InoutDiseType = "1"
  10991. fdd.MaindiseFlag = "1"
  10992. fdd.DiseDate = s_tm
  10993. fdd.DiasSrtNo = "1"
  10994. fdd.DiseName = item.CountryContentName
  10995. fdd.DiseCodg = item.CountryCode
  10996. fdds = append(fdds, &fdd)
  10997. } else {
  10998. var fdd models.FsiDiagnoseDtos
  10999. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11000. fdd.InoutDiseType = "1"
  11001. fdd.MaindiseFlag = "1"
  11002. fdd.DiseDate = s_tm
  11003. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11004. fdd.DiseName = item.CountryContentName
  11005. fdd.DiseCodg = item.CountryCode
  11006. fdds = append(fdds, &fdd)
  11007. }
  11008. }
  11009. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11010. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11011. fed.AdmDeptName = de.Name
  11012. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11013. fed.DscgDeptName = de.Name
  11014. fed.MedMdtrtType = "1"
  11015. fed.MedType = "11"
  11016. //if his.Insutype == "390" {
  11017. // fed.MedType = "1402"
  11018. //} else {
  11019. // fed.MedType = "9933"
  11020. //}
  11021. var orders []*models.FsiOrderDtos
  11022. if trig_scen == "2" {
  11023. //处方医嘱信息
  11024. for _, item := range prescriptions {
  11025. for _, subItem := range item.HisDoctorAdviceInfo {
  11026. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11027. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11028. var order models.FsiOrderDtos
  11029. order.RxID = strconv.FormatInt(item.ID, 10)
  11030. order.Rxno = strconv.FormatInt(item.ID, 10)
  11031. order.LongDrordFlag = "0"
  11032. order.HilistType = "1"
  11033. order.ChrgType = "1"
  11034. order.DrordBhvr = "0"
  11035. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11036. order.HosplistName = subItem.BaseDrugLib.DrugName
  11037. order.HilistLv = "1"
  11038. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11039. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11040. order.HosplistName = subItem.BaseDrugLib.DrugName
  11041. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11042. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11043. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11044. order.OwnpayAmt = ""
  11045. order.SelfpayAmt = ""
  11046. order.Spec = spec
  11047. order.SpecUnt = subItem.PrescribingNumberUnit
  11048. order.DrordBegnDate = s_tm
  11049. order.DrordStopDate = ""
  11050. order.DrordDrCodg = doctor_info.DoctorNumber
  11051. order.DrordDeptName = department.Name
  11052. order.DrordDeptCodg = department.Number
  11053. order.DrordDrName = doctor_info.UserName
  11054. order.DrordDrProfttl = "234"
  11055. order.CurrDrordFlag = "1"
  11056. orders = append(orders, &order)
  11057. }
  11058. }
  11059. for _, subItem := range item.HisPrescriptionProject {
  11060. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11061. var order models.FsiOrderDtos
  11062. order.RxID = strconv.FormatInt(item.ID, 10)
  11063. order.Rxno = strconv.FormatInt(item.ID, 10)
  11064. order.LongDrordFlag = "0"
  11065. order.HilistType = "1"
  11066. order.ChrgType = "1"
  11067. order.DrordBhvr = "0"
  11068. order.HilistCode = subItem.HisProject.MedicalCode
  11069. order.HosplistName = subItem.HisProject.ProjectName
  11070. order.HilistLv = "1"
  11071. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11072. order.HosplistCode = subItem.HisProject.MedicalCode
  11073. order.HosplistName = subItem.HisProject.ProjectName
  11074. order.Cnt = subItem.Count
  11075. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11076. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11077. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11078. order.OwnpayAmt = ""
  11079. order.SelfpayAmt = ""
  11080. order.Spec = subItem.Unit
  11081. order.SpecUnt = subItem.Unit
  11082. order.DrordBegnDate = s_tm
  11083. order.DrordStopDate = ""
  11084. order.DrordDrCodg = doctor_info.DoctorNumber
  11085. order.DrordDeptName = department.Name
  11086. order.DrordDeptCodg = department.Number
  11087. order.DrordDrName = doctor_info.UserName
  11088. order.DrordDrProfttl = "234"
  11089. order.CurrDrordFlag = "1"
  11090. orders = append(orders, &order)
  11091. }
  11092. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11093. var order models.FsiOrderDtos
  11094. order.RxID = strconv.FormatInt(item.ID, 10)
  11095. order.Rxno = strconv.FormatInt(item.ID, 10)
  11096. order.LongDrordFlag = "0"
  11097. order.HilistType = "1"
  11098. order.ChrgType = "1"
  11099. order.DrordBhvr = "0"
  11100. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11101. order.HosplistName = subItem.GoodInfo.GoodName
  11102. order.HilistLv = "1"
  11103. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11104. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11105. order.HosplistName = subItem.GoodInfo.GoodName
  11106. order.Cnt = subItem.Count
  11107. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11108. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11109. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11110. order.OwnpayAmt = ""
  11111. order.SelfpayAmt = ""
  11112. order.Spec = subItem.GoodInfo.SpecificationName
  11113. order.SpecUnt = subItem.Unit
  11114. order.DrordBegnDate = s_tm
  11115. order.DrordStopDate = ""
  11116. order.DrordDrCodg = doctor_info.DoctorNumber
  11117. order.DrordDeptName = department.Name
  11118. order.DrordDeptCodg = department.Number
  11119. order.DrordDrName = doctor_info.UserName
  11120. order.DrordDrProfttl = "234"
  11121. order.CurrDrordFlag = "1"
  11122. orders = append(orders, &order)
  11123. }
  11124. }
  11125. }
  11126. //处方医嘱信息
  11127. }
  11128. fed.MatnStas = "0"
  11129. fed.MedfeeSumamt = "0"
  11130. fed.OwnpayAmt = "0"
  11131. fed.SelfpayAmt = "0"
  11132. fed.AcctPayamt = "0"
  11133. fed.MaAmt = "0"
  11134. fed.HifpPayamt = "0"
  11135. fed.SetlTotlnum = "1"
  11136. fed.Insutype = his.Insutype
  11137. fed.ReimFlag = "0"
  11138. fed.OutSetlFlag = "0"
  11139. var fopd []*models.FsiOperationDtosData
  11140. data := make(map[string]interface{})
  11141. data["fed"] = fed
  11142. data["fdd"] = fdds
  11143. data["fod"] = orders
  11144. data["pd"] = pd
  11145. data["pp"] = pp
  11146. data["fopd"] = fopd
  11147. data["trig_scen"] = trig_scen
  11148. fmt.Println(data)
  11149. fmt.Println(fed)
  11150. fmt.Println(fdds)
  11151. fmt.Println(orders)
  11152. fmt.Println(pd)
  11153. fmt.Println(pp)
  11154. fmt.Println(fopd)
  11155. client := &http.Client{}
  11156. bytesData, _ := json.Marshal(data)
  11157. var req *http.Request
  11158. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11159. if miConfig.MdtrtareaAdmvs == "320921" {
  11160. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11161. } else {
  11162. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11163. }
  11164. resp, _ := client.Do(req)
  11165. defer resp.Body.Close()
  11166. body, ioErr := ioutil.ReadAll(resp.Body)
  11167. if ioErr != nil {
  11168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11170. return res
  11171. }
  11172. var respJSON map[string]interface{}
  11173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11176. return res
  11177. }
  11178. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11179. fmt.Println(respJSON)
  11180. result, _ := json.Marshal(respJSON)
  11181. fmt.Println(result)
  11182. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11183. utils.ErrorLog("解析失败:%v", err)
  11184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11185. return res
  11186. }
  11187. return res
  11188. } else {
  11189. //if miConfig.MdtrtareaAdmvs == "441202" {
  11190. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11191. saveLog(output, input, "3101", "事前")
  11192. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11193. utils.ErrorLog("解析失败:%v", err)
  11194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11195. return
  11196. }
  11197. return res
  11198. //}
  11199. }
  11200. }
  11201. 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) {
  11202. adminUser := c.GetAdminUserInfo()
  11203. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11204. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11205. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11206. //record_time := c.GetString("record_time")
  11207. //trig_scen := c.GetString("trig_scen")
  11208. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11209. timeLayout := "2006-01-02"
  11210. loc, _ := time.LoadLocation("Local")
  11211. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11212. if err != nil {
  11213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11214. return res
  11215. }
  11216. recordDateTime := theTime.Unix()
  11217. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11218. var patientPrescription models.HisPrescriptionInfo
  11219. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11220. if patientPrescription.ID == 0 {
  11221. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11222. }
  11223. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11224. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11225. //
  11226. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11227. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11228. var pp models.PublicParams
  11229. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11230. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11231. pp.FixmedinsName = miConfig.OrgName
  11232. pp.FixmedinsCode = miConfig.Code
  11233. pp.RequestUrl = miConfig.Url
  11234. pp.Cainfo = miConfig.Cainfo
  11235. pp.SecretKey = miConfig.SecretKey
  11236. pp.AccessKey = miConfig.AccessKey
  11237. pp.OpterName = roles.UserName
  11238. var config []*models.HisXtDiagnoseConfig
  11239. for _, item := range diagnosis_ids {
  11240. id, _ := strconv.ParseInt(item, 10, 64)
  11241. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11242. config = append(config, &diagnosisConfig)
  11243. }
  11244. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11245. var pd models.PatientDtos
  11246. pd.PatnID = his.PsnNo
  11247. pd.PatnName = his.Name
  11248. pd.Gend = his.Gend
  11249. pd.Brdy = str
  11250. pd.Poolarea = his.InsuplcAdmdvs
  11251. pd.CurrMdtrtID = his.Number
  11252. var fed models.FsiEncounterDtos
  11253. fed.MdtrtID = his.Number
  11254. fed.MedinsID = miConfig.Code
  11255. fed.MedinsName = miConfig.OrgName
  11256. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11257. fed.MedMdtrtType = "1"
  11258. fed.MedinsType = "1"
  11259. fed.MedinsLv = "11"
  11260. tm := time.Unix(his.RecordDate, 0)
  11261. s_tm := tm.Format("2006-01-02 15:04:05")
  11262. fed.AdmDate = s_tm
  11263. fed.DscgDate = s_tm
  11264. fed.DscgMainDiseCodg = config[0].CountryCode
  11265. fed.DscgMainDiseName = config[0].CountryContentName
  11266. //诊断信息
  11267. var fdds []*models.FsiDiagnoseDtos
  11268. for index, item := range config {
  11269. if index == 0 {
  11270. var fdd models.FsiDiagnoseDtos
  11271. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11272. fdd.InoutDiseType = "1"
  11273. fdd.MaindiseFlag = "1"
  11274. fdd.DiseDate = s_tm
  11275. fdd.DiasSrtNo = "1"
  11276. fdd.DiseName = item.CountryContentName
  11277. fdd.DiseCodg = item.CountryCode
  11278. fdds = append(fdds, &fdd)
  11279. } else {
  11280. var fdd models.FsiDiagnoseDtos
  11281. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11282. fdd.InoutDiseType = "1"
  11283. fdd.MaindiseFlag = "1"
  11284. fdd.DiseDate = s_tm
  11285. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11286. fdd.DiseName = item.CountryContentName
  11287. fdd.DiseCodg = item.CountryCode
  11288. fdds = append(fdds, &fdd)
  11289. }
  11290. }
  11291. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11292. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11293. fed.AdmDeptName = department.Name
  11294. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11295. fed.DscgDeptName = department.Name
  11296. fed.MedMdtrtType = "1"
  11297. fed.MedType = "11"
  11298. //if his.Insutype == "390" {
  11299. // fed.MedType = "1402"
  11300. //} else {
  11301. // fed.MedType = "9933"
  11302. //}
  11303. var orders []*models.FsiOrderDtos
  11304. if trig_scen == "2" {
  11305. //处方医嘱信息
  11306. for _, item := range prescriptions {
  11307. for _, subItem := range item.HisDoctorAdviceInfo {
  11308. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11309. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11310. var order models.FsiOrderDtos
  11311. order.RxID = strconv.FormatInt(item.ID, 10)
  11312. order.Rxno = strconv.FormatInt(item.ID, 10)
  11313. order.LongDrordFlag = "0"
  11314. order.HilistType = "1"
  11315. order.ChrgType = "1"
  11316. order.DrordBhvr = "0"
  11317. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11318. order.HosplistName = subItem.BaseDrugLib.DrugName
  11319. order.HilistLv = "1"
  11320. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11321. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11322. order.HosplistName = subItem.BaseDrugLib.DrugName
  11323. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11324. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11325. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11326. order.OwnpayAmt = ""
  11327. order.SelfpayAmt = ""
  11328. order.Spec = spec
  11329. order.SpecUnt = subItem.PrescribingNumberUnit
  11330. order.DrordBegnDate = s_tm
  11331. order.DrordStopDate = ""
  11332. order.DrordDrCodg = doctor_info.DoctorNumber
  11333. order.DrordDeptName = department.Name
  11334. order.DrordDeptCodg = department.Number
  11335. order.DrordDrName = doctor_info.UserName
  11336. order.DrordDrProfttl = "234"
  11337. order.CurrDrordFlag = "1"
  11338. orders = append(orders, &order)
  11339. }
  11340. }
  11341. for _, subItem := range item.HisPrescriptionProject {
  11342. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11343. var order models.FsiOrderDtos
  11344. order.RxID = strconv.FormatInt(item.ID, 10)
  11345. order.Rxno = strconv.FormatInt(item.ID, 10)
  11346. order.LongDrordFlag = "0"
  11347. order.HilistType = "1"
  11348. order.ChrgType = "1"
  11349. order.DrordBhvr = "0"
  11350. order.HilistCode = subItem.HisProject.MedicalCode
  11351. order.HosplistName = subItem.HisProject.ProjectName
  11352. order.HilistLv = "1"
  11353. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11354. order.HosplistCode = subItem.HisProject.MedicalCode
  11355. order.HosplistName = subItem.HisProject.ProjectName
  11356. order.Cnt = subItem.Count
  11357. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11358. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11359. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11360. order.OwnpayAmt = ""
  11361. order.SelfpayAmt = ""
  11362. order.Spec = subItem.Unit
  11363. order.SpecUnt = subItem.Unit
  11364. order.DrordBegnDate = s_tm
  11365. order.DrordStopDate = ""
  11366. order.DrordDrCodg = doctor_info.DoctorNumber
  11367. order.DrordDeptName = department.Name
  11368. order.DrordDeptCodg = department.Number
  11369. order.DrordDrName = doctor_info.UserName
  11370. order.DrordDrProfttl = "234"
  11371. order.CurrDrordFlag = "1"
  11372. orders = append(orders, &order)
  11373. }
  11374. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11375. var order models.FsiOrderDtos
  11376. order.RxID = strconv.FormatInt(item.ID, 10)
  11377. order.Rxno = strconv.FormatInt(item.ID, 10)
  11378. order.LongDrordFlag = "0"
  11379. order.HilistType = "1"
  11380. order.ChrgType = "1"
  11381. order.DrordBhvr = "0"
  11382. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11383. order.HosplistName = subItem.GoodInfo.GoodName
  11384. order.HilistLv = "1"
  11385. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11386. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11387. order.HosplistName = subItem.GoodInfo.GoodName
  11388. order.Cnt = subItem.Count
  11389. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11390. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11391. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11392. order.OwnpayAmt = ""
  11393. order.SelfpayAmt = ""
  11394. order.Spec = subItem.GoodInfo.SpecificationName
  11395. order.SpecUnt = subItem.Unit
  11396. order.DrordBegnDate = s_tm
  11397. order.DrordStopDate = ""
  11398. order.DrordDrCodg = doctor_info.DoctorNumber
  11399. order.DrordDeptName = department.Name
  11400. order.DrordDeptCodg = department.Number
  11401. order.DrordDrName = doctor_info.UserName
  11402. order.DrordDrProfttl = "234"
  11403. order.CurrDrordFlag = "1"
  11404. orders = append(orders, &order)
  11405. }
  11406. }
  11407. }
  11408. //处方医嘱信息
  11409. }
  11410. fed.MatnStas = "0"
  11411. fed.MedfeeSumamt = "0"
  11412. fed.OwnpayAmt = "0"
  11413. fed.SelfpayAmt = "0"
  11414. fed.AcctPayamt = "0"
  11415. fed.MaAmt = "0"
  11416. fed.HifpPayamt = "0"
  11417. fed.SetlTotlnum = "1"
  11418. fed.Insutype = his.Insutype
  11419. fed.ReimFlag = "0"
  11420. fed.OutSetlFlag = "0"
  11421. var fopd []*models.FsiOperationDtosData
  11422. data := make(map[string]interface{})
  11423. data["fed"] = fed
  11424. data["fdd"] = fdds
  11425. data["fod"] = orders
  11426. data["pd"] = pd
  11427. data["pp"] = pp
  11428. data["fopd"] = fopd
  11429. data["trig_scen"] = trig_scen
  11430. fmt.Println(data)
  11431. fmt.Println(fed)
  11432. fmt.Println(fdds)
  11433. fmt.Println(orders)
  11434. fmt.Println(pd)
  11435. fmt.Println(pp)
  11436. fmt.Println(fopd)
  11437. client := &http.Client{}
  11438. bytesData, _ := json.Marshal(data)
  11439. var req *http.Request
  11440. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11441. if miConfig.MdtrtareaAdmvs == "320921" {
  11442. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11443. } else {
  11444. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11445. }
  11446. resp, _ := client.Do(req)
  11447. defer resp.Body.Close()
  11448. body, ioErr := ioutil.ReadAll(resp.Body)
  11449. if ioErr != nil {
  11450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11452. return res
  11453. }
  11454. var respJSON map[string]interface{}
  11455. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11458. return res
  11459. }
  11460. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11461. fmt.Println(respJSON)
  11462. result, _ := json.Marshal(respJSON)
  11463. fmt.Println(result)
  11464. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11465. utils.ErrorLog("解析失败:%v", err)
  11466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11467. return res
  11468. }
  11469. return res
  11470. } else {
  11471. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11472. saveLog(output, input, "3101", "事前")
  11473. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11474. utils.ErrorLog("解析失败:%v", err)
  11475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11476. return
  11477. }
  11478. return res
  11479. }
  11480. return res
  11481. }
  11482. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11483. ////patient_id, _ := c.GetInt64("patient_id")
  11484. //order_id, _ := c.GetInt64("order_id")
  11485. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11486. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11487. //trig_scen := c.GetString("trig_scen")
  11488. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11489. //utils.ErrorLog("解析失败:%v", psn_info)
  11490. adminUser := c.GetAdminUserInfo()
  11491. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11492. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11493. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11494. record_time := c.GetString("record_time")
  11495. order, _ := service.GetHisOrderByID(order_id)
  11496. timeLayout := "2006-01-02"
  11497. loc, _ := time.LoadLocation("Local")
  11498. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11499. if err != nil {
  11500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11501. return
  11502. }
  11503. recordDateTime := theTime.Unix()
  11504. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11505. var patientPrescription models.HisPrescriptionInfo
  11506. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11507. if patientPrescription.ID == 0 {
  11508. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11509. }
  11510. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11511. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11512. //
  11513. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11514. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11515. var pp models.PublicParams
  11516. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11517. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11518. pp.FixmedinsName = miConfig.OrgName
  11519. pp.FixmedinsCode = miConfig.Code
  11520. pp.RequestUrl = miConfig.Url
  11521. pp.Cainfo = miConfig.Cainfo
  11522. pp.SecretKey = miConfig.SecretKey
  11523. pp.AccessKey = miConfig.AccessKey
  11524. pp.OpterName = roles.UserName
  11525. var config []*models.HisXtDiagnoseConfig
  11526. for _, item := range diagnosis_ids {
  11527. id, _ := strconv.ParseInt(item, 10, 64)
  11528. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11529. config = append(config, &diagnosisConfig)
  11530. }
  11531. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11532. var pd models.PatientDtos
  11533. pd.PatnID = his.PsnNo
  11534. pd.PatnName = his.Name
  11535. pd.Gend = his.Gend
  11536. pd.Brdy = str
  11537. pd.Poolarea = his.InsuplcAdmdvs
  11538. pd.CurrMdtrtID = his.Number
  11539. var fed models.FsiEncounterDtos
  11540. fed.MdtrtID = his.Number
  11541. fed.MedinsID = miConfig.Code
  11542. fed.MedinsName = miConfig.OrgName
  11543. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11544. fed.MedMdtrtType = "1"
  11545. fed.MedinsType = "1"
  11546. fed.MedinsLv = "11"
  11547. tm := time.Unix(his.RecordDate, 0)
  11548. s_tm := tm.Format("2006-01-02 15:04:05")
  11549. fed.AdmDate = s_tm
  11550. fed.DscgDate = s_tm
  11551. fed.DscgMainDiseCodg = config[0].CountryCode
  11552. fed.DscgMainDiseName = config[0].CountryContentName
  11553. //诊断信息
  11554. var fdds []*models.FsiDiagnoseDtos
  11555. for index, item := range config {
  11556. if index == 0 {
  11557. var fdd models.FsiDiagnoseDtos
  11558. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11559. fdd.InoutDiseType = "1"
  11560. fdd.MaindiseFlag = "1"
  11561. fdd.DiseDate = s_tm
  11562. fdd.DiasSrtNo = "1"
  11563. fdd.DiseName = item.CountryContentName
  11564. fdd.DiseCodg = item.CountryCode
  11565. fdds = append(fdds, &fdd)
  11566. } else {
  11567. var fdd models.FsiDiagnoseDtos
  11568. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11569. fdd.InoutDiseType = "1"
  11570. fdd.MaindiseFlag = "1"
  11571. fdd.DiseDate = s_tm
  11572. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11573. fdd.DiseName = item.CountryContentName
  11574. fdd.DiseCodg = item.CountryCode
  11575. fdds = append(fdds, &fdd)
  11576. }
  11577. }
  11578. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11579. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11580. fed.AdmDeptName = department.Name
  11581. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11582. fed.DscgDeptName = department.Name
  11583. fed.MedType = order.MedType
  11584. //处方医嘱信息
  11585. var orders []*models.FsiOrderDtos
  11586. //for _, item := range prescriptions {
  11587. // for _, subItem := range item.HisDoctorAdviceInfo {
  11588. // var order models.FsiOrderDtos
  11589. // order.RxID = strconv.FormatInt(item.ID, 10)
  11590. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11591. // order.LongDrordFlag = "0"
  11592. // order.HilistType = "1"
  11593. // order.ChrgType = "1"
  11594. // order.DrordBhvr = "-"
  11595. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11596. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11597. // order.HilistLv = "1"
  11598. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11599. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11600. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11601. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11602. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11603. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11604. // order.OwnpayAmt = ""
  11605. // order.SelfpayAmt = ""
  11606. // order.Spec = ""
  11607. // order.SpecUnt = ""
  11608. // order.DrordBegnDate = s_tm
  11609. // order.DrordStopDate = ""
  11610. // order.DrordDrCodg = "1"
  11611. // order.DrordDeptName = department.Name
  11612. // order.DrordDrCodg = "1"
  11613. // order.DrordDrName = doctor_info.UserName
  11614. // order.DrordDrProfttl = ""
  11615. // order.CurrDrordFlag = "1"
  11616. // orders = append(orders, &order)
  11617. // }
  11618. // for _, subItem := range item.HisPrescriptionProject {
  11619. // if subItem.Type == 2 {
  11620. // var order models.FsiOrderDtos
  11621. // order.RxID = strconv.FormatInt(item.ID, 10)
  11622. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11623. // order.LongDrordFlag = "0"
  11624. // order.HilistType = "1"
  11625. // order.ChrgType = "1"
  11626. // order.DrordBhvr = "-"
  11627. // order.HilistCode = subItem.HisProject.MedicalCode
  11628. // order.HosplistName = subItem.HisProject.ProjectName
  11629. // order.HilistLv = "1"
  11630. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11631. // order.HosplistCode = subItem.HisProject.MedicalCode
  11632. // order.HosplistName = subItem.HisProject.ProjectName
  11633. // order.Cnt = subItem.Count
  11634. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11635. //
  11636. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11637. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11638. // order.OwnpayAmt = ""
  11639. // order.SelfpayAmt = ""
  11640. // order.Spec = ""
  11641. // order.SpecUnt = ""
  11642. // order.DrordBegnDate = s_tm
  11643. // order.DrordStopDate = ""
  11644. // order.DrordDrCodg = "1"
  11645. // order.DrordDeptName = department.Name
  11646. // order.DrordDrCodg = "1"
  11647. // order.DrordDrName = doctor_info.UserName
  11648. // order.DrordDrProfttl = ""
  11649. // order.CurrDrordFlag = "1"
  11650. // orders = append(orders, &order)
  11651. //
  11652. // }
  11653. // if subItem.Type == 3 {
  11654. //
  11655. // var order models.FsiOrderDtos
  11656. // order.RxID = strconv.FormatInt(item.ID, 10)
  11657. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11658. // order.LongDrordFlag = "0"
  11659. // order.HilistType = "1"
  11660. // order.ChrgType = "1"
  11661. // order.DrordBhvr = "-"
  11662. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11663. // order.HosplistName = subItem.GoodInfo.GoodName
  11664. // order.HilistLv = "1"
  11665. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11666. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11667. // order.HosplistName = subItem.GoodInfo.GoodName
  11668. // order.Cnt = subItem.Count
  11669. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11670. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11671. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11672. // order.OwnpayAmt = ""
  11673. // order.SelfpayAmt = ""
  11674. // order.Spec = ""
  11675. // order.SpecUnt = ""
  11676. // order.DrordBegnDate = s_tm
  11677. // order.DrordStopDate = ""
  11678. // order.DrordDrCodg = "1"
  11679. // order.DrordDeptName = department.Name
  11680. // order.DrordDrCodg = "1"
  11681. // order.DrordDrName = doctor_info.UserName
  11682. // order.DrordDrProfttl = ""
  11683. // order.CurrDrordFlag = "1"
  11684. // orders = append(orders, &order)
  11685. //
  11686. // }
  11687. // }
  11688. //}
  11689. for _, item := range prescriptions {
  11690. for _, subItem := range item.HisDoctorAdviceInfo {
  11691. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11692. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11693. var order models.FsiOrderDtos
  11694. order.RxID = strconv.FormatInt(item.ID, 10)
  11695. order.Rxno = strconv.FormatInt(item.ID, 10)
  11696. order.LongDrordFlag = "0"
  11697. order.HilistType = "1"
  11698. order.ChrgType = "1"
  11699. order.DrordBhvr = "0"
  11700. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11701. order.HosplistName = subItem.BaseDrugLib.DrugName
  11702. order.HilistLv = "1"
  11703. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11704. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11705. order.HosplistName = subItem.BaseDrugLib.DrugName
  11706. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11707. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11708. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11709. order.OwnpayAmt = ""
  11710. order.SelfpayAmt = ""
  11711. order.Spec = spec
  11712. order.SpecUnt = subItem.PrescribingNumberUnit
  11713. order.DrordBegnDate = s_tm
  11714. order.DrordStopDate = ""
  11715. order.DrordDrCodg = doctor_info.DoctorNumber
  11716. order.DrordDeptName = department.Name
  11717. order.DrordDeptCodg = department.Number
  11718. order.DrordDrName = doctor_info.UserName
  11719. order.DrordDrProfttl = "234"
  11720. order.CurrDrordFlag = "1"
  11721. orders = append(orders, &order)
  11722. }
  11723. }
  11724. for _, subItem := range item.HisPrescriptionProject {
  11725. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11726. var order models.FsiOrderDtos
  11727. order.RxID = strconv.FormatInt(item.ID, 10)
  11728. order.Rxno = strconv.FormatInt(item.ID, 10)
  11729. order.LongDrordFlag = "0"
  11730. order.HilistType = "1"
  11731. order.ChrgType = "1"
  11732. order.DrordBhvr = "0"
  11733. order.HilistCode = subItem.HisProject.MedicalCode
  11734. order.HosplistName = subItem.HisProject.ProjectName
  11735. order.HilistLv = "1"
  11736. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11737. order.HosplistCode = subItem.HisProject.MedicalCode
  11738. order.HosplistName = subItem.HisProject.ProjectName
  11739. order.Cnt = subItem.Count
  11740. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11741. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11742. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11743. order.OwnpayAmt = ""
  11744. order.SelfpayAmt = ""
  11745. order.Spec = subItem.Unit
  11746. order.SpecUnt = subItem.Unit
  11747. order.DrordBegnDate = s_tm
  11748. order.DrordStopDate = ""
  11749. order.DrordDrCodg = doctor_info.DoctorNumber
  11750. order.DrordDeptName = department.Name
  11751. order.DrordDeptCodg = department.Number
  11752. order.DrordDrName = doctor_info.UserName
  11753. order.DrordDrProfttl = "234"
  11754. order.CurrDrordFlag = "1"
  11755. orders = append(orders, &order)
  11756. }
  11757. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11758. var order models.FsiOrderDtos
  11759. order.RxID = strconv.FormatInt(item.ID, 10)
  11760. order.Rxno = strconv.FormatInt(item.ID, 10)
  11761. order.LongDrordFlag = "0"
  11762. order.HilistType = "1"
  11763. order.ChrgType = "1"
  11764. order.DrordBhvr = "0"
  11765. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11766. order.HosplistName = subItem.GoodInfo.GoodName
  11767. order.HilistLv = "1"
  11768. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11769. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11770. order.HosplistName = subItem.GoodInfo.GoodName
  11771. order.Cnt = subItem.Count
  11772. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11773. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11774. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11775. order.OwnpayAmt = ""
  11776. order.SelfpayAmt = ""
  11777. order.Spec = subItem.GoodInfo.SpecificationName
  11778. order.SpecUnt = subItem.Unit
  11779. order.DrordBegnDate = s_tm
  11780. order.DrordStopDate = ""
  11781. order.DrordDrCodg = doctor_info.DoctorNumber
  11782. order.DrordDeptName = department.Name
  11783. order.DrordDeptCodg = department.Number
  11784. order.DrordDrName = doctor_info.UserName
  11785. order.DrordDrProfttl = "234"
  11786. order.CurrDrordFlag = "1"
  11787. orders = append(orders, &order)
  11788. }
  11789. }
  11790. }
  11791. //处方医嘱信息
  11792. fed.MatnStas = "0"
  11793. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11794. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11795. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11796. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11797. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11798. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11799. fed.SetlTotlnum = "1"
  11800. fed.Insutype = his.Insutype
  11801. fed.ReimFlag = "0"
  11802. fed.OutSetlFlag = "0"
  11803. var fopd []*models.FsiOperationDtosData
  11804. data := make(map[string]interface{})
  11805. data["fed"] = fed
  11806. data["fdd"] = fdds
  11807. data["fod"] = orders
  11808. data["pd"] = pd
  11809. data["pp"] = pp
  11810. data["fopd"] = fopd
  11811. data["trig_scen"] = trig_scen
  11812. client := &http.Client{}
  11813. bytesData, _ := json.Marshal(data)
  11814. var req *http.Request
  11815. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11816. if miConfig.MdtrtareaAdmvs == "320921" {
  11817. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11818. } else {
  11819. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11820. }
  11821. resp, _ := client.Do(req)
  11822. defer resp.Body.Close()
  11823. body, ioErr := ioutil.ReadAll(resp.Body)
  11824. if ioErr != nil {
  11825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11827. return res
  11828. }
  11829. var respJSON map[string]interface{}
  11830. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11833. return res
  11834. }
  11835. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11836. result, _ := json.Marshal(respJSON)
  11837. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11838. utils.ErrorLog("解析失败:%v", err)
  11839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11840. return res
  11841. }
  11842. return res
  11843. } else {
  11844. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11845. saveLog(output, input, "3102", "事中")
  11846. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11847. utils.ErrorLog("解析失败:%v", err)
  11848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11849. return
  11850. }
  11851. return res
  11852. }
  11853. return res
  11854. }
  11855. func (c *HisApiController) Check() {
  11856. psn_no := c.GetString("psn_no")
  11857. in := c.GetString("in")
  11858. mt := c.GetString("mt")
  11859. baseParams := models.BaseParams{
  11860. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  11861. FixmedinsCode: "H15049901371",
  11862. InsuplcAdmdvs: "150499",
  11863. MdtrtareaAdmvs: "150499",
  11864. OrgName: "赤峰费森血液透析中心",
  11865. Doctor: "1111",
  11866. }
  11867. service.Gdyb2001(baseParams, psn_no, in, mt)
  11868. }
  11869. func (c *HisApiController) GetPsnNcdsInfo() {
  11870. admin_user_id, _ := c.GetInt64("admin_user_id")
  11871. patient_id, _ := c.GetInt64("patient_id")
  11872. //id, _ := c.GetInt64("id")
  11873. adminUser := c.GetAdminUserInfo()
  11874. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11875. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11876. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  11877. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11878. //psn_record, _ := service.GetP(id)
  11879. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11880. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  11881. //
  11882. //if psn_record.ID == 0 {
  11883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11884. // return
  11885. //}
  11886. var res Result5301
  11887. var res10265 Result5301For10265
  11888. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11889. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11890. var api string
  11891. if miConfig.MdtrtareaAdmvs == "320921" {
  11892. 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 +
  11893. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11894. } else {
  11895. 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 +
  11896. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11897. }
  11898. resp, requestErr := http.Get(api)
  11899. if requestErr != nil {
  11900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11901. return
  11902. }
  11903. body, ioErr := ioutil.ReadAll(resp.Body)
  11904. if ioErr != nil {
  11905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11907. return
  11908. }
  11909. var respJSON map[string]interface{}
  11910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11913. return
  11914. }
  11915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11916. result, _ := json.Marshal(respJSON)
  11917. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11918. utils.ErrorLog("解析失败:%v", err)
  11919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11920. return
  11921. }
  11922. res.ErrMsg = res10265.ErrMsg
  11923. res.Output = res10265.Output
  11924. res.InfRefmsgid = res10265.InfRefmsgid
  11925. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11926. res.Infcode = infocode
  11927. } else if miConfig.MdtrtareaAdmvs == "341203" {
  11928. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11929. var api string
  11930. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11931. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11932. resp, requestErr := http.Get(api)
  11933. if requestErr != nil {
  11934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11935. return
  11936. }
  11937. body, ioErr := ioutil.ReadAll(resp.Body)
  11938. if ioErr != nil {
  11939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11941. return
  11942. }
  11943. var respJSON map[string]interface{}
  11944. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11947. return
  11948. }
  11949. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11950. if status == "0" {
  11951. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11952. c.ServeSuccessJSON(map[string]interface{}{
  11953. "failed_code": -10,
  11954. "msg": err_msg,
  11955. })
  11956. return
  11957. }
  11958. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11959. result, _ := json.Marshal(respJSON)
  11960. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11961. utils.ErrorLog("解析失败:%v", err)
  11962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11963. return
  11964. }
  11965. } else if miConfig.MdtrtareaAdmvs == "340699" {
  11966. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11967. var api string
  11968. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11969. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11970. resp, requestErr := http.Get(api)
  11971. if requestErr != nil {
  11972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11973. return
  11974. }
  11975. body, ioErr := ioutil.ReadAll(resp.Body)
  11976. if ioErr != nil {
  11977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11979. return
  11980. }
  11981. var respJSON map[string]interface{}
  11982. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11985. return
  11986. }
  11987. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11988. if status == "0" {
  11989. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11990. c.ServeSuccessJSON(map[string]interface{}{
  11991. "failed_code": -10,
  11992. "msg": err_msg,
  11993. })
  11994. return
  11995. }
  11996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11997. result, _ := json.Marshal(respJSON)
  11998. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11999. utils.ErrorLog("解析失败:%v", err)
  12000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12001. return
  12002. }
  12003. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12004. p, _ := service.GetHisPatientById(patient_id)
  12005. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12006. var dat map[string]interface{}
  12007. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12008. fmt.Println(dat)
  12009. } else {
  12010. fmt.Println(err)
  12011. }
  12012. userJSONBytes, _ := json.Marshal(dat)
  12013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12014. utils.ErrorLog("解析失败:%v", err)
  12015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12016. return
  12017. }
  12018. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12019. p, _ := service.GetHisPatientById(patient_id)
  12020. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12021. var dat map[string]interface{}
  12022. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12023. fmt.Println(dat)
  12024. } else {
  12025. fmt.Println(err)
  12026. }
  12027. userJSONBytes, _ := json.Marshal(dat)
  12028. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12029. utils.ErrorLog("解析失败:%v", err)
  12030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12031. return
  12032. }
  12033. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12034. p, _ := service.GetHisPatientById(patient_id)
  12035. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12036. var dat map[string]interface{}
  12037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12038. fmt.Println(dat)
  12039. } else {
  12040. fmt.Println(err)
  12041. }
  12042. userJSONBytes, _ := json.Marshal(dat)
  12043. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12044. utils.ErrorLog("解析失败:%v", err)
  12045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12046. return
  12047. }
  12048. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12049. p, _ := service.GetHisPatientById(patient_id)
  12050. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12051. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12052. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12053. resp, requestErr := http.Get(api)
  12054. if requestErr != nil {
  12055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12056. return
  12057. }
  12058. body, ioErr := ioutil.ReadAll(resp.Body)
  12059. if ioErr != nil {
  12060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12062. return
  12063. }
  12064. var respJSON map[string]interface{}
  12065. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12068. return
  12069. }
  12070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12071. result, _ := json.Marshal(respJSON)
  12072. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12073. utils.ErrorLog("解析失败:%v", err)
  12074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12075. return
  12076. }
  12077. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12078. p, _ := service.GetHisPatientById(patient_id)
  12079. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12080. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12081. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12082. resp, requestErr := http.Get(api)
  12083. if requestErr != nil {
  12084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12085. return
  12086. }
  12087. body, ioErr := ioutil.ReadAll(resp.Body)
  12088. if ioErr != nil {
  12089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12091. return
  12092. }
  12093. var respJSON map[string]interface{}
  12094. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12097. return
  12098. }
  12099. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12100. result, _ := json.Marshal(respJSON)
  12101. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12102. utils.ErrorLog("解析失败:%v", err)
  12103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12104. return
  12105. }
  12106. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12107. p, _ := service.GetHisPatientById(patient_id)
  12108. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12109. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12110. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12111. resp, requestErr := http.Get(api)
  12112. if requestErr != nil {
  12113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12114. return
  12115. }
  12116. body, ioErr := ioutil.ReadAll(resp.Body)
  12117. if ioErr != nil {
  12118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12120. return
  12121. }
  12122. var respJSON map[string]interface{}
  12123. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12126. return
  12127. }
  12128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12129. result, _ := json.Marshal(respJSON)
  12130. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12131. utils.ErrorLog("解析失败:%v", err)
  12132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12133. return
  12134. }
  12135. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12136. p, _ := service.GetHisPatientById(patient_id)
  12137. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12138. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12139. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12140. resp, requestErr := http.Get(api)
  12141. if requestErr != nil {
  12142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12143. return
  12144. }
  12145. body, ioErr := ioutil.ReadAll(resp.Body)
  12146. if ioErr != nil {
  12147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12149. return
  12150. }
  12151. var respJSON map[string]interface{}
  12152. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12155. return
  12156. }
  12157. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12158. result, _ := json.Marshal(respJSON)
  12159. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12160. utils.ErrorLog("解析失败:%v", err)
  12161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12162. return
  12163. }
  12164. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12165. p, _ := service.GetHisPatientById(patient_id)
  12166. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12167. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12168. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12169. resp, requestErr := http.Get(api)
  12170. if requestErr != nil {
  12171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12172. return
  12173. }
  12174. body, ioErr := ioutil.ReadAll(resp.Body)
  12175. if ioErr != nil {
  12176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12178. return
  12179. }
  12180. var respJSON map[string]interface{}
  12181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12184. return
  12185. }
  12186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12187. result, _ := json.Marshal(respJSON)
  12188. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12189. utils.ErrorLog("解析失败:%v", err)
  12190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12191. return
  12192. }
  12193. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12194. p, _ := service.GetHisPatientById(patient_id)
  12195. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12196. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12197. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12198. resp, requestErr := http.Get(api)
  12199. if requestErr != nil {
  12200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12201. return
  12202. }
  12203. body, ioErr := ioutil.ReadAll(resp.Body)
  12204. if ioErr != nil {
  12205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12207. return
  12208. }
  12209. var respJSON map[string]interface{}
  12210. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12213. return
  12214. }
  12215. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12216. result, _ := json.Marshal(respJSON)
  12217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12218. utils.ErrorLog("解析失败:%v", err)
  12219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12220. return
  12221. }
  12222. } else {
  12223. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12224. var dat map[string]interface{}
  12225. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12226. fmt.Println(dat)
  12227. } else {
  12228. fmt.Println(err)
  12229. }
  12230. userJSONBytes, _ := json.Marshal(dat)
  12231. if miConfig.Code == "H15049901371" {
  12232. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12233. utils.ErrorLog("解析失败:%v", err)
  12234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12235. return
  12236. }
  12237. res.InfRefmsgid = res10265.InfRefmsgid
  12238. res.Output = res10265.Output
  12239. res.ErrMsg = res10265.ErrMsg
  12240. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12241. res.Infcode = infocode
  12242. } else {
  12243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12244. utils.ErrorLog("解析失败:%v", err)
  12245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12246. return
  12247. }
  12248. }
  12249. }
  12250. if res.Infcode == 0 {
  12251. c.ServeSuccessJSON(map[string]interface{}{
  12252. "result": res.Output.Result,
  12253. })
  12254. }
  12255. }
  12256. func (c *HisApiController) CheckInsutype() {
  12257. his_patient_id, _ := c.GetInt64("his_patient_id")
  12258. admin_user_id, _ := c.GetInt64("admin_user_id")
  12259. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12260. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12261. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12262. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12263. var dat map[string]interface{}
  12264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12265. fmt.Println(dat)
  12266. } else {
  12267. fmt.Println(err)
  12268. }
  12269. userJSONBytes, _ := json.Marshal(dat)
  12270. var res Result90100
  12271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12272. utils.ErrorLog("解析失败:%v", err)
  12273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12274. return
  12275. }
  12276. if res.Infcode != 0 {
  12277. c.ServeSuccessJSON(map[string]interface{}{
  12278. "failed_code": -10,
  12279. "msg": res.ErrMsg,
  12280. })
  12281. return
  12282. } else {
  12283. fmt.Println(res)
  12284. }
  12285. }
  12286. func (c *HisApiController) CheckCardPWD() {
  12287. card_pwd := c.GetString("card_pwd")
  12288. his_patient_id, _ := c.GetInt64("his_patient_id")
  12289. admin_user_id, _ := c.GetInt64("admin_user_id")
  12290. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12291. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12292. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12293. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12294. bas := strings.Split(psn.CardInfo, "|")
  12295. basNumber := bas[2]
  12296. if psn.InsuplcAdmdvs[:4] == "4403" {
  12297. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12298. var dat map[string]interface{}
  12299. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12300. fmt.Println(dat)
  12301. } else {
  12302. fmt.Println(err)
  12303. }
  12304. userJSONBytes, _ := json.Marshal(dat)
  12305. var res Result90991
  12306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12307. utils.ErrorLog("解析失败:%v", err)
  12308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12309. return
  12310. }
  12311. if res.Infcode != 0 {
  12312. c.ServeSuccessJSON(map[string]interface{}{
  12313. "failed_code": -10,
  12314. "msg": res.ErrMsg,
  12315. })
  12316. return
  12317. } else {
  12318. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12319. var msg string
  12320. switch res.Output.Result.CardStat {
  12321. case "00":
  12322. msg = "未激活"
  12323. break
  12324. case "10":
  12325. msg = "激活"
  12326. break
  12327. case "20":
  12328. msg = "窗口挂失"
  12329. break
  12330. case "21":
  12331. msg = "电话挂失"
  12332. break
  12333. case "22":
  12334. msg = "单位网上申报挂失"
  12335. break
  12336. case "23":
  12337. msg = "保健办挂失"
  12338. break
  12339. case "24":
  12340. msg = "个人网上挂失"
  12341. break
  12342. case "25":
  12343. msg = "网上服务大厅挂失"
  12344. break
  12345. case "30":
  12346. msg = "注销"
  12347. break
  12348. case "40":
  12349. msg = "回收"
  12350. break
  12351. case "99":
  12352. msg = "制卡中(无效卡)"
  12353. break
  12354. }
  12355. c.ServeSuccessJSON(map[string]interface{}{
  12356. "failed_code": -10,
  12357. "msg": msg,
  12358. })
  12359. return
  12360. } else {
  12361. c.ServeSuccessJSON(map[string]interface{}{
  12362. "msg": "校验成功",
  12363. })
  12364. return
  12365. }
  12366. }
  12367. } else {
  12368. c.ServeSuccessJSON(map[string]interface{}{
  12369. "msg": "校验成功",
  12370. })
  12371. return
  12372. }
  12373. }
  12374. func (c *HisApiController) CheckCardPWDTwo() {
  12375. //card_pwd := c.GetString("card_pwd")
  12376. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12377. admin_user_id, _ := c.GetInt64("admin_user_id")
  12378. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12379. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12380. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12381. var dat map[string]interface{}
  12382. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12383. fmt.Println(dat)
  12384. } else {
  12385. fmt.Println(err)
  12386. }
  12387. userJSONBytes, _ := json.Marshal(dat)
  12388. var res Result90991
  12389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12390. utils.ErrorLog("解析失败:%v", err)
  12391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12392. return
  12393. }
  12394. if res.Infcode != 0 {
  12395. c.ServeSuccessJSON(map[string]interface{}{
  12396. "failed_code": -10,
  12397. "msg": res.ErrMsg,
  12398. })
  12399. return
  12400. } else {
  12401. if res.Output.Result.SscnoCheckStat == "0" {
  12402. var msg string
  12403. switch res.Output.Result.CardStat {
  12404. case "00":
  12405. msg = "未激活"
  12406. break
  12407. case "10":
  12408. msg = "激活"
  12409. break
  12410. case "20":
  12411. msg = "窗口挂失"
  12412. break
  12413. case "21":
  12414. msg = "电话挂失"
  12415. break
  12416. case "22":
  12417. msg = "单位网上申报挂失"
  12418. break
  12419. case "23":
  12420. msg = "保健办挂失"
  12421. break
  12422. case "24":
  12423. msg = "个人网上挂失"
  12424. break
  12425. case "25":
  12426. msg = "网上服务大厅挂失"
  12427. break
  12428. case "30":
  12429. msg = "注销"
  12430. break
  12431. case "40":
  12432. msg = "回收"
  12433. break
  12434. case "99":
  12435. msg = "制卡中(无效卡)"
  12436. break
  12437. }
  12438. c.ServeSuccessJSON(map[string]interface{}{
  12439. "failed_code": -10,
  12440. "msg": msg,
  12441. })
  12442. return
  12443. } else {
  12444. c.ServeSuccessJSON(map[string]interface{}{
  12445. "msg": "校验成功",
  12446. })
  12447. return
  12448. }
  12449. }
  12450. }
  12451. type ELeCertData struct {
  12452. Data struct {
  12453. Extra string `json:"extra"`
  12454. IDNo string `json:"idNo"`
  12455. IDType string `json:"idType"`
  12456. EcToken string `json:"ecToken"`
  12457. InsuOrg string `json:"insuOrg"`
  12458. UserName string `json:"userName"`
  12459. EcIndexNo string `json:"ecIndexNo"`
  12460. Gender string `json:"gender"`
  12461. Birthday string `json:"birthday"`
  12462. Nationality string `json:"nationality"`
  12463. Email string `json:"email"`
  12464. } `json:"OutData"`
  12465. }
  12466. func (c *HisApiController) ReadCard() {
  12467. id_card_type, _ := c.GetInt64("id_card_type")
  12468. admin_user_id, _ := c.GetInt64("admin_user_id")
  12469. certificates, _ := c.GetInt64("certificates")
  12470. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12471. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12472. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12473. switch id_card_type {
  12474. case 1:
  12475. if miConfig.MdtrtareaAdmvs == "421300" {
  12476. var res ResultTwo
  12477. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12478. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12479. "&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)
  12480. resp, requestErr := http.Get(api)
  12481. if requestErr != nil {
  12482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12483. return
  12484. }
  12485. body, ioErr := ioutil.ReadAll(resp.Body)
  12486. if ioErr != nil {
  12487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12489. return
  12490. }
  12491. var respJSON map[string]interface{}
  12492. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12495. return
  12496. }
  12497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12498. result, _ := json.Marshal(respJSON)
  12499. fmt.Println("log")
  12500. fmt.Println(string(result))
  12501. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12502. utils.ErrorLog("解析失败:%v", err)
  12503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12504. return
  12505. }
  12506. if res.Infcode == 0 {
  12507. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12508. if err == gorm.ErrRecordNotFound {
  12509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12510. return
  12511. } else if err != nil {
  12512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12513. return
  12514. } else {
  12515. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12516. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12517. infoStr := string(Iinfos)
  12518. idetinfoStr := string(Idetinfos)
  12519. var rf []*ResultFive
  12520. json.Unmarshal([]byte(infoStr), &rf)
  12521. var insutypes []*ResultFive
  12522. var insutype string
  12523. var is390 int = 0
  12524. var is310 int = 0
  12525. for _, item := range rf {
  12526. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12527. insutypes = append(insutypes, item)
  12528. }
  12529. }
  12530. if len(insutypes) == 1 {
  12531. insutype = insutypes[0].Insutype
  12532. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12533. } else {
  12534. for _, i := range insutypes {
  12535. if i.Insutype == "390" {
  12536. is390 = 1
  12537. }
  12538. if i.Insutype == "310" {
  12539. is310 = 1
  12540. }
  12541. }
  12542. }
  12543. if is390 == 1 {
  12544. insutype = "390"
  12545. }
  12546. if is310 == 1 {
  12547. insutype = "310"
  12548. }
  12549. if len(insutypes) == 0 {
  12550. insutype = "390"
  12551. }
  12552. var insuplc_admdvs string
  12553. for _, item := range rf {
  12554. if item.Insutype == insutype {
  12555. insuplc_admdvs = item.InsuplcAdmdvs
  12556. }
  12557. }
  12558. if strings.Contains(insuplc_admdvs, "4213") {
  12559. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12560. }
  12561. psn := &models.HisPsn{
  12562. PsnNo: res.Output.Baseinfo.PsnNo,
  12563. PatientId: patient.ID,
  12564. Certno: res.Output.Baseinfo.Certno,
  12565. Gend: res.Output.Baseinfo.Gend,
  12566. Naty: res.Output.Baseinfo.Naty,
  12567. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12568. PsnName: res.Output.Baseinfo.PsnName,
  12569. Idetinfo: idetinfoStr,
  12570. Insuinfo: infoStr,
  12571. InsuplcAdmdvs: insuplc_admdvs,
  12572. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12573. }
  12574. service.CreateHisPsn(psn)
  12575. c.ServeSuccessJSON(map[string]interface{}{
  12576. "patient": patient,
  12577. "number": res.Output.Baseinfo.Certno,
  12578. })
  12579. }
  12580. } else {
  12581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12582. return
  12583. }
  12584. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12585. var res ResultTwo
  12586. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12587. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12588. "&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)
  12589. resp, requestErr := http.Get(api)
  12590. if requestErr != nil {
  12591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12592. return
  12593. }
  12594. body, ioErr := ioutil.ReadAll(resp.Body)
  12595. if ioErr != nil {
  12596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12598. return
  12599. }
  12600. var respJSON map[string]interface{}
  12601. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12604. return
  12605. }
  12606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12607. result, _ := json.Marshal(respJSON)
  12608. fmt.Println("log")
  12609. fmt.Println(string(result))
  12610. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12611. utils.ErrorLog("解析失败:%v", err)
  12612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12613. return
  12614. }
  12615. if res.Infcode == 0 {
  12616. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12617. if err == gorm.ErrRecordNotFound {
  12618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12619. return
  12620. } else if err != nil {
  12621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12622. return
  12623. } else {
  12624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12626. infoStr := string(Iinfos)
  12627. idetinfoStr := string(Idetinfos)
  12628. psn := &models.HisPsn{
  12629. PsnNo: res.Output.Baseinfo.PsnNo,
  12630. PatientId: patient.ID,
  12631. Certno: res.Output.Baseinfo.Certno,
  12632. Gend: res.Output.Baseinfo.Gend,
  12633. Naty: res.Output.Baseinfo.Naty,
  12634. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12635. PsnName: res.Output.Baseinfo.PsnName,
  12636. Idetinfo: idetinfoStr,
  12637. Insuinfo: infoStr,
  12638. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12639. }
  12640. service.CreateHisPsn(psn)
  12641. var rf []*ResultFive
  12642. json.Unmarshal([]byte(infoStr), &rf)
  12643. var insutypes []*ResultFive
  12644. var insutype string
  12645. var is390 int = 0
  12646. var is310 int = 0
  12647. for _, item := range rf {
  12648. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12649. insutypes = append(insutypes, item)
  12650. }
  12651. }
  12652. if len(insutypes) == 1 {
  12653. insutype = insutypes[0].Insutype
  12654. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12655. } else {
  12656. for _, i := range insutypes {
  12657. if i.Insutype == "390" {
  12658. is390 = 1
  12659. }
  12660. if i.Insutype == "310" {
  12661. is310 = 1
  12662. }
  12663. }
  12664. }
  12665. if is390 == 1 {
  12666. insutype = "390"
  12667. }
  12668. if is310 == 1 {
  12669. insutype = "310"
  12670. }
  12671. if len(insutypes) == 0 {
  12672. insutype = "310"
  12673. }
  12674. c.ServeSuccessJSON(map[string]interface{}{
  12675. "patient": patient,
  12676. "number": res.Output.Baseinfo.Certno,
  12677. "insutype": insutype,
  12678. })
  12679. }
  12680. } else {
  12681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12682. return
  12683. }
  12684. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12685. var res ResultTwo
  12686. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12687. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12688. "&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)
  12689. resp, requestErr := http.Get(api)
  12690. if requestErr != nil {
  12691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12692. return
  12693. }
  12694. body, ioErr := ioutil.ReadAll(resp.Body)
  12695. if ioErr != nil {
  12696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12698. return
  12699. }
  12700. var respJSON map[string]interface{}
  12701. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12704. return
  12705. }
  12706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12707. result, _ := json.Marshal(respJSON)
  12708. fmt.Println("log")
  12709. fmt.Println(string(result))
  12710. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12711. utils.ErrorLog("解析失败:%v", err)
  12712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12713. return
  12714. }
  12715. if res.Infcode == 0 {
  12716. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12717. if err == gorm.ErrRecordNotFound {
  12718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12719. return
  12720. } else if err != nil {
  12721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12722. return
  12723. } else {
  12724. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12725. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12726. infoStr := string(Iinfos)
  12727. idetinfoStr := string(Idetinfos)
  12728. var rf []*ResultFive
  12729. json.Unmarshal([]byte(infoStr), &rf)
  12730. var insutypes []*ResultFive
  12731. var insutype string
  12732. var is390 int = 0
  12733. var is310 int = 0
  12734. for _, item := range rf {
  12735. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12736. insutypes = append(insutypes, item)
  12737. }
  12738. }
  12739. if len(insutypes) == 1 {
  12740. insutype = insutypes[0].Insutype
  12741. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12742. } else {
  12743. for _, i := range insutypes {
  12744. if i.Insutype == "390" {
  12745. is390 = 1
  12746. }
  12747. if i.Insutype == "310" {
  12748. is310 = 1
  12749. }
  12750. }
  12751. }
  12752. if is390 == 1 {
  12753. insutype = "390"
  12754. }
  12755. if is310 == 1 {
  12756. insutype = "310"
  12757. }
  12758. if len(insutypes) == 0 {
  12759. insutype = "390"
  12760. }
  12761. var insuplc_admdvs string
  12762. for _, item := range rf {
  12763. if item.Insutype == insutype {
  12764. insuplc_admdvs = item.InsuplcAdmdvs
  12765. }
  12766. }
  12767. psn := &models.HisPsn{
  12768. PsnNo: res.Output.Baseinfo.PsnNo,
  12769. PatientId: patient.ID,
  12770. Certno: res.Output.Baseinfo.Certno,
  12771. Gend: res.Output.Baseinfo.Gend,
  12772. Naty: res.Output.Baseinfo.Naty,
  12773. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12774. PsnName: res.Output.Baseinfo.PsnName,
  12775. Idetinfo: idetinfoStr,
  12776. Insuinfo: infoStr,
  12777. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12778. InsuplcAdmdvs: insuplc_admdvs,
  12779. }
  12780. service.CreateHisPsn(psn)
  12781. for _, item := range rf {
  12782. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12783. insutypes = append(insutypes, item)
  12784. }
  12785. }
  12786. if len(insutypes) == 1 {
  12787. insutype = insutypes[0].Insutype
  12788. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12789. } else {
  12790. for _, i := range insutypes {
  12791. if i.Insutype == "390" {
  12792. is390 = 1
  12793. }
  12794. if i.Insutype == "310" {
  12795. is310 = 1
  12796. }
  12797. }
  12798. }
  12799. if is390 == 1 {
  12800. insutype = "390"
  12801. }
  12802. if is310 == 1 {
  12803. insutype = "310"
  12804. }
  12805. if len(insutypes) == 0 {
  12806. insutype = "310"
  12807. }
  12808. c.ServeSuccessJSON(map[string]interface{}{
  12809. "patient": patient,
  12810. "number": res.Output.Baseinfo.Certno,
  12811. "insutype": insutype,
  12812. })
  12813. }
  12814. } else {
  12815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12816. return
  12817. }
  12818. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12819. var res ResultTwo
  12820. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12821. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12822. "&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)
  12823. resp, requestErr := http.Get(api)
  12824. if requestErr != nil {
  12825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12826. return
  12827. }
  12828. body, ioErr := ioutil.ReadAll(resp.Body)
  12829. if ioErr != nil {
  12830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12832. return
  12833. }
  12834. var respJSON map[string]interface{}
  12835. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12838. return
  12839. }
  12840. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12841. result, _ := json.Marshal(respJSON)
  12842. fmt.Println("log")
  12843. fmt.Println(string(result))
  12844. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12845. utils.ErrorLog("解析失败:%v", err)
  12846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12847. return
  12848. }
  12849. if res.Infcode == 0 {
  12850. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12851. if err == gorm.ErrRecordNotFound {
  12852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12853. return
  12854. } else if err != nil {
  12855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12856. return
  12857. } else {
  12858. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12859. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12860. infoStr := string(Iinfos)
  12861. idetinfoStr := string(Idetinfos)
  12862. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12863. psn := &models.HisPsn{
  12864. PsnNo: res.Output.Baseinfo.PsnNo,
  12865. PatientId: patient.ID,
  12866. Certno: res.Output.Baseinfo.Certno,
  12867. Brdy: b,
  12868. Age: float64(age),
  12869. Gend: res.Output.Baseinfo.Gend,
  12870. Naty: res.Output.Baseinfo.Naty,
  12871. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12872. PsnName: res.Output.Baseinfo.PsnName,
  12873. Idetinfo: idetinfoStr,
  12874. Insuinfo: infoStr,
  12875. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12876. }
  12877. service.CreateHisPsn(psn)
  12878. var rf []*ResultFive
  12879. json.Unmarshal([]byte(infoStr), &rf)
  12880. var insutypes []*ResultFive
  12881. var insutype string
  12882. var is390 int = 0
  12883. var is310 int = 0
  12884. for _, item := range rf {
  12885. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12886. insutypes = append(insutypes, item)
  12887. }
  12888. }
  12889. if len(insutypes) == 1 {
  12890. insutype = insutypes[0].Insutype
  12891. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12892. } else {
  12893. for _, i := range insutypes {
  12894. if i.Insutype == "390" {
  12895. is390 = 1
  12896. }
  12897. if i.Insutype == "310" {
  12898. is310 = 1
  12899. }
  12900. }
  12901. }
  12902. if is390 == 1 {
  12903. insutype = "390"
  12904. }
  12905. if is310 == 1 {
  12906. insutype = "310"
  12907. }
  12908. if len(insutypes) == 0 {
  12909. insutype = "310"
  12910. }
  12911. c.ServeSuccessJSON(map[string]interface{}{
  12912. "patient": patient,
  12913. "number": res.Output.Baseinfo.Certno,
  12914. "insutype": insutype,
  12915. })
  12916. }
  12917. } else {
  12918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12919. return
  12920. }
  12921. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12922. var api string
  12923. if miConfig.MdtrtareaAdmvs == "320921" {
  12924. 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 +
  12925. "&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
  12926. fmt.Println(api)
  12927. } else {
  12928. 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 +
  12929. "&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)
  12930. }
  12931. resp, requestErr := http.Get(api)
  12932. if requestErr != nil {
  12933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12934. return
  12935. }
  12936. body, ioErr := ioutil.ReadAll(resp.Body)
  12937. if ioErr != nil {
  12938. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12940. return
  12941. }
  12942. var respJSON map[string]interface{}
  12943. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12944. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12946. return
  12947. }
  12948. var status string
  12949. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12950. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12951. //console.log()
  12952. fmt.Println("type===")
  12953. fmt.Println(card_type)
  12954. var token string
  12955. var res ResultTwo //1101结果
  12956. var res10265 ResultTwo10265 //1101结果
  12957. var card_info string //卡信息
  12958. var busi_card_info string
  12959. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12960. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12961. if status == "0" { //读卡成功
  12962. if card_type == "1" {
  12963. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12964. result, _ := json.Marshal(respJSON)
  12965. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12966. utils.ErrorLog("解析失败:%v", err)
  12967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12968. return
  12969. }
  12970. res.ErrMsg = res10265.ErrMsg
  12971. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12972. res.Infcode = infocode
  12973. res.Output = res10265.Output
  12974. res.InfRefmsgid = res10265.InfRefmsgid
  12975. } else {
  12976. //var card_info string //卡信息
  12977. //var busi_card_info string
  12978. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12979. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12980. //fmt.Println(card_info)
  12981. //fmt.Println(busi_card_info)
  12982. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12983. result, _ := json.Marshal(respJSON)
  12984. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12985. utils.ErrorLog("解析失败:%v", err)
  12986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12987. return
  12988. }
  12989. res.ErrMsg = res10265.ErrMsg
  12990. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12991. res.Infcode = infocode
  12992. res.Output = res10265.Output
  12993. res.InfRefmsgid = res10265.InfRefmsgid
  12994. }
  12995. if res.Infcode == 0 {
  12996. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12997. if err == gorm.ErrRecordNotFound {
  12998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12999. return
  13000. } else if err != nil {
  13001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13002. return
  13003. } else {
  13004. if card_type == "1" {
  13005. bas := strings.Split(card_info, "|")
  13006. basNumber := bas[2]
  13007. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13008. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13009. infoStr := string(Iinfos)
  13010. idetinfoStr := string(Idetinfos)
  13011. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13012. psn := &models.HisPsn{
  13013. PsnNo: res.Output.Baseinfo.PsnNo,
  13014. PatientId: patient.ID,
  13015. Certno: res.Output.Baseinfo.Certno,
  13016. Brdy: b,
  13017. Age: float64(age),
  13018. Gend: res.Output.Baseinfo.Gend,
  13019. Naty: res.Output.Baseinfo.Naty,
  13020. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13021. PsnName: res.Output.Baseinfo.PsnName,
  13022. Idetinfo: idetinfoStr,
  13023. Insuinfo: infoStr,
  13024. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13025. CardInfo: card_info,
  13026. VerifyNumber: busi_card_info,
  13027. }
  13028. service.CreateHisPsn(psn)
  13029. var rf []*ResultFive
  13030. json.Unmarshal([]byte(infoStr), &rf)
  13031. var insutypes []*ResultFive
  13032. var insutype string
  13033. var is390 int = 0
  13034. var is310 int = 0
  13035. for _, item := range rf {
  13036. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13037. insutypes = append(insutypes, item)
  13038. }
  13039. }
  13040. if len(insutypes) == 1 {
  13041. insutype = insutypes[0].Insutype
  13042. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13043. } else {
  13044. for _, i := range insutypes {
  13045. if i.Insutype == "390" {
  13046. is390 = 1
  13047. }
  13048. if i.Insutype == "310" {
  13049. is310 = 1
  13050. }
  13051. }
  13052. }
  13053. if is390 == 1 {
  13054. insutype = "390"
  13055. }
  13056. if is310 == 1 {
  13057. insutype = "310"
  13058. }
  13059. if len(insutypes) == 0 {
  13060. insutype = "310"
  13061. }
  13062. c.ServeSuccessJSON(map[string]interface{}{
  13063. "patient": patient,
  13064. "number": basNumber,
  13065. "insutype": insutype,
  13066. })
  13067. } else {
  13068. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13069. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13070. infoStr := string(Iinfos)
  13071. idetinfoStr := string(Idetinfos)
  13072. psn := &models.HisPsn{
  13073. PsnNo: res.Output.Baseinfo.PsnNo,
  13074. PatientId: patient.ID,
  13075. Certno: res.Output.Baseinfo.Certno,
  13076. Gend: res.Output.Baseinfo.Gend,
  13077. Naty: res.Output.Baseinfo.Naty,
  13078. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13079. PsnName: res.Output.Baseinfo.PsnName,
  13080. Idetinfo: idetinfoStr,
  13081. Insuinfo: infoStr,
  13082. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13083. CardInfo: card_info,
  13084. VerifyNumber: token,
  13085. }
  13086. service.CreateHisPsn(psn)
  13087. c.ServeSuccessJSON(map[string]interface{}{
  13088. "patient": patient,
  13089. "number": token,
  13090. })
  13091. }
  13092. }
  13093. } else {
  13094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13095. return
  13096. }
  13097. } else { //读卡失败
  13098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13099. return
  13100. }
  13101. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13102. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13103. cardnum = DeleteExtraSpaceTwo(cardnum)
  13104. cardCode = DeleteExtraSpaceTwo(cardCode)
  13105. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13106. name = DeleteExtraSpaceTwo(name)
  13107. errmsg = DeleteExtraSpaceTwo(errmsg)
  13108. cardnum = Remove0000(cardnum)
  13109. cardCode = Remove0000(cardCode)
  13110. id_card_no = Remove0000(id_card_no)
  13111. name = Remove0000(name)
  13112. errmsg = Remove0000(errmsg)
  13113. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13114. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13115. //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)
  13116. //fmt.Println(result2)
  13117. //fmt.Println(requestLog2)
  13118. //fmt.Println(errMsgLog2)
  13119. 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)
  13120. saveLog(result, requestLog, "1101", "获取人员信息")
  13121. fmt.Println(errMsgLog)
  13122. if len(errMsgLog) > 0 {
  13123. } else {
  13124. var dat map[string]interface{}
  13125. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13126. fmt.Println(dat)
  13127. } else {
  13128. fmt.Println(err)
  13129. }
  13130. userJSONBytes, _ := json.Marshal(dat)
  13131. var res ResultTwo
  13132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13133. utils.ErrorLog("解析失败:%v", err)
  13134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13135. return
  13136. }
  13137. res.ErrMsg = errMsgLog
  13138. if res.Infcode == 0 {
  13139. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13140. if err == gorm.ErrRecordNotFound {
  13141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13142. return
  13143. } else if err != nil {
  13144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13145. return
  13146. } else {
  13147. fmt.Println(res)
  13148. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13149. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13150. infoStr := string(Iinfos)
  13151. idetinfoStr := string(Idetinfos)
  13152. var rf []*ResultFive
  13153. json.Unmarshal([]byte(infoStr), &rf)
  13154. var insutypes []*ResultFive
  13155. var insutype string
  13156. var is390 int = 0
  13157. var is310 int = 0
  13158. for _, item := range rf {
  13159. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13160. insutypes = append(insutypes, item)
  13161. }
  13162. }
  13163. if len(insutypes) == 1 {
  13164. insutype = insutypes[0].Insutype
  13165. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13166. } else {
  13167. for _, i := range insutypes {
  13168. if i.Insutype == "390" {
  13169. is390 = 1
  13170. }
  13171. if i.Insutype == "310" {
  13172. is310 = 1
  13173. }
  13174. }
  13175. }
  13176. if is390 == 1 {
  13177. insutype = "390"
  13178. }
  13179. if is310 == 1 {
  13180. insutype = "310"
  13181. }
  13182. if len(insutypes) == 0 {
  13183. insutype = "390"
  13184. }
  13185. var insuplc_admdvs string
  13186. for _, item := range rf {
  13187. if item.Insutype == insutype {
  13188. insuplc_admdvs = item.InsuplcAdmdvs
  13189. }
  13190. }
  13191. psn := &models.HisPsn{
  13192. PsnNo: res.Output.Baseinfo.PsnNo,
  13193. PatientId: patient.ID,
  13194. Certno: res.Output.Baseinfo.Certno,
  13195. Gend: res.Output.Baseinfo.Gend,
  13196. Naty: res.Output.Baseinfo.Naty,
  13197. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13198. PsnName: res.Output.Baseinfo.PsnName,
  13199. Idetinfo: idetinfoStr,
  13200. Insuinfo: infoStr,
  13201. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13202. CardInfo: basStr,
  13203. VerifyNumber: "",
  13204. InsuplcAdmdvs: insuplc_admdvs,
  13205. }
  13206. service.CreateHisPsn(psn)
  13207. c.ServeSuccessJSON(map[string]interface{}{
  13208. "patient": patient,
  13209. "number": cardnum,
  13210. "insutype": insutype,
  13211. })
  13212. }
  13213. } else {
  13214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13215. return
  13216. }
  13217. }
  13218. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13219. fmt.Println(initFlag)
  13220. fmt.Println("initFlag")
  13221. if initFlag == 0 {
  13222. c.TestGetJiangXiBasBaseInit()
  13223. }
  13224. basStr := c.GetBasBaseInfo()
  13225. if len(basStr) == 0 {
  13226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13227. return
  13228. }
  13229. fmt.Println(basStr)
  13230. bas := strings.Split(basStr, "|")
  13231. basNumber := bas[1]
  13232. fmt.Println(basNumber)
  13233. card_sn := bas[3]
  13234. fmt.Println(card_sn)
  13235. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13236. 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)
  13237. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13238. var dat map[string]interface{}
  13239. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13240. fmt.Println(dat)
  13241. } else {
  13242. fmt.Println(err)
  13243. }
  13244. userJSONBytes, _ := json.Marshal(dat)
  13245. var res ResultTwo
  13246. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13247. utils.ErrorLog("解析失败:%v", err)
  13248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13249. return
  13250. }
  13251. if res.Infcode == 0 {
  13252. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13253. if err == gorm.ErrRecordNotFound {
  13254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13255. return
  13256. } else if err != nil {
  13257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13258. return
  13259. } else {
  13260. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13261. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13262. infoStr := string(Iinfos)
  13263. idetinfoStr := string(Idetinfos)
  13264. var rf []*ResultFive
  13265. json.Unmarshal([]byte(infoStr), &rf)
  13266. var insutypes []*ResultFive
  13267. var insutype string
  13268. var is390 int = 0
  13269. var is310 int = 0
  13270. var insuplc_admdvs string
  13271. for _, item := range rf {
  13272. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13273. insutypes = append(insutypes, item)
  13274. }
  13275. }
  13276. if len(insutypes) == 1 {
  13277. insutype = insutypes[0].Insutype
  13278. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13279. } else {
  13280. for _, i := range insutypes {
  13281. if i.Insutype == "390" {
  13282. is390 = 1
  13283. }
  13284. if i.Insutype == "310" {
  13285. is310 = 1
  13286. }
  13287. }
  13288. }
  13289. if is390 == 1 {
  13290. insutype = "390"
  13291. }
  13292. if is310 == 1 {
  13293. insutype = "310"
  13294. }
  13295. if len(insutypes) == 0 {
  13296. insutype = "310"
  13297. }
  13298. for _, item := range rf {
  13299. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13300. insuplc_admdvs = item.InsuplcAdmdvs
  13301. }
  13302. }
  13303. psn := &models.HisPsn{
  13304. PsnNo: res.Output.Baseinfo.PsnNo,
  13305. PatientId: patient.ID,
  13306. Certno: res.Output.Baseinfo.Certno,
  13307. Gend: res.Output.Baseinfo.Gend,
  13308. Naty: res.Output.Baseinfo.Naty,
  13309. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13310. PsnName: res.Output.Baseinfo.PsnName,
  13311. Idetinfo: idetinfoStr,
  13312. Insuinfo: infoStr,
  13313. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13314. CardInfo: basStr,
  13315. InsuplcAdmdvs: insuplc_admdvs,
  13316. VerifyNumber: "",
  13317. }
  13318. service.CreateHisPsn(psn)
  13319. c.ServeSuccessJSON(map[string]interface{}{
  13320. "patient": patient,
  13321. "number": basNumber,
  13322. "insutype": insutype,
  13323. })
  13324. }
  13325. } else {
  13326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13327. return
  13328. }
  13329. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13330. basStr := c.GetBasBaseInfo1111()
  13331. fmt.Println(basStr)
  13332. if len(basStr) == 0 {
  13333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13334. return
  13335. }
  13336. fmt.Println(basStr)
  13337. bas := strings.Split(basStr, "|")
  13338. basNumber := bas[1]
  13339. fmt.Println(basNumber)
  13340. card_sn := ""
  13341. fmt.Println(card_sn)
  13342. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13343. 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)
  13344. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13345. var dat map[string]interface{}
  13346. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13347. fmt.Println(dat)
  13348. } else {
  13349. fmt.Println(err)
  13350. }
  13351. userJSONBytes, _ := json.Marshal(dat)
  13352. var res ResultTwo
  13353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13354. utils.ErrorLog("解析失败:%v", err)
  13355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13356. return
  13357. }
  13358. if res.Infcode == 0 {
  13359. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13360. if err == gorm.ErrRecordNotFound {
  13361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13362. return
  13363. } else if err != nil {
  13364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13365. return
  13366. } else {
  13367. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13368. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13369. infoStr := string(Iinfos)
  13370. idetinfoStr := string(Idetinfos)
  13371. var rf []*ResultFive
  13372. json.Unmarshal([]byte(infoStr), &rf)
  13373. var insutypes []*ResultFive
  13374. var insutype string
  13375. var is390 int = 0
  13376. var is310 int = 0
  13377. var insuplc_admdvs string
  13378. for _, item := range rf {
  13379. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13380. insutypes = append(insutypes, item)
  13381. }
  13382. }
  13383. if len(insutypes) == 1 {
  13384. insutype = insutypes[0].Insutype
  13385. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13386. } else {
  13387. for _, i := range insutypes {
  13388. if i.Insutype == "390" {
  13389. is390 = 1
  13390. }
  13391. if i.Insutype == "310" {
  13392. is310 = 1
  13393. }
  13394. }
  13395. }
  13396. if is390 == 1 {
  13397. insutype = "390"
  13398. }
  13399. if is310 == 1 {
  13400. insutype = "310"
  13401. }
  13402. if len(insutypes) == 0 {
  13403. insutype = "310"
  13404. }
  13405. for _, item := range rf {
  13406. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13407. insuplc_admdvs = item.InsuplcAdmdvs
  13408. }
  13409. }
  13410. psn := &models.HisPsn{
  13411. PsnNo: res.Output.Baseinfo.PsnNo,
  13412. PatientId: patient.ID,
  13413. Certno: res.Output.Baseinfo.Certno,
  13414. Gend: res.Output.Baseinfo.Gend,
  13415. Naty: res.Output.Baseinfo.Naty,
  13416. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13417. PsnName: res.Output.Baseinfo.PsnName,
  13418. Idetinfo: idetinfoStr,
  13419. Insuinfo: infoStr,
  13420. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13421. CardInfo: basStr,
  13422. InsuplcAdmdvs: insuplc_admdvs,
  13423. VerifyNumber: "",
  13424. }
  13425. service.CreateHisPsn(psn)
  13426. c.ServeSuccessJSON(map[string]interface{}{
  13427. "patient": patient,
  13428. "number": basNumber,
  13429. "insutype": insutype,
  13430. })
  13431. }
  13432. } else {
  13433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13434. return
  13435. }
  13436. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13437. fmt.Println(initFlag)
  13438. fmt.Println("initFlag")
  13439. if initFlag == 0 {
  13440. c.TestGetHnBasBaseInit()
  13441. }
  13442. basStr := c.GetBasBaseInfo()
  13443. if len(basStr) == 0 {
  13444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13445. return
  13446. }
  13447. fmt.Println(basStr)
  13448. bas := strings.Split(basStr, "|")
  13449. basNumber := bas[1]
  13450. fmt.Println(basNumber)
  13451. card_sn := bas[3]
  13452. card_no := bas[2]
  13453. fmt.Println(card_sn)
  13454. name := bas[4]
  13455. name = ConvertToString(name, "gbk", "utf-8")
  13456. 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)
  13457. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13458. var dat map[string]interface{}
  13459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13460. fmt.Println(dat)
  13461. } else {
  13462. fmt.Println(err)
  13463. }
  13464. userJSONBytes, _ := json.Marshal(dat)
  13465. var res ResultTwo
  13466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13467. utils.ErrorLog("解析失败:%v", err)
  13468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13469. return
  13470. }
  13471. if res.Infcode == 0 {
  13472. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13473. if err == gorm.ErrRecordNotFound {
  13474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13475. return
  13476. } else if err != nil {
  13477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13478. return
  13479. } else {
  13480. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13481. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13482. infoStr := string(Iinfos)
  13483. idetinfoStr := string(Idetinfos)
  13484. psn := &models.HisPsn{
  13485. PsnNo: res.Output.Baseinfo.PsnNo,
  13486. PatientId: patient.ID,
  13487. Certno: res.Output.Baseinfo.Certno,
  13488. Gend: res.Output.Baseinfo.Gend,
  13489. Naty: res.Output.Baseinfo.Naty,
  13490. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13491. PsnName: res.Output.Baseinfo.PsnName,
  13492. Idetinfo: idetinfoStr,
  13493. Insuinfo: infoStr,
  13494. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13495. CardInfo: basStr,
  13496. VerifyNumber: "",
  13497. }
  13498. service.CreateHisPsn(psn)
  13499. var rf []*ResultFive
  13500. json.Unmarshal([]byte(infoStr), &rf)
  13501. var insutypes []*ResultFive
  13502. var insutype string
  13503. var is390 int = 0
  13504. var is310 int = 0
  13505. for _, item := range rf {
  13506. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13507. insutypes = append(insutypes, item)
  13508. }
  13509. }
  13510. if len(insutypes) == 1 {
  13511. insutype = insutypes[0].Insutype
  13512. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13513. } else {
  13514. for _, i := range insutypes {
  13515. if i.Insutype == "390" {
  13516. is390 = 1
  13517. }
  13518. if i.Insutype == "310" {
  13519. is310 = 1
  13520. }
  13521. }
  13522. }
  13523. if is390 == 1 {
  13524. insutype = "390"
  13525. }
  13526. if is310 == 1 {
  13527. insutype = "310"
  13528. }
  13529. if len(insutypes) == 0 {
  13530. insutype = "310"
  13531. }
  13532. c.ServeSuccessJSON(map[string]interface{}{
  13533. "patient": patient,
  13534. "number": basNumber,
  13535. "insutype": insutype,
  13536. })
  13537. }
  13538. } else {
  13539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13540. return
  13541. }
  13542. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13543. var api string
  13544. 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 +
  13545. "&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
  13546. fmt.Println(api)
  13547. resp, requestErr := http.Get(api)
  13548. if requestErr != nil {
  13549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13550. return
  13551. }
  13552. body, ioErr := ioutil.ReadAll(resp.Body)
  13553. if ioErr != nil {
  13554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13556. return
  13557. }
  13558. var respJSON map[string]interface{}
  13559. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13562. return
  13563. }
  13564. var res ResultTwo //1101结果
  13565. var res10265 ResultTwo10265 //1101结果
  13566. var card_info string //卡信息
  13567. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13568. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13569. result, _ := json.Marshal(respJSON)
  13570. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13571. utils.ErrorLog("解析失败:%v", err)
  13572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13573. return
  13574. }
  13575. res.ErrMsg = res10265.ErrMsg
  13576. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13577. res.Infcode = infocode
  13578. res.Output = res10265.Output
  13579. res.InfRefmsgid = res10265.InfRefmsgid
  13580. if res.Infcode == 0 {
  13581. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13582. if err == gorm.ErrRecordNotFound {
  13583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13584. return
  13585. } else if err != nil {
  13586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13587. return
  13588. } else {
  13589. bas := strings.Split(card_info, "|")
  13590. basNumber := bas[2]
  13591. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13592. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13593. infoStr := string(Iinfos)
  13594. idetinfoStr := string(Idetinfos)
  13595. psn := &models.HisPsn{
  13596. PsnNo: res.Output.Baseinfo.PsnNo,
  13597. PatientId: patient.ID,
  13598. Certno: res.Output.Baseinfo.Certno,
  13599. Gend: res.Output.Baseinfo.Gend,
  13600. Naty: res.Output.Baseinfo.Naty,
  13601. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13602. PsnName: res.Output.Baseinfo.PsnName,
  13603. Idetinfo: idetinfoStr,
  13604. Insuinfo: infoStr,
  13605. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13606. CardInfo: card_info,
  13607. VerifyNumber: token,
  13608. }
  13609. service.CreateHisPsn(psn)
  13610. var rf []*ResultFive
  13611. json.Unmarshal([]byte(infoStr), &rf)
  13612. var insutypes []*ResultFive
  13613. var insutype string
  13614. var is390 int = 0
  13615. var is310 int = 0
  13616. for _, item := range rf {
  13617. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13618. insutypes = append(insutypes, item)
  13619. }
  13620. }
  13621. if len(insutypes) == 1 {
  13622. insutype = insutypes[0].Insutype
  13623. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13624. } else {
  13625. for _, i := range insutypes {
  13626. if i.Insutype == "390" {
  13627. is390 = 1
  13628. }
  13629. if i.Insutype == "310" {
  13630. is310 = 1
  13631. }
  13632. }
  13633. }
  13634. if is390 == 1 {
  13635. insutype = "390"
  13636. }
  13637. if is310 == 1 {
  13638. insutype = "310"
  13639. }
  13640. if len(insutypes) == 0 {
  13641. insutype = "310"
  13642. }
  13643. c.ServeSuccessJSON(map[string]interface{}{
  13644. "patient": patient,
  13645. "number": basNumber,
  13646. "insutype": insutype,
  13647. })
  13648. }
  13649. } else {
  13650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13651. return
  13652. }
  13653. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13654. res := c.GetoleInfo()
  13655. if res.Infcode == 0 {
  13656. var result string
  13657. if res.Output.MdtrtCertType == "01" {
  13658. 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)
  13659. } else if res.Output.MdtrtCertType == "02" {
  13660. 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)
  13661. } else if res.Output.MdtrtCertType == "03" {
  13662. 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)
  13663. }
  13664. var dat map[string]interface{}
  13665. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13666. fmt.Println(dat)
  13667. } else {
  13668. fmt.Println(err)
  13669. }
  13670. userJSONBytes, _ := json.Marshal(dat)
  13671. var res2 ResultTwo
  13672. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13673. utils.ErrorLog("解析失败:%v", err)
  13674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13675. return
  13676. }
  13677. if res2.Infcode == 0 {
  13678. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13679. if err == gorm.ErrRecordNotFound {
  13680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13681. return
  13682. } else if err != nil {
  13683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13684. return
  13685. } else {
  13686. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13687. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13688. infoStr := string(Iinfos)
  13689. idetinfoStr := string(Idetinfos)
  13690. var rf []*ResultFive
  13691. json.Unmarshal([]byte(infoStr), &rf)
  13692. var insutypes []*ResultFive
  13693. var insutype string
  13694. var is390 int = 0
  13695. var is310 int = 0
  13696. //var insuplc_admdvs string
  13697. for _, item := range rf {
  13698. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13699. insutypes = append(insutypes, item)
  13700. }
  13701. }
  13702. if len(insutypes) == 1 {
  13703. insutype = insutypes[0].Insutype
  13704. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13705. } else {
  13706. for _, i := range insutypes {
  13707. if i.Insutype == "390" {
  13708. is390 = 1
  13709. }
  13710. if i.Insutype == "310" {
  13711. is310 = 1
  13712. }
  13713. }
  13714. }
  13715. if is390 == 1 {
  13716. insutype = "390"
  13717. }
  13718. if is310 == 1 {
  13719. insutype = "310"
  13720. }
  13721. if len(insutypes) == 0 {
  13722. insutype = "310"
  13723. }
  13724. psn := &models.HisPsn{
  13725. PsnNo: res2.Output.Baseinfo.PsnNo,
  13726. PatientId: patient.ID,
  13727. Certno: res2.Output.Baseinfo.Certno,
  13728. Gend: res2.Output.Baseinfo.Gend,
  13729. Naty: res2.Output.Baseinfo.Naty,
  13730. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13731. PsnName: res2.Output.Baseinfo.PsnName,
  13732. Idetinfo: idetinfoStr,
  13733. Insuinfo: infoStr,
  13734. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13735. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13736. VerifyNumber: res.Output.EcToken,
  13737. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13738. }
  13739. if res.Output.MdtrtCertType == "01" {
  13740. psn.VerifyNumber = res.Output.EcToken
  13741. //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)
  13742. } else if res.Output.MdtrtCertType == "02" {
  13743. psn.VerifyNumber = res.Output.MdtrtCertNo
  13744. //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)
  13745. } else if res.Output.MdtrtCertType == "03" {
  13746. psn.VerifyNumber = res.Output.MdtrtCertNo
  13747. //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)
  13748. }
  13749. var balc float64
  13750. for _, item := range rf {
  13751. if item.Insutype == insutype {
  13752. balc = item.Balc
  13753. }
  13754. }
  13755. service.CreateHisPsn(psn)
  13756. c.ServeSuccessJSON(map[string]interface{}{
  13757. "patient": patient,
  13758. "number": res.Output.CardNo,
  13759. "insutype": insutype,
  13760. "blac": balc,
  13761. "desc": idetinfoStr,
  13762. })
  13763. }
  13764. } else {
  13765. c.ServeSuccessJSON(map[string]interface{}{
  13766. "failed_code": -10,
  13767. "msg": res2.ErrMsg,
  13768. })
  13769. }
  13770. } else {
  13771. c.ServeSuccessJSON(map[string]interface{}{
  13772. "failed_code": -10,
  13773. "msg": res.ErrMsg,
  13774. })
  13775. }
  13776. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13777. var api string
  13778. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13779. "&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
  13780. fmt.Println(api)
  13781. resp, requestErr := http.Get(api)
  13782. if requestErr != nil {
  13783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13784. return
  13785. }
  13786. body, ioErr := ioutil.ReadAll(resp.Body)
  13787. if ioErr != nil {
  13788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13790. return
  13791. }
  13792. var respJSON map[string]interface{}
  13793. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13796. return
  13797. }
  13798. var status string
  13799. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13800. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13801. //console.log()
  13802. fmt.Println("type===")
  13803. fmt.Println(card_type)
  13804. var token string
  13805. var res ResultTwo //1101结果
  13806. //var res10265 ResultTwoesultTwo10265 //1101结果
  13807. var card_info string //卡信息
  13808. var busi_card_info string
  13809. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13810. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13811. if status == "0" { //读卡成功
  13812. if card_type == "1" {
  13813. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13814. result, _ := json.Marshal(respJSON)
  13815. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13816. utils.ErrorLog("解析失败:%v", err)
  13817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13818. return
  13819. }
  13820. } else {
  13821. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13822. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13823. result, _ := json.Marshal(respJSON)
  13824. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13825. utils.ErrorLog("解析失败:%v", err)
  13826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13827. return
  13828. }
  13829. }
  13830. if res.Infcode == 0 {
  13831. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13832. if err == gorm.ErrRecordNotFound {
  13833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13834. return
  13835. } else if err != nil {
  13836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13837. return
  13838. } else {
  13839. if card_type == "1" {
  13840. bas := strings.Split(card_info, "|")
  13841. basNumber := bas[2]
  13842. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13843. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13844. infoStr := string(Iinfos)
  13845. idetinfoStr := string(Idetinfos)
  13846. psn := &models.HisPsn{
  13847. PsnNo: res.Output.Baseinfo.PsnNo,
  13848. PatientId: patient.ID,
  13849. Certno: res.Output.Baseinfo.Certno,
  13850. Gend: res.Output.Baseinfo.Gend,
  13851. Naty: res.Output.Baseinfo.Naty,
  13852. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13853. PsnName: res.Output.Baseinfo.PsnName,
  13854. Idetinfo: idetinfoStr,
  13855. Insuinfo: infoStr,
  13856. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13857. CardInfo: card_info,
  13858. VerifyNumber: busi_card_info,
  13859. }
  13860. service.CreateHisPsn(psn)
  13861. var rf []*ResultFive
  13862. json.Unmarshal([]byte(infoStr), &rf)
  13863. var insutypes []*ResultFive
  13864. var insutype string
  13865. var is390 int = 0
  13866. var is310 int = 0
  13867. for _, item := range rf {
  13868. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13869. insutypes = append(insutypes, item)
  13870. }
  13871. }
  13872. if len(insutypes) == 1 {
  13873. insutype = insutypes[0].Insutype
  13874. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13875. } else {
  13876. for _, i := range insutypes {
  13877. if i.Insutype == "390" {
  13878. is390 = 1
  13879. }
  13880. if i.Insutype == "310" {
  13881. is310 = 1
  13882. }
  13883. }
  13884. }
  13885. if is390 == 1 {
  13886. insutype = "390"
  13887. }
  13888. if is310 == 1 {
  13889. insutype = "310"
  13890. }
  13891. if len(insutypes) == 0 {
  13892. insutype = "310"
  13893. }
  13894. c.ServeSuccessJSON(map[string]interface{}{
  13895. "patient": patient,
  13896. "number": basNumber,
  13897. "insutype": insutype,
  13898. })
  13899. } else {
  13900. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13901. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13902. infoStr := string(Iinfos)
  13903. idetinfoStr := string(Idetinfos)
  13904. psn := &models.HisPsn{
  13905. PsnNo: res.Output.Baseinfo.PsnNo,
  13906. PatientId: patient.ID,
  13907. Certno: res.Output.Baseinfo.Certno,
  13908. Gend: res.Output.Baseinfo.Gend,
  13909. Naty: res.Output.Baseinfo.Naty,
  13910. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13911. PsnName: res.Output.Baseinfo.PsnName,
  13912. Idetinfo: idetinfoStr,
  13913. Insuinfo: infoStr,
  13914. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13915. CardInfo: card_info,
  13916. VerifyNumber: token,
  13917. }
  13918. service.CreateHisPsn(psn)
  13919. c.ServeSuccessJSON(map[string]interface{}{
  13920. "patient": patient,
  13921. "number": token,
  13922. })
  13923. }
  13924. }
  13925. } else {
  13926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13927. return
  13928. }
  13929. } else { //读卡失败
  13930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13931. return
  13932. }
  13933. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13934. var api string
  13935. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13936. "&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
  13937. fmt.Println(api)
  13938. resp, requestErr := http.Get(api)
  13939. if requestErr != nil {
  13940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13941. return
  13942. }
  13943. body, ioErr := ioutil.ReadAll(resp.Body)
  13944. if ioErr != nil {
  13945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13947. return
  13948. }
  13949. var respJSON map[string]interface{}
  13950. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13953. return
  13954. }
  13955. var status string
  13956. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13957. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13958. //console.log()
  13959. fmt.Println("type===")
  13960. fmt.Println(card_type)
  13961. var token string
  13962. var res ResultTwo //1101结果
  13963. //var res10265 ResultTwoesultTwo10265 //1101结果
  13964. var card_info string //卡信息
  13965. //var busi_card_info string
  13966. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13967. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13968. if status == "0" { //读卡成功
  13969. if card_type == "1" {
  13970. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13971. result, _ := json.Marshal(respJSON)
  13972. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13973. utils.ErrorLog("解析失败:%v", err)
  13974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13975. return
  13976. }
  13977. } else {
  13978. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13979. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13980. result, _ := json.Marshal(respJSON)
  13981. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13982. utils.ErrorLog("解析失败:%v", err)
  13983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13984. return
  13985. }
  13986. }
  13987. if res.Infcode == 0 {
  13988. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13989. if err == gorm.ErrRecordNotFound {
  13990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13991. return
  13992. } else if err != nil {
  13993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13994. return
  13995. } else {
  13996. if card_type == "1" {
  13997. bas := strings.Split(card_info, "|")
  13998. basNumber := bas[2]
  13999. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14000. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14001. infoStr := string(Iinfos)
  14002. idetinfoStr := string(Idetinfos)
  14003. psn := &models.HisPsn{
  14004. PsnNo: res.Output.Baseinfo.PsnNo,
  14005. PatientId: patient.ID,
  14006. Certno: res.Output.Baseinfo.Certno,
  14007. Gend: res.Output.Baseinfo.Gend,
  14008. Naty: res.Output.Baseinfo.Naty,
  14009. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14010. PsnName: res.Output.Baseinfo.PsnName,
  14011. Idetinfo: idetinfoStr,
  14012. Insuinfo: infoStr,
  14013. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14014. CardInfo: card_info,
  14015. //VerifyNumber: busi_card_info,
  14016. }
  14017. service.CreateHisPsn(psn)
  14018. var rf []*ResultFive
  14019. json.Unmarshal([]byte(infoStr), &rf)
  14020. var insutypes []*ResultFive
  14021. var insutype string
  14022. var is390 int = 0
  14023. var is310 int = 0
  14024. for _, item := range rf {
  14025. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14026. insutypes = append(insutypes, item)
  14027. }
  14028. }
  14029. if len(insutypes) == 1 {
  14030. insutype = insutypes[0].Insutype
  14031. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14032. } else {
  14033. for _, i := range insutypes {
  14034. if i.Insutype == "390" {
  14035. is390 = 1
  14036. }
  14037. if i.Insutype == "310" {
  14038. is310 = 1
  14039. }
  14040. }
  14041. }
  14042. if is390 == 1 {
  14043. insutype = "390"
  14044. }
  14045. if is310 == 1 {
  14046. insutype = "310"
  14047. }
  14048. if len(insutypes) == 0 {
  14049. insutype = "310"
  14050. }
  14051. c.ServeSuccessJSON(map[string]interface{}{
  14052. "patient": patient,
  14053. "number": basNumber,
  14054. "insutype": insutype,
  14055. })
  14056. } else {
  14057. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14058. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14059. infoStr := string(Iinfos)
  14060. idetinfoStr := string(Idetinfos)
  14061. psn := &models.HisPsn{
  14062. PsnNo: res.Output.Baseinfo.PsnNo,
  14063. PatientId: patient.ID,
  14064. Certno: res.Output.Baseinfo.Certno,
  14065. Gend: res.Output.Baseinfo.Gend,
  14066. Naty: res.Output.Baseinfo.Naty,
  14067. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14068. PsnName: res.Output.Baseinfo.PsnName,
  14069. Idetinfo: idetinfoStr,
  14070. Insuinfo: infoStr,
  14071. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14072. CardInfo: card_info,
  14073. VerifyNumber: token,
  14074. }
  14075. service.CreateHisPsn(psn)
  14076. c.ServeSuccessJSON(map[string]interface{}{
  14077. "patient": patient,
  14078. "number": token,
  14079. })
  14080. }
  14081. }
  14082. } else {
  14083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14084. return
  14085. }
  14086. } else { //读卡失败
  14087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14088. return
  14089. }
  14090. } else {
  14091. if initFlag == 0 {
  14092. c.TestGetBasBaseInit()
  14093. }
  14094. basStr := c.GetBasBaseInfo()
  14095. if len(basStr) == 0 {
  14096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14097. return
  14098. }
  14099. fmt.Println(basStr)
  14100. bas := strings.Split(basStr, "|")
  14101. basNumber := bas[1]
  14102. fmt.Println(basNumber)
  14103. card_sn := bas[3]
  14104. fmt.Println(card_sn)
  14105. cardNumber := bas[2]
  14106. fmt.Println(cardNumber)
  14107. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14108. var result string
  14109. if bas[0][:2] == "44" {
  14110. 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)
  14111. } else {
  14112. 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)
  14113. }
  14114. var dat map[string]interface{}
  14115. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14116. fmt.Println(dat)
  14117. } else {
  14118. fmt.Println(err)
  14119. }
  14120. userJSONBytes, _ := json.Marshal(dat)
  14121. var res ResultTwo
  14122. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14123. utils.ErrorLog("解析失败:%v", err)
  14124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14125. return
  14126. }
  14127. if res.Infcode == 0 {
  14128. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14129. if err == gorm.ErrRecordNotFound {
  14130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14131. return
  14132. } else if err != nil {
  14133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14134. return
  14135. } else {
  14136. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14137. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14138. infoStr := string(Iinfos)
  14139. idetinfoStr := string(Idetinfos)
  14140. var rf []*ResultFive
  14141. json.Unmarshal([]byte(infoStr), &rf)
  14142. var insutypes []*ResultFive
  14143. var insutype string
  14144. var is390 int = 0
  14145. var is310 int = 0
  14146. var insuplc_admdvs string
  14147. for _, item := range rf {
  14148. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14149. insutypes = append(insutypes, item)
  14150. }
  14151. }
  14152. if len(insutypes) == 1 {
  14153. insutype = insutypes[0].Insutype
  14154. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14155. } else {
  14156. for _, i := range insutypes {
  14157. if i.Insutype == "390" {
  14158. is390 = 1
  14159. }
  14160. if i.Insutype == "310" {
  14161. is310 = 1
  14162. }
  14163. }
  14164. }
  14165. if is390 == 1 {
  14166. insutype = "390"
  14167. }
  14168. if is310 == 1 {
  14169. insutype = "310"
  14170. }
  14171. if len(insutypes) == 0 {
  14172. insutype = "310"
  14173. }
  14174. for _, item := range rf {
  14175. if item.Insutype == insutype {
  14176. insuplc_admdvs = item.InsuplcAdmdvs
  14177. }
  14178. }
  14179. psn := &models.HisPsn{
  14180. PsnNo: res.Output.Baseinfo.PsnNo,
  14181. PatientId: patient.ID,
  14182. Certno: res.Output.Baseinfo.Certno,
  14183. Gend: res.Output.Baseinfo.Gend,
  14184. Naty: res.Output.Baseinfo.Naty,
  14185. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14186. PsnName: res.Output.Baseinfo.PsnName,
  14187. Idetinfo: idetinfoStr,
  14188. Insuinfo: infoStr,
  14189. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14190. CardInfo: basStr,
  14191. VerifyNumber: "",
  14192. InsuplcAdmdvs: insuplc_admdvs,
  14193. }
  14194. service.CreateHisPsn(psn)
  14195. c.ServeSuccessJSON(map[string]interface{}{
  14196. "patient": patient,
  14197. "number": basNumber,
  14198. })
  14199. }
  14200. } else {
  14201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14202. return
  14203. }
  14204. break
  14205. }
  14206. case 2:
  14207. if miConfig.MdtrtareaAdmvs == "430800" {
  14208. if initFlag == 0 {
  14209. c.TestGetHnBasBaseInit()
  14210. }
  14211. SFZStr := c.GetSFZBaseInfo()
  14212. if len(SFZStr) == 0 {
  14213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14214. return
  14215. }
  14216. fmt.Println(SFZStr)
  14217. id_card_str := strings.Split(SFZStr, "^")
  14218. card_no := id_card_str[0]
  14219. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14220. //name := id_card_str[1]
  14221. //name = ConvertToString(name, "gbk", "utf-8")
  14222. 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)
  14223. var dat map[string]interface{}
  14224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14225. fmt.Println(dat)
  14226. } else {
  14227. fmt.Println(err)
  14228. }
  14229. userJSONBytes, _ := json.Marshal(dat)
  14230. var res ResultTwo
  14231. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14232. utils.ErrorLog("解析失败:%v", err)
  14233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14234. return
  14235. }
  14236. if res.Infcode == 0 {
  14237. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14238. if err == gorm.ErrRecordNotFound {
  14239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14240. return
  14241. } else if err != nil {
  14242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14243. return
  14244. } else {
  14245. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14246. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14247. infoStr := string(Iinfos)
  14248. idetinfoStr := string(Idetinfos)
  14249. var rf []*ResultFive
  14250. json.Unmarshal([]byte(infoStr), &rf)
  14251. var insutypes []*ResultFive
  14252. var insutype string
  14253. var is390 int = 0
  14254. var is310 int = 0
  14255. for _, item := range rf {
  14256. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14257. insutypes = append(insutypes, item)
  14258. }
  14259. }
  14260. if len(insutypes) == 1 {
  14261. insutype = insutypes[0].Insutype
  14262. } else {
  14263. for _, i := range insutypes {
  14264. if i.Insutype == "390" {
  14265. is390 = 1
  14266. }
  14267. if i.Insutype == "310" {
  14268. is310 = 1
  14269. }
  14270. }
  14271. }
  14272. if is390 == 1 {
  14273. insutype = "390"
  14274. }
  14275. if is310 == 1 {
  14276. insutype = "310"
  14277. }
  14278. if len(insutypes) == 0 {
  14279. insutype = "310"
  14280. }
  14281. var InsuplcAdmdvs string
  14282. for _, item := range rf {
  14283. if item.Insutype == insutype {
  14284. InsuplcAdmdvs = item.InsuplcAdmdvs
  14285. }
  14286. }
  14287. psn := &models.HisPsn{
  14288. PsnNo: res.Output.Baseinfo.PsnNo,
  14289. PatientId: patient.ID,
  14290. Certno: res.Output.Baseinfo.Certno,
  14291. Gend: res.Output.Baseinfo.Gend,
  14292. Naty: res.Output.Baseinfo.Naty,
  14293. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14294. PsnName: res.Output.Baseinfo.PsnName,
  14295. Idetinfo: idetinfoStr,
  14296. Insuinfo: infoStr,
  14297. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14298. CardInfo: SFZStr,
  14299. VerifyNumber: "",
  14300. InsuplcAdmdvs: InsuplcAdmdvs,
  14301. }
  14302. service.CreateHisPsn(psn)
  14303. c.ServeSuccessJSON(map[string]interface{}{
  14304. "patient": patient,
  14305. "number": card_no,
  14306. "insutype": insutype,
  14307. })
  14308. }
  14309. } else {
  14310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14311. return
  14312. }
  14313. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14314. var res ResultTwo
  14315. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14316. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14317. "&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)
  14318. resp, requestErr := http.Get(api)
  14319. if requestErr != nil {
  14320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14321. return
  14322. }
  14323. body, ioErr := ioutil.ReadAll(resp.Body)
  14324. if ioErr != nil {
  14325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14327. return
  14328. }
  14329. var respJSON map[string]interface{}
  14330. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14333. return
  14334. }
  14335. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14336. result, _ := json.Marshal(respJSON)
  14337. fmt.Println("log")
  14338. fmt.Println(string(result))
  14339. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14340. utils.ErrorLog("解析失败:%v", err)
  14341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14342. return
  14343. }
  14344. if res.Infcode == 0 {
  14345. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14346. if err == gorm.ErrRecordNotFound {
  14347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14348. return
  14349. } else if err != nil {
  14350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14351. return
  14352. } else {
  14353. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14354. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14355. infoStr := string(Iinfos)
  14356. idetinfoStr := string(Idetinfos)
  14357. psn := &models.HisPsn{
  14358. PsnNo: res.Output.Baseinfo.PsnNo,
  14359. PatientId: patient.ID,
  14360. Certno: res.Output.Baseinfo.Certno,
  14361. Gend: res.Output.Baseinfo.Gend,
  14362. Naty: res.Output.Baseinfo.Naty,
  14363. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14364. PsnName: res.Output.Baseinfo.PsnName,
  14365. Idetinfo: idetinfoStr,
  14366. Insuinfo: infoStr,
  14367. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14368. }
  14369. service.CreateHisPsn(psn)
  14370. c.ServeSuccessJSON(map[string]interface{}{
  14371. "patient": patient,
  14372. "number": res.Output.Baseinfo.Certno,
  14373. })
  14374. }
  14375. } else {
  14376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14377. return
  14378. }
  14379. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14380. var res ResultTwo
  14381. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14382. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14383. "&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)
  14384. resp, requestErr := http.Get(api)
  14385. if requestErr != nil {
  14386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14387. return
  14388. }
  14389. body, ioErr := ioutil.ReadAll(resp.Body)
  14390. if ioErr != nil {
  14391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14393. return
  14394. }
  14395. var respJSON map[string]interface{}
  14396. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14399. return
  14400. }
  14401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14402. result, _ := json.Marshal(respJSON)
  14403. fmt.Println("log")
  14404. fmt.Println(string(result))
  14405. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14406. utils.ErrorLog("解析失败:%v", err)
  14407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14408. return
  14409. }
  14410. if res.Infcode == 0 {
  14411. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14412. if err == gorm.ErrRecordNotFound {
  14413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14414. return
  14415. } else if err != nil {
  14416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14417. return
  14418. } else {
  14419. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14420. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14421. infoStr := string(Iinfos)
  14422. idetinfoStr := string(Idetinfos)
  14423. psn := &models.HisPsn{
  14424. PsnNo: res.Output.Baseinfo.PsnNo,
  14425. PatientId: patient.ID,
  14426. Certno: res.Output.Baseinfo.Certno,
  14427. Gend: res.Output.Baseinfo.Gend,
  14428. Naty: res.Output.Baseinfo.Naty,
  14429. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14430. PsnName: res.Output.Baseinfo.PsnName,
  14431. Idetinfo: idetinfoStr,
  14432. Insuinfo: infoStr,
  14433. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14434. }
  14435. service.CreateHisPsn(psn)
  14436. c.ServeSuccessJSON(map[string]interface{}{
  14437. "patient": patient,
  14438. "number": res.Output.Baseinfo.Certno,
  14439. })
  14440. }
  14441. } else {
  14442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14443. return
  14444. }
  14445. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14446. var res ResultTwo
  14447. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14448. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14449. "&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)
  14450. resp, requestErr := http.Get(api)
  14451. if requestErr != nil {
  14452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14453. return
  14454. }
  14455. body, ioErr := ioutil.ReadAll(resp.Body)
  14456. if ioErr != nil {
  14457. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14459. return
  14460. }
  14461. var respJSON map[string]interface{}
  14462. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14463. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14465. return
  14466. }
  14467. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14468. result, _ := json.Marshal(respJSON)
  14469. fmt.Println("log")
  14470. fmt.Println(string(result))
  14471. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14472. utils.ErrorLog("解析失败:%v", err)
  14473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14474. return
  14475. }
  14476. if res.Infcode == 0 {
  14477. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14478. if err == gorm.ErrRecordNotFound {
  14479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14480. return
  14481. } else if err != nil {
  14482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14483. return
  14484. } else {
  14485. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14486. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14487. infoStr := string(Iinfos)
  14488. idetinfoStr := string(Idetinfos)
  14489. var rf []*ResultFive
  14490. json.Unmarshal([]byte(infoStr), &rf)
  14491. var insutypes []*ResultFive
  14492. var insutype string
  14493. var is390 int = 0
  14494. var is310 int = 0
  14495. for _, item := range rf {
  14496. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14497. insutypes = append(insutypes, item)
  14498. }
  14499. }
  14500. if len(insutypes) == 1 {
  14501. insutype = insutypes[0].Insutype
  14502. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14503. } else {
  14504. for _, i := range insutypes {
  14505. if i.Insutype == "390" {
  14506. is390 = 1
  14507. }
  14508. if i.Insutype == "310" {
  14509. is310 = 1
  14510. }
  14511. }
  14512. }
  14513. if is390 == 1 {
  14514. insutype = "390"
  14515. }
  14516. if is310 == 1 {
  14517. insutype = "310"
  14518. }
  14519. if len(insutypes) == 0 {
  14520. insutype = "390"
  14521. }
  14522. var insuplc_admdvs string
  14523. for _, item := range rf {
  14524. if item.Insutype == insutype {
  14525. insuplc_admdvs = item.InsuplcAdmdvs
  14526. }
  14527. }
  14528. psn := &models.HisPsn{
  14529. PsnNo: res.Output.Baseinfo.PsnNo,
  14530. PatientId: patient.ID,
  14531. Certno: res.Output.Baseinfo.Certno,
  14532. Gend: res.Output.Baseinfo.Gend,
  14533. Naty: res.Output.Baseinfo.Naty,
  14534. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14535. PsnName: res.Output.Baseinfo.PsnName,
  14536. Idetinfo: idetinfoStr,
  14537. Insuinfo: infoStr,
  14538. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14539. InsuplcAdmdvs: insuplc_admdvs,
  14540. }
  14541. service.CreateHisPsn(psn)
  14542. c.ServeSuccessJSON(map[string]interface{}{
  14543. "patient": patient,
  14544. "number": res.Output.Baseinfo.Certno,
  14545. })
  14546. }
  14547. } else {
  14548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14549. return
  14550. }
  14551. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14552. res := c.GetoleInfo()
  14553. if res.Infcode == 0 {
  14554. var result string
  14555. if res.Output.MdtrtCertType == "01" {
  14556. 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)
  14557. } else if res.Output.MdtrtCertType == "02" {
  14558. 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)
  14559. } else if res.Output.MdtrtCertType == "03" {
  14560. 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)
  14561. }
  14562. var dat map[string]interface{}
  14563. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14564. fmt.Println(dat)
  14565. } else {
  14566. fmt.Println(err)
  14567. }
  14568. userJSONBytes, _ := json.Marshal(dat)
  14569. var res2 ResultTwo
  14570. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14571. utils.ErrorLog("解析失败:%v", err)
  14572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14573. return
  14574. }
  14575. if res2.Infcode == 0 {
  14576. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14577. if err == gorm.ErrRecordNotFound {
  14578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14579. return
  14580. } else if err != nil {
  14581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14582. return
  14583. } else {
  14584. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14585. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14586. infoStr := string(Iinfos)
  14587. idetinfoStr := string(Idetinfos)
  14588. var rf []*ResultFive
  14589. json.Unmarshal([]byte(infoStr), &rf)
  14590. var insutypes []*ResultFive
  14591. var insutype string
  14592. var is390 int = 0
  14593. var is310 int = 0
  14594. //var insuplc_admdvs string
  14595. for _, item := range rf {
  14596. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14597. insutypes = append(insutypes, item)
  14598. }
  14599. }
  14600. if len(insutypes) == 1 {
  14601. insutype = insutypes[0].Insutype
  14602. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14603. } else {
  14604. for _, i := range insutypes {
  14605. if i.Insutype == "390" {
  14606. is390 = 1
  14607. }
  14608. if i.Insutype == "310" {
  14609. is310 = 1
  14610. }
  14611. }
  14612. }
  14613. if is390 == 1 {
  14614. insutype = "390"
  14615. }
  14616. if is310 == 1 {
  14617. insutype = "310"
  14618. }
  14619. if len(insutypes) == 0 {
  14620. insutype = "310"
  14621. }
  14622. psn := &models.HisPsn{
  14623. PsnNo: res2.Output.Baseinfo.PsnNo,
  14624. PatientId: patient.ID,
  14625. //Brdy: res2.Output.Baseinfo.Brdy,
  14626. Certno: res2.Output.Baseinfo.Certno,
  14627. Gend: res2.Output.Baseinfo.Gend,
  14628. Naty: res2.Output.Baseinfo.Naty,
  14629. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14630. PsnName: res2.Output.Baseinfo.PsnName,
  14631. Idetinfo: idetinfoStr,
  14632. Insuinfo: infoStr,
  14633. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14634. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14635. VerifyNumber: res.Output.EcToken,
  14636. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14637. }
  14638. service.CreateHisPsn(psn)
  14639. var balc float64
  14640. for _, item := range rf {
  14641. if item.Insutype == insutype {
  14642. balc = item.Balc
  14643. }
  14644. }
  14645. c.ServeSuccessJSON(map[string]interface{}{
  14646. "patient": patient,
  14647. "number": res.Output.CardNo,
  14648. "insutype": insutype,
  14649. "blac": balc,
  14650. "desc": idetinfoStr,
  14651. })
  14652. }
  14653. } else {
  14654. c.ServeSuccessJSON(map[string]interface{}{
  14655. "failed_code": -10,
  14656. "msg": res2.ErrMsg,
  14657. })
  14658. }
  14659. } else {
  14660. c.ServeSuccessJSON(map[string]interface{}{
  14661. "failed_code": -10,
  14662. "msg": res.ErrMsg,
  14663. })
  14664. }
  14665. } else {
  14666. SFZStr := c.GetSFZBaseInfo()
  14667. id_card_str := strings.Split(SFZStr, "^")
  14668. id_card_number := id_card_str[0]
  14669. card_sn := ""
  14670. 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)
  14671. var dat map[string]interface{}
  14672. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14673. fmt.Println(dat)
  14674. } else {
  14675. fmt.Println(err)
  14676. }
  14677. userJSONBytes, _ := json.Marshal(dat)
  14678. var res ResultTwo
  14679. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14680. utils.ErrorLog("解析失败:%v", err)
  14681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14682. return
  14683. }
  14684. if res.Infcode == 0 {
  14685. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  14686. if err == gorm.ErrRecordNotFound {
  14687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14688. return
  14689. } else if err != nil {
  14690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14691. return
  14692. } else {
  14693. c.ServeSuccessJSON(map[string]interface{}{
  14694. "patient": patient,
  14695. "number": id_card_number,
  14696. })
  14697. }
  14698. } else {
  14699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14700. return
  14701. }
  14702. }
  14703. break
  14704. case 3:
  14705. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14706. var api string
  14707. if miConfig.MdtrtareaAdmvs == "320921" {
  14708. 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 +
  14709. "&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
  14710. fmt.Println(api)
  14711. } else {
  14712. 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 +
  14713. "&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)
  14714. }
  14715. resp, requestErr := http.Get(api)
  14716. if requestErr != nil {
  14717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14718. return
  14719. }
  14720. body, ioErr := ioutil.ReadAll(resp.Body)
  14721. if ioErr != nil {
  14722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14724. return
  14725. }
  14726. var respJSON map[string]interface{}
  14727. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14730. return
  14731. }
  14732. var status string
  14733. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14734. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14735. var token string
  14736. var res ResultTwo //1101结果
  14737. var res10265 ResultTwo10265 //1101结果
  14738. var card_info string //卡信息
  14739. var busi_card_info string
  14740. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14741. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14742. if status == "0" { //读卡成功
  14743. if card_type == "1" {
  14744. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14745. result, _ := json.Marshal(respJSON)
  14746. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14747. utils.ErrorLog("解析失败:%v", err)
  14748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14749. return
  14750. }
  14751. res.ErrMsg = res10265.ErrMsg
  14752. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14753. res.Infcode = infocode
  14754. res.Output = res10265.Output
  14755. res.InfRefmsgid = res10265.InfRefmsgid
  14756. } else {
  14757. //var card_info string //卡信息
  14758. //var busi_card_info string
  14759. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14760. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14761. //fmt.Println(card_info)
  14762. //fmt.Println(busi_card_info)
  14763. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14764. result, _ := json.Marshal(respJSON)
  14765. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14766. utils.ErrorLog("解析失败:%v", err)
  14767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14768. return
  14769. }
  14770. res.ErrMsg = res10265.ErrMsg
  14771. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14772. res.Infcode = infocode
  14773. res.Output = res10265.Output
  14774. res.InfRefmsgid = res10265.InfRefmsgid
  14775. }
  14776. if res.Infcode == 0 {
  14777. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14778. if err == gorm.ErrRecordNotFound {
  14779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14780. return
  14781. } else if err != nil {
  14782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14783. return
  14784. } else {
  14785. if card_type == "1" {
  14786. bas := strings.Split(card_info, "|")
  14787. basNumber := bas[2]
  14788. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14789. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14790. infoStr := string(Iinfos)
  14791. idetinfoStr := string(Idetinfos)
  14792. psn := &models.HisPsn{
  14793. PsnNo: res.Output.Baseinfo.PsnNo,
  14794. PatientId: patient.ID,
  14795. Certno: res.Output.Baseinfo.Certno,
  14796. //Brdy: res.Output.Baseinfo.Brdy,
  14797. Gend: res.Output.Baseinfo.Gend,
  14798. Naty: res.Output.Baseinfo.Naty,
  14799. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14800. PsnName: res.Output.Baseinfo.PsnName,
  14801. Idetinfo: idetinfoStr,
  14802. Insuinfo: infoStr,
  14803. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14804. CardInfo: card_info,
  14805. VerifyNumber: busi_card_info,
  14806. }
  14807. service.CreateHisPsn(psn)
  14808. c.ServeSuccessJSON(map[string]interface{}{
  14809. "patient": patient,
  14810. "number": basNumber,
  14811. })
  14812. } else {
  14813. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14814. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14815. infoStr := string(Iinfos)
  14816. idetinfoStr := string(Idetinfos)
  14817. psn := &models.HisPsn{
  14818. PsnNo: res.Output.Baseinfo.PsnNo,
  14819. PatientId: patient.ID,
  14820. Certno: res.Output.Baseinfo.Certno,
  14821. Gend: res.Output.Baseinfo.Gend,
  14822. Naty: res.Output.Baseinfo.Naty,
  14823. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14824. PsnName: res.Output.Baseinfo.PsnName,
  14825. Idetinfo: idetinfoStr,
  14826. Insuinfo: infoStr,
  14827. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14828. CardInfo: card_info,
  14829. VerifyNumber: token,
  14830. }
  14831. service.CreateHisPsn(psn)
  14832. var rf []*ResultFive
  14833. json.Unmarshal([]byte(infoStr), &rf)
  14834. var insutypes []*ResultFive
  14835. var insutype string
  14836. var is390 int = 0
  14837. var is310 int = 0
  14838. for _, item := range rf {
  14839. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14840. insutypes = append(insutypes, item)
  14841. }
  14842. }
  14843. if len(insutypes) == 1 {
  14844. insutype = insutypes[0].Insutype
  14845. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14846. } else {
  14847. for _, i := range insutypes {
  14848. if i.Insutype == "390" {
  14849. is390 = 1
  14850. }
  14851. if i.Insutype == "310" {
  14852. is310 = 1
  14853. }
  14854. }
  14855. }
  14856. if is390 == 1 {
  14857. insutype = "390"
  14858. }
  14859. if is310 == 1 {
  14860. insutype = "310"
  14861. }
  14862. if len(insutypes) == 0 {
  14863. insutype = "310"
  14864. }
  14865. c.ServeSuccessJSON(map[string]interface{}{
  14866. "patient": patient,
  14867. "number": token,
  14868. "insutype": insutype,
  14869. })
  14870. }
  14871. }
  14872. } else {
  14873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14874. return
  14875. }
  14876. } else { //读卡失败
  14877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14878. return
  14879. }
  14880. }
  14881. break
  14882. case 4:
  14883. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14884. var api string
  14885. if miConfig.MdtrtareaAdmvs == "320921" {
  14886. 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 +
  14887. "&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
  14888. fmt.Println(api)
  14889. } else {
  14890. 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 +
  14891. "&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)
  14892. }
  14893. resp, requestErr := http.Get(api)
  14894. if requestErr != nil {
  14895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14896. return
  14897. }
  14898. body, ioErr := ioutil.ReadAll(resp.Body)
  14899. if ioErr != nil {
  14900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14902. return
  14903. }
  14904. var respJSON map[string]interface{}
  14905. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14908. return
  14909. }
  14910. var status string
  14911. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14912. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14913. var token string
  14914. var res ResultTwo //1101结果
  14915. var res10265 ResultTwo10265 //1101结果
  14916. if status == "0" { //读卡成功
  14917. var card_info string //卡信息
  14918. var busi_card_info string
  14919. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14920. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14921. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14922. fmt.Println(card_info)
  14923. fmt.Println(busi_card_info)
  14924. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14925. result, _ := json.Marshal(respJSON)
  14926. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14927. utils.ErrorLog("解析失败:%v", err)
  14928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14929. return
  14930. }
  14931. res.ErrMsg = res10265.ErrMsg
  14932. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14933. res.Infcode = infocode
  14934. res.Output = res10265.Output
  14935. res.InfRefmsgid = res10265.InfRefmsgid
  14936. if res.Infcode == 0 {
  14937. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14938. if err == gorm.ErrRecordNotFound {
  14939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14940. return
  14941. } else if err != nil {
  14942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14943. return
  14944. } else {
  14945. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14946. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14947. infoStr := string(Iinfos)
  14948. idetinfoStr := string(Idetinfos)
  14949. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14950. psn := &models.HisPsn{
  14951. PsnNo: res.Output.Baseinfo.PsnNo,
  14952. PatientId: patient.ID,
  14953. Certno: res.Output.Baseinfo.Certno,
  14954. Brdy: b,
  14955. Age: float64(age),
  14956. //Brdy: res.Output.Baseinfo.Brdy,
  14957. Gend: res.Output.Baseinfo.Gend,
  14958. Naty: res.Output.Baseinfo.Naty,
  14959. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14960. PsnName: res.Output.Baseinfo.PsnName,
  14961. Idetinfo: idetinfoStr,
  14962. Insuinfo: infoStr,
  14963. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14964. CardInfo: card_info,
  14965. VerifyNumber: token,
  14966. }
  14967. var rf []*ResultFive
  14968. json.Unmarshal([]byte(infoStr), &rf)
  14969. var insutypes []*ResultFive
  14970. var insutype string
  14971. var is390 int = 0
  14972. var is310 int = 0
  14973. for _, item := range rf {
  14974. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14975. insutypes = append(insutypes, item)
  14976. }
  14977. }
  14978. if len(insutypes) == 1 {
  14979. insutype = insutypes[0].Insutype
  14980. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14981. } else {
  14982. for _, i := range insutypes {
  14983. if i.Insutype == "390" {
  14984. is390 = 1
  14985. }
  14986. if i.Insutype == "310" {
  14987. is310 = 1
  14988. }
  14989. }
  14990. }
  14991. if is390 == 1 {
  14992. insutype = "390"
  14993. }
  14994. if is310 == 1 {
  14995. insutype = "310"
  14996. }
  14997. if len(insutypes) == 0 {
  14998. insutype = "310"
  14999. }
  15000. service.CreateHisPsn(psn)
  15001. c.ServeSuccessJSON(map[string]interface{}{
  15002. "patient": patient,
  15003. "number": token,
  15004. "insutype": insutype,
  15005. })
  15006. }
  15007. } else {
  15008. c.ServeSuccessJSON(map[string]interface{}{
  15009. "failed_code": -10,
  15010. "msg": res.ErrMsg,
  15011. })
  15012. }
  15013. } else { //读卡失败
  15014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15015. return
  15016. }
  15017. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15018. var api string
  15019. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15020. "&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
  15021. resp, requestErr := http.Get(api)
  15022. if requestErr != nil {
  15023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15024. return
  15025. }
  15026. body, ioErr := ioutil.ReadAll(resp.Body)
  15027. if ioErr != nil {
  15028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15030. return
  15031. }
  15032. var respJSON map[string]interface{}
  15033. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15036. return
  15037. }
  15038. var status string
  15039. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15040. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15041. var token string
  15042. var res ResultTwo //1101结果
  15043. if status == "1" { //读卡成功
  15044. var card_info string //卡信息
  15045. var busi_card_info string
  15046. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15047. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15048. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15049. fmt.Println(card_info)
  15050. fmt.Println(busi_card_info)
  15051. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15052. result, _ := json.Marshal(respJSON)
  15053. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15054. utils.ErrorLog("解析失败:%v", err)
  15055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15056. return
  15057. }
  15058. if res.Infcode == 0 {
  15059. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15060. if err == gorm.ErrRecordNotFound {
  15061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15062. return
  15063. } else if err != nil {
  15064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15065. return
  15066. } else {
  15067. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15068. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15069. infoStr := string(Iinfos)
  15070. idetinfoStr := string(Idetinfos)
  15071. psn := &models.HisPsn{
  15072. PsnNo: res.Output.Baseinfo.PsnNo,
  15073. PatientId: patient.ID,
  15074. Certno: res.Output.Baseinfo.Certno,
  15075. Gend: res.Output.Baseinfo.Gend,
  15076. Naty: res.Output.Baseinfo.Naty,
  15077. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15078. PsnName: res.Output.Baseinfo.PsnName,
  15079. Idetinfo: idetinfoStr,
  15080. Insuinfo: infoStr,
  15081. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15082. CardInfo: card_info,
  15083. VerifyNumber: token,
  15084. }
  15085. var rf []*ResultFive
  15086. json.Unmarshal([]byte(infoStr), &rf)
  15087. var insutypes []*ResultFive
  15088. var insutype string
  15089. var is390 int = 0
  15090. var is310 int = 0
  15091. for _, item := range rf {
  15092. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15093. insutypes = append(insutypes, item)
  15094. }
  15095. }
  15096. if len(insutypes) == 1 {
  15097. insutype = insutypes[0].Insutype
  15098. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15099. } else {
  15100. for _, i := range insutypes {
  15101. if i.Insutype == "390" {
  15102. is390 = 1
  15103. }
  15104. if i.Insutype == "310" {
  15105. is310 = 1
  15106. }
  15107. }
  15108. }
  15109. if is390 == 1 {
  15110. insutype = "390"
  15111. }
  15112. if is310 == 1 {
  15113. insutype = "310"
  15114. }
  15115. if len(insutypes) == 0 {
  15116. insutype = "310"
  15117. }
  15118. service.CreateHisPsn(psn)
  15119. c.ServeSuccessJSON(map[string]interface{}{
  15120. "patient": patient,
  15121. "number": token,
  15122. "insutype": insutype,
  15123. })
  15124. }
  15125. } else {
  15126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15127. return
  15128. }
  15129. } else { //读卡失败
  15130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15131. return
  15132. }
  15133. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15134. var api string
  15135. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15136. "&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
  15137. resp, requestErr := http.Get(api)
  15138. if requestErr != nil {
  15139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15140. return
  15141. }
  15142. body, ioErr := ioutil.ReadAll(resp.Body)
  15143. if ioErr != nil {
  15144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15146. return
  15147. }
  15148. var respJSON map[string]interface{}
  15149. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15152. return
  15153. }
  15154. var status string
  15155. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15156. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15157. var token string
  15158. var res ResultTwo //1101结果
  15159. if status == "1" { //读卡成功
  15160. var card_info string //卡信息
  15161. var busi_card_info string
  15162. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15163. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15164. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15165. fmt.Println(card_info)
  15166. fmt.Println(busi_card_info)
  15167. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15168. result, _ := json.Marshal(respJSON)
  15169. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15170. utils.ErrorLog("解析失败:%v", err)
  15171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15172. return
  15173. }
  15174. if res.Infcode == 0 {
  15175. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15176. if err == gorm.ErrRecordNotFound {
  15177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15178. return
  15179. } else if err != nil {
  15180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15181. return
  15182. } else {
  15183. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15184. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15185. infoStr := string(Iinfos)
  15186. idetinfoStr := string(Idetinfos)
  15187. psn := &models.HisPsn{
  15188. PsnNo: res.Output.Baseinfo.PsnNo,
  15189. PatientId: patient.ID,
  15190. Certno: res.Output.Baseinfo.Certno,
  15191. Gend: res.Output.Baseinfo.Gend,
  15192. Naty: res.Output.Baseinfo.Naty,
  15193. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15194. PsnName: res.Output.Baseinfo.PsnName,
  15195. Idetinfo: idetinfoStr,
  15196. Insuinfo: infoStr,
  15197. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15198. CardInfo: card_info,
  15199. VerifyNumber: token,
  15200. }
  15201. var rf []*ResultFive
  15202. json.Unmarshal([]byte(infoStr), &rf)
  15203. var insutypes []*ResultFive
  15204. var insutype string
  15205. var is390 int = 0
  15206. var is310 int = 0
  15207. for _, item := range rf {
  15208. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15209. insutypes = append(insutypes, item)
  15210. }
  15211. }
  15212. if len(insutypes) == 1 {
  15213. insutype = insutypes[0].Insutype
  15214. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15215. } else {
  15216. for _, i := range insutypes {
  15217. if i.Insutype == "390" {
  15218. is390 = 1
  15219. }
  15220. if i.Insutype == "310" {
  15221. is310 = 1
  15222. }
  15223. }
  15224. }
  15225. if is390 == 1 {
  15226. insutype = "390"
  15227. }
  15228. if is310 == 1 {
  15229. insutype = "310"
  15230. }
  15231. if len(insutypes) == 0 {
  15232. insutype = "310"
  15233. }
  15234. service.CreateHisPsn(psn)
  15235. c.ServeSuccessJSON(map[string]interface{}{
  15236. "patient": patient,
  15237. "number": token,
  15238. "insutype": insutype,
  15239. })
  15240. }
  15241. } else {
  15242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15243. return
  15244. }
  15245. } else { //读卡失败
  15246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15247. return
  15248. }
  15249. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15250. //idNo := c.GetString("idNo")
  15251. //userName := c.GetString("userName")
  15252. //ecToken := c.GetString("ecToken")
  15253. //insuOrg := c.GetString("insuOrg")
  15254. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15255. utils.ErrorLog("解析失败:%v", json_result)
  15256. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15257. type ELeData struct {
  15258. Data struct {
  15259. IdNo string `json:"idNo"`
  15260. IdType string `json:"idType"`
  15261. UserName string `json:"userName"`
  15262. EcToken string `json:"ecToken"`
  15263. InsuOrg string `json:"insuOrg"`
  15264. Gender string `json:"gender"`
  15265. Birthday string `json:"birthday"`
  15266. Nationality string `json:"nationality"`
  15267. Email string `json:"email"`
  15268. Extra string `json:"extra"`
  15269. } `json:"data"`
  15270. Code int `json:"code"`
  15271. Message string `json:"message"`
  15272. }
  15273. var ele ELeData
  15274. err := json.Unmarshal([]byte(json_result), &ele)
  15275. if err != nil {
  15276. utils.ErrorLog("解析失败:%v", err)
  15277. }
  15278. token := ele.Data.EcToken
  15279. token = Remove0000(token)
  15280. 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)
  15281. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15282. var res ResultTwo
  15283. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15284. utils.ErrorLog("解析失败:%v", err)
  15285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15286. return
  15287. }
  15288. if res.Infcode == 0 {
  15289. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15290. if err == gorm.ErrRecordNotFound {
  15291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15292. return
  15293. } else if err != nil {
  15294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15295. return
  15296. } else {
  15297. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15298. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15299. infoStr := string(Iinfos)
  15300. idetinfoStr := string(Idetinfos)
  15301. psn := &models.HisPsn{
  15302. PsnNo: res.Output.Baseinfo.PsnNo,
  15303. PatientId: patient.ID,
  15304. Certno: res.Output.Baseinfo.Certno,
  15305. Gend: res.Output.Baseinfo.Gend,
  15306. Naty: res.Output.Baseinfo.Naty,
  15307. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15308. PsnName: res.Output.Baseinfo.PsnName,
  15309. Idetinfo: idetinfoStr,
  15310. Insuinfo: infoStr,
  15311. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15312. CardInfo: "",
  15313. Stage: "1",
  15314. VerifyNumber: token,
  15315. InsuplcAdmdvs: ele.Data.InsuOrg,
  15316. }
  15317. service.CreateHisPsn(psn)
  15318. var rf []*ResultFive
  15319. json.Unmarshal([]byte(infoStr), &rf)
  15320. var insutypes []*ResultFive
  15321. var insutype string
  15322. var is390 int = 0
  15323. var is310 int = 0
  15324. for _, item := range rf {
  15325. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15326. insutypes = append(insutypes, item)
  15327. }
  15328. }
  15329. if len(insutypes) == 1 {
  15330. insutype = insutypes[0].Insutype
  15331. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15332. } else {
  15333. for _, i := range insutypes {
  15334. if i.Insutype == "390" {
  15335. is390 = 1
  15336. }
  15337. if i.Insutype == "310" {
  15338. is310 = 1
  15339. }
  15340. }
  15341. }
  15342. if is390 == 1 {
  15343. insutype = "390"
  15344. }
  15345. if is310 == 1 {
  15346. insutype = "310"
  15347. }
  15348. if len(insutypes) == 0 {
  15349. insutype = "310"
  15350. }
  15351. c.ServeSuccessJSON(map[string]interface{}{
  15352. "patient": patient,
  15353. "number": token,
  15354. "insutype": insutype,
  15355. })
  15356. }
  15357. } else {
  15358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15359. return
  15360. }
  15361. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15362. //if initFlag == 0 {
  15363. //c.TestGetJiangXiBasBaseInit()
  15364. //}
  15365. //if initEleFlag == 0 {
  15366. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15367. //}
  15368. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15369. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15370. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15371. type ELeData struct {
  15372. Data struct {
  15373. IdNo string `json:"idNo"`
  15374. IdType string `json:"idType"`
  15375. UserName string `json:"userName"`
  15376. EcToken string `json:"ecToken"`
  15377. InsuOrg string `json:"insuOrg"`
  15378. Gender string `json:"gender"`
  15379. Birthday string `json:"birthday"`
  15380. Nationality string `json:"nationality"`
  15381. Email string `json:"email"`
  15382. Extra string `json:"extra"`
  15383. } `json:"data"`
  15384. Code int `json:"code"`
  15385. Message string `json:"message"`
  15386. }
  15387. var ele ELeData
  15388. err := json.Unmarshal([]byte(result), &ele)
  15389. if err != nil {
  15390. utils.ErrorLog("解析失败:%v", err)
  15391. }
  15392. token := ele.Data.EcToken
  15393. token = Remove0000(token)
  15394. 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)
  15395. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15396. var res ResultTwo
  15397. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15398. utils.ErrorLog("解析失败:%v", err)
  15399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15400. return
  15401. }
  15402. if res.Infcode == 0 {
  15403. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15404. if err == gorm.ErrRecordNotFound {
  15405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15406. return
  15407. } else if err != nil {
  15408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15409. return
  15410. } else {
  15411. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15412. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15413. infoStr := string(Iinfos)
  15414. idetinfoStr := string(Idetinfos)
  15415. psn := &models.HisPsn{
  15416. PsnNo: res.Output.Baseinfo.PsnNo,
  15417. PatientId: patient.ID,
  15418. Certno: res.Output.Baseinfo.Certno,
  15419. Gend: res.Output.Baseinfo.Gend,
  15420. Naty: res.Output.Baseinfo.Naty,
  15421. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15422. PsnName: res.Output.Baseinfo.PsnName,
  15423. Idetinfo: idetinfoStr,
  15424. Insuinfo: infoStr,
  15425. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15426. CardInfo: "",
  15427. VerifyNumber: token,
  15428. InsuplcAdmdvs: ele.Data.InsuOrg,
  15429. }
  15430. service.CreateHisPsn(psn)
  15431. var rf []*ResultFive
  15432. json.Unmarshal([]byte(infoStr), &rf)
  15433. var insutypes []*ResultFive
  15434. var insutype string
  15435. var is390 int = 0
  15436. var is310 int = 0
  15437. for _, item := range rf {
  15438. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15439. insutypes = append(insutypes, item)
  15440. }
  15441. }
  15442. if len(insutypes) == 1 {
  15443. insutype = insutypes[0].Insutype
  15444. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15445. } else {
  15446. for _, i := range insutypes {
  15447. if i.Insutype == "390" {
  15448. is390 = 1
  15449. }
  15450. if i.Insutype == "310" {
  15451. is310 = 1
  15452. }
  15453. }
  15454. }
  15455. if is390 == 1 {
  15456. insutype = "390"
  15457. }
  15458. if is310 == 1 {
  15459. insutype = "310"
  15460. }
  15461. if len(insutypes) == 0 {
  15462. insutype = "310"
  15463. }
  15464. c.ServeSuccessJSON(map[string]interface{}{
  15465. "patient": patient,
  15466. "number": token,
  15467. "insutype": insutype,
  15468. })
  15469. }
  15470. } else {
  15471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15472. return
  15473. }
  15474. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15475. //if initFlag == 0 {
  15476. //c.TestGetJiangXiBasBaseInit()
  15477. //}
  15478. //if initEleFlag == 0 {
  15479. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15480. //}
  15481. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15482. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15483. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15484. type ELeData struct {
  15485. Data struct {
  15486. IdNo string `json:"idNo"`
  15487. IdType string `json:"idType"`
  15488. UserName string `json:"userName"`
  15489. EcToken string `json:"ecToken"`
  15490. InsuOrg string `json:"insuOrg"`
  15491. Gender string `json:"gender"`
  15492. Birthday string `json:"birthday"`
  15493. Nationality string `json:"nationality"`
  15494. Email string `json:"email"`
  15495. Extra string `json:"extra"`
  15496. } `json:"data"`
  15497. Code int `json:"code"`
  15498. Message string `json:"message"`
  15499. }
  15500. var ele ELeData
  15501. err := json.Unmarshal([]byte(result), &ele)
  15502. if err != nil {
  15503. utils.ErrorLog("解析失败:%v", err)
  15504. }
  15505. token := ele.Data.EcToken
  15506. token = Remove0000(token)
  15507. 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)
  15508. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15509. var res ResultTwo
  15510. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15511. utils.ErrorLog("解析失败:%v", err)
  15512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15513. return
  15514. }
  15515. if res.Infcode == 0 {
  15516. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15517. if err == gorm.ErrRecordNotFound {
  15518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15519. return
  15520. } else if err != nil {
  15521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15522. return
  15523. } else {
  15524. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15525. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15526. infoStr := string(Iinfos)
  15527. idetinfoStr := string(Idetinfos)
  15528. psn := &models.HisPsn{
  15529. PsnNo: res.Output.Baseinfo.PsnNo,
  15530. PatientId: patient.ID,
  15531. Certno: res.Output.Baseinfo.Certno,
  15532. Gend: res.Output.Baseinfo.Gend,
  15533. Naty: res.Output.Baseinfo.Naty,
  15534. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15535. PsnName: res.Output.Baseinfo.PsnName,
  15536. Idetinfo: idetinfoStr,
  15537. Insuinfo: infoStr,
  15538. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15539. CardInfo: "",
  15540. VerifyNumber: token,
  15541. InsuplcAdmdvs: ele.Data.InsuOrg,
  15542. }
  15543. service.CreateHisPsn(psn)
  15544. var rf []*ResultFive
  15545. json.Unmarshal([]byte(infoStr), &rf)
  15546. var insutypes []*ResultFive
  15547. var insutype string
  15548. var is390 int = 0
  15549. var is310 int = 0
  15550. for _, item := range rf {
  15551. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15552. insutypes = append(insutypes, item)
  15553. }
  15554. }
  15555. if len(insutypes) == 1 {
  15556. insutype = insutypes[0].Insutype
  15557. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15558. } else {
  15559. for _, i := range insutypes {
  15560. if i.Insutype == "390" {
  15561. is390 = 1
  15562. }
  15563. if i.Insutype == "310" {
  15564. is310 = 1
  15565. }
  15566. }
  15567. }
  15568. if is390 == 1 {
  15569. insutype = "390"
  15570. }
  15571. if is310 == 1 {
  15572. insutype = "310"
  15573. }
  15574. if len(insutypes) == 0 {
  15575. insutype = "310"
  15576. }
  15577. c.ServeSuccessJSON(map[string]interface{}{
  15578. "patient": patient,
  15579. "number": token,
  15580. "insutype": insutype,
  15581. })
  15582. }
  15583. } else {
  15584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15585. return
  15586. }
  15587. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15588. //if initFlag == 0 {
  15589. c.TestGetJiangXiBasBaseInit()
  15590. //}
  15591. //if initEleFlag == 0 {
  15592. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15593. //}
  15594. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15595. type ELeData struct {
  15596. Data struct {
  15597. IdNo string `json:"idNo"`
  15598. IdType string `json:"idType"`
  15599. UserName string `json:"userName"`
  15600. EcToken string `json:"ecToken"`
  15601. InsuOrg string `json:"insuOrg"`
  15602. Gender string `json:"gender"`
  15603. Birthday string `json:"birthday"`
  15604. Nationality string `json:"nationality"`
  15605. Email string `json:"email"`
  15606. Extra string `json:"extra"`
  15607. } `json:"data"`
  15608. Code int `json:"code"`
  15609. Message string `json:"message"`
  15610. }
  15611. var ele ELeData
  15612. err := json.Unmarshal([]byte(json_result), &ele)
  15613. if err != nil {
  15614. utils.ErrorLog("解析失败:%v", err)
  15615. }
  15616. token := ele.Data.EcToken
  15617. token = Remove0000(token)
  15618. 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)
  15619. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15620. var res ResultTwo
  15621. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15622. utils.ErrorLog("解析失败:%v", err)
  15623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15624. return
  15625. }
  15626. if res.Infcode == 0 {
  15627. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15628. if err == gorm.ErrRecordNotFound {
  15629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15630. return
  15631. } else if err != nil {
  15632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15633. return
  15634. } else {
  15635. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15636. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15637. infoStr := string(Iinfos)
  15638. idetinfoStr := string(Idetinfos)
  15639. psn := &models.HisPsn{
  15640. PsnNo: res.Output.Baseinfo.PsnNo,
  15641. PatientId: patient.ID,
  15642. Certno: res.Output.Baseinfo.Certno,
  15643. Gend: res.Output.Baseinfo.Gend,
  15644. Naty: res.Output.Baseinfo.Naty,
  15645. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15646. PsnName: res.Output.Baseinfo.PsnName,
  15647. Idetinfo: idetinfoStr,
  15648. Insuinfo: infoStr,
  15649. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15650. CardInfo: "",
  15651. VerifyNumber: token,
  15652. }
  15653. service.CreateHisPsn(psn)
  15654. var rf []*ResultFive
  15655. json.Unmarshal([]byte(infoStr), &rf)
  15656. var insutypes []*ResultFive
  15657. var insutype string
  15658. var is390 int = 0
  15659. var is310 int = 0
  15660. for _, item := range rf {
  15661. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15662. insutypes = append(insutypes, item)
  15663. }
  15664. }
  15665. if len(insutypes) == 1 {
  15666. insutype = insutypes[0].Insutype
  15667. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15668. } else {
  15669. for _, i := range insutypes {
  15670. if i.Insutype == "390" {
  15671. is390 = 1
  15672. }
  15673. if i.Insutype == "310" {
  15674. is310 = 1
  15675. }
  15676. }
  15677. }
  15678. if is390 == 1 {
  15679. insutype = "390"
  15680. }
  15681. if is310 == 1 {
  15682. insutype = "310"
  15683. }
  15684. if len(insutypes) == 0 {
  15685. insutype = "310"
  15686. }
  15687. c.ServeSuccessJSON(map[string]interface{}{
  15688. "patient": patient,
  15689. "number": token,
  15690. "insutype": insutype,
  15691. })
  15692. }
  15693. } else {
  15694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15695. return
  15696. }
  15697. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15698. type ELeData struct {
  15699. Code string `json:"code"`
  15700. Data struct {
  15701. Aac002 string `json:"aac002"`
  15702. Aaz500 string `json:"aaz500"`
  15703. ActCardNo string `json:"actCardNo"`
  15704. Bab520 string `json:"bab520"`
  15705. Bkz543 string `json:"bkz543"`
  15706. BusinessType string `json:"businessType"`
  15707. CertfCodg string `json:"certfCodg"`
  15708. EcIndexNo string `json:"ecIndexNo"`
  15709. EcToken string `json:"ecToken"`
  15710. ID0000 string `json:"id0000"`
  15711. IDNo string `json:"idNo"`
  15712. IDType string `json:"idType"`
  15713. Idcode string `json:"idcode"`
  15714. IdentityToken string `json:"identity_token"`
  15715. InsuOrg string `json:"insuOrg"`
  15716. OfficeID string `json:"officeId"`
  15717. OfficeName string `json:"officeName"`
  15718. OperatorID string `json:"operatorId"`
  15719. OperatorName string `json:"operatorName"`
  15720. OrgID string `json:"orgId"`
  15721. UserName string `json:"userName"`
  15722. } `json:"data"`
  15723. Infno interface{} `json:"infno"`
  15724. Message string `json:"message"`
  15725. OrgID string `json:"orgId"`
  15726. TransType string `json:"transType"`
  15727. }
  15728. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  15729. outPutInfo = Remove0000(outPutInfo)
  15730. if len(outPutInfo) > 0 {
  15731. var ele ELeData
  15732. err := json.Unmarshal([]byte(outPutInfo), &ele)
  15733. if err != nil {
  15734. utils.ErrorLog("解析失败:%v", err)
  15735. }
  15736. token := ele.Data.EcToken
  15737. fmt.Println(inputInfo)
  15738. fmt.Println(outPutInfo)
  15739. 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)
  15740. saveLog(result, requestLog, "1101", "获取人员信息")
  15741. var dat map[string]interface{}
  15742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15743. fmt.Println(dat)
  15744. } else {
  15745. fmt.Println(err)
  15746. }
  15747. userJSONBytes, _ := json.Marshal(dat)
  15748. var res ResultTwo
  15749. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15750. utils.ErrorLog("解析失败:%v", err)
  15751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15752. return
  15753. }
  15754. res.ErrMsg = errMsgLog
  15755. if res.Infcode == 0 {
  15756. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  15757. if err == gorm.ErrRecordNotFound {
  15758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15759. return
  15760. } else if err != nil {
  15761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15762. return
  15763. } else {
  15764. fmt.Println(res)
  15765. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15766. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15767. infoStr := string(Iinfos)
  15768. idetinfoStr := string(Idetinfos)
  15769. psn := &models.HisPsn{
  15770. PsnNo: res.Output.Baseinfo.PsnNo,
  15771. PatientId: patient.ID,
  15772. Certno: res.Output.Baseinfo.Certno,
  15773. Gend: res.Output.Baseinfo.Gend,
  15774. Naty: res.Output.Baseinfo.Naty,
  15775. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15776. PsnName: res.Output.Baseinfo.PsnName,
  15777. Idetinfo: idetinfoStr,
  15778. Insuinfo: infoStr,
  15779. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15780. CardInfo: outPutInfo,
  15781. VerifyNumber: token,
  15782. InsuplcAdmdvs: ele.Data.InsuOrg,
  15783. }
  15784. service.CreateHisPsn(psn)
  15785. var rf []*ResultFive
  15786. json.Unmarshal([]byte(infoStr), &rf)
  15787. var insutypes []*ResultFive
  15788. var insutype string
  15789. var is390 int = 0
  15790. var is310 int = 0
  15791. for _, item := range rf {
  15792. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15793. insutypes = append(insutypes, item)
  15794. }
  15795. }
  15796. if len(insutypes) == 1 {
  15797. insutype = insutypes[0].Insutype
  15798. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15799. } else {
  15800. for _, i := range insutypes {
  15801. if i.Insutype == "390" {
  15802. is390 = 1
  15803. }
  15804. if i.Insutype == "310" {
  15805. is310 = 1
  15806. }
  15807. }
  15808. }
  15809. if is390 == 1 {
  15810. insutype = "390"
  15811. }
  15812. if is310 == 1 {
  15813. insutype = "310"
  15814. }
  15815. if len(insutypes) == 0 {
  15816. insutype = "310"
  15817. }
  15818. c.ServeSuccessJSON(map[string]interface{}{
  15819. "patient": patient,
  15820. "number": token,
  15821. "insutype": insutype,
  15822. })
  15823. }
  15824. } else {
  15825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15826. return
  15827. }
  15828. }
  15829. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15830. var api string
  15831. 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 +
  15832. "&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
  15833. resp, requestErr := http.Get(api)
  15834. if requestErr != nil {
  15835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15836. return
  15837. }
  15838. body, ioErr := ioutil.ReadAll(resp.Body)
  15839. if ioErr != nil {
  15840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15842. return
  15843. }
  15844. var respJSON map[string]interface{}
  15845. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15848. return
  15849. }
  15850. var status string
  15851. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15852. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15853. var token string
  15854. var res ResultTwo //1101结果
  15855. var res10265 ResultTwo10265 //1101结果
  15856. if status == "0" { //读卡成功
  15857. var card_info string //卡信息
  15858. var busi_card_info string
  15859. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15860. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15861. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15862. fmt.Println(card_info)
  15863. fmt.Println(busi_card_info)
  15864. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15865. result, _ := json.Marshal(respJSON)
  15866. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15867. utils.ErrorLog("解析失败:%v", err)
  15868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15869. return
  15870. }
  15871. res.ErrMsg = res10265.ErrMsg
  15872. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15873. res.Infcode = infocode
  15874. res.Output = res10265.Output
  15875. res.InfRefmsgid = res10265.InfRefmsgid
  15876. if res.Infcode == 0 {
  15877. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15878. if err == gorm.ErrRecordNotFound {
  15879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15880. return
  15881. } else if err != nil {
  15882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15883. return
  15884. } else {
  15885. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15886. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15887. infoStr := string(Iinfos)
  15888. idetinfoStr := string(Idetinfos)
  15889. psn := &models.HisPsn{
  15890. PsnNo: res.Output.Baseinfo.PsnNo,
  15891. PatientId: patient.ID,
  15892. Certno: res.Output.Baseinfo.Certno,
  15893. Gend: res.Output.Baseinfo.Gend,
  15894. Naty: res.Output.Baseinfo.Naty,
  15895. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15896. PsnName: res.Output.Baseinfo.PsnName,
  15897. Idetinfo: idetinfoStr,
  15898. Insuinfo: infoStr,
  15899. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15900. CardInfo: card_info,
  15901. VerifyNumber: token,
  15902. }
  15903. var rf []*ResultFive
  15904. json.Unmarshal([]byte(infoStr), &rf)
  15905. var insutypes []*ResultFive
  15906. var insutype string
  15907. var is390 int = 0
  15908. var is310 int = 0
  15909. for _, item := range rf {
  15910. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15911. insutypes = append(insutypes, item)
  15912. }
  15913. }
  15914. if len(insutypes) == 1 {
  15915. insutype = insutypes[0].Insutype
  15916. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15917. } else {
  15918. for _, i := range insutypes {
  15919. if i.Insutype == "390" {
  15920. is390 = 1
  15921. }
  15922. if i.Insutype == "310" {
  15923. is310 = 1
  15924. }
  15925. }
  15926. }
  15927. if is390 == 1 {
  15928. insutype = "390"
  15929. }
  15930. if is310 == 1 {
  15931. insutype = "310"
  15932. }
  15933. if len(insutypes) == 0 {
  15934. insutype = "310"
  15935. }
  15936. service.CreateHisPsn(psn)
  15937. c.ServeSuccessJSON(map[string]interface{}{
  15938. "patient": patient,
  15939. "number": token,
  15940. "insutype": insutype,
  15941. })
  15942. }
  15943. } else {
  15944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15945. return
  15946. }
  15947. } else { //读卡失败
  15948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15949. return
  15950. }
  15951. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15952. res := c.GetoleInfo()
  15953. if res.Infcode == 0 {
  15954. var result string
  15955. if res.Output.MdtrtCertType == "01" {
  15956. 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)
  15957. } else if res.Output.MdtrtCertType == "02" {
  15958. 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)
  15959. } else if res.Output.MdtrtCertType == "03" {
  15960. 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)
  15961. }
  15962. var dat map[string]interface{}
  15963. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15964. fmt.Println(dat)
  15965. } else {
  15966. fmt.Println(err)
  15967. }
  15968. userJSONBytes, _ := json.Marshal(dat)
  15969. var res2 ResultTwo
  15970. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15971. utils.ErrorLog("解析失败:%v", err)
  15972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15973. return
  15974. }
  15975. if res2.Infcode == 0 {
  15976. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15977. if err == gorm.ErrRecordNotFound {
  15978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15979. return
  15980. } else if err != nil {
  15981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15982. return
  15983. } else {
  15984. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15985. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15986. infoStr := string(Iinfos)
  15987. idetinfoStr := string(Idetinfos)
  15988. var rf []*ResultFive
  15989. json.Unmarshal([]byte(infoStr), &rf)
  15990. var insutypes []*ResultFive
  15991. var insutype string
  15992. var is390 int = 0
  15993. var is310 int = 0
  15994. //var insuplc_admdvs string
  15995. for _, item := range rf {
  15996. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15997. insutypes = append(insutypes, item)
  15998. }
  15999. }
  16000. if len(insutypes) == 1 {
  16001. insutype = insutypes[0].Insutype
  16002. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16003. } else {
  16004. for _, i := range insutypes {
  16005. if i.Insutype == "390" {
  16006. is390 = 1
  16007. }
  16008. if i.Insutype == "310" {
  16009. is310 = 1
  16010. }
  16011. }
  16012. }
  16013. if is390 == 1 {
  16014. insutype = "390"
  16015. }
  16016. if is310 == 1 {
  16017. insutype = "310"
  16018. }
  16019. if len(insutypes) == 0 {
  16020. insutype = "310"
  16021. }
  16022. psn := &models.HisPsn{
  16023. PsnNo: res2.Output.Baseinfo.PsnNo,
  16024. PatientId: patient.ID,
  16025. Certno: res2.Output.Baseinfo.Certno,
  16026. Gend: res2.Output.Baseinfo.Gend,
  16027. Naty: res2.Output.Baseinfo.Naty,
  16028. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16029. PsnName: res2.Output.Baseinfo.PsnName,
  16030. Idetinfo: idetinfoStr,
  16031. Insuinfo: infoStr,
  16032. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16033. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16034. VerifyNumber: res.Output.EcToken,
  16035. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16036. }
  16037. if res.Output.MdtrtCertType == "01" {
  16038. psn.VerifyNumber = res.Output.EcToken
  16039. //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)
  16040. } else if res.Output.MdtrtCertType == "02" {
  16041. psn.VerifyNumber = res.Output.CardNo
  16042. //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)
  16043. } else if res.Output.MdtrtCertType == "03" {
  16044. psn.VerifyNumber = res.Output.MdtrtCertNo
  16045. //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)
  16046. }
  16047. service.CreateHisPsn(psn)
  16048. var balc float64
  16049. for _, item := range rf {
  16050. if item.Insutype == insutype {
  16051. balc = item.Balc
  16052. }
  16053. }
  16054. c.ServeSuccessJSON(map[string]interface{}{
  16055. "patient": patient,
  16056. "number": res.Output.CardNo,
  16057. "insutype": insutype,
  16058. "blac": balc,
  16059. "desc": idetinfoStr,
  16060. })
  16061. }
  16062. } else {
  16063. c.ServeSuccessJSON(map[string]interface{}{
  16064. "failed_code": -10,
  16065. "msg": res2.ErrMsg,
  16066. })
  16067. }
  16068. } else {
  16069. c.ServeSuccessJSON(map[string]interface{}{
  16070. "failed_code": -10,
  16071. "msg": res.ErrMsg,
  16072. })
  16073. }
  16074. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16075. var res ResultTwo
  16076. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16077. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16078. "&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)
  16079. resp, requestErr := http.Get(api)
  16080. if requestErr != nil {
  16081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16082. return
  16083. }
  16084. body, ioErr := ioutil.ReadAll(resp.Body)
  16085. if ioErr != nil {
  16086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16088. return
  16089. }
  16090. var respJSON map[string]interface{}
  16091. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16094. return
  16095. }
  16096. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16097. result, _ := json.Marshal(respJSON)
  16098. fmt.Println("log")
  16099. fmt.Println(string(result))
  16100. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16101. utils.ErrorLog("解析失败:%v", err)
  16102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16103. return
  16104. }
  16105. if res.Infcode == 0 {
  16106. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16107. if err == gorm.ErrRecordNotFound {
  16108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16109. return
  16110. } else if err != nil {
  16111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16112. return
  16113. } else {
  16114. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16115. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16116. infoStr := string(Iinfos)
  16117. idetinfoStr := string(Idetinfos)
  16118. var rf []*ResultFive
  16119. json.Unmarshal([]byte(infoStr), &rf)
  16120. var insutypes []*ResultFive
  16121. var insutype string
  16122. var is390 int = 0
  16123. var is310 int = 0
  16124. for _, item := range rf {
  16125. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16126. insutypes = append(insutypes, item)
  16127. }
  16128. }
  16129. if len(insutypes) == 1 {
  16130. insutype = insutypes[0].Insutype
  16131. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16132. } else {
  16133. for _, i := range insutypes {
  16134. if i.Insutype == "390" {
  16135. is390 = 1
  16136. }
  16137. if i.Insutype == "310" {
  16138. is310 = 1
  16139. }
  16140. }
  16141. }
  16142. if is390 == 1 {
  16143. insutype = "390"
  16144. }
  16145. if is310 == 1 {
  16146. insutype = "310"
  16147. }
  16148. if len(insutypes) == 0 {
  16149. insutype = "390"
  16150. }
  16151. var insuplc_admdvs string
  16152. for _, item := range rf {
  16153. if item.Insutype == insutype {
  16154. insuplc_admdvs = item.InsuplcAdmdvs
  16155. }
  16156. }
  16157. psn := &models.HisPsn{
  16158. PsnNo: res.Output.Baseinfo.PsnNo,
  16159. PatientId: patient.ID,
  16160. Certno: res.Output.Baseinfo.Certno,
  16161. Gend: res.Output.Baseinfo.Gend,
  16162. Naty: res.Output.Baseinfo.Naty,
  16163. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16164. PsnName: res.Output.Baseinfo.PsnName,
  16165. Idetinfo: idetinfoStr,
  16166. Insuinfo: infoStr,
  16167. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16168. InsuplcAdmdvs: insuplc_admdvs,
  16169. }
  16170. service.CreateHisPsn(psn)
  16171. c.ServeSuccessJSON(map[string]interface{}{
  16172. "patient": patient,
  16173. "number": res.Output.Baseinfo.Certno,
  16174. })
  16175. }
  16176. } else {
  16177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16178. return
  16179. }
  16180. } else {
  16181. type ELeData struct {
  16182. Code string `json:"code"`
  16183. Data struct {
  16184. Aac002 string `json:"aac002"`
  16185. Aaz500 string `json:"aaz500"`
  16186. ActCardNo string `json:"actCardNo"`
  16187. Bab520 string `json:"bab520"`
  16188. Bkz543 string `json:"bkz543"`
  16189. BusinessType string `json:"businessType"`
  16190. CertfCodg string `json:"certfCodg"`
  16191. EcIndexNo string `json:"ecIndexNo"`
  16192. EcToken string `json:"ecToken"`
  16193. ID0000 string `json:"id0000"`
  16194. IDNo string `json:"idNo"`
  16195. IDType string `json:"idType"`
  16196. Idcode string `json:"idcode"`
  16197. IdentityToken string `json:"identity_token"`
  16198. InsuOrg string `json:"insuOrg"`
  16199. OfficeID string `json:"officeId"`
  16200. OfficeName string `json:"officeName"`
  16201. OperatorID string `json:"operatorId"`
  16202. OperatorName string `json:"operatorName"`
  16203. OrgID string `json:"orgId"`
  16204. UserName string `json:"userName"`
  16205. } `json:"data"`
  16206. Infno interface{} `json:"infno"`
  16207. Message string `json:"message"`
  16208. OrgID string `json:"orgId"`
  16209. TransType string `json:"transType"`
  16210. }
  16211. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16212. fmt.Println(result)
  16213. outPutInfo := Remove0000(result)
  16214. fmt.Println(outPutInfo)
  16215. if len(outPutInfo) > 0 {
  16216. var ele ELeData
  16217. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16218. if err != nil {
  16219. utils.ErrorLog("解析失败:%v", err)
  16220. }
  16221. token := ele.Data.EcToken
  16222. fmt.Println(outPutInfo)
  16223. 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)
  16224. saveLog(result, requestLog, "1101", "获取人员信息")
  16225. var dat map[string]interface{}
  16226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16227. fmt.Println(dat)
  16228. } else {
  16229. fmt.Println(err)
  16230. }
  16231. userJSONBytes, _ := json.Marshal(dat)
  16232. var res ResultTwo
  16233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16234. utils.ErrorLog("解析失败:%v", err)
  16235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16236. return
  16237. }
  16238. if res.Infcode == 0 {
  16239. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16240. if err == gorm.ErrRecordNotFound {
  16241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16242. return
  16243. } else if err != nil {
  16244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16245. return
  16246. } else {
  16247. fmt.Println(res)
  16248. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16249. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16250. infoStr := string(Iinfos)
  16251. idetinfoStr := string(Idetinfos)
  16252. psn := &models.HisPsn{
  16253. PsnNo: res.Output.Baseinfo.PsnNo,
  16254. PatientId: patient.ID,
  16255. Certno: res.Output.Baseinfo.Certno,
  16256. Gend: res.Output.Baseinfo.Gend,
  16257. Naty: res.Output.Baseinfo.Naty,
  16258. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16259. PsnName: res.Output.Baseinfo.PsnName,
  16260. Idetinfo: idetinfoStr,
  16261. Insuinfo: infoStr,
  16262. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16263. CardInfo: outPutInfo,
  16264. VerifyNumber: token,
  16265. InsuplcAdmdvs: ele.Data.InsuOrg,
  16266. }
  16267. service.CreateHisPsn(psn)
  16268. var rf []*ResultFive
  16269. json.Unmarshal([]byte(infoStr), &rf)
  16270. var insutypes []*ResultFive
  16271. var insutype string
  16272. var is390 int = 0
  16273. var is310 int = 0
  16274. for _, item := range rf {
  16275. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16276. insutypes = append(insutypes, item)
  16277. }
  16278. }
  16279. if len(insutypes) == 1 {
  16280. insutype = insutypes[0].Insutype
  16281. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16282. } else {
  16283. for _, i := range insutypes {
  16284. if i.Insutype == "390" {
  16285. is390 = 1
  16286. }
  16287. if i.Insutype == "310" {
  16288. is310 = 1
  16289. }
  16290. }
  16291. }
  16292. if is390 == 1 {
  16293. insutype = "390"
  16294. }
  16295. if is310 == 1 {
  16296. insutype = "310"
  16297. }
  16298. if len(insutypes) == 0 {
  16299. insutype = "310"
  16300. }
  16301. c.ServeSuccessJSON(map[string]interface{}{
  16302. "patient": patient,
  16303. "number": token,
  16304. "insutype": insutype,
  16305. })
  16306. }
  16307. } else {
  16308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16309. return
  16310. }
  16311. }
  16312. //fmt.Println(result)
  16313. //
  16314. //if initFlag == 0 {
  16315. // c.TestGetBasBaseInit()
  16316. //}
  16317. //token := c.GetEleBaseInfo()
  16318. //
  16319. //token = Remove0000(token)
  16320. //
  16321. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16322. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16323. ////
  16324. //var res ResultTwo
  16325. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16326. // utils.ErrorLog("解析失败:%v", err)
  16327. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16328. // return
  16329. //}
  16330. //
  16331. //if res.Infcode == 0 {
  16332. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16333. // if err == gorm.ErrRecordNotFound {
  16334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16335. // return
  16336. // } else if err != nil {
  16337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16338. // return
  16339. //
  16340. // } else {
  16341. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16342. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16343. // infoStr := string(Iinfos)
  16344. // idetinfoStr := string(Idetinfos)
  16345. //
  16346. //
  16347. //
  16348. //
  16349. // var rf []*ResultFive
  16350. // json.Unmarshal([]byte(infoStr), &rf)
  16351. //
  16352. // var insutypes []*ResultFive
  16353. // var insutype string
  16354. // var is390 int = 0
  16355. // var is310 int = 0
  16356. // var insuplc_admdvs string
  16357. //
  16358. // for _, item := range rf {
  16359. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16360. // insutypes = append(insutypes, item)
  16361. // }
  16362. // }
  16363. //
  16364. // if len(insutypes) == 1 {
  16365. // insutype = insutypes[0].Insutype
  16366. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16367. // } else {
  16368. // for _, i := range insutypes {
  16369. // if i.Insutype == "390" {
  16370. // is390 = 1
  16371. // }
  16372. //
  16373. // if i.Insutype == "310" {
  16374. // is310 = 1
  16375. // }
  16376. // }
  16377. // }
  16378. // if is390 == 1 {
  16379. // insutype = "390"
  16380. // }
  16381. //
  16382. // if is310 == 1 {
  16383. // insutype = "310"
  16384. // }
  16385. // if len(insutypes) == 0 {
  16386. // insutype = "310"
  16387. // }
  16388. // for _, item := range rf {
  16389. // if item.Insutype == insutype {
  16390. // insuplc_admdvs = item.InsuplcAdmdvs
  16391. // }
  16392. // }
  16393. // psn := &models.HisPsn{
  16394. // PsnNo: res.Output.Baseinfo.PsnNo,
  16395. // Age: res.Output.Baseinfo.Age,
  16396. // PatientId: patient.ID,
  16397. // Certno: res.Output.Baseinfo.Certno,
  16398. // Brdy: res.Output.Baseinfo.Brdy,
  16399. // Gend: res.Output.Baseinfo.Gend,
  16400. // Naty: res.Output.Baseinfo.Naty,
  16401. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16402. // PsnName: res.Output.Baseinfo.PsnName,
  16403. // Idetinfo: idetinfoStr,
  16404. // Insuinfo: infoStr,
  16405. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16406. // CardInfo: "",
  16407. // VerifyNumber: token,
  16408. // InsuplcAdmdvs: insuplc_admdvs,
  16409. // }
  16410. // service.CreateHisPsn(psn)
  16411. //
  16412. // c.ServeSuccessJSON(map[string]interface{}{
  16413. // "patient": patient,
  16414. // "number": token,
  16415. // })
  16416. // }
  16417. //} else {
  16418. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16419. // return
  16420. //}
  16421. }
  16422. break
  16423. case 5:
  16424. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16425. var api string
  16426. if miConfig.MdtrtareaAdmvs == "320921" {
  16427. 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 +
  16428. "&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
  16429. fmt.Println(api)
  16430. } else {
  16431. 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 +
  16432. "&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)
  16433. }
  16434. resp, requestErr := http.Get(api)
  16435. if requestErr != nil {
  16436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16437. return
  16438. }
  16439. body, ioErr := ioutil.ReadAll(resp.Body)
  16440. if ioErr != nil {
  16441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16443. return
  16444. }
  16445. var respJSON map[string]interface{}
  16446. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16449. return
  16450. }
  16451. var status string
  16452. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16453. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16454. var token string
  16455. var res ResultTwo //1101结果
  16456. var res10265 ResultTwo10265 //1101结果
  16457. if status == "0" { //读卡成功
  16458. var card_info string //卡信息
  16459. //var busi_card_info string
  16460. var auth_info string
  16461. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16462. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16463. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16464. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16465. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16466. result, _ := json.Marshal(respJSON)
  16467. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16468. utils.ErrorLog("解析失败:%v", err)
  16469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16470. return
  16471. }
  16472. res.ErrMsg = res10265.ErrMsg
  16473. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16474. res.Infcode = infocode
  16475. res.Output = res10265.Output
  16476. res.InfRefmsgid = res10265.InfRefmsgid
  16477. if res.Infcode == 0 {
  16478. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16479. if err == gorm.ErrRecordNotFound {
  16480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16481. return
  16482. } else if err != nil {
  16483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16484. return
  16485. } else {
  16486. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16487. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16488. infoStr := string(Iinfos)
  16489. idetinfoStr := string(Idetinfos)
  16490. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16491. psn := &models.HisPsn{
  16492. PsnNo: res.Output.Baseinfo.PsnNo,
  16493. PatientId: patient.ID,
  16494. Certno: res.Output.Baseinfo.Certno,
  16495. Gend: res.Output.Baseinfo.Gend,
  16496. Brdy: b,
  16497. Age: float64(age),
  16498. Naty: res.Output.Baseinfo.Naty,
  16499. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16500. PsnName: res.Output.Baseinfo.PsnName,
  16501. Idetinfo: idetinfoStr,
  16502. Insuinfo: infoStr,
  16503. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16504. CardInfo: card_info,
  16505. VerifyNumber: token,
  16506. AuthInfo: auth_info,
  16507. }
  16508. var rf []*ResultFive
  16509. json.Unmarshal([]byte(infoStr), &rf)
  16510. var insutypes []*ResultFive
  16511. var insutype string
  16512. var is390 int = 0
  16513. var is310 int = 0
  16514. for _, item := range rf {
  16515. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16516. insutypes = append(insutypes, item)
  16517. }
  16518. }
  16519. if len(insutypes) == 1 {
  16520. insutype = insutypes[0].Insutype
  16521. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16522. } else {
  16523. for _, i := range insutypes {
  16524. if i.Insutype == "390" {
  16525. is390 = 1
  16526. }
  16527. if i.Insutype == "310" {
  16528. is310 = 1
  16529. }
  16530. }
  16531. }
  16532. if is390 == 1 {
  16533. insutype = "390"
  16534. }
  16535. if is310 == 1 {
  16536. insutype = "310"
  16537. }
  16538. if len(insutypes) == 0 {
  16539. insutype = "310"
  16540. }
  16541. service.CreateHisPsn(psn)
  16542. c.ServeSuccessJSON(map[string]interface{}{
  16543. "patient": patient,
  16544. "number": token,
  16545. "insutype": insutype,
  16546. })
  16547. }
  16548. } else {
  16549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16550. return
  16551. }
  16552. } else { //读卡失败
  16553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16554. return
  16555. }
  16556. }
  16557. break
  16558. }
  16559. }
  16560. var initFlag int64 = 0
  16561. var initEleFlag int64 = 0
  16562. func (c *HisApiController) TestGetBasBaseInit() {
  16563. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16564. Iinit := DllDef.MustFindProc("Init")
  16565. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16566. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  16567. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  16568. if ret != 0 {
  16569. fmt.Println("SSCard的报错原因:", err)
  16570. fmt.Println("SSCard的运算结果为:", ret)
  16571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16572. return
  16573. }
  16574. result := int(ret)
  16575. fmt.Println("SSCard的运算结果为1:", result)
  16576. initFlag = 1
  16577. return
  16578. }
  16579. func (c *HisApiController) HandleJiangXiReadCard() {
  16580. fmt.Println("~~~~~~")
  16581. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16582. admin_user_id, _ := c.GetInt64("admin_user_id")
  16583. id_card_type, _ := c.GetInt64("id_card_type")
  16584. //certificates, _ := c.GetInt64("certificates")
  16585. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16586. if initFlag == 0 {
  16587. c.TestGetJiangXiBasBaseInit()
  16588. }
  16589. basStr := c.GetBasBaseInfo()
  16590. if len(basStr) == 0 {
  16591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16592. return
  16593. }
  16594. fmt.Println(basStr)
  16595. bas := strings.Split(basStr, "|")
  16596. basNumber := bas[1]
  16597. fmt.Println(basNumber)
  16598. card_sn := bas[3]
  16599. fmt.Println(card_sn)
  16600. 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, "")
  16601. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  16602. var dat map[string]interface{}
  16603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16604. fmt.Println(dat)
  16605. } else {
  16606. fmt.Println(err)
  16607. }
  16608. userJSONBytes, _ := json.Marshal(dat)
  16609. var res ResultTwo
  16610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16611. utils.ErrorLog("解析失败:%v", err)
  16612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16613. return
  16614. }
  16615. if res.Infcode == 0 {
  16616. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  16617. if err == gorm.ErrRecordNotFound {
  16618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16619. return
  16620. } else if err != nil {
  16621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16622. return
  16623. } else {
  16624. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16625. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16626. infoStr := string(Iinfos)
  16627. idetinfoStr := string(Idetinfos)
  16628. psn := &models.HisPsn{
  16629. PsnNo: res.Output.Baseinfo.PsnNo,
  16630. PatientId: patient.ID,
  16631. Certno: res.Output.Baseinfo.Certno,
  16632. Gend: res.Output.Baseinfo.Gend,
  16633. Naty: res.Output.Baseinfo.Naty,
  16634. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16635. PsnName: res.Output.Baseinfo.PsnName,
  16636. Idetinfo: idetinfoStr,
  16637. Insuinfo: infoStr,
  16638. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16639. CardInfo: basStr,
  16640. VerifyNumber: "",
  16641. }
  16642. service.CreateHisPsn(psn)
  16643. c.ServeSuccessJSON(map[string]interface{}{
  16644. "patient": patient,
  16645. "number": basNumber,
  16646. })
  16647. }
  16648. } else {
  16649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16650. return
  16651. }
  16652. }
  16653. func (c *HisApiController) TestGetHnBasBaseInit() {
  16654. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16655. Iinit := DllDef.MustFindProc("Init")
  16656. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16657. //http://10.77.211.236/CSB/hsa-fsi-1303
  16658. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  16659. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  16660. // 调用 Init 函数
  16661. 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"))))
  16662. //if ret != 0 {
  16663. fmt.Println("SSCard的报错原因:", err)
  16664. fmt.Println("SSCard的运算结果为:", ret)
  16665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16666. // return
  16667. //}
  16668. result := int(ret)
  16669. fmt.Println("SSCard的运算结果为1:", result)
  16670. initFlag = 1
  16671. return
  16672. }
  16673. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  16674. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16675. Iinit := DllDef.MustFindProc("Init")
  16676. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16677. //http://10.77.211.236/CSB/hsa-fsi-1303
  16678. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  16679. if ret != 0 {
  16680. fmt.Println("SSCard的报错原因:", err)
  16681. fmt.Println("SSCard的运算结果为:", ret)
  16682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16683. return
  16684. }
  16685. result := int(ret)
  16686. fmt.Println("SSCard的运算结果为1:", result)
  16687. initFlag = 1
  16688. return
  16689. }
  16690. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  16691. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16692. Iinit := DllDef.MustFindProc("Init")
  16693. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16694. //http://10.77.211.236/CSB/hsa-fsi-1303
  16695. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  16696. if ret != 0 {
  16697. fmt.Println("SSCard的报错原因:", err)
  16698. fmt.Println("SSCard的运算结果为:", ret)
  16699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16700. return
  16701. }
  16702. result := int(ret)
  16703. fmt.Println("SSCard的运算结果为1:", result)
  16704. initFlag = 1
  16705. return
  16706. }
  16707. func (c *HisApiController) GetSFZBaseInfo() string {
  16708. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16709. readCard := DllDef.MustFindProc("ReadSFZ")
  16710. if readCard == nil {
  16711. fmt.Println("readcard is nil")
  16712. readCard = DllDef.MustFindProc("ReadSFZ")
  16713. }
  16714. str := make([]byte, 8096)
  16715. str1 := make([]byte, 8096)
  16716. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  16717. fmt.Println(r)
  16718. return Remove0000(string(str))
  16719. }
  16720. func (c *HisApiController) GetEleBaseInfo() string {
  16721. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16722. readCard := DllDef.MustFindProc("GetQRBase")
  16723. fmt.Println(readCard)
  16724. if readCard == nil {
  16725. fmt.Println("readcard is nil")
  16726. readCard = DllDef.MustFindProc("GetQRBase")
  16727. }
  16728. str := make([]byte, 1024)
  16729. str1 := make([]byte, 1024)
  16730. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  16731. fmt.Println(ret2)
  16732. fmt.Println(string(str1))
  16733. fmt.Println(string(str))
  16734. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16735. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16736. if ret2 != 0 {
  16737. return ""
  16738. }
  16739. return string(str)
  16740. }
  16741. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  16742. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16743. readCard := DllDef.MustFindProc("NationEcTrans")
  16744. fmt.Println(readCard)
  16745. fmt.Println("!!!!!")
  16746. pBusiCardInfo := make([]byte, 2048)
  16747. input := make(map[string]interface{})
  16748. inputData := make(map[string]interface{})
  16749. inputData["orgId"] = code
  16750. inputData["businessType"] = "01101"
  16751. inputData["operatorId"] = "1"
  16752. inputData["operatorName"] = "admin"
  16753. inputData["officeId"] = "001"
  16754. inputData["officeName"] = "血透室"
  16755. inputData["deviceType"] = ""
  16756. input["data"] = inputData
  16757. input["orgId"] = code
  16758. input["transType"] = "ec.query"
  16759. bytesData, _ := json.Marshal(input)
  16760. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  16761. fmt.Println(ret2)
  16762. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16763. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16764. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  16765. }
  16766. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  16767. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16768. readCard := DllDef.MustFindProc("NationEcTrans")
  16769. fmt.Println(readCard)
  16770. fmt.Println("!!!!!")
  16771. pBusiCardInfo := make([]byte, 2048)
  16772. input := make(map[string]interface{})
  16773. inputData := make(map[string]interface{})
  16774. inputData["orgId"] = code
  16775. inputData["businessType"] = "01101"
  16776. inputData["operatorId"] = "9"
  16777. inputData["operatorName"] = "admin"
  16778. inputData["officeId"] = "001"
  16779. inputData["officeName"] = "血透室"
  16780. inputData["deviceType"] = ""
  16781. input["data"] = inputData
  16782. input["orgId"] = code
  16783. input["transType"] = "ec.query"
  16784. bytesData, _ := json.Marshal(input)
  16785. 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])))
  16786. fmt.Println(ret2)
  16787. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16788. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16789. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  16790. }
  16791. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  16792. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16793. readCard := DllDef.MustFindProc("NationEcTrans")
  16794. fmt.Println(readCard)
  16795. fmt.Println("!!!!!")
  16796. pBusiCardInfo := make([]byte, 2048)
  16797. input := make(map[string]interface{})
  16798. inputData := make(map[string]interface{})
  16799. inputData["orgId"] = code
  16800. inputData["businessType"] = "01301"
  16801. inputData["operatorId"] = "9"
  16802. inputData["operatorName"] = "admin"
  16803. inputData["officeId"] = "001"
  16804. inputData["officeName"] = "血透室"
  16805. inputData["deviceType"] = ""
  16806. input["data"] = inputData
  16807. input["orgId"] = code
  16808. input["transType"] = "ec.query"
  16809. bytesData, _ := json.Marshal(input)
  16810. 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])))
  16811. fmt.Println(ret2)
  16812. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16813. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16814. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  16815. }
  16816. func GetJxEleBaseInfo(org_id int64) string {
  16817. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16818. readCard := DllDef.MustFindProc("NationEcTrans")
  16819. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16820. if readCard == nil {
  16821. fmt.Println("readcard is nil")
  16822. readCard = DllDef.MustFindProc("NationEcTrans")
  16823. }
  16824. str1 := make([]byte, 1024)
  16825. data := make(map[string]interface{})
  16826. inputData := make(map[string]interface{})
  16827. inputData["orgId"] = miConfig.Code
  16828. inputData["businessType"] = "01101"
  16829. inputData["operatorId"] = "test001"
  16830. inputData["operatorName"] = "cn"
  16831. inputData["officeId"] = "32760"
  16832. inputData["officeName"] = "waike"
  16833. inputData["deviceType"] = ""
  16834. data["data"] = inputData
  16835. data["transType"] = "ec.query"
  16836. data["extra "] = ""
  16837. data["orgId"] = miConfig.Code
  16838. bytesData, _ := json.Marshal(data)
  16839. //bytesData, _ := json.Marshal(data)
  16840. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16841. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16842. fmt.Println(ret2)
  16843. fmt.Println(string(str1))
  16844. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16845. if ret2 != 0 {
  16846. return ""
  16847. }
  16848. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16849. }
  16850. //func GetJxEleBaseInfoTWO(org_id int64) string {
  16851. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  16852. // readCard := DllDef.MustFindProc("NationEcTrans")
  16853. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16854. //
  16855. // if readCard == nil {
  16856. // fmt.Println("readcard is nil")
  16857. // readCard = DllDef.MustFindProc("NationEcTrans")
  16858. // }
  16859. // str1 := make([]byte, 1024)
  16860. //
  16861. // data := make(map[string]interface{})
  16862. //
  16863. // inputData := make(map[string]interface{})
  16864. // inputData["orgId"] = miConfig.Code
  16865. // inputData["businessType"] = "01101"
  16866. // inputData["operatorId"] = "test001"
  16867. // inputData["operatorName"] = "cn"
  16868. // inputData["officeId"] = "32760"
  16869. // inputData["officeName"] = "waike"
  16870. // inputData["deviceType"] = ""
  16871. //
  16872. // data["data"] = inputData
  16873. // data["transType"] = "ec.query"
  16874. // data["extra "] = ""
  16875. // data["orgId"] = miConfig.Code
  16876. // bytesData, _ := json.Marshal(data)
  16877. // //bytesData, _ := json.Marshal(data)
  16878. //
  16879. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16880. //
  16881. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16882. // fmt.Println(ret2)
  16883. // fmt.Println(string(str1))
  16884. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16885. //
  16886. // if ret2 != 0 {
  16887. // return ""
  16888. // }
  16889. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16890. //}
  16891. func GetJxEleBaseInitInfo(org_id int64) string {
  16892. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16893. readCard := DllDef.MustFindProc("NationEcTrans")
  16894. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16895. if readCard == nil {
  16896. fmt.Println("readcard is nil")
  16897. readCard = DllDef.MustFindProc("NationEcTrans")
  16898. }
  16899. str1 := make([]byte, 2048)
  16900. data := make(map[string]interface{})
  16901. inputData := make(map[string]interface{})
  16902. inputData["orgId"] = miConfig.Code
  16903. inputData["businessType"] = "01101"
  16904. inputData["operatorId"] = "1"
  16905. inputData["operatorName"] = "huangchuang"
  16906. inputData["officeId"] = "101"
  16907. inputData["officeName"] = "xuetou"
  16908. inputData["deviceType"] = ""
  16909. data["data"] = inputData
  16910. data["transType"] = "ec.query"
  16911. data["orgId"] = miConfig.Code
  16912. bytesData, _ := json.Marshal(data)
  16913. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16914. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16915. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  16916. fmt.Println(ret2)
  16917. fmt.Println(string(str1))
  16918. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16919. if ret2 != 0 {
  16920. return ""
  16921. }
  16922. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  16923. initEleFlag = 1
  16924. }
  16925. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16926. }
  16927. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  16928. // // 构建命令
  16929. // cmd := exec.Command("python", "b.py")
  16930. //
  16931. // // 执行命令并等待完成
  16932. // output, err := cmd.CombinedOutput()
  16933. // if err != nil {
  16934. // fmt.Println("Error executing Python script:", err)
  16935. // return
  16936. // }
  16937. //
  16938. // // 打印Python脚本的输出
  16939. // fmt.Println(string(output))
  16940. //}
  16941. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  16942. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  16943. readCard := DllDef.MustFindProc("gxyb_call")
  16944. if readCard == nil {
  16945. fmt.Println("readcard is nil")
  16946. readCard = DllDef.MustFindProc("gxyb_call")
  16947. }
  16948. str := make([]byte, 1024)
  16949. str1 := make([]byte, 1024)
  16950. //data := make(map[string]interface{})
  16951. currentTime := time.Now()
  16952. // 格式化时间为 "YYYYMMDDHH24MISS"
  16953. formattedTime := currentTime.Format("20060102150405")
  16954. inputData := make(map[string]interface{})
  16955. inputData2 := make(map[string]interface{})
  16956. inputData["transNo"] = "1401"
  16957. inputData["transType"] = "passwordCheck"
  16958. inputData["timestamp"] = formattedTime
  16959. inputData2["fixmedinsCode"] = code
  16960. inputData2["psnNo"] = ""
  16961. inputData["data"] = inputData2
  16962. jsonBytes, err := json.Marshal(inputData)
  16963. if err != nil {
  16964. fmt.Println("Error encoding map to JSON:", err)
  16965. }
  16966. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16967. fmt.Println(string(str1))
  16968. fmt.Println(string(str))
  16969. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16970. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16971. if ret2 != 0 {
  16972. return ""
  16973. }
  16974. return string(str)
  16975. }
  16976. func (c *HisApiController) GetoleInfo() Response {
  16977. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  16978. defer ole.CoUninitialize()
  16979. // Replace with the ProgID or CLSID of your COM object
  16980. progID := "YinHai.XJ.Actual.Interface.New"
  16981. // Create COM object
  16982. unknown, err := oleutil.CreateObject(progID)
  16983. if err != nil {
  16984. fmt.Println("Unable to create COM object:", err)
  16985. }
  16986. defer unknown.Release()
  16987. // Query for the IDispatch interface
  16988. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  16989. if err != nil {
  16990. fmt.Println("Unable to get IDispatch interface:", err)
  16991. }
  16992. defer dispatch.Release()
  16993. // Prepare parameters
  16994. transNo := "1401"
  16995. transType := "passwordCheck"
  16996. timestamp := time.Now().Unix()
  16997. fixmedinsCode := "H45072101171"
  16998. psnNo := ""
  16999. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17000. result2 := ""
  17001. // Call COM object's method using the IDispatch interface
  17002. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17003. fmt.Println(resulr)
  17004. fmt.Println(result2)
  17005. if err != nil {
  17006. fmt.Println("调用COM对象方法失败:", err)
  17007. }
  17008. var response Response
  17009. err2 := json.Unmarshal([]byte(result2), &response)
  17010. if err2 != nil {
  17011. fmt.Println("解析JSON失败:", err)
  17012. }
  17013. return response
  17014. }
  17015. func (c *HisApiController) GetBasBaseInfo() string {
  17016. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17017. readCard := DllDef.MustFindProc("ReadCardBas")
  17018. if readCard == nil {
  17019. fmt.Println("readcard is nil")
  17020. readCard = DllDef.MustFindProc("ReadCardBas")
  17021. }
  17022. str := make([]byte, 1024)
  17023. str1 := make([]byte, 1024)
  17024. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17025. fmt.Println(string(str1))
  17026. fmt.Println(string(str))
  17027. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17028. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17029. if ret2 != 0 {
  17030. return ""
  17031. }
  17032. return string(str)
  17033. }
  17034. type Program struct {
  17035. FunctionID string `xml:"function_id"`
  17036. CardInfo string `xml:"cardinfo"`
  17037. User string `xml:"user"`
  17038. }
  17039. func (c *HisApiController) GetBasBaseInfo1111() string {
  17040. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17041. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17042. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17043. if readCard == nil {
  17044. fmt.Println("readcard is nil")
  17045. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17046. }
  17047. if readCard2 == nil {
  17048. fmt.Println("readcard is nil")
  17049. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17050. }
  17051. str := make([]byte, 1024)
  17052. str1 := make([]byte, 1024)
  17053. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17054. str3 := make([]byte, 1024)
  17055. str4 := make([]byte, 1024)
  17056. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17057. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17058. //if err != nil {
  17059. // fmt.Println("Error opening file:", err)
  17060. //}
  17061. //defer file.Close()
  17062. //
  17063. //var lastProgram Program
  17064. //scanner := bufio.NewScanner(file)
  17065. //inProgram := false
  17066. //
  17067. //for scanner.Scan() {
  17068. // line := scanner.Text()
  17069. // if strings.Contains(line, "<program>") {
  17070. // inProgram = true
  17071. // programXML := "<program>"
  17072. // for scanner.Scan() {
  17073. // line = scanner.Text()
  17074. // programXML += line
  17075. // if strings.Contains(line, "</program>") {
  17076. // programXML += "</program>"
  17077. // break
  17078. // }
  17079. // }
  17080. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17081. // // 解析成功,更新最后的 Program
  17082. // }
  17083. // inProgram = false
  17084. // }
  17085. //}
  17086. //
  17087. // fmt.Println("Error reading file:", inProgram)
  17088. //
  17089. //if err := scanner.Err(); err != nil {
  17090. // fmt.Println("Error reading file:", err)
  17091. //}
  17092. // 输出最后一次的 Program
  17093. //fmt.Printf("最后一次的 <program>:\n")
  17094. //fmt.Printf("<program>\n")
  17095. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17096. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17097. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17098. //fmt.Printf("</program>\n")
  17099. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17100. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17101. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17102. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17103. return ConvertToString(string(str), "gbk", "utf-8")
  17104. }
  17105. func (c *HisApiController) GetahBasBaseInfo() string {
  17106. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17107. readCard := DllDef.MustFindProc("iReadCardBas")
  17108. if readCard == nil {
  17109. fmt.Println("readcard is nil")
  17110. readCard = DllDef.MustFindProc("iReadCardBas")
  17111. }
  17112. //str := make([]byte, 1024)
  17113. str1 := make([]byte, 1024)
  17114. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17115. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17116. //if err != nil {
  17117. // fmt.Println("Error opening file:", err)
  17118. //}
  17119. //defer file.Close()
  17120. //
  17121. //var lastProgram Program
  17122. //scanner := bufio.NewScanner(file)
  17123. //inProgram := false
  17124. //
  17125. //for scanner.Scan() {
  17126. // line := scanner.Text()
  17127. // if strings.Contains(line, "<program>") {
  17128. // inProgram = true
  17129. // programXML := "<program>"
  17130. // for scanner.Scan() {
  17131. // line = scanner.Text()
  17132. // programXML += line
  17133. // if strings.Contains(line, "</program>") {
  17134. // programXML += "</program>"
  17135. // break
  17136. // }
  17137. // }
  17138. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17139. // // 解析成功,更新最后的 Program
  17140. // }
  17141. // inProgram = false
  17142. // }
  17143. //}
  17144. //
  17145. // fmt.Println("Error reading file:", inProgram)
  17146. //
  17147. //if err := scanner.Err(); err != nil {
  17148. // fmt.Println("Error reading file:", err)
  17149. //}
  17150. // 输出最后一次的 Program
  17151. //fmt.Printf("最后一次的 <program>:\n")
  17152. //fmt.Printf("<program>\n")
  17153. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17154. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17155. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17156. //fmt.Printf("</program>\n")
  17157. fmt.Println(string(str1))
  17158. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17159. if ret2 != 0 {
  17160. return ""
  17161. }
  17162. return string(str1)
  17163. }
  17164. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17165. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17166. readCard := DllDef.MustFindProc("read_cardinfo")
  17167. if readCard == nil {
  17168. fmt.Println("readcard is nil")
  17169. readCard = DllDef.MustFindProc("read_cardinfo")
  17170. }
  17171. str := make([]byte, 1024) //卡号
  17172. str1 := make([]byte, 1024) //卡识别码
  17173. str2 := make([]byte, 1024) //身份证号
  17174. str3 := make([]byte, 1024) //姓名
  17175. str4 := make([]byte, 1024) //错误信息
  17176. 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])))
  17177. fmt.Println(string(str1))
  17178. fmt.Println(string(str))
  17179. fmt.Println(string(str2))
  17180. fmt.Println(string(str3))
  17181. fmt.Println(string(str4))
  17182. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17183. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17184. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17185. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17186. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17187. if ret2 != 0 {
  17188. return "", "", "", "", ""
  17189. }
  17190. return string(str), string(str1), string(str2), string(str3), string(str4)
  17191. }
  17192. type CustomFundPay struct {
  17193. FundPayType string `json:"fund_pay_type"`
  17194. FundPayamt float64 `json:"fund_payamt"`
  17195. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17196. }
  17197. //func (c *HisApiController) GetBatchSettleList() {
  17198. // start_time_str := c.GetString("start_time")
  17199. // //end_time_str := c.GetString("end_time")
  17200. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17201. //
  17202. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17203. //
  17204. // for _, item := range orders {
  17205. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17206. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17207. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17208. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17209. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17210. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17211. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17212. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17213. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17214. //
  17215. // if order.ID == 0 {
  17216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17217. // return
  17218. // }
  17219. //
  17220. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17221. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17222. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17223. // //fmt.Println(count)
  17224. // //var zero string
  17225. // //number := count + 1
  17226. // //if number >= 1000 {
  17227. // // zero = "0000" + strconv.FormatInt(number, 10)
  17228. // //} else if number >= 10000 {
  17229. // // zero = "000" + strconv.FormatInt(number, 10)
  17230. // //} else if number >= 100000 {
  17231. // // zero = "00" + strconv.FormatInt(number, 10)
  17232. // //} else if number >= 1000000 {
  17233. // // zero = "0" + strconv.FormatInt(number, 10)
  17234. // //} else {
  17235. // // zero = strconv.FormatInt(number, 10)
  17236. // //}
  17237. // //fmt.Println(zero)
  17238. //
  17239. // struct4101 := service.Struct4101{
  17240. // PsnNo: order.PsnNo,
  17241. // MdtrtId: order.MdtrtId,
  17242. // SetlId: order.SetlId,
  17243. // PsnName: order.PsnName,
  17244. // Gend: order.Gend,
  17245. // Brdy: his.Brdy,
  17246. // Age: his.Age,
  17247. // Naty: order.Naty,
  17248. // PatnCertType: "01",
  17249. // Certno: order.Certno,
  17250. // Prfs: "90",
  17251. // ConerName: roles[0].UserName,
  17252. // PatnRlts: "99",
  17253. // ConerAddr: miConfig.OrgName,
  17254. // ConerTel: admin.Mobile,
  17255. // HiType: order.Insutype,
  17256. // Insuplc: miConfig.InsuplcAdmdvs,
  17257. // MaindiagFlag: "1",
  17258. // BillCode: order.SetlId,
  17259. // BillNo: order.SetlId,
  17260. // BizSn: order.Number,
  17261. // PsnSelfPay: order.PsnPartAmt,
  17262. // PsnOwnPay: order.PsnPartAmt,
  17263. // AcctPay: order.AcctPay,
  17264. // PsnCashpay: order.PsnCashPay,
  17265. // HiPaymtd: "1",
  17266. // Hsorg: miConfig.InsuplcAdmdvs,
  17267. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17268. // MedinsFillPsn: curRoles.UserName,
  17269. // MedinsFillDept: miConfig.OrgName,
  17270. // IptMedType: "2",
  17271. // }
  17272. // struct4101.SetlBegnDate = order.SetlTime
  17273. // struct4101.SetlEndDate = order.SetlTime
  17274. // time_arr := strings.Split(order.SetlTime, " ")
  17275. // struct4101.AdmTime = time_arr[0]
  17276. // struct4101.AdmEndTime = time_arr[0]
  17277. //
  17278. // var rf []CustomFundPay
  17279. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17280. //
  17281. // var tempFunPays []service.CustomStruct
  17282. // for _, item := range rf {
  17283. // var tempFunPay service.CustomStruct
  17284. // tempFunPay.FundPayamt = item.FundPayamt
  17285. // tempFunPay.FundPayType = item.FundPayType
  17286. // tempFunPays = append(tempFunPays, tempFunPay)
  17287. // }
  17288. // struct4101.CustomStruct = tempFunPays
  17289. //
  17290. // var tempDiaginfos []service.DiaginfoStructTwo
  17291. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17292. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17293. //
  17294. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17295. // var config []*models.HisXtDiagnoseConfig
  17296. // for _, item := range diagnosis_ids {
  17297. // id, _ := strconv.ParseInt(item, 10, 64)
  17298. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17299. // config = append(config, &diagnosisConfig)
  17300. // }
  17301. //
  17302. // for index, item := range config {
  17303. // if index == 0 {
  17304. // var tempDiaginfo service.DiaginfoStructTwo
  17305. // tempDiaginfo.DiagCode = item.CountryCode
  17306. // tempDiaginfo.DiagName = item.CountryContentName
  17307. // tempDiaginfo.DiagType = "1"
  17308. // tempDiaginfo.MaindiagFlag = "1"
  17309. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17310. // } else {
  17311. // var tempDiaginfo service.DiaginfoStructTwo
  17312. // tempDiaginfo.DiagCode = item.CountryCode
  17313. // tempDiaginfo.DiagName = item.CountryContentName
  17314. // tempDiaginfo.DiagType = "1"
  17315. // tempDiaginfo.MaindiagFlag = "0"
  17316. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17317. // }
  17318. // }
  17319. // struct4101.Diseinfo = tempDiaginfos
  17320. //
  17321. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17322. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17323. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17324. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17325. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17326. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17327. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17328. //
  17329. // var iteminfo service.IteminfoStruct
  17330. //
  17331. // var bedCostTotal float64 = 0 //床位总费
  17332. // var bedCostSelfTotal float64 = 0 //床位自费
  17333. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17334. //
  17335. // var operationCostTotal float64 = 0 //手术费
  17336. // var operationCostSelfTotal float64 = 0 //手术费
  17337. // var operationCostPartSelfTotal float64 = 0 //手术费
  17338. //
  17339. // var otherCostTotal float64 = 0 //其他费用
  17340. // var otherCostSelfTotal float64 = 0 //其他费用
  17341. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17342. //
  17343. // var materialCostTotal float64 = 0 //材料费
  17344. // var materialCostSelfTotal float64 = 0 //材料费
  17345. // var materialCostPartSelfTotal float64 = 0 //材料费
  17346. //
  17347. // var westernMedicineCostTotal float64 = 0 //西药费
  17348. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17349. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17350. //
  17351. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17352. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17353. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17354. //
  17355. // var checkCostTotal float64 = 0 //检查费
  17356. // var checkCostSelfTotal float64 = 0 //检查费
  17357. // var checkCostPartSelfTotal float64 = 0 //检查费
  17358. //
  17359. // var laboratoryCostTotal float64 = 0 //化验费
  17360. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17361. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17362. //
  17363. // var treatCostTotal float64 = 0 //治疗费用
  17364. // var treatCostSelfTotal float64 = 0 //治疗费用
  17365. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17366. //
  17367. // decimal.DivisionPrecision = 2
  17368. //
  17369. // var bed_fulamt_ownpay_amt float64 = 0
  17370. // var operation_fulamt_ownpay_amt float64 = 0
  17371. // var other_fulamt_ownpay_amt float64 = 0
  17372. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17373. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17374. // var check_fulamt_ownpay_amt float64 = 0
  17375. // var material_fulamt_ownpay_amt float64 = 0
  17376. // var laboratory_fulamt_ownpay_amt float64 = 0
  17377. // var treat_fulamt_ownpay_amt float64 = 0
  17378. //
  17379. // var bed_claa_sunmfee float64 = 0
  17380. // var bed_clab_amt float64 = 0
  17381. // var bed_other_amt float64 = 0
  17382. //
  17383. // var operation_claa_sunmfee float64 = 0
  17384. // var operation_clab_amt float64 = 0
  17385. // var operation_other_amt float64 = 0
  17386. //
  17387. // var other_claa_sunmfee float64 = 0
  17388. // var other_clab_amt float64 = 0
  17389. // var other_other_amt float64 = 0
  17390. //
  17391. // var westernMedicine_claa_sunmfee float64 = 0
  17392. // var westernMedicine_clab_amt float64 = 0
  17393. // var westernMedicine_other_amt float64 = 0
  17394. //
  17395. // var chineseTraditional_claa_sunmfee float64 = 0
  17396. // var chineseTraditional_clab_amt float64 = 0
  17397. // var chineseTraditional_other_amt float64 = 0
  17398. //
  17399. // var check_claa_sunmfee float64 = 0
  17400. // var check_clab_amt float64 = 0
  17401. // var check_other_amt float64 = 0
  17402. //
  17403. // var material_claa_sunmfee float64 = 0
  17404. // var material_clab_amt float64 = 0
  17405. // var material_other_amt float64 = 0
  17406. //
  17407. // var laboratory_claa_sunmfee float64 = 0
  17408. // var laboratory_clab_amt float64 = 0
  17409. // var laboratory_other_amt float64 = 0
  17410. //
  17411. // var treat_claa_sunmfee float64 = 0
  17412. // var treat_clab_amt float64 = 0
  17413. // var treat_other_amt float64 = 0
  17414. //
  17415. // for _, item := range order.HisOrderInfo {
  17416. // if item.MedChrgitmType == "01" { //床位费
  17417. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17418. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17419. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17420. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17421. // if item.ChrgitmLv == "1" {
  17422. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17423. // }
  17424. // if item.ChrgitmLv == "2" {
  17425. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17426. //
  17427. // }
  17428. // if item.ChrgitmLv == "3" {
  17429. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17430. // }
  17431. //
  17432. // }
  17433. //
  17434. // if item.MedChrgitmType == "03" { //检查费
  17435. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17436. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17437. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17438. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17439. // if item.ChrgitmLv == "1" {
  17440. //
  17441. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17442. //
  17443. // }
  17444. // if item.ChrgitmLv == "2" {
  17445. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17446. //
  17447. // }
  17448. // if item.ChrgitmLv == "3" {
  17449. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17450. // }
  17451. // }
  17452. //
  17453. // if item.MedChrgitmType == "04" { //化验费
  17454. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17455. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17456. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17457. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17458. // if item.ChrgitmLv == "1" {
  17459. //
  17460. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17461. //
  17462. // }
  17463. // if item.ChrgitmLv == "2" {
  17464. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17465. //
  17466. // }
  17467. // if item.ChrgitmLv == "3" {
  17468. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17469. // }
  17470. // }
  17471. //
  17472. // if item.MedChrgitmType == "05" { //治疗费
  17473. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17474. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17475. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17476. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17477. // if item.ChrgitmLv == "1" {
  17478. //
  17479. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17480. //
  17481. // }
  17482. // if item.ChrgitmLv == "2" {
  17483. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17484. //
  17485. // }
  17486. // if item.ChrgitmLv == "3" {
  17487. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17488. // }
  17489. // }
  17490. //
  17491. // if item.MedChrgitmType == "06" { //手术费
  17492. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17493. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17494. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17495. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17496. //
  17497. // if item.ChrgitmLv == "1" {
  17498. //
  17499. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17500. //
  17501. // }
  17502. // if item.ChrgitmLv == "2" {
  17503. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17504. //
  17505. // }
  17506. // if item.ChrgitmLv == "3" {
  17507. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17508. // }
  17509. // }
  17510. //
  17511. // if item.MedChrgitmType == "08" { //材料费
  17512. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17513. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17514. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17515. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17516. // if item.ChrgitmLv == "1" {
  17517. //
  17518. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17519. //
  17520. // }
  17521. // if item.ChrgitmLv == "2" {
  17522. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17523. //
  17524. // }
  17525. // if item.ChrgitmLv == "3" {
  17526. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17527. // }
  17528. // }
  17529. //
  17530. // if item.MedChrgitmType == "09" { //西药费
  17531. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17532. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17533. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17534. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17535. // if item.ChrgitmLv == "1" {
  17536. //
  17537. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17538. //
  17539. // }
  17540. // if item.ChrgitmLv == "2" {
  17541. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17542. //
  17543. // }
  17544. // if item.ChrgitmLv == "3" {
  17545. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17546. // }
  17547. // }
  17548. //
  17549. // if item.MedChrgitmType == "11" { //中成费
  17550. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17551. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17552. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17553. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17554. // if item.ChrgitmLv == "1" {
  17555. //
  17556. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17557. //
  17558. // }
  17559. // if item.ChrgitmLv == "2" {
  17560. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17561. //
  17562. // }
  17563. // if item.ChrgitmLv == "3" {
  17564. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17565. // }
  17566. // }
  17567. //
  17568. // if item.MedChrgitmType == "14" { //其他费
  17569. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17570. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17571. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17572. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17573. // if item.ChrgitmLv == "1" {
  17574. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17575. //
  17576. // }
  17577. // if item.ChrgitmLv == "2" {
  17578. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17579. //
  17580. // }
  17581. // if item.ChrgitmLv == "3" {
  17582. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17583. // }
  17584. // }
  17585. //
  17586. // }
  17587. //
  17588. // var iteminfoStructs []service.IteminfoStruct
  17589. //
  17590. // if bedCostTotal != 0 {
  17591. // iteminfo.MedChrgitm = "01"
  17592. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17593. // iteminfo.Amt = bedCostTotal
  17594. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  17595. // iteminfo.ClabAmt = bed_clab_amt
  17596. // iteminfo.OthAmt = bed_other_amt
  17597. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17598. // }
  17599. //
  17600. // if checkCostTotal != 0 {
  17601. // iteminfo.MedChrgitm = "03"
  17602. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17603. // iteminfo.Amt = checkCostTotal
  17604. // iteminfo.ClaaSumfee = check_claa_sunmfee
  17605. // iteminfo.ClabAmt = check_clab_amt
  17606. // iteminfo.OthAmt = check_other_amt
  17607. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17608. //
  17609. // }
  17610. //
  17611. // if laboratoryCostTotal != 0 {
  17612. // iteminfo.MedChrgitm = "04"
  17613. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17614. // iteminfo.Amt = laboratoryCostTotal
  17615. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17616. // iteminfo.ClabAmt = laboratory_clab_amt
  17617. // iteminfo.OthAmt = laboratory_other_amt
  17618. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17619. //
  17620. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17621. //
  17622. // }
  17623. //
  17624. // if treatCostTotal != 0 {
  17625. // iteminfo.MedChrgitm = "05"
  17626. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17627. // iteminfo.Amt = treatCostTotal
  17628. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  17629. // iteminfo.ClabAmt = treat_clab_amt
  17630. // iteminfo.OthAmt = treat_other_amt
  17631. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17632. // //(struct4101.IteminfoStruct, iteminfo)
  17633. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17634. // }
  17635. //
  17636. // if operationCostTotal != 0 {
  17637. // iteminfo.MedChrgitm = "06"
  17638. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17639. // iteminfo.Amt = operationCostTotal
  17640. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  17641. // iteminfo.ClabAmt = operation_clab_amt
  17642. // iteminfo.OthAmt = operation_other_amt
  17643. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17644. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17645. // }
  17646. //
  17647. // if materialCostTotal != 0 {
  17648. // iteminfo.MedChrgitm = "08"
  17649. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17650. // iteminfo.Amt = materialCostTotal
  17651. // iteminfo.ClaaSumfee = material_claa_sunmfee
  17652. // iteminfo.ClabAmt = material_clab_amt
  17653. // iteminfo.OthAmt = material_other_amt
  17654. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17655. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17656. // }
  17657. //
  17658. // if westernMedicineCostTotal != 0 {
  17659. // iteminfo.MedChrgitm = "09"
  17660. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17661. // iteminfo.Amt = westernMedicineCostTotal
  17662. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17663. // iteminfo.ClabAmt = westernMedicine_clab_amt
  17664. // iteminfo.OthAmt = westernMedicine_other_amt
  17665. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17666. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17667. //
  17668. // }
  17669. // if chineseTraditionalMedicineCostTotal != 0 {
  17670. // iteminfo.MedChrgitm = "11"
  17671. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17672. // iteminfo.Amt = westernMedicineCostTotal
  17673. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17674. // iteminfo.ClabAmt = westernMedicine_clab_amt
  17675. // iteminfo.OthAmt = westernMedicine_other_amt
  17676. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17677. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17678. //
  17679. // }
  17680. // if otherCostTotal != 0 {
  17681. // iteminfo.MedChrgitm = "14"
  17682. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17683. // iteminfo.Amt = otherCostTotal
  17684. // iteminfo.ClaaSumfee = other_claa_sunmfee
  17685. // iteminfo.ClabAmt = other_clab_amt
  17686. // iteminfo.OthAmt = other_other_amt
  17687. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17688. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17689. //
  17690. // }
  17691. // struct4101.IteminfoStruct = iteminfoStructs
  17692. // struct4101.Ntly = "中国"
  17693. // struct4101.AdmCaty = "A03.06"
  17694. //
  17695. // struct4101.DoctorName = doctor.UserName
  17696. // struct4101.DoctorCode = doctor.DoctorNumber
  17697. //
  17698. // var res ResultSeventeen
  17699. //
  17700. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17701. // struct4101.BillCode = order.Number
  17702. // struct4101.BillNo = order.SetlId
  17703. // var resOther ResultSeventeenOther
  17704. // var pp models.PublicParams
  17705. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17706. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17707. // pp.FixmedinsName = miConfig.OrgName
  17708. // pp.FixmedinsCode = miConfig.Code
  17709. // pp.RequestUrl = miConfig.Url
  17710. // pp.Cainfo = miConfig.Cainfo
  17711. // pp.SecretKey = miConfig.SecretKey
  17712. // pp.AccessKey = miConfig.AccessKey
  17713. // pp.OpterName = curRoles.UserName
  17714. //
  17715. // client := &http.Client{}
  17716. // var req *http.Request
  17717. // data := make(map[string]interface{})
  17718. // data["struct4101"] = struct4101
  17719. // data["pp"] = pp
  17720. // bytesData, _ := json.Marshal(data)
  17721. // if miConfig.MdtrtareaAdmvs == "320921" {
  17722. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17723. // } else {
  17724. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17725. // }
  17726. // resp, _ := client.Do(req)
  17727. // defer resp.Body.Close()
  17728. // body, ioErr := ioutil.ReadAll(resp.Body)
  17729. // if ioErr != nil {
  17730. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17732. // return
  17733. // }
  17734. // var respJSON map[string]interface{}
  17735. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17736. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17737. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17738. // return
  17739. // }
  17740. //
  17741. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17742. // userJSONBytes, _ := json.Marshal(respJSON)
  17743. // fmt.Println("log")
  17744. // fmt.Println(string(userJSONBytes))
  17745. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17746. // utils.ErrorLog("解析失败:%v", err)
  17747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17748. // return
  17749. // }
  17750. // res.InfRefmsgid = resOther.InfRefmsgid
  17751. // res.Output = resOther.Output
  17752. // res.ErrMsg = resOther.ErrMsg
  17753. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17754. // res.Infcode = infocode
  17755. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  17756. //
  17757. // var pp models.PublicParams
  17758. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17759. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17760. // pp.FixmedinsName = miConfig.OrgName
  17761. // pp.FixmedinsCode = miConfig.Code
  17762. // pp.RequestUrl = miConfig.Url
  17763. // pp.Cainfo = miConfig.Cainfo
  17764. // pp.SecretKey = miConfig.SecretKey
  17765. // pp.AccessKey = miConfig.AccessKey
  17766. // pp.OpterName = curRoles.UserName
  17767. // result, _ := service.Jxyb4101(struct4101, pp)
  17768. // var dat map[string]interface{}
  17769. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17770. // fmt.Println(dat)
  17771. // } else {
  17772. // fmt.Println(err)
  17773. // }
  17774. // userJSONBytes, _ := json.Marshal(dat)
  17775. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17776. // utils.ErrorLog("解析失败:%v", err)
  17777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17778. // return
  17779. // }
  17780. //
  17781. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  17782. // var pp models.PublicParams
  17783. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17784. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17785. // pp.FixmedinsName = miConfig.OrgName
  17786. // pp.FixmedinsCode = miConfig.Code
  17787. // pp.RequestUrl = miConfig.Url
  17788. // pp.Cainfo = miConfig.Cainfo
  17789. // pp.SecretKey = miConfig.SecretKey
  17790. // pp.AccessKey = miConfig.AccessKey
  17791. // pp.OpterName = curRoles.UserName
  17792. // result, _ := service.Hnyb4101(struct4101, pp)
  17793. // var dat map[string]interface{}
  17794. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17795. // fmt.Println(dat)
  17796. // } else {
  17797. // fmt.Println(err)
  17798. // }
  17799. // userJSONBytes, _ := json.Marshal(dat)
  17800. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17801. // utils.ErrorLog("解析失败:%v", err)
  17802. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17803. // return
  17804. // }
  17805. //
  17806. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  17807. // var resOther ResultSeventeenOther
  17808. //
  17809. // var pp models.PublicParams
  17810. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17811. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17812. // pp.FixmedinsName = miConfig.OrgName
  17813. // pp.FixmedinsCode = miConfig.Code
  17814. // pp.RequestUrl = miConfig.Url
  17815. // pp.Cainfo = miConfig.Cainfo
  17816. // pp.SecretKey = miConfig.SecretKey
  17817. // pp.AccessKey = miConfig.AccessKey
  17818. // pp.OpterName = curRoles.UserName
  17819. // client := &http.Client{}
  17820. // var req *http.Request
  17821. // data := make(map[string]interface{})
  17822. // data["struct4101"] = struct4101
  17823. // data["pp"] = pp
  17824. // bytesData, _ := json.Marshal(data)
  17825. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17826. // resp, _ := client.Do(req)
  17827. // defer resp.Body.Close()
  17828. // body, ioErr := ioutil.ReadAll(resp.Body)
  17829. // if ioErr != nil {
  17830. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17832. // return
  17833. // }
  17834. // var respJSON map[string]interface{}
  17835. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17836. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17838. // return
  17839. // }
  17840. //
  17841. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17842. // userJSONBytes, _ := json.Marshal(respJSON)
  17843. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17844. // utils.ErrorLog("解析失败:%v", err)
  17845. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17846. // return
  17847. // }
  17848. // res.InfRefmsgid = resOther.InfRefmsgid
  17849. // res.Output = resOther.Output
  17850. // res.ErrMsg = resOther.ErrMsg
  17851. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17852. // res.Infcode = infocode
  17853. //
  17854. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  17855. // var pp models.PublicParams
  17856. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17857. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17858. // pp.FixmedinsName = miConfig.OrgName
  17859. // pp.FixmedinsCode = miConfig.Code
  17860. // pp.RequestUrl = miConfig.Url
  17861. // pp.Cainfo = miConfig.Cainfo
  17862. // pp.SecretKey = miConfig.SecretKey
  17863. // pp.AccessKey = miConfig.AccessKey
  17864. // pp.OpterName = curRoles.UserName
  17865. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  17866. // fmt.Println(requestLog)
  17867. // fmt.Println(errMsgLog)
  17868. //
  17869. // saveLog(result, requestLog, "4101a", "上传清单")
  17870. //
  17871. // var dat map[string]interface{}
  17872. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17873. // fmt.Println(dat)
  17874. // } else {
  17875. // fmt.Println(err)
  17876. // }
  17877. // userJSONBytes, _ := json.Marshal(dat)
  17878. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17879. // utils.ErrorLog("解析失败:%v", err)
  17880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17881. // return
  17882. // }
  17883. //
  17884. // } else {
  17885. //
  17886. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  17887. // var dat map[string]interface{}
  17888. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17889. // fmt.Println(dat)
  17890. // } else {
  17891. // fmt.Println(err)
  17892. // }
  17893. // userJSONBytes, _ := json.Marshal(dat)
  17894. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17895. // utils.ErrorLog("解析失败:%v", err)
  17896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17897. // return
  17898. // }
  17899. // }
  17900. //
  17901. // if res.Infcode != 0 {
  17902. // adminUser := c.GetAdminUserInfo()
  17903. // errlog := &models.HisOrderError{
  17904. // UserOrgId: adminUser.CurrentOrgId,
  17905. // Ctime: time.Now().Unix(),
  17906. // Mtime: time.Now().Unix(),
  17907. // ErrMsg: res.ErrMsg,
  17908. // Status: 1,
  17909. // PatientId: order.ID,
  17910. // Stage: 10265,
  17911. // }
  17912. // service.CreateErrMsgLog(errlog)
  17913. // continue
  17914. // } else {
  17915. // //order.FaPiaoNumber = zero
  17916. // //order.FaPiaoCode = last_order.FaPiaoCode
  17917. // //service.UpdateOrder(order)
  17918. // hisFundSettleListResult := &models.HisFundSettleListResult{
  17919. // Number: res.Output.SetlListId,
  17920. // Status: 1,
  17921. // Ctime: time.Now().Unix(),
  17922. // Mtime: time.Now().Unix(),
  17923. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17924. // IsUpload: 1,
  17925. // OrderId: order.ID,
  17926. // }
  17927. // service.CreateUploadRecord(hisFundSettleListResult)
  17928. // c.ServeSuccessJSON(map[string]interface{}{
  17929. // "msg": "上传成功",
  17930. // "result": hisFundSettleListResult,
  17931. // })
  17932. // continue
  17933. // }
  17934. // }
  17935. //}
  17936. func (c *HisApiController) GetbatchSettleList() {
  17937. //order_id, _ := c.GetInt64("order_id")
  17938. admin_user_id, _ := c.GetInt64("admin_user_id")
  17939. orders, _ := service.GetAllHisOrderTwo10485()
  17940. for _, item := range orders {
  17941. order, _ := service.GetHisOrderByIDTwo(item.ID)
  17942. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17943. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17944. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17945. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17946. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17947. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17948. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17949. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17950. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17951. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17952. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17953. //fmt.Println(count)
  17954. //var zero string
  17955. //number := count + 1
  17956. //if number >= 1000 {
  17957. // zero = "0000" + strconv.FormatInt(number, 10)
  17958. //} else if number >= 10000 {
  17959. // zero = "000" + strconv.FormatInt(number, 10)
  17960. //} else if number >= 100000 {
  17961. // zero = "00" + strconv.FormatInt(number, 10)
  17962. //} else if number >= 1000000 {
  17963. // zero = "0" + strconv.FormatInt(number, 10)
  17964. //} else {
  17965. // zero = strconv.FormatInt(number, 10)
  17966. //}
  17967. //fmt.Println(zero)
  17968. struct4101 := service.Struct4101{
  17969. PsnNo: order.PsnNo,
  17970. MdtrtId: order.MdtrtId,
  17971. SetlId: order.SetlId,
  17972. PsnName: order.PsnName,
  17973. Gend: order.Gend,
  17974. Brdy: his.Brdy,
  17975. Age: his.Age,
  17976. Naty: order.Naty,
  17977. PatnCertType: "01",
  17978. Certno: order.Certno,
  17979. Prfs: "90",
  17980. ConerName: roles[0].UserName,
  17981. PatnRlts: "99",
  17982. ConerAddr: miConfig.OrgName,
  17983. ConerTel: admin.Mobile,
  17984. HiType: order.Insutype,
  17985. Insuplc: miConfig.InsuplcAdmdvs,
  17986. MaindiagFlag: "1",
  17987. BillCode: order.SetlId,
  17988. BillNo: order.SetlId,
  17989. BizSn: order.Number,
  17990. PsnSelfPay: order.PsnPartAmt,
  17991. PsnOwnPay: order.PsnPartAmt,
  17992. AcctPay: order.AcctPay,
  17993. PsnCashpay: order.PsnCashPay,
  17994. HiPaymtd: "1",
  17995. Hsorg: miConfig.InsuplcAdmdvs,
  17996. HsorgOpter: miConfig.InsuplcAdmdvs,
  17997. MedinsFillPsn: curRoles.UserName,
  17998. MedinsFillDept: miConfig.OrgName,
  17999. IptMedType: "2",
  18000. }
  18001. struct4101.SetlBegnDate = order.SetlTime
  18002. struct4101.SetlEndDate = order.SetlTime
  18003. time_arr := strings.Split(order.SetlTime, " ")
  18004. struct4101.AdmTime = time_arr[0]
  18005. struct4101.AdmEndTime = time_arr[0]
  18006. //var rf []CustomFundPay
  18007. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18008. //
  18009. //var tempFunPays []service.CustomStruct
  18010. //for _, item := range rf {
  18011. // var tempFunPay service.CustomStruct
  18012. // tempFunPay.FundPayamt = item.FundPayamt
  18013. // tempFunPay.FundPayType = item.FundPayType
  18014. // tempFunPays = append(tempFunPays, tempFunPay)
  18015. //}
  18016. //struct4101.CustomStruct = tempFunPays
  18017. var tempDiaginfos []service.DiaginfoStructTwo
  18018. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18019. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18020. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18021. var config []*models.HisXtDiagnoseConfig
  18022. for _, item := range diagnosis_ids {
  18023. id, _ := strconv.ParseInt(item, 10, 64)
  18024. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18025. config = append(config, &diagnosisConfig)
  18026. }
  18027. for index, item := range config {
  18028. if index == 0 {
  18029. var tempDiaginfo service.DiaginfoStructTwo
  18030. tempDiaginfo.DiagCode = item.CountryCode
  18031. tempDiaginfo.DiagName = item.CountryContentName
  18032. tempDiaginfo.DiagType = "1"
  18033. tempDiaginfo.MaindiagFlag = "1"
  18034. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18035. } else {
  18036. var tempDiaginfo service.DiaginfoStructTwo
  18037. tempDiaginfo.DiagCode = item.CountryCode
  18038. tempDiaginfo.DiagName = item.CountryContentName
  18039. tempDiaginfo.DiagType = "1"
  18040. tempDiaginfo.MaindiagFlag = "0"
  18041. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18042. }
  18043. }
  18044. struct4101.Diseinfo = tempDiaginfos
  18045. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18046. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18047. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18048. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18049. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18050. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18051. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18052. var iteminfo service.IteminfoStruct
  18053. var bedCostTotal float64 = 0 //床位总费
  18054. var bedCostSelfTotal float64 = 0 //床位自费
  18055. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18056. var operationCostTotal float64 = 0 //手术费
  18057. var operationCostSelfTotal float64 = 0 //手术费
  18058. var operationCostPartSelfTotal float64 = 0 //手术费
  18059. var otherCostTotal float64 = 0 //其他费用
  18060. var otherCostSelfTotal float64 = 0 //其他费用
  18061. var otherCostPartSelfTotal float64 = 0 //其他费用
  18062. var materialCostTotal float64 = 0 //材料费
  18063. var materialCostSelfTotal float64 = 0 //材料费
  18064. var materialCostPartSelfTotal float64 = 0 //材料费
  18065. var westernMedicineCostTotal float64 = 0 //西药费
  18066. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18067. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18068. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18069. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18070. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18071. var checkCostTotal float64 = 0 //检查费
  18072. var checkCostSelfTotal float64 = 0 //检查费
  18073. var checkCostPartSelfTotal float64 = 0 //检查费
  18074. var laboratoryCostTotal float64 = 0 //化验费
  18075. var laboratoryCostSelfTotal float64 = 0 //化验费
  18076. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18077. var treatCostTotal float64 = 0 //治疗费用
  18078. var treatCostSelfTotal float64 = 0 //治疗费用
  18079. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18080. decimal.DivisionPrecision = 2
  18081. var bed_fulamt_ownpay_amt float64 = 0
  18082. var operation_fulamt_ownpay_amt float64 = 0
  18083. var other_fulamt_ownpay_amt float64 = 0
  18084. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18085. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18086. var check_fulamt_ownpay_amt float64 = 0
  18087. var material_fulamt_ownpay_amt float64 = 0
  18088. var laboratory_fulamt_ownpay_amt float64 = 0
  18089. var treat_fulamt_ownpay_amt float64 = 0
  18090. var bed_claa_sunmfee float64 = 0
  18091. var bed_clab_amt float64 = 0
  18092. var bed_other_amt float64 = 0
  18093. var operation_claa_sunmfee float64 = 0
  18094. var operation_clab_amt float64 = 0
  18095. var operation_other_amt float64 = 0
  18096. var other_claa_sunmfee float64 = 0
  18097. var other_clab_amt float64 = 0
  18098. var other_other_amt float64 = 0
  18099. var westernMedicine_claa_sunmfee float64 = 0
  18100. var westernMedicine_clab_amt float64 = 0
  18101. var westernMedicine_other_amt float64 = 0
  18102. var chineseTraditional_claa_sunmfee float64 = 0
  18103. var chineseTraditional_clab_amt float64 = 0
  18104. var chineseTraditional_other_amt float64 = 0
  18105. var check_claa_sunmfee float64 = 0
  18106. var check_clab_amt float64 = 0
  18107. var check_other_amt float64 = 0
  18108. var material_claa_sunmfee float64 = 0
  18109. var material_clab_amt float64 = 0
  18110. var material_other_amt float64 = 0
  18111. var laboratory_claa_sunmfee float64 = 0
  18112. var laboratory_clab_amt float64 = 0
  18113. var laboratory_other_amt float64 = 0
  18114. var treat_claa_sunmfee float64 = 0
  18115. var treat_clab_amt float64 = 0
  18116. var treat_other_amt float64 = 0
  18117. for _, item := range order.HisOrderInfo {
  18118. if item.MedChrgitmType == "01" { //床位费
  18119. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18120. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18121. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18122. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18123. if item.ChrgitmLv == "1" {
  18124. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18125. }
  18126. if item.ChrgitmLv == "2" {
  18127. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18128. }
  18129. if item.ChrgitmLv == "3" {
  18130. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18131. }
  18132. }
  18133. if item.MedChrgitmType == "03" { //检查费
  18134. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18135. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18136. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18137. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18138. if item.ChrgitmLv == "1" {
  18139. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18140. }
  18141. if item.ChrgitmLv == "2" {
  18142. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18143. }
  18144. if item.ChrgitmLv == "3" {
  18145. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18146. }
  18147. }
  18148. if item.MedChrgitmType == "04" { //化验费
  18149. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18150. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18151. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18152. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18153. if item.ChrgitmLv == "1" {
  18154. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18155. }
  18156. if item.ChrgitmLv == "2" {
  18157. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18158. }
  18159. if item.ChrgitmLv == "3" {
  18160. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18161. }
  18162. }
  18163. if item.MedChrgitmType == "05" { //治疗费
  18164. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18165. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18166. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18167. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18168. if item.ChrgitmLv == "1" {
  18169. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18170. }
  18171. if item.ChrgitmLv == "2" {
  18172. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18173. }
  18174. if item.ChrgitmLv == "3" {
  18175. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18176. }
  18177. }
  18178. if item.MedChrgitmType == "06" { //手术费
  18179. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18180. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18181. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18182. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18183. if item.ChrgitmLv == "1" {
  18184. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18185. }
  18186. if item.ChrgitmLv == "2" {
  18187. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18188. }
  18189. if item.ChrgitmLv == "3" {
  18190. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18191. }
  18192. }
  18193. if item.MedChrgitmType == "08" { //材料费
  18194. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18195. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18196. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18197. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18198. if item.ChrgitmLv == "1" {
  18199. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18200. }
  18201. if item.ChrgitmLv == "2" {
  18202. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18203. }
  18204. if item.ChrgitmLv == "3" {
  18205. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18206. }
  18207. }
  18208. if item.MedChrgitmType == "09" { //西药费
  18209. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18210. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18211. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18212. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18213. if item.ChrgitmLv == "1" {
  18214. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18215. }
  18216. if item.ChrgitmLv == "2" {
  18217. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18218. }
  18219. if item.ChrgitmLv == "3" {
  18220. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18221. }
  18222. }
  18223. if item.MedChrgitmType == "11" { //中成费
  18224. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18225. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18226. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18227. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18228. if item.ChrgitmLv == "1" {
  18229. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18230. }
  18231. if item.ChrgitmLv == "2" {
  18232. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18233. }
  18234. if item.ChrgitmLv == "3" {
  18235. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18236. }
  18237. }
  18238. if item.MedChrgitmType == "14" { //其他费
  18239. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18240. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18241. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18242. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18243. if item.ChrgitmLv == "1" {
  18244. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18245. }
  18246. if item.ChrgitmLv == "2" {
  18247. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18248. }
  18249. if item.ChrgitmLv == "3" {
  18250. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18251. }
  18252. }
  18253. }
  18254. var iteminfoStructs []service.IteminfoStruct
  18255. if bedCostTotal != 0 {
  18256. iteminfo.MedChrgitm = "01"
  18257. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18258. iteminfo.Amt = bedCostTotal
  18259. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18260. iteminfo.ClabAmt = bed_clab_amt
  18261. iteminfo.OthAmt = bed_other_amt
  18262. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18263. }
  18264. if checkCostTotal != 0 {
  18265. iteminfo.MedChrgitm = "03"
  18266. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18267. iteminfo.Amt = checkCostTotal
  18268. iteminfo.ClaaSumfee = check_claa_sunmfee
  18269. iteminfo.ClabAmt = check_clab_amt
  18270. iteminfo.OthAmt = check_other_amt
  18271. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18272. }
  18273. if laboratoryCostTotal != 0 {
  18274. iteminfo.MedChrgitm = "04"
  18275. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18276. iteminfo.Amt = laboratoryCostTotal
  18277. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18278. iteminfo.ClabAmt = laboratory_clab_amt
  18279. iteminfo.OthAmt = laboratory_other_amt
  18280. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18281. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18282. }
  18283. if treatCostTotal != 0 {
  18284. iteminfo.MedChrgitm = "05"
  18285. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18286. iteminfo.Amt = treatCostTotal
  18287. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18288. iteminfo.ClabAmt = treat_clab_amt
  18289. iteminfo.OthAmt = treat_other_amt
  18290. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18291. //(struct4101.IteminfoStruct, iteminfo)
  18292. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18293. }
  18294. if operationCostTotal != 0 {
  18295. iteminfo.MedChrgitm = "06"
  18296. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18297. iteminfo.Amt = operationCostTotal
  18298. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18299. iteminfo.ClabAmt = operation_clab_amt
  18300. iteminfo.OthAmt = operation_other_amt
  18301. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18302. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18303. }
  18304. if materialCostTotal != 0 {
  18305. iteminfo.MedChrgitm = "08"
  18306. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18307. iteminfo.Amt = materialCostTotal
  18308. iteminfo.ClaaSumfee = material_claa_sunmfee
  18309. iteminfo.ClabAmt = material_clab_amt
  18310. iteminfo.OthAmt = material_other_amt
  18311. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18312. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18313. }
  18314. if westernMedicineCostTotal != 0 {
  18315. iteminfo.MedChrgitm = "09"
  18316. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18317. iteminfo.Amt = westernMedicineCostTotal
  18318. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18319. iteminfo.ClabAmt = westernMedicine_clab_amt
  18320. iteminfo.OthAmt = westernMedicine_other_amt
  18321. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18322. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18323. }
  18324. if chineseTraditionalMedicineCostTotal != 0 {
  18325. iteminfo.MedChrgitm = "11"
  18326. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18327. iteminfo.Amt = westernMedicineCostTotal
  18328. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18329. iteminfo.ClabAmt = westernMedicine_clab_amt
  18330. iteminfo.OthAmt = westernMedicine_other_amt
  18331. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18332. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18333. }
  18334. if otherCostTotal != 0 {
  18335. iteminfo.MedChrgitm = "14"
  18336. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18337. iteminfo.Amt = otherCostTotal
  18338. iteminfo.ClaaSumfee = other_claa_sunmfee
  18339. iteminfo.ClabAmt = other_clab_amt
  18340. iteminfo.OthAmt = other_other_amt
  18341. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18342. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18343. }
  18344. struct4101.IteminfoStruct = iteminfoStructs
  18345. struct4101.Ntly = "中国"
  18346. struct4101.AdmCaty = "A03.06"
  18347. struct4101.DoctorName = doctor.UserName
  18348. struct4101.DoctorCode = doctor.DoctorNumber
  18349. var res ResultSeventeen
  18350. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18351. struct4101.BillCode = order.Number
  18352. struct4101.BillNo = order.SetlId
  18353. var resOther ResultSeventeenOther
  18354. var pp models.PublicParams
  18355. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18356. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18357. pp.FixmedinsName = miConfig.OrgName
  18358. pp.FixmedinsCode = miConfig.Code
  18359. pp.RequestUrl = miConfig.Url
  18360. pp.Cainfo = miConfig.Cainfo
  18361. pp.SecretKey = miConfig.SecretKey
  18362. pp.AccessKey = miConfig.AccessKey
  18363. pp.OpterName = curRoles.UserName
  18364. client := &http.Client{}
  18365. var req *http.Request
  18366. data := make(map[string]interface{})
  18367. data["struct4101"] = struct4101
  18368. data["pp"] = pp
  18369. bytesData, _ := json.Marshal(data)
  18370. if miConfig.MdtrtareaAdmvs == "320921" {
  18371. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18372. } else {
  18373. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18374. }
  18375. resp, _ := client.Do(req)
  18376. defer resp.Body.Close()
  18377. body, ioErr := ioutil.ReadAll(resp.Body)
  18378. if ioErr != nil {
  18379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18381. return
  18382. }
  18383. var respJSON map[string]interface{}
  18384. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18387. return
  18388. }
  18389. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18390. userJSONBytes, _ := json.Marshal(respJSON)
  18391. fmt.Println("log")
  18392. fmt.Println(string(userJSONBytes))
  18393. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18394. utils.ErrorLog("解析失败:%v", err)
  18395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18396. return
  18397. }
  18398. res.InfRefmsgid = resOther.InfRefmsgid
  18399. res.Output = resOther.Output
  18400. res.ErrMsg = resOther.ErrMsg
  18401. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18402. res.Infcode = infocode
  18403. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18404. var pp models.PublicParams
  18405. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18406. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18407. pp.FixmedinsName = miConfig.OrgName
  18408. pp.FixmedinsCode = miConfig.Code
  18409. pp.RequestUrl = miConfig.Url
  18410. pp.Cainfo = miConfig.Cainfo
  18411. pp.SecretKey = miConfig.SecretKey
  18412. pp.AccessKey = miConfig.AccessKey
  18413. pp.OpterName = curRoles.UserName
  18414. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18415. result, _ := service.Jxyb4101(struct4101, pp)
  18416. var dat map[string]interface{}
  18417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18418. fmt.Println(dat)
  18419. } else {
  18420. fmt.Println(err)
  18421. }
  18422. userJSONBytes, _ := json.Marshal(dat)
  18423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18424. utils.ErrorLog("解析失败:%v", err)
  18425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18426. return
  18427. }
  18428. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18429. var pp models.PublicParams
  18430. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18431. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18432. pp.FixmedinsName = miConfig.OrgName
  18433. pp.FixmedinsCode = miConfig.Code
  18434. pp.RequestUrl = miConfig.Url
  18435. pp.Cainfo = miConfig.Cainfo
  18436. pp.SecretKey = miConfig.SecretKey
  18437. pp.AccessKey = miConfig.AccessKey
  18438. pp.OpterName = curRoles.UserName
  18439. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18440. result, _ := service.Jxyb4101(struct4101, pp)
  18441. var dat map[string]interface{}
  18442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18443. fmt.Println(dat)
  18444. } else {
  18445. fmt.Println(err)
  18446. }
  18447. userJSONBytes, _ := json.Marshal(dat)
  18448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18449. utils.ErrorLog("解析失败:%v", err)
  18450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18451. return
  18452. }
  18453. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18454. var pp models.PublicParams
  18455. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18456. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18457. pp.FixmedinsName = miConfig.OrgName
  18458. pp.FixmedinsCode = miConfig.Code
  18459. pp.RequestUrl = miConfig.Url
  18460. pp.Cainfo = miConfig.Cainfo
  18461. pp.SecretKey = miConfig.SecretKey
  18462. pp.AccessKey = miConfig.AccessKey
  18463. pp.OpterName = curRoles.UserName
  18464. result, _ := service.Hnyb4101(struct4101, pp)
  18465. var dat map[string]interface{}
  18466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18467. fmt.Println(dat)
  18468. } else {
  18469. fmt.Println(err)
  18470. }
  18471. userJSONBytes, _ := json.Marshal(dat)
  18472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18473. utils.ErrorLog("解析失败:%v", err)
  18474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18475. return
  18476. }
  18477. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18478. var resOther ResultSeventeenOther
  18479. var pp models.PublicParams
  18480. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18481. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18482. pp.FixmedinsName = miConfig.OrgName
  18483. pp.FixmedinsCode = miConfig.Code
  18484. pp.RequestUrl = miConfig.Url
  18485. pp.Cainfo = miConfig.Cainfo
  18486. pp.SecretKey = miConfig.SecretKey
  18487. pp.AccessKey = miConfig.AccessKey
  18488. pp.OpterName = curRoles.UserName
  18489. client := &http.Client{}
  18490. var req *http.Request
  18491. data := make(map[string]interface{})
  18492. data["struct4101"] = struct4101
  18493. data["pp"] = pp
  18494. bytesData, _ := json.Marshal(data)
  18495. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18496. resp, _ := client.Do(req)
  18497. defer resp.Body.Close()
  18498. body, ioErr := ioutil.ReadAll(resp.Body)
  18499. if ioErr != nil {
  18500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18502. return
  18503. }
  18504. var respJSON map[string]interface{}
  18505. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18508. return
  18509. }
  18510. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18511. userJSONBytes, _ := json.Marshal(respJSON)
  18512. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18513. utils.ErrorLog("解析失败:%v", err)
  18514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18515. return
  18516. }
  18517. res.InfRefmsgid = resOther.InfRefmsgid
  18518. res.Output = resOther.Output
  18519. res.ErrMsg = resOther.ErrMsg
  18520. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18521. res.Infcode = infocode
  18522. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18523. var pp models.PublicParams
  18524. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18525. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18526. pp.FixmedinsName = miConfig.OrgName
  18527. pp.FixmedinsCode = miConfig.Code
  18528. pp.RequestUrl = miConfig.Url
  18529. pp.Cainfo = miConfig.Cainfo
  18530. pp.SecretKey = miConfig.SecretKey
  18531. pp.AccessKey = miConfig.AccessKey
  18532. pp.OpterName = curRoles.UserName
  18533. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18534. fmt.Println(requestLog)
  18535. fmt.Println(errMsgLog)
  18536. saveLog(result, requestLog, "4101a", "上传清单")
  18537. var dat map[string]interface{}
  18538. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18539. fmt.Println(dat)
  18540. } else {
  18541. fmt.Println(err)
  18542. }
  18543. userJSONBytes, _ := json.Marshal(dat)
  18544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18545. utils.ErrorLog("解析失败:%v", err)
  18546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18547. return
  18548. }
  18549. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18550. var pp models.PublicParams
  18551. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18552. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18553. pp.FixmedinsName = miConfig.OrgName
  18554. pp.FixmedinsCode = miConfig.Code
  18555. pp.RequestUrl = miConfig.Url
  18556. pp.Cainfo = miConfig.Cainfo
  18557. pp.SecretKey = miConfig.SecretKey
  18558. pp.AccessKey = miConfig.AccessKey
  18559. pp.OpterName = curRoles.UserName
  18560. client := &http.Client{}
  18561. var req *http.Request
  18562. data := make(map[string]interface{})
  18563. data["struct4101"] = struct4101
  18564. data["pp"] = pp
  18565. bytesData, _ := json.Marshal(data)
  18566. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18567. resp, _ := client.Do(req)
  18568. defer resp.Body.Close()
  18569. body, ioErr := ioutil.ReadAll(resp.Body)
  18570. if ioErr != nil {
  18571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18573. return
  18574. }
  18575. var respJSON map[string]interface{}
  18576. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18579. return
  18580. }
  18581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18582. userJSONBytes, _ := json.Marshal(respJSON)
  18583. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18584. utils.ErrorLog("解析失败:%v", err)
  18585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18586. return
  18587. }
  18588. } else {
  18589. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18590. var dat map[string]interface{}
  18591. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18592. fmt.Println(dat)
  18593. } else {
  18594. fmt.Println(err)
  18595. }
  18596. userJSONBytes, _ := json.Marshal(dat)
  18597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18598. utils.ErrorLog("解析失败:%v", err)
  18599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18600. return
  18601. }
  18602. }
  18603. if res.Infcode != 0 {
  18604. errlog := &models.HisOrderError{
  18605. UserOrgId: order.UserOrgId,
  18606. Ctime: time.Now().Unix(),
  18607. Mtime: time.Now().Unix(),
  18608. ErrMsg: res.ErrMsg + "解析失败",
  18609. Status: 1,
  18610. PatientId: order.ID,
  18611. Stage: 10485,
  18612. }
  18613. service.CreateErrMsgLog(errlog)
  18614. continue
  18615. //c.ServeSuccessJSON(map[string]interface{}{
  18616. // "failed_code": -10,
  18617. // "msg": res.ErrMsg,
  18618. //})
  18619. } else {
  18620. //order.FaPiaoNumber = zero
  18621. //order.FaPiaoCode = last_order.FaPiaoCode
  18622. //service.UpdateOrder(order)
  18623. hisFundSettleListResult := &models.HisFundSettleListResult{
  18624. Number: res.Output.SetlListId,
  18625. Status: 1,
  18626. Ctime: time.Now().Unix(),
  18627. Mtime: time.Now().Unix(),
  18628. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18629. IsUpload: 1,
  18630. OrderId: order.ID,
  18631. }
  18632. service.CreateUploadRecord(hisFundSettleListResult)
  18633. continue
  18634. }
  18635. }
  18636. }
  18637. func (c *HisApiController) GetSettleList() {
  18638. order_id, _ := c.GetInt64("order_id")
  18639. admin_user_id, _ := c.GetInt64("admin_user_id")
  18640. order, _ := service.GetHisOrderByIDTwo(order_id)
  18641. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18642. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18643. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18644. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18645. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18646. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18647. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18648. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18649. if order.ID == 0 {
  18650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18651. return
  18652. }
  18653. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18654. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18655. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18656. //fmt.Println(count)
  18657. //var zero string
  18658. //number := count + 1
  18659. //if number >= 1000 {
  18660. // zero = "0000" + strconv.FormatInt(number, 10)
  18661. //} else if number >= 10000 {
  18662. // zero = "000" + strconv.FormatInt(number, 10)
  18663. //} else if number >= 100000 {
  18664. // zero = "00" + strconv.FormatInt(number, 10)
  18665. //} else if number >= 1000000 {
  18666. // zero = "0" + strconv.FormatInt(number, 10)
  18667. //} else {
  18668. // zero = strconv.FormatInt(number, 10)
  18669. //}
  18670. //fmt.Println(zero)
  18671. struct4101 := service.Struct4101{
  18672. PsnNo: order.PsnNo,
  18673. MdtrtId: order.MdtrtId,
  18674. SetlId: order.SetlId,
  18675. PsnName: order.PsnName,
  18676. Gend: order.Gend,
  18677. Brdy: his.Brdy,
  18678. Age: his.Age,
  18679. Naty: order.Naty,
  18680. PatnCertType: "01",
  18681. Certno: order.Certno,
  18682. Prfs: "90",
  18683. ConerName: roles[0].UserName,
  18684. PatnRlts: "99",
  18685. ConerAddr: miConfig.OrgName,
  18686. ConerTel: admin.Mobile,
  18687. HiType: order.Insutype,
  18688. Insuplc: miConfig.InsuplcAdmdvs,
  18689. MaindiagFlag: "1",
  18690. BillCode: order.SetlId,
  18691. BillNo: order.SetlId,
  18692. BizSn: order.Number,
  18693. PsnSelfPay: order.PsnPartAmt,
  18694. PsnOwnPay: order.PsnPartAmt,
  18695. AcctPay: order.AcctPay,
  18696. PsnCashpay: order.PsnCashPay,
  18697. HiPaymtd: "1",
  18698. Hsorg: miConfig.InsuplcAdmdvs,
  18699. HsorgOpter: miConfig.InsuplcAdmdvs,
  18700. MedinsFillPsn: curRoles.UserName,
  18701. MedinsFillDept: miConfig.OrgName,
  18702. IptMedType: "2",
  18703. }
  18704. struct4101.SetlBegnDate = order.SetlTime
  18705. struct4101.SetlEndDate = order.SetlTime
  18706. time_arr := strings.Split(order.SetlTime, " ")
  18707. struct4101.AdmTime = time_arr[0]
  18708. struct4101.AdmEndTime = time_arr[0]
  18709. //
  18710. //var rf []CustomFundPay
  18711. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18712. //
  18713. //var tempFunPays []service.CustomStruct
  18714. //for _, item := range rf {
  18715. // var tempFunPay service.CustomStruct
  18716. // tempFunPay.FundPayamt = item.FundPayamt
  18717. // tempFunPay.FundPayType = item.FundPayType
  18718. // tempFunPays = append(tempFunPays, tempFunPay)
  18719. //}
  18720. //struct4101.CustomStruct = tempFunPays
  18721. var tempDiaginfos []service.DiaginfoStructTwo
  18722. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18723. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18724. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  18725. var config []*models.HisXtDiagnoseConfig
  18726. for _, item := range diagnosis_ids {
  18727. id, _ := strconv.ParseInt(item, 10, 64)
  18728. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18729. config = append(config, &diagnosisConfig)
  18730. }
  18731. if miConfig.Code == "H15049901371" {
  18732. //for _, item := range config {
  18733. // if item.ID == 138 {
  18734. diagnosisConfig, _ := service.FindDiagnoseById(138)
  18735. var tempDiaginfo service.DiaginfoStructTwo
  18736. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  18737. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  18738. tempDiaginfo.DiagType = "1"
  18739. tempDiaginfo.MaindiagFlag = "1"
  18740. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18741. //}
  18742. //}
  18743. for _, item := range config {
  18744. if item.ID != 138 {
  18745. var tempDiaginfo service.DiaginfoStructTwo
  18746. tempDiaginfo.DiagCode = item.CountryCode
  18747. tempDiaginfo.DiagName = item.CountryContentName
  18748. tempDiaginfo.DiagType = "1"
  18749. tempDiaginfo.MaindiagFlag = "0"
  18750. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18751. }
  18752. }
  18753. } else {
  18754. for index, item := range config {
  18755. if index == 0 {
  18756. var tempDiaginfo service.DiaginfoStructTwo
  18757. tempDiaginfo.DiagCode = item.CountryCode
  18758. tempDiaginfo.DiagName = item.CountryContentName
  18759. tempDiaginfo.DiagType = "1"
  18760. tempDiaginfo.MaindiagFlag = "1"
  18761. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18762. } else {
  18763. var tempDiaginfo service.DiaginfoStructTwo
  18764. tempDiaginfo.DiagCode = item.CountryCode
  18765. tempDiaginfo.DiagName = item.CountryContentName
  18766. tempDiaginfo.DiagType = "1"
  18767. tempDiaginfo.MaindiagFlag = "0"
  18768. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18769. }
  18770. }
  18771. }
  18772. struct4101.Diseinfo = tempDiaginfos
  18773. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18774. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18775. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18776. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18777. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18778. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18779. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18780. var iteminfo service.IteminfoStruct
  18781. var bedCostTotal float64 = 0 //床位总费
  18782. var bedCostSelfTotal float64 = 0 //床位自费
  18783. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18784. var operationCostTotal float64 = 0 //手术费
  18785. var operationCostSelfTotal float64 = 0 //手术费
  18786. var operationCostPartSelfTotal float64 = 0 //手术费
  18787. var otherCostTotal float64 = 0 //其他费用
  18788. var otherCostSelfTotal float64 = 0 //其他费用
  18789. var otherCostPartSelfTotal float64 = 0 //其他费用
  18790. var materialCostTotal float64 = 0 //材料费
  18791. var materialCostSelfTotal float64 = 0 //材料费
  18792. var materialCostPartSelfTotal float64 = 0 //材料费
  18793. var westernMedicineCostTotal float64 = 0 //西药费
  18794. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18795. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18796. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18797. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18798. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18799. var checkCostTotal float64 = 0 //检查费
  18800. var checkCostSelfTotal float64 = 0 //检查费
  18801. var checkCostPartSelfTotal float64 = 0 //检查费
  18802. var laboratoryCostTotal float64 = 0 //化验费
  18803. var laboratoryCostSelfTotal float64 = 0 //化验费
  18804. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18805. var treatCostTotal float64 = 0 //治疗费用
  18806. var treatCostSelfTotal float64 = 0 //治疗费用
  18807. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18808. decimal.DivisionPrecision = 2
  18809. var bed_fulamt_ownpay_amt float64 = 0
  18810. var operation_fulamt_ownpay_amt float64 = 0
  18811. var other_fulamt_ownpay_amt float64 = 0
  18812. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18813. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18814. var check_fulamt_ownpay_amt float64 = 0
  18815. var material_fulamt_ownpay_amt float64 = 0
  18816. var laboratory_fulamt_ownpay_amt float64 = 0
  18817. var treat_fulamt_ownpay_amt float64 = 0
  18818. var bed_claa_sunmfee float64 = 0
  18819. var bed_clab_amt float64 = 0
  18820. var bed_other_amt float64 = 0
  18821. var operation_claa_sunmfee float64 = 0
  18822. var operation_clab_amt float64 = 0
  18823. var operation_other_amt float64 = 0
  18824. var other_claa_sunmfee float64 = 0
  18825. var other_clab_amt float64 = 0
  18826. var other_other_amt float64 = 0
  18827. var westernMedicine_claa_sunmfee float64 = 0
  18828. var westernMedicine_clab_amt float64 = 0
  18829. var westernMedicine_other_amt float64 = 0
  18830. var chineseTraditional_claa_sunmfee float64 = 0
  18831. var chineseTraditional_clab_amt float64 = 0
  18832. var chineseTraditional_other_amt float64 = 0
  18833. var check_claa_sunmfee float64 = 0
  18834. var check_clab_amt float64 = 0
  18835. var check_other_amt float64 = 0
  18836. var material_claa_sunmfee float64 = 0
  18837. var material_clab_amt float64 = 0
  18838. var material_other_amt float64 = 0
  18839. var laboratory_claa_sunmfee float64 = 0
  18840. var laboratory_clab_amt float64 = 0
  18841. var laboratory_other_amt float64 = 0
  18842. var treat_claa_sunmfee float64 = 0
  18843. var treat_clab_amt float64 = 0
  18844. var treat_other_amt float64 = 0
  18845. for _, item := range order.HisOrderInfo {
  18846. if item.MedChrgitmType == "01" { //床位费
  18847. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18848. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18849. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18850. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18851. if item.ChrgitmLv == "1" {
  18852. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18853. }
  18854. if item.ChrgitmLv == "2" {
  18855. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18856. }
  18857. if item.ChrgitmLv == "3" {
  18858. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18859. }
  18860. }
  18861. if item.MedChrgitmType == "03" { //检查费
  18862. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18863. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18864. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18865. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18866. if item.ChrgitmLv == "1" {
  18867. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18868. }
  18869. if item.ChrgitmLv == "2" {
  18870. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18871. }
  18872. if item.ChrgitmLv == "3" {
  18873. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18874. }
  18875. }
  18876. if item.MedChrgitmType == "04" { //化验费
  18877. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18878. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18879. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18880. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18881. if item.ChrgitmLv == "1" {
  18882. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18883. }
  18884. if item.ChrgitmLv == "2" {
  18885. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18886. }
  18887. if item.ChrgitmLv == "3" {
  18888. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18889. }
  18890. }
  18891. if item.MedChrgitmType == "05" { //治疗费
  18892. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18893. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18894. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18895. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18896. if item.ChrgitmLv == "1" {
  18897. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18898. }
  18899. if item.ChrgitmLv == "2" {
  18900. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18901. }
  18902. if item.ChrgitmLv == "3" {
  18903. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18904. }
  18905. }
  18906. if item.MedChrgitmType == "06" { //手术费
  18907. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18908. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18909. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18910. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18911. if item.ChrgitmLv == "1" {
  18912. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18913. }
  18914. if item.ChrgitmLv == "2" {
  18915. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18916. }
  18917. if item.ChrgitmLv == "3" {
  18918. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18919. }
  18920. }
  18921. if item.MedChrgitmType == "08" { //材料费
  18922. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18923. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18924. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18925. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18926. if item.ChrgitmLv == "1" {
  18927. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18928. }
  18929. if item.ChrgitmLv == "2" {
  18930. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18931. }
  18932. if item.ChrgitmLv == "3" {
  18933. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18934. }
  18935. }
  18936. if item.MedChrgitmType == "09" { //西药费
  18937. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18938. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18939. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18940. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18941. if item.ChrgitmLv == "1" {
  18942. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18943. }
  18944. if item.ChrgitmLv == "2" {
  18945. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18946. }
  18947. if item.ChrgitmLv == "3" {
  18948. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18949. }
  18950. }
  18951. if item.MedChrgitmType == "11" { //中成费
  18952. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18953. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18954. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18955. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18956. if item.ChrgitmLv == "1" {
  18957. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18958. }
  18959. if item.ChrgitmLv == "2" {
  18960. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18961. }
  18962. if item.ChrgitmLv == "3" {
  18963. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18964. }
  18965. }
  18966. if item.MedChrgitmType == "14" { //其他费
  18967. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18968. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18969. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18970. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18971. if item.ChrgitmLv == "1" {
  18972. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18973. }
  18974. if item.ChrgitmLv == "2" {
  18975. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18976. }
  18977. if item.ChrgitmLv == "3" {
  18978. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18979. }
  18980. }
  18981. }
  18982. var iteminfoStructs []service.IteminfoStruct
  18983. if bedCostTotal != 0 {
  18984. iteminfo.MedChrgitm = "01"
  18985. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18986. iteminfo.Amt = bedCostTotal
  18987. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18988. iteminfo.ClabAmt = bed_clab_amt
  18989. iteminfo.OthAmt = bed_other_amt
  18990. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18991. }
  18992. if checkCostTotal != 0 {
  18993. iteminfo.MedChrgitm = "03"
  18994. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18995. iteminfo.Amt = checkCostTotal
  18996. iteminfo.ClaaSumfee = check_claa_sunmfee
  18997. iteminfo.ClabAmt = check_clab_amt
  18998. iteminfo.OthAmt = check_other_amt
  18999. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19000. }
  19001. if laboratoryCostTotal != 0 {
  19002. iteminfo.MedChrgitm = "04"
  19003. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19004. iteminfo.Amt = laboratoryCostTotal
  19005. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19006. iteminfo.ClabAmt = laboratory_clab_amt
  19007. iteminfo.OthAmt = laboratory_other_amt
  19008. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19009. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19010. }
  19011. if treatCostTotal != 0 {
  19012. iteminfo.MedChrgitm = "05"
  19013. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19014. iteminfo.Amt = treatCostTotal
  19015. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19016. iteminfo.ClabAmt = treat_clab_amt
  19017. iteminfo.OthAmt = treat_other_amt
  19018. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19019. //(struct4101.IteminfoStruct, iteminfo)
  19020. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19021. }
  19022. if operationCostTotal != 0 {
  19023. iteminfo.MedChrgitm = "06"
  19024. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19025. iteminfo.Amt = operationCostTotal
  19026. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19027. iteminfo.ClabAmt = operation_clab_amt
  19028. iteminfo.OthAmt = operation_other_amt
  19029. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19030. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19031. }
  19032. if materialCostTotal != 0 {
  19033. iteminfo.MedChrgitm = "08"
  19034. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19035. iteminfo.Amt = materialCostTotal
  19036. iteminfo.ClaaSumfee = material_claa_sunmfee
  19037. iteminfo.ClabAmt = material_clab_amt
  19038. iteminfo.OthAmt = material_other_amt
  19039. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19040. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19041. }
  19042. if westernMedicineCostTotal != 0 {
  19043. iteminfo.MedChrgitm = "09"
  19044. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19045. iteminfo.Amt = westernMedicineCostTotal
  19046. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19047. iteminfo.ClabAmt = westernMedicine_clab_amt
  19048. iteminfo.OthAmt = westernMedicine_other_amt
  19049. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19050. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19051. }
  19052. if chineseTraditionalMedicineCostTotal != 0 {
  19053. iteminfo.MedChrgitm = "11"
  19054. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19055. iteminfo.Amt = westernMedicineCostTotal
  19056. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19057. iteminfo.ClabAmt = westernMedicine_clab_amt
  19058. iteminfo.OthAmt = westernMedicine_other_amt
  19059. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19060. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19061. }
  19062. if otherCostTotal != 0 {
  19063. iteminfo.MedChrgitm = "14"
  19064. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19065. iteminfo.Amt = otherCostTotal
  19066. iteminfo.ClaaSumfee = other_claa_sunmfee
  19067. iteminfo.ClabAmt = other_clab_amt
  19068. iteminfo.OthAmt = other_other_amt
  19069. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19070. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19071. }
  19072. struct4101.IteminfoStruct = iteminfoStructs
  19073. struct4101.Ntly = "中国"
  19074. struct4101.AdmCaty = "A03.06"
  19075. struct4101.DoctorName = doctor.UserName
  19076. struct4101.DoctorCode = doctor.DoctorNumber
  19077. var res ResultSeventeen
  19078. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19079. struct4101.BillCode = order.Number
  19080. struct4101.BillNo = order.SetlId
  19081. var resOther ResultSeventeenOther
  19082. var pp models.PublicParams
  19083. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19084. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19085. pp.FixmedinsName = miConfig.OrgName
  19086. pp.FixmedinsCode = miConfig.Code
  19087. pp.RequestUrl = miConfig.Url
  19088. pp.Cainfo = miConfig.Cainfo
  19089. pp.SecretKey = miConfig.SecretKey
  19090. pp.AccessKey = miConfig.AccessKey
  19091. pp.OpterName = curRoles.UserName
  19092. client := &http.Client{}
  19093. var req *http.Request
  19094. data := make(map[string]interface{})
  19095. data["struct4101"] = struct4101
  19096. data["pp"] = pp
  19097. bytesData, _ := json.Marshal(data)
  19098. if miConfig.MdtrtareaAdmvs == "320921" {
  19099. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19100. } else {
  19101. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19102. }
  19103. resp, _ := client.Do(req)
  19104. defer resp.Body.Close()
  19105. body, ioErr := ioutil.ReadAll(resp.Body)
  19106. if ioErr != nil {
  19107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19109. return
  19110. }
  19111. var respJSON map[string]interface{}
  19112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19115. return
  19116. }
  19117. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19118. userJSONBytes, _ := json.Marshal(respJSON)
  19119. fmt.Println("log")
  19120. fmt.Println(string(userJSONBytes))
  19121. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19122. utils.ErrorLog("解析失败:%v", err)
  19123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19124. return
  19125. }
  19126. res.InfRefmsgid = resOther.InfRefmsgid
  19127. res.Output = resOther.Output
  19128. res.ErrMsg = resOther.ErrMsg
  19129. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19130. res.Infcode = infocode
  19131. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19132. var pp models.PublicParams
  19133. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19134. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19135. pp.FixmedinsName = miConfig.OrgName
  19136. pp.FixmedinsCode = miConfig.Code
  19137. pp.RequestUrl = miConfig.Url
  19138. pp.Cainfo = miConfig.Cainfo
  19139. pp.SecretKey = miConfig.SecretKey
  19140. pp.AccessKey = miConfig.AccessKey
  19141. pp.OpterName = curRoles.UserName
  19142. result, _ := service.Jxyb4101(struct4101, pp)
  19143. var dat map[string]interface{}
  19144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19145. fmt.Println(dat)
  19146. } else {
  19147. fmt.Println(err)
  19148. }
  19149. userJSONBytes, _ := json.Marshal(dat)
  19150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19151. utils.ErrorLog("解析失败:%v", err)
  19152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19153. return
  19154. }
  19155. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19156. var pp models.PublicParams
  19157. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19158. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19159. pp.FixmedinsName = miConfig.OrgName
  19160. pp.FixmedinsCode = miConfig.Code
  19161. pp.RequestUrl = miConfig.Url
  19162. pp.Cainfo = miConfig.Cainfo
  19163. pp.SecretKey = miConfig.SecretKey
  19164. pp.AccessKey = miConfig.AccessKey
  19165. pp.OpterName = curRoles.UserName
  19166. result, _ := service.Jxyb4101(struct4101, pp)
  19167. var dat map[string]interface{}
  19168. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19169. fmt.Println(dat)
  19170. } else {
  19171. fmt.Println(err)
  19172. }
  19173. userJSONBytes, _ := json.Marshal(dat)
  19174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19175. utils.ErrorLog("解析失败:%v", err)
  19176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19177. return
  19178. }
  19179. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19180. var pp models.PublicParams
  19181. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19182. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19183. pp.FixmedinsName = miConfig.OrgName
  19184. pp.FixmedinsCode = miConfig.Code
  19185. pp.RequestUrl = miConfig.Url
  19186. pp.Cainfo = miConfig.Cainfo
  19187. pp.SecretKey = miConfig.SecretKey
  19188. pp.AccessKey = miConfig.AccessKey
  19189. pp.OpterName = curRoles.UserName
  19190. result, _ := service.Hnyb4101(struct4101, pp)
  19191. var dat map[string]interface{}
  19192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19193. fmt.Println(dat)
  19194. } else {
  19195. fmt.Println(err)
  19196. }
  19197. userJSONBytes, _ := json.Marshal(dat)
  19198. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19199. utils.ErrorLog("解析失败:%v", err)
  19200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19201. return
  19202. }
  19203. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19204. var resOther ResultSeventeenOther
  19205. var pp models.PublicParams
  19206. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19207. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19208. pp.FixmedinsName = miConfig.OrgName
  19209. pp.FixmedinsCode = miConfig.Code
  19210. pp.RequestUrl = miConfig.Url
  19211. pp.Cainfo = miConfig.Cainfo
  19212. pp.SecretKey = miConfig.SecretKey
  19213. pp.AccessKey = miConfig.AccessKey
  19214. pp.OpterName = curRoles.UserName
  19215. client := &http.Client{}
  19216. var req *http.Request
  19217. data := make(map[string]interface{})
  19218. data["struct4101"] = struct4101
  19219. data["pp"] = pp
  19220. bytesData, _ := json.Marshal(data)
  19221. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19222. resp, _ := client.Do(req)
  19223. defer resp.Body.Close()
  19224. body, ioErr := ioutil.ReadAll(resp.Body)
  19225. if ioErr != nil {
  19226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19228. return
  19229. }
  19230. var respJSON map[string]interface{}
  19231. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19234. return
  19235. }
  19236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19237. userJSONBytes, _ := json.Marshal(respJSON)
  19238. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19239. utils.ErrorLog("解析失败:%v", err)
  19240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19241. return
  19242. }
  19243. res.InfRefmsgid = resOther.InfRefmsgid
  19244. res.Output = resOther.Output
  19245. res.ErrMsg = resOther.ErrMsg
  19246. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19247. res.Infcode = infocode
  19248. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19249. var pp models.PublicParams
  19250. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19251. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19252. pp.FixmedinsName = miConfig.OrgName
  19253. pp.FixmedinsCode = miConfig.Code
  19254. pp.RequestUrl = miConfig.Url
  19255. pp.Cainfo = miConfig.Cainfo
  19256. pp.SecretKey = miConfig.SecretKey
  19257. pp.AccessKey = miConfig.AccessKey
  19258. pp.OpterName = curRoles.UserName
  19259. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19260. fmt.Println(requestLog)
  19261. fmt.Println(errMsgLog)
  19262. saveLog(result, requestLog, "4101a", "上传清单")
  19263. var dat map[string]interface{}
  19264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19265. fmt.Println(dat)
  19266. } else {
  19267. fmt.Println(err)
  19268. }
  19269. userJSONBytes, _ := json.Marshal(dat)
  19270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19271. utils.ErrorLog("解析失败:%v", err)
  19272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19273. return
  19274. }
  19275. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19276. var pp models.PublicParams
  19277. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19278. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19279. pp.FixmedinsName = miConfig.OrgName
  19280. pp.FixmedinsCode = miConfig.Code
  19281. pp.RequestUrl = miConfig.Url
  19282. pp.Cainfo = miConfig.Cainfo
  19283. pp.SecretKey = miConfig.SecretKey
  19284. pp.AccessKey = miConfig.AccessKey
  19285. pp.OpterName = curRoles.UserName
  19286. client := &http.Client{}
  19287. var req *http.Request
  19288. data := make(map[string]interface{})
  19289. data["struct4101"] = struct4101
  19290. data["pp"] = pp
  19291. bytesData, _ := json.Marshal(data)
  19292. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19293. resp, _ := client.Do(req)
  19294. defer resp.Body.Close()
  19295. body, ioErr := ioutil.ReadAll(resp.Body)
  19296. if ioErr != nil {
  19297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19299. return
  19300. }
  19301. var respJSON map[string]interface{}
  19302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19305. return
  19306. }
  19307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19308. userJSONBytes, _ := json.Marshal(respJSON)
  19309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19310. utils.ErrorLog("解析失败:%v", err)
  19311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19312. return
  19313. }
  19314. } else {
  19315. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19316. var dat map[string]interface{}
  19317. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19318. fmt.Println(dat)
  19319. } else {
  19320. fmt.Println(err)
  19321. }
  19322. userJSONBytes, _ := json.Marshal(dat)
  19323. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19324. utils.ErrorLog("解析失败:%v", err)
  19325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19326. return
  19327. }
  19328. }
  19329. if res.Infcode != 0 {
  19330. c.ServeSuccessJSON(map[string]interface{}{
  19331. "failed_code": -10,
  19332. "msg": res.ErrMsg,
  19333. })
  19334. return
  19335. } else {
  19336. //order.FaPiaoNumber = zero
  19337. //order.FaPiaoCode = last_order.FaPiaoCode
  19338. //service.UpdateOrder(order)
  19339. hisFundSettleListResult := &models.HisFundSettleListResult{
  19340. Number: res.Output.SetlListId,
  19341. Status: 1,
  19342. Ctime: time.Now().Unix(),
  19343. Mtime: time.Now().Unix(),
  19344. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19345. IsUpload: 1,
  19346. OrderId: order_id,
  19347. }
  19348. service.CreateUploadRecord(hisFundSettleListResult)
  19349. c.ServeSuccessJSON(map[string]interface{}{
  19350. "msg": "上传成功",
  19351. "result": hisFundSettleListResult,
  19352. })
  19353. return
  19354. }
  19355. }
  19356. func (c *HisApiController) GetSettleListHospital() {
  19357. order_id, _ := c.GetInt64("order_id")
  19358. admin_user_id, _ := c.GetInt64("admin_user_id")
  19359. order, _ := service.GetHisOrderByIDTwo(order_id)
  19360. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19361. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19362. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19363. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19364. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19365. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19366. if order.ID == 0 {
  19367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19368. return
  19369. }
  19370. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19371. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19372. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19373. fmt.Println(count)
  19374. var zero string
  19375. number := count + 1
  19376. if number >= 1000 {
  19377. zero = "0000" + strconv.FormatInt(number, 10)
  19378. } else if number >= 10000 {
  19379. zero = "000" + strconv.FormatInt(number, 10)
  19380. } else if number >= 100000 {
  19381. zero = "00" + strconv.FormatInt(number, 10)
  19382. } else if number >= 1000000 {
  19383. zero = "0" + strconv.FormatInt(number, 10)
  19384. } else {
  19385. zero = strconv.FormatInt(number, 10)
  19386. }
  19387. fmt.Println(zero)
  19388. struct4101 := service.Struct4101{
  19389. PsnNo: order.PsnNo,
  19390. MdtrtId: order.MdtrtId,
  19391. SetlId: order.SetlId,
  19392. PsnName: order.PsnName,
  19393. Gend: order.Gend,
  19394. Brdy: his.Brdy,
  19395. Age: int64(order.Age),
  19396. Naty: order.Naty,
  19397. PatnCertType: "01",
  19398. Certno: order.Certno,
  19399. Prfs: "90",
  19400. ConerName: roles[0].UserName,
  19401. PatnRlts: "99",
  19402. ConerAddr: miConfig.OrgName,
  19403. ConerTel: admin.Mobile,
  19404. HiType: order.Insutype,
  19405. Insuplc: miConfig.InsuplcAdmdvs,
  19406. MaindiagFlag: "1",
  19407. BillCode: order.SetlId,
  19408. BillNo: order.SetlId,
  19409. BizSn: order.Number,
  19410. PsnSelfPay: order.PsnPartAmt,
  19411. PsnOwnPay: order.PsnPartAmt,
  19412. AcctPay: order.AcctPay,
  19413. PsnCashpay: order.PsnCashPay,
  19414. HiPaymtd: "1",
  19415. Hsorg: miConfig.InsuplcAdmdvs,
  19416. HsorgOpter: miConfig.InsuplcAdmdvs,
  19417. MedinsFillPsn: curRoles.UserName,
  19418. MedinsFillDept: depart.Name,
  19419. IptMedType: "2",
  19420. AdmTime: his.InHosptialTime,
  19421. AdmEndTime: his.OutHosptialTime,
  19422. }
  19423. struct4101.SetlBegnDate = order.SetlTime
  19424. struct4101.SetlEndDate = order.SetlTime
  19425. //var rf []CustomFundPay
  19426. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19427. //
  19428. //var tempFunPays []service.CustomStruct
  19429. //for _, item := range rf {
  19430. // var tempFunPay service.CustomStruct
  19431. // tempFunPay.FundPayamt = item.FundPayamt
  19432. // tempFunPay.FundPayType = item.FundPayType
  19433. // tempFunPays = append(tempFunPays, tempFunPay)
  19434. //}
  19435. //struct4101.CustomStruct = tempFunPays
  19436. var tempDiaginfos []service.DiaginfoStructTwo
  19437. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19438. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19439. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19440. //for _, item := range infos {
  19441. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19442. //}
  19443. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19444. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19445. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19446. fmt.Println(diagnosis_ids_arr)
  19447. if order.UserOrgId == 10210 {
  19448. var diagnosis_ids_arr_two []int64
  19449. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19450. var config []*models.HisXtDiagnoseConfig
  19451. for _, id := range diagnosis_ids_arr_two {
  19452. //id, _ := strconv.ParseInt(item, 10, 64)
  19453. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19454. if diagnosisConfig.ID > 0 {
  19455. config = append(config, &diagnosisConfig)
  19456. }
  19457. }
  19458. for index, item := range config {
  19459. if item.ID > 0 {
  19460. if index == 0 {
  19461. var tempDiaginfo service.DiaginfoStructTwo
  19462. tempDiaginfo.DiagCode = item.CountryCode
  19463. tempDiaginfo.DiagName = item.CountryContentName
  19464. tempDiaginfo.DiagType = "1"
  19465. tempDiaginfo.MaindiagFlag = "1"
  19466. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19467. } else {
  19468. var tempDiaginfo service.DiaginfoStructTwo
  19469. tempDiaginfo.DiagCode = item.CountryCode
  19470. tempDiaginfo.DiagName = item.CountryContentName
  19471. tempDiaginfo.DiagType = "1"
  19472. tempDiaginfo.MaindiagFlag = "0"
  19473. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19474. }
  19475. }
  19476. }
  19477. struct4101.Diseinfo = tempDiaginfos
  19478. } else {
  19479. var config []*models.HisXtDiagnoseConfig
  19480. for _, item := range diagnosis_ids_arr {
  19481. id, _ := strconv.ParseInt(item, 10, 64)
  19482. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19483. if diagnosisConfig.ID > 0 {
  19484. config = append(config, &diagnosisConfig)
  19485. }
  19486. }
  19487. for index, item := range config {
  19488. if item.ID > 0 {
  19489. if index == 0 {
  19490. var tempDiaginfo service.DiaginfoStructTwo
  19491. tempDiaginfo.DiagCode = item.CountryCode
  19492. tempDiaginfo.DiagName = item.CountryContentName
  19493. tempDiaginfo.DiagType = "1"
  19494. tempDiaginfo.MaindiagFlag = "1"
  19495. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19496. } else {
  19497. var tempDiaginfo service.DiaginfoStructTwo
  19498. tempDiaginfo.DiagCode = item.CountryCode
  19499. tempDiaginfo.DiagName = item.CountryContentName
  19500. tempDiaginfo.DiagType = "1"
  19501. tempDiaginfo.MaindiagFlag = "0"
  19502. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19503. }
  19504. }
  19505. }
  19506. struct4101.Diseinfo = tempDiaginfos
  19507. }
  19508. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19509. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19510. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19511. tempOpspdiseinfo2.OprnOprtCode = ""
  19512. tempOpspdiseinfo2.OprnOprtName = ""
  19513. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19514. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19515. var iteminfo service.IteminfoStruct
  19516. var bedCostTotal float64 = 0 //床位总费
  19517. var bedCostSelfTotal float64 = 0 //床位自费
  19518. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19519. var operationCostTotal float64 = 0 //手术费
  19520. var operationCostSelfTotal float64 = 0 //手术费
  19521. var operationCostPartSelfTotal float64 = 0 //手术费
  19522. var otherCostTotal float64 = 0 //其他费用
  19523. var otherCostSelfTotal float64 = 0 //其他费用
  19524. var otherCostPartSelfTotal float64 = 0 //其他费用
  19525. var materialCostTotal float64 = 0 //材料费
  19526. var materialCostSelfTotal float64 = 0 //材料费
  19527. var materialCostPartSelfTotal float64 = 0 //材料费
  19528. var westernMedicineCostTotal float64 = 0 //西药费
  19529. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19530. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19531. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19532. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19533. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19534. var checkCostTotal float64 = 0 //检查费
  19535. var checkCostSelfTotal float64 = 0 //检查费
  19536. var checkCostPartSelfTotal float64 = 0 //检查费
  19537. var laboratoryCostTotal float64 = 0 //化验费
  19538. var laboratoryCostSelfTotal float64 = 0 //化验费
  19539. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19540. var treatCostTotal float64 = 0 //治疗费用
  19541. var treatCostSelfTotal float64 = 0 //治疗费用
  19542. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19543. decimal.DivisionPrecision = 2
  19544. var bed_fulamt_ownpay_amt float64 = 0
  19545. var operation_fulamt_ownpay_amt float64 = 0
  19546. var other_fulamt_ownpay_amt float64 = 0
  19547. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19548. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19549. var check_fulamt_ownpay_amt float64 = 0
  19550. var material_fulamt_ownpay_amt float64 = 0
  19551. var laboratory_fulamt_ownpay_amt float64 = 0
  19552. var treat_fulamt_ownpay_amt float64 = 0
  19553. var bed_claa_sunmfee float64 = 0
  19554. var bed_clab_amt float64 = 0
  19555. var bed_other_amt float64 = 0
  19556. var operation_claa_sunmfee float64 = 0
  19557. var operation_clab_amt float64 = 0
  19558. var operation_other_amt float64 = 0
  19559. var other_claa_sunmfee float64 = 0
  19560. var other_clab_amt float64 = 0
  19561. var other_other_amt float64 = 0
  19562. var westernMedicine_claa_sunmfee float64 = 0
  19563. var westernMedicine_clab_amt float64 = 0
  19564. var westernMedicine_other_amt float64 = 0
  19565. var chineseTraditional_claa_sunmfee float64 = 0
  19566. var chineseTraditional_clab_amt float64 = 0
  19567. var chineseTraditional_other_amt float64 = 0
  19568. var check_claa_sunmfee float64 = 0
  19569. var check_clab_amt float64 = 0
  19570. var check_other_amt float64 = 0
  19571. var material_claa_sunmfee float64 = 0
  19572. var material_clab_amt float64 = 0
  19573. var material_other_amt float64 = 0
  19574. var laboratory_claa_sunmfee float64 = 0
  19575. var laboratory_clab_amt float64 = 0
  19576. var laboratory_other_amt float64 = 0
  19577. var treat_claa_sunmfee float64 = 0
  19578. var treat_clab_amt float64 = 0
  19579. var treat_other_amt float64 = 0
  19580. for _, item := range order.HisOrderInfo {
  19581. if item.MedChrgitmType == "01" { //床位费
  19582. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19583. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19584. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19585. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19586. if item.ChrgitmLv == "1" {
  19587. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19588. }
  19589. if item.ChrgitmLv == "2" {
  19590. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19591. }
  19592. if item.ChrgitmLv == "3" {
  19593. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19594. }
  19595. }
  19596. if item.MedChrgitmType == "03" { //检查费
  19597. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19598. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19599. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19600. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19601. if item.ChrgitmLv == "1" {
  19602. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19603. }
  19604. if item.ChrgitmLv == "2" {
  19605. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19606. }
  19607. if item.ChrgitmLv == "3" {
  19608. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19609. }
  19610. }
  19611. if item.MedChrgitmType == "04" { //化验费
  19612. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19613. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19614. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19615. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19616. if item.ChrgitmLv == "1" {
  19617. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19618. }
  19619. if item.ChrgitmLv == "2" {
  19620. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19621. }
  19622. if item.ChrgitmLv == "3" {
  19623. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19624. }
  19625. }
  19626. if item.MedChrgitmType == "05" { //治疗费
  19627. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19628. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19629. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19630. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19631. if item.ChrgitmLv == "1" {
  19632. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19633. }
  19634. if item.ChrgitmLv == "2" {
  19635. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19636. }
  19637. if item.ChrgitmLv == "3" {
  19638. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19639. }
  19640. }
  19641. if item.MedChrgitmType == "06" { //手术费
  19642. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19643. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19644. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19645. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19646. if item.ChrgitmLv == "1" {
  19647. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19648. }
  19649. if item.ChrgitmLv == "2" {
  19650. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19651. }
  19652. if item.ChrgitmLv == "3" {
  19653. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19654. }
  19655. }
  19656. if item.MedChrgitmType == "08" { //材料费
  19657. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19658. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19659. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19660. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19661. if item.ChrgitmLv == "1" {
  19662. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19663. }
  19664. if item.ChrgitmLv == "2" {
  19665. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19666. }
  19667. if item.ChrgitmLv == "3" {
  19668. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19669. }
  19670. }
  19671. if item.MedChrgitmType == "09" { //西药费
  19672. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19673. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19674. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19675. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19676. if item.ChrgitmLv == "1" {
  19677. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19678. }
  19679. if item.ChrgitmLv == "2" {
  19680. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19681. }
  19682. if item.ChrgitmLv == "3" {
  19683. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19684. }
  19685. }
  19686. if item.MedChrgitmType == "11" { //中成费
  19687. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19688. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19689. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19690. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19691. if item.ChrgitmLv == "1" {
  19692. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19693. }
  19694. if item.ChrgitmLv == "2" {
  19695. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19696. }
  19697. if item.ChrgitmLv == "3" {
  19698. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19699. }
  19700. }
  19701. if item.MedChrgitmType == "14" { //其他费
  19702. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19703. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19704. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19705. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19706. if item.ChrgitmLv == "1" {
  19707. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19708. }
  19709. if item.ChrgitmLv == "2" {
  19710. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19711. }
  19712. if item.ChrgitmLv == "3" {
  19713. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19714. }
  19715. }
  19716. }
  19717. var iteminfoStructs []service.IteminfoStruct
  19718. if bedCostTotal != 0 {
  19719. iteminfo.MedChrgitm = "01"
  19720. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19721. iteminfo.Amt = bedCostTotal
  19722. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19723. iteminfo.ClabAmt = bed_clab_amt
  19724. iteminfo.OthAmt = bed_other_amt
  19725. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19726. }
  19727. if checkCostTotal != 0 {
  19728. iteminfo.MedChrgitm = "03"
  19729. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19730. iteminfo.Amt = checkCostTotal
  19731. iteminfo.ClaaSumfee = check_claa_sunmfee
  19732. iteminfo.ClabAmt = check_clab_amt
  19733. iteminfo.OthAmt = check_other_amt
  19734. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19735. }
  19736. if laboratoryCostTotal != 0 {
  19737. iteminfo.MedChrgitm = "04"
  19738. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19739. iteminfo.Amt = laboratoryCostTotal
  19740. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19741. iteminfo.ClabAmt = laboratory_clab_amt
  19742. iteminfo.OthAmt = laboratory_other_amt
  19743. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19744. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19745. }
  19746. if treatCostTotal != 0 {
  19747. iteminfo.MedChrgitm = "05"
  19748. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19749. iteminfo.Amt = treatCostTotal
  19750. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19751. iteminfo.ClabAmt = treat_clab_amt
  19752. iteminfo.OthAmt = treat_other_amt
  19753. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19754. //(struct4101.IteminfoStruct, iteminfo)
  19755. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19756. }
  19757. if operationCostTotal != 0 {
  19758. iteminfo.MedChrgitm = "06"
  19759. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19760. iteminfo.Amt = operationCostTotal
  19761. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19762. iteminfo.ClabAmt = operation_clab_amt
  19763. iteminfo.OthAmt = operation_other_amt
  19764. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19765. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19766. }
  19767. if materialCostTotal != 0 {
  19768. iteminfo.MedChrgitm = "08"
  19769. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19770. iteminfo.Amt = materialCostTotal
  19771. iteminfo.ClaaSumfee = material_claa_sunmfee
  19772. iteminfo.ClabAmt = material_clab_amt
  19773. iteminfo.OthAmt = material_other_amt
  19774. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19775. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19776. }
  19777. if westernMedicineCostTotal != 0 {
  19778. iteminfo.MedChrgitm = "09"
  19779. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19780. iteminfo.Amt = westernMedicineCostTotal
  19781. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19782. iteminfo.ClabAmt = westernMedicine_clab_amt
  19783. iteminfo.OthAmt = westernMedicine_other_amt
  19784. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19785. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19786. }
  19787. if chineseTraditionalMedicineCostTotal != 0 {
  19788. iteminfo.MedChrgitm = "11"
  19789. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19790. iteminfo.Amt = westernMedicineCostTotal
  19791. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19792. iteminfo.ClabAmt = westernMedicine_clab_amt
  19793. iteminfo.OthAmt = westernMedicine_other_amt
  19794. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19795. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19796. }
  19797. if otherCostTotal != 0 {
  19798. iteminfo.MedChrgitm = "14"
  19799. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19800. iteminfo.Amt = otherCostTotal
  19801. iteminfo.ClaaSumfee = other_claa_sunmfee
  19802. iteminfo.ClabAmt = other_clab_amt
  19803. iteminfo.OthAmt = other_other_amt
  19804. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19805. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19806. }
  19807. struct4101.IteminfoStruct = iteminfoStructs
  19808. struct4101.Ntly = "中国"
  19809. struct4101.AdmCaty = "A03.06"
  19810. var resOther ResultSeventeenOther
  19811. var res ResultSeventeen
  19812. if miConfig.MdtrtareaAdmvs == "150499" {
  19813. var pp models.PublicParams
  19814. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19815. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19816. pp.FixmedinsName = miConfig.OrgName
  19817. pp.FixmedinsCode = miConfig.Code
  19818. pp.RequestUrl = miConfig.Url
  19819. pp.Cainfo = miConfig.Cainfo
  19820. pp.SecretKey = miConfig.SecretKey
  19821. pp.AccessKey = miConfig.AccessKey
  19822. pp.OpterName = curRoles.UserName
  19823. client := &http.Client{}
  19824. var req *http.Request
  19825. data := make(map[string]interface{})
  19826. data["struct4101"] = struct4101
  19827. data["pp"] = pp
  19828. bytesData, _ := json.Marshal(data)
  19829. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19830. resp, _ := client.Do(req)
  19831. defer resp.Body.Close()
  19832. body, ioErr := ioutil.ReadAll(resp.Body)
  19833. if ioErr != nil {
  19834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19836. return
  19837. }
  19838. var respJSON map[string]interface{}
  19839. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19842. return
  19843. }
  19844. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19845. userJSONBytes, _ := json.Marshal(respJSON)
  19846. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19847. utils.ErrorLog("解析失败:%v", err)
  19848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19849. return
  19850. }
  19851. res.InfRefmsgid = resOther.InfRefmsgid
  19852. res.Output = resOther.Output
  19853. res.ErrMsg = resOther.ErrMsg
  19854. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19855. res.Infcode = infocode
  19856. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19857. var pp models.PublicParams
  19858. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19859. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19860. pp.FixmedinsName = miConfig.OrgName
  19861. pp.FixmedinsCode = miConfig.Code
  19862. pp.RequestUrl = miConfig.Url
  19863. pp.Cainfo = miConfig.Cainfo
  19864. pp.SecretKey = miConfig.SecretKey
  19865. pp.AccessKey = miConfig.AccessKey
  19866. pp.OpterName = curRoles.UserName
  19867. result, _ := service.Jxyb4101(struct4101, pp)
  19868. var dat map[string]interface{}
  19869. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19870. fmt.Println(dat)
  19871. } else {
  19872. fmt.Println(err)
  19873. }
  19874. userJSONBytes, _ := json.Marshal(dat)
  19875. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19876. utils.ErrorLog("解析失败:%v", err)
  19877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19878. return
  19879. }
  19880. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19881. var pp models.PublicParams
  19882. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19883. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19884. pp.FixmedinsName = miConfig.OrgName
  19885. pp.FixmedinsCode = miConfig.Code
  19886. pp.RequestUrl = miConfig.Url
  19887. pp.Cainfo = miConfig.Cainfo
  19888. pp.SecretKey = miConfig.SecretKey
  19889. pp.AccessKey = miConfig.AccessKey
  19890. pp.OpterName = curRoles.UserName
  19891. result, _ := service.Jxyb4101(struct4101, pp)
  19892. var dat map[string]interface{}
  19893. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19894. fmt.Println(dat)
  19895. } else {
  19896. fmt.Println(err)
  19897. }
  19898. userJSONBytes, _ := json.Marshal(dat)
  19899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19900. utils.ErrorLog("解析失败:%v", err)
  19901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19902. return
  19903. }
  19904. } else {
  19905. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19906. var dat map[string]interface{}
  19907. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19908. fmt.Println(dat)
  19909. } else {
  19910. fmt.Println(err)
  19911. }
  19912. userJSONBytes, _ := json.Marshal(dat)
  19913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19914. utils.ErrorLog("解析失败:%v", err)
  19915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19916. return
  19917. }
  19918. }
  19919. if res.Infcode != 0 {
  19920. c.ServeSuccessJSON(map[string]interface{}{
  19921. "failed_code": -10,
  19922. "msg": res.ErrMsg,
  19923. })
  19924. return
  19925. } else {
  19926. if miConfig.MdtrtareaAdmvs != "150499" {
  19927. order.FaPiaoNumber = zero
  19928. order.FaPiaoCode = last_order.FaPiaoCode
  19929. service.UpdateOrder(order)
  19930. }
  19931. hisFundSettleListResult := &models.HisFundSettleListResult{
  19932. Number: res.Output.SetlListId,
  19933. Status: 1,
  19934. Ctime: time.Now().Unix(),
  19935. Mtime: time.Now().Unix(),
  19936. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19937. IsUpload: 1,
  19938. OrderId: order_id,
  19939. }
  19940. service.CreateUploadRecord(hisFundSettleListResult)
  19941. c.ServeSuccessJSON(map[string]interface{}{
  19942. "msg": "上传成功",
  19943. "result": hisFundSettleListResult,
  19944. })
  19945. return
  19946. }
  19947. }
  19948. //func (c *HisApiController) GetBatchSettleList() {
  19949. // orders, _ := service.GetAllHisOrder(10106)
  19950. // for _, item := range orders {
  19951. // order_id := item.ID
  19952. // order, _ := service.GetHisOrderByIDTwo(order_id)
  19953. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19954. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19955. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19956. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  19957. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19958. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19959. //
  19960. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19961. //
  19962. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19963. //
  19964. // if order.ID == 0 {
  19965. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19966. // return
  19967. // }
  19968. // if his.BalanceAccountsType == 2 {
  19969. // continue
  19970. // }
  19971. // struct4101 := service.Struct4101{
  19972. // PsnNo: order.PsnNo,
  19973. // MdtrtId: order.MdtrtId,
  19974. // SetlId: order.SetlId,
  19975. // PsnName: order.PsnName,
  19976. // Gend: order.Gend,
  19977. // Brdy: his.Brdy,
  19978. // Age: his.Age,
  19979. // Naty: order.Naty,
  19980. // PatnCertType: "01",
  19981. // Certno: order.Certno,
  19982. // Prfs: "90",
  19983. // ConerName: roles[0].UserName,
  19984. // PatnRlts: "99",
  19985. // ConerAddr: miConfig.OrgName,
  19986. // ConerTel: admin.Mobile,
  19987. // HiType: order.Insutype,
  19988. // Insuplc: his.InsuplcAdmdvs,
  19989. // MaindiagFlag: "1",
  19990. // BillCode: order.SetlId,
  19991. // BillNo: order.SetlId,
  19992. // BizSn: order.Number,
  19993. // PsnSelfPay: order.PsnPartAmt,
  19994. // PsnOwnPay: order.PsnPartAmt,
  19995. // AcctPay: order.AcctPay,
  19996. // PsnCashpay: order.PsnCashPay,
  19997. // HiPaymtd: "1",
  19998. // Hsorg: his.InsuplcAdmdvs,
  19999. // HsorgOpter: his.InsuplcAdmdvs,
  20000. // MedinsFillPsn: curRoles.UserName,
  20001. // MedinsFillDept: depart.Name,
  20002. // IptMedType: "2",
  20003. // }
  20004. // struct4101.SetlBegnDate = order.SetlTime
  20005. // struct4101.SetlEndDate = order.SetlTime
  20006. // //if order.SettleType == 1 {
  20007. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20008. // // dateStr := t.Format("2006-01-02")
  20009. // // struct4101.SetlBegnDate = dateStr
  20010. // // struct4101.SetlEndDate = dateStr
  20011. // //} else {
  20012. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20013. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20014. // // dateStartStr := t.Format("2006-01-02")
  20015. // // dateEndStr := t2.Format("2006-01-02")
  20016. // // struct4101.SetlBegnDate = dateStartStr
  20017. // // struct4101.SetlEndDate = dateEndStr
  20018. // //}
  20019. //
  20020. // var rf []CustomFundPay
  20021. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20022. //
  20023. // var tempFunPays []service.CustomStruct
  20024. // var tempFunPay610100 service.CustomStruct
  20025. //
  20026. // for _, item := range rf {
  20027. // if item.FundPayType == "610100" {
  20028. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20029. // tempFunPay610100.FundPayType = item.FundPayType
  20030. // } else {
  20031. // var tempFunPay service.CustomStruct
  20032. // tempFunPay.FundPayamt = item.FundPayamt
  20033. // tempFunPay.FundPayType = item.FundPayType
  20034. // tempFunPays = append(tempFunPays, tempFunPay)
  20035. // }
  20036. // }
  20037. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20038. // struct4101.CustomStruct = tempFunPays
  20039. //
  20040. // var tempDiaginfos []service.DiaginfoStructTwo
  20041. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20042. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20043. //
  20044. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20045. // var config []*models.HisXtDiagnoseConfig
  20046. // for _, item := range diagnosis_ids {
  20047. // id, _ := strconv.ParseInt(item, 10, 64)
  20048. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20049. // config = append(config, &diagnosisConfig)
  20050. // }
  20051. //
  20052. // for index, item := range config {
  20053. // if index == 0 {
  20054. // var tempDiaginfo service.DiaginfoStructTwo
  20055. // tempDiaginfo.DiagCode = item.CountryCode
  20056. // tempDiaginfo.DiagName = item.CountryContentName
  20057. // tempDiaginfo.DiagType = "1"
  20058. // tempDiaginfo.MaindiagFlag = "1"
  20059. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20060. // } else {
  20061. //
  20062. // var tempDiaginfo service.DiaginfoStructTwo
  20063. // tempDiaginfo.DiagCode = item.CountryCode
  20064. // tempDiaginfo.DiagName = item.CountryContentName
  20065. // tempDiaginfo.DiagType = "2"
  20066. // tempDiaginfo.MaindiagFlag = "0"
  20067. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20068. // }
  20069. // }
  20070. // struct4101.Diseinfo = tempDiaginfos
  20071. //
  20072. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20073. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20074. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20075. // tempOpspdiseinfo2.OprnOprtCode = ""
  20076. // tempOpspdiseinfo2.OprnOprtName = ""
  20077. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20078. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20079. //
  20080. // var iteminfo service.IteminfoStruct
  20081. //
  20082. // var bedCostTotal float64 = 0 //床位总费
  20083. // var bedCostSelfTotal float64 = 0 //床位自费
  20084. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20085. //
  20086. // var examineCostTotal float64 = 0 //诊查总费
  20087. // var examineCostSelfTotal float64 = 0 //诊查自费
  20088. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20089. //
  20090. // var nursingCostTotal float64 = 0 //护理总费
  20091. // var nursingCostSelfTotal float64 = 0 //护理自费
  20092. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20093. //
  20094. // var chineseMedicineCostTotal float64 = 0 //中成药
  20095. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20096. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20097. //
  20098. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20099. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20100. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20101. //
  20102. // var registerCostTotal float64 = 0 //一般诊疗费
  20103. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20104. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20105. //
  20106. // var operationCostTotal float64 = 0 //手术费
  20107. // var operationCostSelfTotal float64 = 0 //手术费
  20108. // var operationCostPartSelfTotal float64 = 0 //手术费
  20109. //
  20110. // var otherCostTotal float64 = 0 //其他费用
  20111. // var otherCostSelfTotal float64 = 0 //其他费用
  20112. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20113. //
  20114. // var materialCostTotal float64 = 0 //材料费
  20115. // var materialCostSelfTotal float64 = 0 //材料费
  20116. // var materialCostPartSelfTotal float64 = 0 //材料费
  20117. //
  20118. // var westernMedicineCostTotal float64 = 0 //西药费
  20119. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20120. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20121. //
  20122. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20123. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20124. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20125. //
  20126. // var checkCostTotal float64 = 0 //检查费
  20127. // var checkCostSelfTotal float64 = 0 //检查费
  20128. // var checkCostPartSelfTotal float64 = 0 //检查费
  20129. //
  20130. // var laboratoryCostTotal float64 = 0 //化验费
  20131. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20132. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20133. //
  20134. // var treatCostTotal float64 = 0 //治疗费用
  20135. // var treatCostSelfTotal float64 = 0 //治疗费用
  20136. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20137. //
  20138. // decimal.DivisionPrecision = 2
  20139. //
  20140. // var bed_fulamt_ownpay_amt float64 = 0
  20141. //
  20142. // var examine_fulamt_ownpay_amt float64 = 0
  20143. //
  20144. // var nursing_fulamt_ownpay_amt float64 = 0
  20145. //
  20146. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20147. //
  20148. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20149. //
  20150. // var register_fulamt_ownpay_amt float64 = 0
  20151. //
  20152. // var operation_fulamt_ownpay_amt float64 = 0
  20153. // var other_fulamt_ownpay_amt float64 = 0
  20154. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20155. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20156. // var check_fulamt_ownpay_amt float64 = 0
  20157. // var material_fulamt_ownpay_amt float64 = 0
  20158. // var laboratory_fulamt_ownpay_amt float64 = 0
  20159. // var treat_fulamt_ownpay_amt float64 = 0
  20160. //
  20161. // var bed_claa_sunmfee float64 = 0
  20162. // var bed_clab_amt float64 = 0
  20163. // var bed_other_amt float64 = 0
  20164. //
  20165. // var examine_claa_sunmfee float64 = 0
  20166. // var examine_clab_amt float64 = 0
  20167. // var examine_other_amt float64 = 0
  20168. //
  20169. // var nursing_claa_sunmfee float64 = 0
  20170. // var nursing_clab_amt float64 = 0
  20171. // var nursing_other_amt float64 = 0
  20172. //
  20173. // var chinese_medicine_claa_sunmfee float64 = 0
  20174. // var chinese_medicine_clab_amt float64 = 0
  20175. // var chinese_medicine_other_amt float64 = 0
  20176. //
  20177. // var commonly_treatment_claa_sunmfee float64 = 0
  20178. // var commonly_treatment_clab_amt float64 = 0
  20179. // var commonly_treatment_other_amt float64 = 0
  20180. //
  20181. // var operation_claa_sunmfee float64 = 0
  20182. // var operation_clab_amt float64 = 0
  20183. // var operation_other_amt float64 = 0
  20184. //
  20185. // var other_claa_sunmfee float64 = 0
  20186. // var other_clab_amt float64 = 0
  20187. // var other_other_amt float64 = 0
  20188. //
  20189. // var westernMedicine_claa_sunmfee float64 = 0
  20190. // var westernMedicine_clab_amt float64 = 0
  20191. // var westernMedicine_other_amt float64 = 0
  20192. //
  20193. // var chineseTraditional_claa_sunmfee float64 = 0
  20194. // var chineseTraditional_clab_amt float64 = 0
  20195. // var chineseTraditional_other_amt float64 = 0
  20196. //
  20197. // var check_claa_sunmfee float64 = 0
  20198. // var check_clab_amt float64 = 0
  20199. // var check_other_amt float64 = 0
  20200. //
  20201. // var material_claa_sunmfee float64 = 0
  20202. // var material_clab_amt float64 = 0
  20203. // var material_other_amt float64 = 0
  20204. //
  20205. // var laboratory_claa_sunmfee float64 = 0
  20206. // var laboratory_clab_amt float64 = 0
  20207. // var laboratory_other_amt float64 = 0
  20208. //
  20209. // var treat_claa_sunmfee float64 = 0
  20210. // var treat_clab_amt float64 = 0
  20211. // var treat_other_amt float64 = 0
  20212. //
  20213. // var register_claa_sunmfee float64 = 0
  20214. // var register_clab_amt float64 = 0
  20215. // var register_other_amt float64 = 0
  20216. //
  20217. // for _, item := range order.HisOrderInfo {
  20218. // if item.MedChrgitmType == "01" { //床位费
  20219. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20220. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20221. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20222. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20223. // if item.ChrgitmLv == "1" {
  20224. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20225. // }
  20226. // if item.ChrgitmLv == "2" {
  20227. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20228. //
  20229. // }
  20230. // if item.ChrgitmLv == "3" {
  20231. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20232. // }
  20233. //
  20234. // }
  20235. //
  20236. // if item.MedChrgitmType == "02" { //诊查
  20237. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20238. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20239. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20240. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20241. // if item.ChrgitmLv == "1" {
  20242. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20243. // }
  20244. // if item.ChrgitmLv == "2" {
  20245. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20246. //
  20247. // }
  20248. // if item.ChrgitmLv == "3" {
  20249. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20250. // }
  20251. //
  20252. // }
  20253. //
  20254. // if item.MedChrgitmType == "03" { //检查费
  20255. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20256. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20257. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20258. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20259. // if item.ChrgitmLv == "1" {
  20260. //
  20261. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20262. //
  20263. // }
  20264. // if item.ChrgitmLv == "2" {
  20265. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20266. //
  20267. // }
  20268. // if item.ChrgitmLv == "3" {
  20269. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20270. // }
  20271. // }
  20272. //
  20273. // if item.MedChrgitmType == "04" { //化验费
  20274. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20275. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20276. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20277. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20278. // if item.ChrgitmLv == "1" {
  20279. //
  20280. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20281. //
  20282. // }
  20283. // if item.ChrgitmLv == "2" {
  20284. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20285. //
  20286. // }
  20287. // if item.ChrgitmLv == "3" {
  20288. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20289. // }
  20290. // }
  20291. //
  20292. // if item.MedChrgitmType == "05" { //治疗费
  20293. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20294. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20295. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20296. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20297. // if item.ChrgitmLv == "1" {
  20298. //
  20299. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20300. //
  20301. // }
  20302. // if item.ChrgitmLv == "2" {
  20303. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20304. //
  20305. // }
  20306. // if item.ChrgitmLv == "3" {
  20307. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20308. // }
  20309. // }
  20310. //
  20311. // if item.MedChrgitmType == "06" { //手术费
  20312. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20313. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20314. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20315. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20316. //
  20317. // if item.ChrgitmLv == "1" {
  20318. //
  20319. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20320. //
  20321. // }
  20322. // if item.ChrgitmLv == "2" {
  20323. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20324. //
  20325. // }
  20326. // if item.ChrgitmLv == "3" {
  20327. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20328. // }
  20329. // }
  20330. //
  20331. // if item.MedChrgitmType == "07" { //手术费
  20332. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20333. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20334. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20335. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20336. //
  20337. // if item.ChrgitmLv == "1" {
  20338. //
  20339. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20340. //
  20341. // }
  20342. // if item.ChrgitmLv == "2" {
  20343. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20344. //
  20345. // }
  20346. // if item.ChrgitmLv == "3" {
  20347. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20348. // }
  20349. // }
  20350. //
  20351. // if item.MedChrgitmType == "08" { //材料费
  20352. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20353. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20354. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20355. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20356. // if item.ChrgitmLv == "1" {
  20357. //
  20358. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20359. //
  20360. // }
  20361. // if item.ChrgitmLv == "2" {
  20362. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20363. //
  20364. // }
  20365. // if item.ChrgitmLv == "3" {
  20366. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20367. // }
  20368. // }
  20369. // if item.MedChrgitmType == "09" { //西药费
  20370. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20371. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20372. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20373. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20374. // if item.ChrgitmLv == "1" {
  20375. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20376. // }
  20377. // if item.ChrgitmLv == "2" {
  20378. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20379. // }
  20380. // if item.ChrgitmLv == "3" {
  20381. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20382. // }
  20383. // }
  20384. // if item.MedChrgitmType == "10" { //中药饮片
  20385. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20386. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20387. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20388. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20389. // if item.ChrgitmLv == "1" {
  20390. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20391. // }
  20392. // if item.ChrgitmLv == "2" {
  20393. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20394. // }
  20395. // if item.ChrgitmLv == "3" {
  20396. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20397. // }
  20398. // }
  20399. //
  20400. // if item.MedChrgitmType == "11" { //中成费
  20401. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20402. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20403. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20404. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20405. // if item.ChrgitmLv == "1" {
  20406. //
  20407. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20408. //
  20409. // }
  20410. // if item.ChrgitmLv == "2" {
  20411. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20412. //
  20413. // }
  20414. // if item.ChrgitmLv == "3" {
  20415. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20416. // }
  20417. // }
  20418. //
  20419. // if item.MedChrgitmType == "12" { //中成费
  20420. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20421. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20422. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20423. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20424. // if item.ChrgitmLv == "1" {
  20425. //
  20426. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20427. //
  20428. // }
  20429. // if item.ChrgitmLv == "2" {
  20430. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20431. //
  20432. // }
  20433. // if item.ChrgitmLv == "3" {
  20434. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20435. // }
  20436. // }
  20437. //
  20438. // if item.MedChrgitmType == "13" { //中成费
  20439. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20440. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20441. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20442. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20443. // if item.ChrgitmLv == "1" {
  20444. //
  20445. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20446. //
  20447. // }
  20448. // if item.ChrgitmLv == "2" {
  20449. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20450. //
  20451. // }
  20452. // if item.ChrgitmLv == "3" {
  20453. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20454. // }
  20455. // }
  20456. //
  20457. // if item.MedChrgitmType == "14" { //其他费
  20458. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20459. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20460. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20461. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20462. // if item.ChrgitmLv == "1" {
  20463. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20464. //
  20465. // }
  20466. // if item.ChrgitmLv == "2" {
  20467. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20468. //
  20469. // }
  20470. // if item.ChrgitmLv == "3" {
  20471. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20472. // }
  20473. // }
  20474. //
  20475. // }
  20476. //
  20477. // var iteminfoStructs []service.IteminfoStruct
  20478. //
  20479. // if bedCostTotal != 0 {
  20480. // iteminfo.MedChrgitm = "01"
  20481. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20482. // iteminfo.Amt = bedCostTotal
  20483. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20484. // iteminfo.ClabAmt = bed_clab_amt
  20485. // iteminfo.OthAmt = bed_other_amt
  20486. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20487. // }
  20488. //
  20489. // if examineCostTotal != 0 {
  20490. // iteminfo.MedChrgitm = "02"
  20491. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20492. // iteminfo.Amt = examineCostTotal
  20493. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20494. // iteminfo.ClabAmt = examine_clab_amt
  20495. // iteminfo.OthAmt = examine_other_amt
  20496. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20497. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20498. // }
  20499. //
  20500. // if checkCostTotal != 0 {
  20501. // iteminfo.MedChrgitm = "03"
  20502. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20503. // iteminfo.Amt = checkCostTotal
  20504. // iteminfo.ClaaSumfee = check_claa_sunmfee
  20505. // iteminfo.ClabAmt = check_clab_amt
  20506. // iteminfo.OthAmt = check_other_amt
  20507. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20508. //
  20509. // }
  20510. //
  20511. // if laboratoryCostTotal != 0 {
  20512. // iteminfo.MedChrgitm = "04"
  20513. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20514. // iteminfo.Amt = laboratoryCostTotal
  20515. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20516. // iteminfo.ClabAmt = laboratory_clab_amt
  20517. // iteminfo.OthAmt = laboratory_other_amt
  20518. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20519. //
  20520. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20521. //
  20522. // }
  20523. //
  20524. // if treatCostTotal != 0 {
  20525. // iteminfo.MedChrgitm = "05"
  20526. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20527. // iteminfo.Amt = treatCostTotal
  20528. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  20529. // iteminfo.ClabAmt = treat_clab_amt
  20530. // iteminfo.OthAmt = treat_other_amt
  20531. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20532. // //(struct4101.IteminfoStruct, iteminfo)
  20533. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20534. // }
  20535. //
  20536. // if operationCostTotal != 0 {
  20537. // iteminfo.MedChrgitm = "06"
  20538. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20539. // iteminfo.Amt = operationCostTotal
  20540. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  20541. // iteminfo.ClabAmt = operation_clab_amt
  20542. // iteminfo.OthAmt = operation_other_amt
  20543. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20544. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20545. // }
  20546. //
  20547. // if nursingCostTotal != 0 {
  20548. // iteminfo.MedChrgitm = "07"
  20549. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  20550. // iteminfo.Amt = nursingCostTotal
  20551. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  20552. // iteminfo.ClabAmt = nursing_clab_amt
  20553. // iteminfo.OthAmt = nursing_other_amt
  20554. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20555. // }
  20556. //
  20557. // if materialCostTotal != 0 {
  20558. // iteminfo.MedChrgitm = "08"
  20559. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20560. // iteminfo.Amt = materialCostTotal
  20561. // iteminfo.ClaaSumfee = material_claa_sunmfee
  20562. // iteminfo.ClabAmt = material_clab_amt
  20563. // iteminfo.OthAmt = material_other_amt
  20564. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20565. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20566. // }
  20567. //
  20568. // if westernMedicineCostTotal != 0 {
  20569. // iteminfo.MedChrgitm = "09"
  20570. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20571. // iteminfo.Amt = westernMedicineCostTotal
  20572. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20573. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20574. // iteminfo.OthAmt = westernMedicine_other_amt
  20575. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20576. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20577. //
  20578. // }
  20579. //
  20580. // if chineseMedicineCostTotal != 0 {
  20581. // iteminfo.MedChrgitm = "10"
  20582. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  20583. // iteminfo.Amt = chineseMedicineCostTotal
  20584. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  20585. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  20586. // iteminfo.OthAmt = chinese_medicine_other_amt
  20587. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20588. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20589. //
  20590. // }
  20591. //
  20592. // if chineseTraditionalMedicineCostTotal != 0 {
  20593. // iteminfo.MedChrgitm = "11"
  20594. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20595. // iteminfo.Amt = westernMedicineCostTotal
  20596. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20597. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20598. // iteminfo.OthAmt = westernMedicine_other_amt
  20599. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20600. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20601. //
  20602. // }
  20603. //
  20604. // if commonlyTreatmentCostTotal != 0 {
  20605. // iteminfo.MedChrgitm = "12"
  20606. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  20607. // iteminfo.Amt = commonlyTreatmentCostTotal
  20608. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  20609. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  20610. // iteminfo.OthAmt = commonly_treatment_other_amt
  20611. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20612. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20613. //
  20614. // }
  20615. //
  20616. // if registerCostTotal != 0 {
  20617. // iteminfo.MedChrgitm = "13"
  20618. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  20619. // iteminfo.Amt = registerCostTotal
  20620. // iteminfo.ClaaSumfee = register_claa_sunmfee
  20621. // iteminfo.ClabAmt = register_clab_amt
  20622. // iteminfo.OthAmt = register_other_amt
  20623. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20624. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20625. //
  20626. // }
  20627. //
  20628. // if otherCostTotal != 0 {
  20629. // iteminfo.MedChrgitm = "14"
  20630. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20631. // iteminfo.Amt = otherCostTotal
  20632. // iteminfo.ClaaSumfee = other_claa_sunmfee
  20633. // iteminfo.ClabAmt = other_clab_amt
  20634. // iteminfo.OthAmt = other_other_amt
  20635. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20636. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20637. //
  20638. // }
  20639. // struct4101.IteminfoStruct = iteminfoStructs
  20640. // time_arr := strings.Split(order.SetlTime, " ")
  20641. // struct4101.AdmTime = time_arr[0]
  20642. // struct4101.AdmEndTime = time_arr[0]
  20643. //
  20644. // struct4101.DoctorName = doctor.UserName
  20645. // struct4101.DoctorCode = doctor.DoctorNumber
  20646. //
  20647. // struct4101.Ntly = "中国"
  20648. // struct4101.AdmCaty = "A03.06"
  20649. // var res ResultSeventeen
  20650. // if miConfig.MdtrtareaAdmvs == "421300" {
  20651. // data := make(map[string]interface{})
  20652. // data["struct4101"] = struct4101
  20653. // data["secret_key"] = miConfig.SecretKey
  20654. // data["org_name"] = miConfig.OrgName
  20655. // data["opera"] = curRoles.UserName
  20656. // data["code"] = miConfig.Code
  20657. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  20658. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20659. //
  20660. // client := &http.Client{}
  20661. // bytesData, _ := json.Marshal(data)
  20662. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  20663. // resp, _ := client.Do(req)
  20664. // defer resp.Body.Close()
  20665. // body, ioErr := ioutil.ReadAll(resp.Body)
  20666. // if ioErr != nil {
  20667. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20669. // return
  20670. // }
  20671. // var respJSON map[string]interface{}
  20672. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20673. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20674. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20675. // return
  20676. // }
  20677. //
  20678. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20679. // userJSONBytes, _ := json.Marshal(respJSON)
  20680. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20681. // utils.ErrorLog("解析失败:%v", err)
  20682. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20683. // adminUser := c.GetAdminUserInfo()
  20684. // errlog := &models.HisOrderError{
  20685. // UserOrgId: adminUser.CurrentOrgId,
  20686. // Ctime: time.Now().Unix(),
  20687. // Mtime: time.Now().Unix(),
  20688. // ErrMsg: res.ErrMsg + "解析失败",
  20689. // Status: 1,
  20690. // PatientId: order_id,
  20691. // Stage: 10088,
  20692. // }
  20693. // service.CreateErrMsgLog(errlog)
  20694. // continue
  20695. // }
  20696. //
  20697. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  20698. // data := make(map[string]interface{})
  20699. // data["struct4101"] = struct4101
  20700. // data["secret_key"] = miConfig.SecretKey
  20701. // data["org_name"] = miConfig.OrgName
  20702. // data["opera"] = curRoles.UserName
  20703. // data["code"] = miConfig.Code
  20704. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  20705. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20706. //
  20707. // client := &http.Client{}
  20708. // bytesData, _ := json.Marshal(data)
  20709. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  20710. // resp, _ := client.Do(req)
  20711. // defer resp.Body.Close()
  20712. // body, ioErr := ioutil.ReadAll(resp.Body)
  20713. // if ioErr != nil {
  20714. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20715. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20716. // return
  20717. // }
  20718. // var respJSON map[string]interface{}
  20719. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20720. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20722. // return
  20723. // }
  20724. //
  20725. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20726. // userJSONBytes, _ := json.Marshal(respJSON)
  20727. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20728. // utils.ErrorLog("解析失败:%v", err)
  20729. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20730. // adminUser := c.GetAdminUserInfo()
  20731. // errlog := &models.HisOrderError{
  20732. // UserOrgId: adminUser.CurrentOrgId,
  20733. // Ctime: time.Now().Unix(),
  20734. // Mtime: time.Now().Unix(),
  20735. // ErrMsg: res.ErrMsg + "解析失败",
  20736. // Status: 1,
  20737. // PatientId: order_id,
  20738. // Stage: 10088,
  20739. // }
  20740. // service.CreateErrMsgLog(errlog)
  20741. // continue
  20742. // }
  20743. //
  20744. // } else {
  20745. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  20746. // fmt.Println(result)
  20747. //
  20748. // var dat map[string]interface{}
  20749. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20750. // fmt.Println(dat)
  20751. // } else {
  20752. // fmt.Println(err)
  20753. // }
  20754. // userJSONBytes, _ := json.Marshal(dat)
  20755. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20756. // utils.ErrorLog("解析失败:%v", err)
  20757. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20758. // adminUser := c.GetAdminUserInfo()
  20759. // errlog := &models.HisOrderError{
  20760. // UserOrgId: adminUser.CurrentOrgId,
  20761. // Ctime: time.Now().Unix(),
  20762. // Mtime: time.Now().Unix(),
  20763. // ErrMsg: res.ErrMsg + "解析失败",
  20764. // Status: 1,
  20765. // PatientId: order_id,
  20766. // Stage: 10106,
  20767. // }
  20768. // service.CreateErrMsgLog(errlog)
  20769. // continue
  20770. // }
  20771. // }
  20772. //
  20773. // if res.Infcode != 0 {
  20774. // adminUser := c.GetAdminUserInfo()
  20775. // errlog := &models.HisOrderError{
  20776. // UserOrgId: adminUser.CurrentOrgId,
  20777. // Ctime: time.Now().Unix(),
  20778. // Mtime: time.Now().Unix(),
  20779. // ErrMsg: res.ErrMsg,
  20780. // Status: 1,
  20781. // PatientId: order_id,
  20782. // Stage: 10106,
  20783. // }
  20784. // service.CreateErrMsgLog(errlog)
  20785. // continue
  20786. // } else {
  20787. // hisFundSettleListResult := &models.HisFundSettleListResult{
  20788. // Number: res.Output.SetlListId,
  20789. // Status: 1,
  20790. // Ctime: time.Now().Unix(),
  20791. // Mtime: time.Now().Unix(),
  20792. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20793. // IsUpload: 1,
  20794. // OrderId: order_id,
  20795. // }
  20796. // service.CreateUploadRecord(hisFundSettleListResult)
  20797. // continue
  20798. // }
  20799. // }
  20800. //}
  20801. func (c *HisApiController) GetOrgInfo() {
  20802. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  20803. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  20804. }
  20805. func (c *HisApiController) GetHisPatientInfo() {
  20806. medical_insurance_card := c.GetString("medical_insurance_card")
  20807. id_card_type, _ := c.GetInt64("id_card_type")
  20808. id_card := c.GetString("id_card")
  20809. adminInfo := c.GetAdminUserInfo()
  20810. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  20811. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  20812. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  20813. IdCardNo := ""
  20814. if id_card_type == 1 {
  20815. IdCardNo = medical_insurance_card
  20816. } else if id_card_type == 2 {
  20817. IdCardNo = id_card
  20818. }
  20819. if config.IsOpen == 1 {
  20820. 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
  20821. resp, requestErr := http.Get(api)
  20822. if requestErr != nil {
  20823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20824. return
  20825. }
  20826. defer resp.Body.Close()
  20827. body, ioErr := ioutil.ReadAll(resp.Body)
  20828. if ioErr != nil {
  20829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20831. return
  20832. }
  20833. var respJSON map[string]interface{}
  20834. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20837. return
  20838. }
  20839. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20840. userJSONBytes, _ := json.Marshal(userJSON)
  20841. var res ResultTwo
  20842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20843. utils.ErrorLog("解析失败:%v", err)
  20844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20845. return
  20846. }
  20847. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20848. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  20849. infoStr := string(Iinfos)
  20850. idetinfoStr := string(Idetinfos)
  20851. if res.Infcode == 0 {
  20852. his := models.VMHisPatient{
  20853. Status: 1,
  20854. Ctime: time.Now().Unix(),
  20855. Mtime: time.Now().Unix(),
  20856. PsnNo: res.Output.Baseinfo.PsnNo,
  20857. PsnCertType: res.Output.Baseinfo.PsnCertType,
  20858. Certno: res.Output.Baseinfo.Certno,
  20859. PsnName: res.Output.Baseinfo.PsnName,
  20860. Gend: res.Output.Baseinfo.Gend,
  20861. Naty: res.Output.Baseinfo.Naty,
  20862. Iinfo: infoStr,
  20863. Idetinfo: idetinfoStr,
  20864. UserOrgId: adminInfo.CurrentOrgId,
  20865. IsReturn: 1,
  20866. IdCardType: id_card_type,
  20867. }
  20868. c.ServeSuccessJSON(map[string]interface{}{
  20869. "info": his,
  20870. })
  20871. } else {
  20872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  20873. return
  20874. }
  20875. }
  20876. }
  20877. //func GetBasBaseInfo() (jsonStr string, err error) {
  20878. //
  20879. // handle := syscall.NewLazyDLL("SSCard.dll")
  20880. // add := handle.NewProc("ReadCardBas")
  20881. // str := make([]byte, 1024)
  20882. // str1 := make([]byte, 1024)
  20883. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  20884. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  20885. //
  20886. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  20887. //
  20888. // fmt.Println("> Add(4,5)的结果为:", ret)
  20889. // handle.Release()
  20890. //
  20891. // return "", nil
  20892. //
  20893. //}
  20894. //func GetQRBaseInfo() (jsonStr string, err error) {
  20895. // handle := syscall.LoadDLL("SSCard.dll")
  20896. // ReadCardBas := handle.FindProc("GetQRBase")
  20897. //
  20898. // str := make([]byte, 256)
  20899. // str1 := make([]byte, 256)
  20900. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  20901. //
  20902. // fmt.Println(string(str))
  20903. // fmt.Println(r)
  20904. // return string(str), nil
  20905. //}
  20906. //func CardInit() int {
  20907. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  20908. // add := DllTestDef.MustFindProc("Init")
  20909. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  20910. // if err != nil {
  20911. // fmt.Println("SSCard的运算结果为:", ret)
  20912. // }
  20913. // result := int(ret)
  20914. // return result
  20915. //}
  20916. //func CardInit() int {
  20917. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  20918. // if err != nil {
  20919. // fmt.Println("SSCard的运算结果为:", ret)
  20920. // }
  20921. // fmt.Println(err)
  20922. // result := int(ret)
  20923. // return result
  20924. //}
  20925. func IntPtr(n int) uintptr {
  20926. return uintptr(n)
  20927. }
  20928. func StrPtr(s string) uintptr {
  20929. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  20930. }
  20931. type Result2001 struct {
  20932. Cainfo interface{} `json:"cainfo"`
  20933. ErrMsg string `json:"err_msg"`
  20934. InfRefmsgid string `json:"inf_refmsgid"`
  20935. Infcode int64 `json:"infcode"`
  20936. Output struct {
  20937. Trtinfo struct {
  20938. PsnNo string `json:"psn_no"`
  20939. TrtChkType string `json:"trt_chk_type"`
  20940. FundPayType string `json:"fund_pay_type"`
  20941. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  20942. Begndate string `json:"begndate"`
  20943. Enddate string `json:"enddate"`
  20944. TrtChkRslt string `json:"trt_chk_rslt"`
  20945. } `json:"trtinfo"`
  20946. } `json:"output"`
  20947. RefmsgTime string `json:"refmsg_time"`
  20948. RespondTime string `json:"respond_time"`
  20949. Signtype interface{} `json:"signtype"`
  20950. WarnMsg interface{} `json:"warn_msg"`
  20951. }
  20952. type Result2001Org10265 struct {
  20953. Cainfo interface{} `json:"cainfo"`
  20954. ErrMsg string `json:"err_msg"`
  20955. InfRefmsgid string `json:"inf_refmsgid"`
  20956. Infcode string `json:"infcode"`
  20957. Output struct {
  20958. Trtinfo struct {
  20959. PsnNo string `json:"psn_no"`
  20960. TrtChkType string `json:"trt_chk_type"`
  20961. FundPayType string `json:"fund_pay_type"`
  20962. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  20963. Begndate string `json:"begndate"`
  20964. Enddate string `json:"enddate"`
  20965. TrtChkRslt string `json:"trt_chk_rslt"`
  20966. } `json:"trtinfo"`
  20967. } `json:"output"`
  20968. RefmsgTime string `json:"refmsg_time"`
  20969. RespondTime string `json:"respond_time"`
  20970. Signtype interface{} `json:"signtype"`
  20971. WarnMsg interface{} `json:"warn_msg"`
  20972. }
  20973. type ResultTwo struct {
  20974. ErrMsg string `json:"err_msg"`
  20975. InfRefmsgid string `json:"inf_refmsgid"`
  20976. Infcode int64 `json:"infcode"`
  20977. Output struct {
  20978. Baseinfo struct {
  20979. //Brdy string `json:"brdy"`
  20980. Certno string `json:"certno"`
  20981. Gend string `json:"gend"`
  20982. Naty string `json:"naty"`
  20983. PsnCertType string `json:"psn_cert_type"`
  20984. PsnName string `json:"psn_name"`
  20985. PsnNo string `json:"psn_no"`
  20986. } `json:"baseinfo"`
  20987. Idetinfo []interface{} `json:"idetinfo"`
  20988. Iinfo []struct {
  20989. Balc float64 `json:"balc"`
  20990. CvlservFlag string `json:"cvlserv_flag"`
  20991. EmpName string `json:"emp_name"`
  20992. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  20993. Insutype string `json:"insutype"`
  20994. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  20995. //PausInsuDate string `json:"paus_insu_date"`
  20996. //PsnInsuDate string `json:"psn_insu_date"`
  20997. PsnInsuStas string `json:"psn_insu_stas"`
  20998. PsnType string `json:"psn_type"`
  20999. } `json:"insuinfo"`
  21000. } `json:"output"`
  21001. RefmsgTime string `json:"refmsg_time"`
  21002. RespondTime string `json:"respond_time"`
  21003. Signtype interface{} `json:"signtype"`
  21004. WarnInfo interface{} `json:"warn_info"`
  21005. }
  21006. type ResultTwo10265 struct {
  21007. ErrMsg string `json:"err_msg"`
  21008. InfRefmsgid string `json:"inf_refmsgid"`
  21009. Infcode string `json:"infcode"`
  21010. Output struct {
  21011. Baseinfo struct {
  21012. //Brdy string `json:"brdy"`
  21013. Certno string `json:"certno"`
  21014. Gend string `json:"gend"`
  21015. Naty string `json:"naty"`
  21016. PsnCertType string `json:"psn_cert_type"`
  21017. PsnName string `json:"psn_name"`
  21018. PsnNo string `json:"psn_no"`
  21019. } `json:"baseinfo"`
  21020. Idetinfo []interface{} `json:"idetinfo"`
  21021. Iinfo []struct {
  21022. Balc float64 `json:"balc"`
  21023. CvlservFlag string `json:"cvlserv_flag"`
  21024. EmpName string `json:"emp_name"`
  21025. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21026. Insutype string `json:"insutype"`
  21027. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21028. PsnInsuStas string `json:"psn_insu_stas"`
  21029. PsnType string `json:"psn_type"`
  21030. } `json:"insuinfo"`
  21031. } `json:"output"`
  21032. RefmsgTime string `json:"refmsg_time"`
  21033. RespondTime string `json:"respond_time"`
  21034. Signtype interface{} `json:"signtype"`
  21035. WarnInfo interface{} `json:"warn_info"`
  21036. }
  21037. type ResultThree struct {
  21038. Cainfo interface{} `json:"cainfo"`
  21039. ErrMsg string `json:"err_msg"`
  21040. InfRefmsgid string `json:"inf_refmsgid"`
  21041. Infcode int64 `json:"infcode"`
  21042. Output struct {
  21043. Data struct {
  21044. IptOtpNo string `json:"ipt_otp_no"`
  21045. MdtrtID string `json:"mdtrt_id"`
  21046. PsnNo string `json:"psn_no"`
  21047. } `json:"data"`
  21048. } `json:"output"`
  21049. RefmsgTime string `json:"refmsg_time"`
  21050. RespondTime string `json:"respond_time"`
  21051. Signtype interface{} `json:"signtype"`
  21052. WarnMsg interface{} `json:"warn_msg"`
  21053. }
  21054. type ResultThree10265 struct {
  21055. Cainfo interface{} `json:"cainfo"`
  21056. ErrMsg string `json:"err_msg"`
  21057. InfRefmsgid string `json:"inf_refmsgid"`
  21058. Infcode string `json:"infcode"`
  21059. Output struct {
  21060. Data struct {
  21061. IptOtpNo string `json:"ipt_otp_no"`
  21062. MdtrtID string `json:"mdtrt_id"`
  21063. PsnNo string `json:"psn_no"`
  21064. } `json:"data"`
  21065. } `json:"output"`
  21066. RefmsgTime string `json:"refmsg_time"`
  21067. RespondTime string `json:"respond_time"`
  21068. Signtype interface{} `json:"signtype"`
  21069. WarnMsg interface{} `json:"warn_msg"`
  21070. }
  21071. type ResultFour struct {
  21072. Cainfo string `json:"cainfo"`
  21073. ErrMsg string `json:"err_msg"`
  21074. InfRefmsgid string `json:"inf_refmsgid"`
  21075. Infcode int64 `json:"infcode"`
  21076. Output struct {
  21077. Result []struct {
  21078. BasMednFlag string `json:"bas_medn_flag"`
  21079. ChldMedcFlag string `json:"chld_medc_flag"`
  21080. ChrgitmLv string `json:"chrgitm_lv"`
  21081. Cnt float64 `json:"cnt"`
  21082. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21083. DrtReimFlag string `json:"drt_reim_flag"`
  21084. FeedetlSn string `json:"feedetl_sn"`
  21085. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21086. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21087. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21088. ListSpItemFlag string `json:"list_sp_item_flag"`
  21089. LmtUsedFlag string `json:"lmt_used_flag"`
  21090. MedChrgitmType string `json:"med_chrgitm_type"`
  21091. Memo string `json:"memo"`
  21092. OverlmtAmt float64 `json:"overlmt_amt"`
  21093. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21094. Pric float64 `json:"pric"`
  21095. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21096. SelfpayProp float64 `json:"selfpay_prop"`
  21097. } `json:"result"`
  21098. } `json:"output"`
  21099. RefmsgTime string `json:"refmsg_time"`
  21100. RespondTime string `json:"respond_time"`
  21101. Signtype string `json:"signtype"`
  21102. WarnMsg string `json:"warn_msg"`
  21103. }
  21104. type ResultFour10265 struct {
  21105. Cainfo string `json:"cainfo"`
  21106. ErrMsg string `json:"err_msg"`
  21107. InfRefmsgid string `json:"inf_refmsgid"`
  21108. Infcode string `json:"infcode"`
  21109. Output struct {
  21110. Result []struct {
  21111. BasMednFlag string `json:"bas_medn_flag"`
  21112. ChldMedcFlag string `json:"chld_medc_flag"`
  21113. ChrgitmLv string `json:"chrgitm_lv"`
  21114. Cnt float64 `json:"cnt"`
  21115. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21116. DrtReimFlag string `json:"drt_reim_flag"`
  21117. FeedetlSn string `json:"feedetl_sn"`
  21118. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21119. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21120. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21121. ListSpItemFlag string `json:"list_sp_item_flag"`
  21122. LmtUsedFlag string `json:"lmt_used_flag"`
  21123. MedChrgitmType string `json:"med_chrgitm_type"`
  21124. Memo string `json:"memo"`
  21125. OverlmtAmt float64 `json:"overlmt_amt"`
  21126. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21127. Pric float64 `json:"pric"`
  21128. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21129. SelfpayProp float64 `json:"selfpay_prop"`
  21130. } `json:"result"`
  21131. } `json:"output"`
  21132. RefmsgTime string `json:"refmsg_time"`
  21133. RespondTime string `json:"respond_time"`
  21134. Signtype string `json:"signtype"`
  21135. WarnMsg string `json:"warn_msg"`
  21136. }
  21137. type ResultMemo struct {
  21138. InsuAdmdvs string `json:"insuAdmdvs"`
  21139. }
  21140. // [{"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}]
  21141. type ResultIDInfo struct {
  21142. Begntime string `json:"begntime"`
  21143. Endtime string `json:"endtime"`
  21144. Memo string `json:"memo"`
  21145. }
  21146. type ResultFive struct {
  21147. Balc float64 `json:"balc"`
  21148. CvlservFlag string `json:"cvlserv_flag"`
  21149. EmpName string `json:"emp_name"`
  21150. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21151. Insutype string `json:"insutype"`
  21152. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21153. PausInsuDate string `json:"paus_insu_date"`
  21154. PsnInsuDate string `json:"psn_insu_date"`
  21155. PsnInsuStas string `json:"psn_insu_stas"`
  21156. PsnType string `json:"psn_type"`
  21157. }
  21158. type ResultSix struct {
  21159. Cainfo interface{} `json:"cainfo"`
  21160. ErrMsg string `json:"err_msg"`
  21161. InfRefmsgid string `json:"inf_refmsgid"`
  21162. Infcode int64 `json:"infcode"`
  21163. Output struct {
  21164. } `json:"output"`
  21165. RefmsgTime string `json:"refmsg_time"`
  21166. RespondTime string `json:"respond_time"`
  21167. Signtype interface{} `json:"signtype"`
  21168. WarnMsg interface{} `json:"warn_msg"`
  21169. }
  21170. type FJ3507Result struct {
  21171. Cainfo interface{} `json:"cainfo"`
  21172. ErrMsg string `json:"err_msg"`
  21173. InfRefmsgid string `json:"inf_refmsgid"`
  21174. Infcode int64 `json:"infcode"`
  21175. Output struct {
  21176. retRslt string `json:"retRslt"`
  21177. msgRslt string `json:"msgRslt"`
  21178. } `json:"output"`
  21179. RefmsgTime string `json:"refmsg_time"`
  21180. RespondTime string `json:"respond_time"`
  21181. Signtype interface{} `json:"signtype"`
  21182. WarnMsg interface{} `json:"warn_msg"`
  21183. }
  21184. type FJ3507ResultFor10188 struct {
  21185. Cainfo interface{} `json:"cainfo"`
  21186. ErrMsg string `json:"err_msg"`
  21187. InfRefmsgid string `json:"inf_refmsgid"`
  21188. Infcode string `json:"infcode"`
  21189. RefmsgTime string `json:"refmsg_time"`
  21190. RespondTime string `json:"respond_time"`
  21191. Signtype interface{} `json:"signtype"`
  21192. WarnMsg interface{} `json:"warn_msg"`
  21193. }
  21194. type Result2406 struct {
  21195. Cainfo interface{} `json:"cainfo"`
  21196. ErrMsg string `json:"err_msg"`
  21197. InfRefmsgid string `json:"inf_refmsgid"`
  21198. Infcode int64 `json:"infcode"`
  21199. Output struct {
  21200. Result struct {
  21201. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21202. } `json:"result"`
  21203. } `json:"output"`
  21204. RefmsgTime string `json:"refmsg_time"`
  21205. RespondTime string `json:"respond_time"`
  21206. Signtype interface{} `json:"signtype"`
  21207. WarnMsg interface{} `json:"warn_msg"`
  21208. }
  21209. type GZResultSix struct {
  21210. Cainfo interface{} `json:"cainfo"`
  21211. ErrMsg string `json:"err_msg"`
  21212. InfRefmsgid string `json:"inf_refmsgid"`
  21213. Infcode int64 `json:"infcode"`
  21214. Output string `json:"output"`
  21215. RefmsgTime string `json:"refmsg_time"`
  21216. RespondTime string `json:"respond_time"`
  21217. Signtype interface{} `json:"signtype"`
  21218. WarnMsg interface{} `json:"warn_msg"`
  21219. }
  21220. type ResultSix10265 struct {
  21221. Cainfo interface{} `json:"cainfo"`
  21222. ErrMsg string `json:"err_msg"`
  21223. InfRefmsgid string `json:"inf_refmsgid"`
  21224. Infcode string `json:"infcode"`
  21225. Output struct {
  21226. } `json:"output"`
  21227. RefmsgTime string `json:"refmsg_time"`
  21228. RespondTime string `json:"respond_time"`
  21229. Signtype interface{} `json:"signtype"`
  21230. WarnMsg interface{} `json:"warn_msg"`
  21231. }
  21232. type ResultSeven struct {
  21233. Cainfo string `json:"cainfo"`
  21234. ErrMsg string `json:"err_msg"`
  21235. InfRefmsgid string `json:"inf_refmsgid"`
  21236. Infcode int64 `json:"infcode"`
  21237. Output struct {
  21238. Setlinfo struct {
  21239. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21240. AcctPay float64 `json:"acct_pay"`
  21241. ActPayDedc float64 `json:"act_pay_dedc"`
  21242. Age float64 `json:"age"`
  21243. Balc float64 `json:"balc"`
  21244. Certno string `json:"certno"`
  21245. ClrOptins string `json:"clr_optins"`
  21246. ClrType string `json:"clr_type"`
  21247. ClrWay string `json:"clr_way"`
  21248. CvlservFlag string `json:"cvlserv_flag"`
  21249. CvlservPay float64 `json:"cvlserv_pay"`
  21250. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21251. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21252. Gend string `json:"gend"`
  21253. HifesPay float64 `json:"hifes_pay"`
  21254. HifmiPay float64 `json:"hifmi_pay"`
  21255. HifpPay float64 `json:"hifp_pay"`
  21256. HospPartAmt float64 `json:"hosp_part_amt"`
  21257. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21258. Insutype string `json:"insutype"`
  21259. MafPay float64 `json:"maf_pay"`
  21260. MdtrtCertType string `json:"mdtrt_cert_type"`
  21261. HifobPay float64 `json:"hifob_pay"`
  21262. MdtrtID string `json:"mdtrt_id"`
  21263. MedType string `json:"med_type"`
  21264. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21265. MedinsSetlID string `json:"medins_setl_id"`
  21266. Naty string `json:"naty"`
  21267. OthPay float64 `json:"oth_pay"`
  21268. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21269. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21270. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21271. PsnCashPay float64 `json:"psn_cash_pay"`
  21272. PsnCertType string `json:"psn_cert_type"`
  21273. PsnName string `json:"psn_name"`
  21274. PsnNo string `json:"psn_no"`
  21275. PsnPartAmt float64 `json:"psn_part_amt"`
  21276. PsnType string `json:"psn_type"`
  21277. SetlID string `json:"setl_id"`
  21278. SetlTime string `json:"setl_time"`
  21279. } `json:"setlinfo"`
  21280. Setldetail interface{} `json:"setldetail"`
  21281. } `json:"output"`
  21282. RefmsgTime string `json:"refmsg_time"`
  21283. RespondTime string `json:"respond_time"`
  21284. Signtype interface{} `json:"signtype"`
  21285. WarnMsg interface{} `json:"warn_msg"`
  21286. }
  21287. type ResultSevenAH struct {
  21288. Cainfo string `json:"cainfo"`
  21289. ErrMsg string `json:"err_msg"`
  21290. InfRefmsgid string `json:"inf_refmsgid"`
  21291. Infcode int64 `json:"infcode"`
  21292. Output struct {
  21293. Setlinfo struct {
  21294. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21295. AcctPay float64 `json:"acct_pay"`
  21296. ActPayDedc float64 `json:"act_pay_dedc"`
  21297. Age float64 `json:"age"`
  21298. Balc float64 `json:"balc"`
  21299. Certno string `json:"certno"`
  21300. ClrOptins string `json:"clr_optins"`
  21301. ClrType string `json:"clr_type"`
  21302. ClrWay string `json:"clr_way"`
  21303. CvlservFlag string `json:"cvlserv_flag"`
  21304. CvlservPay float64 `json:"cvlserv_pay"`
  21305. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21306. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21307. Gend string `json:"gend"`
  21308. HifesPay float64 `json:"hifes_pay"`
  21309. HifmiPay float64 `json:"hifmi_pay"`
  21310. HifpPay float64 `json:"hifp_pay"`
  21311. HospPartAmt float64 `json:"hosp_part_amt"`
  21312. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21313. Insutype string `json:"insutype"`
  21314. MafPay float64 `json:"maf_pay"`
  21315. MdtrtCertType string `json:"mdtrt_cert_type"`
  21316. HifobPay float64 `json:"hifob_pay"`
  21317. MdtrtID string `json:"mdtrt_id"`
  21318. MedType string `json:"med_type"`
  21319. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21320. MedinsSetlID string `json:"medins_setl_id"`
  21321. Naty string `json:"naty"`
  21322. OthPay float64 `json:"oth_pay"`
  21323. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21324. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21325. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21326. PsnCashPay float64 `json:"psn_cash_pay"`
  21327. PsnCertType string `json:"psn_cert_type"`
  21328. PsnName string `json:"psn_name"`
  21329. PsnNo string `json:"psn_no"`
  21330. PsnPartAmt float64 `json:"psn_part_amt"`
  21331. PsnType string `json:"psn_type"`
  21332. SetlID string `json:"setl_id"`
  21333. SetlTime int64 `json:"setl_time"`
  21334. } `json:"setlinfo"`
  21335. Setldetail interface{} `json:"setldetail"`
  21336. } `json:"output"`
  21337. RefmsgTime string `json:"refmsg_time"`
  21338. RespondTime string `json:"respond_time"`
  21339. Signtype interface{} `json:"signtype"`
  21340. WarnMsg interface{} `json:"warn_msg"`
  21341. }
  21342. type ResultSeven10265 struct {
  21343. Cainfo string `json:"cainfo"`
  21344. ErrMsg string `json:"err_msg"`
  21345. InfRefmsgid string `json:"inf_refmsgid"`
  21346. Infcode string `json:"infcode"`
  21347. Output struct {
  21348. Setlinfo struct {
  21349. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21350. AcctPay float64 `json:"acct_pay"`
  21351. ActPayDedc float64 `json:"act_pay_dedc"`
  21352. Age float64 `json:"age"`
  21353. Balc float64 `json:"balc"`
  21354. Certno string `json:"certno"`
  21355. ClrOptins string `json:"clr_optins"`
  21356. ClrType string `json:"clr_type"`
  21357. ClrWay string `json:"clr_way"`
  21358. CvlservFlag string `json:"cvlserv_flag"`
  21359. CvlservPay float64 `json:"cvlserv_pay"`
  21360. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21361. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21362. Gend string `json:"gend"`
  21363. HifesPay float64 `json:"hifes_pay"`
  21364. HifmiPay float64 `json:"hifmi_pay"`
  21365. HifpPay float64 `json:"hifp_pay"`
  21366. HospPartAmt float64 `json:"hosp_part_amt"`
  21367. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21368. Insutype string `json:"insutype"`
  21369. MafPay float64 `json:"maf_pay"`
  21370. MdtrtCertType string `json:"mdtrt_cert_type"`
  21371. HifobPay float64 `json:"hifob_pay"`
  21372. MdtrtID string `json:"mdtrt_id"`
  21373. MedType string `json:"med_type"`
  21374. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21375. MedinsSetlID string `json:"medins_setl_id"`
  21376. Naty string `json:"naty"`
  21377. OthPay float64 `json:"oth_pay"`
  21378. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21379. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21380. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21381. PsnCashPay float64 `json:"psn_cash_pay"`
  21382. PsnCertType string `json:"psn_cert_type"`
  21383. PsnName string `json:"psn_name"`
  21384. PsnNo string `json:"psn_no"`
  21385. PsnPartAmt float64 `json:"psn_part_amt"`
  21386. PsnType string `json:"psn_type"`
  21387. SetlID string `json:"setl_id"`
  21388. SetlTime string `json:"setl_time"`
  21389. } `json:"setlinfo"`
  21390. Setldetail interface{} `json:"setldetail"`
  21391. } `json:"output"`
  21392. RefmsgTime string `json:"refmsg_time"`
  21393. RespondTime string `json:"respond_time"`
  21394. Signtype interface{} `json:"signtype"`
  21395. WarnMsg interface{} `json:"warn_msg"`
  21396. }
  21397. type ResultSeven10265Two struct {
  21398. Cainfo string `json:"cainfo"`
  21399. ErrMsg string `json:"err_msg"`
  21400. InfRefmsgid string `json:"inf_refmsgid"`
  21401. Infcode string `json:"infcode"`
  21402. Output struct {
  21403. Setlinfo struct {
  21404. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21405. AcctPay float64 `json:"acct_pay"`
  21406. ActPayDedc float64 `json:"act_pay_dedc"`
  21407. Age float64 `json:"age"`
  21408. Balc float64 `json:"balc"`
  21409. Certno string `json:"certno"`
  21410. ClrOptins string `json:"clr_optins"`
  21411. ClrType string `json:"clr_type"`
  21412. ClrWay string `json:"clr_way"`
  21413. CvlservFlag string `json:"cvlserv_flag"`
  21414. CvlservPay float64 `json:"cvlserv_pay"`
  21415. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21416. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21417. Gend string `json:"gend"`
  21418. HifesPay float64 `json:"hifes_pay"`
  21419. HifmiPay float64 `json:"hifmi_pay"`
  21420. HifpPay float64 `json:"hifp_pay"`
  21421. HospPartAmt string `json:"hosp_part_amt"`
  21422. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21423. Insutype string `json:"insutype"`
  21424. MafPay float64 `json:"maf_pay"`
  21425. MdtrtCertType string `json:"mdtrt_cert_type"`
  21426. HifobPay float64 `json:"hifob_pay"`
  21427. MdtrtID string `json:"mdtrt_id"`
  21428. MedType string `json:"med_type"`
  21429. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21430. MedinsSetlID string `json:"medins_setl_id"`
  21431. Naty string `json:"naty"`
  21432. OthPay float64 `json:"oth_pay"`
  21433. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21434. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21435. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21436. PsnCashPay float64 `json:"psn_cash_pay"`
  21437. PsnCertType string `json:"psn_cert_type"`
  21438. PsnName string `json:"psn_name"`
  21439. PsnNo string `json:"psn_no"`
  21440. PsnPartAmt float64 `json:"psn_part_amt"`
  21441. PsnType string `json:"psn_type"`
  21442. SetlID string `json:"setl_id"`
  21443. SetlTime string `json:"setl_time"`
  21444. } `json:"setlinfo"`
  21445. Setldetail interface{} `json:"setldetail"`
  21446. } `json:"output"`
  21447. RefmsgTime string `json:"refmsg_time"`
  21448. RespondTime string `json:"respond_time"`
  21449. Signtype interface{} `json:"signtype"`
  21450. WarnMsg interface{} `json:"warn_msg"`
  21451. }
  21452. type GZResultSeven10265Two struct {
  21453. Cainfo string `json:"cainfo"`
  21454. ErrMsg string `json:"err_msg"`
  21455. InfRefmsgid string `json:"inf_refmsgid"`
  21456. Infcode int64 `json:"infcode"`
  21457. Output struct {
  21458. Setlinfo struct {
  21459. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21460. AcctPay float64 `json:"acct_pay"`
  21461. ActPayDedc float64 `json:"act_pay_dedc"`
  21462. Age float64 `json:"age"`
  21463. Balc float64 `json:"balc"`
  21464. Certno string `json:"certno"`
  21465. ClrOptins string `json:"clr_optins"`
  21466. ClrType string `json:"clr_type"`
  21467. ClrWay string `json:"clr_way"`
  21468. CvlservFlag string `json:"cvlserv_flag"`
  21469. CvlservPay float64 `json:"cvlserv_pay"`
  21470. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21471. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21472. Gend string `json:"gend"`
  21473. HifesPay float64 `json:"hifes_pay"`
  21474. HifmiPay float64 `json:"hifmi_pay"`
  21475. HifpPay float64 `json:"hifp_pay"`
  21476. HospPartAmt float64 `json:"hosp_part_amt"`
  21477. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21478. Insutype string `json:"insutype"`
  21479. MafPay float64 `json:"maf_pay"`
  21480. MdtrtCertType string `json:"mdtrt_cert_type"`
  21481. HifobPay float64 `json:"hifob_pay"`
  21482. MdtrtID string `json:"mdtrt_id"`
  21483. MedType string `json:"med_type"`
  21484. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21485. MedinsSetlID string `json:"medins_setl_id"`
  21486. Naty string `json:"naty"`
  21487. OthPay float64 `json:"oth_pay"`
  21488. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21489. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21490. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21491. PsnCashPay float64 `json:"psn_cash_pay"`
  21492. PsnCertType string `json:"psn_cert_type"`
  21493. PsnName string `json:"psn_name"`
  21494. PsnNo string `json:"psn_no"`
  21495. PsnPartAmt float64 `json:"psn_part_amt"`
  21496. PsnType string `json:"psn_type"`
  21497. SetlID string `json:"setl_id"`
  21498. SetlTime string `json:"setl_time"`
  21499. } `json:"setlinfo"`
  21500. Setldetail interface{} `json:"setldetail"`
  21501. } `json:"output"`
  21502. RefmsgTime string `json:"refmsg_time"`
  21503. RespondTime string `json:"respond_time"`
  21504. Signtype interface{} `json:"signtype"`
  21505. WarnMsg interface{} `json:"warn_msg"`
  21506. }
  21507. type ResultEight struct {
  21508. Cainfo string `json:"cainfo"`
  21509. ErrMsg string `json:"err_msg"`
  21510. InfRefmsgid string `json:"inf_refmsgid"`
  21511. Infcode int64 `json:"infcode"`
  21512. Output struct {
  21513. Stmtinfo struct {
  21514. SetlOptins string `json:"setl_optins"`
  21515. StmtRslt string `json:"stmt_rslt"`
  21516. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21517. } `json:"stmtinfo"`
  21518. } `json:"output"`
  21519. RefmsgTime string `json:"refmsg_time"`
  21520. RespondTime string `json:"respond_time"`
  21521. Signtype interface{} `json:"signtype"`
  21522. WarnMsg interface{} `json:"warn_msg"`
  21523. }
  21524. type ResultEightFor10188 struct {
  21525. Cainfo string `json:"cainfo"`
  21526. ErrMsg string `json:"err_msg"`
  21527. InfRefmsgid string `json:"inf_refmsgid"`
  21528. Infcode string `json:"infcode"`
  21529. Output struct {
  21530. Stmtinfo struct {
  21531. SetlOptins string `json:"setl_optins"`
  21532. StmtRslt string `json:"stmt_rslt"`
  21533. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21534. } `json:"stmtinfo"`
  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 ResultNine struct {
  21542. Cainfo string `json:"cainfo"`
  21543. ErrMsg string `json:"err_msg"`
  21544. InfRefmsgid string `json:"inf_refmsgid"`
  21545. Infcode int64 `json:"infcode"`
  21546. Output struct {
  21547. FileQuryNo string `json:"file_qury_no"`
  21548. } `json:"output"`
  21549. RefmsgTime string `json:"refmsg_time"`
  21550. RespondTime string `json:"respond_time"`
  21551. Signtype interface{} `json:"signtype"`
  21552. WarnMsg interface{} `json:"warn_msg"`
  21553. }
  21554. type ResultTen struct {
  21555. Cainfo string `json:"cainfo"`
  21556. ErrMsg string `json:"err_msg"`
  21557. InfRefmsgid string `json:"inf_refmsgid"`
  21558. Infcode int64 `json:"infcode"`
  21559. Output struct {
  21560. Fileinfo struct {
  21561. DldEndtime string `json:"dld_endtime"`
  21562. FileQuryNo string `json:"file_qury_no"`
  21563. Filename string `json:"filename"`
  21564. } `json:"fileinfo"`
  21565. } `json:"output"`
  21566. RefmsgTime string `json:"refmsg_time"`
  21567. RespondTime string `json:"respond_time"`
  21568. Signtype interface{} `json:"signtype"`
  21569. WarnMsg interface{} `json:"warn_msg"`
  21570. }
  21571. type Result5262 struct {
  21572. ErrMsg string `json:"err_msg"`
  21573. InfRefmsgid string `json:"inf_refmsgid"`
  21574. Infcode int64 `json:"infcode"`
  21575. Output struct {
  21576. PageInfo struct {
  21577. Size int `json:"size"`
  21578. RecordCounts int `json:"record_counts"`
  21579. } `json:"page_info"`
  21580. Idetinfo []interface{} `json:"idetinfo"`
  21581. Result []struct {
  21582. SetlID string `json:"setl_id"`
  21583. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21584. MdtrtID string `json:"mdtrt_id"`
  21585. InitSetlID string `json:"init_setl_id,omitempty"`
  21586. PsnNo string `json:"psn_no"`
  21587. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21588. PsnName string `json:"psn_name"`
  21589. PsnCertType string `json:"psn_cert_type"`
  21590. Certno string `json:"certno"`
  21591. Gend string `json:"gend,omitempty"`
  21592. Naty string `json:"naty,omitempty"`
  21593. Brdy string `json:"brdy,omitempty"`
  21594. Age float64 `json:"age,omitempty"`
  21595. Insutype string `json:"insutype,omitempty"`
  21596. PsnType string `json:"psn_type"`
  21597. CvlservFlag string `json:"cvlserv_flag"`
  21598. CvlservLv string `json:"cvlserv_lv,omitempty"`
  21599. SpPsnType string `json:"sp_psn_type,omitempty"`
  21600. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  21601. ClctGrde string `json:"clct_grde,omitempty"`
  21602. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  21603. NwbFlag string `json:"nwb_flag,omitempty"`
  21604. InsuAdmdvs string `json:"insu_admdvs"`
  21605. EmpNo string `json:"emp_no,omitempty"`
  21606. EmpName string `json:"emp_name,omitempty"`
  21607. EmpType string `json:"emp_type,omitempty"`
  21608. EconType string `json:"econ_type,omitempty"`
  21609. AfilIndu string `json:"afil_indu,omitempty"`
  21610. AfilRlts string `json:"afil_rlts,omitempty"`
  21611. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  21612. PayLoc string `json:"pay_loc,omitempty"`
  21613. FixmedinsCode string `json:"fixmedins_code"`
  21614. FixmedinsName string `json:"fixmedins_name"`
  21615. HospLv string `json:"hosp_lv,omitempty"`
  21616. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  21617. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  21618. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  21619. Begndate string `json:"begndate"`
  21620. Enddate string `json:"enddate"`
  21621. SetlTime string `json:"setl_time"`
  21622. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  21623. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  21624. MedType string `json:"med_type"`
  21625. SetlType string `json:"setl_type,omitempty"`
  21626. ClrType string `json:"clr_type,omitempty"`
  21627. ClrWay string `json:"clr_way,omitempty"`
  21628. PsnSetlway string `json:"psn_setlway,omitempty"`
  21629. ClrOptins string `json:"clr_optins,omitempty"`
  21630. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  21631. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  21632. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  21633. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  21634. InscpAmt float64 `json:"inscp_amt,omitempty"`
  21635. DedcStd float64 `json:"dedc_std,omitempty"`
  21636. CrtDedc float64 `json:"crt_dedc,omitempty"`
  21637. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  21638. HifpPay float64 `json:"hifp_pay,omitempty"`
  21639. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  21640. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  21641. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  21642. HifesPay float64 `json:"hifes_pay,omitempty"`
  21643. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  21644. HifobPay float64 `json:"hifob_pay,omitempty"`
  21645. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  21646. MafPay float64 `json:"maf_pay,omitempty"`
  21647. OthfundPay float64 `json:"othfund_pay,omitempty"`
  21648. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  21649. PsnPay float64 `json:"psn_pay,omitempty"`
  21650. AcctPay float64 `json:"acct_pay,omitempty"`
  21651. CashPayamt float64 `json:"cash_payamt,omitempty"`
  21652. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  21653. Balc float64 `json:"balc,omitempty"`
  21654. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  21655. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  21656. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  21657. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  21658. Year string `json:"year,omitempty"`
  21659. DiseNo string `json:"dise_no,omitempty"`
  21660. DiseName string `json:"dise_name,omitempty"`
  21661. Invono string `json:"invono,omitempty"`
  21662. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  21663. ValiFlag string `json:"vali_flag,omitempty"`
  21664. Memo string `json:"memo,omitempty"`
  21665. Rid string `json:"rid"`
  21666. UpdtTime string `json:"updt_time,omitempty"`
  21667. CrterID string `json:"crter_id,omitempty"`
  21668. CrterName string `json:"crter_name,omitempty"`
  21669. CrteTime string `json:"crte_time,omitempty"`
  21670. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  21671. OpterID string `json:"opter_id,omitempty"`
  21672. OpterName string `json:"opter_name,omitempty"`
  21673. OptTime string `json:"opt_time,omitempty"`
  21674. OptinsNo string `json:"optins_no,omitempty"`
  21675. PoolareaNo string `json:"poolarea_no,omitempty"`
  21676. } `json:"result"`
  21677. } `json:"output"`
  21678. RefmsgTime string `json:"refmsg_time"`
  21679. RespondTime string `json:"respond_time"`
  21680. Signtype interface{} `json:"signtype"`
  21681. WarnInfo interface{} `json:"warn_info"`
  21682. }
  21683. type Result5267 struct {
  21684. ErrMsg string `json:"err_msg"`
  21685. InfRefmsgid string `json:"inf_refmsgid"`
  21686. Infcode int64 `json:"infcode"`
  21687. Output struct {
  21688. PageInfo struct {
  21689. Size int `json:"size"`
  21690. RecordCounts int `json:"record_counts"`
  21691. } `json:"pageinfo"`
  21692. Result []struct {
  21693. SetlID string `json:"setl_id"`
  21694. ClrOptins string `json:"clr_optins"`
  21695. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21696. MdtrtID string `json:"mdtrt_id"`
  21697. InitSetlID string `json:"init_setl_id,omitempty"`
  21698. PsnNo string `json:"psn_no"`
  21699. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21700. PsnName string `json:"psn_name"`
  21701. PsnCertType string `json:"psn_cert_type"`
  21702. Certno string `json:"certno"`
  21703. Gend string `json:"gend,omitempty"`
  21704. Naty string `json:"naty,omitempty"`
  21705. Brdy string `json:"brdy,omitempty"`
  21706. Age float64 `json:"age,omitempty"`
  21707. Insutype string `json:"insutype,omitempty"`
  21708. PsnType string `json:"psn_type"`
  21709. CvlservFlag string `json:"cvlserv_flag"`
  21710. CvlservLv string `json:"cvlserv_lv,omitempty"`
  21711. SpPsnType string `json:"sp_psn_type,omitempty"`
  21712. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  21713. ClctGrde string `json:"clct_grde,omitempty"`
  21714. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  21715. NwbFlag string `json:"nwb_flag,omitempty"`
  21716. InsuAdmdvs string `json:"insu_admdvs"`
  21717. EmpNo string `json:"emp_no,omitempty"`
  21718. EmpName string `json:"emp_name,omitempty"`
  21719. EmpType string `json:"emp_type,omitempty"`
  21720. EconType string `json:"econ_type,omitempty"`
  21721. AfilIndu string `json:"afil_indu,omitempty"`
  21722. AfilRlts string `json:"afil_rlts,omitempty"`
  21723. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  21724. PayLoc string `json:"pay_loc,omitempty"`
  21725. FixmedinsCode string `json:"fixmedins_code"`
  21726. FixmedinsName string `json:"fixmedins_name"`
  21727. HospLv string `json:"hosp_lv,omitempty"`
  21728. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  21729. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  21730. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  21731. Begndate string `json:"begndate,omitempty"`
  21732. Enddate string `json:"enddate,omitempty"`
  21733. SetlTime string `json:"setl_time,omitempty"`
  21734. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  21735. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  21736. MedType string `json:"med_type"`
  21737. SetlType string `json:"setl_type,omitempty"`
  21738. ClrType string `json:"clr_type,omitempty"`
  21739. ClrWay string `json:"clr_way,omitempty"`
  21740. PsnSetlway string `json:"psn_setlway,omitempty"`
  21741. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  21742. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  21743. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  21744. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  21745. InscpAmt float64 `json:"inscp_amt,omitempty"`
  21746. DedcStd float64 `json:"dedc_std,omitempty"`
  21747. CrtDedc float64 `json:"crt_dedc,omitempty"`
  21748. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  21749. HifpPay float64 `json:"hifp_pay,omitempty"`
  21750. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  21751. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  21752. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  21753. HifesPay float64 `json:"hifes_pay,omitempty"`
  21754. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  21755. HifobPay float64 `json:"hifob_pay,omitempty"`
  21756. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  21757. MafPay float64 `json:"maf_pay,omitempty"`
  21758. OthfundPay float64 `json:"othfund_pay,omitempty"`
  21759. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  21760. PsnPay float64 `json:"psn_pay,omitempty"`
  21761. AcctPay float64 `json:"acct_pay,omitempty"`
  21762. CashPayamt float64 `json:"cash_payamt,omitempty"`
  21763. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  21764. Balc float64 `json:"balc,omitempty"`
  21765. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  21766. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  21767. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  21768. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  21769. Year string `json:"year,omitempty"`
  21770. DiseNo string `json:"dise_no,omitempty"`
  21771. DiseName string `json:"dise_name,omitempty"`
  21772. Invono string `json:"invono,omitempty"`
  21773. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  21774. Memo string `json:"memo,omitempty"`
  21775. UpdtTime string `json:"updt_time,omitempty"`
  21776. OpterID string `json:"opter_id,omitempty"`
  21777. OpterName string `json:"opter_name,omitempty"`
  21778. OptTime string `json:"opt_time,omitempty"`
  21779. OptinsNo string `json:"optins_no,omitempty"`
  21780. PoolareaNo string `json:"poolarea_no,omitempty"`
  21781. } `json:"result"`
  21782. } `json:"output"`
  21783. RefmsgTime string `json:"refmsg_time"`
  21784. RespondTime string `json:"respond_time"`
  21785. Signtype interface{} `json:"signtype"`
  21786. WarnInfo interface{} `json:"warn_info"`
  21787. }
  21788. // type Autogenerated struct {
  21789. // Output struct {
  21790. // Setlinfo struct {
  21791. // SetlTime string `json:"setl_time"`
  21792. // CvlservPay float64 `json:"cvlserv_pay"`
  21793. // Year string `json:"year"`
  21794. // MedType string `json:"med_type"`
  21795. // PsnPay float64 `json:"psn_pay"`
  21796. // OpterID string `json:"opter_id"`
  21797. // Begndate string `json:"begndate"`
  21798. // FlxempeFlag string `json:"flxempe_flag"`
  21799. // HifmiPay float64 `json:"hifmi_pay"`
  21800. // PsnNo string `json:"psn_no"`
  21801. // ActPayDedc float64 `json:"act_pay_dedc"`
  21802. // MedinsSetlID interface{} `json:"medins_setl_id"`
  21803. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21804. // ClrWay string `json:"clr_way"`
  21805. // OthPay float64 `json:"oth_pay"`
  21806. // Gend string `json:"gend"`
  21807. // MdtrtID string `json:"mdtrt_id"`
  21808. // AcctPay float64 `json:"acct_pay"`
  21809. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  21810. // Insutype string `json:"insutype"`
  21811. // Invono interface{} `json:"invono"`
  21812. // Enddate string `json:"enddate"`
  21813. // CashPayamt float64 `json:"cash_payamt"`
  21814. // PsnType string `json:"psn_type"`
  21815. // FixmedinsName string `json:"fixmedins_name"`
  21816. // HifpPay float64 `json:"hifp_pay"`
  21817. // NewFlag interface{} `json:"new_flag"`
  21818. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21819. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  21820. // PayLoc string `json:"pay_loc"`
  21821. // ClrType string `json:"clr_type"`
  21822. // RefdSetlFlag string `json:"refd_setl_flag"`
  21823. // CvlservFlag string `json:"cvlserv_flag"`
  21824. // EmpName string `json:"emp_name"`
  21825. // Brdy string `json:"brdy"`
  21826. // Naty string `json:"naty"`
  21827. // Certno string `json:"certno"`
  21828. // DiseCode string `json:"dise_code"`
  21829. // FixmedinsCode string `json:"fixmedins_code"`
  21830. // DedcHospLv string `json:"dedc_hosp_lv"`
  21831. // OpterName string `json:"opter_name"`
  21832. // Balc float64 `json:"balc"`
  21833. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21834. // PsnCertType string `json:"psn_cert_type"`
  21835. // HifobPay float64 `json:"hifob_pay"`
  21836. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  21837. // HifesPay float64 `json:"hifes_pay"`
  21838. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21839. // OptTime string `json:"opt_time"`
  21840. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21841. // SetlID string `json:"setl_id"`
  21842. // MafPay float64 `json:"maf_pay"`
  21843. // PsnName string `json:"psn_name"`
  21844. // InsuOptins interface{} `json:"insu_optins"`
  21845. // PrefFundPay interface{} `json:"pref_fund_pay"`
  21846. // ClrOptins string `json:"clr_optins"`
  21847. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21848. // DiseName string `json:"dise_name"`
  21849. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  21850. // Age float64 `json:"age"`
  21851. // DtrtCertType string `json:"dtrt_cert_type"`
  21852. // HospLv string `json:"hosp_lv"`
  21853. // } `json:"setlinfo"`
  21854. // Setldetail []struct {
  21855. // FundPayType string `json:"fund_pay_type"`
  21856. // FundPayamt float64 `json:"fund_payamt"`
  21857. // SetlProcInfo interface{} `json:"setl_proc_info"`
  21858. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  21859. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  21860. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  21861. // PrefFundPay interface{} `json:"pref_fund_pay"`
  21862. // } `json:"setldetail"`
  21863. // } `json:"output"`
  21864. // Infcode int `json:"infcode"`
  21865. // WarnMsg interface{} `json:"warn_msg"`
  21866. // Cainfo interface{} `json:"cainfo"`
  21867. // ErrMsg interface{} `json:"err_msg"`
  21868. // RefmsgTime string `json:"refmsg_time"`
  21869. // Signtype interface{} `json:"signtype"`
  21870. // RespondTime string `json:"respond_time"`
  21871. // InfRefmsgid string `json:"inf_refmsgid"`
  21872. // }
  21873. type Result002 struct {
  21874. Cainfo interface{} `json:"cainfo"`
  21875. ErrMsg string `json:"err_msg"`
  21876. InfRefmsgid string `json:"inf_refmsgid"`
  21877. Infcode int64 `json:"infcode"`
  21878. Output struct {
  21879. RxFile string `json:"rx_file"`
  21880. SignDigest string `json:"sign_digest"`
  21881. SignCertSn string `json:"sign_cert_sn"`
  21882. SignCertDn string `json:"sign_cert_dn"`
  21883. } `json:"output"`
  21884. RefmsgTime string `json:"refmsg_time"`
  21885. RespondTime string `json:"respond_time"`
  21886. Signtype interface{} `json:"signtype"`
  21887. WarnMsg interface{} `json:"warn_msg"`
  21888. }
  21889. type Result003 struct {
  21890. Cainfo interface{} `json:"cainfo"`
  21891. ErrMsg string `json:"err_msg"`
  21892. InfRefmsgid string `json:"inf_refmsgid"`
  21893. Infcode int64 `json:"infcode"`
  21894. Output struct {
  21895. HiRxno string `json:"hi_rxno"`
  21896. RxStasCodg string `json:"rx_stas_codg"`
  21897. RxStasName string `json:"rx_stas_name"`
  21898. } `json:"output"`
  21899. RefmsgTime string `json:"refmsg_time"`
  21900. RespondTime string `json:"respond_time"`
  21901. Signtype interface{} `json:"signtype"`
  21902. WarnMsg interface{} `json:"warn_msg"`
  21903. }
  21904. type ResultEleven struct {
  21905. Cainfo string `json:"cainfo"`
  21906. ErrMsg string `json:"err_msg"`
  21907. InfRefmsgid string `json:"inf_refmsgid"`
  21908. Infcode int64 `json:"infcode"`
  21909. Output struct {
  21910. Setlinfo struct {
  21911. SetlTime string `json:"setl_time"`
  21912. CvlservPay float64 `json:"cvlserv_pay"`
  21913. Year string `json:"year"`
  21914. MedType string `json:"med_type"`
  21915. PsnPay float64 `json:"psn_pay"`
  21916. OpterID string `json:"opter_id"`
  21917. Begndate string `json:"begndate"`
  21918. FlxempeFlag string `json:"flxempe_flag"`
  21919. HifmiPay float64 `json:"hifmi_pay"`
  21920. PsnNo string `json:"psn_no"`
  21921. ActPayDedc float64 `json:"act_pay_dedc"`
  21922. MedinsSetlID interface{} `json:"medins_setl_id"`
  21923. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21924. ClrWay string `json:"clr_way"`
  21925. OthPay float64 `json:"oth_pay"`
  21926. Gend string `json:"gend"`
  21927. MdtrtID string `json:"mdtrt_id"`
  21928. AcctPay float64 `json:"acct_pay"`
  21929. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21930. Insutype string `json:"insutype"`
  21931. Invono interface{} `json:"invono"`
  21932. Enddate string `json:"enddate"`
  21933. CashPayamt float64 `json:"cash_payamt"`
  21934. PsnType string `json:"psn_type"`
  21935. FixmedinsName string `json:"fixmedins_name"`
  21936. HifpPay float64 `json:"hifp_pay"`
  21937. NewFlag interface{} `json:"new_flag"`
  21938. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21939. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21940. PayLoc string `json:"pay_loc"`
  21941. ClrType string `json:"clr_type"`
  21942. RefdSetlFlag string `json:"refd_setl_flag"`
  21943. CvlservFlag string `json:"cvlserv_flag"`
  21944. EmpName string `json:"emp_name"`
  21945. Brdy string `json:"brdy"`
  21946. Naty string `json:"naty"`
  21947. Certno string `json:"certno"`
  21948. DiseCode string `json:"dise_code"`
  21949. FixmedinsCode string `json:"fixmedins_code"`
  21950. DedcHospLv string `json:"dedc_hosp_lv"`
  21951. OpterName string `json:"opter_name"`
  21952. Balc float64 `json:"balc"`
  21953. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21954. PsnCertType string `json:"psn_cert_type"`
  21955. HifobPay float64 `json:"hifob_pay"`
  21956. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21957. HifesPay float64 `json:"hifes_pay"`
  21958. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21959. OptTime string `json:"opt_time"`
  21960. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21961. SetlID string `json:"setl_id"`
  21962. MafPay float64 `json:"maf_pay"`
  21963. PsnName string `json:"psn_name"`
  21964. InsuOptins interface{} `json:"insu_optins"`
  21965. PrefFundPay interface{} `json:"pref_fund_pay"`
  21966. ClrOptins string `json:"clr_optins"`
  21967. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21968. DiseName string `json:"dise_name"`
  21969. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  21970. Age float64 `json:"age"`
  21971. DtrtCertType string `json:"dtrt_cert_type"`
  21972. HospLv string `json:"hosp_lv"`
  21973. PsnCashPay float64 `json:"psn_cash_pay"`
  21974. } `json:"setlinfo"`
  21975. } `json:"output"`
  21976. RefmsgTime string `json:"refmsg_time"`
  21977. RespondTime string `json:"respond_time"`
  21978. Signtype interface{} `json:"signtype"`
  21979. WarnMsg interface{} `json:"warn_msg"`
  21980. }
  21981. type ResultElevenah struct {
  21982. Cainfo string `json:"cainfo"`
  21983. ErrMsg string `json:"err_msg"`
  21984. InfRefmsgid string `json:"inf_refmsgid"`
  21985. Infcode int64 `json:"infcode"`
  21986. Output struct {
  21987. Setlinfo struct {
  21988. SetlTime int64 `json:"setl_time"`
  21989. CvlservPay float64 `json:"cvlserv_pay"`
  21990. Year string `json:"year"`
  21991. MedType string `json:"med_type"`
  21992. PsnPay float64 `json:"psn_pay"`
  21993. OpterID string `json:"opter_id"`
  21994. Begndate int64 `json:"begndate"`
  21995. FlxempeFlag string `json:"flxempe_flag"`
  21996. HifmiPay float64 `json:"hifmi_pay"`
  21997. PsnNo string `json:"psn_no"`
  21998. ActPayDedc float64 `json:"act_pay_dedc"`
  21999. MedinsSetlID interface{} `json:"medins_setl_id"`
  22000. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22001. ClrWay string `json:"clr_way"`
  22002. OthPay float64 `json:"oth_pay"`
  22003. Gend string `json:"gend"`
  22004. MdtrtID string `json:"mdtrt_id"`
  22005. AcctPay float64 `json:"acct_pay"`
  22006. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22007. Insutype string `json:"insutype"`
  22008. Invono interface{} `json:"invono"`
  22009. Enddate int64 `json:"enddate"`
  22010. CashPayamt float64 `json:"cash_payamt"`
  22011. PsnType string `json:"psn_type"`
  22012. FixmedinsName string `json:"fixmedins_name"`
  22013. HifpPay float64 `json:"hifp_pay"`
  22014. NewFlag interface{} `json:"new_flag"`
  22015. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22016. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22017. PayLoc string `json:"pay_loc"`
  22018. ClrType string `json:"clr_type"`
  22019. RefdSetlFlag string `json:"refd_setl_flag"`
  22020. CvlservFlag string `json:"cvlserv_flag"`
  22021. EmpName string `json:"emp_name"`
  22022. Brdy int64 `json:"brdy"`
  22023. Naty string `json:"naty"`
  22024. Certno string `json:"certno"`
  22025. DiseCode string `json:"dise_code"`
  22026. FixmedinsCode string `json:"fixmedins_code"`
  22027. DedcHospLv string `json:"dedc_hosp_lv"`
  22028. OpterName string `json:"opter_name"`
  22029. Balc float64 `json:"balc"`
  22030. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22031. PsnCertType string `json:"psn_cert_type"`
  22032. HifobPay float64 `json:"hifob_pay"`
  22033. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22034. HifesPay float64 `json:"hifes_pay"`
  22035. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22036. OptTime int64 `json:"opt_time"`
  22037. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22038. SetlID string `json:"setl_id"`
  22039. MafPay float64 `json:"maf_pay"`
  22040. PsnName string `json:"psn_name"`
  22041. InsuOptins interface{} `json:"insu_optins"`
  22042. PrefFundPay interface{} `json:"pref_fund_pay"`
  22043. ClrOptins string `json:"clr_optins"`
  22044. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22045. DiseName string `json:"dise_name"`
  22046. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22047. Age float64 `json:"age"`
  22048. DtrtCertType string `json:"dtrt_cert_type"`
  22049. HospLv string `json:"hosp_lv"`
  22050. PsnCashPay float64 `json:"psn_cash_pay"`
  22051. } `json:"setlinfo"`
  22052. } `json:"output"`
  22053. RefmsgTime string `json:"refmsg_time"`
  22054. RespondTime string `json:"respond_time"`
  22055. Signtype interface{} `json:"signtype"`
  22056. WarnMsg interface{} `json:"warn_msg"`
  22057. }
  22058. type ResultEleven10265 struct {
  22059. Cainfo string `json:"cainfo"`
  22060. ErrMsg string `json:"err_msg"`
  22061. InfRefmsgid string `json:"inf_refmsgid"`
  22062. Infcode string `json:"infcode"`
  22063. Output struct {
  22064. Setlinfo struct {
  22065. SetlTime string `json:"setl_time"`
  22066. CvlservPay float64 `json:"cvlserv_pay"`
  22067. Year string `json:"year"`
  22068. MedType string `json:"med_type"`
  22069. PsnPay float64 `json:"psn_pay"`
  22070. OpterID string `json:"opter_id"`
  22071. Begndate string `json:"begndate"`
  22072. FlxempeFlag string `json:"flxempe_flag"`
  22073. HifmiPay float64 `json:"hifmi_pay"`
  22074. PsnNo string `json:"psn_no"`
  22075. ActPayDedc float64 `json:"act_pay_dedc"`
  22076. MedinsSetlID interface{} `json:"medins_setl_id"`
  22077. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22078. ClrWay string `json:"clr_way"`
  22079. OthPay float64 `json:"oth_pay"`
  22080. Gend string `json:"gend"`
  22081. MdtrtID string `json:"mdtrt_id"`
  22082. AcctPay float64 `json:"acct_pay"`
  22083. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22084. Insutype string `json:"insutype"`
  22085. Invono interface{} `json:"invono"`
  22086. Enddate string `json:"enddate"`
  22087. CashPayamt float64 `json:"cash_payamt"`
  22088. PsnType string `json:"psn_type"`
  22089. FixmedinsName string `json:"fixmedins_name"`
  22090. HifpPay float64 `json:"hifp_pay"`
  22091. NewFlag interface{} `json:"new_flag"`
  22092. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22093. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22094. PayLoc string `json:"pay_loc"`
  22095. ClrType string `json:"clr_type"`
  22096. RefdSetlFlag string `json:"refd_setl_flag"`
  22097. CvlservFlag string `json:"cvlserv_flag"`
  22098. EmpName string `json:"emp_name"`
  22099. Brdy string `json:"brdy"`
  22100. Naty string `json:"naty"`
  22101. Certno string `json:"certno"`
  22102. DiseCode string `json:"dise_code"`
  22103. FixmedinsCode string `json:"fixmedins_code"`
  22104. DedcHospLv string `json:"dedc_hosp_lv"`
  22105. OpterName string `json:"opter_name"`
  22106. Balc float64 `json:"balc"`
  22107. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22108. PsnCertType string `json:"psn_cert_type"`
  22109. HifobPay float64 `json:"hifob_pay"`
  22110. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22111. HifesPay float64 `json:"hifes_pay"`
  22112. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22113. OptTime string `json:"opt_time"`
  22114. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22115. SetlID string `json:"setl_id"`
  22116. MafPay float64 `json:"maf_pay"`
  22117. PsnName string `json:"psn_name"`
  22118. InsuOptins interface{} `json:"insu_optins"`
  22119. PrefFundPay interface{} `json:"pref_fund_pay"`
  22120. ClrOptins string `json:"clr_optins"`
  22121. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22122. DiseName string `json:"dise_name"`
  22123. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22124. Age float64 `json:"age"`
  22125. DtrtCertType string `json:"dtrt_cert_type"`
  22126. HospLv string `json:"hosp_lv"`
  22127. PsnCashPay float64 `json:"psn_cash_pay"`
  22128. } `json:"setlinfo"`
  22129. } `json:"output"`
  22130. RefmsgTime string `json:"refmsg_time"`
  22131. RespondTime string `json:"respond_time"`
  22132. Signtype interface{} `json:"signtype"`
  22133. WarnMsg interface{} `json:"warn_msg"`
  22134. }
  22135. type ResultTwelve struct {
  22136. Cainfo string `json:"cainfo"`
  22137. ErrMsg string `json:"err_msg"`
  22138. InfRefmsgid string `json:"inf_refmsgid"`
  22139. Infcode int64 `json:"infcode"`
  22140. Output struct {
  22141. MdtrtId string `json:"mdtrt_id"`
  22142. ChrgBchno string `json:"chrg_bchno"`
  22143. PsnNo string `json:"psn_no"`
  22144. } `json:"output"`
  22145. RefmsgTime string `json:"refmsg_time"`
  22146. RespondTime string `json:"respond_time"`
  22147. Signtype interface{} `json:"signtype"`
  22148. WarnMsg interface{} `json:"warn_msg"`
  22149. }
  22150. type ResultThirteen struct {
  22151. ErrMsg string `json:"err_msg"`
  22152. InfRefmsgid string `json:"inf_refmsgid"`
  22153. Infcode int64 `json:"infcode"`
  22154. Output struct {
  22155. Result struct {
  22156. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22157. } `json:"result"`
  22158. } `json:"output"`
  22159. RefmsgTime string `json:"refmsg_time"`
  22160. RespondTime string `json:"respond_time"`
  22161. Signtype interface{} `json:"signtype"`
  22162. WarnInfo interface{} `json:"warn_info"`
  22163. }
  22164. type ResultThirteen10265 struct {
  22165. ErrMsg string `json:"err_msg"`
  22166. InfRefmsgid string `json:"inf_refmsgid"`
  22167. Infcode string `json:"infcode"`
  22168. Output struct {
  22169. Result struct {
  22170. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22171. } `json:"result"`
  22172. } `json:"output"`
  22173. RefmsgTime string `json:"refmsg_time"`
  22174. RespondTime string `json:"respond_time"`
  22175. Signtype interface{} `json:"signtype"`
  22176. WarnInfo interface{} `json:"warn_info"`
  22177. }
  22178. type ResultFourteen struct {
  22179. ErrMsg string `json:"err_msg"`
  22180. InfRefmsgid string `json:"inf_refmsgid"`
  22181. Infcode int64 `json:"infcode"`
  22182. Output struct {
  22183. } `json:"output"`
  22184. RefmsgTime string `json:"refmsg_time"`
  22185. RespondTime string `json:"respond_time"`
  22186. Signtype interface{} `json:"signtype"`
  22187. WarnInfo interface{} `json:"warn_info"`
  22188. }
  22189. type ResultCFYLJG001 struct {
  22190. ErrMsg string `json:"err_msg"`
  22191. InfRefmsgid string `json:"inf_refmsgid"`
  22192. Infcode int64 `json:"infcode"`
  22193. Output struct {
  22194. RxTraceCode string `json:"rx_trace_code"`
  22195. HiRxno string `json:"hi_rxno"`
  22196. } `json:"output"`
  22197. RefmsgTime string `json:"refmsg_time"`
  22198. RespondTime string `json:"respond_time"`
  22199. Signtype interface{} `json:"signtype"`
  22200. WarnInfo interface{} `json:"warn_info"`
  22201. }
  22202. type ResultCFYLJG007 struct {
  22203. ErrMsg string `json:"err_msg"`
  22204. InfRefmsgid string `json:"inf_refmsgid"`
  22205. Infcode int64 `json:"infcode"`
  22206. Output struct {
  22207. HiRxno string `json:"hi_rxno"`
  22208. RxStasName string `json:"rx_stas_name"`
  22209. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22210. Seltdelts []interface{} `json:"seltdelts"`
  22211. RxUsedStasName string `json:"rx_used_stas_name"`
  22212. RxStasCodg string `json:"rx_stas_codg"`
  22213. } `json:"output"`
  22214. RefmsgTime string `json:"refmsg_time"`
  22215. RespondTime string `json:"respond_time"`
  22216. Signtype interface{} `json:"signtype"`
  22217. WarnInfo interface{} `json:"warn_info"`
  22218. }
  22219. type ResultCFYLJG002 struct {
  22220. ErrMsg string `json:"err_msg"`
  22221. InfRefmsgid string `json:"inf_refmsgid"`
  22222. Infcode int64 `json:"infcode"`
  22223. Output struct {
  22224. RxFile string `json:"rx_file"`
  22225. SignDigest string `json:"sign_digest"`
  22226. SignCertSn string `json:"sign_cert_sn"`
  22227. SignCertDn string `json:"sign_cert_dn"`
  22228. } `json:"output"`
  22229. RefmsgTime string `json:"refmsg_time"`
  22230. RespondTime string `json:"respond_time"`
  22231. Signtype interface{} `json:"signtype"`
  22232. WarnInfo interface{} `json:"warn_info"`
  22233. }
  22234. type ResultCFYLJG003 struct {
  22235. ErrMsg string `json:"err_msg"`
  22236. InfRefmsgid string `json:"inf_refmsgid"`
  22237. Infcode int64 `json:"infcode"`
  22238. Output struct {
  22239. HiRxno string `json:"hi_rxno"`
  22240. RxStasCodg string `json:"rx_stas_codg"`
  22241. RxStasName string `json:"rx_stas_name"`
  22242. } `json:"output"`
  22243. RefmsgTime string `json:"refmsg_time"`
  22244. RespondTime string `json:"respond_time"`
  22245. Signtype interface{} `json:"signtype"`
  22246. WarnInfo interface{} `json:"warn_info"`
  22247. }
  22248. type ResultCFYLJG004 struct {
  22249. ErrMsg string `json:"err_msg"`
  22250. InfRefmsgid string `json:"inf_refmsgid"`
  22251. Infcode int64 `json:"infcode"`
  22252. Output struct {
  22253. HiRxno string `json:"hi_rxno"`
  22254. RxStasCodg string `json:"rx_stas_codg"`
  22255. RxStasName string `json:"rx_stas_name"`
  22256. } `json:"output"`
  22257. RefmsgTime string `json:"refmsg_time"`
  22258. RespondTime string `json:"respond_time"`
  22259. Signtype interface{} `json:"signtype"`
  22260. WarnInfo interface{} `json:"warn_info"`
  22261. }
  22262. type ResultCFYLJG008 struct {
  22263. ErrMsg string `json:"err_msg"`
  22264. InfRefmsgid string `json:"inf_refmsgid"`
  22265. Infcode int64 `json:"infcode"`
  22266. Output struct {
  22267. PoolareaNo string `json:"poolareaNo"`
  22268. AdmdvsName string `json:"admdvsName"`
  22269. Count string `json:"count"`
  22270. } `json:"output"`
  22271. RefmsgTime string `json:"refmsg_time"`
  22272. RespondTime string `json:"respond_time"`
  22273. Signtype interface{} `json:"signtype"`
  22274. WarnInfo interface{} `json:"warn_info"`
  22275. }
  22276. type ResultCFYLJG005 struct {
  22277. ErrMsg string `json:"err_msg"`
  22278. InfRefmsgid string `json:"inf_refmsgid"`
  22279. Infcode int64 `json:"infcode"`
  22280. Output struct {
  22281. HiRxNo string `json:"hi_rxno"`
  22282. FixMedinsCode string `json:"fixmedins_code"`
  22283. FixMedinsName string `json:"fixmedins_name"`
  22284. RxStasCodg string `json:"rx_stas_codg"`
  22285. RxStasName string `json:"rx_stas_name"`
  22286. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22287. RxUserdStasName string `json:"rx_userd_stas_name"`
  22288. PrscTime string `json:"prsc_time"`
  22289. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22290. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22291. RxUsedWayName string `json:"rx_used_way_name"`
  22292. RxFrquCodg string `json:"rx_frqu_codg"`
  22293. RxFrquName string `json:"rx_frqu_name"`
  22294. RxDosunt string `json:"rx_dosunt"`
  22295. RxDoscnt float64 `json:"rx_doscnt"`
  22296. RxDrordDscr string `json:"rx_drord_dscr"`
  22297. ValiDays int64 `json:"vali_days"`
  22298. ValiEndTime string `json:"vali_end_time"`
  22299. ReptFlag string `json:"rept_flag"`
  22300. MaxReptCnt int64 `json:"max_rept_cnt"`
  22301. ReptdCnt int64 `json:"reptd_cnt"`
  22302. MinInrvDays int64 `json:"min_inrv_days"`
  22303. RxTypeCode string `json:"rx_type_code"`
  22304. RxTypeName string `json:"rx_type_name"`
  22305. LongRxFlag string `json:"long_rx_flag"`
  22306. RxDetlList []struct {
  22307. MedListCodg string `json:"med_list_codg"`
  22308. MedinsListCodg string `json:"medins_list_codg"`
  22309. HospPrepFlag string `json:"hosp_prep_flag"`
  22310. RxItemTypeCode string `json:"rx_item_type_code"`
  22311. RxItemTypeName string `json:"rx_item_type_name"`
  22312. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22313. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22314. TcmHerbFoote string `json:"tcmherb_foote"`
  22315. MednTypeCode string `json:"medn_type_code"`
  22316. MednTypeName string `json:"medn_type_name"`
  22317. MainMedcFlag string `json:"main_medc_flag"`
  22318. UrgtFlag string `json:"urgt_flag"`
  22319. BasMednFlag string `json:"bas_medn_flag"`
  22320. ImpDrugFlag string `json:"imp_drug_flag"`
  22321. ProdBarc string `json:"prod_barc"`
  22322. DrugProdname string `json:"drug_prodname"`
  22323. GennameCodg string `json:"genname_codg"`
  22324. DrugGenname string `json:"drug_genname"`
  22325. DrugDosform string `json:"drug_dosform"`
  22326. DrugSpec string `json:"drug_spec"`
  22327. PrdrName string `json:"prdr_name"`
  22328. MedcWayCodg string `json:"medc_way_codg"`
  22329. MedcWayDscr string `json:"medc_way_dscr"`
  22330. MedcBegntime string `json:"medc_begntime"`
  22331. MedcEndtime string `json:"medc_endtime"`
  22332. MedcDays float64 `json:"medc_days"`
  22333. DrugPric float64 `json:"drug_pric"`
  22334. DrugSumamt float64 `json:"drug_sumamt"`
  22335. DrugCnt float64 `json:"drug_cnt"`
  22336. DrugDosunt string `json:"drug_dosunt"`
  22337. SinDoscnt float64 `json:"sin_doscnt"`
  22338. SinDosunt string `json:"sin_dosunt"`
  22339. UsedFrquCodg string `json:"used_frqu_codg"`
  22340. UsedFrquName string `json:"used_frqu_name"`
  22341. DrugTotlcnt string `json:"drug_totlcnt"`
  22342. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22343. DiseCodg string `json:"dise_codg"`
  22344. HospApprFlag string `json:"hosp_appr_flag"`
  22345. } `json:"rx_detl_list"`
  22346. RxOtpinfo struct {
  22347. MedType string `json:"med_type"`
  22348. IptOtpNo string `json:"ipt_otp_no"`
  22349. OtpIptFlag string `json:"otp_ipt_flag"`
  22350. PatnName string `json:"patn_name"`
  22351. PatnAge float64 `json:"patn_age"`
  22352. PatnHgt float64 `json:"patn_hgt"`
  22353. PatnWt float64 `json:"patn_wt"`
  22354. Gend string `json:"gend"`
  22355. GesoVal float64 `json:"geso_val"`
  22356. NwbFlag string `json:"nwb_flag"`
  22357. NwbAge string `json:"nwb_age"`
  22358. SuckPrdFlag string `json:"suck_prd_flag"`
  22359. AlgsHis string `json:"algs_his"`
  22360. Insutype string `json:"insutype"`
  22361. PrscDeptName string `json:"prsc_dept_name"`
  22362. PrscDrName string `json:"prsc_dr_name"`
  22363. PharName string `json:"phar_name"`
  22364. PharChkTime string `json:"phar_chk_time"`
  22365. MdtrtTime string `json:"mdtrt_time"`
  22366. DiseCodg string `json:"dise_codg"`
  22367. DiseName string `json:"dise_name"`
  22368. SpDiseFlag string `json:"sp_dise_flag"`
  22369. MaindiagCode string `json:"maindiag_code"`
  22370. MaindiagName string `json:"maindiag_name"`
  22371. DiseCondDscr string `json:"dise_cond_dscr"`
  22372. FstdiagFlag string `json:"fstdiag_flag"`
  22373. } `json:"rx_otpinfo"`
  22374. RxDiseList []struct {
  22375. DiagType string `json:"diag_type"`
  22376. MaindiagFlag string `json:"maindiag_flag"`
  22377. DiagSrtNo string `json:"diag_srt_no"`
  22378. DiagCode string `json:"diag_code"`
  22379. DiagName string `json:"diag_name"`
  22380. DiagDept string `json:"diag_dept"`
  22381. DiagDrNo string `json:"diag_dr_no"`
  22382. DiagDrName string `json:"diag_dr_name"`
  22383. DiagTime string `json:"diag_time"`
  22384. TcmDiseCode string `json:"tcm_dise_code"`
  22385. TcmDiseName string `json:"tcm_dise_name"`
  22386. TcmSympCode string `json:"tcmsymp_code"`
  22387. TcmSymp string `json:"tcmsymp"`
  22388. } `json:"rx_dise_list"`
  22389. } `json:"output"`
  22390. RefmsgTime string `json:"refmsg_time"`
  22391. RespondTime string `json:"respond_time"`
  22392. Signtype interface{} `json:"signtype"`
  22393. WarnInfo interface{} `json:"warn_info"`
  22394. }
  22395. type ResultCFYLJG006 struct {
  22396. ErrMsg string `json:"err_msg"`
  22397. InfRefmsgid string `json:"inf_refmsgid"`
  22398. Infcode int64 `json:"infcode"`
  22399. Output struct {
  22400. HiRxNo string `json:"hi_rxno"`
  22401. PharCode string `json:"phar_code"`
  22402. PharName string `json:"phar_name"`
  22403. RxChkOpnn string `json:"rx_chk_opnn"`
  22404. RxChkTime string `json:"rx_chk_time"`
  22405. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22406. RxChkStasName string `json:"rx_chk_stas_name"`
  22407. RxStasCodg string `json:"rx_stas_codg"`
  22408. RxStasName string `json:"rx_stas_name"`
  22409. } `json:"output"`
  22410. RefmsgTime string `json:"refmsg_time"`
  22411. RespondTime string `json:"respond_time"`
  22412. Signtype interface{} `json:"signtype"`
  22413. WarnInfo interface{} `json:"warn_info"`
  22414. }
  22415. type ResultFourteen10265 struct {
  22416. ErrMsg string `json:"err_msg"`
  22417. InfRefmsgid string `json:"inf_refmsgid"`
  22418. Infcode string `json:"infcode"`
  22419. Output struct {
  22420. } `json:"output"`
  22421. RefmsgTime string `json:"refmsg_time"`
  22422. RespondTime string `json:"respond_time"`
  22423. Signtype interface{} `json:"signtype"`
  22424. WarnInfo interface{} `json:"warn_info"`
  22425. }
  22426. type ResultSixteen struct {
  22427. Cainfo string `json:"cainfo"`
  22428. ErrMsg string `json:"err_msg"`
  22429. InfRefmsgid string `json:"inf_refmsgid"`
  22430. Infcode int64 `json:"infcode"`
  22431. Output struct {
  22432. Setlinfo struct {
  22433. MdtrtID string `json:"mdtrt_id"`
  22434. SetlID string `json:"setl_id"`
  22435. ClrOptins string `json:"clr_optins"`
  22436. SetlTime string `json:"setl_time"`
  22437. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22438. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22439. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22440. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22441. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22442. ActPayDedc float64 `json:"act_pay_dedc"`
  22443. HifpPay float64 `json:"hifp_pay"`
  22444. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22445. Lfpay float64 `json:"selfpay"`
  22446. CvlservPay float64 `json:"cvlserv_pay"`
  22447. HifesPay float64 `json:"hifes_pay"`
  22448. HifmiPay float64 `json:"hifmi_pay"`
  22449. HifobPay float64 `json:"hifob_pay"`
  22450. MafPay float64 `json:"maf_pay"`
  22451. OthPay float64 `json:"oth_pay"`
  22452. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22453. PsnPartAmt float64 `json:"psn_part_amt"`
  22454. AcctPay float64 `json:"acct_pay"`
  22455. Balc float64 `json:"balc"`
  22456. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22457. HospPartAmt float64 `json:"hosp_part_amt"`
  22458. MedinsSetlID string `json:"medins_setl_id"`
  22459. PdnCashPay string `json:"pdn_cash_pay"`
  22460. } `json:"setlinfo"`
  22461. } `json:"output"`
  22462. RefmsgTime string `json:"refmsg_time"`
  22463. RespondTime string `json:"respond_time"`
  22464. Signtype interface{} `json:"signtype"`
  22465. WarnMsg interface{} `json:"warn_msg"`
  22466. }
  22467. type ResultSixteen10265 struct {
  22468. Cainfo string `json:"cainfo"`
  22469. ErrMsg string `json:"err_msg"`
  22470. InfRefmsgid string `json:"inf_refmsgid"`
  22471. Infcode string `json:"infcode"`
  22472. Output struct {
  22473. Setlinfo struct {
  22474. MdtrtID string `json:"mdtrt_id"`
  22475. SetlID string `json:"setl_id"`
  22476. ClrOptins string `json:"clr_optins"`
  22477. SetlTime string `json:"setl_time"`
  22478. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22479. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22480. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22481. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22482. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22483. ActPayDedc float64 `json:"act_pay_dedc"`
  22484. HifpPay float64 `json:"hifp_pay"`
  22485. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22486. Lfpay float64 `json:"selfpay"`
  22487. CvlservPay float64 `json:"cvlserv_pay"`
  22488. HifesPay float64 `json:"hifes_pay"`
  22489. HifmiPay float64 `json:"hifmi_pay"`
  22490. HifobPay float64 `json:"hifob_pay"`
  22491. MafPay float64 `json:"maf_pay"`
  22492. OthPay float64 `json:"oth_pay"`
  22493. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22494. PsnPartAmt float64 `json:"psn_part_amt"`
  22495. AcctPay float64 `json:"acct_pay"`
  22496. Balc float64 `json:"balc"`
  22497. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22498. HospPartAmt float64 `json:"hosp_part_amt"`
  22499. MedinsSetlID string `json:"medins_setl_id"`
  22500. PdnCashPay string `json:"pdn_cash_pay"`
  22501. } `json:"setlinfo"`
  22502. } `json:"output"`
  22503. RefmsgTime string `json:"refmsg_time"`
  22504. RespondTime string `json:"respond_time"`
  22505. Signtype interface{} `json:"signtype"`
  22506. WarnMsg interface{} `json:"warn_msg"`
  22507. }
  22508. type ResultSixteen10265Two struct {
  22509. Cainfo string `json:"cainfo"`
  22510. ErrMsg string `json:"err_msg"`
  22511. InfRefmsgid string `json:"inf_refmsgid"`
  22512. Infcode string `json:"infcode"`
  22513. Output struct {
  22514. Setlinfo interface{} `json:"setlinfo"`
  22515. } `json:"output"`
  22516. RefmsgTime string `json:"refmsg_time"`
  22517. RespondTime string `json:"respond_time"`
  22518. Signtype interface{} `json:"signtype"`
  22519. WarnMsg interface{} `json:"warn_msg"`
  22520. }
  22521. type ResultgzSixteen10265Two struct {
  22522. Cainfo string `json:"cainfo"`
  22523. ErrMsg string `json:"err_msg"`
  22524. InfRefmsgid string `json:"inf_refmsgid"`
  22525. Infcode int64 `json:"infcode"`
  22526. Output struct {
  22527. Setlinfo interface{} `json:"setlinfo"`
  22528. } `json:"output"`
  22529. RefmsgTime string `json:"refmsg_time"`
  22530. RespondTime string `json:"respond_time"`
  22531. Signtype interface{} `json:"signtype"`
  22532. WarnMsg interface{} `json:"warn_msg"`
  22533. }
  22534. type ResultSeventeen struct {
  22535. ErrMsg string `json:"err_msg"`
  22536. InfRefmsgid string `json:"inf_refmsgid"`
  22537. Infcode int64 `json:"infcode"`
  22538. Output struct {
  22539. SetlListId string `json:"setl_list_id"`
  22540. } `json:"output"`
  22541. RefmsgTime string `json:"refmsg_time"`
  22542. RespondTime string `json:"respond_time"`
  22543. Signtype string `json:"signtype"`
  22544. WarnInfo string `json:"warn_info"`
  22545. }
  22546. type ResultSeventeenOther struct {
  22547. ErrMsg string `json:"err_msg"`
  22548. InfRefmsgid string `json:"inf_refmsgid"`
  22549. Infcode string `json:"infcode"`
  22550. Output struct {
  22551. SetlListId string `json:"setl_list_id"`
  22552. } `json:"output"`
  22553. RefmsgTime string `json:"refmsg_time"`
  22554. RespondTime string `json:"respond_time"`
  22555. Signtype string `json:"signtype"`
  22556. WarnInfo string `json:"warn_info"`
  22557. }
  22558. type Result90991 struct {
  22559. ErrMsg string `json:"err_msg"`
  22560. InfRefmsgid string `json:"inf_refmsgid"`
  22561. Infcode int64 `json:"infcode"`
  22562. Output struct {
  22563. Result struct {
  22564. PsnNo string `json:"psn_no"`
  22565. CardStat string `json:"card_stat"`
  22566. Certno string `json:"certno"`
  22567. PsnName string `json:"psn_name"`
  22568. CheckStat string `json:"check_stat"`
  22569. SscnoCheckStat string `json:"sscno_check_stat"`
  22570. } `json:"result"`
  22571. } `json:"output"`
  22572. RefmsgTime string `json:"refmsg_time"`
  22573. RespondTime string `json:"respond_time"`
  22574. Signtype interface{} `json:"signtype"`
  22575. WarnInfo interface{} `json:"warn_info"`
  22576. }
  22577. type Result90100 struct {
  22578. ErrMsg string `json:"err_msg"`
  22579. InfRefmsgid string `json:"inf_refmsgid"`
  22580. Infcode int64 `json:"infcode"`
  22581. Output struct {
  22582. PoolareaNo string `json:"poolarea_no"`
  22583. PoolareaNoName string `json:"poolarea_no_name"`
  22584. Insutype string `json:"insutype"`
  22585. InsutypeName string `json:"insutype_name"`
  22586. ClctType string `json:"clct_type"`
  22587. ClctTypeName string `json:"clct_type_name"`
  22588. ClctFlag string `json:"clct_flag"`
  22589. ClctFlagName string `json:"clct_flag_name"`
  22590. AccrymBegn string `json:"accrym_begn"`
  22591. AccrymEnd string `json:"accrym_end"`
  22592. ClctTime string `json:"clct_time"`
  22593. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  22594. } `json:"output"`
  22595. RefmsgTime string `json:"refmsg_time"`
  22596. RespondTime string `json:"respond_time"`
  22597. Signtype interface{} `json:"signtype"`
  22598. WarnInfo interface{} `json:"warn_info"`
  22599. }
  22600. type Custom struct {
  22601. DetItemFeeSumamt string
  22602. Cut string
  22603. FeedetlSn string
  22604. Price string
  22605. MedListCodg string
  22606. Type int64
  22607. AdviceId int64
  22608. ProjectId int64
  22609. ItemId int64
  22610. }
  22611. type Result5301 struct {
  22612. ErrMsg string `json:"err_msg"`
  22613. InfRefmsgid string `json:"inf_refmsgid"`
  22614. Infcode int64 `json:"infcode"`
  22615. Output struct {
  22616. Result []struct {
  22617. OpspDiseCode string `json:"opsp_dise_code"`
  22618. OpspDiseName string `json:"opsp_dise_name"`
  22619. Begndate string `json:"begndate"`
  22620. Enddate string `json:"enddate"`
  22621. } `json:"feedetail"`
  22622. } `json:"output"`
  22623. RefmsgTime string `json:"refmsg_time"`
  22624. RespondTime string `json:"respond_time"`
  22625. Signtype interface{} `json:"signtype"`
  22626. WarnInfo interface{} `json:"warn_info"`
  22627. }
  22628. type Result5301For10265 struct {
  22629. ErrMsg string `json:"err_msg"`
  22630. InfRefmsgid string `json:"inf_refmsgid"`
  22631. Infcode string `json:"infcode"`
  22632. Output struct {
  22633. Result []struct {
  22634. OpspDiseCode string `json:"opsp_dise_code"`
  22635. OpspDiseName string `json:"opsp_dise_name"`
  22636. Begndate string `json:"begndate"`
  22637. Enddate string `json:"enddate"`
  22638. } `json:"feedetail"`
  22639. } `json:"output"`
  22640. RefmsgTime string `json:"refmsg_time"`
  22641. RespondTime string `json:"respond_time"`
  22642. Signtype interface{} `json:"signtype"`
  22643. WarnInfo interface{} `json:"warn_info"`
  22644. }
  22645. //获取个人信息----挂号-----上传就诊信息
  22646. func (c *HisApiController) GetRegisterInfo() {
  22647. id, _ := c.GetInt64("id")
  22648. record_time := c.GetString("record_time")
  22649. settlementValue, _ := c.GetInt64("settlement_value")
  22650. medical_insurance_card := c.GetString("medical_insurance_card")
  22651. name := c.GetString("name")
  22652. id_card_type, _ := c.GetInt64("id_card_type")
  22653. certificates, _ := c.GetInt64("certificates")
  22654. medical_care, _ := c.GetInt64("medical_care")
  22655. birthday := c.GetString("birthday")
  22656. id_card := c.GetString("id_card")
  22657. register_type, _ := c.GetInt64("register")
  22658. doctor, _ := c.GetInt64("doctor")
  22659. department, _ := c.GetInt64("department")
  22660. gender, _ := c.GetInt64("sex")
  22661. registration_fee, _ := c.GetFloat("registration_fee")
  22662. medical_expenses, _ := c.GetFloat("medical_expenses")
  22663. social_type, _ := c.GetInt64("social_type")
  22664. admin_user_id, _ := c.GetInt64("admin_user_id")
  22665. insuplc_admdvs := c.GetString("insuplc_admdvs")
  22666. mdtrt_type := c.GetString("mdtrt_type")
  22667. if id_card_type == 5 {
  22668. id_card_type = 4
  22669. }
  22670. timeLayout := "2006-01-02"
  22671. loc, _ := time.LoadLocation("Local")
  22672. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  22673. birthUnix := birthdays.Unix()
  22674. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  22675. if err != nil {
  22676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22677. return
  22678. }
  22679. recordDateTime := theTime.Unix()
  22680. adminInfo := c.GetAdminUserInfo()
  22681. var patient service.Patients
  22682. if id == 0 {
  22683. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  22684. } else {
  22685. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  22686. }
  22687. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  22688. if patientPrescription.ID == 0 {
  22689. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  22690. }
  22691. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22692. if patient.ID == 0 {
  22693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  22694. return
  22695. }
  22696. if len(patient.IdCardNo) == 0 {
  22697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  22698. return
  22699. }
  22700. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22701. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  22702. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  22703. //就诊结算未完成,不能进行二次挂号
  22704. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  22705. if len(his) >= 1 {
  22706. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  22707. if len(his) >= 1 && order.ID == 0 {
  22708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  22709. return
  22710. }
  22711. }
  22712. //var register_log string
  22713. if config.IsOpen == 1 {
  22714. var res ResultTwo
  22715. var res10265 ResultTwo10265
  22716. var PsnNo string
  22717. var PsnCertType string
  22718. var Certno string
  22719. var PsnName string
  22720. var Gend string
  22721. var Naty string
  22722. var Brdy string
  22723. var Age float64
  22724. var infoStr string
  22725. var idetinfoStr string
  22726. var infocode int64
  22727. var verify_number string
  22728. fmt.Println(verify_number)
  22729. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  22730. psn_info, _ := service.GetPsnByPatientId(id)
  22731. PsnNo = psn_info.PsnNo
  22732. PsnCertType = psn_info.PsnCertType
  22733. Certno = psn_info.Certno
  22734. PsnName = psn_info.PsnName
  22735. Gend = psn_info.Gend
  22736. Naty = psn_info.Naty
  22737. Brdy = psn_info.Brdy
  22738. Age = psn_info.Age
  22739. infoStr = psn_info.Insuinfo
  22740. idetinfoStr = psn_info.Idetinfo
  22741. infocode = 0
  22742. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22743. psn_info, _ := service.GetPsnByPatientId(id)
  22744. PsnNo = psn_info.PsnNo
  22745. PsnCertType = psn_info.PsnCertType
  22746. Certno = psn_info.Certno
  22747. PsnName = psn_info.PsnName
  22748. Gend = psn_info.Gend
  22749. Naty = psn_info.Naty
  22750. Brdy = psn_info.Brdy
  22751. Age = psn_info.Age
  22752. infoStr = psn_info.Insuinfo
  22753. idetinfoStr = psn_info.Idetinfo
  22754. infocode = 0
  22755. verify_number = psn_info.VerifyNumber
  22756. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22757. if id_card_type == 2 {
  22758. //请求内网数据
  22759. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  22760. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22761. "&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
  22762. resp, requestErr := http.Get(api)
  22763. if requestErr != nil {
  22764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22765. return
  22766. }
  22767. body, ioErr := ioutil.ReadAll(resp.Body)
  22768. if ioErr != nil {
  22769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22771. return
  22772. }
  22773. var respJSON map[string]interface{}
  22774. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22777. return
  22778. }
  22779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22780. result_byte, _ := json.Marshal(respJSON)
  22781. result := string(result_byte)
  22782. var dat map[string]interface{}
  22783. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22784. fmt.Println(dat)
  22785. } else {
  22786. fmt.Println(err)
  22787. }
  22788. userJSONBytes, _ := json.Marshal(dat)
  22789. var res ResultTwo
  22790. var resTwo10265 ResultTwo10265
  22791. if miConfig.Code == "H15049901371" {
  22792. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  22793. utils.ErrorLog("解析失败:%v", err)
  22794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22795. return
  22796. }
  22797. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  22798. res.Infcode = Infcode
  22799. res.ErrMsg = resTwo10265.ErrMsg
  22800. res.Output = resTwo10265.Output
  22801. res.InfRefmsgid = resTwo10265.InfRefmsgid
  22802. res.RespondTime = resTwo10265.RespondTime
  22803. res.WarnInfo = resTwo10265.WarnInfo
  22804. } else {
  22805. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22806. utils.ErrorLog("解析失败:%v", err)
  22807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22808. return
  22809. }
  22810. }
  22811. //var insutypes []string
  22812. //var insutype string
  22813. //var is390 int = 0
  22814. //var is310 int = 0
  22815. //for _, item := range res.Output.Iinfo {
  22816. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22817. // insutypes = append(insutypes, item.Insutype)
  22818. // }
  22819. //}
  22820. //if len(insutypes) == 1 {
  22821. // insutype = insutypes[0]
  22822. //} else {
  22823. // for _, i := range insutypes {
  22824. // if i == "390" {
  22825. // is390 = 1
  22826. // }
  22827. //
  22828. // if i == "310" {
  22829. // is310 = 1
  22830. // }
  22831. // }
  22832. //}
  22833. //if is390 == 1 {
  22834. // insutype = "390"
  22835. //}
  22836. //if is310 == 1 {
  22837. // insutype = "310"
  22838. //}
  22839. //if len(insutypes) == 0 {
  22840. // insutype = "310"
  22841. //}
  22842. PsnNo = res.Output.Baseinfo.PsnNo
  22843. PsnCertType = res.Output.Baseinfo.PsnCertType
  22844. Certno = res.Output.Baseinfo.Certno
  22845. PsnName = res.Output.Baseinfo.PsnName
  22846. Gend = res.Output.Baseinfo.Gend
  22847. Naty = res.Output.Baseinfo.Naty
  22848. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22849. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22850. infoStr = string(Iinfos)
  22851. idetinfoStr = string(Idetinfos)
  22852. infocode = res.Infcode
  22853. //infocode = 0
  22854. //verify_number = psn_info.VerifyNumber
  22855. } else {
  22856. psn_info, _ := service.GetPsnByPatientId(id)
  22857. PsnNo = psn_info.PsnNo
  22858. PsnCertType = psn_info.PsnCertType
  22859. Certno = psn_info.Certno
  22860. PsnName = psn_info.PsnName
  22861. Gend = psn_info.Gend
  22862. Naty = psn_info.Naty
  22863. Brdy = psn_info.Brdy
  22864. Age = psn_info.Age
  22865. infoStr = psn_info.Insuinfo
  22866. idetinfoStr = psn_info.Idetinfo
  22867. infocode = 0
  22868. verify_number = psn_info.VerifyNumber
  22869. }
  22870. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22871. if id_card_type == 1 {
  22872. psn_info, _ := service.GetPsnByPatientId(id)
  22873. PsnNo = psn_info.PsnNo
  22874. PsnCertType = psn_info.PsnCertType
  22875. Certno = psn_info.Certno
  22876. PsnName = psn_info.PsnName
  22877. Gend = psn_info.Gend
  22878. Naty = psn_info.Naty
  22879. Brdy = psn_info.Brdy
  22880. Age = psn_info.Age
  22881. infoStr = psn_info.Insuinfo
  22882. idetinfoStr = psn_info.Idetinfo
  22883. infocode = 0
  22884. verify_number = psn_info.VerifyNumber
  22885. } else if id_card_type == 2 {
  22886. 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)
  22887. fmt.Println(errMsgLog)
  22888. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22889. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22890. utils.ErrorLog("解析失败:%v", err)
  22891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22892. return
  22893. }
  22894. PsnNo = res.Output.Baseinfo.PsnNo
  22895. PsnCertType = res.Output.Baseinfo.PsnCertType
  22896. Certno = res.Output.Baseinfo.Certno
  22897. PsnName = res.Output.Baseinfo.PsnName
  22898. Gend = res.Output.Baseinfo.Gend
  22899. Naty = res.Output.Baseinfo.Naty
  22900. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22901. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22902. infoStr = string(Iinfos)
  22903. idetinfoStr = string(Idetinfos)
  22904. infocode = res.Infcode
  22905. }
  22906. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22907. if id_card_type == 1 {
  22908. psn_info, _ := service.GetPsnByPatientId(id)
  22909. PsnNo = psn_info.PsnNo
  22910. PsnCertType = psn_info.PsnCertType
  22911. Certno = psn_info.Certno
  22912. PsnName = psn_info.PsnName
  22913. Gend = psn_info.Gend
  22914. Naty = psn_info.Naty
  22915. Brdy = psn_info.Brdy
  22916. Age = psn_info.Age
  22917. infoStr = psn_info.Insuinfo
  22918. idetinfoStr = psn_info.Idetinfo
  22919. infocode = 0
  22920. verify_number = psn_info.VerifyNumber
  22921. } else if id_card_type == 2 {
  22922. 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, "")
  22923. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22924. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22925. utils.ErrorLog("解析失败:%v", err)
  22926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22927. return
  22928. }
  22929. PsnNo = res.Output.Baseinfo.PsnNo
  22930. PsnCertType = res.Output.Baseinfo.PsnCertType
  22931. Certno = res.Output.Baseinfo.Certno
  22932. PsnName = res.Output.Baseinfo.PsnName
  22933. Gend = res.Output.Baseinfo.Gend
  22934. Naty = res.Output.Baseinfo.Naty
  22935. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22936. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22937. infoStr = string(Iinfos)
  22938. idetinfoStr = string(Idetinfos)
  22939. infocode = res.Infcode
  22940. } else {
  22941. psn_info, _ := service.GetPsnByPatientId(id)
  22942. PsnNo = psn_info.PsnNo
  22943. PsnCertType = psn_info.PsnCertType
  22944. Certno = psn_info.Certno
  22945. PsnName = psn_info.PsnName
  22946. Gend = psn_info.Gend
  22947. Naty = psn_info.Naty
  22948. Brdy = psn_info.Brdy
  22949. Age = psn_info.Age
  22950. infoStr = psn_info.Insuinfo
  22951. idetinfoStr = psn_info.Idetinfo
  22952. infocode = 0
  22953. verify_number = psn_info.VerifyNumber
  22954. }
  22955. } else if miConfig.MdtrtareaAdmvs == "361025" {
  22956. if id_card_type == 1 {
  22957. psn_info, _ := service.GetPsnByPatientId(id)
  22958. PsnNo = psn_info.PsnNo
  22959. PsnCertType = psn_info.PsnCertType
  22960. Certno = psn_info.Certno
  22961. PsnName = psn_info.PsnName
  22962. Gend = psn_info.Gend
  22963. Naty = psn_info.Naty
  22964. Brdy = psn_info.Brdy
  22965. Age = psn_info.Age
  22966. infoStr = psn_info.Insuinfo
  22967. idetinfoStr = psn_info.Idetinfo
  22968. infocode = 0
  22969. verify_number = psn_info.VerifyNumber
  22970. } else if id_card_type == 2 {
  22971. psn_info, _ := service.GetPsnByPatientId(id)
  22972. PsnNo = psn_info.PsnNo
  22973. PsnCertType = psn_info.PsnCertType
  22974. Certno = psn_info.Certno
  22975. PsnName = psn_info.PsnName
  22976. Gend = psn_info.Gend
  22977. Naty = psn_info.Naty
  22978. Brdy = psn_info.Brdy
  22979. Age = psn_info.Age
  22980. infoStr = psn_info.Insuinfo
  22981. idetinfoStr = psn_info.Idetinfo
  22982. infocode = 0
  22983. verify_number = psn_info.VerifyNumber
  22984. } else {
  22985. psn_info, _ := service.GetPsnByPatientId(id)
  22986. PsnNo = psn_info.PsnNo
  22987. PsnCertType = psn_info.PsnCertType
  22988. Certno = psn_info.Certno
  22989. PsnName = psn_info.PsnName
  22990. Gend = psn_info.Gend
  22991. Naty = psn_info.Naty
  22992. Brdy = psn_info.Brdy
  22993. Age = psn_info.Age
  22994. infoStr = psn_info.Insuinfo
  22995. idetinfoStr = psn_info.Idetinfo
  22996. infocode = 0
  22997. verify_number = psn_info.VerifyNumber
  22998. }
  22999. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23000. psn_info, _ := service.GetPsnByPatientId(id)
  23001. PsnNo = psn_info.PsnNo
  23002. PsnCertType = psn_info.PsnCertType
  23003. Certno = psn_info.Certno
  23004. PsnName = psn_info.PsnName
  23005. Gend = psn_info.Gend
  23006. Naty = psn_info.Naty
  23007. Brdy = psn_info.Brdy
  23008. Age = psn_info.Age
  23009. infoStr = psn_info.Insuinfo
  23010. idetinfoStr = psn_info.Idetinfo
  23011. infocode = 0
  23012. verify_number = psn_info.VerifyNumber
  23013. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23014. if id_card_type == 1 {
  23015. psn_info, _ := service.GetPsnByPatientId(id)
  23016. PsnNo = psn_info.PsnNo
  23017. PsnCertType = psn_info.PsnCertType
  23018. Certno = psn_info.Certno
  23019. PsnName = psn_info.PsnName
  23020. Gend = psn_info.Gend
  23021. Naty = psn_info.Naty
  23022. Brdy = psn_info.Brdy
  23023. Age = psn_info.Age
  23024. infoStr = psn_info.Insuinfo
  23025. idetinfoStr = psn_info.Idetinfo
  23026. infocode = 0
  23027. verify_number = psn_info.VerifyNumber
  23028. } else if id_card_type == 2 {
  23029. 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)
  23030. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23031. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23032. utils.ErrorLog("解析失败:%v", err)
  23033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23034. return
  23035. }
  23036. PsnNo = res.Output.Baseinfo.PsnNo
  23037. PsnCertType = res.Output.Baseinfo.PsnCertType
  23038. Certno = res.Output.Baseinfo.Certno
  23039. PsnName = res.Output.Baseinfo.PsnName
  23040. Gend = res.Output.Baseinfo.Gend
  23041. Naty = res.Output.Baseinfo.Naty
  23042. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23043. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23044. infoStr = string(Iinfos)
  23045. idetinfoStr = string(Idetinfos)
  23046. infocode = res.Infcode
  23047. } else if id_card_type == 4 {
  23048. psn_info, _ := service.GetPsnByPatientId(id)
  23049. PsnNo = psn_info.PsnNo
  23050. PsnCertType = psn_info.PsnCertType
  23051. Certno = psn_info.Certno
  23052. PsnName = psn_info.PsnName
  23053. Gend = psn_info.Gend
  23054. Naty = psn_info.Naty
  23055. Brdy = psn_info.Brdy
  23056. Age = psn_info.Age
  23057. infoStr = psn_info.Insuinfo
  23058. idetinfoStr = psn_info.Idetinfo
  23059. infocode = 0
  23060. verify_number = psn_info.VerifyNumber
  23061. }
  23062. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23063. var result string
  23064. var requestLog string
  23065. 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), "")
  23066. if id_card_type == 4 {
  23067. psn_info, _ := service.GetPsnByPatientId(id)
  23068. PsnNo = psn_info.PsnNo
  23069. PsnCertType = psn_info.PsnCertType
  23070. Certno = psn_info.Certno
  23071. PsnName = psn_info.PsnName
  23072. Gend = psn_info.Gend
  23073. Naty = psn_info.Naty
  23074. Brdy = psn_info.Brdy
  23075. Age = psn_info.Age
  23076. infoStr = psn_info.Insuinfo
  23077. idetinfoStr = psn_info.Idetinfo
  23078. infocode = 0
  23079. verify_number = psn_info.VerifyNumber
  23080. } else {
  23081. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23082. if miConfig.Code == "H15049901371" {
  23083. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23084. utils.ErrorLog("解析失败:%v", err)
  23085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23086. return
  23087. }
  23088. res.ErrMsg = res10265.ErrMsg
  23089. res.Output = res10265.Output
  23090. res.InfRefmsgid = res10265.InfRefmsgid
  23091. } else {
  23092. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23093. utils.ErrorLog("解析失败:%v", err)
  23094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23095. return
  23096. }
  23097. }
  23098. PsnNo = res.Output.Baseinfo.PsnNo
  23099. PsnCertType = res.Output.Baseinfo.PsnCertType
  23100. Certno = res.Output.Baseinfo.Certno
  23101. PsnName = res.Output.Baseinfo.PsnName
  23102. Gend = res.Output.Baseinfo.Gend
  23103. Naty = res.Output.Baseinfo.Naty
  23104. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23105. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23106. infoStr = string(Iinfos)
  23107. idetinfoStr = string(Idetinfos)
  23108. if miConfig.Code == "H15049901371" {
  23109. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23110. } else {
  23111. infocode = res.Infcode
  23112. }
  23113. }
  23114. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23115. psn_info, _ := service.GetPsnByPatientId(id)
  23116. PsnNo = psn_info.PsnNo
  23117. PsnCertType = psn_info.PsnCertType
  23118. Certno = psn_info.Certno
  23119. PsnName = psn_info.PsnName
  23120. Gend = psn_info.Gend
  23121. Naty = psn_info.Naty
  23122. Brdy = psn_info.Brdy
  23123. Age = psn_info.Age
  23124. infoStr = psn_info.Insuinfo
  23125. idetinfoStr = psn_info.Idetinfo
  23126. infocode = 0
  23127. verify_number = psn_info.VerifyNumber
  23128. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23129. psn_info, _ := service.GetPsnByPatientId(id)
  23130. PsnNo = psn_info.PsnNo
  23131. PsnCertType = psn_info.PsnCertType
  23132. Certno = psn_info.Certno
  23133. PsnName = psn_info.PsnName
  23134. Gend = psn_info.Gend
  23135. Naty = psn_info.Naty
  23136. Brdy = psn_info.Brdy
  23137. Age = psn_info.Age
  23138. infoStr = psn_info.Insuinfo
  23139. idetinfoStr = psn_info.Idetinfo
  23140. infocode = 0
  23141. verify_number = psn_info.VerifyNumber
  23142. } else {
  23143. var result string
  23144. var requestLog string
  23145. //if miConfig.UserOrgId == 10138 {
  23146. if id_card_type != 4 || id_card_type != 1 {
  23147. var insa string
  23148. if len(patient.InsuplcAdmdvs) > 0 {
  23149. insa = patient.InsuplcAdmdvs
  23150. } else {
  23151. insa = miConfig.InsuplcAdmdvs
  23152. }
  23153. //psn_info, _ := service.GetPsnByPatientId(id)
  23154. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23155. 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)
  23156. }
  23157. //}
  23158. //else {
  23159. // var insa string
  23160. // if len(patient.InsuplcAdmdvs) > 0 {
  23161. // insa = patient.InsuplcAdmdvs
  23162. // } else {
  23163. // insa = miConfig.InsuplcAdmdvs
  23164. // }
  23165. // 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)
  23166. //}
  23167. if id_card_type == 4 || id_card_type == 1 {
  23168. psn_info, _ := service.GetPsnByPatientId(id)
  23169. PsnNo = psn_info.PsnNo
  23170. PsnCertType = psn_info.PsnCertType
  23171. Certno = psn_info.Certno
  23172. PsnName = psn_info.PsnName
  23173. Gend = psn_info.Gend
  23174. Naty = psn_info.Naty
  23175. Brdy = psn_info.Brdy
  23176. Age = psn_info.Age
  23177. infoStr = psn_info.Insuinfo
  23178. idetinfoStr = psn_info.Idetinfo
  23179. infocode = 0
  23180. verify_number = psn_info.VerifyNumber
  23181. } else {
  23182. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23183. if miConfig.Code == "H15049901371" {
  23184. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23185. utils.ErrorLog("解析失败:%v", err)
  23186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23187. return
  23188. }
  23189. res.ErrMsg = res10265.ErrMsg
  23190. res.Output = res10265.Output
  23191. res.InfRefmsgid = res10265.InfRefmsgid
  23192. } else {
  23193. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23194. utils.ErrorLog("解析失败:%v", err)
  23195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23196. return
  23197. }
  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. if miConfig.Code == "H15049901371" {
  23210. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23211. } else {
  23212. infocode = res.Infcode
  23213. }
  23214. }
  23215. }
  23216. if infocode == 0 {
  23217. his := models.VMHisPatient{
  23218. Name: name,
  23219. Gender: gender,
  23220. Birthday: birthUnix,
  23221. MedicalTreatmentType: medical_care,
  23222. IdType: certificates,
  23223. IdCardNo: id_card,
  23224. BalanceAccountsType: settlementValue,
  23225. SocialType: social_type,
  23226. MedicalInsuranceNumber: medical_insurance_card,
  23227. RegisterType: register_type,
  23228. RegisterCost: registration_fee,
  23229. TreatmentCost: medical_expenses,
  23230. Status: 1,
  23231. Ctime: time.Now().Unix(),
  23232. Mtime: time.Now().Unix(),
  23233. PsnNo: PsnNo,
  23234. PsnCertType: PsnCertType,
  23235. Certno: Certno,
  23236. PsnName: PsnName,
  23237. Gend: Gend,
  23238. Naty: Naty,
  23239. Brdy: Brdy,
  23240. Age: Age,
  23241. Iinfo: infoStr,
  23242. Idetinfo: idetinfoStr,
  23243. PatientId: patient.ID,
  23244. RecordDate: theTime.Unix(),
  23245. UserOrgId: adminInfo.CurrentOrgId,
  23246. AdminUserId: admin_user_id,
  23247. IsReturn: 1,
  23248. IdCardType: id_card_type,
  23249. Doctor: doctor,
  23250. Departments: department,
  23251. MdtrtGrpType: mdtrt_type,
  23252. }
  23253. timestamp := time.Now().Unix()
  23254. tempTime := time.Unix(timestamp, 0)
  23255. timeFormat := tempTime.Format("20060102150405")
  23256. chrgBchno := rand.Intn(100000) + 10000
  23257. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23258. his.Number = ipt_otp_no
  23259. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23260. department, _ := service.GetDepartMentDetail(department)
  23261. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23262. IdCardNo := ""
  23263. if id_card_type == 1 {
  23264. // IdCardNo = medical_insurance_card
  23265. IdCardNo = patient.IdCardNo
  23266. } else {
  23267. IdCardNo = patient.IdCardNo
  23268. }
  23269. var rf []*ResultFive
  23270. json.Unmarshal([]byte(his.Iinfo), &rf)
  23271. var insutypes []*ResultFive
  23272. var insutype string
  23273. var insuplc_admdvs_temp string
  23274. var is390 int = 0
  23275. var is310 int = 0
  23276. for _, item := range rf {
  23277. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23278. insutypes = append(insutypes, item)
  23279. }
  23280. }
  23281. if len(insutypes) == 1 {
  23282. insutype = insutypes[0].Insutype
  23283. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23284. if insutype == "390" {
  23285. is390 = 1
  23286. }
  23287. if insutype == "310" {
  23288. is310 = 1
  23289. }
  23290. } else {
  23291. for _, i := range insutypes {
  23292. if i.Insutype == "390" {
  23293. is390 = 1
  23294. }
  23295. if i.Insutype == "310" {
  23296. is310 = 1
  23297. }
  23298. }
  23299. }
  23300. if is390 == 1 {
  23301. insutype = "390"
  23302. }
  23303. if is310 == 1 {
  23304. insutype = "310"
  23305. }
  23306. fmt.Println(social_type)
  23307. if social_type > 0 {
  23308. insutype = strconv.FormatInt(social_type, 10)
  23309. }
  23310. var infocode int64
  23311. var resThree ResultThree
  23312. var resThree10265 ResultThree10265
  23313. if len(insuplc_admdvs) == 0 {
  23314. psn_info, _ := service.GetPsnByPatientId(id)
  23315. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23316. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23317. //}
  23318. } else {
  23319. insuplc_admdvs_temp = insuplc_admdvs
  23320. }
  23321. if miConfig.MdtrtareaAdmvs == "421300" {
  23322. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23323. psn_info, _ := service.GetPsnByPatientId(id)
  23324. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23325. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23326. "&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
  23327. resp, requestErr := http.Get(api)
  23328. if requestErr != nil {
  23329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23330. return
  23331. }
  23332. body, ioErr := ioutil.ReadAll(resp.Body)
  23333. if ioErr != nil {
  23334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23336. return
  23337. }
  23338. var respJSON map[string]interface{}
  23339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23342. return
  23343. }
  23344. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23345. result, _ := json.Marshal(respJSON)
  23346. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23347. utils.ErrorLog("解析失败:%v", err)
  23348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23349. return
  23350. }
  23351. infocode = resThree.Infcode
  23352. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23353. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23354. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23355. // insuplc_admdvs_temp =
  23356. //}
  23357. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23358. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23359. //}
  23360. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23361. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23362. "&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
  23363. resp, requestErr := http.Get(api)
  23364. if requestErr != nil {
  23365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23366. return
  23367. }
  23368. body, ioErr := ioutil.ReadAll(resp.Body)
  23369. if ioErr != nil {
  23370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23372. return
  23373. }
  23374. var respJSON map[string]interface{}
  23375. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23378. return
  23379. }
  23380. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23381. result, _ := json.Marshal(respJSON)
  23382. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23383. utils.ErrorLog("解析失败:%v", err)
  23384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23385. return
  23386. }
  23387. infocode = resThree.Infcode
  23388. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23389. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23390. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23391. // insuplc_admdvs_temp =
  23392. //}
  23393. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23394. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23395. //}
  23396. utils.ErrorLog("解析失败:%v", insutype)
  23397. utils.ErrorLog("解析失败:%v", PsnNo)
  23398. utils.ErrorLog("解析失败:%v", Certno)
  23399. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23400. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23401. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23402. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23403. utils.ErrorLog("解析失败:%v", PsnNo)
  23404. utils.ErrorLog("解析失败:%v", department.Number)
  23405. utils.ErrorLog("解析失败:%v", department.Name)
  23406. utils.ErrorLog("解析失败:%v", roles.UserName)
  23407. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23408. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23409. "&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
  23410. resp, requestErr := http.Get(api)
  23411. if requestErr != nil {
  23412. utils.ErrorLog("解析失败:%v", requestErr)
  23413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23414. return
  23415. }
  23416. body, ioErr := ioutil.ReadAll(resp.Body)
  23417. if ioErr != nil {
  23418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23420. return
  23421. }
  23422. var respJSON map[string]interface{}
  23423. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23426. return
  23427. }
  23428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23429. result, _ := json.Marshal(respJSON)
  23430. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23431. utils.ErrorLog("解析失败:%v", err)
  23432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23433. return
  23434. }
  23435. infocode = resThree.Infcode
  23436. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23437. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23438. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23439. // insuplc_admdvs_temp =
  23440. //}
  23441. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23442. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23443. //}
  23444. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23445. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23446. "&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
  23447. resp, requestErr := http.Get(api)
  23448. if requestErr != nil {
  23449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23450. return
  23451. }
  23452. body, ioErr := ioutil.ReadAll(resp.Body)
  23453. if ioErr != nil {
  23454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23456. return
  23457. }
  23458. var respJSON map[string]interface{}
  23459. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23462. return
  23463. }
  23464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23465. result, _ := json.Marshal(respJSON)
  23466. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23467. utils.ErrorLog("解析失败:%v", err)
  23468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23469. return
  23470. }
  23471. infocode = resThree.Infcode
  23472. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23473. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23474. psn_info, _ := service.GetPsnByPatientId(id)
  23475. var verify_number string
  23476. if id_card_type == 4 {
  23477. verify_number = psn_info.VerifyNumber
  23478. } else if id_card_type == 1 {
  23479. bas := strings.Split(psn_info.CardInfo, "|")
  23480. cardNumber := bas[2]
  23481. verify_number = cardNumber
  23482. }
  23483. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23484. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23485. "&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
  23486. resp, requestErr := http.Get(api)
  23487. if requestErr != nil {
  23488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23489. return
  23490. }
  23491. body, ioErr := ioutil.ReadAll(resp.Body)
  23492. if ioErr != nil {
  23493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23495. return
  23496. }
  23497. var respJSON map[string]interface{}
  23498. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23501. return
  23502. }
  23503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23504. result, _ := json.Marshal(respJSON)
  23505. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23506. // utils.ErrorLog("解析失败:%v", err)
  23507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23508. // return
  23509. //}
  23510. //infocode = resThree.Infcode
  23511. //result, _ := json.Marshal(respJSON)
  23512. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23513. utils.ErrorLog("解析失败:%v", err)
  23514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23515. return
  23516. }
  23517. resThree.ErrMsg = resThree10265.ErrMsg
  23518. resThree.Output = resThree10265.Output
  23519. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23520. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23521. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23522. psn_info, _ := service.GetPsnByPatientId(id)
  23523. his.PsnNo = psn_info.PsnNo
  23524. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23525. var cert_no string
  23526. if id_card_type == 3 {
  23527. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  23528. cert_no = IdCardNo
  23529. } else if id_card_type == 4 {
  23530. cert_no = IdCardNo
  23531. psn_info.VerifyNumber = psn_info.VerifyNumber
  23532. } else {
  23533. bas := strings.Split(psn_info.CardInfo, "|")
  23534. cert_no = bas[2]
  23535. }
  23536. var hisPrescription []*models.HisPrescription
  23537. for _, item := range rf {
  23538. if item.Insutype == insutype {
  23539. //insuplc_admdvs = item.InsuplcAdmdvs
  23540. his.InsuplcAdmdvs = insuplc_admdvs
  23541. }
  23542. }
  23543. his.Insutype = insutype
  23544. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23545. fmt.Println(res3101)
  23546. fmt.Println(res3101.Infcode)
  23547. if res3101.Infcode == "0" {
  23548. fmt.Println("33333333")
  23549. if len(res3101.Output.Result) > 0 {
  23550. fmt.Println("222222")
  23551. for _, item := range res3101.Output.Result {
  23552. if len(res3101.ErrMsg) == 0 {
  23553. res3101.ErrMsg = item.VolaCont
  23554. } else {
  23555. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23556. }
  23557. }
  23558. c.ServeSuccessJSON(map[string]interface{}{
  23559. "failed_code": -10,
  23560. "msg": res3101.ErrMsg,
  23561. })
  23562. return
  23563. } else {
  23564. fmt.Println("11111")
  23565. var api string
  23566. if miConfig.MdtrtareaAdmvs == "320921" {
  23567. ipt_otp_no = timeFormat
  23568. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23569. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23570. "&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
  23571. } else {
  23572. ipt_otp_no = timeFormat
  23573. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23574. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23575. "&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
  23576. }
  23577. resp, requestErr := http.Get(api)
  23578. if requestErr != nil {
  23579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23580. return
  23581. }
  23582. body, ioErr := ioutil.ReadAll(resp.Body)
  23583. if ioErr != nil {
  23584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23586. return
  23587. }
  23588. var respJSON map[string]interface{}
  23589. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23592. return
  23593. }
  23594. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23595. result, _ := json.Marshal(respJSON)
  23596. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23597. utils.ErrorLog("解析失败:%v", err)
  23598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23599. return
  23600. }
  23601. resThree.ErrMsg = resThree10265.ErrMsg
  23602. resThree.Output = resThree10265.Output
  23603. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23604. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23605. }
  23606. } else if res3101.Infcode != "0" {
  23607. c.ServeSuccessJSON(map[string]interface{}{
  23608. "failed_code": -10,
  23609. "msg": res3101.ErrMsg,
  23610. })
  23611. return
  23612. }
  23613. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23614. psn_info, _ := service.GetPsnByPatientId(id)
  23615. var cert_no string
  23616. if id_card_type == 1 {
  23617. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  23618. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23619. } else if id_card_type == 4 {
  23620. cert_no = psn_info.VerifyNumber
  23621. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23622. } else {
  23623. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23624. cert_no = psn_info.VerifyNumber
  23625. }
  23626. 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)
  23627. saveLog(result, requestLog, "2201", "挂号")
  23628. if miConfig.Code == "H15049901371" {
  23629. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23630. utils.ErrorLog("解析失败:%v", err)
  23631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23632. return
  23633. }
  23634. resThree.ErrMsg = resThree10265.ErrMsg
  23635. resThree.Output = resThree10265.Output
  23636. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23637. } else {
  23638. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23639. utils.ErrorLog("解析失败:%v", err)
  23640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23641. return
  23642. }
  23643. }
  23644. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23645. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  23646. psn_info, _ := service.GetPsnByPatientId(id)
  23647. var result string
  23648. var requestLog string
  23649. if id_card_type == 1 {
  23650. bas := strings.Split(psn_info.CardInfo, "|")
  23651. basNumber := bas[2]
  23652. card_sn := bas[3]
  23653. 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)
  23654. saveLog(result, requestLog, "2201A", "挂号")
  23655. } else if id_card_type == 2 {
  23656. 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, "", "", "", "", "", "")
  23657. saveLog(result, requestLog, "2201A", "挂号")
  23658. } else {
  23659. 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)
  23660. saveLog(result, requestLog, "2201A", "挂号")
  23661. }
  23662. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23663. utils.ErrorLog("解析失败:%v", err)
  23664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23665. return
  23666. }
  23667. infocode = resThree.Infcode
  23668. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  23669. psn_info, _ := service.GetPsnByPatientId(id)
  23670. var result string
  23671. var requestLog string
  23672. if id_card_type == 1 {
  23673. bas := strings.Split(psn_info.CardInfo, "|")
  23674. basNumber := bas[2]
  23675. card_sn :=""
  23676. 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)
  23677. saveLog(result, requestLog, "2201A", "挂号")
  23678. } else if id_card_type == 2 {
  23679. 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, "", "", "", "", "", "")
  23680. saveLog(result, requestLog, "2201A", "挂号")
  23681. } else {
  23682. 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)
  23683. saveLog(result, requestLog, "2201A", "挂号")
  23684. }
  23685. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23686. utils.ErrorLog("解析失败:%v", err)
  23687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23688. return
  23689. }
  23690. infocode = resThree.Infcode
  23691. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23692. psn_info, _ := service.GetPsnByPatientId(id)
  23693. his.PsnNo = psn_info.PsnNo
  23694. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23695. var cert_no string
  23696. if id_card_type == 1 {
  23697. bas := strings.Split(psn_info.CardInfo, "|")
  23698. cert_no = bas[2]
  23699. } else if id_card_type == 4 {
  23700. cert_no = psn_info.VerifyNumber
  23701. psn_info.VerifyNumber = psn_info.VerifyNumber
  23702. IdCardNo = psn_info.VerifyNumber
  23703. } else {
  23704. cert_no = IdCardNo
  23705. psn_info.VerifyNumber = cert_no
  23706. }
  23707. for _, item := range rf {
  23708. if item.Insutype == insutype {
  23709. his.InsuplcAdmdvs = insuplc_admdvs
  23710. }
  23711. }
  23712. his.Insutype = insutype
  23713. var api string
  23714. ipt_otp_no = timeFormat
  23715. 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 +
  23716. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23717. "&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
  23718. resp, requestErr := http.Get(api)
  23719. if requestErr != nil {
  23720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23721. return
  23722. }
  23723. body, ioErr := ioutil.ReadAll(resp.Body)
  23724. if ioErr != nil {
  23725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23727. return
  23728. }
  23729. var respJSON map[string]interface{}
  23730. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23733. return
  23734. }
  23735. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23736. if status == "0" {
  23737. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23738. c.ServeSuccessJSON(map[string]interface{}{
  23739. "failed_code": -10,
  23740. "msg": err_msg,
  23741. })
  23742. return
  23743. }
  23744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23745. result, _ := json.Marshal(respJSON)
  23746. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23747. utils.ErrorLog("解析失败:%v", err)
  23748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23749. return
  23750. }
  23751. infocode = resThree.Infcode
  23752. } else if miConfig.MdtrtareaAdmvs == "340699" {
  23753. psn_info, _ := service.GetPsnByPatientId(id)
  23754. his.PsnNo = psn_info.PsnNo
  23755. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23756. var cert_no string
  23757. if id_card_type == 1 {
  23758. bas := strings.Split(psn_info.CardInfo, "|")
  23759. cert_no = bas[2]
  23760. } else if id_card_type == 4 {
  23761. cert_no = psn_info.VerifyNumber
  23762. psn_info.VerifyNumber = psn_info.VerifyNumber
  23763. IdCardNo = psn_info.VerifyNumber
  23764. } else {
  23765. cert_no = IdCardNo
  23766. psn_info.VerifyNumber = cert_no
  23767. }
  23768. for _, item := range rf {
  23769. if item.Insutype == insutype {
  23770. his.InsuplcAdmdvs = insuplc_admdvs
  23771. }
  23772. }
  23773. his.Insutype = insutype
  23774. var api string
  23775. ipt_otp_no = timeFormat
  23776. 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 +
  23777. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23778. "&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
  23779. resp, requestErr := http.Get(api)
  23780. if requestErr != nil {
  23781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23782. return
  23783. }
  23784. body, ioErr := ioutil.ReadAll(resp.Body)
  23785. if ioErr != nil {
  23786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23788. return
  23789. }
  23790. var respJSON map[string]interface{}
  23791. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23794. return
  23795. }
  23796. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23797. if status == "0" {
  23798. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23799. c.ServeSuccessJSON(map[string]interface{}{
  23800. "failed_code": -10,
  23801. "msg": err_msg,
  23802. })
  23803. return
  23804. }
  23805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23806. result, _ := json.Marshal(respJSON)
  23807. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23808. utils.ErrorLog("解析失败:%v", err)
  23809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23810. return
  23811. }
  23812. infocode = resThree.Infcode
  23813. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23814. psn_info, _ := service.GetPsnByPatientId(id)
  23815. var result string
  23816. var requestLog string
  23817. if id_card_type == 1 {
  23818. bas := strings.Split(psn_info.CardInfo, "|")
  23819. basNumber := bas[2]
  23820. card_sn := bas[3]
  23821. 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)
  23822. saveLog(result, requestLog, "2201A", "挂号")
  23823. } else if id_card_type == 2 {
  23824. 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, "", "")
  23825. saveLog(result, requestLog, "2201A", "挂号")
  23826. } else {
  23827. 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, "", "")
  23828. saveLog(result, requestLog, "2201A", "挂号")
  23829. }
  23830. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23831. utils.ErrorLog("解析失败:%v", err)
  23832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23833. return
  23834. }
  23835. infocode = resThree.Infcode
  23836. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23837. psn_info, _ := service.GetPsnByPatientId(id)
  23838. 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)
  23839. saveLog(result, requestLog, "2201A", "挂号")
  23840. if miConfig.Code == "H15049901371" {
  23841. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23842. utils.ErrorLog("解析失败:%v", err)
  23843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23844. return
  23845. }
  23846. resThree.ErrMsg = resThree10265.ErrMsg
  23847. resThree.Output = resThree10265.Output
  23848. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23849. } else {
  23850. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23851. utils.ErrorLog("解析失败:%v", err)
  23852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23853. return
  23854. }
  23855. }
  23856. if miConfig.Code == "H15049901371" {
  23857. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23858. } else {
  23859. infocode = resThree.Infcode
  23860. }
  23861. } else {
  23862. psn_info, _ := service.GetPsnByPatientId(id)
  23863. if id_card_type == 4 || id_card_type == 1 {
  23864. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23865. }
  23866. var rf []*ResultFive
  23867. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  23868. var insutypes []*ResultFive
  23869. var insutype string
  23870. var is390 int = 0
  23871. var is310 int = 0
  23872. for _, item := range rf {
  23873. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23874. insutypes = append(insutypes, item)
  23875. }
  23876. }
  23877. if len(insutypes) == 1 {
  23878. insutype = insutypes[0].Insutype
  23879. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23880. } else {
  23881. for _, i := range insutypes {
  23882. if i.Insutype == "390" {
  23883. is390 = 1
  23884. }
  23885. if i.Insutype == "310" {
  23886. is310 = 1
  23887. }
  23888. }
  23889. }
  23890. if is390 == 1 {
  23891. insutype = "390"
  23892. }
  23893. if is310 == 1 {
  23894. insutype = "310"
  23895. }
  23896. fmt.Println(len(insutypes))
  23897. if len(insutypes) == 0 {
  23898. for index, item := range rf {
  23899. if index == 0 {
  23900. insutype = item.Insutype
  23901. insuplc_admdvs = item.InsuplcAdmdvs
  23902. }
  23903. }
  23904. fmt.Println(insutype)
  23905. fmt.Println(insuplc_admdvs)
  23906. }
  23907. if social_type > 0 {
  23908. insutype = strconv.FormatInt(social_type, 10)
  23909. }
  23910. fmt.Println("--------")
  23911. fmt.Println(psn_info)
  23912. fmt.Println(psn_info.PsnNo)
  23913. if miConfig.MdtrtareaAdmvs == "441202" {
  23914. var hisPrescription []*models.HisPrescription
  23915. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23916. if res3101.Infcode == 0 {
  23917. fmt.Println("33333333")
  23918. if len(res3101.Output.Result) > 0 {
  23919. fmt.Println("222222")
  23920. for _, item := range res3101.Output.Result {
  23921. if len(res3101.ErrMsg) == 0 {
  23922. res3101.ErrMsg = item.VolaCont
  23923. } else {
  23924. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23925. }
  23926. }
  23927. c.ServeSuccessJSON(map[string]interface{}{
  23928. "failed_code": -10,
  23929. "msg": res3101.ErrMsg,
  23930. })
  23931. return
  23932. } else {
  23933. hour := time.Now().Format("15")
  23934. min := time.Now().Format("04")
  23935. sec := time.Now().Format("05")
  23936. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  23937. fmt.Println(record_time_two)
  23938. 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)
  23939. saveLog(result, requestLog, "2201A", "挂号")
  23940. if miConfig.Code == "H15049901371" {
  23941. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23942. utils.ErrorLog("解析失败:%v", err)
  23943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23944. return
  23945. }
  23946. resThree.ErrMsg = resThree10265.ErrMsg
  23947. resThree.Output = resThree10265.Output
  23948. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23949. } else {
  23950. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23951. utils.ErrorLog("解析失败:%v", err)
  23952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23953. return
  23954. }
  23955. }
  23956. if miConfig.Code == "H15049901371" {
  23957. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23958. } else {
  23959. infocode = resThree.Infcode
  23960. }
  23961. }
  23962. } else if res3101.Infcode != 0 {
  23963. c.ServeSuccessJSON(map[string]interface{}{
  23964. "failed_code": -10,
  23965. "msg": res3101.ErrMsg,
  23966. })
  23967. return
  23968. }
  23969. } else if miConfig.MdtrtareaAdmvs == "440205" {
  23970. var hisPrescription []*models.HisPrescription
  23971. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23972. if res3101.Infcode == 0 {
  23973. fmt.Println("33333333")
  23974. if len(res3101.Output.Result) > 0 {
  23975. fmt.Println("222222")
  23976. for _, item := range res3101.Output.Result {
  23977. if len(res3101.ErrMsg) == 0 {
  23978. res3101.ErrMsg = item.VolaCont
  23979. } else {
  23980. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23981. }
  23982. }
  23983. c.ServeSuccessJSON(map[string]interface{}{
  23984. "failed_code": -10,
  23985. "msg": res3101.ErrMsg,
  23986. })
  23987. return
  23988. } else {
  23989. hour := time.Now().Format("15")
  23990. min := time.Now().Format("04")
  23991. sec := time.Now().Format("05")
  23992. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  23993. fmt.Println(record_time_two)
  23994. 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)
  23995. saveLog(result, requestLog, "2201A", "挂号")
  23996. if miConfig.Code == "H15049901371" {
  23997. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23998. utils.ErrorLog("解析失败:%v", err)
  23999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24000. return
  24001. }
  24002. resThree.ErrMsg = resThree10265.ErrMsg
  24003. resThree.Output = resThree10265.Output
  24004. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24005. } else {
  24006. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24007. utils.ErrorLog("解析失败:%v", err)
  24008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24009. return
  24010. }
  24011. }
  24012. if miConfig.Code == "H15049901371" {
  24013. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24014. } else {
  24015. infocode = resThree.Infcode
  24016. }
  24017. }
  24018. } else if res3101.Infcode != 0 {
  24019. c.ServeSuccessJSON(map[string]interface{}{
  24020. "failed_code": -10,
  24021. "msg": res3101.ErrMsg,
  24022. })
  24023. return
  24024. }
  24025. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24026. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24027. psn_info, _ := service.GetPsnByPatientId(id)
  24028. var verify_number string
  24029. if id_card_type == 4 {
  24030. verify_number = psn_info.VerifyNumber
  24031. } else if id_card_type == 1 {
  24032. bas := strings.Split(psn_info.CardInfo, "|")
  24033. cardNumber := bas[2]
  24034. verify_number = cardNumber
  24035. } else {
  24036. verify_number = psn_info.Certno
  24037. }
  24038. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24039. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24040. "&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
  24041. resp, requestErr := http.Get(api)
  24042. if requestErr != nil {
  24043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24044. return
  24045. }
  24046. body, ioErr := ioutil.ReadAll(resp.Body)
  24047. if ioErr != nil {
  24048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24050. return
  24051. }
  24052. var respJSON map[string]interface{}
  24053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24056. return
  24057. }
  24058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24059. result, _ := json.Marshal(respJSON)
  24060. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24061. utils.ErrorLog("解析失败:%v", err)
  24062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24063. return
  24064. }
  24065. infocode = resThree.Infcode
  24066. } else {
  24067. hour := time.Now().Format("15")
  24068. min := time.Now().Format("04")
  24069. sec := time.Now().Format("05")
  24070. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24071. if id_card_type == 1 {
  24072. for _, item := range rf {
  24073. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24074. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24075. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24076. } else if strconv.FormatInt(social_type, 10) == "390" {
  24077. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24078. } else {
  24079. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24080. }
  24081. }
  24082. }
  24083. }
  24084. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24085. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24086. }
  24087. if id_card_type == 1 {
  24088. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24089. bas := strings.Split(psn_info.CardInfo, "|")
  24090. basNumber := bas[1]
  24091. IdCardNo = basNumber
  24092. }
  24093. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24094. IdCardNo = psn_info.VerifyNumber
  24095. }
  24096. if len(insuplc_admdvs_temp) == 0 {
  24097. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24098. }
  24099. 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)
  24100. saveLog(result, requestLog, "2201A", "挂号")
  24101. if miConfig.Code == "H15049901371" {
  24102. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24103. utils.ErrorLog("解析失败:%v", err)
  24104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24105. return
  24106. }
  24107. resThree.ErrMsg = resThree10265.ErrMsg
  24108. resThree.Output = resThree10265.Output
  24109. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24110. } else {
  24111. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24112. utils.ErrorLog("解析失败:%v", err)
  24113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24114. return
  24115. }
  24116. }
  24117. if miConfig.Code == "H15049901371" {
  24118. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24119. } else {
  24120. infocode = resThree.Infcode
  24121. }
  24122. }
  24123. }
  24124. if infocode == -1 {
  24125. adminUser := c.GetAdminUserInfo()
  24126. errlog := &models.HisOrderError{
  24127. UserOrgId: adminUser.CurrentOrgId,
  24128. Ctime: time.Now().Unix(),
  24129. Mtime: time.Now().Unix(),
  24130. ErrMsg: resThree.ErrMsg,
  24131. Status: 1,
  24132. PatientId: id,
  24133. RecordTime: recordDateTime,
  24134. Stage: 2,
  24135. }
  24136. service.CreateErrMsgLog(errlog)
  24137. c.ServeSuccessJSON(map[string]interface{}{
  24138. "failed_code": -10,
  24139. "msg": resThree.ErrMsg,
  24140. })
  24141. return
  24142. }
  24143. his.Number = resThree.Output.Data.MdtrtID
  24144. his.PsnNo = resThree.Output.Data.PsnNo
  24145. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24146. his.IdCardNo = patient.IdCardNo
  24147. his.PhoneNumber = patient.Phone
  24148. his.UserOrgId = adminInfo.CurrentOrgId
  24149. his.Insutype = insutype
  24150. his.Ctime = time.Now().Unix()
  24151. his.Mtime = time.Now().Unix()
  24152. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24153. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24154. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24155. }
  24156. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24157. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24158. }
  24159. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24160. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24161. }
  24162. his.Status = 1
  24163. his.MdtrtGrpType = mdtrt_type
  24164. service.UpdateHisPatientStatus(&his)
  24165. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24166. c.ServeSuccessJSON(map[string]interface{}{
  24167. "his_info": his,
  24168. })
  24169. } else {
  24170. adminUser := c.GetAdminUserInfo()
  24171. errlog := &models.HisOrderError{
  24172. UserOrgId: adminUser.CurrentOrgId,
  24173. Ctime: time.Now().Unix(),
  24174. Mtime: time.Now().Unix(),
  24175. ErrMsg: res.ErrMsg,
  24176. Status: 1,
  24177. PatientId: id,
  24178. RecordTime: recordDateTime,
  24179. Stage: 1,
  24180. }
  24181. service.CreateErrMsgLog(errlog)
  24182. c.ServeSuccessJSON(map[string]interface{}{
  24183. "failed_code": -10,
  24184. "msg": res.ErrMsg,
  24185. })
  24186. return
  24187. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24188. }
  24189. }
  24190. }
  24191. func (c *HisApiController) GetUploadInfo() {
  24192. id, _ := c.GetInt64("id")
  24193. record_time := c.GetString("record_time")
  24194. his_patient_id, _ := c.GetInt64("his_patient_id")
  24195. order_id, _ := c.GetInt64("order_id")
  24196. pay_way, _ := c.GetInt64("pay_way")
  24197. pay_ways := c.GetString("pay_ways")
  24198. oth_desc := c.GetString("oth_desc")
  24199. pay_price, _ := c.GetFloat("pay_price")
  24200. pay_card_no := c.GetString("pay_card_no")
  24201. discount_price, _ := c.GetFloat("discount_price")
  24202. preferential_price, _ := c.GetFloat("preferential_price")
  24203. reality_price, _ := c.GetFloat("reality_price")
  24204. found_price, _ := c.GetFloat("found_price")
  24205. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24206. private_price, _ := c.GetFloat("private_price")
  24207. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24208. admin_user_id, _ := c.GetInt64("admin_user_id")
  24209. fapiao_code := c.GetString("fapiao_code")
  24210. fapiao_number := c.GetString("fapiao_number")
  24211. diagnosis_id := c.GetString("diagnosis")
  24212. sick_type, _ := c.GetInt64("sick_type")
  24213. reg_type, _ := c.GetInt64("p_type")
  24214. begin_time := c.GetString("begin_time")
  24215. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24216. cash_pay := c.GetString("cash_pay")
  24217. band_card_pay := c.GetString("band_card_pay")
  24218. wechat_pay := c.GetString("wechat_pay")
  24219. ali_pay := c.GetString("ali_pay")
  24220. jifen_pay := c.GetString("jifen_pay")
  24221. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24222. fmt.Println(acct_used_flag)
  24223. id_str := c.GetString("ids")
  24224. ids_arr := strings.Split(id_str, ",")
  24225. timeLayout := "2006-01-02"
  24226. loc, _ := time.LoadLocation("Local")
  24227. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24228. if err != nil {
  24229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24230. return
  24231. }
  24232. recordDateTime := theTime.Unix()
  24233. adminUser := c.GetAdminUserInfo()
  24234. var tempOrder models.HisOrder
  24235. tempOrder, _ = service.GetHisOrderByID(order_id)
  24236. var prescriptions []*models.HisPrescription
  24237. var start_time int64
  24238. var end_time int64
  24239. //押金模块
  24240. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24241. tmp_decimal := c.GetString("tmp_decimal")
  24242. var decimal float64 //本次使用的押金
  24243. var errmsg error
  24244. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24245. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24246. return
  24247. }
  24248. if len(tmp_decimal) > 0 {
  24249. if tmp_decimal[0] == 45 {
  24250. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24251. return
  24252. }
  24253. }
  24254. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24255. fmt.Println(errs)
  24256. decimal = tt
  24257. //if adminUser.CurrentOrgId == 10106{
  24258. // if len(fapiao_code) == 0{
  24259. // fapiao_code = "144072080589"
  24260. // }
  24261. // if len(fapiao_number) == 0{
  24262. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24263. // if order.ID == 0{
  24264. // fapiao_number = "00001520"
  24265. // }else{
  24266. // //fapiao_code = "00001520"
  24267. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24268. // var zero string
  24269. // if fpNumber >= 1000{
  24270. // zero = "0000" + strconv.Itoa(fpNumber)
  24271. // }else if fpNumber >= 10000{
  24272. // zero = "000" + strconv.Itoa(fpNumber)
  24273. // } else if fpNumber >= 100000{
  24274. // zero = "00" + strconv.Itoa(fpNumber)
  24275. // } else if fpNumber >= 1000000{
  24276. // zero = "0" + strconv.Itoa(fpNumber)
  24277. // }else {
  24278. // zero = strconv.Itoa(fpNumber)
  24279. // }
  24280. // fapiao_number = zero
  24281. // }
  24282. // }
  24283. //}
  24284. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24285. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24286. var patientPrescription models.HisPrescriptionInfo
  24287. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24288. if patientPrescription.ID == 0 {
  24289. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24290. }
  24291. //if patientPrescription.Do
  24292. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24293. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24294. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24295. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24296. var config []*models.HisXtDiagnoseConfig
  24297. for _, item := range diagnosis_ids {
  24298. id, _ := strconv.ParseInt(item, 10, 64)
  24299. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24300. config = append(config, &diagnosisConfig)
  24301. }
  24302. sickConfig, _ := service.FindSickById(sick_type)
  24303. //if tempOrder.ID == 0 {
  24304. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24305. //}
  24306. if tempOrder.ID == 0 {
  24307. var result string
  24308. var requestLog string
  24309. var res2 ResultSix
  24310. var res3 GZResultSix
  24311. var ressix10265 ResultSix10265
  24312. if miConfig.MdtrtareaAdmvs == "421300" {
  24313. data := make(map[string]interface{})
  24314. client := &http.Client{}
  24315. data["psn_no"] = his.PsnNo
  24316. data["mdtrt_id"] = his.Number
  24317. data["opter"] = roles.UserName
  24318. data["org_name"] = miConfig.OrgName
  24319. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24320. data["doctor_id"] = doctor_info.DoctorNumber
  24321. data["doctor_name"] = doctor_info.UserName
  24322. data["department"] = department.Name
  24323. data["fixmedins_code"] = miConfig.Code
  24324. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24325. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24326. data["secret_key"] = miConfig.SecretKey
  24327. data["sick_code"] = sickConfig.CountryCode
  24328. data["sick_name"] = sickConfig.ClassName
  24329. data["dept"] = strconv.FormatInt(department.ID, 10)
  24330. data["config"] = config
  24331. data["begin_time"] = begin_time
  24332. bytesData, _ := json.Marshal(data)
  24333. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24334. resp, _ := client.Do(req)
  24335. defer resp.Body.Close()
  24336. body, ioErr := ioutil.ReadAll(resp.Body)
  24337. if ioErr != nil {
  24338. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24340. return
  24341. }
  24342. var respJSON map[string]interface{}
  24343. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24346. return
  24347. }
  24348. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24349. userJSONBytes, _ := json.Marshal(respJSON)
  24350. fmt.Println("log")
  24351. fmt.Println(string(userJSONBytes))
  24352. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24353. utils.ErrorLog("解析失败:%v", err)
  24354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24355. return
  24356. }
  24357. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24358. data := make(map[string]interface{})
  24359. client := &http.Client{}
  24360. data["psn_no"] = his.PsnNo
  24361. data["mdtrt_id"] = his.Number
  24362. data["opter"] = roles.UserName
  24363. data["org_name"] = miConfig.OrgName
  24364. if reg_type == 11 && his.Insutype == "390" {
  24365. data["med_type"] = "110104"
  24366. } else {
  24367. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24368. }
  24369. data["doctor_id"] = doctor_info.DoctorNumber
  24370. data["doctor_name"] = doctor_info.UserName
  24371. data["department"] = department.Name
  24372. data["fixmedins_code"] = miConfig.Code
  24373. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24374. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24375. data["secret_key"] = miConfig.SecretKey
  24376. data["sick_code"] = sickConfig.CountryCode
  24377. data["sick_name"] = sickConfig.ClassName
  24378. data["dept"] = strconv.FormatInt(department.ID, 10)
  24379. data["config"] = config
  24380. data["begin_time"] = begin_time
  24381. bytesData, _ := json.Marshal(data)
  24382. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24383. resp, _ := client.Do(req)
  24384. defer resp.Body.Close()
  24385. body, ioErr := ioutil.ReadAll(resp.Body)
  24386. if ioErr != nil {
  24387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24389. return
  24390. }
  24391. var respJSON map[string]interface{}
  24392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24395. return
  24396. }
  24397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24398. userJSONBytes, _ := json.Marshal(respJSON)
  24399. fmt.Println("log")
  24400. fmt.Println(string(userJSONBytes))
  24401. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24402. utils.ErrorLog("解析失败:%v", err)
  24403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24404. return
  24405. }
  24406. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24407. data := make(map[string]interface{})
  24408. client := &http.Client{}
  24409. data["psn_no"] = his.PsnNo
  24410. data["mdtrt_id"] = his.Number
  24411. data["opter"] = roles.UserName
  24412. data["org_name"] = miConfig.OrgName
  24413. if reg_type == 11 && his.Insutype == "390" {
  24414. data["med_type"] = "110104"
  24415. } else {
  24416. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24417. }
  24418. data["doctor_id"] = doctor_info.DoctorNumber
  24419. data["doctor_name"] = doctor_info.UserName
  24420. data["department"] = department.Name
  24421. data["fixmedins_code"] = miConfig.Code
  24422. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24423. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24424. data["secret_key"] = miConfig.SecretKey
  24425. data["sick_code"] = sickConfig.CountryCode
  24426. data["sick_name"] = sickConfig.ClassName
  24427. data["dept"] = strconv.FormatInt(department.ID, 10)
  24428. data["config"] = config
  24429. data["begin_time"] = begin_time
  24430. bytesData, _ := json.Marshal(data)
  24431. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24432. resp, _ := client.Do(req)
  24433. defer resp.Body.Close()
  24434. body, ioErr := ioutil.ReadAll(resp.Body)
  24435. if ioErr != nil {
  24436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24438. return
  24439. }
  24440. var respJSON map[string]interface{}
  24441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24444. return
  24445. }
  24446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24447. userJSONBytes, _ := json.Marshal(respJSON)
  24448. fmt.Println("log")
  24449. fmt.Println(string(userJSONBytes))
  24450. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24451. utils.ErrorLog("解析失败:%v", err)
  24452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24453. return
  24454. }
  24455. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24456. data := make(map[string]interface{})
  24457. client := &http.Client{}
  24458. data["psn_no"] = his.PsnNo
  24459. data["mdtrt_id"] = his.Number
  24460. data["opter"] = roles.UserName
  24461. data["org_name"] = miConfig.OrgName
  24462. if reg_type == 11 && his.Insutype == "390" {
  24463. data["med_type"] = "110104"
  24464. } else {
  24465. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24466. }
  24467. data["doctor_id"] = doctor_info.DoctorNumber
  24468. data["doctor_name"] = doctor_info.UserName
  24469. data["department"] = department.Name
  24470. data["fixmedins_code"] = miConfig.Code
  24471. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24472. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24473. data["secret_key"] = miConfig.SecretKey
  24474. data["sick_code"] = sickConfig.CountryCode
  24475. data["sick_name"] = sickConfig.ClassName
  24476. data["dept"] = strconv.FormatInt(department.ID, 10)
  24477. data["config"] = config
  24478. data["begin_time"] = begin_time
  24479. bytesData, _ := json.Marshal(data)
  24480. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24481. resp, _ := client.Do(req)
  24482. defer resp.Body.Close()
  24483. body, ioErr := ioutil.ReadAll(resp.Body)
  24484. if ioErr != nil {
  24485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24487. return
  24488. }
  24489. var respJSON map[string]interface{}
  24490. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24493. return
  24494. }
  24495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24496. userJSONBytes, _ := json.Marshal(respJSON)
  24497. fmt.Println("log")
  24498. fmt.Println(string(userJSONBytes))
  24499. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24500. utils.ErrorLog("解析失败:%v", err)
  24501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24502. return
  24503. }
  24504. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24505. data := make(map[string]interface{})
  24506. client := &http.Client{}
  24507. data["psn_no"] = his.PsnNo
  24508. data["mdtrt_id"] = his.Number
  24509. data["doctor"] = roles.UserName
  24510. data["department"] = department.Name
  24511. data["org_name"] = miConfig.OrgName
  24512. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24513. data["doctor_id"] = doctor_info.DoctorNumber
  24514. data["new_doctor_name"] = doctor_info.UserName
  24515. data["fixmedins_code"] = miConfig.Code
  24516. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24517. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24518. data["secret_key"] = miConfig.SecretKey
  24519. data["sick_code"] = sickConfig.CountryCode
  24520. data["sick_name"] = sickConfig.ClassName
  24521. data["url"] = miConfig.Url
  24522. data["ak"] = miConfig.AccessKey
  24523. data["begin_time"] = begin_time
  24524. data["cainfo"] = miConfig.Cainfo
  24525. data["dept"] = strconv.FormatInt(department.ID, 10)
  24526. data["config"] = config
  24527. bytesData, _ := json.Marshal(data)
  24528. var req *http.Request
  24529. if miConfig.MdtrtareaAdmvs == "320921" {
  24530. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24531. //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 +
  24532. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  24533. } else {
  24534. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24535. }
  24536. resp, _ := client.Do(req)
  24537. defer resp.Body.Close()
  24538. body, ioErr := ioutil.ReadAll(resp.Body)
  24539. if ioErr != nil {
  24540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24542. return
  24543. }
  24544. var respJSON map[string]interface{}
  24545. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24548. return
  24549. }
  24550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24551. userJSONBytes, _ := json.Marshal(respJSON)
  24552. fmt.Println("log")
  24553. fmt.Println(string(userJSONBytes))
  24554. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  24555. utils.ErrorLog("解析失败:%v", err)
  24556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24557. return
  24558. }
  24559. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24560. res2.Output = ressix10265.Output
  24561. res2.ErrMsg = ressix10265.ErrMsg
  24562. res2.Cainfo = ressix10265.Cainfo
  24563. res2.WarnMsg = ressix10265.WarnMsg
  24564. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24565. res2.Infcode = infocode
  24566. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24567. data := make(map[string]interface{})
  24568. client := &http.Client{}
  24569. data["psn_no"] = his.PsnNo
  24570. data["mdtrt_id"] = his.Number
  24571. data["doctor"] = roles.UserName
  24572. data["department"] = department.Name
  24573. data["org_name"] = miConfig.OrgName
  24574. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24575. data["doctor_id"] = doctor_info.DoctorNumber
  24576. data["new_doctor_name"] = doctor_info.UserName
  24577. data["fixmedins_code"] = miConfig.Code
  24578. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24579. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24580. data["secret_key"] = miConfig.SecretKey
  24581. data["sick_code"] = sickConfig.CountryCode
  24582. data["sick_name"] = sickConfig.ClassName
  24583. data["url"] = miConfig.Url
  24584. data["ak"] = miConfig.AccessKey
  24585. data["begin_time"] = begin_time
  24586. data["cainfo"] = miConfig.Cainfo
  24587. data["dept"] = strconv.FormatInt(department.ID, 10)
  24588. data["config"] = config
  24589. bytesData, _ := json.Marshal(data)
  24590. var req *http.Request
  24591. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  24592. resp, _ := client.Do(req)
  24593. defer resp.Body.Close()
  24594. body, ioErr := ioutil.ReadAll(resp.Body)
  24595. if ioErr != nil {
  24596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24598. return
  24599. }
  24600. var respJSON map[string]interface{}
  24601. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24604. return
  24605. }
  24606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24607. userJSONBytes, _ := json.Marshal(respJSON)
  24608. fmt.Println("log")
  24609. fmt.Println(string(userJSONBytes))
  24610. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  24611. utils.ErrorLog("解析失败:%v", err)
  24612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24613. return
  24614. }
  24615. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24616. res2.Output = ressix10265.Output
  24617. res2.ErrMsg = ressix10265.ErrMsg
  24618. res2.Cainfo = ressix10265.Cainfo
  24619. res2.WarnMsg = ressix10265.WarnMsg
  24620. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24621. res2.Infcode = infocode
  24622. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24623. 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)
  24624. saveLog(result, requestLog, "2203", "上传就诊信息")
  24625. var respJSON2 map[string]interface{}
  24626. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  24627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24629. return
  24630. }
  24631. userJSONBytes2, _ := json.Marshal(respJSON2)
  24632. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  24633. utils.ErrorLog("解析失败:%v", err)
  24634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24635. return
  24636. }
  24637. 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)
  24638. fmt.Println(result2)
  24639. fmt.Println(src_request)
  24640. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24641. data := make(map[string]interface{})
  24642. client := &http.Client{}
  24643. data["psn_no"] = his.PsnNo
  24644. data["mdtrt_id"] = his.Number
  24645. data["doctor"] = roles.UserName
  24646. data["department"] = department.Name
  24647. data["org_name"] = miConfig.OrgName
  24648. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24649. data["doctor_id"] = doctor_info.DoctorNumber
  24650. data["new_doctor_name"] = doctor_info.UserName
  24651. data["fixmedins_code"] = miConfig.Code
  24652. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24653. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24654. data["secret_key"] = miConfig.SecretKey
  24655. data["sick_code"] = sickConfig.CountryCode
  24656. data["sick_name"] = sickConfig.ClassName
  24657. data["url"] = miConfig.Url
  24658. data["ak"] = miConfig.AccessKey
  24659. data["begin_time"] = begin_time
  24660. data["cainfo"] = miConfig.Cainfo
  24661. data["dept"] = strconv.FormatInt(department.ID, 10)
  24662. data["config"] = config
  24663. bytesData, _ := json.Marshal(data)
  24664. var req *http.Request
  24665. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  24666. resp, _ := client.Do(req)
  24667. defer resp.Body.Close()
  24668. body, ioErr := ioutil.ReadAll(resp.Body)
  24669. if ioErr != nil {
  24670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24672. return
  24673. }
  24674. var respJSON map[string]interface{}
  24675. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24678. return
  24679. }
  24680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24681. userJSONBytes, _ := json.Marshal(respJSON)
  24682. fmt.Println("log")
  24683. fmt.Println(string(userJSONBytes))
  24684. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24685. utils.ErrorLog("解析失败:%v", err)
  24686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24687. return
  24688. }
  24689. } else {
  24690. if miConfig.MdtrtareaAdmvs == "440781" { //
  24691. 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)
  24692. } else {
  24693. if miConfig.Code == "H15049901371" {
  24694. //赤峰地区国家医保医疗类别
  24695. //职工透析:医疗类别选特殊情况门诊990502
  24696. //居民定额血透门慢: 医疗类别选门诊慢病140104
  24697. var med_type string
  24698. if his.Insutype == "390" {
  24699. if reg_type == 14 {
  24700. med_type = "9933"
  24701. } else if reg_type == 11 {
  24702. med_type = "11"
  24703. }
  24704. } else if his.Insutype == "310" {
  24705. if reg_type == 14 {
  24706. med_type = "990502"
  24707. } else if reg_type == 11 {
  24708. med_type = "11"
  24709. }
  24710. }
  24711. 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)
  24712. } else {
  24713. 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)
  24714. }
  24715. }
  24716. saveLog(result, requestLog, "2203", "上传就诊信息")
  24717. var respJSON2 map[string]interface{}
  24718. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  24719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24721. return
  24722. }
  24723. userJSONBytes2, _ := json.Marshal(respJSON2)
  24724. if miConfig.Code == "H15049901371" {
  24725. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  24726. utils.ErrorLog("解析失败:%v", err)
  24727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24728. return
  24729. }
  24730. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24731. res2.Output = ressix10265.Output
  24732. res2.ErrMsg = ressix10265.ErrMsg
  24733. res2.Cainfo = ressix10265.Cainfo
  24734. res2.WarnMsg = ressix10265.WarnMsg
  24735. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24736. res2.Infcode = infocode
  24737. } else {
  24738. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24739. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  24740. utils.ErrorLog("解析失败:%v", err)
  24741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24742. return
  24743. }
  24744. res2.Infcode = res3.Infcode
  24745. } else {
  24746. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  24747. utils.ErrorLog("解析失败:%v", err)
  24748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24749. return
  24750. }
  24751. }
  24752. }
  24753. }
  24754. if res2.Infcode == -1 {
  24755. adminUser := c.GetAdminUserInfo()
  24756. errlog := &models.HisOrderError{
  24757. UserOrgId: adminUser.CurrentOrgId,
  24758. Ctime: time.Now().Unix(),
  24759. Mtime: time.Now().Unix(),
  24760. ErrMsg: res2.ErrMsg,
  24761. Status: 1,
  24762. PatientId: id,
  24763. RecordTime: recordDateTime,
  24764. Stage: 3,
  24765. }
  24766. service.CreateErrMsgLog(errlog)
  24767. c.ServeSuccessJSON(map[string]interface{}{
  24768. "failed_code": -10,
  24769. "msg": res2.ErrMsg,
  24770. })
  24771. return
  24772. } else {
  24773. his.Diagnosis = diagnosis_id
  24774. his.SickType = sickConfig.ID
  24775. //var p_type int64
  24776. //if reg_type == 1111 || reg_type == 1112 {
  24777. // p_type = 11
  24778. //
  24779. //}
  24780. his.PType = fmt.Sprintf("%d", reg_type)
  24781. service.UpdateHisPatientThree(&his)
  24782. data := make(map[string]interface{})
  24783. if settle_accounts_type == 1 { //日结
  24784. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  24785. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  24786. } else {
  24787. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  24788. }
  24789. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  24790. data["pre"] = prescriptions
  24791. } else { //月结
  24792. start_time_str := c.GetString("start_time")
  24793. end_time_str := c.GetString("end_time")
  24794. timeLayout := "2006-01-02"
  24795. loc, _ := time.LoadLocation("Local")
  24796. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  24797. if err != nil {
  24798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24799. return
  24800. }
  24801. recordStartTime := theStartTime.Unix()
  24802. start_time = recordStartTime
  24803. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  24804. if err != nil {
  24805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24806. return
  24807. }
  24808. recordEndTime := theEndTime.Unix()
  24809. end_time = recordEndTime
  24810. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  24811. data["pre"] = prescriptions
  24812. }
  24813. timestamp := time.Now().Unix()
  24814. tempTime := time.Unix(timestamp, 0)
  24815. timeFormat := tempTime.Format("20060102150405")
  24816. chrgBchno := rand.Intn(100000) + 10000
  24817. new_chrg_bchno := ""
  24818. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24819. new_chrg_bchno = chrg_bchno
  24820. strconv.FormatInt(his.PatientId, 10)
  24821. client := &http.Client{}
  24822. if adminUser.CurrentOrgId == 10265 {
  24823. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  24824. new_chrg_bchno = "0000"
  24825. }
  24826. }
  24827. data["psn_no"] = his.PsnNo
  24828. data["mdtrt_id"] = his.Number
  24829. data["chrg_bchno"] = new_chrg_bchno
  24830. data["org_name"] = miConfig.OrgName
  24831. data["doctor"] = doctor_info.UserName
  24832. data["doctor_id"] = doctor_info.DoctorNumber
  24833. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  24834. data["fixmedins_code"] = miConfig.Code
  24835. data["dept_code"] = department.Number
  24836. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24837. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24838. data["secret_key"] = miConfig.SecretKey
  24839. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  24840. data["url"] = miConfig.Url
  24841. data["ak"] = miConfig.AccessKey
  24842. data["new_doctor_name"] = patientPrescription.Doctor
  24843. data["diag_code"] = sickConfig.CountryCode
  24844. data["cainfo"] = miConfig.Cainfo
  24845. data["opter"] = roles.UserName
  24846. var ids []int64
  24847. for _, item := range prescriptions {
  24848. ids = append(ids, item.ID)
  24849. }
  24850. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24851. if config.IsOpen == 1 { //对接了医保,走医保流程
  24852. var res ResultFour
  24853. var resFour10265 ResultFour10265
  24854. if miConfig.MdtrtareaAdmvs == "421300" {
  24855. bytesData, _ := json.Marshal(data)
  24856. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  24857. resp, _ := client.Do(req)
  24858. defer resp.Body.Close()
  24859. body, ioErr := ioutil.ReadAll(resp.Body)
  24860. if ioErr != nil {
  24861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24863. return
  24864. }
  24865. var respJSON map[string]interface{}
  24866. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24869. return
  24870. }
  24871. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24872. userJSONBytes, _ := json.Marshal(respJSON)
  24873. fmt.Println("log")
  24874. fmt.Println(string(userJSONBytes))
  24875. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24876. utils.ErrorLog("解析失败:%v", err)
  24877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24878. return
  24879. }
  24880. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24881. bytesData, _ := json.Marshal(data)
  24882. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  24883. resp, _ := client.Do(req)
  24884. defer resp.Body.Close()
  24885. body, ioErr := ioutil.ReadAll(resp.Body)
  24886. if ioErr != nil {
  24887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24889. return
  24890. }
  24891. var respJSON map[string]interface{}
  24892. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24895. return
  24896. }
  24897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24898. userJSONBytes, _ := json.Marshal(respJSON)
  24899. fmt.Println("log")
  24900. fmt.Println(string(userJSONBytes))
  24901. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24902. utils.ErrorLog("解析失败:%v", err)
  24903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24904. return
  24905. }
  24906. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24907. bytesData, _ := json.Marshal(data)
  24908. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  24909. resp, _ := client.Do(req)
  24910. defer resp.Body.Close()
  24911. body, ioErr := ioutil.ReadAll(resp.Body)
  24912. if ioErr != nil {
  24913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24915. return
  24916. }
  24917. var respJSON map[string]interface{}
  24918. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24921. return
  24922. }
  24923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24924. userJSONBytes, _ := json.Marshal(respJSON)
  24925. fmt.Println("log")
  24926. fmt.Println(string(userJSONBytes))
  24927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24928. utils.ErrorLog("解析失败:%v", err)
  24929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24930. return
  24931. }
  24932. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24933. bytesData, _ := json.Marshal(data)
  24934. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  24935. resp, _ := client.Do(req)
  24936. defer resp.Body.Close()
  24937. body, ioErr := ioutil.ReadAll(resp.Body)
  24938. if ioErr != nil {
  24939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24941. return
  24942. }
  24943. var respJSON map[string]interface{}
  24944. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24947. return
  24948. }
  24949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24950. userJSONBytes, _ := json.Marshal(respJSON)
  24951. fmt.Println("log")
  24952. fmt.Println(string(userJSONBytes))
  24953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24954. utils.ErrorLog("解析失败:%v", err)
  24955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24956. return
  24957. }
  24958. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24959. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  24960. if result3101.Infcode == "0" {
  24961. if len(result3101.Output.Result) > 0 {
  24962. var errMsgs []string
  24963. for _, item := range result3101.Output.Result {
  24964. errMsgs = append(errMsgs, item.VolaCont)
  24965. }
  24966. c.ServeSuccessJSON(map[string]interface{}{
  24967. "failed_code": -10,
  24968. "msg": errMsgs,
  24969. })
  24970. return
  24971. }
  24972. }
  24973. bytesData, _ := json.Marshal(data)
  24974. var req *http.Request
  24975. if miConfig.MdtrtareaAdmvs == "320921" {
  24976. data["diag_code"] = sickConfig.CountryCode
  24977. fmt.Println(data)
  24978. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24979. } else {
  24980. data["diag_code"] = sickConfig.CountryCode
  24981. fmt.Println(data)
  24982. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24983. }
  24984. resp, _ := client.Do(req)
  24985. defer resp.Body.Close()
  24986. body, ioErr := ioutil.ReadAll(resp.Body)
  24987. if ioErr != nil {
  24988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24990. return
  24991. }
  24992. var respJSON map[string]interface{}
  24993. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24996. return
  24997. }
  24998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24999. userJSONBytes, _ := json.Marshal(respJSON)
  25000. fmt.Println("log")
  25001. fmt.Println(string(userJSONBytes))
  25002. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25003. utils.ErrorLog("解析失败:%v", err)
  25004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25005. return
  25006. }
  25007. res.InfRefmsgid = resFour10265.InfRefmsgid
  25008. res.Output = resFour10265.Output
  25009. res.ErrMsg = resFour10265.ErrMsg
  25010. res.Cainfo = resFour10265.Cainfo
  25011. res.WarnMsg = resFour10265.WarnMsg
  25012. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25013. res.Infcode = infocode
  25014. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25015. var pagesize int = 2
  25016. var start int = 1
  25017. var stop int
  25018. var pagecount int
  25019. var curpage int
  25020. var isSuccess bool = true
  25021. data["doctor_id"] = doctor_info.DoctorNumber
  25022. //总页数,向上取整,注意除之前要先转换类型为float64
  25023. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25024. for curpage = 1; curpage <= pagecount; curpage++ {
  25025. if curpage == 1 {
  25026. start = 1
  25027. } else {
  25028. start = (curpage-1)*pagesize + 1
  25029. }
  25030. stop = curpage * pagesize
  25031. if stop > len(prescriptions) {
  25032. stop = len(prescriptions)
  25033. }
  25034. //var requestLog string
  25035. data["pre"] = prescriptions[start-1 : stop]
  25036. fmt.Println(data["pre"])
  25037. bytesData, _ := json.Marshal(data)
  25038. var req *http.Request
  25039. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25040. resp, _ := client.Do(req)
  25041. defer resp.Body.Close()
  25042. body, ioErr := ioutil.ReadAll(resp.Body)
  25043. if ioErr != nil {
  25044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25046. return
  25047. }
  25048. var respJSON map[string]interface{}
  25049. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25052. return
  25053. }
  25054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25055. userJSONBytes, _ := json.Marshal(respJSON)
  25056. fmt.Println("log")
  25057. fmt.Println(string(userJSONBytes))
  25058. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25059. utils.ErrorLog("解析失败:%v", err)
  25060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25061. return
  25062. }
  25063. res.InfRefmsgid = resFour10265.InfRefmsgid
  25064. res.Output = resFour10265.Output
  25065. res.ErrMsg = resFour10265.ErrMsg
  25066. res.Cainfo = resFour10265.Cainfo
  25067. res.WarnMsg = resFour10265.WarnMsg
  25068. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25069. res.Infcode = infocode
  25070. if infocode == 0 {
  25071. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25072. } else {
  25073. isSuccess = false
  25074. errlog := &models.HisOrderError{
  25075. UserOrgId: adminUser.CurrentOrgId,
  25076. Ctime: time.Now().Unix(),
  25077. Mtime: time.Now().Unix(),
  25078. Number: chrg_bchno,
  25079. ErrMsg: "",
  25080. Status: 1,
  25081. PatientId: id,
  25082. RecordTime: recordDateTime,
  25083. Stage: 4,
  25084. }
  25085. service.CreateErrMsgLog(errlog)
  25086. c.ServeSuccessJSON(map[string]interface{}{
  25087. "failed_code": -10,
  25088. "msg": res.ErrMsg,
  25089. })
  25090. return
  25091. }
  25092. }
  25093. if isSuccess {
  25094. res.Infcode = 0
  25095. }
  25096. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25097. 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)
  25098. var dat map[string]interface{}
  25099. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25100. fmt.Println(dat)
  25101. } else {
  25102. fmt.Println(err)
  25103. }
  25104. saveLog(result, request_log, "2204", "上传费用明细")
  25105. userJSONBytes, _ := json.Marshal(dat)
  25106. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25107. utils.ErrorLog("解析失败:%v", err)
  25108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25109. return
  25110. }
  25111. res.InfRefmsgid = resFour10265.InfRefmsgid
  25112. res.Output = resFour10265.Output
  25113. res.ErrMsg = resFour10265.ErrMsg
  25114. res.Cainfo = resFour10265.Cainfo
  25115. res.WarnMsg = resFour10265.WarnMsg
  25116. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25117. res.Infcode = infocode
  25118. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25119. bytesData, _ := json.Marshal(data)
  25120. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25121. resp, _ := client.Do(req)
  25122. defer resp.Body.Close()
  25123. body, ioErr := ioutil.ReadAll(resp.Body)
  25124. if ioErr != nil {
  25125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25127. return
  25128. }
  25129. var respJSON map[string]interface{}
  25130. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25133. return
  25134. }
  25135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25136. userJSONBytes, _ := json.Marshal(respJSON)
  25137. fmt.Println("log")
  25138. fmt.Println(string(userJSONBytes))
  25139. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25140. utils.ErrorLog("解析失败:%v", err)
  25141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25142. return
  25143. }
  25144. } else {
  25145. if miConfig.Code == "H15049901371" {
  25146. 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)
  25147. var dat map[string]interface{}
  25148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25149. fmt.Println(dat)
  25150. } else {
  25151. fmt.Println(err)
  25152. }
  25153. saveLog(result, request_log, "2204", "上传费用明细")
  25154. userJSONBytes, _ := json.Marshal(dat)
  25155. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25156. utils.ErrorLog("解析失败:%v", err)
  25157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25158. return
  25159. }
  25160. res.InfRefmsgid = resFour10265.InfRefmsgid
  25161. res.Output = resFour10265.Output
  25162. res.ErrMsg = resFour10265.ErrMsg
  25163. res.Cainfo = resFour10265.Cainfo
  25164. res.WarnMsg = resFour10265.WarnMsg
  25165. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25166. res.Infcode = infocode
  25167. } else {
  25168. 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)
  25169. var dat map[string]interface{}
  25170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25171. fmt.Println(dat)
  25172. } else {
  25173. fmt.Println(err)
  25174. }
  25175. saveLog(result, request_log, "2204", "上传费用明细")
  25176. userJSONBytes, _ := json.Marshal(dat)
  25177. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25178. utils.ErrorLog("解析失败:%v", err)
  25179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25180. return
  25181. }
  25182. }
  25183. }
  25184. if res.Infcode == 0 {
  25185. order := &models.HisOrder{
  25186. UserOrgId: adminUser.CurrentOrgId,
  25187. HisPatientId: his.ID,
  25188. PatientId: his.PatientId,
  25189. SettleAccountsDate: recordDateTime,
  25190. MdtrtId: his.Number,
  25191. PsnNo: his.PsnNo,
  25192. MedType: strconv.FormatInt(reg_type, 10),
  25193. Ctime: time.Now().Unix(),
  25194. Mtime: time.Now().Unix(),
  25195. Status: 1,
  25196. Number: chrg_bchno,
  25197. Infcode: res.Infcode,
  25198. WarnMsg: res.WarnMsg,
  25199. Cainfo: res.Cainfo,
  25200. ErrMsg: res.ErrMsg,
  25201. RespondTime: res.RefmsgTime,
  25202. InfRefmsgid: res.InfRefmsgid,
  25203. OrderStatus: 1,
  25204. PayWay: pay_way,
  25205. PayWays: pay_ways,
  25206. OthDesc: oth_desc,
  25207. PayPrice: pay_price,
  25208. PayCardNo: pay_card_no,
  25209. DiscountPrice: discount_price,
  25210. PreferentialPrice: preferential_price,
  25211. RealityPrice: reality_price,
  25212. FoundPrice: found_price,
  25213. MedicalInsurancePrice: medical_insurance_price,
  25214. PrivatePrice: private_price,
  25215. IsMedicineInsurance: 1,
  25216. SettleType: settle_accounts_type,
  25217. SettleStartTime: start_time,
  25218. SettleEndTime: end_time,
  25219. Creator: roles.AdminUserId,
  25220. Modify: roles.AdminUserId,
  25221. FaPiaoNumber: fapiao_number,
  25222. FaPiaoCode: fapiao_code,
  25223. PType: 2,
  25224. Diagnosis: diagnosis_id,
  25225. CashPay: cash_pay,
  25226. WechatPay: wechat_pay,
  25227. AliPay: ali_pay,
  25228. JifenPay: jifen_pay,
  25229. BandCardPay: band_card_pay,
  25230. }
  25231. err = service.CreateOrder(order)
  25232. if err != nil {
  25233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25234. return
  25235. }
  25236. for _, item := range res.Output.Result {
  25237. temp := strings.Split(item.FeedetlSn, "-")
  25238. var advice_id int64 = 0
  25239. var project_id int64 = 0
  25240. var types int64 = 0
  25241. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25242. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25243. if temp[1] == "1" {
  25244. advice_id = id
  25245. project_id = 0
  25246. } else if temp[1] == "2" {
  25247. advice_id = 0
  25248. project_id = id
  25249. }
  25250. if item.MedChrgitmType == "9" {
  25251. item.MedChrgitmType = "09"
  25252. }
  25253. info := &models.HisOrderInfo{
  25254. OrderNumber: order.Number,
  25255. FeedetlSn: item.FeedetlSn,
  25256. UploadDate: time.Now().Unix(),
  25257. AdviceId: advice_id,
  25258. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25259. Cnt: item.Cnt,
  25260. Pric: float64(item.Pric),
  25261. PatientId: his.PatientId,
  25262. PricUplmtAmt: item.PricUplmtAmt,
  25263. SelfpayProp: item.SelfpayProp,
  25264. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25265. OverlmtAmt: item.OverlmtAmt,
  25266. PreselfpayAmt: item.PreselfpayAmt,
  25267. BasMednFlag: item.BasMednFlag,
  25268. MedChrgitmType: item.MedChrgitmType,
  25269. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25270. Status: 1,
  25271. Memo: item.Memo,
  25272. Mtime: time.Now().Unix(),
  25273. InscpScpAmt: item.InscpScpAmt,
  25274. DrtReimFlag: item.DrtReimFlag,
  25275. Ctime: time.Now().Unix(),
  25276. ListSpItemFlag: item.ListSpItemFlag,
  25277. ChldMedcFlag: item.ChldMedcFlag,
  25278. LmtUsedFlag: item.LmtUsedFlag,
  25279. ChrgitmLv: item.ChrgitmLv,
  25280. UserOrgId: adminUser.CurrentOrgId,
  25281. HisPatientId: his.ID,
  25282. OrderId: order.ID,
  25283. ProjectId: project_id,
  25284. Type: types,
  25285. }
  25286. service.CreateOrderInfo(info)
  25287. }
  25288. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25289. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25290. var total float64
  25291. for _, item := range prescriptions {
  25292. if item.Type == 1 { //药品
  25293. for _, subItem := range item.HisDoctorAdviceInfo {
  25294. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25295. total_one := price * subItem.PrescribingNumber
  25296. total = total + total_one
  25297. }
  25298. }
  25299. if item.Type == 2 { //项目
  25300. for _, subItem := range item.HisPrescriptionProject {
  25301. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25302. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25303. total_one := price * cnt
  25304. total = total + total_one
  25305. }
  25306. }
  25307. }
  25308. allTotal := fmt.Sprintf("%.2f", total)
  25309. //if adminUser.CurrentOrgId == 9919 {
  25310. //
  25311. // allTotal = fmt.Sprintf("%.2f", total)
  25312. //
  25313. //} else {
  25314. //
  25315. // allTotal = fmt.Sprintf("%.2f", total)
  25316. //
  25317. //}
  25318. if res.Infcode == 0 {
  25319. var rf []*ResultFive
  25320. json.Unmarshal([]byte(his.Iinfo), &rf)
  25321. chrg_bchno := chrg_bchno
  25322. cert_no := his.Certno
  25323. var insutypes []string
  25324. var insutype string
  25325. var is390 int = 0
  25326. var is310 int = 0
  25327. for _, item := range rf {
  25328. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25329. insutypes = append(insutypes, item.Insutype)
  25330. }
  25331. }
  25332. if len(insutypes) == 1 {
  25333. insutype = insutypes[0]
  25334. } else {
  25335. for _, i := range insutypes {
  25336. if i == "390" {
  25337. is390 = 1
  25338. }
  25339. if i == "310" {
  25340. is310 = 1
  25341. }
  25342. }
  25343. }
  25344. if is390 == 1 {
  25345. insutype = "390"
  25346. }
  25347. if is310 == 1 {
  25348. insutype = "310"
  25349. }
  25350. if len(insutypes) == 0 {
  25351. insutype = "310"
  25352. }
  25353. if len(insutypes) == 2 {
  25354. insutype = strconv.FormatInt(his.SocialType, 10)
  25355. }
  25356. insutype = strconv.FormatInt(his.SocialType, 10)
  25357. //insutype = "390"
  25358. if his.IdCardType == 1 {
  25359. // cert_no = his.MedicalInsuranceNumber
  25360. cert_no = his.Certno
  25361. } else {
  25362. cert_no = his.Certno
  25363. }
  25364. var res ResultSeven
  25365. var resSeven10265 ResultSeven10265
  25366. var gzresSeven10265Two GZResultSeven10265Two
  25367. var src_resquest string
  25368. var result2 string
  25369. if miConfig.MdtrtareaAdmvs == "421300" {
  25370. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25371. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25372. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25373. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25374. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25375. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25376. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25377. resp, requestErr := http.Get(api)
  25378. if requestErr != nil {
  25379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25380. return
  25381. }
  25382. body, ioErr := ioutil.ReadAll(resp.Body)
  25383. if ioErr != nil {
  25384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25386. return
  25387. }
  25388. var respJSON map[string]interface{}
  25389. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25392. return
  25393. }
  25394. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25395. result, _ := json.Marshal(respJSON)
  25396. if miConfig.Code == "H15049901371" {
  25397. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25398. utils.ErrorLog("解析失败:%v", err)
  25399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25400. return
  25401. }
  25402. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25403. res.Output = resSeven10265.Output
  25404. res.ErrMsg = resSeven10265.ErrMsg
  25405. res.Cainfo = resSeven10265.Cainfo
  25406. res.WarnMsg = resSeven10265.WarnMsg
  25407. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25408. res.Infcode = infocode
  25409. } else {
  25410. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25411. utils.ErrorLog("解析失败:%v", err)
  25412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25413. return
  25414. }
  25415. }
  25416. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25417. if reg_type == 11 && his.Insutype == "390" {
  25418. reg_type = 110104
  25419. }
  25420. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25421. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25422. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25423. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25424. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25425. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25426. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25427. resp, requestErr := http.Get(api)
  25428. if requestErr != nil {
  25429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25430. return
  25431. }
  25432. body, ioErr := ioutil.ReadAll(resp.Body)
  25433. if ioErr != nil {
  25434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25436. return
  25437. }
  25438. var respJSON map[string]interface{}
  25439. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25442. return
  25443. }
  25444. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25445. result, _ := json.Marshal(respJSON)
  25446. if miConfig.Code == "H15049901371" {
  25447. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25448. utils.ErrorLog("解析失败:%v", err)
  25449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25450. return
  25451. }
  25452. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25453. res.Output = resSeven10265.Output
  25454. res.ErrMsg = resSeven10265.ErrMsg
  25455. res.Cainfo = resSeven10265.Cainfo
  25456. res.WarnMsg = resSeven10265.WarnMsg
  25457. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25458. res.Infcode = infocode
  25459. } else {
  25460. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25461. utils.ErrorLog("解析失败:%v", err)
  25462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25463. return
  25464. }
  25465. }
  25466. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25467. if reg_type == 11 && his.Insutype == "390" {
  25468. reg_type = 110104
  25469. }
  25470. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25471. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25472. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25473. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25474. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25475. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25476. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25477. resp, requestErr := http.Get(api)
  25478. if requestErr != nil {
  25479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25480. return
  25481. }
  25482. body, ioErr := ioutil.ReadAll(resp.Body)
  25483. if ioErr != nil {
  25484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25486. return
  25487. }
  25488. var respJSON map[string]interface{}
  25489. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25492. return
  25493. }
  25494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25495. result, _ := json.Marshal(respJSON)
  25496. if miConfig.Code == "H15049901371" {
  25497. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25498. utils.ErrorLog("解析失败:%v", err)
  25499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25500. return
  25501. }
  25502. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25503. res.Output = resSeven10265.Output
  25504. res.ErrMsg = resSeven10265.ErrMsg
  25505. res.Cainfo = resSeven10265.Cainfo
  25506. res.WarnMsg = resSeven10265.WarnMsg
  25507. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25508. res.Infcode = infocode
  25509. } else {
  25510. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25511. utils.ErrorLog("解析失败:%v", err)
  25512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25513. return
  25514. }
  25515. }
  25516. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25517. if reg_type == 11 && his.Insutype == "390" {
  25518. reg_type = 110104
  25519. }
  25520. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25521. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25522. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25523. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25524. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25525. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25526. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25527. resp, requestErr := http.Get(api)
  25528. if requestErr != nil {
  25529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25530. return
  25531. }
  25532. body, ioErr := ioutil.ReadAll(resp.Body)
  25533. if ioErr != nil {
  25534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25536. return
  25537. }
  25538. var respJSON map[string]interface{}
  25539. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25542. return
  25543. }
  25544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25545. result, _ := json.Marshal(respJSON)
  25546. if miConfig.Code == "H15049901371" {
  25547. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25548. utils.ErrorLog("解析失败:%v", err)
  25549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25550. return
  25551. }
  25552. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25553. res.Output = resSeven10265.Output
  25554. res.ErrMsg = resSeven10265.ErrMsg
  25555. res.Cainfo = resSeven10265.Cainfo
  25556. res.WarnMsg = resSeven10265.WarnMsg
  25557. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25558. res.Infcode = infocode
  25559. } else {
  25560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25561. utils.ErrorLog("解析失败:%v", err)
  25562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25563. return
  25564. }
  25565. }
  25566. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25567. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  25568. if result3101.Infcode == "0" {
  25569. if len(result3101.Output.Result) > 0 {
  25570. var errMsgs []string
  25571. for _, item := range result3101.Output.Result {
  25572. errMsgs = append(errMsgs, item.VolaCont)
  25573. }
  25574. c.ServeSuccessJSON(map[string]interface{}{
  25575. "failed_code": -10,
  25576. "msg": errMsgs,
  25577. })
  25578. return
  25579. } else {
  25580. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25581. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25582. bas := strings.Split(psn_info.CardInfo, "|")
  25583. if his.IdCardType == 1 {
  25584. cert_no = bas[2]
  25585. } else if his.IdCardType == 3 {
  25586. cert_no = his.Certno
  25587. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25588. } else if his.IdCardType == 4 {
  25589. cert_no = his.Certno
  25590. psn_info.VerifyNumber = psn_info.VerifyNumber
  25591. }
  25592. var api string
  25593. if miConfig.MdtrtareaAdmvs == "320921" {
  25594. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25595. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25596. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25597. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25598. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25599. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25600. "&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
  25601. } else {
  25602. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25603. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25604. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25605. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25606. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25607. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25608. "&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
  25609. }
  25610. resp, requestErr := http.Get(api)
  25611. if requestErr != nil {
  25612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25613. return
  25614. }
  25615. body, ioErr := ioutil.ReadAll(resp.Body)
  25616. if ioErr != nil {
  25617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25619. return
  25620. }
  25621. var respJSON map[string]interface{}
  25622. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25625. return
  25626. }
  25627. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25628. result, _ := json.Marshal(respJSON)
  25629. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25630. utils.ErrorLog("解析失败:%v", err)
  25631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25632. return
  25633. }
  25634. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25635. res.Output = resSeven10265.Output
  25636. res.ErrMsg = resSeven10265.ErrMsg
  25637. res.Cainfo = resSeven10265.Cainfo
  25638. res.WarnMsg = resSeven10265.WarnMsg
  25639. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25640. res.Infcode = infocode
  25641. }
  25642. }
  25643. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25644. psn_info, _ := service.GetPsnByPatientId(id)
  25645. var verify_number string
  25646. if psn_info.IdCardType == 4 {
  25647. verify_number = psn_info.VerifyNumber
  25648. } else if psn_info.IdCardType == 1 {
  25649. bas := strings.Split(psn_info.CardInfo, "|")
  25650. cardNumber := bas[2]
  25651. verify_number = cardNumber
  25652. } else {
  25653. psn_info.IdCardType = 2
  25654. verify_number = psn_info.Certno
  25655. }
  25656. var api string
  25657. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25658. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25659. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25660. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25661. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25662. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25663. "&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
  25664. resp, requestErr := http.Get(api)
  25665. if requestErr != nil {
  25666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25667. return
  25668. }
  25669. body, ioErr := ioutil.ReadAll(resp.Body)
  25670. if ioErr != nil {
  25671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25673. return
  25674. }
  25675. var respJSON map[string]interface{}
  25676. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25679. return
  25680. }
  25681. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25682. result, _ := json.Marshal(respJSON)
  25683. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25684. utils.ErrorLog("解析失败:%v", err)
  25685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25686. return
  25687. }
  25688. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25689. res.Output = resSeven10265.Output
  25690. res.ErrMsg = resSeven10265.ErrMsg
  25691. res.Cainfo = resSeven10265.Cainfo
  25692. res.WarnMsg = resSeven10265.WarnMsg
  25693. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25694. res.Infcode = infocode
  25695. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25696. var cert_no string
  25697. if his.IdCardType == 4 {
  25698. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25699. cert_no = psn_info.VerifyNumber
  25700. 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)
  25701. } else if his.IdCardType == 1 {
  25702. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25703. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25704. 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)
  25705. }
  25706. //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)
  25707. var dat map[string]interface{}
  25708. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25709. fmt.Println(dat)
  25710. } else {
  25711. fmt.Println(err)
  25712. }
  25713. saveLog(result2, src_resquest, "2207", "结算")
  25714. userJSONBytes, _ := json.Marshal(dat)
  25715. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  25716. utils.ErrorLog("解析失败:%v", err)
  25717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25718. return
  25719. }
  25720. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25721. res.Output = resSeven10265.Output
  25722. res.ErrMsg = resSeven10265.ErrMsg
  25723. res.Cainfo = resSeven10265.Cainfo
  25724. res.WarnMsg = resSeven10265.WarnMsg
  25725. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25726. res.Infcode = infocode
  25727. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25728. res2 := c.GetoleInfo()
  25729. if res2.Infcode == 0 {
  25730. var result string
  25731. var request_log string
  25732. var result_log string
  25733. if res2.Output.MdtrtCertType == "02" {
  25734. 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)
  25735. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25736. } else if res2.Output.MdtrtCertType == "01" {
  25737. 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)
  25738. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25739. } else {
  25740. 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)
  25741. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25742. }
  25743. var dat map[string]interface{}
  25744. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25745. fmt.Println(dat)
  25746. } else {
  25747. fmt.Println(err)
  25748. }
  25749. userJSONBytes, _ := json.Marshal(dat)
  25750. var res5 ResultTwo
  25751. //var resTwo10265 ResultTwo10265
  25752. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  25753. utils.ErrorLog("解析失败:%v", err)
  25754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25755. return
  25756. }
  25757. if res5.Infcode == -1 {
  25758. c.ServeSuccessJSON(map[string]interface{}{
  25759. "failed_code": -10,
  25760. "msg": res5.ErrMsg,
  25761. })
  25762. return
  25763. }
  25764. var insutypes []string
  25765. var insutype string
  25766. var is390 int = 0
  25767. var is310 int = 0
  25768. for _, item := range res5.Output.Iinfo {
  25769. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25770. insutypes = append(insutypes, item.Insutype)
  25771. }
  25772. }
  25773. if len(insutypes) == 1 {
  25774. insutype = insutypes[0]
  25775. } else {
  25776. for _, i := range insutypes {
  25777. if i == "390" {
  25778. is390 = 1
  25779. }
  25780. if i == "310" {
  25781. is310 = 1
  25782. }
  25783. }
  25784. }
  25785. if is390 == 1 {
  25786. insutype = "390"
  25787. }
  25788. if is310 == 1 {
  25789. insutype = "310"
  25790. }
  25791. if len(insutypes) == 0 {
  25792. insutype = "310"
  25793. }
  25794. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  25795. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  25796. infoStr := string(Iinfos)
  25797. idetinfoStr := string(Idetinfos)
  25798. psn := &models.HisPsn{
  25799. PsnNo: res5.Output.Baseinfo.PsnNo,
  25800. PatientId: id,
  25801. Certno: res5.Output.Baseinfo.Certno,
  25802. Gend: res5.Output.Baseinfo.Gend,
  25803. Naty: res5.Output.Baseinfo.Naty,
  25804. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  25805. PsnName: res5.Output.Baseinfo.PsnName,
  25806. Idetinfo: idetinfoStr,
  25807. Insuinfo: infoStr,
  25808. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  25809. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  25810. VerifyNumber: res2.Output.EcToken,
  25811. }
  25812. if res2.Output.MdtrtCertType == "01" {
  25813. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25814. psn.VerifyNumber = res2.Output.EcToken
  25815. } else if res2.Output.MdtrtCertType == "02" {
  25816. psn.VerifyNumber = res2.Output.CardNo
  25817. } else {
  25818. psn.VerifyNumber = res2.Output.MdtrtCertNo
  25819. }
  25820. service.CreateHisPsn(psn)
  25821. if res2.Output.MdtrtCertType == "01" {
  25822. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25823. token := res2.Output.EcToken
  25824. 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)
  25825. } else if res2.Output.MdtrtCertType == "02" {
  25826. 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)
  25827. } else {
  25828. 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)
  25829. }
  25830. var dat2 map[string]interface{}
  25831. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  25832. fmt.Println(dat2)
  25833. } else {
  25834. fmt.Println(err)
  25835. }
  25836. userJSONBytes3, _ := json.Marshal(dat2)
  25837. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  25838. utils.ErrorLog("解析失败:%v", err)
  25839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25840. return
  25841. }
  25842. saveLog(result2, src_resquest, "2207", "结算")
  25843. } else {
  25844. c.ServeSuccessJSON(map[string]interface{}{
  25845. "failed_code": -10,
  25846. "msg": res2.ErrMsg,
  25847. })
  25848. return
  25849. }
  25850. } else {
  25851. if miConfig.Code == "H15049901371" {
  25852. //赤峰地区国家医保医疗类别
  25853. //职工透析:医疗类别选特殊情况门诊990502
  25854. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25855. var med_type string
  25856. if his.Insutype == "390" {
  25857. if reg_type == 14 {
  25858. med_type = "9933"
  25859. } else if reg_type == 11 {
  25860. med_type = "11"
  25861. }
  25862. } else if his.Insutype == "310" {
  25863. if reg_type == 14 {
  25864. med_type = "990502"
  25865. } else if reg_type == 11 {
  25866. med_type = "11"
  25867. }
  25868. }
  25869. 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)
  25870. } else {
  25871. if his.IdCardType == 4 {
  25872. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25873. var token string
  25874. token = psn_info.VerifyNumber
  25875. 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)
  25876. } else {
  25877. if his.IdCardType == 1 {
  25878. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25879. bas := strings.Split(psn_info.CardInfo, "|")
  25880. basNumber := bas[2]
  25881. cert_no = basNumber
  25882. }
  25883. 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)
  25884. }
  25885. }
  25886. //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)
  25887. var dat map[string]interface{}
  25888. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25889. fmt.Println(dat)
  25890. } else {
  25891. fmt.Println(err)
  25892. }
  25893. saveLog(result2, src_resquest, "2207", "结算")
  25894. userJSONBytes, _ := json.Marshal(dat)
  25895. if miConfig.Code == "H15049901371" {
  25896. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  25897. utils.ErrorLog("解析失败:%v", err)
  25898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25899. return
  25900. }
  25901. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25902. res.Output = resSeven10265.Output
  25903. res.ErrMsg = resSeven10265.ErrMsg
  25904. res.Cainfo = resSeven10265.Cainfo
  25905. res.WarnMsg = resSeven10265.WarnMsg
  25906. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25907. res.Infcode = infocode
  25908. } else {
  25909. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25910. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  25911. utils.ErrorLog("解析失败:%v", err)
  25912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25913. return
  25914. }
  25915. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  25916. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  25917. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  25918. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25919. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  25920. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  25921. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  25922. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25923. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  25924. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25925. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25926. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25927. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25928. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25929. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  25930. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  25931. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  25932. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  25933. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  25934. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  25935. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25936. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  25937. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  25938. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  25939. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  25940. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  25941. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  25942. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  25943. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  25944. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  25945. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  25946. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  25947. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  25948. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  25949. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  25950. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  25951. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  25952. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  25953. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25954. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  25955. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  25956. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  25957. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  25958. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  25959. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  25960. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  25961. res.ErrMsg = gzresSeven10265Two.ErrMsg
  25962. res.Cainfo = gzresSeven10265Two.Cainfo
  25963. res.WarnMsg = gzresSeven10265Two.WarnMsg
  25964. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  25965. //res.Infcode = infocode
  25966. } else {
  25967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25968. utils.ErrorLog("解析失败:%v", err)
  25969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25970. return
  25971. }
  25972. }
  25973. }
  25974. }
  25975. if res.Infcode == -1 {
  25976. errlog := &models.HisOrderError{
  25977. UserOrgId: adminUser.CurrentOrgId,
  25978. Ctime: time.Now().Unix(),
  25979. Mtime: time.Now().Unix(),
  25980. Number: chrg_bchno,
  25981. ErrMsg: res.ErrMsg,
  25982. Status: 1,
  25983. PatientId: id,
  25984. RecordTime: recordDateTime,
  25985. Stage: 6,
  25986. }
  25987. service.CreateErrMsgLog(errlog)
  25988. c.ServeSuccessJSON(map[string]interface{}{
  25989. "failed_code": -10,
  25990. "msg": res.ErrMsg,
  25991. })
  25992. return
  25993. } else {
  25994. sickConfig, _ := service.FindSickById(his.SickType)
  25995. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  25996. order.OrderStatus = 2
  25997. order.Status = 1
  25998. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  25999. order.SetlId = res.Output.Setlinfo.SetlID
  26000. order.PsnNo = res.Output.Setlinfo.PsnNo
  26001. order.PsnName = res.Output.Setlinfo.PsnName
  26002. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26003. order.Certno = res.Output.Setlinfo.Certno
  26004. order.Gend = res.Output.Setlinfo.Gend
  26005. order.Naty = res.Output.Setlinfo.Naty
  26006. order.Age = res.Output.Setlinfo.Age
  26007. order.Insutype = res.Output.Setlinfo.Insutype
  26008. order.PsnType = res.Output.Setlinfo.PsnType
  26009. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26010. order.SetlTime = res.Output.Setlinfo.SetlTime
  26011. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26012. if res.Output.Setlinfo.MedType == "140101" {
  26013. order.MedType = "14"
  26014. } else {
  26015. if res.Output.Setlinfo.MedType == "110104" {
  26016. order.MedType = "11"
  26017. } else {
  26018. order.MedType = res.Output.Setlinfo.MedType
  26019. }
  26020. }
  26021. if reg_type == 1112 {
  26022. order.MedType = "1112"
  26023. }
  26024. if reg_type == 1111 {
  26025. order.MedType = "1111"
  26026. }
  26027. order.ClrType = res.Output.Setlinfo.ClrType
  26028. if adminUser.CurrentOrgId == 10480 {
  26029. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26030. order.ClrType = "11"
  26031. } else {
  26032. order.ClrType = "9903"
  26033. }
  26034. }
  26035. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26036. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26037. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26038. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26039. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26040. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26041. order.HifpPay = res.Output.Setlinfo.HifpPay
  26042. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26043. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26044. order.HifesPay = res.Output.Setlinfo.HifesPay
  26045. order.HifobPay = res.Output.Setlinfo.HifobPay
  26046. order.MafPay = res.Output.Setlinfo.MafPay
  26047. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26048. order.OthPay = res.Output.Setlinfo.OthPay
  26049. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26050. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26051. order.AcctPay = res.Output.Setlinfo.AcctPay
  26052. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26053. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26054. order.Balc = res.Output.Setlinfo.Balc
  26055. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26056. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26057. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26058. //order.ClrType = res.Output.Setlinfo.ClrType
  26059. order.ClrWay = res.Output.Setlinfo.ClrWay
  26060. order.Creator = order.Creator
  26061. order.Modify = roles.AdminUserId
  26062. order.RequestLog = src_resquest
  26063. order.FaPiaoNumber = fapiao_number
  26064. order.FaPiaoCode = fapiao_code
  26065. order.SickName = sickConfig.ClassName
  26066. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26067. //detailStr := string(setlDetail)
  26068. //order.SetlDetail = detailStr
  26069. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26070. err = service.UpDateOrder(order)
  26071. if err == nil {
  26072. //判断是否使用了押金
  26073. if dec_way == "true" {
  26074. tmpstring := strconv.FormatInt(order.ID, 10)
  26075. order.Decimal = decimal
  26076. service.UpDateOrder(order)
  26077. //扣押金
  26078. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26079. if errmsg != nil {
  26080. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26081. return
  26082. }
  26083. }
  26084. c.ServeSuccessJSON(map[string]interface{}{
  26085. "msg": "结算成功",
  26086. })
  26087. } else {
  26088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26089. return
  26090. }
  26091. }
  26092. } else {
  26093. adminUser := c.GetAdminUserInfo()
  26094. errlog := &models.HisOrderError{
  26095. UserOrgId: adminUser.CurrentOrgId,
  26096. Ctime: time.Now().Unix(),
  26097. Mtime: time.Now().Unix(),
  26098. ErrMsg: res.ErrMsg,
  26099. Status: 1,
  26100. PatientId: id,
  26101. RecordTime: recordDateTime,
  26102. Stage: 4,
  26103. }
  26104. service.CreateErrMsgLog(errlog)
  26105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26106. return
  26107. }
  26108. } else {
  26109. adminUser := c.GetAdminUserInfo()
  26110. errlog := &models.HisOrderError{
  26111. UserOrgId: adminUser.CurrentOrgId,
  26112. Ctime: time.Now().Unix(),
  26113. Mtime: time.Now().Unix(),
  26114. ErrMsg: res.ErrMsg,
  26115. Status: 1,
  26116. PatientId: id,
  26117. RecordTime: recordDateTime,
  26118. Stage: 4,
  26119. }
  26120. service.CreateErrMsgLog(errlog)
  26121. c.ServeSuccessJSON(map[string]interface{}{
  26122. "failed_code": -10,
  26123. "msg": res.ErrMsg,
  26124. })
  26125. return
  26126. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26127. //return
  26128. }
  26129. }
  26130. }
  26131. } else if tempOrder.ID > 0 {
  26132. if tempOrder.IsPre == 1 {
  26133. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26134. var rf []*ResultFive
  26135. json.Unmarshal([]byte(his.Iinfo), &rf)
  26136. chrg_bchno := tempOrder.Number
  26137. cert_no := his.Certno
  26138. var insutypes []string
  26139. var insutype string
  26140. var is390 int = 0
  26141. var is310 int = 0
  26142. for _, item := range rf {
  26143. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26144. insutypes = append(insutypes, item.Insutype)
  26145. }
  26146. }
  26147. if len(insutypes) == 1 {
  26148. insutype = insutypes[0]
  26149. } else {
  26150. for _, i := range insutypes {
  26151. if i == "390" {
  26152. is390 = 1
  26153. }
  26154. if i == "310" {
  26155. is310 = 1
  26156. }
  26157. }
  26158. }
  26159. if is390 == 1 {
  26160. insutype = "390"
  26161. }
  26162. if is310 == 1 {
  26163. insutype = "310"
  26164. }
  26165. if len(insutypes) == 0 {
  26166. insutype = "310"
  26167. }
  26168. if len(insutypes) == 2 {
  26169. insutype = strconv.FormatInt(his.SocialType, 10)
  26170. }
  26171. //insutype = "390"
  26172. if his.IdCardType == 1 {
  26173. // cert_no = his.MedicalInsuranceNumber
  26174. cert_no = his.Certno
  26175. } else {
  26176. cert_no = his.Certno
  26177. }
  26178. var res ResultSeven
  26179. var ahres ResultSevenAH
  26180. var resSeven10265 ResultSeven10265
  26181. var gzresSeven10265Two GZResultSeven10265Two
  26182. var src_resquest string
  26183. var result2 string
  26184. if miConfig.MdtrtareaAdmvs == "450721" {
  26185. res2 := c.GetoleInfo()
  26186. if res2.Infcode == 0 {
  26187. var result string
  26188. var request_log string
  26189. var result_log string
  26190. if res2.Output.MdtrtCertType == "02" {
  26191. 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)
  26192. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26193. } else if res2.Output.MdtrtCertType == "01" {
  26194. 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)
  26195. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26196. } else {
  26197. 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)
  26198. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26199. }
  26200. var dat map[string]interface{}
  26201. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26202. fmt.Println(dat)
  26203. } else {
  26204. fmt.Println(err)
  26205. }
  26206. userJSONBytes, _ := json.Marshal(dat)
  26207. var res5 ResultTwo
  26208. //var resTwo10265 ResultTwo10265
  26209. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26210. utils.ErrorLog("解析失败:%v", err)
  26211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26212. return
  26213. }
  26214. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26215. if res5.Infcode == -1 {
  26216. c.ServeSuccessJSON(map[string]interface{}{
  26217. "failed_code": -10,
  26218. "msg": res5.ErrMsg,
  26219. })
  26220. return
  26221. }
  26222. var insutypes []string
  26223. var insutype string
  26224. var is390 int = 0
  26225. var is310 int = 0
  26226. for _, item := range res5.Output.Iinfo {
  26227. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26228. insutypes = append(insutypes, item.Insutype)
  26229. }
  26230. }
  26231. if len(insutypes) == 1 {
  26232. insutype = insutypes[0]
  26233. } else {
  26234. for _, i := range insutypes {
  26235. if i == "390" {
  26236. is390 = 1
  26237. }
  26238. if i == "310" {
  26239. is310 = 1
  26240. }
  26241. }
  26242. }
  26243. if is390 == 1 {
  26244. insutype = "390"
  26245. }
  26246. if is310 == 1 {
  26247. insutype = "310"
  26248. }
  26249. if len(insutypes) == 0 {
  26250. insutype = "310"
  26251. }
  26252. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26253. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26254. infoStr := string(Iinfos)
  26255. idetinfoStr := string(Idetinfos)
  26256. psn := &models.HisPsn{
  26257. PsnNo: res5.Output.Baseinfo.PsnNo,
  26258. PatientId: id,
  26259. Certno: res5.Output.Baseinfo.Certno,
  26260. Gend: res5.Output.Baseinfo.Gend,
  26261. Naty: res5.Output.Baseinfo.Naty,
  26262. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26263. PsnName: res5.Output.Baseinfo.PsnName,
  26264. Idetinfo: idetinfoStr,
  26265. Insuinfo: infoStr,
  26266. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26267. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26268. VerifyNumber: res2.Output.EcToken,
  26269. }
  26270. service.CreateHisPsn(psn)
  26271. if res2.Output.MdtrtCertType == "01" {
  26272. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26273. token := res2.Output.EcToken
  26274. 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)
  26275. } else if res2.Output.MdtrtCertType == "02" {
  26276. 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)
  26277. } else {
  26278. 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)
  26279. }
  26280. var dat2 map[string]interface{}
  26281. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26282. fmt.Println(dat2)
  26283. } else {
  26284. fmt.Println(err)
  26285. }
  26286. userJSONBytes3, _ := json.Marshal(dat2)
  26287. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26288. utils.ErrorLog("解析失败:%v", err)
  26289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26290. return
  26291. }
  26292. saveLog(result2, src_resquest, "2207", "结算")
  26293. } else {
  26294. c.ServeSuccessJSON(map[string]interface{}{
  26295. "failed_code": -10,
  26296. "msg": res2.ErrMsg,
  26297. })
  26298. return
  26299. }
  26300. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26301. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26302. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26303. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26304. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26305. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26306. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26307. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26308. resp, requestErr := http.Get(api)
  26309. if requestErr != nil {
  26310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26311. return
  26312. }
  26313. body, ioErr := ioutil.ReadAll(resp.Body)
  26314. if ioErr != nil {
  26315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26317. return
  26318. }
  26319. var respJSON map[string]interface{}
  26320. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26323. return
  26324. }
  26325. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26326. result, _ := json.Marshal(respJSON)
  26327. fmt.Println("log")
  26328. fmt.Println(string(result))
  26329. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26330. utils.ErrorLog("解析失败:%v", err)
  26331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26332. return
  26333. }
  26334. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26335. if reg_type == 11 && his.Insutype == "390" {
  26336. reg_type = 110104
  26337. }
  26338. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26339. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26340. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26341. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26342. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26343. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26344. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26345. resp, requestErr := http.Get(api)
  26346. if requestErr != nil {
  26347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26348. return
  26349. }
  26350. body, ioErr := ioutil.ReadAll(resp.Body)
  26351. if ioErr != nil {
  26352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26354. return
  26355. }
  26356. var respJSON map[string]interface{}
  26357. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26360. return
  26361. }
  26362. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26363. result, _ := json.Marshal(respJSON)
  26364. fmt.Println("log")
  26365. fmt.Println(string(result))
  26366. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26367. utils.ErrorLog("解析失败:%v", err)
  26368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26369. return
  26370. }
  26371. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26372. if reg_type == 11 && his.Insutype == "390" {
  26373. reg_type = 110104
  26374. }
  26375. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26376. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26377. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26378. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26379. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26380. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26381. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26382. resp, requestErr := http.Get(api)
  26383. if requestErr != nil {
  26384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26385. return
  26386. }
  26387. body, ioErr := ioutil.ReadAll(resp.Body)
  26388. if ioErr != nil {
  26389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26391. return
  26392. }
  26393. var respJSON map[string]interface{}
  26394. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26397. return
  26398. }
  26399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26400. result, _ := json.Marshal(respJSON)
  26401. fmt.Println("log")
  26402. fmt.Println(string(result))
  26403. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26404. utils.ErrorLog("解析失败:%v", err)
  26405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26406. return
  26407. }
  26408. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26409. if reg_type == 11 && his.Insutype == "390" {
  26410. reg_type = 110104
  26411. }
  26412. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26413. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26414. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26415. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26416. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26417. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26418. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26419. resp, requestErr := http.Get(api)
  26420. if requestErr != nil {
  26421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26422. return
  26423. }
  26424. body, ioErr := ioutil.ReadAll(resp.Body)
  26425. if ioErr != nil {
  26426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26428. return
  26429. }
  26430. var respJSON map[string]interface{}
  26431. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26434. return
  26435. }
  26436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26437. result, _ := json.Marshal(respJSON)
  26438. fmt.Println("log")
  26439. fmt.Println(string(result))
  26440. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26441. utils.ErrorLog("解析失败:%v", err)
  26442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26443. return
  26444. }
  26445. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26446. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  26447. if result3101.Infcode == "0" {
  26448. if len(result3101.Output.Result) > 0 {
  26449. var errMsgs []string
  26450. for _, item := range result3101.Output.Result {
  26451. errMsgs = append(errMsgs, item.VolaCont)
  26452. }
  26453. c.ServeSuccessJSON(map[string]interface{}{
  26454. "failed_code": -10,
  26455. "msg": errMsgs,
  26456. })
  26457. return
  26458. } else {
  26459. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26460. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26461. bas := strings.Split(psn_info.CardInfo, "|")
  26462. if his.IdCardType == 1 {
  26463. cert_no = bas[2]
  26464. } else if his.IdCardType == 3 {
  26465. cert_no = his.Certno
  26466. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26467. } else if his.IdCardType == 4 {
  26468. cert_no = his.Certno
  26469. psn_info.VerifyNumber = psn_info.VerifyNumber
  26470. }
  26471. //江苏地区国家医保医疗类别
  26472. //职工透析:医疗类别选特殊情况门诊9933
  26473. //居民血透门慢: 医疗类别选门诊慢病1402
  26474. //var med_type string
  26475. //if his.Insutype == "310" {
  26476. // if reg_type == 14 {
  26477. // med_type = "9933"
  26478. // } else if reg_type == 11 {
  26479. // med_type = "11"
  26480. //
  26481. // }
  26482. //} else if his.Insutype == "390" {
  26483. // if reg_type == 14 {
  26484. // med_type = "1402"
  26485. // } else if reg_type == 11 {
  26486. // med_type = "11"
  26487. // }
  26488. //}
  26489. var api string
  26490. if miConfig.MdtrtareaAdmvs == "320921" {
  26491. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26492. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26493. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26495. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26496. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26497. "&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
  26498. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26499. } else {
  26500. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26501. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26502. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26503. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26505. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26506. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26507. "&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
  26508. }
  26509. resp, requestErr := http.Get(api)
  26510. if requestErr != nil {
  26511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26512. return
  26513. }
  26514. body, ioErr := ioutil.ReadAll(resp.Body)
  26515. if ioErr != nil {
  26516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26518. return
  26519. }
  26520. var respJSON map[string]interface{}
  26521. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26524. return
  26525. }
  26526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26527. result, _ := json.Marshal(respJSON)
  26528. fmt.Println("log")
  26529. fmt.Println(string(result))
  26530. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26531. utils.ErrorLog("解析失败:%v", err)
  26532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26533. return
  26534. }
  26535. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26536. res.Output = resSeven10265.Output
  26537. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26538. res.ErrMsg = resSeven10265.ErrMsg
  26539. res.Cainfo = resSeven10265.Cainfo
  26540. res.WarnMsg = resSeven10265.WarnMsg
  26541. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26542. res.Infcode = infocode
  26543. }
  26544. }
  26545. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26546. psn_info, _ := service.GetPsnByPatientId(id)
  26547. var verify_number string
  26548. if psn_info.IdCardType == 4 {
  26549. verify_number = psn_info.VerifyNumber
  26550. } else if psn_info.IdCardType == 1 {
  26551. bas := strings.Split(psn_info.CardInfo, "|")
  26552. cardNumber := bas[2]
  26553. verify_number = cardNumber
  26554. } else {
  26555. verify_number = psn_info.Certno
  26556. psn_info.IdCardType = 2
  26557. }
  26558. var api string
  26559. new_chrg_bchno := chrg_bchno
  26560. if adminUser.CurrentOrgId == 10265 {
  26561. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26562. new_chrg_bchno = "0000"
  26563. }
  26564. }
  26565. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26566. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  26567. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26568. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26569. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  26570. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26571. "&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
  26572. resp, requestErr := http.Get(api)
  26573. if requestErr != nil {
  26574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26575. return
  26576. }
  26577. body, ioErr := ioutil.ReadAll(resp.Body)
  26578. if ioErr != nil {
  26579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26581. return
  26582. }
  26583. var respJSON map[string]interface{}
  26584. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26587. return
  26588. }
  26589. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26590. result, _ := json.Marshal(respJSON)
  26591. fmt.Println("log")
  26592. fmt.Println(string(result))
  26593. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26594. utils.ErrorLog("解析失败:%v", err)
  26595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26596. return
  26597. }
  26598. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26599. res.Output = resSeven10265.Output
  26600. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26601. res.ErrMsg = resSeven10265.ErrMsg
  26602. res.Cainfo = resSeven10265.Cainfo
  26603. res.WarnMsg = resSeven10265.WarnMsg
  26604. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26605. res.Infcode = infocode
  26606. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26607. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26608. var cert_no string
  26609. if his.IdCardType == 1 {
  26610. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26611. } else {
  26612. cert_no = psn_info.VerifyNumber
  26613. }
  26614. 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)
  26615. var dat map[string]interface{}
  26616. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26617. fmt.Println(dat)
  26618. } else {
  26619. fmt.Println(err)
  26620. }
  26621. saveLog(result2, src_resquest, "2207", "结算")
  26622. userJSONBytes, _ := json.Marshal(dat)
  26623. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26624. utils.ErrorLog("解析失败:%v", err)
  26625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26626. return
  26627. }
  26628. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26629. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26630. var cert_no string
  26631. var card_sn string
  26632. if his.IdCardType == 1 {
  26633. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26634. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26635. bas := strings.Split(psn_info.CardInfo, "|")
  26636. card_sn = bas[3]
  26637. } else if his.IdCardType == 2 {
  26638. cert_no = his.IdCardNo
  26639. } else {
  26640. cert_no = psn_info.VerifyNumber
  26641. }
  26642. var rf []*ResultFive
  26643. json.Unmarshal([]byte(his.Iinfo), &rf)
  26644. var psn_type string
  26645. for _, item := range rf {
  26646. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  26647. psn_type = item.PsnType
  26648. }
  26649. }
  26650. 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)
  26651. var dat map[string]interface{}
  26652. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26653. fmt.Println(dat)
  26654. } else {
  26655. fmt.Println(err)
  26656. }
  26657. saveLog(result2, src_resquest, "2207", "结算")
  26658. userJSONBytes, _ := json.Marshal(dat)
  26659. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26660. utils.ErrorLog("解析失败:%v", err)
  26661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26662. return
  26663. }
  26664. } else if miConfig.MdtrtareaAdmvs == "361025" {
  26665. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26666. var cert_no string
  26667. var card_sn string
  26668. if his.IdCardType == 1 {
  26669. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26670. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26671. //bas := strings.Split(psn_info.CardInfo, "|")
  26672. card_sn = ""
  26673. } else if his.IdCardType == 2 {
  26674. cert_no = his.IdCardNo
  26675. } else {
  26676. cert_no = psn_info.VerifyNumber
  26677. }
  26678. var rf []*ResultFive
  26679. json.Unmarshal([]byte(his.Iinfo), &rf)
  26680. var psn_type string
  26681. for _, item := range rf {
  26682. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  26683. psn_type = item.PsnType
  26684. }
  26685. }
  26686. 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)
  26687. var dat map[string]interface{}
  26688. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26689. fmt.Println(dat)
  26690. } else {
  26691. fmt.Println(err)
  26692. }
  26693. saveLog(result2, src_resquest, "2207", "结算")
  26694. userJSONBytes, _ := json.Marshal(dat)
  26695. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26696. utils.ErrorLog("解析失败:%v", err)
  26697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26698. return
  26699. }
  26700. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26701. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26702. if his.IdCardType == 1 {
  26703. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26704. bas := strings.Split(psn_info.CardInfo, "|")
  26705. cert_no = bas[2]
  26706. } else if his.IdCardType == 3 {
  26707. cert_no = his.Certno
  26708. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26709. } else if his.IdCardType == 4 {
  26710. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26711. cert_no =psn_info.VerifyNumber
  26712. psn_info.VerifyNumber = psn_info.VerifyNumber
  26713. } else {
  26714. cert_no = his.Certno
  26715. psn_info.VerifyNumber = his.Certno
  26716. }
  26717. var api string
  26718. var med_type string
  26719. if his.Insutype == "390" {
  26720. if reg_type == 992102 {
  26721. med_type = "992102"
  26722. }
  26723. if reg_type == 140104 {
  26724. med_type = "140104"
  26725. }
  26726. if reg_type == 140201 {
  26727. med_type = "140201"
  26728. }
  26729. if reg_type == 14 {
  26730. med_type = "14"
  26731. }
  26732. } else if his.Insutype == "310" {
  26733. if reg_type == 992102 {
  26734. med_type = "992102"
  26735. }
  26736. if reg_type == 140104 {
  26737. med_type = "140104"
  26738. }
  26739. if reg_type == 140201 {
  26740. med_type = "140201"
  26741. }
  26742. if reg_type == 14 {
  26743. med_type = "14"
  26744. }
  26745. }
  26746. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26747. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26748. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26749. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26750. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26751. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26752. "&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
  26753. resp, requestErr := http.Get(api)
  26754. if requestErr != nil {
  26755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26756. return
  26757. }
  26758. body, ioErr := ioutil.ReadAll(resp.Body)
  26759. if ioErr != nil {
  26760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26762. return
  26763. }
  26764. var respJSON map[string]interface{}
  26765. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26768. return
  26769. }
  26770. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26771. if status == "0" {
  26772. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26773. c.ServeSuccessJSON(map[string]interface{}{
  26774. "failed_code": -10,
  26775. "msg": err_msg,
  26776. })
  26777. return
  26778. }
  26779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26780. result, _ := json.Marshal(respJSON)
  26781. fmt.Println("log")
  26782. fmt.Println(string(result))
  26783. if err := json.Unmarshal(result, &ahres); err != nil {
  26784. utils.ErrorLog("解析失败:%v", err)
  26785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26786. return
  26787. }
  26788. res.InfRefmsgid = ahres.InfRefmsgid
  26789. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26790. // 创建对应的Time类型
  26791. t := time.UnixMilli(timestamp)
  26792. // 格式化成指定的日期字符串
  26793. str := t.Format("2006-01-02 15:04:05")
  26794. res.Output.Setlinfo.SetlTime = str
  26795. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  26796. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  26797. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26798. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  26799. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  26800. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  26801. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26802. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  26803. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  26804. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26805. res.Output.Setlinfo.ClrType = "11"
  26806. } else {
  26807. res.Output.Setlinfo.ClrType = "9903"
  26808. }
  26809. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  26810. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  26811. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26812. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  26813. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  26814. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  26815. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  26816. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  26817. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  26818. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26819. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  26820. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  26821. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  26822. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  26823. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  26824. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  26825. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  26826. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  26827. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  26828. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  26829. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  26830. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  26831. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  26832. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  26833. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  26834. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  26835. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  26836. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  26837. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  26838. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  26839. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  26840. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  26841. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  26842. res.Output.Setldetail = ahres.Output.Setldetail
  26843. res.ErrMsg = ahres.ErrMsg
  26844. res.Cainfo = ahres.Cainfo
  26845. res.WarnMsg = ahres.WarnMsg
  26846. res.Infcode = ahres.Infcode
  26847. } else if miConfig.MdtrtareaAdmvs == "340699" {
  26848. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26849. if his.IdCardType == 1 {
  26850. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26851. bas := strings.Split(psn_info.CardInfo, "|")
  26852. cert_no = bas[2]
  26853. } else if his.IdCardType == 3 {
  26854. cert_no = his.Certno
  26855. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26856. } else if his.IdCardType == 4 {
  26857. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26858. cert_no = his.Certno
  26859. psn_info.VerifyNumber = psn_info.VerifyNumber
  26860. } else {
  26861. cert_no = his.Certno
  26862. psn_info.VerifyNumber = his.Certno
  26863. }
  26864. var api string
  26865. var med_type string
  26866. if his.Insutype == "390" {
  26867. if reg_type == 992102 {
  26868. med_type = "992102"
  26869. }
  26870. if reg_type == 140104 {
  26871. med_type = "140104"
  26872. }
  26873. if reg_type == 14 {
  26874. med_type = "14"
  26875. }
  26876. if reg_type == 140201 {
  26877. med_type = "140201"
  26878. }
  26879. } else if his.Insutype == "310" {
  26880. if reg_type == 992102 {
  26881. med_type = "992102"
  26882. }
  26883. if reg_type == 14 {
  26884. med_type = "14"
  26885. }
  26886. if reg_type == 140104 {
  26887. med_type = "140104"
  26888. }
  26889. if reg_type == 140201 {
  26890. med_type = "140201"
  26891. }
  26892. }
  26893. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26894. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26895. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26896. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26897. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26898. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26899. "&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
  26900. resp, requestErr := http.Get(api)
  26901. if requestErr != nil {
  26902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26903. return
  26904. }
  26905. body, ioErr := ioutil.ReadAll(resp.Body)
  26906. if ioErr != nil {
  26907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26909. return
  26910. }
  26911. var respJSON map[string]interface{}
  26912. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26915. return
  26916. }
  26917. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26918. if status == "0" {
  26919. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26920. c.ServeSuccessJSON(map[string]interface{}{
  26921. "failed_code": -10,
  26922. "msg": err_msg,
  26923. })
  26924. return
  26925. }
  26926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26927. result, _ := json.Marshal(respJSON)
  26928. fmt.Println("log")
  26929. fmt.Println(string(result))
  26930. if err := json.Unmarshal(result, &ahres); err != nil {
  26931. utils.ErrorLog("解析失败:%v", err)
  26932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26933. return
  26934. }
  26935. res.InfRefmsgid = ahres.InfRefmsgid
  26936. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26937. // 创建对应的Time类型
  26938. t := time.UnixMilli(timestamp)
  26939. // 格式化成指定的日期字符串
  26940. str := t.Format("2006-01-02 15:04:05")
  26941. res.Output.Setlinfo.SetlTime = str
  26942. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  26943. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  26944. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26945. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  26946. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  26947. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  26948. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26949. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  26950. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  26951. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26952. res.Output.Setlinfo.ClrType = "11"
  26953. } else {
  26954. res.Output.Setlinfo.ClrType = "9903"
  26955. }
  26956. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  26957. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  26958. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26959. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  26960. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  26961. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  26962. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  26963. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  26964. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  26965. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26966. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  26967. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  26968. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  26969. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  26970. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  26971. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  26972. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  26973. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  26974. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  26975. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  26976. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  26977. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  26978. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  26979. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  26980. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  26981. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  26982. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  26983. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  26984. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  26985. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  26986. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  26987. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  26988. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  26989. res.Output.Setldetail = ahres.Output.Setldetail
  26990. res.ErrMsg = ahres.ErrMsg
  26991. res.Cainfo = ahres.Cainfo
  26992. res.WarnMsg = ahres.WarnMsg
  26993. res.Infcode = ahres.Infcode
  26994. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26995. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26996. var cert_no string
  26997. if his.IdCardType == 1 {
  26998. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26999. } else if his.IdCardType == 2 {
  27000. cert_no = his.IdCardNo
  27001. } else {
  27002. cert_no = psn_info.VerifyNumber
  27003. }
  27004. 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, "")
  27005. var dat map[string]interface{}
  27006. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27007. fmt.Println(dat)
  27008. } else {
  27009. fmt.Println(err)
  27010. }
  27011. saveLog(result2, src_resquest, "2207", "结算")
  27012. userJSONBytes, _ := json.Marshal(dat)
  27013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27014. utils.ErrorLog("解析失败:%v", err)
  27015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27016. return
  27017. }
  27018. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27019. psn_info, _ := service.GetPsnByPatientId(id)
  27020. var verify_number string
  27021. if psn_info.IdCardType == 4 {
  27022. verify_number = psn_info.VerifyNumber
  27023. } else if psn_info.IdCardType == 1 {
  27024. bas := strings.Split(psn_info.CardInfo, "|")
  27025. cardNumber := bas[2]
  27026. verify_number = cardNumber
  27027. } else {
  27028. verify_number = psn_info.Certno
  27029. psn_info.IdCardType = 2
  27030. }
  27031. var api string
  27032. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27033. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27034. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27035. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27036. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27037. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27038. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27039. resp, requestErr := http.Get(api)
  27040. if requestErr != nil {
  27041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27042. return
  27043. }
  27044. body, ioErr := ioutil.ReadAll(resp.Body)
  27045. if ioErr != nil {
  27046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27048. return
  27049. }
  27050. var respJSON map[string]interface{}
  27051. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27054. return
  27055. }
  27056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27057. result, _ := json.Marshal(respJSON)
  27058. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27059. utils.ErrorLog("解析失败:%v", err)
  27060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27061. return
  27062. }
  27063. } else {
  27064. var src_resquest string
  27065. if miConfig.Code == "H15049901371" {
  27066. //赤峰地区国家医保医疗类别
  27067. //职工透析:医疗类别选特殊情况门诊990502
  27068. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27069. var med_type string
  27070. if his.Insutype == "390" {
  27071. if reg_type == 14 {
  27072. med_type = "9933"
  27073. } else if reg_type == 11 {
  27074. med_type = "11"
  27075. }
  27076. } else if his.Insutype == "310" {
  27077. if reg_type == 14 {
  27078. med_type = "990502"
  27079. } else if reg_type == 11 {
  27080. med_type = "11"
  27081. }
  27082. }
  27083. 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)
  27084. } else {
  27085. if his.IdCardType == 4 {
  27086. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27087. token := psn_info.VerifyNumber
  27088. 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)
  27089. } else {
  27090. 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)
  27091. }
  27092. }
  27093. var dat map[string]interface{}
  27094. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27095. fmt.Println(dat)
  27096. } else {
  27097. fmt.Println(err)
  27098. }
  27099. saveLog(result2, src_resquest, "2207", "结算")
  27100. userJSONBytes, _ := json.Marshal(dat)
  27101. if miConfig.Code == "H15049901371" {
  27102. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27103. utils.ErrorLog("解析失败:%v", err)
  27104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27105. return
  27106. }
  27107. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27108. res.Output = resSeven10265.Output
  27109. res.ErrMsg = resSeven10265.ErrMsg
  27110. res.Cainfo = resSeven10265.Cainfo
  27111. res.WarnMsg = resSeven10265.WarnMsg
  27112. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27113. res.Infcode = infocode
  27114. } else {
  27115. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27116. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27117. utils.ErrorLog("解析失败:%v", err)
  27118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27119. return
  27120. }
  27121. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27122. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27123. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27124. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27125. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27126. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27127. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27128. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27129. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27130. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27131. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27132. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27133. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27134. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27135. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27136. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27137. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27138. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27139. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27140. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27141. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27142. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27143. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27144. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27145. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27146. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27147. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27148. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27149. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27150. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27151. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27152. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27153. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27154. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27155. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27156. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27157. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27158. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27159. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27160. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27161. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27162. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27163. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27164. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27165. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27166. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27167. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27168. res.Cainfo = gzresSeven10265Two.Cainfo
  27169. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27170. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27171. //res.Infcode = infocode
  27172. } else {
  27173. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27174. utils.ErrorLog("解析失败:%v", err)
  27175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27176. return
  27177. }
  27178. }
  27179. }
  27180. }
  27181. if res.Infcode == -1 {
  27182. errlog := &models.HisOrderError{
  27183. UserOrgId: adminUser.CurrentOrgId,
  27184. Ctime: time.Now().Unix(),
  27185. Mtime: time.Now().Unix(),
  27186. Number: chrg_bchno,
  27187. ErrMsg: res.ErrMsg,
  27188. Status: 1,
  27189. PatientId: id,
  27190. RecordTime: recordDateTime,
  27191. Stage: 6,
  27192. }
  27193. service.CreateErrMsgLog(errlog)
  27194. c.ServeSuccessJSON(map[string]interface{}{
  27195. "failed_code": -10,
  27196. "msg": res.ErrMsg,
  27197. })
  27198. return
  27199. } else {
  27200. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27201. order.OrderStatus = 2
  27202. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27203. order.SetlId = res.Output.Setlinfo.SetlID
  27204. order.PsnNo = res.Output.Setlinfo.PsnNo
  27205. order.PsnName = res.Output.Setlinfo.PsnName
  27206. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27207. order.Certno = res.Output.Setlinfo.Certno
  27208. order.Gend = res.Output.Setlinfo.Gend
  27209. order.Naty = res.Output.Setlinfo.Naty
  27210. order.Age = res.Output.Setlinfo.Age
  27211. order.Insutype = res.Output.Setlinfo.Insutype
  27212. order.PsnType = res.Output.Setlinfo.PsnType
  27213. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27214. order.SetlTime = res.Output.Setlinfo.SetlTime
  27215. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27216. order.PayWays = pay_ways
  27217. order.AcctUsedFlag = acct_used_flag
  27218. order.WechatPay = wechat_pay
  27219. order.AliPay = ali_pay
  27220. order.JifenPay = jifen_pay
  27221. order.BandCardPay = band_card_pay
  27222. order.CashPay = cash_pay
  27223. order.OthDesc = oth_desc
  27224. //order.MedType = res.Output.Setlinfo.MedType
  27225. if reg_type == 1112 {
  27226. order.MedType = "1112"
  27227. }
  27228. if reg_type == 1111 {
  27229. order.MedType = "1111"
  27230. }
  27231. order.ClrType = res.Output.Setlinfo.ClrType
  27232. if adminUser.CurrentOrgId == 10480 {
  27233. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27234. order.ClrType = "11"
  27235. } else {
  27236. order.ClrType = "9903"
  27237. }
  27238. }
  27239. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27240. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27241. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27242. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27243. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27244. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27245. order.HifpPay = res.Output.Setlinfo.HifpPay
  27246. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27247. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27248. order.HifesPay = res.Output.Setlinfo.HifesPay
  27249. order.HifobPay = res.Output.Setlinfo.HifobPay
  27250. order.MafPay = res.Output.Setlinfo.MafPay
  27251. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27252. order.OthPay = res.Output.Setlinfo.OthPay
  27253. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27254. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27255. order.AcctPay = res.Output.Setlinfo.AcctPay
  27256. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27257. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27258. order.Balc = res.Output.Setlinfo.Balc
  27259. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27260. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27261. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27262. order.ClrWay = res.Output.Setlinfo.ClrWay
  27263. order.Creator = order.Creator
  27264. order.Modify = roles.AdminUserId
  27265. order.RequestLog = src_resquest
  27266. order.Diagnosis = diagnosis_id
  27267. order.FaPiaoNumber = fapiao_number
  27268. order.FaPiaoCode = fapiao_code
  27269. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27270. detailStr := string(setlDetail)
  27271. order.SetlDetail = detailStr
  27272. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27273. err = service.UpDateOrder(order)
  27274. if err == nil {
  27275. //判断是否使用了押金
  27276. if dec_way == "true" {
  27277. tmpstring := strconv.FormatInt(order.ID, 10)
  27278. //扣押金
  27279. order.Decimal = decimal
  27280. service.UpDateOrder(order)
  27281. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27282. if errmsg != nil {
  27283. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27284. return
  27285. }
  27286. }
  27287. c.ServeSuccessJSON(map[string]interface{}{
  27288. "msg": "结算成功",
  27289. })
  27290. } else {
  27291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27292. return
  27293. }
  27294. }
  27295. }
  27296. }
  27297. }
  27298. // 上传明细-预结算-
  27299. func (c *HisApiController) GetPreUploadInfo() {
  27300. id, _ := c.GetInt64("id")
  27301. record_time := c.GetString("record_time")
  27302. his_patient_id, _ := c.GetInt64("his_patient_id")
  27303. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27304. admin_user_id, _ := c.GetInt64("admin_user_id")
  27305. diagnosis_id := c.GetString("diagnosis")
  27306. sick_type, _ := c.GetInt64("sick_type")
  27307. reg_type, _ := c.GetInt64("p_type")
  27308. begin_time := c.GetString("begin_time")
  27309. acct_used_flag := c.GetString("acct_used_flag")
  27310. id_str := c.GetString("ids")
  27311. ids_arr := strings.Split(id_str, ",")
  27312. timeLayout := "2006-01-02"
  27313. loc, _ := time.LoadLocation("Local")
  27314. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27315. if err != nil {
  27316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27317. return
  27318. }
  27319. recordDateTime := theTime.Unix()
  27320. adminUser := c.GetAdminUserInfo()
  27321. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27322. var config []*models.HisXtDiagnoseConfig
  27323. for _, item := range diagnosis_ids {
  27324. id, _ := strconv.ParseInt(item, 10, 64)
  27325. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27326. config = append(config, &diagnosisConfig)
  27327. }
  27328. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27329. sickConfig, _ := service.FindSickById(sick_type)
  27330. var prescriptions []*models.HisPrescription
  27331. var start_time int64
  27332. var end_time int64
  27333. var isSuccess bool = true
  27334. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27335. fmt.Println(his_patient_id)
  27336. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27337. timestamp := time.Now().Unix()
  27338. tempTime := time.Unix(timestamp, 0)
  27339. timeFormat := tempTime.Format("20060102150405")
  27340. chrgBchno := rand.Intn(100000) + 10000
  27341. new_chrg_bchno := ""
  27342. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27343. new_chrg_bchno = chrg_bchno
  27344. if adminUser.CurrentOrgId == 10265 {
  27345. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27346. new_chrg_bchno = "0000"
  27347. }
  27348. }
  27349. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27350. var patientPrescription models.HisPrescriptionInfo
  27351. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27352. if patientPrescription.ID == 0 {
  27353. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27354. }
  27355. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27356. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27357. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27358. strconv.FormatInt(his.PatientId, 10)
  27359. var res2406 Result2406
  27360. //安徽单病种处理
  27361. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27362. data := make(map[string]interface{})
  27363. client := &http.Client{}
  27364. data["psn_no"] = his.PsnNo
  27365. data["mdtrt_id"] = his.Number
  27366. data["operator"] = roles.UserName
  27367. data["cert_no"] = his.IdCardNo
  27368. data["org_name"] = miConfig.OrgName
  27369. data["psn_name"] = his.Name
  27370. data["ipt_otp_no"] = his.IptOtpNo
  27371. data["ipt_psn_sp_flag_type"] = "0901"
  27372. data["ipt_psn_sp_flag"] = "1"
  27373. data["fixmedins_code"] = miConfig.Code
  27374. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27375. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27376. data["url"] = miConfig.Url
  27377. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27378. bytesData, _ := json.Marshal(data)
  27379. var req *http.Request
  27380. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27381. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27382. resp, _ := client.Do(req)
  27383. defer resp.Body.Close()
  27384. body, ioErr := ioutil.ReadAll(resp.Body)
  27385. if ioErr != nil {
  27386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27388. return
  27389. }
  27390. var respJSON map[string]interface{}
  27391. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27394. return
  27395. }
  27396. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27397. if status == "0" {
  27398. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27399. c.ServeSuccessJSON(map[string]interface{}{
  27400. "failed_code": -10,
  27401. "msg": err_msg,
  27402. })
  27403. return
  27404. }
  27405. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27406. userJSONBytes, _ := json.Marshal(respJSON)
  27407. fmt.Println("log")
  27408. fmt.Println(string(userJSONBytes))
  27409. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27410. utils.ErrorLog("解析失败:%v", err)
  27411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27412. return
  27413. }
  27414. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  27415. data := make(map[string]interface{})
  27416. client := &http.Client{}
  27417. data["psn_no"] = his.PsnNo
  27418. data["mdtrt_id"] = his.Number
  27419. data["operator"] = roles.UserName
  27420. data["cert_no"] = his.IdCardNo
  27421. data["org_name"] = miConfig.OrgName
  27422. data["psn_name"] = his.Name
  27423. data["ipt_otp_no"] = his.IptOtpNo
  27424. data["ipt_psn_sp_flag_type"] = "0901"
  27425. data["ipt_psn_sp_flag"] = "1"
  27426. data["fixmedins_code"] = miConfig.Code
  27427. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27428. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27429. data["url"] = miConfig.Url
  27430. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27431. bytesData, _ := json.Marshal(data)
  27432. var req *http.Request
  27433. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27434. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27435. resp, _ := client.Do(req)
  27436. defer resp.Body.Close()
  27437. body, ioErr := ioutil.ReadAll(resp.Body)
  27438. if ioErr != nil {
  27439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27441. return
  27442. }
  27443. var respJSON map[string]interface{}
  27444. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27447. return
  27448. }
  27449. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27450. if status == "0" {
  27451. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27452. c.ServeSuccessJSON(map[string]interface{}{
  27453. "failed_code": -10,
  27454. "msg": err_msg,
  27455. })
  27456. return
  27457. }
  27458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27459. userJSONBytes, _ := json.Marshal(respJSON)
  27460. fmt.Println("log")
  27461. fmt.Println(string(userJSONBytes))
  27462. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27463. utils.ErrorLog("解析失败:%v", err)
  27464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27465. return
  27466. }
  27467. }
  27468. if res2406.Infcode != 0 {
  27469. adminUser := c.GetAdminUserInfo()
  27470. errlog := &models.HisOrderError{
  27471. UserOrgId: adminUser.CurrentOrgId,
  27472. Ctime: time.Now().Unix(),
  27473. Mtime: time.Now().Unix(),
  27474. ErrMsg: res2406.ErrMsg,
  27475. Status: 1,
  27476. PatientId: id,
  27477. RecordTime: recordDateTime,
  27478. Stage: 3,
  27479. }
  27480. service.CreateErrMsgLog(errlog)
  27481. c.ServeSuccessJSON(map[string]interface{}{
  27482. "failed_code": -10,
  27483. "msg": res2406.ErrMsg,
  27484. })
  27485. return
  27486. }
  27487. var res2 ResultSix
  27488. var res3 GZResultSix
  27489. var resSix10265 ResultSix10265
  27490. //var time_stamp string
  27491. if miConfig.MdtrtareaAdmvs == "421300" {
  27492. data := make(map[string]interface{})
  27493. client := &http.Client{}
  27494. data["psn_no"] = his.PsnNo
  27495. data["mdtrt_id"] = his.Number
  27496. data["department"] = department.Name
  27497. data["org_name"] = miConfig.OrgName
  27498. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27499. data["doctor_id"] = doctor_info.DoctorNumber
  27500. data["doctor_name"] = roles.UserName
  27501. data["fixmedins_code"] = miConfig.Code
  27502. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27503. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27504. data["secret_key"] = miConfig.SecretKey
  27505. data["sick_code"] = sickConfig.CountryCode
  27506. data["sick_name"] = sickConfig.ClassName
  27507. data["begin_time"] = begin_time
  27508. data["dept"] = strconv.FormatInt(department.ID, 10)
  27509. data["config"] = config
  27510. data["opter"] = roles.UserName
  27511. fmt.Println(data)
  27512. bytesData, _ := json.Marshal(data)
  27513. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  27514. resp, _ := client.Do(req)
  27515. defer resp.Body.Close()
  27516. body, ioErr := ioutil.ReadAll(resp.Body)
  27517. if ioErr != nil {
  27518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27520. return
  27521. }
  27522. var respJSON map[string]interface{}
  27523. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27526. return
  27527. }
  27528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27529. userJSONBytes, _ := json.Marshal(respJSON)
  27530. fmt.Println("log")
  27531. fmt.Println(string(userJSONBytes))
  27532. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27533. utils.ErrorLog("解析失败:%v", err)
  27534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27535. return
  27536. }
  27537. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27538. data := make(map[string]interface{})
  27539. client := &http.Client{}
  27540. data["psn_no"] = his.PsnNo
  27541. data["mdtrt_id"] = his.Number
  27542. data["department"] = department.Name
  27543. data["org_name"] = miConfig.OrgName
  27544. if reg_type == 11 && his.Insutype == "390" {
  27545. data["med_type"] = "110104"
  27546. } else {
  27547. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27548. }
  27549. data["doctor_id"] = doctor_info.DoctorNumber
  27550. data["doctor_name"] = roles.UserName
  27551. data["fixmedins_code"] = miConfig.Code
  27552. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27553. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27554. data["secret_key"] = miConfig.SecretKey
  27555. data["sick_code"] = sickConfig.CountryCode
  27556. data["sick_name"] = sickConfig.ClassName
  27557. data["begin_time"] = begin_time
  27558. data["dept"] = strconv.FormatInt(department.ID, 10)
  27559. data["config"] = config
  27560. data["opter"] = roles.UserName
  27561. fmt.Println(data)
  27562. bytesData, _ := json.Marshal(data)
  27563. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  27564. resp, _ := client.Do(req)
  27565. defer resp.Body.Close()
  27566. body, ioErr := ioutil.ReadAll(resp.Body)
  27567. if ioErr != nil {
  27568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27570. return
  27571. }
  27572. var respJSON map[string]interface{}
  27573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27576. return
  27577. }
  27578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27579. userJSONBytes, _ := json.Marshal(respJSON)
  27580. fmt.Println("log")
  27581. fmt.Println(string(userJSONBytes))
  27582. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27583. utils.ErrorLog("解析失败:%v", err)
  27584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27585. return
  27586. }
  27587. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27588. data := make(map[string]interface{})
  27589. client := &http.Client{}
  27590. data["psn_no"] = his.PsnNo
  27591. data["mdtrt_id"] = his.Number
  27592. data["department"] = department.Name
  27593. data["org_name"] = miConfig.OrgName
  27594. if reg_type == 11 && his.Insutype == "390" {
  27595. data["med_type"] = "110104"
  27596. } else {
  27597. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27598. }
  27599. data["doctor_id"] = doctor_info.DoctorNumber
  27600. data["doctor_name"] = roles.UserName
  27601. data["fixmedins_code"] = miConfig.Code
  27602. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27603. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27604. data["secret_key"] = miConfig.SecretKey
  27605. data["sick_code"] = sickConfig.CountryCode
  27606. data["sick_name"] = sickConfig.ClassName
  27607. data["begin_time"] = begin_time
  27608. data["dept"] = strconv.FormatInt(department.ID, 10)
  27609. data["config"] = config
  27610. data["opter"] = roles.UserName
  27611. fmt.Println(data)
  27612. bytesData, _ := json.Marshal(data)
  27613. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  27614. resp, _ := client.Do(req)
  27615. defer resp.Body.Close()
  27616. body, ioErr := ioutil.ReadAll(resp.Body)
  27617. if ioErr != nil {
  27618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27620. return
  27621. }
  27622. var respJSON map[string]interface{}
  27623. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27626. return
  27627. }
  27628. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27629. userJSONBytes, _ := json.Marshal(respJSON)
  27630. fmt.Println("log")
  27631. fmt.Println(string(userJSONBytes))
  27632. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27633. utils.ErrorLog("解析失败:%v", err)
  27634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27635. return
  27636. }
  27637. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27638. data := make(map[string]interface{})
  27639. client := &http.Client{}
  27640. data["psn_no"] = his.PsnNo
  27641. data["mdtrt_id"] = his.Number
  27642. data["department"] = department.Name
  27643. data["org_name"] = miConfig.OrgName
  27644. if reg_type == 11 && his.Insutype == "390" {
  27645. data["med_type"] = "110104"
  27646. } else {
  27647. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27648. }
  27649. data["doctor_id"] = doctor_info.DoctorNumber
  27650. data["doctor_name"] = roles.UserName
  27651. data["fixmedins_code"] = miConfig.Code
  27652. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27653. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27654. data["secret_key"] = miConfig.SecretKey
  27655. data["sick_code"] = sickConfig.CountryCode
  27656. data["sick_name"] = sickConfig.ClassName
  27657. data["begin_time"] = begin_time
  27658. data["dept"] = strconv.FormatInt(department.ID, 10)
  27659. data["config"] = config
  27660. data["opter"] = roles.UserName
  27661. fmt.Println(data)
  27662. bytesData, _ := json.Marshal(data)
  27663. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  27664. resp, _ := client.Do(req)
  27665. defer resp.Body.Close()
  27666. body, ioErr := ioutil.ReadAll(resp.Body)
  27667. if ioErr != nil {
  27668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27670. return
  27671. }
  27672. var respJSON map[string]interface{}
  27673. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27676. return
  27677. }
  27678. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27679. userJSONBytes, _ := json.Marshal(respJSON)
  27680. fmt.Println("log")
  27681. fmt.Println(string(userJSONBytes))
  27682. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27683. utils.ErrorLog("解析失败:%v", err)
  27684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27685. return
  27686. }
  27687. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27688. data := make(map[string]interface{})
  27689. client := &http.Client{}
  27690. data["psn_no"] = his.PsnNo
  27691. data["mdtrt_id"] = his.Number
  27692. data["doctor"] = roles.UserName
  27693. data["department"] = department.Name
  27694. data["org_name"] = miConfig.OrgName
  27695. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27696. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  27697. data["fixmedins_code"] = miConfig.Code
  27698. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27699. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27700. data["secret_key"] = miConfig.SecretKey
  27701. data["sick_code"] = sickConfig.CountryCode
  27702. data["sick_name"] = sickConfig.ClassName
  27703. data["begin_time"] = begin_time
  27704. data["dept"] = strconv.FormatInt(department.ID, 10)
  27705. data["config"] = config
  27706. data["url"] = miConfig.Url
  27707. data["ak"] = miConfig.AccessKey
  27708. data["cainfo"] = miConfig.Cainfo
  27709. bytesData, _ := json.Marshal(data)
  27710. var req *http.Request
  27711. if miConfig.MdtrtareaAdmvs == "320921" {
  27712. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  27713. } else {
  27714. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  27715. }
  27716. resp, _ := client.Do(req)
  27717. defer resp.Body.Close()
  27718. body, ioErr := ioutil.ReadAll(resp.Body)
  27719. if ioErr != nil {
  27720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27722. return
  27723. }
  27724. var respJSON map[string]interface{}
  27725. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27728. return
  27729. }
  27730. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  27731. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  27732. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  27733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27734. userJSONBytes, _ := json.Marshal(respJSON)
  27735. fmt.Println("log")
  27736. fmt.Println(string(userJSONBytes))
  27737. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  27738. utils.ErrorLog("解析失败:%v", err)
  27739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27740. return
  27741. }
  27742. res2.InfRefmsgid = resSix10265.InfRefmsgid
  27743. res2.Output = resSix10265.Output
  27744. res2.ErrMsg = resSix10265.ErrMsg
  27745. res2.Cainfo = resSix10265.Cainfo
  27746. res2.WarnMsg = resSix10265.WarnMsg
  27747. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  27748. res2.Infcode = infocode
  27749. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27750. data := make(map[string]interface{})
  27751. client := &http.Client{}
  27752. data["psn_no"] = his.PsnNo
  27753. data["mdtrt_id"] = his.Number
  27754. data["doctor"] = roles.UserName
  27755. data["department"] = department.Name
  27756. data["org_name"] = miConfig.OrgName
  27757. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27758. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  27759. data["fixmedins_code"] = miConfig.Code
  27760. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27761. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27762. data["secret_key"] = miConfig.SecretKey
  27763. data["sick_code"] = sickConfig.CountryCode
  27764. data["sick_name"] = sickConfig.ClassName
  27765. data["begin_time"] = begin_time
  27766. data["dept"] = strconv.FormatInt(department.ID, 10)
  27767. data["config"] = config
  27768. //data["url"] = miConfig.Url
  27769. //data["ak"] = miConfig.AccessKey
  27770. data["cainfo"] = miConfig.Cainfo
  27771. fmt.Println(data)
  27772. bytesData, _ := json.Marshal(data)
  27773. var req *http.Request
  27774. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  27775. resp, _ := client.Do(req)
  27776. defer resp.Body.Close()
  27777. body, ioErr := ioutil.ReadAll(resp.Body)
  27778. if ioErr != nil {
  27779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27781. return
  27782. }
  27783. var respJSON map[string]interface{}
  27784. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27787. return
  27788. }
  27789. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  27790. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  27791. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  27792. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27793. userJSONBytes, _ := json.Marshal(respJSON)
  27794. fmt.Println("log")
  27795. fmt.Println(string(userJSONBytes))
  27796. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  27797. utils.ErrorLog("解析失败:%v", err)
  27798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27799. return
  27800. }
  27801. res2.InfRefmsgid = resSix10265.InfRefmsgid
  27802. res2.Output = resSix10265.Output
  27803. res2.ErrMsg = resSix10265.ErrMsg
  27804. res2.Cainfo = resSix10265.Cainfo
  27805. res2.WarnMsg = resSix10265.WarnMsg
  27806. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  27807. res2.Infcode = infocode
  27808. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27809. 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)
  27810. saveLog(result, requestLog, "2203", "上传就诊信息")
  27811. var respJSON2 map[string]interface{}
  27812. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  27813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27815. return
  27816. }
  27817. userJSONBytes2, _ := json.Marshal(respJSON2)
  27818. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27819. utils.ErrorLog("解析失败:%v", err)
  27820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27821. return
  27822. }
  27823. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27824. var result string
  27825. var requestLog string
  27826. 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, "")
  27827. saveLog(result, requestLog, "2203", "上传就诊信息")
  27828. var respJSON2 map[string]interface{}
  27829. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  27830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27832. return
  27833. }
  27834. userJSONBytes2, _ := json.Marshal(respJSON2)
  27835. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27836. utils.ErrorLog("解析失败:%v", err)
  27837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27838. return
  27839. }
  27840. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27841. var result string
  27842. var requestLog string
  27843. 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, "")
  27844. saveLog(result, requestLog, "2203", "上传就诊信息")
  27845. var respJSON2 map[string]interface{}
  27846. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  27847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27849. return
  27850. }
  27851. userJSONBytes2, _ := json.Marshal(respJSON2)
  27852. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27853. utils.ErrorLog("解析失败:%v", err)
  27854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27855. return
  27856. }
  27857. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27858. data := make(map[string]interface{})
  27859. client := &http.Client{}
  27860. data["psn_no"] = his.PsnNo
  27861. data["mdtrt_id"] = his.Number
  27862. data["operator"] = roles.UserName
  27863. data["department"] = department.Name
  27864. data["org_name"] = miConfig.OrgName
  27865. var med_type string
  27866. if his.Insutype == "390" {
  27867. if reg_type == 992102 {
  27868. med_type = "992102"
  27869. data["sick_code"] = "ZDZ940"
  27870. data["sick_name"] = "慢性肾衰竭"
  27871. }
  27872. if reg_type == 140104 {
  27873. med_type = "140104"
  27874. data["sick_code"] = sickConfig.CountryCode
  27875. data["sick_name"] = sickConfig.ClassName
  27876. }
  27877. if reg_type == 14 {
  27878. med_type = "140104"
  27879. data["sick_code"] = sickConfig.CountryCode
  27880. data["sick_name"] = sickConfig.ClassName
  27881. }
  27882. } else if his.Insutype == "310" {
  27883. if reg_type == 992102 {
  27884. med_type = "992102"
  27885. data["sick_code"] = "ZDZ940"
  27886. data["sick_name"] = "慢性肾衰竭"
  27887. }
  27888. if reg_type == 140104 {
  27889. med_type = "140104"
  27890. data["sick_code"] = sickConfig.CountryCode
  27891. data["sick_name"] = sickConfig.ClassName
  27892. }
  27893. if reg_type == 14 {
  27894. med_type = "14"
  27895. data["sick_code"] = sickConfig.CountryCode
  27896. data["sick_name"] = sickConfig.ClassName
  27897. }
  27898. }
  27899. data["med_type"] = med_type
  27900. data["doctor_number"] = doctor_info.DoctorNumber
  27901. data["doctor_name"] = doctor_info.UserName
  27902. data["fixmedins_code"] = miConfig.Code
  27903. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27904. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27905. data["secret_key"] = miConfig.SecretKey
  27906. data["begin_time"] = begin_time
  27907. data["dept"] = strconv.FormatInt(department.ID, 10)
  27908. data["config"] = config
  27909. data["url"] = miConfig.Url
  27910. data["ak"] = miConfig.AccessKey
  27911. data["cainfo"] = miConfig.Cainfo
  27912. bytesData, _ := json.Marshal(data)
  27913. var req *http.Request
  27914. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  27915. resp, _ := client.Do(req)
  27916. defer resp.Body.Close()
  27917. body, ioErr := ioutil.ReadAll(resp.Body)
  27918. if ioErr != nil {
  27919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27921. return
  27922. }
  27923. var respJSON map[string]interface{}
  27924. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27927. return
  27928. }
  27929. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27930. if status == "0" {
  27931. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27932. c.ServeSuccessJSON(map[string]interface{}{
  27933. "failed_code": -10,
  27934. "msg": err_msg,
  27935. })
  27936. return
  27937. }
  27938. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27939. userJSONBytes, _ := json.Marshal(respJSON)
  27940. fmt.Println("log")
  27941. fmt.Println(string(userJSONBytes))
  27942. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27943. utils.ErrorLog("解析失败:%v", err)
  27944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27945. return
  27946. }
  27947. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27948. data := make(map[string]interface{})
  27949. client := &http.Client{}
  27950. data["psn_no"] = his.PsnNo
  27951. data["mdtrt_id"] = his.Number
  27952. data["operator"] = roles.UserName
  27953. data["department"] = department.Name
  27954. data["org_name"] = miConfig.OrgName
  27955. var med_type string
  27956. if his.Insutype == "390" {
  27957. if reg_type == 992102 {
  27958. med_type = "992102"
  27959. data["sick_code"] = sickConfig.CountryCode
  27960. data["sick_name"] = sickConfig.ClassName
  27961. }
  27962. if reg_type == 140104 {
  27963. med_type = "140104"
  27964. data["sick_code"] = sickConfig.CountryCode
  27965. data["sick_name"] = sickConfig.ClassName
  27966. }
  27967. if reg_type == 140201 {
  27968. med_type = "140201"
  27969. data["sick_code"] = sickConfig.CountryCode
  27970. data["sick_name"] = sickConfig.ClassName
  27971. }
  27972. if reg_type == 14 {
  27973. med_type = "14"
  27974. data["sick_code"] = sickConfig.CountryCode
  27975. data["sick_name"] = sickConfig.ClassName
  27976. }
  27977. } else if his.Insutype == "310" {
  27978. if reg_type == 992102 {
  27979. med_type = "992102"
  27980. data["sick_code"] = sickConfig.CountryCode
  27981. data["sick_name"] = sickConfig.ClassName
  27982. }
  27983. if reg_type == 140104 {
  27984. med_type = "140104"
  27985. data["sick_code"] = sickConfig.CountryCode
  27986. data["sick_name"] = sickConfig.ClassName
  27987. }
  27988. if reg_type == 140201 {
  27989. med_type = "140201"
  27990. data["sick_code"] = sickConfig.CountryCode
  27991. data["sick_name"] = sickConfig.ClassName
  27992. }
  27993. if reg_type == 14 {
  27994. med_type = "14"
  27995. data["sick_code"] = sickConfig.CountryCode
  27996. data["sick_name"] = sickConfig.ClassName
  27997. }
  27998. }
  27999. data["med_type"] = med_type
  28000. data["doctor_number"] = doctor_info.DoctorNumber
  28001. data["doctor_name"] = doctor_info.UserName
  28002. data["fixmedins_code"] = miConfig.Code
  28003. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28004. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28005. data["secret_key"] = miConfig.SecretKey
  28006. data["begin_time"] = begin_time
  28007. data["dept"] = strconv.FormatInt(department.ID, 10)
  28008. data["config"] = config
  28009. data["url"] = miConfig.Url
  28010. data["ak"] = miConfig.AccessKey
  28011. data["cainfo"] = miConfig.Cainfo
  28012. bytesData, _ := json.Marshal(data)
  28013. var req *http.Request
  28014. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28015. resp, _ := client.Do(req)
  28016. defer resp.Body.Close()
  28017. body, ioErr := ioutil.ReadAll(resp.Body)
  28018. if ioErr != nil {
  28019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28021. return
  28022. }
  28023. var respJSON map[string]interface{}
  28024. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28027. return
  28028. }
  28029. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28030. if status == "0" {
  28031. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28032. c.ServeSuccessJSON(map[string]interface{}{
  28033. "failed_code": -10,
  28034. "msg": err_msg,
  28035. })
  28036. return
  28037. }
  28038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28039. userJSONBytes, _ := json.Marshal(respJSON)
  28040. fmt.Println("log")
  28041. fmt.Println(string(userJSONBytes))
  28042. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28043. utils.ErrorLog("解析失败:%v", err)
  28044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28045. return
  28046. }
  28047. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28048. var result string
  28049. var requestLog string
  28050. 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, "")
  28051. saveLog(result, requestLog, "2203", "上传就诊信息")
  28052. var respJSON2 map[string]interface{}
  28053. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28056. return
  28057. }
  28058. userJSONBytes2, _ := json.Marshal(respJSON2)
  28059. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28060. utils.ErrorLog("解析失败:%v", err)
  28061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28062. return
  28063. }
  28064. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28065. data := make(map[string]interface{})
  28066. client := &http.Client{}
  28067. data["psn_no"] = his.PsnNo
  28068. data["mdtrt_id"] = his.Number
  28069. data["doctor"] = roles.UserName
  28070. data["department"] = department.Name
  28071. data["org_name"] = miConfig.OrgName
  28072. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28073. data["doctor_id"] = doctor_info.DoctorNumber
  28074. data["fixmedins_code"] = miConfig.Code
  28075. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28076. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28077. data["secret_key"] = miConfig.SecretKey
  28078. data["sick_code"] = sickConfig.CountryCode
  28079. data["sick_name"] = sickConfig.ClassName
  28080. data["begin_time"] = begin_time
  28081. data["new_doctor_name"] = doctor_info.UserName
  28082. data["dept"] = strconv.FormatInt(department.ID, 10)
  28083. data["config"] = config
  28084. bytesData, _ := json.Marshal(data)
  28085. var req *http.Request
  28086. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28087. resp, _ := client.Do(req)
  28088. defer resp.Body.Close()
  28089. body, ioErr := ioutil.ReadAll(resp.Body)
  28090. if ioErr != nil {
  28091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28093. return
  28094. }
  28095. var respJSON map[string]interface{}
  28096. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28099. return
  28100. }
  28101. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28102. userJSONBytes, _ := json.Marshal(respJSON)
  28103. fmt.Println("log")
  28104. fmt.Println(string(userJSONBytes))
  28105. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28106. utils.ErrorLog("解析失败:%v", err)
  28107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28108. return
  28109. }
  28110. } else {
  28111. var result string
  28112. var requestLog string
  28113. if miConfig.MdtrtareaAdmvs == "440781" { //
  28114. 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)
  28115. } else {
  28116. if miConfig.Code == "H15049901371" {
  28117. //赤峰地区国家医保医疗类别
  28118. //职工透析:医疗类别选特殊情况门诊990502
  28119. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28120. var med_type string
  28121. if his.Insutype == "390" {
  28122. if reg_type == 14 {
  28123. med_type = "9933"
  28124. } else if reg_type == 11 {
  28125. med_type = "11"
  28126. }
  28127. } else if his.Insutype == "310" {
  28128. if reg_type == 14 {
  28129. med_type = "990502"
  28130. } else if reg_type == 11 {
  28131. med_type = "11"
  28132. }
  28133. }
  28134. 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)
  28135. } else {
  28136. 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)
  28137. }
  28138. saveLog(result, requestLog, "2203", "上传就诊信息")
  28139. var respJSON2 map[string]interface{}
  28140. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28143. return
  28144. }
  28145. userJSONBytes2, _ := json.Marshal(respJSON2)
  28146. if miConfig.Code == "H15049901371" {
  28147. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28148. utils.ErrorLog("解析失败:%v", err)
  28149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28150. return
  28151. }
  28152. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28153. res2.Output = resSix10265.Output
  28154. res2.ErrMsg = resSix10265.ErrMsg
  28155. res2.Cainfo = resSix10265.Cainfo
  28156. res2.WarnMsg = resSix10265.WarnMsg
  28157. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28158. res2.Infcode = infocode
  28159. } else {
  28160. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28161. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28162. utils.ErrorLog("解析失败:%v", err)
  28163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28164. return
  28165. }
  28166. res2.Infcode = res3.Infcode
  28167. } else {
  28168. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28169. utils.ErrorLog("解析失败:%v", err)
  28170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28171. return
  28172. }
  28173. }
  28174. }
  28175. }
  28176. }
  28177. if res2.Infcode == -1 {
  28178. adminUser := c.GetAdminUserInfo()
  28179. errlog := &models.HisOrderError{
  28180. UserOrgId: adminUser.CurrentOrgId,
  28181. Ctime: time.Now().Unix(),
  28182. Mtime: time.Now().Unix(),
  28183. ErrMsg: res2.ErrMsg,
  28184. Status: 1,
  28185. PatientId: id,
  28186. RecordTime: recordDateTime,
  28187. Stage: 3,
  28188. }
  28189. service.CreateErrMsgLog(errlog)
  28190. c.ServeSuccessJSON(map[string]interface{}{
  28191. "failed_code": -10,
  28192. "msg": res2.ErrMsg,
  28193. })
  28194. return
  28195. }
  28196. if res2.Infcode != 0 {
  28197. adminUser := c.GetAdminUserInfo()
  28198. errlog := &models.HisOrderError{
  28199. UserOrgId: adminUser.CurrentOrgId,
  28200. Ctime: time.Now().Unix(),
  28201. Mtime: time.Now().Unix(),
  28202. ErrMsg: res2.ErrMsg,
  28203. Status: 1,
  28204. PatientId: id,
  28205. RecordTime: recordDateTime,
  28206. Stage: 3,
  28207. }
  28208. service.CreateErrMsgLog(errlog)
  28209. c.ServeSuccessJSON(map[string]interface{}{
  28210. "failed_code": -10,
  28211. "msg": res2.ErrMsg,
  28212. })
  28213. return
  28214. } else {
  28215. his.Diagnosis = diagnosis_id
  28216. his.SickType = sickConfig.ID
  28217. his.PType = fmt.Sprintf("%d", reg_type)
  28218. service.UpdateHisPatientThree(&his)
  28219. data := make(map[string]interface{})
  28220. if settle_accounts_type == 1 { //日结
  28221. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28222. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28223. } else {
  28224. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28225. }
  28226. data["pre"] = prescriptions
  28227. } else { //月结
  28228. start_time_str := c.GetString("start_time")
  28229. end_time_str := c.GetString("end_time")
  28230. timeLayout := "2006-01-02"
  28231. loc, _ := time.LoadLocation("Local")
  28232. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28233. if err != nil {
  28234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28235. return
  28236. }
  28237. recordStartTime := theStartTime.Unix()
  28238. start_time = recordStartTime
  28239. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28240. if err != nil {
  28241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28242. return
  28243. }
  28244. recordEndTime := theEndTime.Unix()
  28245. end_time = recordEndTime
  28246. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28247. data["pre"] = prescriptions
  28248. }
  28249. client := &http.Client{}
  28250. data["psn_no"] = his.PsnNo
  28251. data["mdtrt_id"] = his.Number
  28252. data["chrg_bchno"] = new_chrg_bchno
  28253. data["org_name"] = miConfig.OrgName
  28254. data["doctor"] = doctor_info.UserName
  28255. data["doctor_id"] = doctor_info.DoctorNumber
  28256. data["dept"] = department.Name
  28257. data["fixmedins_code"] = miConfig.Code
  28258. data["opter"] = roles.UserName
  28259. data["dept_code"] = department.Number
  28260. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28261. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28262. data["secret_key"] = miConfig.SecretKey
  28263. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28264. data["url"] = miConfig.Url
  28265. data["ak"] = miConfig.AccessKey
  28266. data["new_doctor_name"] = patientPrescription.Doctor
  28267. if his.Insutype == "390" {
  28268. if reg_type == 992102 {
  28269. data["diag_code"] = "ZDZ940"
  28270. }
  28271. if reg_type == 140104 {
  28272. data["diag_code"] = sickConfig.CountryCode
  28273. }
  28274. if reg_type == 140201 {
  28275. data["diag_code"] = sickConfig.CountryCode
  28276. }
  28277. if reg_type == 14 {
  28278. data["diag_code"] = sickConfig.CountryCode
  28279. }
  28280. } else if his.Insutype == "310" {
  28281. if miConfig.MdtrtareaAdmvs == "341203"{
  28282. if reg_type == 992102 {
  28283. data["diag_code"] = "ZDZ940"
  28284. }
  28285. if reg_type != 992102 {
  28286. data["diag_code"] = sickConfig.CountryCode
  28287. }
  28288. }else{
  28289. data["diag_code"] = sickConfig.CountryCode
  28290. }
  28291. }
  28292. data["cainfo"] = miConfig.Cainfo
  28293. data["opter"] = roles.UserName
  28294. var ids []int64
  28295. for _, item := range prescriptions {
  28296. ids = append(ids, item.ID)
  28297. }
  28298. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28299. if config.IsOpen == 1 { //对接了医保,走医保流程
  28300. var res ResultFour
  28301. var resFour10265 ResultFour10265
  28302. if miConfig.MdtrtareaAdmvs == "421300" {
  28303. bytesData, _ := json.Marshal(data)
  28304. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28305. resp, _ := client.Do(req)
  28306. defer resp.Body.Close()
  28307. body, ioErr := ioutil.ReadAll(resp.Body)
  28308. if ioErr != nil {
  28309. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28311. return
  28312. }
  28313. var respJSON map[string]interface{}
  28314. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28315. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28317. return
  28318. }
  28319. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28320. userJSONBytes, _ := json.Marshal(respJSON)
  28321. fmt.Println("log")
  28322. fmt.Println(string(userJSONBytes))
  28323. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28324. utils.ErrorLog("解析失败:%v", err)
  28325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28326. return
  28327. }
  28328. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28329. bytesData, _ := json.Marshal(data)
  28330. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28331. resp, _ := client.Do(req)
  28332. defer resp.Body.Close()
  28333. body, ioErr := ioutil.ReadAll(resp.Body)
  28334. if ioErr != nil {
  28335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28337. return
  28338. }
  28339. var respJSON map[string]interface{}
  28340. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28343. return
  28344. }
  28345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28346. userJSONBytes, _ := json.Marshal(respJSON)
  28347. fmt.Println("log")
  28348. fmt.Println(string(userJSONBytes))
  28349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28350. utils.ErrorLog("解析失败:%v", err)
  28351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28352. return
  28353. }
  28354. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28355. bytesData, _ := json.Marshal(data)
  28356. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28357. resp, _ := client.Do(req)
  28358. defer resp.Body.Close()
  28359. body, ioErr := ioutil.ReadAll(resp.Body)
  28360. if ioErr != nil {
  28361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28363. return
  28364. }
  28365. var respJSON map[string]interface{}
  28366. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28369. return
  28370. }
  28371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28372. userJSONBytes, _ := json.Marshal(respJSON)
  28373. fmt.Println("log")
  28374. fmt.Println(string(userJSONBytes))
  28375. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28376. utils.ErrorLog("解析失败:%v", err)
  28377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28378. return
  28379. }
  28380. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28381. bytesData, _ := json.Marshal(data)
  28382. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28383. resp, _ := client.Do(req)
  28384. defer resp.Body.Close()
  28385. body, ioErr := ioutil.ReadAll(resp.Body)
  28386. if ioErr != nil {
  28387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28389. return
  28390. }
  28391. var respJSON map[string]interface{}
  28392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28395. return
  28396. }
  28397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28398. userJSONBytes, _ := json.Marshal(respJSON)
  28399. fmt.Println("log")
  28400. fmt.Println(string(userJSONBytes))
  28401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28402. utils.ErrorLog("解析失败:%v", err)
  28403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28404. return
  28405. }
  28406. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28407. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28408. if result3101.Infcode == "0" {
  28409. if len(result3101.Output.Result) > 0 {
  28410. var errMsgs []string
  28411. for _, item := range result3101.Output.Result {
  28412. errMsgs = append(errMsgs, item.VolaCont)
  28413. }
  28414. c.ServeSuccessJSON(map[string]interface{}{
  28415. "failed_code": -10,
  28416. "msg": errMsgs,
  28417. })
  28418. return
  28419. } else {
  28420. if miConfig.MdtrtareaAdmvs == "320921" {
  28421. data["doctor_id"] = "D320923012139"
  28422. } else {
  28423. data["doctor_id"] = "D371621008686"
  28424. }
  28425. bytesData, _ := json.Marshal(data)
  28426. var req *http.Request
  28427. if miConfig.MdtrtareaAdmvs == "320921" {
  28428. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28429. } else {
  28430. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28431. }
  28432. resp, _ := client.Do(req)
  28433. defer resp.Body.Close()
  28434. body, ioErr := ioutil.ReadAll(resp.Body)
  28435. if ioErr != nil {
  28436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28438. return
  28439. }
  28440. var respJSON map[string]interface{}
  28441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28444. return
  28445. }
  28446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28447. userJSONBytes, _ := json.Marshal(respJSON)
  28448. fmt.Println("log")
  28449. fmt.Println(string(userJSONBytes))
  28450. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28451. utils.ErrorLog("解析失败:%v", err)
  28452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28453. return
  28454. }
  28455. res.InfRefmsgid = resFour10265.InfRefmsgid
  28456. res.Output = resFour10265.Output
  28457. res.ErrMsg = resFour10265.ErrMsg
  28458. res.Cainfo = resFour10265.Cainfo
  28459. res.WarnMsg = resFour10265.WarnMsg
  28460. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28461. res.Infcode = infocode
  28462. }
  28463. }
  28464. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28465. var pagesize int = 5
  28466. var start int = 1
  28467. var stop int
  28468. var pagecount int
  28469. var curpage int
  28470. data["doctor_id"] = doctor_info.DoctorNumber
  28471. var res2 ResultFour
  28472. //var result res.
  28473. //总页数,向上取整,注意除之前要先转换类型为float64
  28474. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  28475. for curpage = 1; curpage <= pagecount; curpage++ {
  28476. if curpage == 1 {
  28477. start = 1
  28478. } else {
  28479. start = (curpage-1)*pagesize + 1
  28480. }
  28481. stop = curpage * pagesize
  28482. if stop > len(prescriptions) {
  28483. stop = len(prescriptions)
  28484. }
  28485. //var requestLog string
  28486. data["pre"] = prescriptions[start-1 : stop]
  28487. fmt.Println(data["pre"])
  28488. bytesData, _ := json.Marshal(data)
  28489. var req *http.Request
  28490. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  28491. resp, _ := client.Do(req)
  28492. defer resp.Body.Close()
  28493. body, ioErr := ioutil.ReadAll(resp.Body)
  28494. if ioErr != nil {
  28495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28497. return
  28498. }
  28499. var respJSON map[string]interface{}
  28500. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28503. return
  28504. }
  28505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28506. userJSONBytes, _ := json.Marshal(respJSON)
  28507. fmt.Println("log")
  28508. fmt.Println(string(userJSONBytes))
  28509. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28510. utils.ErrorLog("解析失败:%v", err)
  28511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28512. return
  28513. }
  28514. res.InfRefmsgid = resFour10265.InfRefmsgid
  28515. res.Output = resFour10265.Output
  28516. res.ErrMsg = resFour10265.ErrMsg
  28517. res.Cainfo = resFour10265.Cainfo
  28518. res.WarnMsg = resFour10265.WarnMsg
  28519. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28520. res.Infcode = infocode
  28521. if infocode == 0 {
  28522. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  28523. } else {
  28524. isSuccess = false
  28525. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  28526. res.Infcode = -1
  28527. res.ErrMsg = resFour10265.ErrMsg
  28528. errlog := &models.HisOrderError{
  28529. UserOrgId: adminUser.CurrentOrgId,
  28530. Ctime: time.Now().Unix(),
  28531. Mtime: time.Now().Unix(),
  28532. Number: chrg_bchno,
  28533. ErrMsg: "",
  28534. Status: 1,
  28535. PatientId: id,
  28536. RecordTime: recordDateTime,
  28537. Stage: 4,
  28538. }
  28539. service.CreateErrMsgLog(errlog)
  28540. }
  28541. }
  28542. if isSuccess {
  28543. res.Infcode = 0
  28544. res.Output.Result = res2.Output.Result
  28545. } else {
  28546. order := &models.HisOrder{
  28547. UserOrgId: adminUser.CurrentOrgId,
  28548. HisPatientId: his.ID,
  28549. PatientId: his.PatientId,
  28550. SettleAccountsDate: recordDateTime,
  28551. Ctime: time.Now().Unix(),
  28552. Mtime: time.Now().Unix(),
  28553. MdtrtId: his.Number,
  28554. PsnNo: his.PsnNo,
  28555. MedType: strconv.FormatInt(reg_type, 10),
  28556. Status: 1,
  28557. Number: chrg_bchno,
  28558. Infcode: res.Infcode,
  28559. WarnMsg: res.WarnMsg,
  28560. Cainfo: res.Cainfo,
  28561. ErrMsg: res.ErrMsg,
  28562. RespondTime: res.RefmsgTime,
  28563. InfRefmsgid: res.InfRefmsgid,
  28564. OrderStatus: 1,
  28565. IsMedicineInsurance: 1,
  28566. SettleType: settle_accounts_type,
  28567. SettleStartTime: start_time,
  28568. SettleEndTime: end_time,
  28569. Creator: roles.AdminUserId,
  28570. Modify: roles.AdminUserId,
  28571. PType: 2,
  28572. Diagnosis: diagnosis_id,
  28573. }
  28574. err = service.CreateOrder(order)
  28575. if err != nil {
  28576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  28577. return
  28578. }
  28579. c.ServeSuccessJSON(map[string]interface{}{
  28580. "failed_code": -10,
  28581. "msg": res2.ErrMsg,
  28582. })
  28583. return
  28584. }
  28585. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28586. 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)
  28587. var dat map[string]interface{}
  28588. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28589. fmt.Println(dat)
  28590. } else {
  28591. fmt.Println(err)
  28592. }
  28593. saveLog(result, request_log, "2204", "上传费用明细")
  28594. userJSONBytes, _ := json.Marshal(dat)
  28595. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28596. utils.ErrorLog("解析失败:%v", err)
  28597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28598. return
  28599. }
  28600. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28601. 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, "", "")
  28602. var dat map[string]interface{}
  28603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28604. fmt.Println(dat)
  28605. } else {
  28606. fmt.Println(err)
  28607. }
  28608. saveLog(result, request_log, "2204", "上传费用明细")
  28609. userJSONBytes, _ := json.Marshal(dat)
  28610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28611. utils.ErrorLog("解析失败:%v", err)
  28612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28613. return
  28614. }
  28615. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28616. 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, "", "")
  28617. var dat map[string]interface{}
  28618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28619. fmt.Println(dat)
  28620. } else {
  28621. fmt.Println(err)
  28622. }
  28623. saveLog(result, request_log, "2204", "上传费用明细")
  28624. userJSONBytes, _ := json.Marshal(dat)
  28625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28626. utils.ErrorLog("解析失败:%v", err)
  28627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28628. return
  28629. }
  28630. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28631. bytesData, _ := json.Marshal(data)
  28632. var req *http.Request
  28633. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  28634. resp, _ := client.Do(req)
  28635. defer resp.Body.Close()
  28636. body, ioErr := ioutil.ReadAll(resp.Body)
  28637. if ioErr != nil {
  28638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28640. return
  28641. }
  28642. var respJSON map[string]interface{}
  28643. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28646. return
  28647. }
  28648. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28649. if status == "0" {
  28650. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28651. c.ServeSuccessJSON(map[string]interface{}{
  28652. "failed_code": -10,
  28653. "msg": err_msg,
  28654. })
  28655. return
  28656. }
  28657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28658. userJSONBytes, _ := json.Marshal(respJSON)
  28659. fmt.Println("log")
  28660. fmt.Println(string(userJSONBytes))
  28661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28662. utils.ErrorLog("解析失败:%v", err)
  28663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28664. return
  28665. }
  28666. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28667. bytesData, _ := json.Marshal(data)
  28668. var req *http.Request
  28669. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  28670. resp, _ := client.Do(req)
  28671. defer resp.Body.Close()
  28672. body, ioErr := ioutil.ReadAll(resp.Body)
  28673. if ioErr != nil {
  28674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28676. return
  28677. }
  28678. var respJSON map[string]interface{}
  28679. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28682. return
  28683. }
  28684. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28685. if status == "0" {
  28686. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28687. c.ServeSuccessJSON(map[string]interface{}{
  28688. "failed_code": -10,
  28689. "msg": err_msg,
  28690. })
  28691. return
  28692. }
  28693. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28694. userJSONBytes, _ := json.Marshal(respJSON)
  28695. fmt.Println("log")
  28696. fmt.Println(string(userJSONBytes))
  28697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28698. utils.ErrorLog("解析失败:%v", err)
  28699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28700. return
  28701. }
  28702. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28703. 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, "", "")
  28704. var dat map[string]interface{}
  28705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28706. fmt.Println(dat)
  28707. } else {
  28708. fmt.Println(err)
  28709. }
  28710. saveLog(result, request_log, "2204", "上传费用明细")
  28711. userJSONBytes, _ := json.Marshal(dat)
  28712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28713. utils.ErrorLog("解析失败:%v", err)
  28714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28715. return
  28716. }
  28717. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28718. bytesData, _ := json.Marshal(data)
  28719. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  28720. resp, _ := client.Do(req)
  28721. defer resp.Body.Close()
  28722. body, ioErr := ioutil.ReadAll(resp.Body)
  28723. if ioErr != nil {
  28724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28726. return
  28727. }
  28728. var respJSON map[string]interface{}
  28729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28732. return
  28733. }
  28734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28735. userJSONBytes, _ := json.Marshal(respJSON)
  28736. fmt.Println("log")
  28737. fmt.Println(string(userJSONBytes))
  28738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28739. utils.ErrorLog("解析失败:%v", err)
  28740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28741. return
  28742. }
  28743. } else {
  28744. if miConfig.MdtrtareaAdmvs == "441202" {
  28745. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28746. if result3101.Infcode == 0 {
  28747. if len(result3101.Output.Result) > 0 {
  28748. var errMsgs []string
  28749. for _, item := range result3101.Output.Result {
  28750. errMsgs = append(errMsgs, item.VolaCont)
  28751. }
  28752. c.ServeSuccessJSON(map[string]interface{}{
  28753. "failed_code": -10,
  28754. "msg": errMsgs,
  28755. })
  28756. return
  28757. } else {
  28758. 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)
  28759. var dat map[string]interface{}
  28760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28761. fmt.Println(dat)
  28762. } else {
  28763. fmt.Println(err)
  28764. }
  28765. saveLog(result, request_log, "2204", "上传费用明细")
  28766. userJSONBytes, _ := json.Marshal(dat)
  28767. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28768. utils.ErrorLog("解析失败:%v", err)
  28769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28770. return
  28771. }
  28772. }
  28773. } else {
  28774. c.ServeSuccessJSON(map[string]interface{}{
  28775. "failed_code": -10,
  28776. "msg": result3101.ErrMsg,
  28777. })
  28778. return
  28779. }
  28780. } else if miConfig.MdtrtareaAdmvs == "440205" {
  28781. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28782. if result3101.Infcode == 0 {
  28783. if len(result3101.Output.Result) > 0 {
  28784. var errMsgs []string
  28785. for _, item := range result3101.Output.Result {
  28786. errMsgs = append(errMsgs, item.VolaCont)
  28787. }
  28788. c.ServeSuccessJSON(map[string]interface{}{
  28789. "failed_code": -10,
  28790. "msg": errMsgs,
  28791. })
  28792. return
  28793. } else {
  28794. 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)
  28795. var dat map[string]interface{}
  28796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28797. fmt.Println(dat)
  28798. } else {
  28799. fmt.Println(err)
  28800. }
  28801. saveLog(result, request_log, "2204", "上传费用明细")
  28802. userJSONBytes, _ := json.Marshal(dat)
  28803. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28804. utils.ErrorLog("解析失败:%v", err)
  28805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28806. return
  28807. }
  28808. }
  28809. } else {
  28810. c.ServeSuccessJSON(map[string]interface{}{
  28811. "failed_code": -10,
  28812. "msg": result3101.ErrMsg,
  28813. })
  28814. return
  28815. }
  28816. } else {
  28817. if miConfig.Code == "H15049901371" {
  28818. 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)
  28819. var dat map[string]interface{}
  28820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28821. fmt.Println(dat)
  28822. } else {
  28823. fmt.Println(err)
  28824. }
  28825. saveLog(result, request_log, "2204", "上传费用明细")
  28826. userJSONBytes, _ := json.Marshal(dat)
  28827. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28828. utils.ErrorLog("解析失败:%v", err)
  28829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28830. return
  28831. }
  28832. res.InfRefmsgid = resFour10265.InfRefmsgid
  28833. res.Output = resFour10265.Output
  28834. res.ErrMsg = resFour10265.ErrMsg
  28835. res.Cainfo = resFour10265.Cainfo
  28836. res.WarnMsg = resFour10265.WarnMsg
  28837. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28838. res.Infcode = infocode
  28839. } else {
  28840. 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)
  28841. var dat map[string]interface{}
  28842. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28843. fmt.Println(dat)
  28844. } else {
  28845. fmt.Println(err)
  28846. }
  28847. saveLog(result, request_log, "2204", "上传费用明细")
  28848. userJSONBytes, _ := json.Marshal(dat)
  28849. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28850. utils.ErrorLog("解析失败:%v", err)
  28851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28852. return
  28853. }
  28854. }
  28855. }
  28856. }
  28857. var total_two float64
  28858. if res.Infcode == -1 {
  28859. errlog := &models.HisOrderError{
  28860. UserOrgId: adminUser.CurrentOrgId,
  28861. Ctime: time.Now().Unix(),
  28862. Mtime: time.Now().Unix(),
  28863. Number: chrg_bchno,
  28864. ErrMsg: res.ErrMsg,
  28865. Status: 1,
  28866. PatientId: id,
  28867. RecordTime: recordDateTime,
  28868. Stage: 4,
  28869. }
  28870. service.CreateErrMsgLog(errlog)
  28871. c.ServeSuccessJSON(map[string]interface{}{
  28872. "failed_code": -10,
  28873. "msg": res.ErrMsg,
  28874. })
  28875. return
  28876. }
  28877. if res.Infcode == 0 {
  28878. order := &models.HisOrder{
  28879. UserOrgId: adminUser.CurrentOrgId,
  28880. HisPatientId: his.ID,
  28881. PatientId: his.PatientId,
  28882. SettleAccountsDate: recordDateTime,
  28883. Ctime: time.Now().Unix(),
  28884. Mtime: time.Now().Unix(),
  28885. MdtrtId: his.Number,
  28886. PsnNo: his.PsnNo,
  28887. MedType: strconv.FormatInt(reg_type, 10),
  28888. Status: 1,
  28889. Number: chrg_bchno,
  28890. Infcode: res.Infcode,
  28891. WarnMsg: res.WarnMsg,
  28892. Cainfo: res.Cainfo,
  28893. ErrMsg: res.ErrMsg,
  28894. RespondTime: res.RefmsgTime,
  28895. InfRefmsgid: res.InfRefmsgid,
  28896. OrderStatus: 1,
  28897. IsMedicineInsurance: 1,
  28898. SettleType: settle_accounts_type,
  28899. SettleStartTime: start_time,
  28900. SettleEndTime: end_time,
  28901. Creator: roles.AdminUserId,
  28902. Modify: roles.AdminUserId,
  28903. PType: 2,
  28904. Diagnosis: diagnosis_id,
  28905. }
  28906. err = service.CreateOrder(order)
  28907. if err != nil {
  28908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  28909. return
  28910. }
  28911. for _, item := range res.Output.Result {
  28912. temp := strings.Split(item.FeedetlSn, "-")
  28913. var advice_id int64 = 0
  28914. var project_id int64 = 0
  28915. var types int64 = 0
  28916. id, _ := strconv.ParseInt(temp[2], 10, 64)
  28917. types, _ = strconv.ParseInt(temp[1], 10, 64)
  28918. if temp[1] == "1" {
  28919. advice_id = id
  28920. project_id = 0
  28921. } else if temp[1] == "2" {
  28922. advice_id = 0
  28923. project_id = id
  28924. }
  28925. total_two = total_two + item.DetItemFeeSumamt
  28926. info := &models.HisOrderInfo{
  28927. OrderNumber: order.Number,
  28928. FeedetlSn: item.FeedetlSn,
  28929. UploadDate: time.Now().Unix(),
  28930. AdviceId: advice_id,
  28931. DetItemFeeSumamt: item.DetItemFeeSumamt,
  28932. Cnt: item.Cnt,
  28933. Pric: float64(item.Pric),
  28934. PatientId: his.PatientId,
  28935. PricUplmtAmt: item.PricUplmtAmt,
  28936. SelfpayProp: item.SelfpayProp,
  28937. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  28938. OverlmtAmt: item.OverlmtAmt,
  28939. PreselfpayAmt: item.PreselfpayAmt,
  28940. BasMednFlag: item.BasMednFlag,
  28941. MedChrgitmType: item.MedChrgitmType,
  28942. HiNegoDrugFlag: item.HiNegoDrugFlag,
  28943. Status: 1,
  28944. Memo: item.Memo,
  28945. Mtime: time.Now().Unix(),
  28946. InscpScpAmt: item.InscpScpAmt,
  28947. DrtReimFlag: item.DrtReimFlag,
  28948. Ctime: time.Now().Unix(),
  28949. ListSpItemFlag: item.ListSpItemFlag,
  28950. ChldMedcFlag: item.ChldMedcFlag,
  28951. LmtUsedFlag: item.LmtUsedFlag,
  28952. ChrgitmLv: item.ChrgitmLv,
  28953. UserOrgId: adminUser.CurrentOrgId,
  28954. HisPatientId: his.ID,
  28955. OrderId: order.ID,
  28956. ProjectId: project_id,
  28957. Type: types,
  28958. }
  28959. service.CreateOrderInfo(info)
  28960. }
  28961. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  28962. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  28963. var total float64
  28964. for _, item := range prescriptions {
  28965. if item.Type == 1 { //药品
  28966. for _, subItem := range item.HisDoctorAdviceInfo {
  28967. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  28968. total_one := price * subItem.PrescribingNumber
  28969. fmt.Println("subItem")
  28970. fmt.Println(subItem.Price)
  28971. fmt.Println("price")
  28972. fmt.Println(price)
  28973. fmt.Println("total_one")
  28974. fmt.Println(total_one)
  28975. total = total + total_one
  28976. fmt.Println(total)
  28977. }
  28978. }
  28979. if item.Type == 2 { //项目
  28980. for _, subItem := range item.HisPrescriptionProject {
  28981. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  28982. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  28983. total_one := price * cnt
  28984. total = total + total_one
  28985. }
  28986. }
  28987. }
  28988. allTotal := fmt.Sprintf("%.2f", total)
  28989. if res.Infcode == 0 {
  28990. var rf []*ResultFive
  28991. json.Unmarshal([]byte(his.Iinfo), &rf)
  28992. chrg_bchno := chrg_bchno
  28993. cert_no := his.Certno
  28994. var insutypes []string
  28995. var insutype string
  28996. var is390 int = 0
  28997. var is310 int = 0
  28998. for _, item := range rf {
  28999. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29000. insutypes = append(insutypes, item.Insutype)
  29001. }
  29002. }
  29003. if len(insutypes) == 1 {
  29004. insutype = insutypes[0]
  29005. } else {
  29006. for _, i := range insutypes {
  29007. if i == "390" {
  29008. is390 = 1
  29009. }
  29010. if i == "310" {
  29011. is310 = 1
  29012. }
  29013. }
  29014. }
  29015. if is390 == 1 {
  29016. insutype = "390"
  29017. }
  29018. if is310 == 1 {
  29019. insutype = "310"
  29020. }
  29021. if len(insutypes) == 0 {
  29022. insutype = "390"
  29023. }
  29024. if len(insutypes) == 2 {
  29025. insutype = strconv.FormatInt(his.SocialType, 10)
  29026. }
  29027. //insutype = "390"
  29028. if his.IdCardType == 1 {
  29029. cert_no = his.MedicalInsuranceNumber
  29030. } else {
  29031. cert_no = his.Certno
  29032. }
  29033. var res ResultSeven
  29034. var ahres ResultSevenAH
  29035. var resSeven10265 ResultSeven10265
  29036. var resSeven10265Two ResultSeven10265Two
  29037. var gzresSeven10265Two GZResultSeven10265Two
  29038. if miConfig.MdtrtareaAdmvs == "421300" {
  29039. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29040. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29041. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29042. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29043. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29044. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29045. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29046. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29047. resp, requestErr := http.Get(api)
  29048. if requestErr != nil {
  29049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29050. return
  29051. }
  29052. body, ioErr := ioutil.ReadAll(resp.Body)
  29053. if ioErr != nil {
  29054. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29056. return
  29057. }
  29058. var respJSON map[string]interface{}
  29059. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29060. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29062. return
  29063. }
  29064. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29065. result, _ := json.Marshal(respJSON)
  29066. fmt.Println("log")
  29067. fmt.Println(string(result))
  29068. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29069. utils.ErrorLog("解析失败:%v", err)
  29070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29071. return
  29072. }
  29073. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29074. if reg_type == 11 && his.Insutype == "390" {
  29075. reg_type = 110104
  29076. }
  29077. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29078. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29079. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29080. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29081. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29082. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29083. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29084. resp, requestErr := http.Get(api)
  29085. if requestErr != nil {
  29086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29087. return
  29088. }
  29089. body, ioErr := ioutil.ReadAll(resp.Body)
  29090. if ioErr != nil {
  29091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29093. return
  29094. }
  29095. var respJSON map[string]interface{}
  29096. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29099. return
  29100. }
  29101. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29102. result, _ := json.Marshal(respJSON)
  29103. fmt.Println("log")
  29104. fmt.Println(string(result))
  29105. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29106. utils.ErrorLog("解析失败:%v", err)
  29107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29108. return
  29109. }
  29110. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29111. if reg_type == 11 && his.Insutype == "390" {
  29112. reg_type = 110104
  29113. }
  29114. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29115. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29116. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29117. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29118. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29119. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29120. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29121. resp, requestErr := http.Get(api)
  29122. if requestErr != nil {
  29123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29124. return
  29125. }
  29126. body, ioErr := ioutil.ReadAll(resp.Body)
  29127. if ioErr != nil {
  29128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29130. return
  29131. }
  29132. var respJSON map[string]interface{}
  29133. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29136. return
  29137. }
  29138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29139. result, _ := json.Marshal(respJSON)
  29140. fmt.Println("log")
  29141. fmt.Println(string(result))
  29142. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29143. utils.ErrorLog("解析失败:%v", err)
  29144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29145. return
  29146. }
  29147. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29148. if reg_type == 11 && his.Insutype == "390" {
  29149. reg_type = 110104
  29150. }
  29151. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29152. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29153. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29154. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29155. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29156. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29157. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29158. resp, requestErr := http.Get(api)
  29159. if requestErr != nil {
  29160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29161. return
  29162. }
  29163. body, ioErr := ioutil.ReadAll(resp.Body)
  29164. if ioErr != nil {
  29165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29167. return
  29168. }
  29169. var respJSON map[string]interface{}
  29170. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29173. return
  29174. }
  29175. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29176. result, _ := json.Marshal(respJSON)
  29177. fmt.Println("log")
  29178. fmt.Println(string(result))
  29179. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29180. utils.ErrorLog("解析失败:%v", err)
  29181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29182. return
  29183. }
  29184. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29185. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  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. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29199. if his.IdCardType != 4 {
  29200. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29201. bas := strings.Split(psn_info.CardInfo, "|")
  29202. if his.IdCardType == 1 {
  29203. cert_no = bas[2]
  29204. } else {
  29205. cert_no = bas[1]
  29206. }
  29207. } else {
  29208. cert_no = his.Certno
  29209. }
  29210. //江苏地区国家医保医疗类别
  29211. //职工透析:医疗类别选特殊情况门诊9933
  29212. //居民血透门慢: 医疗类别选门诊慢病1402
  29213. //var med_type string
  29214. //if his.Insutype == "310" {
  29215. // if reg_type == 14 {
  29216. // med_type = "9933"
  29217. // } else if reg_type == 11 {
  29218. // med_type = "11"
  29219. //
  29220. // }
  29221. //} else if his.Insutype == "390" {
  29222. // if reg_type == 14 {
  29223. // med_type = "1402"
  29224. // } else if reg_type == 11 {
  29225. // med_type = "11"
  29226. // }
  29227. //}
  29228. var api string
  29229. if miConfig.MdtrtareaAdmvs == "320921" {
  29230. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29231. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29232. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29233. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29234. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29235. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29236. "&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
  29237. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29238. } else {
  29239. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29240. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29241. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29242. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29243. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29244. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29245. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29246. "&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
  29247. }
  29248. resp, requestErr := http.Get(api)
  29249. if requestErr != nil {
  29250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29251. return
  29252. }
  29253. body, ioErr := ioutil.ReadAll(resp.Body)
  29254. if ioErr != nil {
  29255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29257. return
  29258. }
  29259. var respJSON map[string]interface{}
  29260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29263. return
  29264. }
  29265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29266. result, _ := json.Marshal(respJSON)
  29267. fmt.Println("log")
  29268. fmt.Println(string(result))
  29269. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29270. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29271. utils.ErrorLog("解析失败:%v", err)
  29272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29273. return
  29274. }
  29275. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29276. res.Output = resSeven10265.Output
  29277. res.ErrMsg = resSeven10265.ErrMsg
  29278. res.Cainfo = resSeven10265.Cainfo
  29279. res.WarnMsg = resSeven10265.WarnMsg
  29280. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29281. res.Infcode = infocode
  29282. } else {
  29283. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29284. utils.ErrorLog("解析失败:%v", err)
  29285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29286. return
  29287. }
  29288. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29289. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29290. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29291. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29292. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29293. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29294. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29295. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29296. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29297. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29298. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29299. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29300. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29301. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29302. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29303. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29304. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29305. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29306. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29307. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29308. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29309. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29310. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29311. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29312. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29313. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29314. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29315. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29316. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29317. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29318. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29319. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29320. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29321. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29322. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29323. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29324. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29325. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29326. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29327. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29328. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29329. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29330. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29331. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29332. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29333. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29334. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29335. res.ErrMsg = resSeven10265Two.ErrMsg
  29336. res.Cainfo = resSeven10265Two.Cainfo
  29337. res.WarnMsg = resSeven10265Two.WarnMsg
  29338. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29339. res.Infcode = infocode
  29340. }
  29341. }
  29342. }
  29343. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29344. psn_info, _ := service.GetPsnByPatientId(id)
  29345. var verify_number string
  29346. if psn_info.IdCardType == 4 {
  29347. verify_number = psn_info.VerifyNumber
  29348. } else if psn_info.IdCardType == 1 {
  29349. bas := strings.Split(psn_info.CardInfo, "|")
  29350. cardNumber := bas[2]
  29351. verify_number = cardNumber
  29352. } else {
  29353. psn_info.IdCardType = 2
  29354. verify_number = psn_info.Certno
  29355. }
  29356. var api string
  29357. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29358. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  29359. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29360. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29361. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29362. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29363. "&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
  29364. resp, requestErr := http.Get(api)
  29365. if requestErr != nil {
  29366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29367. return
  29368. }
  29369. body, ioErr := ioutil.ReadAll(resp.Body)
  29370. if ioErr != nil {
  29371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29373. return
  29374. }
  29375. var respJSON map[string]interface{}
  29376. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29379. return
  29380. }
  29381. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29382. result, _ := json.Marshal(respJSON)
  29383. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29384. utils.ErrorLog("解析失败:%v", err)
  29385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29386. return
  29387. }
  29388. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29389. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  29390. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  29391. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29392. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  29393. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  29394. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  29395. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  29396. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  29397. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  29398. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  29399. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  29400. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  29401. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29402. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  29403. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  29404. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  29405. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  29406. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  29407. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  29408. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29409. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  29410. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  29411. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  29412. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  29413. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  29414. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  29415. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  29416. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  29417. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  29418. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  29419. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  29420. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  29421. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  29422. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29423. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  29424. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  29425. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  29426. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  29427. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  29428. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  29429. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  29430. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  29431. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  29432. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  29433. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  29434. res.ErrMsg = resSeven10265.ErrMsg
  29435. res.Cainfo = resSeven10265.Cainfo
  29436. res.WarnMsg = resSeven10265.WarnMsg
  29437. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29438. res.Infcode = infocode
  29439. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29440. acct_used_flag := "1"
  29441. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  29442. var result string
  29443. var request_log string
  29444. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  29445. 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)
  29446. } else {
  29447. 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)
  29448. }
  29449. var dat map[string]interface{}
  29450. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29451. fmt.Println(dat)
  29452. } else {
  29453. fmt.Println(err)
  29454. }
  29455. saveLog(result, request_log, "2206", "预结算")
  29456. userJSONBytes, _ := json.Marshal(dat)
  29457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29458. utils.ErrorLog("解析失败:%v", err)
  29459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29460. return
  29461. }
  29462. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29463. var result string
  29464. var request_log string
  29465. if his.IdCardType == 2 {
  29466. 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, "")
  29467. } else if his.IdCardType == 1 {
  29468. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29469. bas := strings.Split(psn_info.CardInfo, "|")
  29470. basNumber := bas[2]
  29471. card_sn := bas[3]
  29472. var rf []*ResultFive
  29473. json.Unmarshal([]byte(his.Iinfo), &rf)
  29474. var psn_type string
  29475. for _, item := range rf {
  29476. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29477. psn_type = item.PsnType
  29478. }
  29479. }
  29480. 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)
  29481. } else {
  29482. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29483. //bas := strings.Split(psn_info.CardInfo, "|")
  29484. //basNumber := bas[2]
  29485. //card_sn := bas[3]
  29486. var rf []*ResultFive
  29487. json.Unmarshal([]byte(his.Iinfo), &rf)
  29488. var psn_type string
  29489. for _, item := range rf {
  29490. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29491. psn_type = item.PsnType
  29492. }
  29493. }
  29494. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29495. 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)
  29496. }
  29497. var dat map[string]interface{}
  29498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29499. fmt.Println(dat)
  29500. } else {
  29501. fmt.Println(err)
  29502. }
  29503. saveLog(result, request_log, "2206", "预结算")
  29504. userJSONBytes, _ := json.Marshal(dat)
  29505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29506. utils.ErrorLog("解析失败:%v", err)
  29507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29508. return
  29509. }
  29510. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29511. var result string
  29512. var request_log string
  29513. if his.IdCardType == 2 {
  29514. 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, "")
  29515. } else if his.IdCardType == 1 {
  29516. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29517. bas := strings.Split(psn_info.CardInfo, "|")
  29518. basNumber := bas[0]
  29519. card_sn := ""
  29520. var rf []*ResultFive
  29521. json.Unmarshal([]byte(his.Iinfo), &rf)
  29522. var psn_type string
  29523. for _, item := range rf {
  29524. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29525. psn_type = item.PsnType
  29526. }
  29527. }
  29528. 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)
  29529. } else {
  29530. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29531. //bas := strings.Split(psn_info.CardInfo, "|")
  29532. //basNumber := bas[2]
  29533. //card_sn := bas[3]
  29534. var rf []*ResultFive
  29535. json.Unmarshal([]byte(his.Iinfo), &rf)
  29536. var psn_type string
  29537. for _, item := range rf {
  29538. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29539. psn_type = item.PsnType
  29540. }
  29541. }
  29542. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29543. 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)
  29544. }
  29545. var dat map[string]interface{}
  29546. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29547. fmt.Println(dat)
  29548. } else {
  29549. fmt.Println(err)
  29550. }
  29551. saveLog(result, request_log, "2206", "预结算")
  29552. userJSONBytes, _ := json.Marshal(dat)
  29553. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29554. utils.ErrorLog("解析失败:%v", err)
  29555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29556. return
  29557. }
  29558. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29559. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29560. if his.IdCardType == 4 {
  29561. psn_info.VerifyNumber = psn_info.VerifyNumber
  29562. cert_no = psn_info.VerifyNumber
  29563. } else if his.IdCardType == 2 {
  29564. cert_no = psn_info.Certno
  29565. psn_info.VerifyNumber = psn_info.Certno
  29566. } else {
  29567. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29568. bas := strings.Split(psn_info.CardInfo, "|")
  29569. if his.IdCardType == 1 {
  29570. cert_no = bas[2]
  29571. } else {
  29572. cert_no = bas[1]
  29573. }
  29574. }
  29575. var api string
  29576. var med_type string
  29577. if his.Insutype == "390" {
  29578. if reg_type == 992102 {
  29579. med_type = "992102"
  29580. }
  29581. if reg_type == 140104 {
  29582. med_type = "140104"
  29583. }
  29584. if reg_type == 140201 {
  29585. med_type = "140201"
  29586. }
  29587. if reg_type == 14 {
  29588. med_type = "140104"
  29589. }
  29590. } else if his.Insutype == "310" {
  29591. if reg_type == 992102 {
  29592. med_type = "992102"
  29593. }
  29594. if reg_type == 140104 {
  29595. med_type = "140104"
  29596. }
  29597. if reg_type == 140201 {
  29598. med_type = "140201"
  29599. }
  29600. if reg_type == 14 {
  29601. med_type = "140104"
  29602. }
  29603. }
  29604. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29605. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29606. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29607. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29608. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29609. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29610. "&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
  29611. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29612. resp, requestErr := http.Get(api)
  29613. if requestErr != nil {
  29614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29615. return
  29616. }
  29617. body, ioErr := ioutil.ReadAll(resp.Body)
  29618. if ioErr != nil {
  29619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29621. return
  29622. }
  29623. var respJSON map[string]interface{}
  29624. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29627. return
  29628. }
  29629. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29630. if status == "0" {
  29631. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29632. c.ServeSuccessJSON(map[string]interface{}{
  29633. "failed_code": -10,
  29634. "msg": err_msg,
  29635. })
  29636. return
  29637. }
  29638. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29639. result, _ := json.Marshal(respJSON)
  29640. fmt.Println("log")
  29641. fmt.Println(string(result))
  29642. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  29643. utils.ErrorLog("解析失败:%v", err)
  29644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29645. return
  29646. }
  29647. res.InfRefmsgid = ahres.InfRefmsgid
  29648. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29649. // 创建对应的Time类型
  29650. t := time.UnixMilli(timestamp)
  29651. // 格式化成指定的日期字符串
  29652. str := t.Format("2006-01-02 15:04:05")
  29653. res.Output.Setlinfo.SetlTime = str
  29654. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29655. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29656. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29657. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29658. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29659. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29660. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29661. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29662. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29663. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  29664. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29665. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29666. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29667. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29668. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29669. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29670. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29671. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29672. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29673. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29674. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29675. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29676. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29677. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29678. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29679. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29680. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29681. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29682. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29683. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29684. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29685. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29686. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29687. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29688. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29689. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29690. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29691. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29692. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29693. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29694. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29695. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29696. //res.Output.Setldetail = ahres.Output.Setldetail
  29697. res.ErrMsg = ahres.ErrMsg
  29698. res.Cainfo = ahres.Cainfo
  29699. res.WarnMsg = ahres.WarnMsg
  29700. res.Infcode = ahres.Infcode
  29701. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29702. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29703. if his.IdCardType == 4 {
  29704. psn_info.VerifyNumber = psn_info.VerifyNumber
  29705. cert_no = psn_info.Certno
  29706. } else if his.IdCardType == 2 {
  29707. cert_no = psn_info.Certno
  29708. psn_info.VerifyNumber = psn_info.Certno
  29709. } else {
  29710. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29711. bas := strings.Split(psn_info.CardInfo, "|")
  29712. if his.IdCardType == 1 {
  29713. cert_no = bas[2]
  29714. } else {
  29715. cert_no = bas[1]
  29716. }
  29717. }
  29718. var api string
  29719. var med_type string
  29720. if his.Insutype == "390" {
  29721. if reg_type == 992102 {
  29722. med_type = "992102"
  29723. }
  29724. if reg_type == 140104 {
  29725. med_type = "140104"
  29726. }
  29727. if reg_type == 140201 {
  29728. med_type = "140201"
  29729. }
  29730. if reg_type == 14 {
  29731. med_type = "14"
  29732. }
  29733. } else if his.Insutype == "310" {
  29734. if reg_type == 992102 {
  29735. med_type = "992102"
  29736. }
  29737. if reg_type == 140104 {
  29738. med_type = "140104"
  29739. }
  29740. if reg_type == 140201 {
  29741. med_type = "140201"
  29742. }
  29743. if reg_type == 14 {
  29744. med_type = "14"
  29745. }
  29746. }
  29747. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29748. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29749. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29750. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29751. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29752. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29753. "&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
  29754. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29755. resp, requestErr := http.Get(api)
  29756. if requestErr != nil {
  29757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29758. return
  29759. }
  29760. body, ioErr := ioutil.ReadAll(resp.Body)
  29761. if ioErr != nil {
  29762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29764. return
  29765. }
  29766. var respJSON map[string]interface{}
  29767. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29770. return
  29771. }
  29772. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29773. if status == "0" {
  29774. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29775. c.ServeSuccessJSON(map[string]interface{}{
  29776. "failed_code": -10,
  29777. "msg": err_msg,
  29778. })
  29779. return
  29780. }
  29781. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29782. result, _ := json.Marshal(respJSON)
  29783. fmt.Println("log")
  29784. fmt.Println(string(result))
  29785. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  29786. utils.ErrorLog("解析失败:%v", err)
  29787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29788. return
  29789. }
  29790. res.InfRefmsgid = ahres.InfRefmsgid
  29791. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29792. // 创建对应的Time类型
  29793. t := time.UnixMilli(timestamp)
  29794. // 格式化成指定的日期字符串
  29795. str := t.Format("2006-01-02 15:04:05")
  29796. res.Output.Setlinfo.SetlTime = str
  29797. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29798. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29799. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29800. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29801. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29802. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29803. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29804. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29805. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29806. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  29807. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29808. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29809. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29810. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29811. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29812. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29813. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29814. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29815. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29816. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29817. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29818. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29819. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29820. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29821. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29822. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29823. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29824. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29825. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29826. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29827. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29828. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29829. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29830. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29831. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29832. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29833. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29834. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29835. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29836. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29837. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29838. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29839. //res.Output.Setldetail = ahres.Output.Setldetail
  29840. res.ErrMsg = ahres.ErrMsg
  29841. res.Cainfo = ahres.Cainfo
  29842. res.WarnMsg = ahres.WarnMsg
  29843. res.Infcode = ahres.Infcode
  29844. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29845. var result string
  29846. var request_log string
  29847. if his.IdCardType == 2 {
  29848. 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")
  29849. } else if his.IdCardType == 1 {
  29850. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29851. bas := strings.Split(psn_info.CardInfo, "|")
  29852. basNumber := bas[2]
  29853. card_sn := bas[3]
  29854. 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")
  29855. } else {
  29856. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29857. 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")
  29858. }
  29859. var dat map[string]interface{}
  29860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29861. fmt.Println(dat)
  29862. } else {
  29863. fmt.Println(err)
  29864. }
  29865. saveLog(result, request_log, "2206", "预结算")
  29866. userJSONBytes, _ := json.Marshal(dat)
  29867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29868. utils.ErrorLog("解析失败:%v", err)
  29869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29870. return
  29871. }
  29872. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29873. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29874. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29875. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29876. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29877. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29878. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29879. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29880. resp, requestErr := http.Get(api)
  29881. if requestErr != nil {
  29882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29883. return
  29884. }
  29885. body, ioErr := ioutil.ReadAll(resp.Body)
  29886. if ioErr != nil {
  29887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29889. return
  29890. }
  29891. var respJSON map[string]interface{}
  29892. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29895. return
  29896. }
  29897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29898. result, _ := json.Marshal(respJSON)
  29899. fmt.Println("log")
  29900. fmt.Println(string(result))
  29901. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29902. utils.ErrorLog("解析失败:%v", err)
  29903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29904. return
  29905. }
  29906. } else {
  29907. if miConfig.MdtrtareaAdmvs == "441202" {
  29908. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29909. if result3101.Infcode == 0 {
  29910. if len(result3101.Output.Result) > 0 {
  29911. var errMsgs []string
  29912. for _, item := range result3101.Output.Result {
  29913. errMsgs = append(errMsgs, item.VolaCont)
  29914. }
  29915. c.ServeSuccessJSON(map[string]interface{}{
  29916. "failed_code": -10,
  29917. "msg": errMsgs,
  29918. })
  29919. return
  29920. } else {
  29921. var result string
  29922. var request_log string
  29923. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29924. allTotal = fmt.Sprintf("%.2f", total_two)
  29925. if his.IdCardType == 4 {
  29926. 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)
  29927. } else {
  29928. 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)
  29929. }
  29930. var dat map[string]interface{}
  29931. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29932. fmt.Println(dat)
  29933. } else {
  29934. fmt.Println(err)
  29935. }
  29936. saveLog(result, request_log, "2206", "预结算")
  29937. //userJSONBytes, _ := json.Marshal(dat)
  29938. //
  29939. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29940. // utils.ErrorLog("解析失败:%v", err)
  29941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29942. // return
  29943. //}
  29944. userJSONBytes, _ := json.Marshal(dat)
  29945. if miConfig.Code == "H15049901371" {
  29946. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29947. utils.ErrorLog("解析失败:%v", err)
  29948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29949. return
  29950. }
  29951. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29952. res.Output = resSeven10265.Output
  29953. res.ErrMsg = resSeven10265.ErrMsg
  29954. res.Cainfo = resSeven10265.Cainfo
  29955. res.WarnMsg = resSeven10265.WarnMsg
  29956. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29957. res.Infcode = infocode
  29958. } else {
  29959. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29960. utils.ErrorLog("解析失败:%v", err)
  29961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29962. return
  29963. }
  29964. }
  29965. }
  29966. } else {
  29967. c.ServeSuccessJSON(map[string]interface{}{
  29968. "failed_code": -10,
  29969. "msg": result3101.ErrMsg,
  29970. })
  29971. return
  29972. }
  29973. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29974. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29975. if result3101.Infcode == 0 {
  29976. if len(result3101.Output.Result) > 0 {
  29977. var errMsgs []string
  29978. for _, item := range result3101.Output.Result {
  29979. errMsgs = append(errMsgs, item.VolaCont)
  29980. }
  29981. c.ServeSuccessJSON(map[string]interface{}{
  29982. "failed_code": -10,
  29983. "msg": errMsgs,
  29984. })
  29985. return
  29986. } else {
  29987. var result string
  29988. var request_log string
  29989. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29990. allTotal = fmt.Sprintf("%.2f", total_two)
  29991. if his.IdCardType == 4 {
  29992. 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)
  29993. } else {
  29994. 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)
  29995. }
  29996. var dat map[string]interface{}
  29997. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29998. fmt.Println(dat)
  29999. } else {
  30000. fmt.Println(err)
  30001. }
  30002. saveLog(result, request_log, "2206", "预结算")
  30003. //userJSONBytes, _ := json.Marshal(dat)
  30004. //
  30005. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30006. // utils.ErrorLog("解析失败:%v", err)
  30007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30008. // return
  30009. //}
  30010. userJSONBytes, _ := json.Marshal(dat)
  30011. if miConfig.Code == "H15049901371" {
  30012. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30013. utils.ErrorLog("解析失败:%v", err)
  30014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30015. return
  30016. }
  30017. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30018. res.Output = resSeven10265.Output
  30019. res.ErrMsg = resSeven10265.ErrMsg
  30020. res.Cainfo = resSeven10265.Cainfo
  30021. res.WarnMsg = resSeven10265.WarnMsg
  30022. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30023. res.Infcode = infocode
  30024. } else {
  30025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30026. utils.ErrorLog("解析失败:%v", err)
  30027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30028. return
  30029. }
  30030. }
  30031. }
  30032. } else {
  30033. c.ServeSuccessJSON(map[string]interface{}{
  30034. "failed_code": -10,
  30035. "msg": result3101.ErrMsg,
  30036. })
  30037. return
  30038. }
  30039. } else {
  30040. var result string
  30041. var request_log string
  30042. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30043. allTotal = fmt.Sprintf("%.2f", total_two)
  30044. if his.IdCardType == 4 {
  30045. 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)
  30046. } else {
  30047. 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)
  30048. }
  30049. var dat map[string]interface{}
  30050. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30051. fmt.Println(dat)
  30052. } else {
  30053. fmt.Println(err)
  30054. }
  30055. saveLog(result, request_log, "2206", "预结算")
  30056. //userJSONBytes, _ := json.Marshal(dat)
  30057. //
  30058. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30059. // utils.ErrorLog("解析失败:%v", err)
  30060. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30061. // return
  30062. //}
  30063. userJSONBytes, _ := json.Marshal(dat)
  30064. if miConfig.Code == "H15049901371" {
  30065. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30066. utils.ErrorLog("解析失败:%v", err)
  30067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30068. return
  30069. }
  30070. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30071. res.Output = resSeven10265.Output
  30072. res.ErrMsg = resSeven10265.ErrMsg
  30073. res.Cainfo = resSeven10265.Cainfo
  30074. res.WarnMsg = resSeven10265.WarnMsg
  30075. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30076. res.Infcode = infocode
  30077. } else {
  30078. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30079. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30080. utils.ErrorLog("解析失败:%v", err)
  30081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30082. return
  30083. }
  30084. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30085. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30086. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30087. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30088. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30089. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30090. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30091. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30092. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30093. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30094. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30095. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30096. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30097. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30098. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30099. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30100. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30101. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30102. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30103. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30104. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30105. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30106. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30107. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30108. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30109. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30110. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30111. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30112. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30113. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30114. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30115. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30116. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30117. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30118. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30119. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30120. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30121. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30122. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30123. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30124. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30125. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30126. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30127. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30128. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30129. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30130. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30131. res.Cainfo = gzresSeven10265Two.Cainfo
  30132. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30133. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30134. //res.Infcode = infocode
  30135. } else {
  30136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30137. utils.ErrorLog("解析失败:%v", err)
  30138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30139. return
  30140. }
  30141. }
  30142. }
  30143. }
  30144. }
  30145. utils.ErrorLog("解析失败:%v", res.Infcode)
  30146. if res.Infcode == -1 {
  30147. errlog := &models.HisOrderError{
  30148. UserOrgId: adminUser.CurrentOrgId,
  30149. Ctime: time.Now().Unix(),
  30150. Mtime: time.Now().Unix(),
  30151. Number: chrg_bchno,
  30152. ErrMsg: res.ErrMsg,
  30153. Status: 1,
  30154. PatientId: id,
  30155. RecordTime: recordDateTime,
  30156. Stage: 20,
  30157. }
  30158. service.CreateErrMsgLog(errlog)
  30159. c.ServeSuccessJSON(map[string]interface{}{
  30160. "failed_code": -10,
  30161. "msg": res.ErrMsg,
  30162. })
  30163. return
  30164. }
  30165. if res.Infcode != 0 {
  30166. errlog := &models.HisOrderError{
  30167. UserOrgId: adminUser.CurrentOrgId,
  30168. Ctime: time.Now().Unix(),
  30169. Mtime: time.Now().Unix(),
  30170. Number: chrg_bchno,
  30171. ErrMsg: res.ErrMsg,
  30172. Status: 1,
  30173. PatientId: id,
  30174. RecordTime: recordDateTime,
  30175. Stage: 20,
  30176. }
  30177. service.CreateErrMsgLog(errlog)
  30178. c.ServeSuccessJSON(map[string]interface{}{
  30179. "failed_code": -10,
  30180. "msg": res.ErrMsg,
  30181. })
  30182. return
  30183. } else {
  30184. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30185. order.OrderStatus = 1
  30186. order.IsPre = 1
  30187. order.Status = 1
  30188. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30189. order.SetlId = res.Output.Setlinfo.SetlID
  30190. order.PsnNo = res.Output.Setlinfo.PsnNo
  30191. order.PsnName = res.Output.Setlinfo.PsnName
  30192. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30193. order.Certno = res.Output.Setlinfo.Certno
  30194. order.Gend = res.Output.Setlinfo.Gend
  30195. order.Naty = res.Output.Setlinfo.Naty
  30196. order.Age = res.Output.Setlinfo.Age
  30197. order.Insutype = res.Output.Setlinfo.Insutype
  30198. order.PsnType = res.Output.Setlinfo.PsnType
  30199. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30200. order.SetlTime = res.Output.Setlinfo.SetlTime
  30201. order.AcctUsedFlag = acct_used_flag
  30202. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30203. if res.Output.Setlinfo.MedType == "140101" {
  30204. order.MedType = "14"
  30205. } else {
  30206. if res.Output.Setlinfo.MedType == "110104" {
  30207. order.MedType = "11"
  30208. } else {
  30209. order.MedType = res.Output.Setlinfo.MedType
  30210. }
  30211. }
  30212. if res.Output.Setlinfo.MedType == "992102" {
  30213. order.MedType = "992102"
  30214. }
  30215. if res.Output.Setlinfo.MedType == "140104" {
  30216. order.MedType = "140104"
  30217. }
  30218. if res.Output.Setlinfo.MedType == "140201" {
  30219. order.MedType = "140201"
  30220. }
  30221. if res.Output.Setlinfo.MedType == "14" {
  30222. order.MedType = "14"
  30223. }
  30224. if reg_type == 1112 {
  30225. order.MedType = "1112"
  30226. }
  30227. if reg_type == 1111 {
  30228. order.MedType = "1111"
  30229. }
  30230. order.ClrType = res.Output.Setlinfo.ClrType
  30231. if adminUser.CurrentOrgId == 10480 {
  30232. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30233. order.ClrType = "11"
  30234. } else {
  30235. order.ClrType = "9903"
  30236. }
  30237. }
  30238. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30239. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30240. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30241. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30242. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30243. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30244. order.HifpPay = res.Output.Setlinfo.HifpPay
  30245. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30246. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30247. order.HifesPay = res.Output.Setlinfo.HifesPay
  30248. order.HifobPay = res.Output.Setlinfo.HifobPay
  30249. order.MafPay = res.Output.Setlinfo.MafPay
  30250. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30251. order.OthPay = res.Output.Setlinfo.OthPay
  30252. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30253. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30254. order.AcctPay = res.Output.Setlinfo.AcctPay
  30255. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30256. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30257. order.Balc = res.Output.Setlinfo.Balc
  30258. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30259. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30260. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30261. order.ClrWay = res.Output.Setlinfo.ClrWay
  30262. order.Creator = order.Creator
  30263. order.Modify = roles.AdminUserId
  30264. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30265. //detailStr := string(setlDetail)
  30266. //order.SetlDetail = detailStr
  30267. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30268. err = service.UpDateOrder(order)
  30269. if err == nil {
  30270. c.ServeSuccessJSON(map[string]interface{}{
  30271. "msg": "预结算成功",
  30272. })
  30273. } else {
  30274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30275. return
  30276. }
  30277. }
  30278. } else {
  30279. adminUser := c.GetAdminUserInfo()
  30280. errlog := &models.HisOrderError{
  30281. UserOrgId: adminUser.CurrentOrgId,
  30282. Ctime: time.Now().Unix(),
  30283. Mtime: time.Now().Unix(),
  30284. ErrMsg: res.ErrMsg,
  30285. Status: 1,
  30286. PatientId: id,
  30287. RecordTime: recordDateTime,
  30288. Stage: 4,
  30289. }
  30290. service.CreateErrMsgLog(errlog)
  30291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  30292. return
  30293. }
  30294. } else {
  30295. if miConfig.MdtrtareaAdmvs == "150499" {
  30296. order := &models.HisOrder{
  30297. UserOrgId: adminUser.CurrentOrgId,
  30298. HisPatientId: his.ID,
  30299. PatientId: his.PatientId,
  30300. SettleAccountsDate: recordDateTime,
  30301. Ctime: time.Now().Unix(),
  30302. Mtime: time.Now().Unix(),
  30303. MdtrtId: his.Number,
  30304. PsnNo: his.PsnNo,
  30305. MedType: strconv.FormatInt(reg_type, 10),
  30306. Status: 1,
  30307. Number: chrg_bchno,
  30308. Infcode: res.Infcode,
  30309. WarnMsg: res.WarnMsg,
  30310. Cainfo: res.Cainfo,
  30311. ErrMsg: res.ErrMsg,
  30312. RespondTime: res.RefmsgTime,
  30313. InfRefmsgid: res.InfRefmsgid,
  30314. OrderStatus: 1,
  30315. IsMedicineInsurance: 1,
  30316. SettleType: settle_accounts_type,
  30317. SettleStartTime: start_time,
  30318. SettleEndTime: end_time,
  30319. Creator: roles.AdminUserId,
  30320. Modify: roles.AdminUserId,
  30321. PType: 2,
  30322. Diagnosis: diagnosis_id,
  30323. }
  30324. err = service.CreateOrder(order)
  30325. if err != nil {
  30326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30327. return
  30328. }
  30329. }
  30330. adminUser := c.GetAdminUserInfo()
  30331. errlog := &models.HisOrderError{
  30332. UserOrgId: adminUser.CurrentOrgId,
  30333. Ctime: time.Now().Unix(),
  30334. Mtime: time.Now().Unix(),
  30335. ErrMsg: res.ErrMsg,
  30336. Status: 1,
  30337. PatientId: id,
  30338. RecordTime: recordDateTime,
  30339. Stage: 4,
  30340. }
  30341. service.CreateErrMsgLog(errlog)
  30342. c.ServeSuccessJSON(map[string]interface{}{
  30343. "failed_code": -10,
  30344. "msg": res.ErrMsg,
  30345. })
  30346. return
  30347. }
  30348. }
  30349. }
  30350. }
  30351. // 退款
  30352. func (c *HisApiController) Refund() {
  30353. order_id, _ := c.GetInt64("order_id")
  30354. admin_user_id, _ := c.GetInt64("admin_user_id")
  30355. adminUser := c.GetAdminUserInfo()
  30356. var order models.HisOrder
  30357. order, _ = service.GetHisOrderByID(order_id)
  30358. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  30359. if fapiao.ID > 0 {
  30360. c.ServeSuccessJSON(map[string]interface{}{
  30361. "failed_code": -10,
  30362. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  30363. })
  30364. return
  30365. }
  30366. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30367. if order.ID == 0 {
  30368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30369. return
  30370. }
  30371. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30372. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30373. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30374. if config.IsOpen == 1 { //对接了医保,走医保流程
  30375. var res ResultSixteen
  30376. var ahres ResultSevenAH
  30377. var resSixteen10265 ResultSixteen10265
  30378. var resSixteen10265Two ResultSixteen10265Two
  30379. var gz ResultgzSixteen10265Two
  30380. var src_resquest string
  30381. var result string
  30382. if miConfig.MdtrtareaAdmvs == "421300" {
  30383. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30384. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30385. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30386. resp3, requestErr3 := http.Get(api3)
  30387. if requestErr3 != nil {
  30388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30389. return
  30390. }
  30391. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30392. if ioErr3 != nil {
  30393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30395. return
  30396. }
  30397. var respJSON3 map[string]interface{}
  30398. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30401. return
  30402. }
  30403. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30404. userJSONBytes3, _ := json.Marshal(respJSON3)
  30405. fmt.Println("log")
  30406. fmt.Println(string(userJSONBytes3))
  30407. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30408. utils.ErrorLog("解析失败:%v", err)
  30409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30410. return
  30411. }
  30412. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30413. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30414. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30415. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30416. resp3, requestErr3 := http.Get(api3)
  30417. if requestErr3 != nil {
  30418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30419. return
  30420. }
  30421. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30422. if ioErr3 != nil {
  30423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30425. return
  30426. }
  30427. var respJSON3 map[string]interface{}
  30428. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30431. return
  30432. }
  30433. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30434. userJSONBytes3, _ := json.Marshal(respJSON3)
  30435. fmt.Println("log")
  30436. fmt.Println(string(userJSONBytes3))
  30437. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30438. utils.ErrorLog("解析失败:%v", err)
  30439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30440. return
  30441. }
  30442. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30443. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30444. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30445. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30446. resp3, requestErr3 := http.Get(api3)
  30447. if requestErr3 != nil {
  30448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30449. return
  30450. }
  30451. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30452. if ioErr3 != nil {
  30453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30455. return
  30456. }
  30457. var respJSON3 map[string]interface{}
  30458. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30461. return
  30462. }
  30463. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30464. userJSONBytes3, _ := json.Marshal(respJSON3)
  30465. fmt.Println("log")
  30466. fmt.Println(string(userJSONBytes3))
  30467. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30468. utils.ErrorLog("解析失败:%v", err)
  30469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30470. return
  30471. }
  30472. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30473. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30474. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30475. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30476. resp3, requestErr3 := http.Get(api3)
  30477. if requestErr3 != nil {
  30478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30479. return
  30480. }
  30481. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30482. if ioErr3 != nil {
  30483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30485. return
  30486. }
  30487. var respJSON3 map[string]interface{}
  30488. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30491. return
  30492. }
  30493. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30494. userJSONBytes3, _ := json.Marshal(respJSON3)
  30495. fmt.Println("log")
  30496. fmt.Println(string(userJSONBytes3))
  30497. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30498. utils.ErrorLog("解析失败:%v", err)
  30499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30500. return
  30501. }
  30502. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30503. var api3 string
  30504. if miConfig.MdtrtareaAdmvs == "320921" {
  30505. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  30506. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30507. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30508. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30509. } else {
  30510. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30511. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  30512. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30513. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30514. }
  30515. resp3, requestErr3 := http.Get(api3)
  30516. if requestErr3 != nil {
  30517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30518. return
  30519. }
  30520. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30521. if ioErr3 != nil {
  30522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30524. return
  30525. }
  30526. var respJSON3 map[string]interface{}
  30527. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30530. return
  30531. }
  30532. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30533. userJSONBytes3, _ := json.Marshal(respJSON3)
  30534. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  30535. utils.ErrorLog("解析失败:%v", err)
  30536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30537. return
  30538. }
  30539. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  30540. res.Output = resSixteen10265.Output
  30541. res.ErrMsg = resSixteen10265.ErrMsg
  30542. res.Cainfo = resSixteen10265.Cainfo
  30543. res.WarnMsg = resSixteen10265.WarnMsg
  30544. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  30545. res.Infcode = infocode
  30546. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30547. var api3 string
  30548. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  30549. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30550. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30551. resp3, requestErr3 := http.Get(api3)
  30552. if requestErr3 != nil {
  30553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30554. return
  30555. }
  30556. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30557. if ioErr3 != nil {
  30558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30560. return
  30561. }
  30562. var respJSON3 map[string]interface{}
  30563. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30566. return
  30567. }
  30568. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30569. userJSONBytes3, _ := json.Marshal(respJSON3)
  30570. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  30571. utils.ErrorLog("解析失败:%v", err)
  30572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30573. return
  30574. }
  30575. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  30576. res.Output = resSixteen10265.Output
  30577. res.ErrMsg = resSixteen10265.ErrMsg
  30578. res.Cainfo = resSixteen10265.Cainfo
  30579. res.WarnMsg = resSixteen10265.WarnMsg
  30580. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  30581. res.Infcode = infocode
  30582. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30583. 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)
  30584. var dat map[string]interface{}
  30585. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30586. fmt.Println(dat)
  30587. } else {
  30588. fmt.Println(err)
  30589. }
  30590. saveLog(result, src_resquest, "2208", "退费")
  30591. userJSONBytes, _ := json.Marshal(dat)
  30592. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30593. utils.ErrorLog("解析失败:%v", err)
  30594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30595. return
  30596. }
  30597. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30598. 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, "")
  30599. var dat map[string]interface{}
  30600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30601. fmt.Println(dat)
  30602. } else {
  30603. fmt.Println(err)
  30604. }
  30605. saveLog(result, src_resquest, "2208", "退费")
  30606. userJSONBytes, _ := json.Marshal(dat)
  30607. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30608. utils.ErrorLog("解析失败:%v", err)
  30609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30610. return
  30611. }
  30612. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30613. 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, "")
  30614. var dat map[string]interface{}
  30615. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30616. fmt.Println(dat)
  30617. } else {
  30618. fmt.Println(err)
  30619. }
  30620. saveLog(result, src_resquest, "2208", "退费")
  30621. userJSONBytes, _ := json.Marshal(dat)
  30622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30623. utils.ErrorLog("解析失败:%v", err)
  30624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30625. return
  30626. }
  30627. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30628. var api3 string
  30629. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  30630. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30631. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30632. resp3, requestErr3 := http.Get(api3)
  30633. if requestErr3 != nil {
  30634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30635. return
  30636. }
  30637. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30638. if ioErr3 != nil {
  30639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30641. return
  30642. }
  30643. var respJSON3 map[string]interface{}
  30644. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30647. return
  30648. }
  30649. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30650. if status == "0" {
  30651. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30652. c.ServeSuccessJSON(map[string]interface{}{
  30653. "failed_code": -10,
  30654. "msg": err_msg,
  30655. })
  30656. return
  30657. }
  30658. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30659. userJSONBytes3, _ := json.Marshal(respJSON3)
  30660. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30661. // utils.ErrorLog("解析失败:%v", err)
  30662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30663. // return
  30664. //}
  30665. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  30666. utils.ErrorLog("解析失败:%v", err)
  30667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30668. return
  30669. }
  30670. res.InfRefmsgid = ahres.InfRefmsgid
  30671. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30672. // 创建对应的Time类型
  30673. t := time.UnixMilli(timestamp)
  30674. // 格式化成指定的日期字符串
  30675. str := t.Format("2006-01-02 15:04:05")
  30676. res.Output.Setlinfo.SetlTime = str
  30677. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30678. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30679. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30680. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30681. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30682. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30683. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30684. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30685. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30686. //
  30687. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30688. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30689. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30690. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30691. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30692. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30693. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30694. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30695. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30696. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30697. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30698. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30699. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30700. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30701. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30702. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30703. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30704. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30705. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30706. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30707. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30708. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30709. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30710. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30711. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30712. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30713. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30714. //res.Output.Setldetail = ahres.Output.Setldetail
  30715. res.ErrMsg = ahres.ErrMsg
  30716. res.Cainfo = ahres.Cainfo
  30717. res.WarnMsg = ahres.WarnMsg
  30718. res.Infcode = ahres.Infcode
  30719. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30720. var api3 string
  30721. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  30722. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30723. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30724. resp3, requestErr3 := http.Get(api3)
  30725. if requestErr3 != nil {
  30726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30727. return
  30728. }
  30729. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30730. if ioErr3 != nil {
  30731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30733. return
  30734. }
  30735. var respJSON3 map[string]interface{}
  30736. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30739. return
  30740. }
  30741. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30742. if status == "0" {
  30743. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30744. c.ServeSuccessJSON(map[string]interface{}{
  30745. "failed_code": -10,
  30746. "msg": err_msg,
  30747. })
  30748. return
  30749. }
  30750. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30751. userJSONBytes3, _ := json.Marshal(respJSON3)
  30752. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30753. // utils.ErrorLog("解析失败:%v", err)
  30754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30755. // return
  30756. //}
  30757. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  30758. utils.ErrorLog("解析失败:%v", err)
  30759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30760. return
  30761. }
  30762. res.InfRefmsgid = ahres.InfRefmsgid
  30763. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30764. // 创建对应的Time类型
  30765. t := time.UnixMilli(timestamp)
  30766. // 格式化成指定的日期字符串
  30767. str := t.Format("2006-01-02 15:04:05")
  30768. res.Output.Setlinfo.SetlTime = str
  30769. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30770. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30771. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30772. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30773. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30774. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30775. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30776. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30777. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30778. //
  30779. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30780. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30781. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30782. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30783. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30784. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30785. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30786. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30787. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30788. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30789. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30790. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30791. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30792. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30793. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30794. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30795. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30796. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30797. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30798. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30799. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30800. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30801. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30802. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30803. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30804. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30805. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30806. //res.Output.Setldetail = ahres.Output.Setldetail
  30807. res.ErrMsg = ahres.ErrMsg
  30808. res.Cainfo = ahres.Cainfo
  30809. res.WarnMsg = ahres.WarnMsg
  30810. res.Infcode = ahres.Infcode
  30811. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30812. 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, "")
  30813. var dat map[string]interface{}
  30814. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30815. fmt.Println(dat)
  30816. } else {
  30817. fmt.Println(err)
  30818. }
  30819. saveLog(result, src_resquest, "2208", "退费")
  30820. userJSONBytes, _ := json.Marshal(dat)
  30821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30822. utils.ErrorLog("解析失败:%v", err)
  30823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30824. return
  30825. }
  30826. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30827. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  30828. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30829. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30830. resp3, requestErr3 := http.Get(api3)
  30831. if requestErr3 != nil {
  30832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30833. return
  30834. }
  30835. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30836. if ioErr3 != nil {
  30837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30839. return
  30840. }
  30841. var respJSON3 map[string]interface{}
  30842. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30845. return
  30846. }
  30847. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30848. userJSONBytes3, _ := json.Marshal(respJSON3)
  30849. fmt.Println("log")
  30850. fmt.Println(string(userJSONBytes3))
  30851. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30852. utils.ErrorLog("解析失败:%v", err)
  30853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30854. return
  30855. }
  30856. } else {
  30857. if miConfig.Code == "H15049901371" {
  30858. 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)
  30859. var dat map[string]interface{}
  30860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30861. fmt.Println(dat)
  30862. } else {
  30863. fmt.Println(err)
  30864. }
  30865. saveLog(result, src_resquest, "2208", "退费")
  30866. if strings.Contains(result, "Post") {
  30867. res.Infcode = -1
  30868. res.ErrMsg = result
  30869. }
  30870. userJSONBytes, _ := json.Marshal(dat)
  30871. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  30872. utils.ErrorLog("解析失败:%v", err)
  30873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30874. return
  30875. }
  30876. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  30877. res.Output = resSixteen10265.Output
  30878. res.ErrMsg = resSixteen10265.ErrMsg
  30879. res.Cainfo = resSixteen10265.Cainfo
  30880. res.WarnMsg = resSixteen10265.WarnMsg
  30881. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  30882. res.Infcode = infocode
  30883. } else {
  30884. 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)
  30885. var dat map[string]interface{}
  30886. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30887. fmt.Println(dat)
  30888. } else {
  30889. fmt.Println(err)
  30890. }
  30891. saveLog(result, src_resquest, "2208", "退费")
  30892. userJSONBytes, _ := json.Marshal(dat)
  30893. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30894. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  30895. utils.ErrorLog("解析失败:%v", err)
  30896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30897. return
  30898. }
  30899. res.Infcode = gz.Infcode
  30900. } else {
  30901. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30902. utils.ErrorLog("解析失败:%v", err)
  30903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30904. return
  30905. }
  30906. }
  30907. if strings.Contains(result, "Post") {
  30908. res.Infcode = -1
  30909. res.ErrMsg = result
  30910. }
  30911. }
  30912. }
  30913. if res.Infcode == -1 {
  30914. c.ServeSuccessJSON(map[string]interface{}{
  30915. "failed_code": -10,
  30916. "msg": res.ErrMsg,
  30917. })
  30918. return
  30919. }
  30920. if res.Infcode != -1 {
  30921. var res2 ResultSix
  30922. var resSix10265 ResultSix10265
  30923. if miConfig.MdtrtareaAdmvs == "421300" {
  30924. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  30925. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30926. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30927. resp3, requestErr3 := http.Get(api3)
  30928. if requestErr3 != nil {
  30929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30930. return
  30931. }
  30932. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30933. if ioErr3 != nil {
  30934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30936. return
  30937. }
  30938. var respJSON3 map[string]interface{}
  30939. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30942. return
  30943. }
  30944. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30945. userJSONBytes3, _ := json.Marshal(respJSON3)
  30946. fmt.Println("log")
  30947. fmt.Println(string(userJSONBytes3))
  30948. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30949. utils.ErrorLog("解析失败:%v", err)
  30950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30951. return
  30952. }
  30953. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30954. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  30955. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30957. resp3, requestErr3 := http.Get(api3)
  30958. if requestErr3 != nil {
  30959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30960. return
  30961. }
  30962. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30963. if ioErr3 != nil {
  30964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30966. return
  30967. }
  30968. var respJSON3 map[string]interface{}
  30969. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30972. return
  30973. }
  30974. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30975. userJSONBytes3, _ := json.Marshal(respJSON3)
  30976. fmt.Println("log")
  30977. fmt.Println(string(userJSONBytes3))
  30978. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30979. utils.ErrorLog("解析失败:%v", err)
  30980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30981. return
  30982. }
  30983. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30984. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  30985. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30986. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30987. resp3, requestErr3 := http.Get(api3)
  30988. if requestErr3 != nil {
  30989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30990. return
  30991. }
  30992. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30993. if ioErr3 != nil {
  30994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30996. return
  30997. }
  30998. var respJSON3 map[string]interface{}
  30999. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31002. return
  31003. }
  31004. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31005. userJSONBytes3, _ := json.Marshal(respJSON3)
  31006. fmt.Println("log")
  31007. fmt.Println(string(userJSONBytes3))
  31008. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31009. utils.ErrorLog("解析失败:%v", err)
  31010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31011. return
  31012. }
  31013. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31014. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31015. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31016. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31017. resp3, requestErr3 := http.Get(api3)
  31018. if requestErr3 != nil {
  31019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31020. return
  31021. }
  31022. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31023. if ioErr3 != nil {
  31024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31026. return
  31027. }
  31028. var respJSON3 map[string]interface{}
  31029. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31032. return
  31033. }
  31034. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31035. userJSONBytes3, _ := json.Marshal(respJSON3)
  31036. fmt.Println("log")
  31037. fmt.Println(string(userJSONBytes3))
  31038. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31039. utils.ErrorLog("解析失败:%v", err)
  31040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31041. return
  31042. }
  31043. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31044. var api3 string
  31045. if miConfig.MdtrtareaAdmvs == "320921" {
  31046. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31047. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31048. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31049. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31050. } else {
  31051. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31052. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31053. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31054. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31055. }
  31056. resp3, requestErr3 := http.Get(api3)
  31057. if requestErr3 != nil {
  31058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31059. return
  31060. }
  31061. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31062. if ioErr3 != nil {
  31063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31065. return
  31066. }
  31067. var respJSON3 map[string]interface{}
  31068. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31071. return
  31072. }
  31073. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31074. userJSONBytes3, _ := json.Marshal(respJSON3)
  31075. fmt.Println("log")
  31076. fmt.Println(string(userJSONBytes3))
  31077. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31078. utils.ErrorLog("解析失败:%v", err)
  31079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31080. return
  31081. }
  31082. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31083. res2.Output = resSix10265.Output
  31084. res2.ErrMsg = resSix10265.ErrMsg
  31085. res2.Cainfo = resSix10265.Cainfo
  31086. res2.WarnMsg = resSix10265.WarnMsg
  31087. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31088. res2.Infcode = infocode
  31089. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31090. var api3 string
  31091. new_chrg_bchno := order.Number
  31092. if adminUser.CurrentOrgId == 10265 {
  31093. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31094. new_chrg_bchno = "0000"
  31095. }
  31096. }
  31097. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31098. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31099. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31100. resp3, requestErr3 := http.Get(api3)
  31101. if requestErr3 != nil {
  31102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31103. return
  31104. }
  31105. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31106. if ioErr3 != nil {
  31107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31109. return
  31110. }
  31111. var respJSON3 map[string]interface{}
  31112. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31115. return
  31116. }
  31117. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31118. userJSONBytes3, _ := json.Marshal(respJSON3)
  31119. fmt.Println("log")
  31120. fmt.Println(string(userJSONBytes3))
  31121. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31122. utils.ErrorLog("解析失败:%v", err)
  31123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31124. return
  31125. }
  31126. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31127. res2.Output = resSix10265.Output
  31128. res2.ErrMsg = resSix10265.ErrMsg
  31129. res2.Cainfo = resSix10265.Cainfo
  31130. res2.WarnMsg = resSix10265.WarnMsg
  31131. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31132. res2.Infcode = infocode
  31133. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31134. 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)
  31135. var dat map[string]interface{}
  31136. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31137. fmt.Println(dat)
  31138. } else {
  31139. fmt.Println(err)
  31140. }
  31141. saveLog(result2, src_request, "2205", "撤销明细")
  31142. userJSONBytes, _ := json.Marshal(dat)
  31143. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31144. utils.ErrorLog("解析失败:%v", err)
  31145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31146. return
  31147. }
  31148. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31149. 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, "")
  31150. var dat map[string]interface{}
  31151. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31152. fmt.Println(dat)
  31153. } else {
  31154. fmt.Println(err)
  31155. }
  31156. saveLog(result2, src_request, "2205", "撤销明细")
  31157. userJSONBytes, _ := json.Marshal(dat)
  31158. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31159. utils.ErrorLog("解析失败:%v", err)
  31160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31161. return
  31162. }
  31163. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31164. 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, "")
  31165. var dat map[string]interface{}
  31166. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31167. fmt.Println(dat)
  31168. } else {
  31169. fmt.Println(err)
  31170. }
  31171. saveLog(result2, src_request, "2205", "撤销明细")
  31172. userJSONBytes, _ := json.Marshal(dat)
  31173. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31174. utils.ErrorLog("解析失败:%v", err)
  31175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31176. return
  31177. }
  31178. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31179. var api3 string
  31180. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31181. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31182. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31183. resp3, requestErr3 := http.Get(api3)
  31184. if requestErr3 != nil {
  31185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31186. return
  31187. }
  31188. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31189. if ioErr3 != nil {
  31190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31192. return
  31193. }
  31194. var respJSON3 map[string]interface{}
  31195. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31198. return
  31199. }
  31200. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31201. if status == "0" {
  31202. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31203. c.ServeSuccessJSON(map[string]interface{}{
  31204. "failed_code": -10,
  31205. "msg": err_msg,
  31206. })
  31207. return
  31208. }
  31209. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31210. userJSONBytes3, _ := json.Marshal(respJSON3)
  31211. fmt.Println("log")
  31212. fmt.Println(string(userJSONBytes3))
  31213. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31214. utils.ErrorLog("解析失败:%v", err)
  31215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31216. return
  31217. }
  31218. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31219. 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, "")
  31220. var dat map[string]interface{}
  31221. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31222. fmt.Println(dat)
  31223. } else {
  31224. fmt.Println(err)
  31225. }
  31226. saveLog(result2, src_request, "2205", "撤销明细")
  31227. userJSONBytes, _ := json.Marshal(dat)
  31228. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31229. utils.ErrorLog("解析失败:%v", err)
  31230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31231. return
  31232. }
  31233. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31234. 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, "")
  31235. var dat map[string]interface{}
  31236. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31237. fmt.Println(dat)
  31238. } else {
  31239. fmt.Println(err)
  31240. }
  31241. saveLog(result2, src_request, "2205", "撤销明细")
  31242. userJSONBytes, _ := json.Marshal(dat)
  31243. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31244. utils.ErrorLog("解析失败:%v", err)
  31245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31246. return
  31247. }
  31248. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31249. var api3 string
  31250. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31251. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31252. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31253. resp3, requestErr3 := http.Get(api3)
  31254. if requestErr3 != nil {
  31255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31256. return
  31257. }
  31258. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31259. if ioErr3 != nil {
  31260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31262. return
  31263. }
  31264. var respJSON3 map[string]interface{}
  31265. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31268. return
  31269. }
  31270. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31271. if status == "0" {
  31272. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31273. c.ServeSuccessJSON(map[string]interface{}{
  31274. "failed_code": -10,
  31275. "msg": err_msg,
  31276. })
  31277. return
  31278. }
  31279. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31280. userJSONBytes3, _ := json.Marshal(respJSON3)
  31281. fmt.Println("log")
  31282. fmt.Println(string(userJSONBytes3))
  31283. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31284. utils.ErrorLog("解析失败:%v", err)
  31285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31286. return
  31287. }
  31288. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31289. 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, "")
  31290. var dat map[string]interface{}
  31291. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31292. fmt.Println(dat)
  31293. } else {
  31294. fmt.Println(err)
  31295. }
  31296. saveLog(result2, src_request, "2205", "撤销明细")
  31297. userJSONBytes, _ := json.Marshal(dat)
  31298. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31299. utils.ErrorLog("解析失败:%v", err)
  31300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31301. return
  31302. }
  31303. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31304. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  31305. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31306. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31307. resp3, requestErr3 := http.Get(api3)
  31308. if requestErr3 != nil {
  31309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31310. return
  31311. }
  31312. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31313. if ioErr3 != nil {
  31314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31316. return
  31317. }
  31318. var respJSON3 map[string]interface{}
  31319. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31322. return
  31323. }
  31324. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31325. userJSONBytes3, _ := json.Marshal(respJSON3)
  31326. fmt.Println("log")
  31327. fmt.Println(string(userJSONBytes3))
  31328. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31329. utils.ErrorLog("解析失败:%v", err)
  31330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31331. return
  31332. }
  31333. } else {
  31334. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31335. res2.Infcode = 0
  31336. } else {
  31337. 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)
  31338. var dat map[string]interface{}
  31339. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31340. fmt.Println(dat)
  31341. } else {
  31342. fmt.Println(err)
  31343. }
  31344. saveLog(result2, src_request, "2205", "撤销明细")
  31345. userJSONBytes, _ := json.Marshal(dat)
  31346. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31347. utils.ErrorLog("解析失败:%v", err)
  31348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31349. return
  31350. }
  31351. }
  31352. }
  31353. if res2.Infcode == -1 {
  31354. c.ServeSuccessJSON(map[string]interface{}{
  31355. "failed_code": -10,
  31356. "msg": res2.ErrMsg,
  31357. })
  31358. return
  31359. }
  31360. if res2.Infcode == 0 {
  31361. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  31362. if err == nil {
  31363. //当押金不为零时产生退费记录
  31364. if order.Decimal != 0 {
  31365. tmp := strconv.FormatInt(order.ID, 10)
  31366. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  31367. if err != nil {
  31368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31369. return
  31370. }
  31371. }
  31372. c.ServeSuccessJSON(map[string]interface{}{
  31373. "msg": "退费成功",
  31374. })
  31375. } else {
  31376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31377. return
  31378. }
  31379. } else {
  31380. c.ServeSuccessJSON(map[string]interface{}{
  31381. "failed_code": -10,
  31382. "msg": res2.ErrMsg,
  31383. })
  31384. }
  31385. } else {
  31386. c.ServeSuccessJSON(map[string]interface{}{
  31387. "failed_code": -10,
  31388. "msg": res.ErrMsg,
  31389. })
  31390. }
  31391. }
  31392. }
  31393. func (c *HisApiController) RefundNumber() {
  31394. record_time := c.GetString("record_time")
  31395. //patient_id, _ := c.GetInt64("patient_id")
  31396. admin_user_id, _ := c.GetInt64("admin_user_id")
  31397. his_patient_id, _ := c.GetInt64("id")
  31398. timeLayout := "2006-01-02"
  31399. loc, _ := time.LoadLocation("Local")
  31400. adminUser := c.GetAdminUserInfo()
  31401. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31402. fmt.Println(err)
  31403. if err != nil {
  31404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31405. return
  31406. }
  31407. recordDateTime := theTime.Unix()
  31408. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31409. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  31410. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31411. //order, _ := service.GetHisOrderByID(order_id)
  31412. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31413. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31414. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31415. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  31416. if count > 0 {
  31417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  31418. return
  31419. }
  31420. if config.IsOpen == 1 { //对接了医保,走医保流程
  31421. var res2 ResultSix
  31422. var res3 GZResultSix
  31423. var resSix10265 ResultSix10265
  31424. if miConfig.MdtrtareaAdmvs == "421300" {
  31425. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31426. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31427. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31428. resp3, requestErr3 := http.Get(api3)
  31429. if requestErr3 != nil {
  31430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31431. return
  31432. }
  31433. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31434. if ioErr3 != nil {
  31435. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31437. return
  31438. }
  31439. var respJSON3 map[string]interface{}
  31440. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31443. return
  31444. }
  31445. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31446. userJSONBytes3, _ := json.Marshal(respJSON3)
  31447. fmt.Println("log")
  31448. fmt.Println(string(userJSONBytes3))
  31449. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31450. utils.ErrorLog("解析失败:%v", err)
  31451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31452. return
  31453. }
  31454. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31455. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31456. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31457. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31458. resp3, requestErr3 := http.Get(api3)
  31459. if requestErr3 != nil {
  31460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31461. return
  31462. }
  31463. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31464. if ioErr3 != nil {
  31465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31467. return
  31468. }
  31469. var respJSON3 map[string]interface{}
  31470. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31473. return
  31474. }
  31475. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31476. userJSONBytes3, _ := json.Marshal(respJSON3)
  31477. fmt.Println("log")
  31478. fmt.Println(string(userJSONBytes3))
  31479. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31480. utils.ErrorLog("解析失败:%v", err)
  31481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31482. return
  31483. }
  31484. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31485. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  31486. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31487. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31488. resp3, requestErr3 := http.Get(api3)
  31489. if requestErr3 != nil {
  31490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31491. return
  31492. }
  31493. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31494. if ioErr3 != nil {
  31495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31497. return
  31498. }
  31499. var respJSON3 map[string]interface{}
  31500. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31503. return
  31504. }
  31505. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31506. userJSONBytes3, _ := json.Marshal(respJSON3)
  31507. fmt.Println("log")
  31508. fmt.Println(string(userJSONBytes3))
  31509. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31510. utils.ErrorLog("解析失败:%v", err)
  31511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31512. return
  31513. }
  31514. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31515. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  31516. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31517. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31518. resp3, requestErr3 := http.Get(api3)
  31519. if requestErr3 != nil {
  31520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31521. return
  31522. }
  31523. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31524. if ioErr3 != nil {
  31525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31527. return
  31528. }
  31529. var respJSON3 map[string]interface{}
  31530. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31533. return
  31534. }
  31535. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31536. userJSONBytes3, _ := json.Marshal(respJSON3)
  31537. fmt.Println("log")
  31538. fmt.Println(string(userJSONBytes3))
  31539. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31540. utils.ErrorLog("解析失败:%v", err)
  31541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31542. return
  31543. }
  31544. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31545. var api3 string
  31546. if miConfig.MdtrtareaAdmvs == "320921" {
  31547. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  31548. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31549. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31550. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31551. } else {
  31552. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31553. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  31554. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31555. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31556. }
  31557. resp3, requestErr3 := http.Get(api3)
  31558. if requestErr3 != nil {
  31559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31560. return
  31561. }
  31562. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31563. if ioErr3 != nil {
  31564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31566. return
  31567. }
  31568. var respJSON3 map[string]interface{}
  31569. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31572. return
  31573. }
  31574. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31575. userJSONBytes3, _ := json.Marshal(respJSON3)
  31576. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31577. utils.ErrorLog("解析失败:%v", err)
  31578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31579. return
  31580. }
  31581. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31582. res2.Output = resSix10265.Output
  31583. res2.ErrMsg = resSix10265.ErrMsg
  31584. res2.Cainfo = resSix10265.Cainfo
  31585. res2.WarnMsg = resSix10265.WarnMsg
  31586. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31587. res2.Infcode = infocode
  31588. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31589. var api3 string
  31590. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  31591. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31592. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31593. resp3, requestErr3 := http.Get(api3)
  31594. if requestErr3 != nil {
  31595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31596. return
  31597. }
  31598. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31599. if ioErr3 != nil {
  31600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31602. return
  31603. }
  31604. var respJSON3 map[string]interface{}
  31605. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31608. return
  31609. }
  31610. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31611. userJSONBytes3, _ := json.Marshal(respJSON3)
  31612. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31613. utils.ErrorLog("解析失败:%v", err)
  31614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31615. return
  31616. }
  31617. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31618. res2.Output = resSix10265.Output
  31619. res2.ErrMsg = resSix10265.ErrMsg
  31620. res2.Cainfo = resSix10265.Cainfo
  31621. res2.WarnMsg = resSix10265.WarnMsg
  31622. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31623. res2.Infcode = infocode
  31624. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31625. 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)
  31626. var dat map[string]interface{}
  31627. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31628. fmt.Println(dat)
  31629. } else {
  31630. fmt.Println(err)
  31631. }
  31632. saveLog(result, request, "2202", "退号")
  31633. userJSONBytes, _ := json.Marshal(dat)
  31634. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31635. utils.ErrorLog("解析失败:%v", err)
  31636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31637. return
  31638. }
  31639. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31640. 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, "")
  31641. var dat map[string]interface{}
  31642. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31643. fmt.Println(dat)
  31644. } else {
  31645. fmt.Println(err)
  31646. }
  31647. saveLog(result, request, "2202", "退号")
  31648. userJSONBytes, _ := json.Marshal(dat)
  31649. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31650. utils.ErrorLog("解析失败:%v", err)
  31651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31652. return
  31653. }
  31654. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31655. 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, "")
  31656. var dat map[string]interface{}
  31657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31658. fmt.Println(dat)
  31659. } else {
  31660. fmt.Println(err)
  31661. }
  31662. saveLog(result, request, "2202", "退号")
  31663. userJSONBytes, _ := json.Marshal(dat)
  31664. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31665. utils.ErrorLog("解析失败:%v", err)
  31666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31667. return
  31668. }
  31669. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31670. var api3 string
  31671. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  31672. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31673. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31674. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31675. resp3, requestErr3 := http.Get(api3)
  31676. if requestErr3 != nil {
  31677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31678. return
  31679. }
  31680. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31681. if ioErr3 != nil {
  31682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31684. return
  31685. }
  31686. var respJSON3 map[string]interface{}
  31687. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31690. return
  31691. }
  31692. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31693. if status == "0" {
  31694. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31695. c.ServeSuccessJSON(map[string]interface{}{
  31696. "failed_code": -10,
  31697. "msg": err_msg,
  31698. })
  31699. return
  31700. }
  31701. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31702. userJSONBytes3, _ := json.Marshal(respJSON3)
  31703. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31704. utils.ErrorLog("解析失败:%v", err)
  31705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31706. return
  31707. }
  31708. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  31709. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31710. var api3 string
  31711. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  31712. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31713. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31714. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31715. resp3, requestErr3 := http.Get(api3)
  31716. if requestErr3 != nil {
  31717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31718. return
  31719. }
  31720. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31721. if ioErr3 != nil {
  31722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31724. return
  31725. }
  31726. var respJSON3 map[string]interface{}
  31727. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31730. return
  31731. }
  31732. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31733. if status == "0" {
  31734. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31735. c.ServeSuccessJSON(map[string]interface{}{
  31736. "failed_code": -10,
  31737. "msg": err_msg,
  31738. })
  31739. return
  31740. }
  31741. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31742. userJSONBytes3, _ := json.Marshal(respJSON3)
  31743. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31744. utils.ErrorLog("解析失败:%v", err)
  31745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31746. return
  31747. }
  31748. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  31749. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31750. 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, "")
  31751. var dat map[string]interface{}
  31752. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31753. fmt.Println(dat)
  31754. } else {
  31755. fmt.Println(err)
  31756. }
  31757. saveLog(result, request, "2202", "退号")
  31758. userJSONBytes, _ := json.Marshal(dat)
  31759. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31760. utils.ErrorLog("解析失败:%v", err)
  31761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31762. return
  31763. }
  31764. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31765. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  31766. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31767. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  31768. resp3, requestErr3 := http.Get(api3)
  31769. if requestErr3 != nil {
  31770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31771. return
  31772. }
  31773. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31774. if ioErr3 != nil {
  31775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31777. return
  31778. }
  31779. var respJSON3 map[string]interface{}
  31780. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31783. return
  31784. }
  31785. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31786. userJSONBytes3, _ := json.Marshal(respJSON3)
  31787. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31788. utils.ErrorLog("解析失败:%v", err)
  31789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31790. return
  31791. }
  31792. } else {
  31793. var api3 string
  31794. if miConfig.Code == "H15049901371" {
  31795. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  31796. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31797. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31798. } else {
  31799. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  31800. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31801. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  31802. }
  31803. resp3, requestErr3 := http.Get(api3)
  31804. if requestErr3 != nil {
  31805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31806. return
  31807. }
  31808. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31809. if ioErr3 != nil {
  31810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31812. return
  31813. }
  31814. var respJSON3 map[string]interface{}
  31815. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31818. return
  31819. }
  31820. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31821. userJSONBytes3, _ := json.Marshal(respJSON3)
  31822. if miConfig.Code == "H15049901371" {
  31823. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31824. utils.ErrorLog("解析失败:%v", err)
  31825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31826. return
  31827. }
  31828. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31829. res2.Output = resSix10265.Output
  31830. res2.ErrMsg = resSix10265.ErrMsg
  31831. res2.Cainfo = resSix10265.Cainfo
  31832. res2.WarnMsg = resSix10265.WarnMsg
  31833. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31834. res2.Infcode = infocode
  31835. } else {
  31836. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31837. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  31838. utils.ErrorLog("解析失败:%v", err)
  31839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31840. return
  31841. }
  31842. res2.Infcode = res3.Infcode
  31843. } else {
  31844. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31845. utils.ErrorLog("解析失败:%v", err)
  31846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31847. return
  31848. }
  31849. }
  31850. }
  31851. }
  31852. if res2.Infcode == -1 {
  31853. c.ServeSuccessJSON(map[string]interface{}{
  31854. "failed_code": -10,
  31855. "msg": res2.ErrMsg,
  31856. })
  31857. return
  31858. }
  31859. if res2.Infcode == 0 {
  31860. if err == nil {
  31861. c.ServeSuccessJSON(map[string]interface{}{
  31862. "msg": "退号成功",
  31863. })
  31864. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  31865. } else {
  31866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31867. return
  31868. }
  31869. }
  31870. } else {
  31871. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  31872. //if err == nil {
  31873. // c.ServeSuccessJSON(map[string]interface{}{
  31874. // "msg": "退费成功",
  31875. // })
  31876. //} else {
  31877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31878. // return
  31879. //}
  31880. }
  31881. }
  31882. func (c *HisApiController) RefundDetail() {
  31883. order_id, _ := c.GetInt64("order_id")
  31884. admin_user_id, _ := c.GetInt64("admin_user_id")
  31885. //his_patient_id, _ := c.GetInt64("his_patient_id")
  31886. number := c.GetString("number")
  31887. record_time := c.GetString("record_time")
  31888. patient_id, _ := c.GetInt64("patient_id")
  31889. //med_type, _ := c.GetInt64("med_type")
  31890. timeLayout := "2006-01-02"
  31891. loc, _ := time.LoadLocation("Local")
  31892. adminUser := c.GetAdminUserInfo()
  31893. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31894. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31895. fmt.Println(err)
  31896. if err != nil {
  31897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31898. return
  31899. }
  31900. recordDateTime := theTime.Unix()
  31901. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  31902. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31903. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31904. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31905. var order models.HisOrder
  31906. order, _ = service.GetHisOrderByID(order_id)
  31907. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31908. if config.IsOpen == 1 { //对接了医保,走医保流程
  31909. var res2 ResultSix
  31910. if miConfig.MdtrtareaAdmvs == "421300" {
  31911. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31912. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31913. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31914. resp3, requestErr3 := http.Get(api3)
  31915. if requestErr3 != nil {
  31916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31917. return
  31918. }
  31919. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31920. if ioErr3 != nil {
  31921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31923. return
  31924. }
  31925. var respJSON3 map[string]interface{}
  31926. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31929. return
  31930. }
  31931. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31932. userJSONBytes3, _ := json.Marshal(respJSON3)
  31933. fmt.Println("log")
  31934. fmt.Println(string(userJSONBytes3))
  31935. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31936. utils.ErrorLog("解析失败:%v", err)
  31937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31938. return
  31939. }
  31940. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31941. if err == nil {
  31942. c.ServeSuccessJSON(map[string]interface{}{
  31943. "msg": "撤销明细成功",
  31944. })
  31945. return
  31946. } else {
  31947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31948. return
  31949. }
  31950. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31951. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31952. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31953. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31954. resp3, requestErr3 := http.Get(api3)
  31955. if requestErr3 != nil {
  31956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31957. return
  31958. }
  31959. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31960. if ioErr3 != nil {
  31961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31963. return
  31964. }
  31965. var respJSON3 map[string]interface{}
  31966. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31969. return
  31970. }
  31971. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31972. userJSONBytes3, _ := json.Marshal(respJSON3)
  31973. fmt.Println("log")
  31974. fmt.Println(string(userJSONBytes3))
  31975. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31976. utils.ErrorLog("解析失败:%v", err)
  31977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31978. return
  31979. }
  31980. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31981. if err == nil {
  31982. c.ServeSuccessJSON(map[string]interface{}{
  31983. "msg": "撤销明细成功",
  31984. })
  31985. return
  31986. } else {
  31987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31988. return
  31989. }
  31990. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31991. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31992. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31993. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31994. resp3, requestErr3 := http.Get(api3)
  31995. if requestErr3 != nil {
  31996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31997. return
  31998. }
  31999. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32000. if ioErr3 != nil {
  32001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32003. return
  32004. }
  32005. var respJSON3 map[string]interface{}
  32006. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32009. return
  32010. }
  32011. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32012. userJSONBytes3, _ := json.Marshal(respJSON3)
  32013. fmt.Println("log")
  32014. fmt.Println(string(userJSONBytes3))
  32015. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32016. utils.ErrorLog("解析失败:%v", err)
  32017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32018. return
  32019. }
  32020. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32021. if err == nil {
  32022. c.ServeSuccessJSON(map[string]interface{}{
  32023. "msg": "撤销明细成功",
  32024. })
  32025. return
  32026. } else {
  32027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32028. return
  32029. }
  32030. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32031. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32032. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32033. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32034. resp3, requestErr3 := http.Get(api3)
  32035. if requestErr3 != nil {
  32036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32037. return
  32038. }
  32039. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32040. if ioErr3 != nil {
  32041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32043. return
  32044. }
  32045. var respJSON3 map[string]interface{}
  32046. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32049. return
  32050. }
  32051. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32052. userJSONBytes3, _ := json.Marshal(respJSON3)
  32053. fmt.Println("log")
  32054. fmt.Println(string(userJSONBytes3))
  32055. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32056. utils.ErrorLog("解析失败:%v", err)
  32057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32058. return
  32059. }
  32060. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32061. if err == nil {
  32062. c.ServeSuccessJSON(map[string]interface{}{
  32063. "msg": "撤销明细成功",
  32064. })
  32065. return
  32066. } else {
  32067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32068. return
  32069. }
  32070. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32071. var resSix10265 ResultSix10265
  32072. var api3 string
  32073. if miConfig.MdtrtareaAdmvs == "320921" {
  32074. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32075. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32076. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32077. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32078. } else {
  32079. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32080. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32081. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32082. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32083. }
  32084. resp3, requestErr3 := http.Get(api3)
  32085. utils.ErrorLog("接口: %v", requestErr3)
  32086. if requestErr3 != nil {
  32087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32088. return
  32089. }
  32090. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32091. if ioErr3 != nil {
  32092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32094. return
  32095. }
  32096. var respJSON3 map[string]interface{}
  32097. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32100. return
  32101. }
  32102. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32103. userJSONBytes3, _ := json.Marshal(respJSON3)
  32104. fmt.Println("log")
  32105. fmt.Println(string(userJSONBytes3))
  32106. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32107. utils.ErrorLog("解析失败:%v", err)
  32108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32109. return
  32110. }
  32111. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32112. res2.Output = resSix10265.Output
  32113. res2.ErrMsg = resSix10265.ErrMsg
  32114. res2.Cainfo = resSix10265.Cainfo
  32115. res2.WarnMsg = resSix10265.WarnMsg
  32116. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32117. res2.Infcode = infocode
  32118. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32119. if err == nil {
  32120. c.ServeSuccessJSON(map[string]interface{}{
  32121. "msg": "撤销明细成功",
  32122. })
  32123. return
  32124. } else {
  32125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32126. return
  32127. }
  32128. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32129. var api3 string
  32130. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32131. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32132. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32133. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32134. resp3, requestErr3 := http.Get(api3)
  32135. utils.ErrorLog("接口: %v", requestErr3)
  32136. if requestErr3 != nil {
  32137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32138. return
  32139. }
  32140. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32141. if ioErr3 != nil {
  32142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32144. return
  32145. }
  32146. var respJSON3 map[string]interface{}
  32147. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32150. return
  32151. }
  32152. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32153. if status == "0" {
  32154. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32155. c.ServeSuccessJSON(map[string]interface{}{
  32156. "failed_code": -10,
  32157. "msg": err_msg,
  32158. })
  32159. return
  32160. }
  32161. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32162. userJSONBytes3, _ := json.Marshal(respJSON3)
  32163. fmt.Println("log")
  32164. fmt.Println(string(userJSONBytes3))
  32165. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32166. utils.ErrorLog("解析失败:%v", err)
  32167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32168. return
  32169. }
  32170. fmt.Println(res2.Infcode)
  32171. if res2.Infcode == -1 {
  32172. c.ServeSuccessJSON(map[string]interface{}{
  32173. "failed_code": -10,
  32174. "msg": res2.ErrMsg,
  32175. })
  32176. return
  32177. }
  32178. if res2.Infcode == 0 {
  32179. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32180. if err == nil {
  32181. c.ServeSuccessJSON(map[string]interface{}{
  32182. "msg": "撤销明细成功",
  32183. })
  32184. return
  32185. } else {
  32186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32187. return
  32188. }
  32189. } else {
  32190. c.ServeSuccessJSON(map[string]interface{}{
  32191. "failed_code": -10,
  32192. "msg": res2.ErrMsg,
  32193. })
  32194. }
  32195. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32196. if err == nil {
  32197. c.ServeSuccessJSON(map[string]interface{}{
  32198. "msg": "撤销明细成功",
  32199. })
  32200. return
  32201. } else {
  32202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32203. return
  32204. }
  32205. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32206. var api3 string
  32207. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32208. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32209. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32210. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32211. resp3, requestErr3 := http.Get(api3)
  32212. utils.ErrorLog("接口: %v", requestErr3)
  32213. if requestErr3 != nil {
  32214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32215. return
  32216. }
  32217. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32218. if ioErr3 != nil {
  32219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32221. return
  32222. }
  32223. var respJSON3 map[string]interface{}
  32224. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32227. return
  32228. }
  32229. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32230. if status == "0" {
  32231. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32232. c.ServeSuccessJSON(map[string]interface{}{
  32233. "failed_code": -10,
  32234. "msg": err_msg,
  32235. })
  32236. return
  32237. }
  32238. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32239. userJSONBytes3, _ := json.Marshal(respJSON3)
  32240. fmt.Println("log")
  32241. fmt.Println(string(userJSONBytes3))
  32242. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32243. utils.ErrorLog("解析失败:%v", err)
  32244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32245. return
  32246. }
  32247. fmt.Println(res2.Infcode)
  32248. if res2.Infcode == -1 {
  32249. c.ServeSuccessJSON(map[string]interface{}{
  32250. "failed_code": -10,
  32251. "msg": res2.ErrMsg,
  32252. })
  32253. return
  32254. }
  32255. if res2.Infcode == 0 {
  32256. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32257. if err == nil {
  32258. c.ServeSuccessJSON(map[string]interface{}{
  32259. "msg": "撤销明细成功",
  32260. })
  32261. return
  32262. } else {
  32263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32264. return
  32265. }
  32266. } else {
  32267. c.ServeSuccessJSON(map[string]interface{}{
  32268. "failed_code": -10,
  32269. "msg": res2.ErrMsg,
  32270. })
  32271. }
  32272. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32273. if err == nil {
  32274. c.ServeSuccessJSON(map[string]interface{}{
  32275. "msg": "撤销明细成功",
  32276. })
  32277. return
  32278. } else {
  32279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32280. return
  32281. }
  32282. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32283. var resSix10265 ResultSix10265
  32284. new_chrg_bchno := order.Number
  32285. if adminUser.CurrentOrgId == 10265 {
  32286. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32287. new_chrg_bchno = "0000"
  32288. }
  32289. }
  32290. var api3 string
  32291. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32292. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32293. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32294. resp3, requestErr3 := http.Get(api3)
  32295. if requestErr3 != nil {
  32296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32297. return
  32298. }
  32299. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32300. if ioErr3 != nil {
  32301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32303. return
  32304. }
  32305. var respJSON3 map[string]interface{}
  32306. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32309. return
  32310. }
  32311. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32312. userJSONBytes3, _ := json.Marshal(respJSON3)
  32313. fmt.Println("log")
  32314. fmt.Println(string(userJSONBytes3))
  32315. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32316. utils.ErrorLog("解析失败:%v", err)
  32317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32318. return
  32319. }
  32320. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32321. res2.Output = resSix10265.Output
  32322. res2.ErrMsg = resSix10265.ErrMsg
  32323. res2.Cainfo = resSix10265.Cainfo
  32324. res2.WarnMsg = resSix10265.WarnMsg
  32325. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32326. res2.Infcode = infocode
  32327. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32328. if err == nil {
  32329. c.ServeSuccessJSON(map[string]interface{}{
  32330. "msg": "撤销明细成功",
  32331. })
  32332. return
  32333. } else {
  32334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32335. return
  32336. }
  32337. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32338. 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)
  32339. var dat map[string]interface{}
  32340. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32341. fmt.Println(dat)
  32342. } else {
  32343. fmt.Println(err)
  32344. }
  32345. saveLog(result2, src_request, "2205", "撤销明细")
  32346. userJSONBytes, _ := json.Marshal(dat)
  32347. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32348. utils.ErrorLog("解析失败:%v", err)
  32349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32350. return
  32351. }
  32352. if res2.Infcode == 0 {
  32353. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32354. if err == nil {
  32355. c.ServeSuccessJSON(map[string]interface{}{
  32356. "msg": "撤销明细成功",
  32357. })
  32358. return
  32359. } else {
  32360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32361. return
  32362. }
  32363. } else {
  32364. c.ServeSuccessJSON(map[string]interface{}{
  32365. "failed_code": -10,
  32366. "msg": res2.ErrMsg,
  32367. })
  32368. }
  32369. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32370. 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, "")
  32371. var dat map[string]interface{}
  32372. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32373. fmt.Println(dat)
  32374. } else {
  32375. fmt.Println(err)
  32376. }
  32377. saveLog(result2, src_request, "2205", "撤销明细")
  32378. userJSONBytes, _ := json.Marshal(dat)
  32379. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32380. utils.ErrorLog("解析失败:%v", err)
  32381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32382. return
  32383. }
  32384. if res2.Infcode == 0 {
  32385. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32386. if err == nil {
  32387. c.ServeSuccessJSON(map[string]interface{}{
  32388. "msg": "撤销明细成功",
  32389. })
  32390. return
  32391. } else {
  32392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32393. return
  32394. }
  32395. } else {
  32396. c.ServeSuccessJSON(map[string]interface{}{
  32397. "failed_code": -10,
  32398. "msg": res2.ErrMsg,
  32399. })
  32400. }
  32401. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32402. 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, "")
  32403. var dat map[string]interface{}
  32404. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32405. fmt.Println(dat)
  32406. } else {
  32407. fmt.Println(err)
  32408. }
  32409. saveLog(result2, src_request, "2205", "撤销明细")
  32410. userJSONBytes, _ := json.Marshal(dat)
  32411. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32412. utils.ErrorLog("解析失败:%v", err)
  32413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32414. return
  32415. }
  32416. if res2.Infcode == 0 {
  32417. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32418. if err == nil {
  32419. c.ServeSuccessJSON(map[string]interface{}{
  32420. "msg": "撤销明细成功",
  32421. })
  32422. return
  32423. } else {
  32424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32425. return
  32426. }
  32427. } else {
  32428. c.ServeSuccessJSON(map[string]interface{}{
  32429. "failed_code": -10,
  32430. "msg": res2.ErrMsg,
  32431. })
  32432. }
  32433. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32434. 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, "")
  32435. var dat map[string]interface{}
  32436. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32437. fmt.Println(dat)
  32438. } else {
  32439. fmt.Println(err)
  32440. }
  32441. saveLog(result2, src_request, "2205", "撤销明细")
  32442. userJSONBytes, _ := json.Marshal(dat)
  32443. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32444. utils.ErrorLog("解析失败:%v", err)
  32445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32446. return
  32447. }
  32448. if res2.Infcode == 0 {
  32449. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32450. if err == nil {
  32451. c.ServeSuccessJSON(map[string]interface{}{
  32452. "msg": "撤销明细成功",
  32453. })
  32454. return
  32455. } else {
  32456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32457. return
  32458. }
  32459. } else {
  32460. c.ServeSuccessJSON(map[string]interface{}{
  32461. "failed_code": -10,
  32462. "msg": res2.ErrMsg,
  32463. })
  32464. }
  32465. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32466. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  32467. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32468. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32469. resp2, requestErr2 := http.Get(api2)
  32470. if requestErr2 != nil {
  32471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32472. return
  32473. }
  32474. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32475. if ioErr2 != nil {
  32476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32478. return
  32479. }
  32480. var respJSON2 map[string]interface{}
  32481. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32484. return
  32485. }
  32486. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32487. userJSONBytes3, _ := json.Marshal(respJSON2)
  32488. fmt.Println("log")
  32489. fmt.Println(string(userJSONBytes3))
  32490. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32491. utils.ErrorLog("解析失败:%v", err)
  32492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32493. return
  32494. }
  32495. if res2.Infcode == 0 {
  32496. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32497. if err == nil {
  32498. c.ServeSuccessJSON(map[string]interface{}{
  32499. "msg": "撤销明细成功",
  32500. })
  32501. return
  32502. } else {
  32503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32504. return
  32505. }
  32506. } else {
  32507. c.ServeSuccessJSON(map[string]interface{}{
  32508. "failed_code": -10,
  32509. "msg": res2.ErrMsg,
  32510. })
  32511. }
  32512. } else {
  32513. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  32514. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32515. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32516. resp2, requestErr2 := http.Get(api2)
  32517. if requestErr2 != nil {
  32518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32519. return
  32520. }
  32521. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32522. if ioErr2 != nil {
  32523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32525. return
  32526. }
  32527. var respJSON2 map[string]interface{}
  32528. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32531. return
  32532. }
  32533. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32534. userJSONBytes3, _ := json.Marshal(respJSON2)
  32535. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32536. utils.ErrorLog("解析失败:%v", err)
  32537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32538. return
  32539. }
  32540. if res2.Infcode == -1 {
  32541. c.ServeSuccessJSON(map[string]interface{}{
  32542. "failed_code": -10,
  32543. "msg": res2.ErrMsg,
  32544. })
  32545. return
  32546. } else {
  32547. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32548. if err == nil {
  32549. c.ServeSuccessJSON(map[string]interface{}{
  32550. "msg": "撤销明细成功",
  32551. })
  32552. return
  32553. } else {
  32554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32555. return
  32556. }
  32557. }
  32558. }
  32559. } else {
  32560. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32561. if err == nil {
  32562. c.ServeSuccessJSON(map[string]interface{}{
  32563. "msg": "退费成功",
  32564. })
  32565. } else {
  32566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32567. return
  32568. }
  32569. }
  32570. }
  32571. // 对账
  32572. func (c *HisApiController) GetCheckAccount() {
  32573. start_time := c.GetString("start_time")
  32574. end_time := c.GetString("end_time")
  32575. insutype := c.GetString("insutype")
  32576. clr_type := c.GetString("clr_type")
  32577. clr_org := c.GetString("clr_optins")
  32578. admin_user_id, _ := c.GetInt64("admin_user_id")
  32579. adminUser := c.GetAdminUserInfo()
  32580. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32581. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32582. if len(clr_org) == 0 {
  32583. clr_org = miConfig.InsuplcAdmdvs
  32584. }
  32585. timeLayout := "2006-01-02"
  32586. loc, _ := time.LoadLocation("Local")
  32587. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  32588. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  32589. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32590. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32591. fixmedins_setl_cnt := int64(len(orders))
  32592. var medfee_sumamt float64
  32593. var acct_pay float64
  32594. var fund_pay_sumamt float64
  32595. for _, item := range orders {
  32596. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  32597. acct_pay = acct_pay + item.AcctPay
  32598. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  32599. }
  32600. var user_name string
  32601. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32602. if role.ID == 0 {
  32603. user_name = "xxx"
  32604. } else {
  32605. user_name = role.UserName
  32606. }
  32607. var res ResultEight
  32608. var res10188 ResultEightFor10188
  32609. if config.IsOpen == 1 {
  32610. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32611. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  32612. "insutype=" + insutype +
  32613. "&clr_type=" + clr_type +
  32614. "&setl_optins=" + clr_org +
  32615. "&stmt_begndate=" + start_time +
  32616. "&stm_enddate=" + end_time +
  32617. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32618. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32619. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32620. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  32621. "&fixmedins_code=" + miConfig.Code +
  32622. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32623. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32624. "&secret_key=" + miConfig.SecretKey +
  32625. "&org_name=" + miConfig.OrgName +
  32626. "&doctor=" + user_name +
  32627. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32628. fmt.Println(api)
  32629. resp, requestErr := http.Get(api)
  32630. if requestErr != nil {
  32631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32632. return
  32633. }
  32634. body, ioErr := ioutil.ReadAll(resp.Body)
  32635. fmt.Println(body)
  32636. if ioErr != nil {
  32637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32639. return
  32640. }
  32641. var respJSON map[string]interface{}
  32642. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32645. return
  32646. }
  32647. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32648. userJSONBytes, _ := json.Marshal(respJSON)
  32649. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32650. utils.ErrorLog("解析失败:%v", err)
  32651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32652. return
  32653. }
  32654. res.InfRefmsgid = res10188.InfRefmsgid
  32655. res.Output = res10188.Output
  32656. res.ErrMsg = res10188.ErrMsg
  32657. res.Cainfo = res10188.Cainfo
  32658. res.WarnMsg = res10188.WarnMsg
  32659. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  32660. res.Infcode = infocode
  32661. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32662. if clr_type != "9903" {
  32663. clr_type = "99" // 就诊 ID(来自2201接口返回)
  32664. }
  32665. if clr_type == "9903" {
  32666. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  32667. }
  32668. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  32669. "insutype=" + insutype +
  32670. "&clr_type=" + clr_type +
  32671. "&setl_optins=" + clr_org +
  32672. "&stmt_begndate=" + start_time +
  32673. "&stm_enddate=" + end_time +
  32674. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32675. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32676. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32677. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  32678. "&fixmedins_code=" + miConfig.Code +
  32679. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32680. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32681. "&secret_key=" + miConfig.SecretKey +
  32682. "&org_name=" + miConfig.OrgName +
  32683. "&doctor=" + user_name
  32684. resp, requestErr := http.Get(api)
  32685. if requestErr != nil {
  32686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32687. return
  32688. }
  32689. body, ioErr := ioutil.ReadAll(resp.Body)
  32690. if ioErr != nil {
  32691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32693. return
  32694. }
  32695. var respJSON map[string]interface{}
  32696. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32699. return
  32700. }
  32701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32702. result, _ := json.Marshal(respJSON)
  32703. fmt.Println("log")
  32704. fmt.Println(string(result))
  32705. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  32706. utils.ErrorLog("解析失败:%v", err)
  32707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32708. return
  32709. }
  32710. res.InfRefmsgid = res10188.InfRefmsgid
  32711. res.Output = res10188.Output
  32712. res.ErrMsg = res10188.ErrMsg
  32713. res.Cainfo = res10188.Cainfo
  32714. res.WarnMsg = res10188.WarnMsg
  32715. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  32716. res.Infcode = infocode
  32717. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32718. var baseParams models.BaseParams
  32719. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  32720. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  32721. baseParams.SecretKey = miConfig.SecretKey
  32722. baseParams.OrgName = miConfig.OrgName
  32723. baseParams.FixmedinsCode = miConfig.Code
  32724. baseParams.EncKey = miConfig.EncKey
  32725. baseParams.AppSecret = miConfig.AppSecret
  32726. baseParams.SignKey = miConfig.SignKey
  32727. baseParams.AppID = miConfig.Code
  32728. baseParams.Doctor = role.UserName
  32729. baseParams.RequestUrl = miConfig.Url
  32730. businessParams := models.BusinessParams{
  32731. Insutype: insutype,
  32732. ClrType: clr_type,
  32733. SetlOptins: clr_org,
  32734. StmtBegndate: start_time,
  32735. StmtEnddate: end_time,
  32736. MedfeeSumamt: medfee_sumamt,
  32737. FundPaySumamt: fund_pay_sumamt,
  32738. AcctPay: acct_pay,
  32739. FixmedinsSetlCnt: fixmedins_setl_cnt,
  32740. }
  32741. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  32742. fmt.Println(requestLog)
  32743. fmt.Println(result)
  32744. fmt.Println(err_msg)
  32745. var dat map[string]interface{}
  32746. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32747. fmt.Println(dat)
  32748. } else {
  32749. fmt.Println(err)
  32750. }
  32751. userJSONBytes, _ := json.Marshal(dat)
  32752. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32753. utils.ErrorLog("解析失败:%v", err)
  32754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32755. return
  32756. }
  32757. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32758. var baseParams models.BaseParams
  32759. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  32760. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  32761. baseParams.SecretKey = miConfig.SecretKey
  32762. baseParams.OrgName = miConfig.OrgName
  32763. baseParams.FixmedinsCode = miConfig.Code
  32764. baseParams.EncKey = miConfig.EncKey
  32765. baseParams.AppSecret = miConfig.AppSecret
  32766. baseParams.SignKey = miConfig.SignKey
  32767. baseParams.AppID = miConfig.Code
  32768. baseParams.Doctor = role.UserName
  32769. baseParams.RequestUrl = miConfig.Url
  32770. baseParams.AccessKey = miConfig.AccessKey
  32771. businessParams := models.BusinessParams{
  32772. Insutype: insutype,
  32773. ClrType: clr_type,
  32774. SetlOptins: "430822",
  32775. StmtBegndate: start_time,
  32776. StmtEnddate: end_time,
  32777. MedfeeSumamt: medfee_sumamt,
  32778. FundPaySumamt: fund_pay_sumamt,
  32779. AcctPay: acct_pay,
  32780. FixmedinsSetlCnt: fixmedins_setl_cnt,
  32781. }
  32782. 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)
  32783. fmt.Println(requestLog)
  32784. fmt.Println(result)
  32785. var dat map[string]interface{}
  32786. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32787. fmt.Println(dat)
  32788. } else {
  32789. fmt.Println(err)
  32790. }
  32791. userJSONBytes, _ := json.Marshal(dat)
  32792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32793. utils.ErrorLog("解析失败:%v", err)
  32794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32795. return
  32796. }
  32797. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32798. var baseParams models.BaseParams
  32799. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  32800. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  32801. baseParams.SecretKey = miConfig.SecretKey
  32802. baseParams.OrgName = miConfig.OrgName
  32803. baseParams.FixmedinsCode = miConfig.Code
  32804. baseParams.EncKey = miConfig.EncKey
  32805. baseParams.AppSecret = miConfig.AppSecret
  32806. baseParams.SignKey = miConfig.SignKey
  32807. baseParams.AppID = miConfig.Code
  32808. baseParams.Doctor = role.UserName
  32809. baseParams.RequestUrl = miConfig.Url
  32810. businessParams := models.BusinessParams{
  32811. Insutype: insutype,
  32812. ClrType: clr_type,
  32813. SetlOptins: clr_org,
  32814. StmtBegndate: start_time,
  32815. StmtEnddate: end_time,
  32816. MedfeeSumamt: medfee_sumamt,
  32817. FundPaySumamt: fund_pay_sumamt,
  32818. AcctPay: acct_pay,
  32819. FixmedinsSetlCnt: fixmedins_setl_cnt,
  32820. }
  32821. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  32822. fmt.Println(requestLog)
  32823. fmt.Println(result)
  32824. fmt.Println(err_msg)
  32825. var dat map[string]interface{}
  32826. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32827. fmt.Println(dat)
  32828. } else {
  32829. fmt.Println(err)
  32830. }
  32831. userJSONBytes, _ := json.Marshal(dat)
  32832. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32833. utils.ErrorLog("解析失败:%v", err)
  32834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32835. return
  32836. }
  32837. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32838. if len(clr_type) == 0 {
  32839. clr_type = "11"
  32840. }
  32841. api := miConfig.Url + "gdyb/ten?" +
  32842. "insutype=" + insutype +
  32843. "&clr_type=" + clr_type +
  32844. "&setl_optins=" + clr_org +
  32845. "&stmt_begndate=" + start_time +
  32846. "&stm_enddate=" + end_time +
  32847. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32848. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32849. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32850. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  32851. "&fixmedins_code=" + miConfig.Code +
  32852. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32853. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32854. "&secret_key=" + miConfig.SecretKey +
  32855. "&org_name=" + miConfig.OrgName +
  32856. "&doctor=" + user_name
  32857. fmt.Println(api)
  32858. resp, requestErr := http.Get(api)
  32859. if requestErr != nil {
  32860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32861. return
  32862. }
  32863. body, ioErr := ioutil.ReadAll(resp.Body)
  32864. fmt.Println(body)
  32865. if ioErr != nil {
  32866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32868. return
  32869. }
  32870. var respJSON map[string]interface{}
  32871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32874. return
  32875. }
  32876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32877. userJSONBytes, _ := json.Marshal(respJSON)
  32878. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32879. utils.ErrorLog("解析失败:%v", err)
  32880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32881. return
  32882. }
  32883. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32884. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32885. //fixmedins_setl_cnt := int64(len(orders_two))
  32886. //var medfee_sumamt float64
  32887. //var acct_pay float64
  32888. //var fund_pay_sumamt float64
  32889. //for _, item := range orders_two {
  32890. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  32891. // acct_pay = acct_pay + item.AcctPay
  32892. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  32893. //}
  32894. var baseParams models.BaseParams
  32895. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  32896. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  32897. baseParams.SecretKey = miConfig.SecretKey
  32898. baseParams.OrgName = miConfig.OrgName
  32899. baseParams.FixmedinsCode = miConfig.Code
  32900. baseParams.EncKey = miConfig.EncKey
  32901. baseParams.AppSecret = miConfig.AppSecret
  32902. baseParams.SignKey = miConfig.SignKey
  32903. baseParams.AppID = miConfig.Code
  32904. baseParams.Doctor = role.UserName
  32905. baseParams.RequestUrl = miConfig.Url
  32906. if clr_type == "9903" {
  32907. clr_type = "9994"
  32908. }
  32909. businessParams := models.BusinessParams{
  32910. Insutype: insutype,
  32911. ClrType: clr_type,
  32912. SetlOptins: "360302",
  32913. StmtBegndate: start_time,
  32914. StmtEnddate: end_time,
  32915. MedfeeSumamt: 0,
  32916. FundPaySumamt: 0,
  32917. AcctPay: 0,
  32918. FixmedinsSetlCnt: fixmedins_setl_cnt,
  32919. }
  32920. 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))
  32921. fmt.Println(requestLog)
  32922. fmt.Println(result)
  32923. var dat map[string]interface{}
  32924. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32925. fmt.Println(dat)
  32926. } else {
  32927. fmt.Println(err)
  32928. }
  32929. userJSONBytes, _ := json.Marshal(dat)
  32930. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32931. utils.ErrorLog("解析失败:%v", err)
  32932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32933. return
  32934. }
  32935. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32936. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32937. fixmedins_setl_cnt := int64(len(orders_two))
  32938. var medfee_sumamt float64
  32939. var acct_pay float64
  32940. var fund_pay_sumamt float64
  32941. for _, item := range orders_two {
  32942. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  32943. acct_pay = acct_pay + item.AcctPay
  32944. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  32945. }
  32946. var baseParams models.BaseParams
  32947. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  32948. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  32949. baseParams.SecretKey = miConfig.SecretKey
  32950. baseParams.OrgName = miConfig.OrgName
  32951. baseParams.FixmedinsCode = miConfig.Code
  32952. baseParams.EncKey = miConfig.EncKey
  32953. baseParams.AppSecret = miConfig.AppSecret
  32954. baseParams.SignKey = miConfig.SignKey
  32955. baseParams.AppID = miConfig.Code
  32956. baseParams.Doctor = role.UserName
  32957. baseParams.RequestUrl = miConfig.Url
  32958. if clr_type == "9903" {
  32959. clr_type = "9994"
  32960. }
  32961. businessParams := models.BusinessParams{
  32962. Insutype: insutype,
  32963. ClrType: clr_type,
  32964. SetlOptins: "361025",
  32965. StmtBegndate: start_time,
  32966. StmtEnddate: end_time,
  32967. MedfeeSumamt: 0,
  32968. FundPaySumamt: 0,
  32969. AcctPay: 0,
  32970. FixmedinsSetlCnt: fixmedins_setl_cnt,
  32971. }
  32972. 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))
  32973. fmt.Println(requestLog)
  32974. fmt.Println(result)
  32975. var dat map[string]interface{}
  32976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32977. fmt.Println(dat)
  32978. } else {
  32979. fmt.Println(err)
  32980. }
  32981. userJSONBytes, _ := json.Marshal(dat)
  32982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32983. utils.ErrorLog("解析失败:%v", err)
  32984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32985. return
  32986. }
  32987. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32988. var api string
  32989. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  32990. "&clr_type=" + clr_type +
  32991. "&setl_optins=" + clr_org +
  32992. "&stmt_begndate=" + start_time +
  32993. "&stm_enddate=" + end_time +
  32994. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32995. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32996. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32997. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  32998. "&fixmedins_code=" + miConfig.Code +
  32999. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33000. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33001. "&secret_key=" + miConfig.SecretKey +
  33002. "&org_name=" + miConfig.OrgName +
  33003. "&doctor=" + user_name + "&url=" + miConfig.Url
  33004. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33005. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33006. resp, requestErr := http.Get(api)
  33007. if requestErr != nil {
  33008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33009. return
  33010. }
  33011. body, ioErr := ioutil.ReadAll(resp.Body)
  33012. if ioErr != nil {
  33013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33015. return
  33016. }
  33017. var respJSON map[string]interface{}
  33018. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33021. return
  33022. }
  33023. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33024. if status == "0" {
  33025. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33026. c.ServeSuccessJSON(map[string]interface{}{
  33027. "failed_code": -10,
  33028. "msg": err_msg,
  33029. })
  33030. return
  33031. }
  33032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33033. userJSONBytes, _ := json.Marshal(respJSON)
  33034. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33035. utils.ErrorLog("解析失败:%v", err)
  33036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33037. return
  33038. }
  33039. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33040. var api string
  33041. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33042. "&clr_type=" + clr_type +
  33043. "&setl_optins=" + clr_org +
  33044. "&stmt_begndate=" + start_time +
  33045. "&stm_enddate=" + end_time +
  33046. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33047. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33048. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33049. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33050. "&fixmedins_code=" + miConfig.Code +
  33051. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33052. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33053. "&secret_key=" + miConfig.SecretKey +
  33054. "&org_name=" + miConfig.OrgName +
  33055. "&doctor=" + user_name + "&url=" + miConfig.Url
  33056. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33057. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33058. resp, requestErr := http.Get(api)
  33059. if requestErr != nil {
  33060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33061. return
  33062. }
  33063. body, ioErr := ioutil.ReadAll(resp.Body)
  33064. if ioErr != nil {
  33065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33067. return
  33068. }
  33069. var respJSON map[string]interface{}
  33070. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33073. return
  33074. }
  33075. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33076. if status == "0" {
  33077. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33078. c.ServeSuccessJSON(map[string]interface{}{
  33079. "failed_code": -10,
  33080. "msg": err_msg,
  33081. })
  33082. return
  33083. }
  33084. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33085. userJSONBytes, _ := json.Marshal(respJSON)
  33086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33087. utils.ErrorLog("解析失败:%v", err)
  33088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33089. return
  33090. }
  33091. } else {
  33092. if len(clr_type) == 0 {
  33093. clr_type = "11"
  33094. }
  33095. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33096. "insutype=" + insutype +
  33097. "&clr_type=" + clr_type +
  33098. "&setl_optins=" + clr_org +
  33099. "&stmt_begndate=" + start_time +
  33100. "&stm_enddate=" + end_time +
  33101. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33102. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33103. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33104. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33105. "&fixmedins_code=" + miConfig.Code +
  33106. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33107. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33108. "&secret_key=" + miConfig.SecretKey +
  33109. "&org_name=" + miConfig.OrgName +
  33110. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33111. fmt.Println(api)
  33112. resp, requestErr := http.Get(api)
  33113. if requestErr != nil {
  33114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33115. return
  33116. }
  33117. body, ioErr := ioutil.ReadAll(resp.Body)
  33118. fmt.Println(body)
  33119. if ioErr != nil {
  33120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33122. return
  33123. }
  33124. var respJSON map[string]interface{}
  33125. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33128. return
  33129. }
  33130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33131. userJSONBytes, _ := json.Marshal(respJSON)
  33132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33133. utils.ErrorLog("解析失败:%v", err)
  33134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33135. return
  33136. }
  33137. }
  33138. if res.Infcode == 0 {
  33139. if res.Output.Stmtinfo.StmtRslt == "0" {
  33140. micc := &models.MedicalInsuranceCostCompare{
  33141. StartTime: startime.Unix(),
  33142. EndTime: endtime.Unix(),
  33143. Insutype: insutype,
  33144. CheckType: 1,
  33145. Num: fixmedins_setl_cnt,
  33146. Mtime: time.Now().Unix(),
  33147. Status: 1,
  33148. UserOrgId: adminUser.CurrentOrgId,
  33149. CostTotal: medfee_sumamt,
  33150. FuncTotal: fund_pay_sumamt,
  33151. PsnPay: acct_pay,
  33152. Creator: admin_user_id,
  33153. Ctime: time.Now().Unix(),
  33154. ClrType: clr_type,
  33155. }
  33156. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33157. if err == nil {
  33158. c.ServeSuccessJSON(map[string]interface{}{
  33159. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33160. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33161. })
  33162. } else {
  33163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33164. }
  33165. } else {
  33166. c.ServeSuccessJSON(map[string]interface{}{
  33167. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33168. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33169. })
  33170. }
  33171. } else {
  33172. c.ServeSuccessJSON(map[string]interface{}{
  33173. "failed_code": -10,
  33174. "msg": res.ErrMsg,
  33175. })
  33176. }
  33177. }
  33178. }
  33179. func (c *HisApiController) Check310() {
  33180. adminUser := c.GetAdminUserInfo()
  33181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33182. var user_name string
  33183. user_name = "高慧裕"
  33184. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33185. "insutype=" + "310" +
  33186. "&clr_type=" + "" +
  33187. "&setl_optins=" + "441202" +
  33188. "&stmt_begndate=" + "2022-03-01" +
  33189. "&stm_enddate=" + "2022-03-31" +
  33190. "&medfee_sumamt=" + "194930.12" +
  33191. "&fund_pay_sumamt=" + "188741.46" +
  33192. "&acct_pay=" + "0" +
  33193. "&fixmedins_setl_cnt=" + "452" +
  33194. "&fixmedins_code=" + miConfig.Code +
  33195. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33196. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33197. "&secret_key=" + miConfig.SecretKey +
  33198. "&org_name=" + miConfig.OrgName +
  33199. "&doctor=" + user_name
  33200. fmt.Println(api)
  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. fmt.Println(body)
  33208. if ioErr != nil {
  33209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33211. return
  33212. }
  33213. var respJSON map[string]interface{}
  33214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33217. return
  33218. }
  33219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33220. userJSONBytes, _ := json.Marshal(respJSON)
  33221. var res ResultEight
  33222. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33223. utils.ErrorLog("解析失败:%v", err)
  33224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33225. return
  33226. }
  33227. }
  33228. func (c *HisApiController) Check390() {
  33229. adminUser := c.GetAdminUserInfo()
  33230. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33231. var user_name string
  33232. user_name = "高慧裕"
  33233. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33234. "insutype=" + "390" +
  33235. "&clr_type=" + "" +
  33236. "&setl_optins=" + "441202" +
  33237. "&stmt_begndate=" + "2022-03-01" +
  33238. "&stm_enddate=" + "2022-03-31" +
  33239. "&medfee_sumamt=" + "1068448.89" +
  33240. "&fund_pay_sumamt=" + "1014677.62" +
  33241. "&acct_pay=" + "0" +
  33242. "&fixmedins_setl_cnt=" + "1950" +
  33243. "&fixmedins_code=" + miConfig.Code +
  33244. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33245. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33246. "&secret_key=" + miConfig.SecretKey +
  33247. "&org_name=" + miConfig.OrgName +
  33248. "&doctor=" + user_name
  33249. fmt.Println(api)
  33250. resp, requestErr := http.Get(api)
  33251. if requestErr != nil {
  33252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33253. return
  33254. }
  33255. body, ioErr := ioutil.ReadAll(resp.Body)
  33256. fmt.Println(body)
  33257. if ioErr != nil {
  33258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33260. return
  33261. }
  33262. var respJSON map[string]interface{}
  33263. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33266. return
  33267. }
  33268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33269. userJSONBytes, _ := json.Marshal(respJSON)
  33270. var res ResultEight
  33271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33272. utils.ErrorLog("解析失败:%v", err)
  33273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33274. return
  33275. }
  33276. }
  33277. // 对账明细
  33278. func (c *HisApiController) GetCheckDetailAccount() {
  33279. start_time := c.GetString("start_time")
  33280. end_time := c.GetString("end_time")
  33281. admin_user_id, _ := c.GetInt64("admin_user_id")
  33282. adminUser := c.GetAdminUserInfo()
  33283. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33284. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33285. timeLayout := "2006-01-02"
  33286. loc, _ := time.LoadLocation("Local")
  33287. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33288. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33289. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33290. rand.Seed(time.Now().UnixNano())
  33291. num := rand.Intn(30000)
  33292. Mkdir(miConfig.OrgName)
  33293. file := strconv.FormatInt(int64(num), 10)
  33294. file_name := file + ".txt"
  33295. zip_name := file + ".zip"
  33296. zip_path := miConfig.OrgName + "/" + zip_name
  33297. file_path := miConfig.OrgName + "/" + file_name
  33298. decimal.DivisionPrecision = 2
  33299. var medfee_sumamt float64
  33300. var psn_cash_pay float64
  33301. var fund_pay_sumamt float64
  33302. fixmedins_setl_cnt := int64(len(orders))
  33303. for _, item := range orders {
  33304. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33305. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  33306. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33307. }
  33308. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  33309. defer f.Close()
  33310. if err != nil {
  33311. fmt.Println(err.Error())
  33312. } else {
  33313. for _, item := range orders {
  33314. var refd_setl_flag string
  33315. if item.OrderStatus == 2 {
  33316. refd_setl_flag = "0"
  33317. var str string
  33318. str = item.SetlId + " " +
  33319. item.MdtrtId + " " +
  33320. item.PsnNo + " " +
  33321. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33322. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33323. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  33324. _, err = f.Write([]byte(str))
  33325. }
  33326. if item.OrderStatus == 3 {
  33327. var str string
  33328. str = item.SetlId + " " +
  33329. item.MdtrtId + " " +
  33330. item.PsnNo + " " +
  33331. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33332. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33333. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  33334. _, err = f.Write([]byte(str))
  33335. var str2 string
  33336. str2 = item.SetlId + " " +
  33337. item.MdtrtId + " " +
  33338. item.PsnNo + " " +
  33339. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  33340. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  33341. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  33342. _, err = f.Write([]byte(str2))
  33343. }
  33344. }
  33345. }
  33346. Zip(file_path, zip_path)
  33347. fmt.Println(ReadFile(zip_path))
  33348. fmt.Println(string(ReadFile(zip_path)))
  33349. if config.IsOpen == 1 {
  33350. var user_name string
  33351. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33352. if role.ID == 0 {
  33353. user_name = "管理员"
  33354. } else {
  33355. user_name = role.UserName
  33356. }
  33357. baseParams := models.BaseParams{
  33358. SecretKey: miConfig.SecretKey,
  33359. FixmedinsCode: miConfig.Code,
  33360. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33361. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33362. OrgName: miConfig.OrgName,
  33363. Doctor: user_name,
  33364. }
  33365. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  33366. var dat map[string]interface{}
  33367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33368. fmt.Println(dat)
  33369. } else {
  33370. fmt.Println(err)
  33371. }
  33372. userJSONBytes, _ := json.Marshal(dat)
  33373. var res ResultNine
  33374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33375. utils.ErrorLog("解析失败:%v", err)
  33376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33377. return
  33378. }
  33379. if res.Infcode == 0 {
  33380. fileNo := res.Output.FileQuryNo
  33381. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  33382. "file_qury_no=" + fileNo +
  33383. "&setl_optins=" + "定点医保中心" +
  33384. "&stmt_begndate=" + start_time +
  33385. "&stm_enddate=" + end_time +
  33386. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33387. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33388. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  33389. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33390. "&fixmedins_code=" + miConfig.Code +
  33391. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33392. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33393. "&secret_key=" + miConfig.SecretKey +
  33394. "&org_name=" + miConfig.OrgName +
  33395. "&doctor=" + user_name
  33396. resp, requestErr := http.Get(api)
  33397. if requestErr != nil {
  33398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33399. return
  33400. }
  33401. body, ioErr := ioutil.ReadAll(resp.Body)
  33402. if ioErr != nil {
  33403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33405. return
  33406. }
  33407. var respJSON map[string]interface{}
  33408. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33411. return
  33412. }
  33413. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33414. userJSONBytes, _ := json.Marshal(respJSON)
  33415. var res ResultTen
  33416. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33417. utils.ErrorLog("解析失败:%v", err)
  33418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33419. return
  33420. }
  33421. if res.Infcode == 0 {
  33422. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  33423. micc := &models.MedicalInsuranceCostCompare{
  33424. StartTime: startime.Unix(),
  33425. EndTime: endtime.Unix(),
  33426. Insutype: "0",
  33427. CheckType: 2,
  33428. Num: fixmedins_setl_cnt,
  33429. Mtime: time.Now().Unix(),
  33430. Status: 1,
  33431. UserOrgId: adminUser.CurrentOrgId,
  33432. CostTotal: medfee_sumamt,
  33433. FuncTotal: fund_pay_sumamt,
  33434. PsnPay: psn_cash_pay,
  33435. Creator: admin_user_id,
  33436. Ctime: time.Now().Unix(),
  33437. }
  33438. service.CreateMedicalInsuranceCostCompareRecord(micc)
  33439. c.ServeSuccessJSON(map[string]interface{}{
  33440. "msg": "明细对账成功",
  33441. })
  33442. }
  33443. } else {
  33444. }
  33445. }
  33446. }
  33447. type CustomOrderInfo struct {
  33448. Name string
  33449. Spec string
  33450. Unit string
  33451. Count float64
  33452. Price float64
  33453. Total float64
  33454. }
  33455. func (c *HisApiController) GetBatchSettleAccounts() {
  33456. admin_user_id, _ := c.GetInt64("admin_user_id")
  33457. order_ids := c.GetString("order_ids")
  33458. order_ids_arr := strings.Split(order_ids, ",")
  33459. data3 := []map[string]interface{}{}
  33460. for _, item := range order_ids_arr {
  33461. id, _ := strconv.ParseInt(item, 10, 64)
  33462. order_id := id
  33463. adminUser := c.GetAdminUserInfo()
  33464. order, _ := service.GetHisOrderByID(order_id)
  33465. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33466. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  33467. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  33468. orderInfos = append(orderInfos, orderInfos_two...)
  33469. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  33470. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  33471. var diagnosis_ids []string
  33472. if his.ID > 0 {
  33473. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  33474. } else {
  33475. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  33476. }
  33477. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  33478. var dia_config []*models.HisXtDiagnoseConfig
  33479. var name string
  33480. for _, item := range diagnosis_ids {
  33481. id, _ := strconv.ParseInt(item, 10, 64)
  33482. diagnosisConfig, _ := service.FindDiagnoseById(id)
  33483. dia_config = append(dia_config, &diagnosisConfig)
  33484. if len(name) == 0 {
  33485. name = diagnosisConfig.ClassName
  33486. }
  33487. //} else {
  33488. // name = name + "," + diagnosisConfig.ClassName
  33489. //}
  33490. }
  33491. var bedCostTotal float64 = 0 //床位总费
  33492. var bedCostSelfTotal float64 = 0 //床位自费
  33493. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  33494. var bedSelfTotal float64 = 0 //床位部分项目自费
  33495. var bedInscpTotal float64 = 0 //床位部分项目自费
  33496. var operationCostTotal float64 = 0 //手术费
  33497. var operationCostSelfTotal float64 = 0 //手术费
  33498. var operationCostPartSelfTotal float64 = 0 //手术费
  33499. var operationSelfTotal float64 = 0 //床位部分项目自费
  33500. var operationInscpTotal float64 = 0 //床位部分项目自费
  33501. var otherCostTotal float64 = 0 //其他费用
  33502. var otherCostSelfTotal float64 = 0 //其他费用
  33503. var otherCostPartSelfTotal float64 = 0 //其他费用
  33504. var otherSelfTotal float64 = 0 //床位部分项目自费
  33505. var otherInscpTotal float64 = 0 //床位部分项目自费
  33506. var materialCostTotal float64 = 0 //材料费
  33507. var materialCostSelfTotal float64 = 0 //材料费
  33508. var materialCostPartSelfTotal float64 = 0 //材料费
  33509. var materialSelfTotal float64 = 0 //床位部分项目自费
  33510. var materialInscpTotal float64 = 0 //床位部分项目自费
  33511. var westernMedicineCostTotal float64 = 0 //西药费
  33512. var westernMedicineCostSelfTotal float64 = 0 //西药费
  33513. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  33514. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  33515. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  33516. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  33517. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  33518. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  33519. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  33520. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  33521. var checkCostTotal float64 = 0 //检查费
  33522. var checkCostSelfTotal float64 = 0 //检查费
  33523. var checkCostPartSelfTotal float64 = 0 //检查费
  33524. var checkSelfTotal float64 = 0 //床位部分项目自费
  33525. var checkInscpTotal float64 = 0 //床位部分项目自费
  33526. var laboratoryCostTotal float64 = 0 //化验费
  33527. var laboratoryCostSelfTotal float64 = 0 //化验费
  33528. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  33529. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  33530. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  33531. var treatCostTotal float64 = 0 //治疗费用
  33532. var treatCostSelfTotal float64 = 0 //治疗费用
  33533. var treatCostPartSelfTotal float64 = 0 //治疗费用
  33534. var treatSelfTotal float64 = 0 //床位部分项目自费
  33535. var treatInscpTotal float64 = 0 //床位部分项目自费
  33536. decimal.DivisionPrecision = 2
  33537. for _, item := range orderInfos {
  33538. if item.MedChrgitmType == "01" { //床位费
  33539. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33540. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33541. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33542. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33543. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33544. }
  33545. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  33546. if item.MedChrgitmType == "03" { //检查费
  33547. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33548. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33549. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33550. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33551. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33552. }
  33553. } else {
  33554. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  33555. fmt.Println("------------")
  33556. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33557. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33558. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33559. }
  33560. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  33561. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33562. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33563. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33564. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33565. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33566. }
  33567. }
  33568. if item.MedChrgitmType == "04" { //化验费
  33569. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33570. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33571. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33572. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33573. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33574. }
  33575. if item.MedChrgitmType == "05" { //治疗费
  33576. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33577. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33578. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33579. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33580. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33581. }
  33582. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  33583. fmt.Println("------------")
  33584. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33585. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33586. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33587. }
  33588. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  33589. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33590. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33591. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33592. }
  33593. //if item.MedChrgitmType == "06" { //手术费
  33594. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33595. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33596. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33597. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33598. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33599. //
  33600. //}
  33601. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  33602. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33603. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33604. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33605. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33606. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33607. }
  33608. if item.MedChrgitmType == "09" { //西药费
  33609. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33610. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33611. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33612. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33613. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33614. }
  33615. if item.MedChrgitmType == "11" { //中成费
  33616. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33617. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33618. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33619. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33620. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33621. }
  33622. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  33623. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33624. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33625. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33626. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33627. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33628. }
  33629. }
  33630. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33631. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33632. var user_name string
  33633. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33634. if role.ID == 0 {
  33635. user_name = "管理员"
  33636. } else {
  33637. user_name = role.UserName
  33638. }
  33639. baseParams := models.BaseParams{
  33640. SecretKey: miConfig.SecretKey,
  33641. FixmedinsCode: miConfig.Code,
  33642. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33643. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33644. OrgName: miConfig.OrgName,
  33645. Doctor: user_name,
  33646. RequestUrl: miConfig.Url,
  33647. AccessKey: miConfig.AccessKey,
  33648. }
  33649. businessParams := models.BusinessParams{
  33650. PsnNo: order.PsnNo,
  33651. MdtrtId: order.MdtrtId,
  33652. SetlId: order.SetlId,
  33653. }
  33654. var res ResultEleven
  33655. var resEleven10265 ResultEleven10265
  33656. if config.IsOpen == 1 {
  33657. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  33658. result := service.Gdyb5203(baseParams, businessParams)
  33659. service.Gdyb5204(baseParams, businessParams)
  33660. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  33661. var dat map[string]interface{}
  33662. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33663. fmt.Println(dat)
  33664. } else {
  33665. fmt.Println(err)
  33666. }
  33667. userJSONBytes, _ := json.Marshal(dat)
  33668. if miConfig.Code == "H15049901371" {
  33669. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  33670. utils.ErrorLog("解析失败:%v", err)
  33671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33672. return
  33673. }
  33674. res.InfRefmsgid = resEleven10265.InfRefmsgid
  33675. res.Output = resEleven10265.Output
  33676. res.ErrMsg = resEleven10265.ErrMsg
  33677. res.Cainfo = resEleven10265.Cainfo
  33678. res.WarnMsg = resEleven10265.WarnMsg
  33679. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  33680. res.Infcode = infocode
  33681. } else {
  33682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33683. utils.ErrorLog("解析失败:%v", err)
  33684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33685. return
  33686. }
  33687. }
  33688. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33689. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  33690. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  33691. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  33692. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  33693. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33694. var doctor_name string
  33695. if roles.ID == 0 {
  33696. doctor_name = "管理员"
  33697. } else {
  33698. doctor_name = roles.UserName
  33699. }
  33700. yiliao_leibie := ""
  33701. switch order.MedType {
  33702. case "11":
  33703. yiliao_leibie = "普通门诊"
  33704. break
  33705. case "12":
  33706. yiliao_leibie = "门诊挂号"
  33707. break
  33708. case "13":
  33709. yiliao_leibie = "急诊"
  33710. break
  33711. case "14":
  33712. yiliao_leibie = "门诊特殊病"
  33713. break
  33714. case "15":
  33715. yiliao_leibie = "门诊统筹"
  33716. break
  33717. case "16":
  33718. yiliao_leibie = "门诊慢性病"
  33719. break
  33720. case "21":
  33721. yiliao_leibie = "普通住院"
  33722. break
  33723. }
  33724. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  33725. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  33726. if res.Infcode == 0 {
  33727. data2 := map[string]interface{}{
  33728. "diagnosis": name,
  33729. "order_infos": orderInfos,
  33730. "number": order.MdtrtId,
  33731. "date": order.SettleAccountsDate,
  33732. "charge_admin": charge_admin,
  33733. "printor_admin": printor_admin,
  33734. "info": res.Output.Setlinfo,
  33735. "order": order,
  33736. "bedCostTotal": bedCostTotal,
  33737. "bedCostSelfTotal": bedCostSelfTotal,
  33738. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  33739. "bedSelfTotal": bedSelfTotal,
  33740. "bedInscpTotal": bedInscpTotal,
  33741. "operationCostTotal": operationCostTotal,
  33742. "operationCostSelfTotal": operationCostSelfTotal,
  33743. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  33744. "operationSelfTotal": operationSelfTotal,
  33745. "operationInscpTotal": operationInscpTotal,
  33746. "otherCostTotal": otherCostTotal,
  33747. "otherCostSelfTotal": otherCostSelfTotal,
  33748. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  33749. "otherSelfTotal": otherSelfTotal,
  33750. "otherInscpTotal": otherInscpTotal,
  33751. "materialCostTotal": materialCostTotal,
  33752. "materialCostSelfTotal": materialCostSelfTotal,
  33753. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  33754. "materialSelfTotal": materialSelfTotal,
  33755. "materialInscpTotal": materialInscpTotal,
  33756. "westernMedicineCostTotal": westernMedicineCostTotal,
  33757. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  33758. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  33759. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  33760. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  33761. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  33762. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  33763. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  33764. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  33765. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  33766. "checkCostTotal": checkCostTotal,
  33767. "checkCostSelfTotal": checkCostSelfTotal,
  33768. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  33769. "checkSelfTotal": checkSelfTotal,
  33770. "checkInscpTotal": checkInscpTotal,
  33771. "laboratoryCostTotal": laboratoryCostTotal,
  33772. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  33773. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  33774. "laboratorySelfTotal": laboratorySelfTotal,
  33775. "laboratoryInscpTotal": laboratoryInscpTotal,
  33776. "treatCostTotal": treatCostTotal,
  33777. "treatCostSelfTotal": treatCostSelfTotal,
  33778. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  33779. "treatSelfTotal": treatSelfTotal,
  33780. "treatInscpTotal": treatInscpTotal,
  33781. "doctor_info": doctor_info,
  33782. "doctor_code": adminRole_two.DoctorCode,
  33783. "doctor_name": doctor_name,
  33784. "health_card_no": order.PsnNo,
  33785. "department": departments.Name,
  33786. "yiliao_leibie": yiliao_leibie,
  33787. "after_money": order.AccountPrice,
  33788. "patient": patient,
  33789. "org_name": miConfig.OrgName,
  33790. "org_code": miConfig.Code,
  33791. "order_number": order.Number,
  33792. "his_hospital": his_hospital,
  33793. "his": his,
  33794. "dia_config": dia_config,
  33795. "psn_cash_pay": order.PsnCashPay,
  33796. //"check_order_info": cus_slice,
  33797. }
  33798. data3 = append(data3, data2)
  33799. }
  33800. }
  33801. }
  33802. c.ServeSuccessJSON(map[string]interface{}{
  33803. "infos": data3,
  33804. })
  33805. }
  33806. func (c *HisApiController) GetSettleAccounts() {
  33807. //id, _ := c.GetInt64("id")
  33808. //record_time := c.GetString("record_time")
  33809. order_id, _ := c.GetInt64("order_id")
  33810. admin_user_id, _ := c.GetInt64("admin_user_id")
  33811. //timeLayout := "2006-01-02"
  33812. //loc, _ := time.LoadLocation("Local")
  33813. //
  33814. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33815. //if err != nil {
  33816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33817. // return
  33818. //}Hbyb5203
  33819. //recordDateTime := theTime.Unix()
  33820. adminUser := c.GetAdminUserInfo()
  33821. order, _ := service.GetHisOrderByID(order_id)
  33822. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33823. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  33824. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  33825. orderInfos = append(orderInfos, orderInfos_two...)
  33826. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  33827. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  33828. var diagnosis_ids []string
  33829. if his.ID > 0 {
  33830. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  33831. } else {
  33832. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  33833. }
  33834. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  33835. var dia_config []*models.HisXtDiagnoseConfig
  33836. var name string
  33837. for _, item := range diagnosis_ids {
  33838. id, _ := strconv.ParseInt(item, 10, 64)
  33839. diagnosisConfig, _ := service.FindDiagnoseById(id)
  33840. dia_config = append(dia_config, &diagnosisConfig)
  33841. if len(name) == 0 {
  33842. name = diagnosisConfig.ClassName
  33843. } else {
  33844. name = name + "," + diagnosisConfig.ClassName
  33845. }
  33846. }
  33847. if patient.UserOrgId == 10215 {
  33848. name = "慢性肾功能不全(血透治疗)"
  33849. }
  33850. var bedCostTotal float64 = 0 //床位总费
  33851. var bedCostSelfTotal float64 = 0 //床位自费
  33852. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  33853. var bedSelfTotal float64 = 0 //床位部分项目自费
  33854. var bedInscpTotal float64 = 0 //床位部分项目自费
  33855. var operationCostTotal float64 = 0 //手术费
  33856. var operationCostSelfTotal float64 = 0 //手术费
  33857. var operationCostPartSelfTotal float64 = 0 //手术费
  33858. var operationSelfTotal float64 = 0 //床位部分项目自费
  33859. var operationInscpTotal float64 = 0 //床位部分项目自费
  33860. var otherCostTotal float64 = 0 //其他费用
  33861. var otherCostSelfTotal float64 = 0 //其他费用
  33862. var otherCostPartSelfTotal float64 = 0 //其他费用
  33863. var otherSelfTotal float64 = 0 //床位部分项目自费
  33864. var otherInscpTotal float64 = 0 //床位部分项目自费
  33865. var materialCostTotal float64 = 0 //材料费
  33866. var materialCostSelfTotal float64 = 0 //材料费
  33867. var materialCostPartSelfTotal float64 = 0 //材料费
  33868. var materialSelfTotal float64 = 0 //床位部分项目自费
  33869. var materialInscpTotal float64 = 0 //床位部分项目自费
  33870. var westernMedicineCostTotal float64 = 0 //西药费
  33871. var westernMedicineCostSelfTotal float64 = 0 //西药费
  33872. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  33873. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  33874. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  33875. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  33876. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  33877. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  33878. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  33879. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  33880. var checkCostTotal float64 = 0 //检查费
  33881. var checkCostSelfTotal float64 = 0 //检查费
  33882. var checkCostPartSelfTotal float64 = 0 //检查费
  33883. var checkSelfTotal float64 = 0 //床位部分项目自费
  33884. var checkInscpTotal float64 = 0 //床位部分项目自费
  33885. var laboratoryCostTotal float64 = 0 //化验费
  33886. var laboratoryCostSelfTotal float64 = 0 //化验费
  33887. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  33888. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  33889. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  33890. var treatCostTotal float64 = 0 //治疗费用
  33891. var treatCostSelfTotal float64 = 0 //治疗费用
  33892. var treatCostPartSelfTotal float64 = 0 //治疗费用
  33893. var treatSelfTotal float64 = 0 //床位部分项目自费
  33894. var treatInscpTotal float64 = 0 //床位部分项目自费
  33895. var zcCostTotal float64 = 0 //治疗费用
  33896. var zcCostSelfTotal float64 = 0 //治疗费用
  33897. var zcCostPartSelfTotal float64 = 0 //治疗费用
  33898. var zcSelfTotal float64 = 0 //床位部分项目自费
  33899. var zcInscpTotal float64 = 0 //床位部分项目自费
  33900. var huliCostTotal float64 = 0 //治疗费用
  33901. var huliCostSelfTotal float64 = 0 //治疗费用
  33902. var huliCostPartSelfTotal float64 = 0 //治疗费用
  33903. var huliSelfTotal float64 = 0 //床位部分项目自费
  33904. var huliInscpTotal float64 = 0 //床位部分项目自费
  33905. decimal.DivisionPrecision = 2
  33906. for _, item := range orderInfos {
  33907. if item.MedChrgitmType == "01" { //床位费
  33908. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33909. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33910. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33911. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33912. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33913. }
  33914. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  33915. if item.MedChrgitmType == "03" { //检查费
  33916. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33917. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33918. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33919. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33920. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33921. }
  33922. } else {
  33923. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  33924. fmt.Println("------------")
  33925. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33926. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33927. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33928. }
  33929. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  33930. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33931. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33932. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33933. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33934. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33935. }
  33936. }
  33937. if item.MedChrgitmType == "04" { //化验费
  33938. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33939. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33940. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33941. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33942. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33943. }
  33944. if item.MedChrgitmType == "05" { //治疗费
  33945. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33946. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33947. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33948. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33949. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33950. }
  33951. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  33952. fmt.Println("------------")
  33953. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33954. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33955. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33956. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33957. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33958. }
  33959. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  33960. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33961. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33962. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33963. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33964. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33965. }
  33966. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  33967. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33968. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33969. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33970. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33971. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33972. }
  33973. if item.MedChrgitmType == "09" { //西药费
  33974. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33975. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33976. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33977. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33978. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33979. }
  33980. if item.MedChrgitmType == "11" { //中成费
  33981. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33982. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33983. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33984. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33985. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33986. }
  33987. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  33988. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33989. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33990. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33991. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33992. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33993. }
  33994. if item.MedChrgitmType == "02" { //其他费
  33995. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33996. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33997. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33998. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33999. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34000. }
  34001. if item.MedChrgitmType == "07" { //其他费
  34002. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34003. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34004. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34005. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34006. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34007. }
  34008. }
  34009. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34010. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34011. var user_name string
  34012. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34013. if role.ID == 0 {
  34014. user_name = "管理员"
  34015. } else {
  34016. user_name = role.UserName
  34017. }
  34018. baseParams := models.BaseParams{
  34019. SecretKey: miConfig.SecretKey,
  34020. FixmedinsCode: miConfig.Code,
  34021. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34022. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34023. OrgName: miConfig.OrgName,
  34024. Doctor: user_name,
  34025. RequestUrl: miConfig.Url,
  34026. AccessKey: miConfig.AccessKey,
  34027. }
  34028. businessParams := models.BusinessParams{
  34029. PsnNo: order.PsnNo,
  34030. MdtrtId: order.MdtrtId,
  34031. SetlId: order.SetlId,
  34032. }
  34033. var res ResultEleven
  34034. var resah ResultElevenah
  34035. var resEleven10265 ResultEleven10265
  34036. if config.IsOpen == 1 {
  34037. if miConfig.MdtrtareaAdmvs == "421300" {
  34038. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34039. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34040. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34041. resp, requestErr := http.Get(api)
  34042. if requestErr != nil {
  34043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34044. return
  34045. }
  34046. body, ioErr := ioutil.ReadAll(resp.Body)
  34047. if ioErr != nil {
  34048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34050. return
  34051. }
  34052. var respJSON map[string]interface{}
  34053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34056. return
  34057. }
  34058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34059. result, _ := json.Marshal(respJSON)
  34060. fmt.Println("log")
  34061. fmt.Println(string(result))
  34062. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34063. utils.ErrorLog("解析失败:%v", err)
  34064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34065. return
  34066. }
  34067. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34068. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34069. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34070. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34071. resp, requestErr := http.Get(api)
  34072. if requestErr != nil {
  34073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34074. return
  34075. }
  34076. body, ioErr := ioutil.ReadAll(resp.Body)
  34077. if ioErr != nil {
  34078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34080. return
  34081. }
  34082. var respJSON map[string]interface{}
  34083. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34086. return
  34087. }
  34088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34089. result, _ := json.Marshal(respJSON)
  34090. fmt.Println("log")
  34091. fmt.Println(string(result))
  34092. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34093. utils.ErrorLog("解析失败:%v", err)
  34094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34095. return
  34096. }
  34097. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34098. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34099. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34100. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34101. resp, requestErr := http.Get(api)
  34102. if requestErr != nil {
  34103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34104. return
  34105. }
  34106. body, ioErr := ioutil.ReadAll(resp.Body)
  34107. if ioErr != nil {
  34108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34110. return
  34111. }
  34112. var respJSON map[string]interface{}
  34113. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34116. return
  34117. }
  34118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34119. result, _ := json.Marshal(respJSON)
  34120. fmt.Println("log")
  34121. fmt.Println(string(result))
  34122. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34123. utils.ErrorLog("解析失败:%v", err)
  34124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34125. return
  34126. }
  34127. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34128. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34129. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34130. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34131. resp, requestErr := http.Get(api)
  34132. if requestErr != nil {
  34133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34134. return
  34135. }
  34136. body, ioErr := ioutil.ReadAll(resp.Body)
  34137. if ioErr != nil {
  34138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34140. return
  34141. }
  34142. var respJSON map[string]interface{}
  34143. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34146. return
  34147. }
  34148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34149. result, _ := json.Marshal(respJSON)
  34150. fmt.Println("log")
  34151. fmt.Println(string(result))
  34152. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34153. utils.ErrorLog("解析失败:%v", err)
  34154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34155. return
  34156. }
  34157. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34158. var api string
  34159. if miConfig.MdtrtareaAdmvs == "320921" {
  34160. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34161. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34162. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34163. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34164. } else {
  34165. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34166. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34167. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34168. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34169. }
  34170. resp, requestErr := http.Get(api)
  34171. if requestErr != nil {
  34172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34173. return
  34174. }
  34175. body, ioErr := ioutil.ReadAll(resp.Body)
  34176. if ioErr != nil {
  34177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34179. return
  34180. }
  34181. var respJSON map[string]interface{}
  34182. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34185. return
  34186. }
  34187. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34188. result, _ := json.Marshal(respJSON)
  34189. fmt.Println("log")
  34190. fmt.Println(string(result))
  34191. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34192. utils.ErrorLog("解析失败:%v", err)
  34193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34194. return
  34195. }
  34196. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34197. res.Output = resEleven10265.Output
  34198. res.ErrMsg = resEleven10265.ErrMsg
  34199. res.Cainfo = resEleven10265.Cainfo
  34200. res.WarnMsg = resEleven10265.WarnMsg
  34201. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34202. res.Infcode = infocode
  34203. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34204. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34205. saveLog(result, requestLog, "5203", "结算单")
  34206. var dat map[string]interface{}
  34207. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34208. fmt.Println(dat)
  34209. } else {
  34210. fmt.Println(err)
  34211. }
  34212. userJSONBytes, _ := json.Marshal(dat)
  34213. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34214. utils.ErrorLog("解析失败:%v", err)
  34215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34216. return
  34217. }
  34218. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34219. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34220. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  34221. fmt.Println(result3)
  34222. fmt.Println(requestLog3)
  34223. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  34224. fmt.Println(result2)
  34225. fmt.Println(requestLog2)
  34226. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34227. saveLog(result, requestLog, "5203", "结算单")
  34228. var dat map[string]interface{}
  34229. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34230. fmt.Println(dat)
  34231. } else {
  34232. fmt.Println(err)
  34233. }
  34234. userJSONBytes, _ := json.Marshal(dat)
  34235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34236. utils.ErrorLog("解析失败:%v", err)
  34237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34238. return
  34239. }
  34240. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34241. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34242. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  34243. fmt.Println(result3)
  34244. fmt.Println(requestLog3)
  34245. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  34246. fmt.Println(result2)
  34247. fmt.Println(requestLog2)
  34248. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34249. saveLog(result, requestLog, "5203", "结算单")
  34250. var dat map[string]interface{}
  34251. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34252. fmt.Println(dat)
  34253. } else {
  34254. fmt.Println(err)
  34255. }
  34256. userJSONBytes, _ := json.Marshal(dat)
  34257. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34258. utils.ErrorLog("解析失败:%v", err)
  34259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34260. return
  34261. }
  34262. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34263. var api string
  34264. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34265. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34266. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34267. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34268. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34269. resp, requestErr := http.Get(api)
  34270. if requestErr != nil {
  34271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34272. return
  34273. }
  34274. body, ioErr := ioutil.ReadAll(resp.Body)
  34275. if ioErr != nil {
  34276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34278. return
  34279. }
  34280. var respJSON map[string]interface{}
  34281. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34284. return
  34285. }
  34286. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34287. if status == "0" {
  34288. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34289. c.ServeSuccessJSON(map[string]interface{}{
  34290. "failed_code": -10,
  34291. "msg": err_msg,
  34292. })
  34293. return
  34294. }
  34295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34296. result, _ := json.Marshal(respJSON)
  34297. fmt.Println("log")
  34298. fmt.Println(string(result))
  34299. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34300. utils.ErrorLog("解析失败:%v", err)
  34301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34302. return
  34303. }
  34304. res.InfRefmsgid = resah.InfRefmsgid
  34305. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34306. // 创建对应的Time类型
  34307. t := time.UnixMilli(timestamp)
  34308. // 格式化成指定的日期字符串
  34309. str := t.Format("2006-01-02 15:04:05")
  34310. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34311. // 创建对应的Time类型
  34312. t3 := time.UnixMilli(timestamp2)
  34313. // 格式化成指定的日期字符串
  34314. str2 := t3.Format("2006-01-02 15:04:05")
  34315. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34316. // 创建对应的Time类型
  34317. t4 := time.UnixMilli(timestamp3)
  34318. // 格式化成指定的日期字符串
  34319. str3 := t4.Format("2006-01-02 15:04:05")
  34320. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34321. // 创建对应的Time类型
  34322. t5 := time.UnixMilli(timestamp4)
  34323. // 格式化成指定的日期字符串
  34324. str5 := t5.Format("2006-01-02 15:04:05")
  34325. res.Output.Setlinfo.Brdy = str2
  34326. res.Output.Setlinfo.SetlTime = str
  34327. res.Output.Setlinfo.Begndate = str3
  34328. res.Output.Setlinfo.Enddate = str5
  34329. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34330. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34331. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34332. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34333. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34334. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34335. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34336. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34337. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34338. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34339. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34340. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34341. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34342. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34343. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34344. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34345. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34346. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34347. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34348. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34349. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34350. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34351. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34352. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34353. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34354. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34355. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34356. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34357. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34358. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34359. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34360. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34361. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34362. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34363. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34364. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34365. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34366. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34367. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34368. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34369. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34370. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34371. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34372. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34373. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34374. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34375. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34376. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34377. //res.Output.Setldetail = resah.Output.Setldetail
  34378. res.ErrMsg = resah.ErrMsg
  34379. res.Cainfo = resah.Cainfo
  34380. res.WarnMsg = resah.WarnMsg
  34381. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34382. var api string
  34383. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34384. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34385. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34386. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34387. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34388. resp, requestErr := http.Get(api)
  34389. if requestErr != nil {
  34390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34391. return
  34392. }
  34393. body, ioErr := ioutil.ReadAll(resp.Body)
  34394. if ioErr != nil {
  34395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34397. return
  34398. }
  34399. var respJSON map[string]interface{}
  34400. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34403. return
  34404. }
  34405. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34406. if status == "0" {
  34407. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34408. c.ServeSuccessJSON(map[string]interface{}{
  34409. "failed_code": -10,
  34410. "msg": err_msg,
  34411. })
  34412. return
  34413. }
  34414. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34415. result, _ := json.Marshal(respJSON)
  34416. fmt.Println("log")
  34417. fmt.Println(string(result))
  34418. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34419. utils.ErrorLog("解析失败:%v", err)
  34420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34421. return
  34422. }
  34423. res.InfRefmsgid = resah.InfRefmsgid
  34424. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34425. // 创建对应的Time类型
  34426. t := time.UnixMilli(timestamp)
  34427. // 格式化成指定的日期字符串
  34428. str := t.Format("2006-01-02 15:04:05")
  34429. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34430. // 创建对应的Time类型
  34431. t3 := time.UnixMilli(timestamp2)
  34432. // 格式化成指定的日期字符串
  34433. str2 := t3.Format("2006-01-02 15:04:05")
  34434. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34435. // 创建对应的Time类型
  34436. t4 := time.UnixMilli(timestamp3)
  34437. // 格式化成指定的日期字符串
  34438. str3 := t4.Format("2006-01-02 15:04:05")
  34439. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34440. // 创建对应的Time类型
  34441. t5 := time.UnixMilli(timestamp4)
  34442. // 格式化成指定的日期字符串
  34443. str5 := t5.Format("2006-01-02 15:04:05")
  34444. res.Output.Setlinfo.Brdy = str2
  34445. res.Output.Setlinfo.SetlTime = str
  34446. res.Output.Setlinfo.Begndate = str3
  34447. res.Output.Setlinfo.Enddate = str5
  34448. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34449. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34450. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34451. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34452. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34453. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34454. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34455. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34456. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34457. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34458. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34459. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34460. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34461. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34462. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34463. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34464. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34465. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34466. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34467. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34468. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34469. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34470. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34471. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34472. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34473. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34474. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34475. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34476. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34477. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34478. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34479. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34480. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34481. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34482. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34483. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34484. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34485. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34486. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34487. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34488. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34489. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34490. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34491. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34492. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34493. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34494. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34495. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34496. //res.Output.Setldetail = resah.Output.Setldetail
  34497. res.ErrMsg = resah.ErrMsg
  34498. res.Cainfo = resah.Cainfo
  34499. res.WarnMsg = resah.WarnMsg
  34500. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34501. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  34502. saveLog(result, requestLog, "5203", "结算单")
  34503. var dat map[string]interface{}
  34504. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34505. fmt.Println(dat)
  34506. } else {
  34507. fmt.Println(err)
  34508. }
  34509. userJSONBytes, _ := json.Marshal(dat)
  34510. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34511. utils.ErrorLog("解析失败:%v", err)
  34512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34513. return
  34514. }
  34515. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34516. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34517. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34518. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34519. resp, requestErr := http.Get(api)
  34520. if requestErr != nil {
  34521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34522. return
  34523. }
  34524. body, ioErr := ioutil.ReadAll(resp.Body)
  34525. if ioErr != nil {
  34526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34528. return
  34529. }
  34530. var respJSON map[string]interface{}
  34531. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34534. return
  34535. }
  34536. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34537. result, _ := json.Marshal(respJSON)
  34538. fmt.Println("log")
  34539. fmt.Println(string(result))
  34540. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34541. utils.ErrorLog("解析失败:%v", err)
  34542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34543. return
  34544. }
  34545. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34546. res.Output = resEleven10265.Output
  34547. res.ErrMsg = resEleven10265.ErrMsg
  34548. res.Cainfo = resEleven10265.Cainfo
  34549. res.WarnMsg = resEleven10265.WarnMsg
  34550. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34551. res.Infcode = infocode
  34552. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34553. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34554. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34555. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34556. resp, requestErr := http.Get(api)
  34557. if requestErr != nil {
  34558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34559. return
  34560. }
  34561. body, ioErr := ioutil.ReadAll(resp.Body)
  34562. if ioErr != nil {
  34563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34565. return
  34566. }
  34567. var respJSON map[string]interface{}
  34568. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34571. return
  34572. }
  34573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34574. result, _ := json.Marshal(respJSON)
  34575. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34576. utils.ErrorLog("解析失败:%v", err)
  34577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34578. return
  34579. }
  34580. } else if miConfig.MdtrtareaAdmvs == "450721" {
  34581. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  34582. //return
  34583. } else {
  34584. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34585. if len(his.InsuplcAdmdvs) == 0 {
  34586. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34587. } else {
  34588. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34589. }
  34590. result := service.Gdyb5203(baseParams, businessParams)
  34591. //service.Gdyb5204(baseParams, businessParams)
  34592. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34593. var dat map[string]interface{}
  34594. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34595. fmt.Println(dat)
  34596. } else {
  34597. fmt.Println(err)
  34598. }
  34599. userJSONBytes, _ := json.Marshal(dat)
  34600. if miConfig.Code == "H15049901371" {
  34601. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34602. utils.ErrorLog("解析失败:%v", err)
  34603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34604. return
  34605. }
  34606. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34607. res.Output = resEleven10265.Output
  34608. res.ErrMsg = resEleven10265.ErrMsg
  34609. res.Cainfo = resEleven10265.Cainfo
  34610. res.WarnMsg = resEleven10265.WarnMsg
  34611. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34612. res.Infcode = infocode
  34613. } else {
  34614. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34615. utils.ErrorLog("解析失败:%v", err)
  34616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34617. return
  34618. }
  34619. }
  34620. }
  34621. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34622. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34623. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34624. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34625. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34626. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34627. var doctor_name string
  34628. if roles.ID == 0 {
  34629. doctor_name = "管理员"
  34630. } else {
  34631. doctor_name = roles.UserName
  34632. }
  34633. yiliao_leibie := ""
  34634. switch order.MedType {
  34635. case "11":
  34636. yiliao_leibie = "普通门诊"
  34637. break
  34638. case "12":
  34639. yiliao_leibie = "门诊挂号"
  34640. break
  34641. case "13":
  34642. yiliao_leibie = "急诊"
  34643. break
  34644. case "14":
  34645. yiliao_leibie = "门诊特殊病"
  34646. break
  34647. case "15":
  34648. yiliao_leibie = "门诊统筹"
  34649. break
  34650. case "16":
  34651. yiliao_leibie = "门诊慢性病"
  34652. break
  34653. case "21":
  34654. yiliao_leibie = "普通住院"
  34655. break
  34656. }
  34657. //var rf []CustomFundPay
  34658. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  34659. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34660. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  34661. if res.Infcode == 0 {
  34662. 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 {
  34663. c.ServeSuccessJSON(map[string]interface{}{
  34664. "diagnosis": name,
  34665. "order_infos": orderInfos,
  34666. "number": order.MdtrtId,
  34667. "date": order.SettleAccountsDate,
  34668. "charge_admin": charge_admin,
  34669. "printor_admin": printor_admin,
  34670. "info": res.Output.Setlinfo,
  34671. "order": order,
  34672. "bedCostTotal": bedCostTotal,
  34673. "bedCostSelfTotal": bedCostSelfTotal,
  34674. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34675. "bedSelfTotal": bedSelfTotal,
  34676. "bedInscpTotal": bedInscpTotal,
  34677. "operationCostTotal": operationCostTotal,
  34678. "operationCostSelfTotal": operationCostSelfTotal,
  34679. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34680. "operationSelfTotal": operationSelfTotal,
  34681. "operationInscpTotal": operationInscpTotal,
  34682. "otherCostTotal": otherCostTotal,
  34683. "otherCostSelfTotal": otherCostSelfTotal,
  34684. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34685. "otherSelfTotal": otherSelfTotal,
  34686. "otherInscpTotal": otherInscpTotal,
  34687. "materialCostTotal": materialCostTotal,
  34688. "materialCostSelfTotal": materialCostSelfTotal,
  34689. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34690. "materialSelfTotal": materialSelfTotal,
  34691. "materialInscpTotal": materialInscpTotal,
  34692. "westernMedicineCostTotal": westernMedicineCostTotal,
  34693. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34694. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34695. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34696. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34697. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34698. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34699. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34700. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34701. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34702. "checkCostTotal": checkCostTotal,
  34703. "checkCostSelfTotal": checkCostSelfTotal,
  34704. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34705. "checkSelfTotal": checkSelfTotal,
  34706. "checkInscpTotal": checkInscpTotal,
  34707. "laboratoryCostTotal": laboratoryCostTotal,
  34708. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34709. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34710. "laboratorySelfTotal": laboratorySelfTotal,
  34711. "laboratoryInscpTotal": laboratoryInscpTotal,
  34712. "treatCostTotal": treatCostTotal,
  34713. "treatCostSelfTotal": treatCostSelfTotal,
  34714. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34715. "treatSelfTotal": treatSelfTotal,
  34716. "treatInscpTotal": treatInscpTotal,
  34717. "doctor_info": doctor_info,
  34718. "doctor_code": adminRole_two.DoctorCode,
  34719. "doctor_name": doctor_name,
  34720. "health_card_no": order.PsnNo,
  34721. "department": departments.Name,
  34722. "yiliao_leibie": yiliao_leibie,
  34723. "after_money": order.AccountPrice,
  34724. "patient": patient,
  34725. "org_name": miConfig.OrgName,
  34726. "org_code": miConfig.Code,
  34727. "order_number": order.Number,
  34728. "his_hospital": his_hospital,
  34729. "his": his,
  34730. "dia_config": dia_config,
  34731. "psn_cash_pay": order.PsnCashPay,
  34732. "zcCostTotal": zcCostTotal,
  34733. "zcCostSelfTotal": zcCostSelfTotal,
  34734. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  34735. "zcSelfTotal": zcSelfTotal,
  34736. "zcInscpTotal": zcInscpTotal,
  34737. "huliCostTotal": huliCostTotal,
  34738. "huliCostSelfTotal": huliCostSelfTotal,
  34739. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  34740. "huliSelfTotal": huliSelfTotal,
  34741. "huliInscpTotal": huliInscpTotal,
  34742. //"funds": rf,
  34743. //"check_order_info": cus_slice,
  34744. })
  34745. } else {
  34746. c.ServeSuccessJSON(map[string]interface{}{
  34747. "diagnosis": name,
  34748. "order_infos": orderInfos,
  34749. "number": order.MdtrtId,
  34750. "date": order.SettleAccountsDate,
  34751. "charge_admin": charge_admin,
  34752. "printor_admin": printor_admin,
  34753. "info": order,
  34754. "order": order,
  34755. "bedCostTotal": bedCostTotal,
  34756. "bedCostSelfTotal": bedCostSelfTotal,
  34757. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34758. "bedSelfTotal": bedSelfTotal,
  34759. "bedInscpTotal": bedInscpTotal,
  34760. "operationCostTotal": operationCostTotal,
  34761. "operationCostSelfTotal": operationCostSelfTotal,
  34762. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34763. "operationSelfTotal": operationSelfTotal,
  34764. "operationInscpTotal": operationInscpTotal,
  34765. "otherCostTotal": otherCostTotal,
  34766. "otherCostSelfTotal": otherCostSelfTotal,
  34767. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34768. "otherSelfTotal": otherSelfTotal,
  34769. "otherInscpTotal": otherInscpTotal,
  34770. "materialCostTotal": materialCostTotal,
  34771. "materialCostSelfTotal": materialCostSelfTotal,
  34772. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34773. "materialSelfTotal": materialSelfTotal,
  34774. "materialInscpTotal": materialInscpTotal,
  34775. "westernMedicineCostTotal": westernMedicineCostTotal,
  34776. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34777. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34778. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34779. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34780. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34781. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34782. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34783. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34784. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34785. "checkCostTotal": checkCostTotal,
  34786. "checkCostSelfTotal": checkCostSelfTotal,
  34787. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34788. "checkSelfTotal": checkSelfTotal,
  34789. "checkInscpTotal": checkInscpTotal,
  34790. "laboratoryCostTotal": laboratoryCostTotal,
  34791. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34792. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34793. "laboratorySelfTotal": laboratorySelfTotal,
  34794. "laboratoryInscpTotal": laboratoryInscpTotal,
  34795. "treatCostTotal": treatCostTotal,
  34796. "treatCostSelfTotal": treatCostSelfTotal,
  34797. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34798. "treatSelfTotal": treatSelfTotal,
  34799. "treatInscpTotal": treatInscpTotal,
  34800. "doctor_info": doctor_info,
  34801. "doctor_code": adminRole_two.DoctorCode,
  34802. "doctor_name": doctor_name,
  34803. "health_card_no": order.PsnNo,
  34804. "department": departments.Name,
  34805. "yiliao_leibie": yiliao_leibie,
  34806. "after_money": order.AccountPrice,
  34807. "patient": patient,
  34808. "org_name": miConfig.OrgName,
  34809. "org_code": miConfig.Code,
  34810. "order_number": order.Number,
  34811. "his_hospital": his_hospital,
  34812. "his": his,
  34813. "dia_config": dia_config,
  34814. "psn_cash_pay": order.PsnCashPay,
  34815. "zcCostTotal": zcCostTotal,
  34816. "zcCostSelfTotal": zcCostSelfTotal,
  34817. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  34818. "zcSelfTotal": zcSelfTotal,
  34819. "zcInscpTotal": zcInscpTotal,
  34820. "huliCostTotal": huliCostTotal,
  34821. "huliCostSelfTotal": huliCostSelfTotal,
  34822. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  34823. "huliSelfTotal": huliSelfTotal,
  34824. "huliInscpTotal": huliInscpTotal,
  34825. //"funds": rf,
  34826. //"check_order_info": cus_slice,
  34827. })
  34828. }
  34829. }
  34830. }
  34831. }
  34832. //func (c *HisApiController) CheckTreatment() {
  34833. // patient_id, _ := c.GetInt64("patient_id")
  34834. // id_card_no := c.GetString("id_card_no")
  34835. // insutype := c.GetString("insutype")
  34836. // med_type := c.GetString("med_type")
  34837. // admin_user_id, _ := c.GetInt64("admin_user_id")
  34838. //
  34839. // adminUser := c.GetAdminUserInfo()
  34840. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  34841. //
  34842. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34843. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34844. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34845. //
  34846. // if miConfig.MdtrtareaAdmvs == "421300" {
  34847. // var res ResultTwo
  34848. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  34849. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  34850. // "&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)
  34851. // resp, requestErr := http.Get(api)
  34852. // if requestErr != nil {
  34853. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34854. // return
  34855. // }
  34856. //
  34857. // body, ioErr := ioutil.ReadAll(resp.Body)
  34858. // if ioErr != nil {
  34859. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34860. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34861. // return
  34862. // }
  34863. // var respJSON map[string]interface{}
  34864. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34865. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34867. // return
  34868. // }
  34869. //
  34870. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34871. // result, _ := json.Marshal(respJSON)
  34872. //
  34873. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  34874. // utils.ErrorLog("解析失败:%v", err)
  34875. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34876. // return
  34877. // }
  34878. //
  34879. // if res.Infcode == 0 {
  34880. //
  34881. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  34882. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  34883. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  34884. // resp, requestErr := http.Get(api)
  34885. // if requestErr != nil {
  34886. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34887. // return
  34888. // }
  34889. //
  34890. // body, ioErr := ioutil.ReadAll(resp.Body)
  34891. // if ioErr != nil {
  34892. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34894. // return
  34895. // }
  34896. // var respJSON map[string]interface{}
  34897. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34898. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34900. // return
  34901. // }
  34902. // var res Result2001
  34903. //
  34904. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34905. // result2, _ := json.Marshal(respJSON)
  34906. //
  34907. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  34908. // utils.ErrorLog("解析失败:%v", err)
  34909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34910. // return
  34911. // }
  34912. //
  34913. // if res.Infcode == 0 {
  34914. // c.ServeSuccessJSON(map[string]interface{}{
  34915. // "msg": res.Output.Trtinfo,
  34916. // })
  34917. // }
  34918. //
  34919. // } else {
  34920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34921. // return
  34922. // }
  34923. //
  34924. // } else {
  34925. //
  34926. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  34927. // var dat map[string]interface{}
  34928. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34929. // fmt.Println(dat)
  34930. // } else {
  34931. // fmt.Println(err)
  34932. // }
  34933. // userJSONBytes, _ := json.Marshal(dat)
  34934. // var res ResultTwo
  34935. // var res10265 ResultTwo10265
  34936. // if miConfig.Code == "H15049901371" {
  34937. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  34938. // utils.ErrorLog("解析失败:%v", err)
  34939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34940. // return
  34941. // }
  34942. // res.ErrMsg = res10265.ErrMsg
  34943. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34944. // res.Infcode = infocode
  34945. // res.Output = res10265.Output
  34946. // res.InfRefmsgid = res10265.InfRefmsgid
  34947. // } else {
  34948. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34949. // utils.ErrorLog("解析失败:%v", err)
  34950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34951. // return
  34952. // }
  34953. // }
  34954. //
  34955. // var user_name string
  34956. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  34957. // if role.ID == 0 {
  34958. // user_name = "xxx"
  34959. // } else {
  34960. // user_name = role.UserName
  34961. // }
  34962. //
  34963. // baseParams := models.BaseParams{
  34964. // SecretKey: miConfig.SecretKey,
  34965. // FixmedinsCode: miConfig.Code,
  34966. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34967. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34968. // OrgName: miConfig.OrgName,
  34969. // Doctor: user_name,
  34970. // }
  34971. //
  34972. // if config.IsOpen == 1 {
  34973. // if miConfig.Code == "H15049901371" {
  34974. // if med_type == "14" {
  34975. // if insutype == "390" {
  34976. // med_type = "9933"
  34977. // } else if insutype == "310" {
  34978. // med_type = "990502"
  34979. // }
  34980. // } else if med_type == "11" {
  34981. // med_type = "11"
  34982. // }
  34983. // }
  34984. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  34985. // var dat map[string]interface{}
  34986. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34987. // fmt.Println(dat)
  34988. // } else {
  34989. // fmt.Println(err)
  34990. // }
  34991. // var res Result2001
  34992. // var res10265 Result2001Org10265
  34993. // if miConfig.Code == "H15049901371" {
  34994. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34995. // utils.ErrorLog("解析失败:%v", err)
  34996. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34997. // return
  34998. // }
  34999. // res.ErrMsg = res10265.ErrMsg
  35000. // res.Output = res10265.Output
  35001. // res.InfRefmsgid = res10265.InfRefmsgid
  35002. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35003. // res.Infcode = infocode
  35004. // } else {
  35005. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35006. // utils.ErrorLog("解析失败:%v", err)
  35007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35008. // return
  35009. // }
  35010. // }
  35011. // if res.Infcode == 0 {
  35012. // c.ServeSuccessJSON(map[string]interface{}{
  35013. // "msg": res.Output.Trtinfo,
  35014. // })
  35015. // }
  35016. // }
  35017. // }
  35018. //}
  35019. //func (c *HisApiController) PutRecord() {
  35020. // id, _ := c.GetInt64("id")
  35021. // record_time := c.GetString("record_time")
  35022. // timeLayout := "2006-01-02"
  35023. // loc, _ := time.LoadLocation("Local")
  35024. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35025. // if err != nil {
  35026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35027. // return
  35028. // }
  35029. // recordDateTime := theTime.Unix()
  35030. //
  35031. // adminInfo := c.GetAdminUserInfo()
  35032. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35033. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35034. //
  35035. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35036. //
  35037. // fmt.Println(miConfig.SecretKey)
  35038. //
  35039. // if patient == nil {
  35040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35041. // return
  35042. // }
  35043. // if len(patient.IdCardNo) == 0 {
  35044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35045. // return
  35046. // }
  35047. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35048. // if config.IsOpen == 1 {
  35049. // 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
  35050. // resp, requestErr := http.Get(api)
  35051. // if requestErr != nil {
  35052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35053. // return
  35054. // }
  35055. // defer resp.Body.Close()
  35056. // body, ioErr := ioutil.ReadAll(resp.Body)
  35057. // if ioErr != nil {
  35058. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35060. // return
  35061. // }
  35062. // var respJSON map[string]interface{}
  35063. //
  35064. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35065. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35067. // return
  35068. // }
  35069. //
  35070. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35071. // userJSONBytes, _ := json.Marshal(userJSON)
  35072. // var res ResultTwo
  35073. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35074. // utils.ErrorLog("解析失败:%v", err)
  35075. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35076. // return
  35077. // }
  35078. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35079. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35080. // infoStr := string(Iinfos)
  35081. // idetinfoStr := string(Idetinfos)
  35082. //
  35083. // if res.Infcode == 0 {
  35084. // his := models.VMHisPatient{
  35085. // Status: 1,
  35086. // Ctime: time.Now().Unix(),
  35087. // Mtime: time.Now().Unix(),
  35088. // PsnNo: res.Output.Baseinfo.PsnNo,
  35089. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35090. // Certno: res.Output.Baseinfo.Certno,
  35091. // PsnName: res.Output.Baseinfo.PsnName,
  35092. // Gend: res.Output.Baseinfo.Gend,
  35093. // Naty: res.Output.Baseinfo.Naty,
  35094. // Brdy: res.Output.Baseinfo.Brdy,
  35095. // Age: res.Output.Baseinfo.Age,
  35096. // Iinfo: infoStr,
  35097. // Idetinfo: idetinfoStr,
  35098. // PatientId: patient.ID,
  35099. // RecordDate: theTime.Unix(),
  35100. // UserOrgId: adminInfo.CurrentOrgId,
  35101. // AdminUserId: adminInfo.AdminUser.Id,
  35102. // IsReturn: 1,
  35103. // }
  35104. //
  35105. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35106. // //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")
  35107. // //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")
  35108. //
  35109. // //var dat map[string]interface{}
  35110. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35111. // // fmt.Println(dat)
  35112. // //} else {
  35113. // // fmt.Println(err)
  35114. // //}
  35115. //
  35116. // var dat2 map[string]interface{}
  35117. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35118. // fmt.Println(dat2)
  35119. // } else {
  35120. // fmt.Println(err)
  35121. // }
  35122. //
  35123. // } else {
  35124. // adminUser := c.GetAdminUserInfo()
  35125. // errlog := &models.HisOrderError{
  35126. // UserOrgId: adminUser.CurrentOrgId,
  35127. // Ctime: time.Now().Unix(),
  35128. // Mtime: time.Now().Unix(),
  35129. // ErrMsg: res.ErrMsg,
  35130. // Status: 1,
  35131. // PatientId: id,
  35132. // RecordTime: recordDateTime,
  35133. // Stage: 1,
  35134. // }
  35135. // service.CreateErrMsgLog(errlog)
  35136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35137. // return
  35138. // }
  35139. // }
  35140. //
  35141. //}
  35142. //func (c *HisApiController) GetUploadDiag() {
  35143. // id, _ := c.GetInt64("id")
  35144. // record_time := c.GetString("record_time")
  35145. //
  35146. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35147. // sick_type, _ := c.GetInt64("sick_type")
  35148. // reg_type, _ := c.GetInt64("reg_type")
  35149. //
  35150. // timeLayout := "2006-01-02"
  35151. // loc, _ := time.LoadLocation("Local")
  35152. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35153. // if err != nil {
  35154. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35155. // return
  35156. // }
  35157. //
  35158. // var patientPrescription models.HisPrescriptionInfo
  35159. // recordDateTime := theTime.Unix()
  35160. // adminInfo := c.GetAdminUserInfo()
  35161. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35162. //
  35163. // if patientPrescription.ID == 0 {
  35164. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35165. // }
  35166. //
  35167. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35168. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35169. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35170. // sickConfig, _ := service.FindSickById(sick_type)
  35171. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35172. //
  35173. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35174. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35175. // "&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 +
  35176. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35177. // resp2, requestErr2 := http.Get(api2)
  35178. // if requestErr2 != nil {
  35179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35180. // return
  35181. // }
  35182. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35183. // if ioErr2 != nil {
  35184. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35185. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35186. // return
  35187. // }
  35188. // var respJSON2 map[string]interface{}
  35189. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35190. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35192. // return
  35193. // }
  35194. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35195. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35196. //
  35197. // var res2 ResultSix
  35198. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35199. // utils.ErrorLog("解析失败:%v", err)
  35200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35201. // return
  35202. // }
  35203. // if res2.Infcode != 0 {
  35204. // adminUser := c.GetAdminUserInfo()
  35205. // errlog := &models.HisOrderError{
  35206. // UserOrgId: adminUser.CurrentOrgId,
  35207. // Ctime: time.Now().Unix(),
  35208. // Mtime: time.Now().Unix(),
  35209. // ErrMsg: res2.ErrMsg,
  35210. // Status: 1,
  35211. // PatientId: id,
  35212. // RecordTime: recordDateTime,
  35213. // Stage: 3,
  35214. // }
  35215. // service.CreateErrMsgLog(errlog)
  35216. //
  35217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35218. // return
  35219. // }
  35220. //
  35221. // c.ServeSuccessJSON(map[string]interface{}{
  35222. // "msg": "上传成功",
  35223. // })
  35224. //
  35225. //}
  35226. type QueryResult struct {
  35227. ID int64
  35228. Name string
  35229. Code string
  35230. List_type_code string
  35231. }
  35232. func (c *HisApiController) GetCheckCode() {
  35233. ids_str := c.GetString("ids")
  35234. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35235. ids_arr := strings.Split(ids_str, ",")
  35236. var queryResult []QueryResult
  35237. ids := make([]int64, 0)
  35238. for _, item := range ids_arr {
  35239. id, _ := strconv.ParseInt(item, 10, 64)
  35240. ids = append(ids, id)
  35241. }
  35242. if record_type == 1 {
  35243. drugs, _ := service.GetBatchDrugList(ids)
  35244. for _, item := range drugs {
  35245. result := QueryResult{
  35246. ID: item.ID,
  35247. Name: item.DrugName,
  35248. Code: item.MedicalInsuranceNumber,
  35249. List_type_code: "101",
  35250. }
  35251. queryResult = append(queryResult, result)
  35252. }
  35253. } else if record_type == 2 {
  35254. goods, _ := service.GetBatchGoodInformationList(ids)
  35255. fmt.Println(goods)
  35256. for _, item := range goods {
  35257. result := QueryResult{
  35258. ID: item.ID,
  35259. Name: item.GoodName,
  35260. Code: item.SocialSecurityDirectoryCode,
  35261. List_type_code: "301",
  35262. }
  35263. queryResult = append(queryResult, result)
  35264. }
  35265. } else if record_type == 3 {
  35266. projects, _ := service.GetBathchMyPorjecgList(ids)
  35267. for _, item := range projects {
  35268. result := QueryResult{
  35269. ID: item.ID,
  35270. Name: item.ProjectName,
  35271. Code: item.MedicalCode,
  35272. List_type_code: "201",
  35273. }
  35274. queryResult = append(queryResult, result)
  35275. }
  35276. }
  35277. admin_user_id, _ := c.GetInt64("admin_user_id")
  35278. adminUser := c.GetAdminUserInfo()
  35279. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35280. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35281. var user_name string
  35282. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35283. if role.ID == 0 {
  35284. user_name = "管理员"
  35285. } else {
  35286. user_name = role.UserName
  35287. }
  35288. baseParams := models.BaseParams{
  35289. SecretKey: miConfig.SecretKey,
  35290. FixmedinsCode: miConfig.Code,
  35291. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35292. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35293. OrgName: miConfig.OrgName,
  35294. Doctor: user_name,
  35295. }
  35296. var result string
  35297. if miConfig.MdtrtareaAdmvs == "430800" {
  35298. for _, item := range queryResult {
  35299. if record_type == 1 {
  35300. 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)
  35301. } else if record_type == 2 {
  35302. fmt.Println(item.Code)
  35303. 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)
  35304. } else if record_type == 3 {
  35305. 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)
  35306. }
  35307. var dat map[string]interface{}
  35308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35309. fmt.Println(dat)
  35310. } else {
  35311. fmt.Println(err)
  35312. }
  35313. userJSONBytes, _ := json.Marshal(dat)
  35314. var res ResultSix
  35315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35316. utils.ErrorLog("解析失败:%v", err)
  35317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35318. return
  35319. }
  35320. if res.Infcode == 0 {
  35321. if record_type == 1 {
  35322. service.UpdateBaseDrugById(item.ID)
  35323. } else if record_type == 2 {
  35324. service.UpdateGoodInformaitonByDetail(item.ID)
  35325. } else if record_type == 3 {
  35326. service.UpdateProjectById(item.ID)
  35327. }
  35328. c.ServeSuccessJSON(map[string]interface{}{
  35329. "failed_code": 0,
  35330. "msg": "目录对照成功",
  35331. })
  35332. } else {
  35333. c.ServeSuccessJSON(map[string]interface{}{
  35334. "failed_code": -10,
  35335. "msg": res.ErrMsg,
  35336. })
  35337. }
  35338. }
  35339. } else {
  35340. for _, item := range queryResult {
  35341. var result string
  35342. if record_type == 1 {
  35343. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35344. } else if record_type == 2 {
  35345. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35346. } else if record_type == 3 {
  35347. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35348. }
  35349. var dat map[string]interface{}
  35350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35351. fmt.Println(dat)
  35352. } else {
  35353. fmt.Println(err)
  35354. }
  35355. userJSONBytes, _ := json.Marshal(dat)
  35356. var res ResultSix
  35357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35358. utils.ErrorLog("解析失败:%v", err)
  35359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35360. return
  35361. }
  35362. if res.Infcode == 0 {
  35363. if record_type == 1 {
  35364. service.UpdateBaseDrugById(item.ID)
  35365. } else if record_type == 2 {
  35366. service.UpdateGoodInformaitonByDetail(item.ID)
  35367. } else if record_type == 3 {
  35368. service.UpdateProjectById(item.ID)
  35369. }
  35370. c.ServeSuccessJSON(map[string]interface{}{
  35371. "failed_code": 0,
  35372. "msg": "目录对照成功",
  35373. })
  35374. } else {
  35375. c.ServeSuccessJSON(map[string]interface{}{
  35376. "failed_code": -10,
  35377. "msg": res.ErrMsg,
  35378. })
  35379. }
  35380. }
  35381. }
  35382. }
  35383. func (c *HisApiController) UnCheckCode() {
  35384. ids_str := c.GetString("ids")
  35385. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35386. admin_user_id, _ := c.GetInt64("admin_user_id")
  35387. ids_arr := strings.Split(ids_str, ",")
  35388. var queryResult []QueryResult
  35389. ids := make([]int64, 0)
  35390. for _, item := range ids_arr {
  35391. id, _ := strconv.ParseInt(item, 10, 64)
  35392. ids = append(ids, id)
  35393. }
  35394. if record_type == 1 {
  35395. drugs, _ := service.GetBatchDrugList(ids)
  35396. for _, item := range drugs {
  35397. result := QueryResult{
  35398. ID: item.ID,
  35399. Name: item.DrugName,
  35400. Code: item.MedicalInsuranceNumber,
  35401. List_type_code: "101",
  35402. }
  35403. queryResult = append(queryResult, result)
  35404. }
  35405. } else if record_type == 2 {
  35406. goods, _ := service.GetBatchGoodInformationList(ids)
  35407. for _, item := range goods {
  35408. result := QueryResult{
  35409. ID: item.ID,
  35410. Name: item.GoodName,
  35411. Code: item.SocialSecurityDirectoryCode,
  35412. List_type_code: "301",
  35413. }
  35414. queryResult = append(queryResult, result)
  35415. }
  35416. } else if record_type == 3 {
  35417. projects, _ := service.GetBathchMyPorjecgList(ids)
  35418. for _, item := range projects {
  35419. result := QueryResult{
  35420. ID: item.ID,
  35421. Name: item.ProjectName,
  35422. Code: item.MedicalCode,
  35423. List_type_code: "201",
  35424. }
  35425. queryResult = append(queryResult, result)
  35426. }
  35427. }
  35428. adminUser := c.GetAdminUserInfo()
  35429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35430. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35431. var user_name string
  35432. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35433. if role.ID == 0 {
  35434. user_name = "xxx"
  35435. } else {
  35436. user_name = role.UserName
  35437. }
  35438. baseParams := &models.BaseParams{
  35439. SecretKey: miConfig.SecretKey,
  35440. FixmedinsCode: miConfig.Code,
  35441. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35442. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35443. OrgName: miConfig.OrgName,
  35444. Doctor: user_name,
  35445. }
  35446. if config.IsOpen == 1 {
  35447. if miConfig.MdtrtareaAdmvs == "430800" {
  35448. for _, item := range queryResult {
  35449. var result string
  35450. if record_type == 1 {
  35451. 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)
  35452. } else if record_type == 2 {
  35453. fmt.Println(item.Code)
  35454. 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)
  35455. } else if record_type == 3 {
  35456. 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)
  35457. }
  35458. var dat map[string]interface{}
  35459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35460. fmt.Println(dat)
  35461. } else {
  35462. fmt.Println(err)
  35463. }
  35464. userJSONBytes, _ := json.Marshal(dat)
  35465. var res ResultSix
  35466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35467. utils.ErrorLog("解析失败:%v", err)
  35468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35469. return
  35470. }
  35471. if res.Infcode == 0 {
  35472. if record_type == 1 {
  35473. service.UpdateBaseDrugById(item.ID)
  35474. } else if record_type == 2 {
  35475. service.UpdateGoodInformaitonByDetail(item.ID)
  35476. } else if record_type == 3 {
  35477. service.UpdateProjectById(item.ID)
  35478. }
  35479. c.ServeSuccessJSON(map[string]interface{}{
  35480. "failed_code": 0,
  35481. "msg": "目录对照成功",
  35482. })
  35483. } else {
  35484. c.ServeSuccessJSON(map[string]interface{}{
  35485. "failed_code": -10,
  35486. "msg": res.ErrMsg,
  35487. })
  35488. }
  35489. }
  35490. } else {
  35491. for _, item := range queryResult {
  35492. var result string
  35493. if record_type == 1 {
  35494. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35495. } else if record_type == 2 {
  35496. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35497. } else if record_type == 3 {
  35498. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35499. }
  35500. var dat2 map[string]interface{}
  35501. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  35502. fmt.Println(dat2)
  35503. } else {
  35504. fmt.Println(err)
  35505. }
  35506. userJSONBytes, _ := json.Marshal(dat2)
  35507. var res ResultSix
  35508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35509. utils.ErrorLog("解析失败:%v", err)
  35510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35511. return
  35512. }
  35513. if res.Infcode == 0 {
  35514. if record_type == 1 {
  35515. service.UpdateDrugByIdDetail(item.ID)
  35516. } else if record_type == 2 {
  35517. service.UpdateGoodInfoById(item.ID)
  35518. } else if record_type == 3 {
  35519. service.UpdateMyProjectById(item.ID)
  35520. }
  35521. c.ServeSuccessJSON(map[string]interface{}{
  35522. "failed_code": 0,
  35523. "msg": "撤销目录对照成功",
  35524. })
  35525. } else {
  35526. c.ServeSuccessJSON(map[string]interface{}{
  35527. "failed_code": -10,
  35528. "msg": res.ErrMsg,
  35529. })
  35530. }
  35531. }
  35532. }
  35533. }
  35534. }
  35535. func (c *HisApiController) GetPatientInfo() {
  35536. id_card_no := c.GetString("id_card_no")
  35537. admin_user_id, _ := c.GetInt64("admin_user_id")
  35538. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  35539. if patient.ID == 0 {
  35540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35541. return
  35542. }
  35543. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  35544. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35545. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  35546. var res ResultTwo
  35547. var res10265 ResultTwo10265
  35548. if config.IsOpen == 1 {
  35549. if miConfig.MdtrtareaAdmvs == "150499" {
  35550. //请求内网数据
  35551. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  35552. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  35553. "&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
  35554. resp, requestErr := http.Get(api)
  35555. if requestErr != nil {
  35556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35557. return
  35558. }
  35559. body, ioErr := ioutil.ReadAll(resp.Body)
  35560. if ioErr != nil {
  35561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35563. return
  35564. }
  35565. var respJSON map[string]interface{}
  35566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35569. return
  35570. }
  35571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35572. result_byte, _ := json.Marshal(respJSON)
  35573. result := string(result_byte)
  35574. var dat map[string]interface{}
  35575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35576. fmt.Println(dat)
  35577. } else {
  35578. fmt.Println(err)
  35579. }
  35580. userJSONBytes, _ := json.Marshal(dat)
  35581. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35582. utils.ErrorLog("解析失败:%v", err)
  35583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35584. return
  35585. }
  35586. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35587. res.Infcode = Infcode
  35588. res.ErrMsg = res10265.ErrMsg
  35589. res.Output = res10265.Output
  35590. res.InfRefmsgid = res10265.InfRefmsgid
  35591. res.RespondTime = res10265.RespondTime
  35592. res.WarnInfo = res10265.WarnInfo
  35593. } else {
  35594. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35595. var dat map[string]interface{}
  35596. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35597. fmt.Println(dat)
  35598. } else {
  35599. fmt.Println(err)
  35600. }
  35601. userJSONBytes, _ := json.Marshal(dat)
  35602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35603. utils.ErrorLog("解析失败:%v", err)
  35604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35605. return
  35606. }
  35607. }
  35608. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35609. // utils.ErrorLog("解析失败:%v", err)
  35610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35611. // return
  35612. //}
  35613. for index, item := range res.Output.Iinfo {
  35614. if item.PsnInsuStas == "2" {
  35615. fmt.Println("--------")
  35616. res.Output.Iinfo[index].Insutype = "300"
  35617. res.Output.Iinfo[index].PsnInsuStas = "1"
  35618. }
  35619. }
  35620. fmt.Println(res.Output.Iinfo)
  35621. if res.Infcode != 0 {
  35622. c.ServeSuccessJSON(map[string]interface{}{
  35623. "failed_code": -10,
  35624. "msg": res.ErrMsg,
  35625. })
  35626. } else {
  35627. c.ServeSuccessJSON(map[string]interface{}{
  35628. "failed_code": 0,
  35629. "info": res,
  35630. })
  35631. }
  35632. }
  35633. }
  35634. func (c *HisApiController) PsnPutOnRecord() {
  35635. record_type, _ := c.GetInt64("type")
  35636. patient_id, _ := c.GetInt64("patient_id")
  35637. admin_user_id, _ := c.GetInt64("admin_user_id")
  35638. start_time := c.GetString("start_time")
  35639. end_time := c.GetString("end_time")
  35640. adminUser := c.GetAdminUserInfo()
  35641. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35642. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35643. var patients []*models.Patients
  35644. if record_type == 1 { //全部备案
  35645. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  35646. patients = append(patients, patient...)
  35647. } else { //单个备案
  35648. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35649. patients = append(patients, patient)
  35650. }
  35651. var user_name string
  35652. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35653. if role.ID == 0 {
  35654. user_name = "xxx"
  35655. } else {
  35656. user_name = role.UserName
  35657. }
  35658. if config.IsOpen == 1 {
  35659. for _, item := range patients {
  35660. 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
  35661. resp, requestErr := http.Get(api)
  35662. if requestErr != nil {
  35663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35664. return
  35665. }
  35666. defer resp.Body.Close()
  35667. body, ioErr := ioutil.ReadAll(resp.Body)
  35668. if ioErr != nil {
  35669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35671. return
  35672. }
  35673. var respJSON map[string]interface{}
  35674. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35677. return
  35678. }
  35679. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35680. userJSONBytes, _ := json.Marshal(userJSON)
  35681. var res ResultTwo
  35682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35683. utils.ErrorLog("解析失败:%v", err)
  35684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35685. return
  35686. }
  35687. if res.Infcode == 0 {
  35688. 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)
  35689. var dat map[string]interface{}
  35690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35691. fmt.Println(dat)
  35692. } else {
  35693. fmt.Println(err)
  35694. }
  35695. userJSONBytes, _ := json.Marshal(dat)
  35696. var res2 ResultThirteen
  35697. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35698. utils.ErrorLog("解析失败:%v", err)
  35699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35700. return
  35701. }
  35702. if res2.Infcode == 0 {
  35703. psnResult := &models.GdybPsnRecord{
  35704. UserOrgId: adminUser.CurrentOrgId,
  35705. PatientId: item.ID,
  35706. PsnNo: res.Output.Baseinfo.PsnNo,
  35707. Ctime: time.Now().Unix(),
  35708. Mtime: time.Now().Unix(),
  35709. Status: 1,
  35710. IsCancel: 1,
  35711. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  35712. }
  35713. service.CreatePsnRecord(psnResult)
  35714. } else {
  35715. c.ServeSuccessJSON(map[string]interface{}{
  35716. "failed_code": -10,
  35717. "msg": res2.ErrMsg,
  35718. })
  35719. return
  35720. }
  35721. }
  35722. }
  35723. }
  35724. }
  35725. func (c *HisApiController) PsnUnPutOnRecord() {
  35726. id, _ := c.GetInt64("id")
  35727. //record_type, _ := c.GetInt64("type")
  35728. admin_user_id, _ := c.GetInt64("admin_user_id")
  35729. adminUser := c.GetAdminUserInfo()
  35730. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35731. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35732. var user_name string
  35733. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35734. if role.ID == 0 {
  35735. user_name = "xxx"
  35736. } else {
  35737. user_name = role.UserName
  35738. }
  35739. psn_record, _ := service.GetPsnRecordById(id)
  35740. if psn_record.ID == 0 {
  35741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  35742. return
  35743. }
  35744. if config.IsOpen == 1 {
  35745. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  35746. var dat map[string]interface{}
  35747. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35748. fmt.Println(dat)
  35749. } else {
  35750. fmt.Println(err)
  35751. }
  35752. userJSONBytes, _ := json.Marshal(dat)
  35753. var res ResultFourteen
  35754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35755. utils.ErrorLog("解析失败:%v", err)
  35756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35757. return
  35758. }
  35759. if res.Infcode == 0 {
  35760. psn_record.IsCancel = 2
  35761. service.CreatePsnRecord(&psn_record)
  35762. } else {
  35763. c.ServeSuccessJSON(map[string]interface{}{
  35764. "failed_code": -10,
  35765. "msg": res.ErrMsg,
  35766. })
  35767. return
  35768. }
  35769. }
  35770. }
  35771. func (c *HisApiController) PsnPutNCDSOnRecord() {
  35772. patient_id, _ := c.GetInt64("patient_id")
  35773. insutype_two := c.GetString("insutype")
  35774. psn_no := c.GetString("psn_no")
  35775. doctor_id, _ := c.GetInt64("doctor_id")
  35776. sick_id, _ := c.GetInt64("sick_id")
  35777. department_id, _ := c.GetInt64("department_id")
  35778. start_time := c.GetString("start_time")
  35779. end_time := c.GetString("end_time")
  35780. check_time := c.GetString("check_time")
  35781. hospital_code := c.GetString("hospital_code")
  35782. hospital_name := c.GetString("hospital_name")
  35783. adminUser := c.GetAdminUserInfo()
  35784. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35785. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35786. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35787. sick, _ := service.FindSickById(sick_id)
  35788. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  35789. if len(hospital_code) == 0 {
  35790. hospital_code = miConfig.Code
  35791. }
  35792. if len(hospital_name) == 0 {
  35793. hospital_name = miConfig.OrgName
  35794. }
  35795. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  35796. var res ResultTwo
  35797. var res10265 ResultTwo10265
  35798. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  35799. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  35800. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  35801. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  35802. "&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
  35803. resp, requestErr := http.Get(api)
  35804. if requestErr != nil {
  35805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35806. return
  35807. }
  35808. body, ioErr := ioutil.ReadAll(resp.Body)
  35809. if ioErr != nil {
  35810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35812. return
  35813. }
  35814. var respJSON map[string]interface{}
  35815. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35818. return
  35819. }
  35820. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35821. result, _ := json.Marshal(respJSON)
  35822. fmt.Println("log")
  35823. fmt.Println(string(result))
  35824. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35825. utils.ErrorLog("解析失败:%v", err)
  35826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35827. return
  35828. }
  35829. res.ErrMsg = res10265.ErrMsg
  35830. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35831. res.Infcode = infocode
  35832. res.Output = res10265.Output
  35833. res.InfRefmsgid = res10265.InfRefmsgid
  35834. } else {
  35835. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  35836. if miConfig.Code == "H15049901371" {
  35837. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35838. utils.ErrorLog("解析失败:%v", err)
  35839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35840. return
  35841. }
  35842. res.ErrMsg = res10265.ErrMsg
  35843. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35844. res.Infcode = infocode
  35845. res.Output = res10265.Output
  35846. res.InfRefmsgid = res10265.InfRefmsgid
  35847. } else {
  35848. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35849. utils.ErrorLog("解析失败:%v", err)
  35850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35851. return
  35852. }
  35853. }
  35854. }
  35855. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35856. infoStr := string(Iinfos)
  35857. var rf []*ResultFive
  35858. json.Unmarshal([]byte(infoStr), &rf)
  35859. var insuplc_admdvs string
  35860. var insutype string
  35861. var is390 int = 0
  35862. var is310 int = 0
  35863. var insutypes []*ResultFive
  35864. for _, item := range rf {
  35865. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  35866. insutypes = append(insutypes, item)
  35867. }
  35868. }
  35869. if len(insutypes) == 1 {
  35870. insutype = insutypes[0].Insutype
  35871. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  35872. } else {
  35873. for _, i := range insutypes {
  35874. if i.Insutype == "390" {
  35875. is390 = 1
  35876. }
  35877. if i.Insutype == "310" {
  35878. is310 = 1
  35879. }
  35880. }
  35881. }
  35882. if is390 == 1 {
  35883. insutype = "390"
  35884. }
  35885. if is310 == 1 {
  35886. insutype = "310"
  35887. }
  35888. if len(insutypes) == 2 {
  35889. insutype = insutype_two
  35890. }
  35891. if len(insutypes) == 0 {
  35892. insutype = "310"
  35893. }
  35894. insutype = insutype_two
  35895. fmt.Println(insutype)
  35896. for _, item := range rf {
  35897. fmt.Println(item.Insutype)
  35898. fmt.Println(insutype)
  35899. if item.Insutype == insutype {
  35900. fmt.Println(item.Insutype)
  35901. fmt.Println(insutype)
  35902. insuplc_admdvs = item.InsuplcAdmdvs
  35903. }
  35904. }
  35905. fmt.Println(insuplc_admdvs)
  35906. var res2 ResultThirteen
  35907. var res10265_2 ResultThirteen10265
  35908. if config.IsOpen == 1 {
  35909. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  35910. } else {
  35911. if miConfig.MdtrtareaAdmvs == "150499" {
  35912. //
  35913. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  35914. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  35915. // "&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
  35916. //resp, requestErr := http.Get(api)
  35917. //if requestErr != nil {
  35918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35919. // return
  35920. //}
  35921. //
  35922. //body, ioErr := ioutil.ReadAll(resp.Body)
  35923. //if ioErr != nil {
  35924. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35926. // return
  35927. //}
  35928. //var respJSON map[string]interface{}
  35929. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35930. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35931. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35932. // return
  35933. //}
  35934. //
  35935. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35936. //result, _ := json.Marshal(respJSON)
  35937. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  35938. // utils.ErrorLog("解析失败:%v", err)
  35939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35940. // return
  35941. //}
  35942. //infocode = resThree.Infcode
  35943. //result, _ := json.Marshal(respJSON)
  35944. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  35945. // utils.ErrorLog("解析失败:%v", err)
  35946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35947. // return
  35948. //}
  35949. //
  35950. //resThree.ErrMsg = resThree10265.ErrMsg
  35951. //
  35952. //resThree.Output = resThree10265.Output
  35953. //
  35954. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  35955. //
  35956. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  35957. //
  35958. } else {
  35959. 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)
  35960. var dat map[string]interface{}
  35961. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35962. fmt.Println(dat)
  35963. } else {
  35964. fmt.Println(err)
  35965. }
  35966. userJSONBytes, _ := json.Marshal(dat)
  35967. if miConfig.Code == "H15049901371" {
  35968. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  35969. utils.ErrorLog("解析失败:%v", err)
  35970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35971. return
  35972. }
  35973. res2.ErrMsg = res10265_2.ErrMsg
  35974. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  35975. res2.Infcode = infocode
  35976. res2.Output = res10265_2.Output
  35977. res2.InfRefmsgid = res10265_2.InfRefmsgid
  35978. } else {
  35979. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35980. utils.ErrorLog("解析失败:%v", err)
  35981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35982. return
  35983. }
  35984. }
  35985. }
  35986. }
  35987. if res2.Infcode == 0 {
  35988. psnResult := &models.GdybPsnNcdsRecord{
  35989. UserOrgId: adminUser.CurrentOrgId,
  35990. PatientId: patient.ID,
  35991. PsnNo: psn_no,
  35992. DoctorId: doctor.AdminUserId,
  35993. DepartmentId: department_id,
  35994. SickType: sick_id,
  35995. Insutype: insutype,
  35996. Ctime: time.Now().Unix(),
  35997. Mtime: time.Now().Unix(),
  35998. Status: 1,
  35999. IsCancel: 1,
  36000. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36001. }
  36002. service.CreatePsnNCDSRecord(psnResult)
  36003. c.ServeSuccessJSON(map[string]interface{}{
  36004. "failed_code": 0,
  36005. "msg": "备案成功",
  36006. "result": psnResult,
  36007. })
  36008. } else {
  36009. c.ServeSuccessJSON(map[string]interface{}{
  36010. "failed_code": -10,
  36011. "msg": res2.ErrMsg,
  36012. })
  36013. return
  36014. }
  36015. }
  36016. }
  36017. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36018. id, _ := c.GetInt64("id")
  36019. admin_user_id, _ := c.GetInt64("admin_user_id")
  36020. adminUser := c.GetAdminUserInfo()
  36021. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36022. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36023. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36024. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36025. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36026. //var user_name string
  36027. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36028. //if role.ID == 0 {
  36029. // user_name = "xxx"
  36030. //} else {
  36031. // user_name = role.UserName
  36032. //}
  36033. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36034. if psn_record.ID == 0 {
  36035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36036. return
  36037. }
  36038. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36039. var res ResultTwo
  36040. var res10265 ResultTwo10265
  36041. if miConfig.Code == "H15049901371" {
  36042. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36043. utils.ErrorLog("解析失败:%v", err)
  36044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36045. return
  36046. }
  36047. res.ErrMsg = res10265.ErrMsg
  36048. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36049. res.Infcode = infocode
  36050. res.Output = res10265.Output
  36051. res.InfRefmsgid = res10265.InfRefmsgid
  36052. } else {
  36053. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36054. utils.ErrorLog("解析失败:%v", err)
  36055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36056. return
  36057. }
  36058. }
  36059. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36060. infoStr := string(Iinfos)
  36061. var rf []*ResultFive
  36062. json.Unmarshal([]byte(infoStr), &rf)
  36063. var insuplc_admdvs string
  36064. var insutype string
  36065. var is390 int = 0
  36066. var is310 int = 0
  36067. var insutypes []*ResultFive
  36068. for _, item := range rf {
  36069. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36070. insutypes = append(insutypes, item)
  36071. }
  36072. }
  36073. if len(insutypes) == 1 {
  36074. insutype = insutypes[0].Insutype
  36075. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36076. } else {
  36077. for _, i := range insutypes {
  36078. if i.Insutype == "390" {
  36079. is390 = 1
  36080. }
  36081. if i.Insutype == "310" {
  36082. is310 = 1
  36083. }
  36084. }
  36085. }
  36086. if is390 == 1 {
  36087. insutype = "390"
  36088. }
  36089. if is310 == 1 {
  36090. insutype = "310"
  36091. }
  36092. if len(insutypes) == 0 {
  36093. insutype = "310"
  36094. }
  36095. insutype = psn_record.Insutype
  36096. for _, item := range rf {
  36097. if item.Insutype == insutype {
  36098. insuplc_admdvs = item.InsuplcAdmdvs
  36099. }
  36100. }
  36101. if config.IsOpen == 1 {
  36102. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36103. var dat map[string]interface{}
  36104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36105. fmt.Println(dat)
  36106. } else {
  36107. fmt.Println(err)
  36108. }
  36109. userJSONBytes, _ := json.Marshal(dat)
  36110. var res ResultFourteen
  36111. var res10265 ResultFourteen10265
  36112. if miConfig.Code == "H15049901371" {
  36113. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36114. utils.ErrorLog("解析失败:%v", err)
  36115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36116. return
  36117. }
  36118. res.ErrMsg = res10265.ErrMsg
  36119. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36120. res.Infcode = infocode
  36121. res.Output = res10265.Output
  36122. res.InfRefmsgid = res10265.InfRefmsgid
  36123. } else {
  36124. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36125. utils.ErrorLog("解析失败:%v", err)
  36126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36127. return
  36128. }
  36129. }
  36130. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36131. // utils.ErrorLog("解析失败:%v", err)
  36132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36133. // return
  36134. //}
  36135. if res.Infcode == 0 {
  36136. psn_record.IsCancel = 2
  36137. service.CreatePsnNCDSRecord(&psn_record)
  36138. c.ServeSuccessJSON(map[string]interface{}{
  36139. "failed_code": 0,
  36140. "msg": "撤销备案成功",
  36141. })
  36142. } else {
  36143. c.ServeSuccessJSON(map[string]interface{}{
  36144. "failed_code": -10,
  36145. "msg": res.ErrMsg,
  36146. })
  36147. return
  36148. }
  36149. }
  36150. }
  36151. func (c *HisApiController) TestTest() {
  36152. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36153. fmt.Println(patient.Iinfo)
  36154. }
  36155. type CustomData struct {
  36156. MsgId string
  36157. PsnNo string
  36158. Info string
  36159. }
  36160. func (c *HisApiController) ReversalData() {
  36161. var customData []*CustomData
  36162. custom := &CustomData{
  36163. MsgId: "H44022900158202103301714472004",
  36164. PsnNo: "44020000001101329945",
  36165. Info: "2207",
  36166. }
  36167. customData = append(customData, custom)
  36168. custom1 := &CustomData{
  36169. MsgId: "H4402290015820210330172057803",
  36170. PsnNo: "44020000001101161813",
  36171. Info: "2207",
  36172. }
  36173. customData = append(customData, custom1)
  36174. custom2 := &CustomData{
  36175. MsgId: "H44022900158202103301705198813",
  36176. PsnNo: "44190000133097375417",
  36177. Info: "2207",
  36178. }
  36179. customData = append(customData, custom2)
  36180. custom3 := &CustomData{
  36181. MsgId: "H44022900158202103301715524756",
  36182. PsnNo: "44020000001100187221",
  36183. Info: "2207",
  36184. }
  36185. customData = append(customData, custom3)
  36186. custom4 := &CustomData{
  36187. MsgId: "H44022900158202103301730376224",
  36188. PsnNo: "44020000001101959155",
  36189. Info: "2207",
  36190. }
  36191. customData = append(customData, custom4)
  36192. custom5 := &CustomData{
  36193. MsgId: "H44022900158202103301748008725",
  36194. PsnNo: "44020000001104246641",
  36195. Info: "2207",
  36196. }
  36197. customData = append(customData, custom5)
  36198. custom6 := &CustomData{
  36199. MsgId: "H44022900158202103301718096755",
  36200. PsnNo: "44020000001102211860",
  36201. Info: "2207",
  36202. }
  36203. customData = append(customData, custom6)
  36204. custom7 := &CustomData{
  36205. MsgId: "H44022900158202103301736551640",
  36206. PsnNo: "44020000001102687718",
  36207. Info: "2207",
  36208. }
  36209. customData = append(customData, custom7)
  36210. custom8 := &CustomData{
  36211. MsgId: "H44022900158202103301743097676",
  36212. PsnNo: "44020000001102127785",
  36213. Info: "2207",
  36214. }
  36215. customData = append(customData, custom8)
  36216. custom9 := &CustomData{
  36217. MsgId: "H44022900158202103301712304203",
  36218. PsnNo: "44020000001101518097",
  36219. Info: "2207",
  36220. }
  36221. customData = append(customData, custom9)
  36222. custom10 := &CustomData{
  36223. MsgId: "H44022900158202103301738448785",
  36224. PsnNo: "44020000001100500813",
  36225. Info: "2207",
  36226. }
  36227. customData = append(customData, custom10)
  36228. custom11 := &CustomData{
  36229. MsgId: "H44022900158202103301732455843",
  36230. PsnNo: "44020000001102690557",
  36231. Info: "2207",
  36232. }
  36233. customData = append(customData, custom11)
  36234. custom12 := &CustomData{
  36235. MsgId: "H44022900158202103301745421708",
  36236. PsnNo: "44020000001102211928",
  36237. Info: "2207",
  36238. }
  36239. customData = append(customData, custom12)
  36240. custom1212 := &CustomData{
  36241. MsgId: "H440229001582021033017351627",
  36242. PsnNo: "44020000001102481733",
  36243. Info: "2207",
  36244. }
  36245. customData = append(customData, custom1212)
  36246. custom13 := &CustomData{
  36247. MsgId: "H44022900158202103301740327951",
  36248. PsnNo: "44020000001103174866",
  36249. Info: "2207",
  36250. }
  36251. customData = append(customData, custom13)
  36252. custom14 := &CustomData{
  36253. MsgId: "H4402290015820210330174922668",
  36254. PsnNo: "44020000001102927272",
  36255. Info: "2207",
  36256. }
  36257. customData = append(customData, custom14)
  36258. custom15 := &CustomData{
  36259. MsgId: "H44022900158202103301752362273",
  36260. PsnNo: "44020000001102942890",
  36261. Info: "2207",
  36262. }
  36263. customData = append(customData, custom15)
  36264. custom16 := &CustomData{
  36265. MsgId: "H44022900158202103301751082917",
  36266. PsnNo: "44020000001101662162",
  36267. Info: "2207",
  36268. }
  36269. customData = append(customData, custom16)
  36270. custom17 := &CustomData{
  36271. MsgId: "H44022900158202103301754147728",
  36272. PsnNo: "44020000000229014511",
  36273. Info: "2207",
  36274. }
  36275. customData = append(customData, custom17)
  36276. adminUser := c.GetAdminUserInfo()
  36277. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36278. for _, item := range customData {
  36279. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36280. fmt.Println(result)
  36281. }
  36282. }
  36283. func (c *HisApiController) GetAllopatry() {
  36284. year := c.GetString("year")
  36285. month := c.GetString("month")
  36286. admin_user_id, _ := c.GetInt64("admin_user_id")
  36287. adminUser := c.GetAdminUserInfo()
  36288. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36289. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36290. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36291. var dat map[string]interface{}
  36292. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36293. fmt.Println(dat)
  36294. } else {
  36295. fmt.Println(err)
  36296. }
  36297. userJSONBytes, _ := json.Marshal(dat)
  36298. var res models.Result9001
  36299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36300. utils.ErrorLog("解析失败:%v", err)
  36301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36302. return
  36303. }
  36304. fmt.Println(res.Output.Signinoutb)
  36305. fmt.Println(res.Output.Signinoutb.SignNo)
  36306. fmt.Println(string(userJSONBytes))
  36307. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36308. var dat3 map[string]interface{}
  36309. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  36310. fmt.Println(dat3)
  36311. } else {
  36312. fmt.Println(err)
  36313. }
  36314. userJSONBytes3, _ := json.Marshal(dat3)
  36315. var res3 models.Result3260
  36316. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  36317. utils.ErrorLog("解析失败:%v", err)
  36318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36319. return
  36320. }
  36321. var curpage int
  36322. var pagesize int = 100
  36323. var start int = 1
  36324. //var stop int
  36325. //pagecount := 10
  36326. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  36327. var res22 []models.Result3260
  36328. for curpage = 1; curpage <= pagecount; curpage++ {
  36329. if curpage == 1 {
  36330. start = 0
  36331. } else {
  36332. start = (curpage-1)*pagesize + 1
  36333. }
  36334. fmt.Println(start)
  36335. //stop = curpage * pagesize
  36336. //if stop > int(res3.Output.Totalrow) {
  36337. // stop =int(res3.Output.Totalrow)
  36338. //}
  36339. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  36340. var dat2 map[string]interface{}
  36341. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36342. fmt.Println(dat)
  36343. } else {
  36344. fmt.Println(err)
  36345. }
  36346. userJSONBytes2, _ := json.Marshal(dat2)
  36347. var res2 models.Result3260
  36348. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36349. utils.ErrorLog("解析失败:%v", err)
  36350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36351. return
  36352. }
  36353. if res2.Infcode == 0 {
  36354. res22 = append(res22, res2)
  36355. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36356. //var dat2 map[string]interface{}
  36357. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36358. // fmt.Println(dat)
  36359. //} else {
  36360. // fmt.Println(err)
  36361. //}
  36362. //c.ServeSuccessJSON(map[string]interface{}{
  36363. // "list": res2.Output.Data,
  36364. //})
  36365. //continue
  36366. }
  36367. }
  36368. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36369. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36370. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  36371. //var dat2 map[string]interface{}
  36372. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36373. // fmt.Println(dat)
  36374. //} else {
  36375. // fmt.Println(err)
  36376. //}
  36377. //userJSONBytes2, _ := json.Marshal(dat2)
  36378. //var res2 models.Result3260
  36379. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36380. // utils.ErrorLog("解析失败:%v", err)
  36381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36382. // return
  36383. //}
  36384. //if res2.Infcode == 0 {
  36385. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36386. // var dat2 map[string]interface{}
  36387. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36388. // fmt.Println(dat)
  36389. // } else {
  36390. // fmt.Println(err)
  36391. // }
  36392. // c.ServeSuccessJSON(map[string]interface{}{
  36393. // "list": res2.Output.Data,
  36394. // })
  36395. //}
  36396. }
  36397. func (c *HisApiController) ComfirmAllopatry() {
  36398. year := c.GetString("year")
  36399. month := c.GetString("month")
  36400. admin_user_id, _ := c.GetInt64("admin_user_id")
  36401. adminUser := c.GetAdminUserInfo()
  36402. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36403. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36404. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36405. var dat map[string]interface{}
  36406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36407. fmt.Println(dat)
  36408. } else {
  36409. fmt.Println(err)
  36410. }
  36411. userJSONBytes, _ := json.Marshal(dat)
  36412. var res models.Result9001
  36413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36414. utils.ErrorLog("解析失败:%v", err)
  36415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36416. return
  36417. }
  36418. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36419. var dat2 map[string]interface{}
  36420. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36421. fmt.Println(dat)
  36422. } else {
  36423. fmt.Println(err)
  36424. }
  36425. userJSONBytes2, _ := json.Marshal(dat2)
  36426. var res2 models.Result3260
  36427. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36428. utils.ErrorLog("解析失败:%v", err)
  36429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36430. return
  36431. }
  36432. //if res2.Infcode == 0 {
  36433. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36434. // var dat map[string]interface{}
  36435. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36436. // fmt.Println(dat)
  36437. // } else {
  36438. // fmt.Println(err)
  36439. // }
  36440. // userJSONBytes, _ := json.Marshal(dat)
  36441. // var res3 models.Result3261
  36442. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  36443. // utils.ErrorLog("解析失败:%v", err)
  36444. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36445. // return
  36446. // }
  36447. //
  36448. // if res3.Infcode == 0 {
  36449. // record := &models.HisYidiClearRecord{
  36450. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  36451. // Ctime: time.Now().Unix(),
  36452. // Mtime: time.Now().Unix(),
  36453. // Status: 1,
  36454. // MsgId: msgId,
  36455. // }
  36456. // service.SaveClearRecord(record)
  36457. // c.ServeSuccessJSON(map[string]interface{}{
  36458. // "msg": "提取成功",
  36459. // })
  36460. // }
  36461. //}
  36462. }
  36463. func (c *HisApiController) RefundAllopatry() {
  36464. year := c.GetString("year")
  36465. month := c.GetString("month")
  36466. //id, _ := c.GetInt64("id")
  36467. admin_user_id, _ := c.GetInt64("admin_user_id")
  36468. adminUser := c.GetAdminUserInfo()
  36469. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36470. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36471. //record, _ := service.GetClearRecordById(id)
  36472. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36473. var dat map[string]interface{}
  36474. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  36475. fmt.Println(dat)
  36476. } else {
  36477. fmt.Println(err)
  36478. }
  36479. userJSONBytes, _ := json.Marshal(dat)
  36480. var res models.Result9001
  36481. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36482. utils.ErrorLog("解析失败:%v", err)
  36483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36484. return
  36485. }
  36486. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  36487. var dat2 map[string]interface{}
  36488. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36489. fmt.Println(dat)
  36490. } else {
  36491. fmt.Println(err)
  36492. }
  36493. userJSONBytes2, _ := json.Marshal(dat2)
  36494. var empty ResultFourteen
  36495. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  36496. utils.ErrorLog("解析失败:%v", err)
  36497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36498. return
  36499. }
  36500. if empty.Infcode == 0 {
  36501. c.ServeSuccessJSON(map[string]interface{}{
  36502. "msg": "撤销成功",
  36503. })
  36504. return
  36505. }
  36506. }
  36507. func (c *HisApiController) ReversalOtherData() {
  36508. var customData []*CustomData
  36509. custom := &CustomData{
  36510. MsgId: "H44022900158202103301714472004",
  36511. PsnNo: "44020000001101329945",
  36512. Info: "2208",
  36513. }
  36514. customData = append(customData, custom)
  36515. custom1 := &CustomData{
  36516. MsgId: "H4402290015820210330172057803",
  36517. PsnNo: "44020000001101161813",
  36518. Info: "2208",
  36519. }
  36520. customData = append(customData, custom1)
  36521. custom2 := &CustomData{
  36522. MsgId: "H44022900158202103301705198813",
  36523. PsnNo: "44190000133097375417",
  36524. Info: "2208",
  36525. }
  36526. customData = append(customData, custom2)
  36527. custom3 := &CustomData{
  36528. MsgId: "H44022900158202103301715524756",
  36529. PsnNo: "44020000001100187221",
  36530. Info: "2208",
  36531. }
  36532. customData = append(customData, custom3)
  36533. custom4 := &CustomData{
  36534. MsgId: "H44022900158202103301730376224",
  36535. PsnNo: "44020000001101959155",
  36536. Info: "2208",
  36537. }
  36538. customData = append(customData, custom4)
  36539. custom5 := &CustomData{
  36540. MsgId: "H44022900158202103301748008725",
  36541. PsnNo: "44020000001104246641",
  36542. Info: "2208",
  36543. }
  36544. customData = append(customData, custom5)
  36545. custom6 := &CustomData{
  36546. MsgId: "H44022900158202103301718096755",
  36547. PsnNo: "44020000001102211860",
  36548. Info: "2208",
  36549. }
  36550. customData = append(customData, custom6)
  36551. custom7 := &CustomData{
  36552. MsgId: "H44022900158202103301736551640",
  36553. PsnNo: "44020000001102687718",
  36554. Info: "2208",
  36555. }
  36556. customData = append(customData, custom7)
  36557. custom8 := &CustomData{
  36558. MsgId: "H44022900158202103301743097676",
  36559. PsnNo: "44020000001102127785",
  36560. Info: "2208",
  36561. }
  36562. customData = append(customData, custom8)
  36563. custom9 := &CustomData{
  36564. MsgId: "H44022900158202103301712304203",
  36565. PsnNo: "44020000001101518097",
  36566. Info: "2208",
  36567. }
  36568. customData = append(customData, custom9)
  36569. custom10 := &CustomData{
  36570. MsgId: "H44022900158202103301738448785",
  36571. PsnNo: "44020000001100500813",
  36572. Info: "2208",
  36573. }
  36574. customData = append(customData, custom10)
  36575. custom11 := &CustomData{
  36576. MsgId: "H44022900158202103301732455843",
  36577. PsnNo: "44020000001102690557",
  36578. Info: "2208",
  36579. }
  36580. customData = append(customData, custom11)
  36581. custom12 := &CustomData{
  36582. MsgId: "H44022900158202103301745421708",
  36583. PsnNo: "44020000001102211928",
  36584. Info: "2208",
  36585. }
  36586. customData = append(customData, custom12)
  36587. custom1212 := &CustomData{
  36588. MsgId: "H440229001582021033017351627",
  36589. PsnNo: "44020000001102481733",
  36590. Info: "2208",
  36591. }
  36592. customData = append(customData, custom1212)
  36593. custom13 := &CustomData{
  36594. MsgId: "H44022900158202103301740327951",
  36595. PsnNo: "44020000001103174866",
  36596. Info: "2208",
  36597. }
  36598. customData = append(customData, custom13)
  36599. custom14 := &CustomData{
  36600. MsgId: "H4402290015820210330174922668",
  36601. PsnNo: "44020000001102927272",
  36602. Info: "2208",
  36603. }
  36604. customData = append(customData, custom14)
  36605. custom15 := &CustomData{
  36606. MsgId: "H44022900158202103301752362273",
  36607. PsnNo: "44020000001102942890",
  36608. Info: "2208",
  36609. }
  36610. customData = append(customData, custom15)
  36611. custom16 := &CustomData{
  36612. MsgId: "H44022900158202103301751082917",
  36613. PsnNo: "44020000001101662162",
  36614. Info: "2208",
  36615. }
  36616. customData = append(customData, custom16)
  36617. custom17 := &CustomData{
  36618. MsgId: "H44022900158202103301754147728",
  36619. PsnNo: "44020000000229014511",
  36620. Info: "2208",
  36621. }
  36622. customData = append(customData, custom17)
  36623. adminUser := c.GetAdminUserInfo()
  36624. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36625. for _, item := range customData {
  36626. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36627. fmt.Println(result)
  36628. }
  36629. }
  36630. func PathExists(path string) (bool, error) {
  36631. _, err := os.Stat(path)
  36632. if err == nil {
  36633. return true, nil
  36634. }
  36635. if os.IsNotExist(err) {
  36636. return false, nil
  36637. }
  36638. return false, err
  36639. }
  36640. // 创建文件夹
  36641. func Mkdir(dir string) {
  36642. // 创建文件夹
  36643. exist, err := PathExists(dir)
  36644. if err != nil {
  36645. fmt.Println(err.Error())
  36646. } else {
  36647. if exist {
  36648. fmt.Println(dir + "文件夹已存在!")
  36649. } else {
  36650. // 文件夹名称,权限
  36651. err := os.Mkdir(dir, os.ModePerm)
  36652. if err != nil {
  36653. fmt.Println(dir+"文件夹创建失败:", err.Error())
  36654. } else {
  36655. fmt.Println(dir + "文件夹创建成功!")
  36656. }
  36657. }
  36658. }
  36659. }
  36660. // 压缩文件
  36661. func Zip(srcFile string, destZip string) error {
  36662. zipfile, err := os.Create(destZip)
  36663. if err != nil {
  36664. return err
  36665. }
  36666. defer zipfile.Close()
  36667. archive := zip.NewWriter(zipfile)
  36668. defer archive.Close()
  36669. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  36670. if err != nil {
  36671. return err
  36672. }
  36673. header, err := zip.FileInfoHeader(info)
  36674. if err != nil {
  36675. return err
  36676. }
  36677. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  36678. // header.Name = path
  36679. if info.IsDir() {
  36680. header.Name += "/"
  36681. } else {
  36682. header.Method = zip.Deflate
  36683. }
  36684. writer, err := archive.CreateHeader(header)
  36685. if err != nil {
  36686. return err
  36687. }
  36688. if !info.IsDir() {
  36689. file, err := os.Open(path)
  36690. if err != nil {
  36691. return err
  36692. }
  36693. defer file.Close()
  36694. _, err = io.Copy(writer, file)
  36695. }
  36696. return err
  36697. })
  36698. return err
  36699. }
  36700. func ReadFile(filePath string) []byte {
  36701. f, err := os.Open(filePath)
  36702. if err != nil {
  36703. fmt.Println("read file fail", err)
  36704. return nil
  36705. }
  36706. defer f.Close()
  36707. fd, err := ioutil.ReadAll(f)
  36708. if err != nil {
  36709. fmt.Println("read to fd fail", err)
  36710. return nil
  36711. }
  36712. return fd
  36713. }
  36714. func saveLogq(result string, request string, infno string, desc string) {
  36715. dir := "日志"
  36716. utils.Mkdir(dir)
  36717. month := time.Unix(1557042972, 0).Format("1")
  36718. year := time.Now().Format("2006")
  36719. month = time.Now().Format("01")
  36720. day := time.Now().Format("02")
  36721. hour := time.Now().Format("15")
  36722. min := time.Now().Format("04")
  36723. sec := time.Now().Format("05")
  36724. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  36725. file := year + month + day + "_log"
  36726. file_name := file + ".txt"
  36727. file_path := "日志" + "/" + file_name
  36728. exist, _ := utils.PathExists(file_path)
  36729. if exist { //存在
  36730. fmt.Println("存在")
  36731. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  36732. if err != nil {
  36733. fmt.Println("read fail")
  36734. }
  36735. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  36736. n, _ := f.Seek(0, 2)
  36737. _, err = f.WriteAt([]byte(content), n)
  36738. } else { //不存在
  36739. fmt.Println("文件不存在,创建文件")
  36740. f, err := os.Create("日志" + "/" + file_name)
  36741. defer f.Close()
  36742. if err != nil {
  36743. } else {
  36744. _, err = f.Write([]byte("记录日志"))
  36745. }
  36746. }
  36747. }
  36748. func saveLog(result string, request string, infno string, desc string) {
  36749. org_id, _ := beego.AppConfig.Int64("org_id")
  36750. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  36751. dir := miConfig.OrgName + "日志"
  36752. utils.Mkdir(dir)
  36753. month := time.Unix(1557042972, 0).Format("1")
  36754. year := time.Now().Format("2006")
  36755. month = time.Now().Format("01")
  36756. day := time.Now().Format("02")
  36757. hour := time.Now().Format("15")
  36758. min := time.Now().Format("04")
  36759. sec := time.Now().Format("05")
  36760. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  36761. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  36762. file_name := file + ".txt"
  36763. file_path := miConfig.OrgName + "日志" + "/" + file_name
  36764. exist, _ := utils.PathExists(file_path)
  36765. if exist { //存在
  36766. fmt.Println("存在")
  36767. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  36768. if err != nil {
  36769. fmt.Println("read fail")
  36770. }
  36771. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  36772. n, _ := f.Seek(0, 2)
  36773. _, err = f.WriteAt([]byte(content), n)
  36774. } else { //不存在
  36775. fmt.Println("文件不存在,创建文件")
  36776. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  36777. defer f.Close()
  36778. if err != nil {
  36779. } else {
  36780. _, err = f.Write([]byte("记录日志"))
  36781. }
  36782. }
  36783. }
  36784. type Charset string
  36785. const (
  36786. UTF8 = Charset("UTF-8")
  36787. GB18030 = Charset("GB18030")
  36788. )
  36789. func ConvertToString(src string, srcCode string, tagCode string) string {
  36790. srcCoder := mahonia.NewDecoder(srcCode)
  36791. srcResult := srcCoder.ConvertString(src)
  36792. tagCoder := mahonia.NewDecoder(tagCode)
  36793. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  36794. result := string(cdata)
  36795. return result
  36796. }
  36797. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  36798. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  36799. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  36800. var token string
  36801. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36802. var api string
  36803. if miConfig.MdtrtareaAdmvs == "320921" {
  36804. 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 +
  36805. "&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
  36806. fmt.Println(api)
  36807. } else {
  36808. 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 +
  36809. "&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
  36810. }
  36811. resp, requestErr := http.Get(api)
  36812. if requestErr != nil {
  36813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36814. return ""
  36815. }
  36816. body, ioErr := ioutil.ReadAll(resp.Body)
  36817. if ioErr != nil {
  36818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36820. return ""
  36821. }
  36822. var respJSON map[string]interface{}
  36823. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36826. return ""
  36827. }
  36828. var status string
  36829. status = respJSON["data"].(map[string]interface{})["status"].(string)
  36830. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  36831. var res ResultTwo //1101结果
  36832. var res10265 ResultTwo10265 //1101结果
  36833. if status == "0" { //读卡成功
  36834. var card_info string //卡信息
  36835. var busi_card_info string
  36836. token = respJSON["data"].(map[string]interface{})["token"].(string)
  36837. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  36838. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  36839. fmt.Println(card_info)
  36840. fmt.Println(busi_card_info)
  36841. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  36842. result, _ := json.Marshal(respJSON)
  36843. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36844. utils.ErrorLog("解析失败:%v", err)
  36845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36846. return ""
  36847. }
  36848. res.ErrMsg = res10265.ErrMsg
  36849. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36850. res.Infcode = infocode
  36851. res.Output = res10265.Output
  36852. res.InfRefmsgid = res10265.InfRefmsgid
  36853. if res.Infcode == 0 {
  36854. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  36855. if err == gorm.ErrRecordNotFound {
  36856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  36857. return ""
  36858. } else if err != nil {
  36859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  36860. return ""
  36861. } else {
  36862. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36863. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  36864. infoStr := string(Iinfos)
  36865. idetinfoStr := string(Idetinfos)
  36866. psn := &models.HisPsn{
  36867. PsnNo: res.Output.Baseinfo.PsnNo,
  36868. PatientId: patient.ID,
  36869. Certno: res.Output.Baseinfo.Certno,
  36870. Gend: res.Output.Baseinfo.Gend,
  36871. Naty: res.Output.Baseinfo.Naty,
  36872. PsnCertType: res.Output.Baseinfo.PsnCertType,
  36873. PsnName: res.Output.Baseinfo.PsnName,
  36874. Idetinfo: idetinfoStr,
  36875. Insuinfo: infoStr,
  36876. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  36877. CardInfo: card_info,
  36878. VerifyNumber: token,
  36879. }
  36880. service.CreateHisPsn(psn)
  36881. return token
  36882. }
  36883. }
  36884. } else {
  36885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  36886. return ""
  36887. }
  36888. } else { //读卡失败
  36889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  36890. return ""
  36891. }
  36892. return token
  36893. }
  36894. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  36895. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  36896. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  36897. var token string
  36898. var api string
  36899. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  36900. "&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
  36901. fmt.Println(api)
  36902. resp, requestErr := http.Get(api)
  36903. if requestErr != nil {
  36904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36905. return ""
  36906. }
  36907. body, ioErr := ioutil.ReadAll(resp.Body)
  36908. if ioErr != nil {
  36909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36911. return ""
  36912. }
  36913. var respJSON map[string]interface{}
  36914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36917. return ""
  36918. }
  36919. var status string
  36920. status = respJSON["data"].(map[string]interface{})["status"].(string)
  36921. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  36922. var res ResultTwo //1101结果
  36923. if status == "1" { //读卡成功
  36924. var card_info string //卡信息
  36925. var busi_card_info string
  36926. token = respJSON["data"].(map[string]interface{})["token"].(string)
  36927. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  36928. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  36929. fmt.Println(card_info)
  36930. fmt.Println(busi_card_info)
  36931. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  36932. result, _ := json.Marshal(respJSON)
  36933. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36934. utils.ErrorLog("解析失败:%v", err)
  36935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36936. return ""
  36937. }
  36938. if res.Infcode == 0 {
  36939. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  36940. if err == gorm.ErrRecordNotFound {
  36941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  36942. return ""
  36943. } else if err != nil {
  36944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  36945. return ""
  36946. } else {
  36947. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36948. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  36949. infoStr := string(Iinfos)
  36950. idetinfoStr := string(Idetinfos)
  36951. psn := &models.HisPsn{
  36952. PsnNo: res.Output.Baseinfo.PsnNo,
  36953. PatientId: patient.ID,
  36954. Certno: res.Output.Baseinfo.Certno,
  36955. Gend: res.Output.Baseinfo.Gend,
  36956. Naty: res.Output.Baseinfo.Naty,
  36957. PsnCertType: res.Output.Baseinfo.PsnCertType,
  36958. PsnName: res.Output.Baseinfo.PsnName,
  36959. Idetinfo: idetinfoStr,
  36960. Insuinfo: infoStr,
  36961. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  36962. CardInfo: card_info,
  36963. VerifyNumber: token,
  36964. }
  36965. service.CreateHisPsn(psn)
  36966. return token
  36967. }
  36968. }
  36969. } else {
  36970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  36971. return ""
  36972. }
  36973. return token
  36974. }
  36975. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  36976. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  36977. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  36978. var token string
  36979. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36980. var api string
  36981. if miConfig.MdtrtareaAdmvs == "320921" {
  36982. 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 +
  36983. "&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
  36984. fmt.Println(api)
  36985. } else {
  36986. 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 +
  36987. "&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
  36988. }
  36989. resp, requestErr := http.Get(api)
  36990. if requestErr != nil {
  36991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36992. return ""
  36993. }
  36994. body, ioErr := ioutil.ReadAll(resp.Body)
  36995. if ioErr != nil {
  36996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36998. return ""
  36999. }
  37000. var respJSON map[string]interface{}
  37001. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37004. return ""
  37005. }
  37006. var status string
  37007. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37008. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37009. var res ResultTwo //1101结果
  37010. var res10265 ResultTwo10265 //1101结果
  37011. if status == "0" { //读卡成功
  37012. var card_info string //卡信息
  37013. var busi_card_info string
  37014. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37015. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37016. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37017. fmt.Println(card_info)
  37018. fmt.Println(busi_card_info)
  37019. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37020. result, _ := json.Marshal(respJSON)
  37021. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37022. utils.ErrorLog("解析失败:%v", err)
  37023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37024. return ""
  37025. }
  37026. res.ErrMsg = res10265.ErrMsg
  37027. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37028. res.Infcode = infocode
  37029. res.Output = res10265.Output
  37030. res.InfRefmsgid = res10265.InfRefmsgid
  37031. if res.Infcode == 0 {
  37032. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37033. if err == gorm.ErrRecordNotFound {
  37034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37035. return ""
  37036. } else if err != nil {
  37037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37038. return ""
  37039. } else {
  37040. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37041. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37042. infoStr := string(Iinfos)
  37043. idetinfoStr := string(Idetinfos)
  37044. psn := &models.HisPsn{
  37045. PsnNo: res.Output.Baseinfo.PsnNo,
  37046. PatientId: patient.ID,
  37047. Certno: res.Output.Baseinfo.Certno,
  37048. Gend: res.Output.Baseinfo.Gend,
  37049. Naty: res.Output.Baseinfo.Naty,
  37050. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37051. PsnName: res.Output.Baseinfo.PsnName,
  37052. Idetinfo: idetinfoStr,
  37053. Insuinfo: infoStr,
  37054. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37055. CardInfo: card_info,
  37056. VerifyNumber: token,
  37057. }
  37058. service.CreateHisPsn(psn)
  37059. return token
  37060. }
  37061. }
  37062. } else {
  37063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37064. return ""
  37065. }
  37066. } else { //读卡失败
  37067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37068. return ""
  37069. }
  37070. return token
  37071. }
  37072. func DeleteExtraSpaceTwo(s string) string {
  37073. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37074. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37075. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37076. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37077. s2 := make([]byte, len(s1)) //定义字符数组切片
  37078. copy(s2, s1) //将字符串复制到切片
  37079. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37080. for len(spc_index) > 0 { //找到适配项
  37081. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37082. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37083. }
  37084. return string(s2)
  37085. }
  37086. func Remove0000(s string) string {
  37087. str := make([]rune, 0, len(s))
  37088. for _, v := range []rune(s) {
  37089. if v == 0 {
  37090. continue
  37091. }
  37092. str = append(str, v)
  37093. }
  37094. return string(str)
  37095. }
  37096. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37097. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37098. readCard := DllDef.MustFindProc("EcQuery")
  37099. pCardInfo := make([]byte, 8192)
  37100. pBusiCardInfo := make([]byte, 8192)
  37101. data := make(map[string]interface{})
  37102. //pData := make(map[string]interface{})
  37103. inputData := make(map[string]interface{})
  37104. inputData["orgId"] = code
  37105. inputData["businessType"] = "01101"
  37106. inputData["operatorId"] = operator_id
  37107. inputData["operatorName"] = operator_name
  37108. inputData["officeId"] = "001"
  37109. inputData["officeName"] = "血透室"
  37110. //
  37111. data["data"] = inputData
  37112. data["transType"] = "ec.query"
  37113. data["orgId"] = code
  37114. bytesData, _ := json.Marshal(data)
  37115. pCardInfo = bytesData
  37116. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37117. fmt.Println(ret2)
  37118. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37119. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37120. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37121. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37122. if ret2 != 0 {
  37123. return "", ""
  37124. }
  37125. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37126. }
  37127. func DeleteExtraSpace(s string) string {
  37128. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37129. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37130. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37131. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37132. s2 := make([]byte, len(s1)) //定义字符数组切片
  37133. copy(s2, s1) //将字符串复制到切片
  37134. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37135. for len(spc_index) > 0 { //找到适配项
  37136. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37137. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37138. }
  37139. return string(s2)
  37140. }
  37141. // 对账
  37142. func (c *HisApiController) Post3202() {
  37143. start_time := c.GetString("start_time")
  37144. end_time := c.GetString("end_time")
  37145. //insutype := c.GetString("insutype")
  37146. clr_type := c.GetString("clr_type")
  37147. clr_org := c.GetString("clr_optins")
  37148. admin_user_id, _ := c.GetInt64("admin_user_id")
  37149. adminUser := c.GetAdminUserInfo()
  37150. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37151. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37152. if len(clr_org) == 0 {
  37153. clr_org = miConfig.MdtrtareaAdmvs
  37154. }
  37155. timeLayout := "2006-01-02"
  37156. loc, _ := time.LoadLocation("Local")
  37157. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37158. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37159. var orders []*models.HisOrder
  37160. if clr_org == "421300" {
  37161. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37162. } else if clr_org == "420902" {
  37163. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37164. } else {
  37165. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37166. }
  37167. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37168. //fixmedins_setl_cnt := int64(len(orders))
  37169. var medfee_sumamt float64
  37170. var acct_pay float64
  37171. var fund_pay_sumamt float64
  37172. for _, item := range orders {
  37173. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37174. acct_pay = acct_pay + item.AcctPay
  37175. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37176. }
  37177. //var medfee_sumamt_two float64
  37178. //var acct_pay_two float64
  37179. //var fund_pay_sumamt_two float64
  37180. //for _, item := range orders_two {
  37181. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37182. // acct_pay_two = acct_pay_two + item.AcctPay
  37183. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37184. //}
  37185. //var user_name string
  37186. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37187. //if role.ID == 0 {
  37188. // user_name = "xxx"
  37189. //} else {
  37190. // user_name = role.UserName
  37191. //}
  37192. var res ResultSix
  37193. if config.IsOpen == 1 {
  37194. var bps []*models.BusinessParamsTwo
  37195. var bp models.BusinessParamsTwo
  37196. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37197. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37198. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37199. bp.MedfeeSumamt = medfee_sumamt_str
  37200. bp.AcctPay = acct_pay_str
  37201. bp.FundPaySumamt = fund_pay_sumamt_str
  37202. bp.Insutype = ""
  37203. bp.StmtBegndate = start_time
  37204. bp.ClrType = clr_type
  37205. bp.SetlOptins = clr_org
  37206. bp.StmtEnddate = end_time
  37207. bps = append(bps, &bp)
  37208. data := make(map[string]interface{})
  37209. data["bps"] = bps
  37210. data["org_name"] = miConfig.OrgName
  37211. data["doctor"] = role.UserName
  37212. data["fixmedins_code"] = miConfig.Code
  37213. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37214. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37215. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37216. if miConfig.MdtrtareaAdmvs == "421300" {
  37217. client := &http.Client{}
  37218. bytesData, _ := json.Marshal(data)
  37219. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37220. resp, _ := client.Do(req)
  37221. defer resp.Body.Close()
  37222. body, ioErr := ioutil.ReadAll(resp.Body)
  37223. if ioErr != nil {
  37224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37226. return
  37227. }
  37228. var respJSON map[string]interface{}
  37229. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37232. return
  37233. }
  37234. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37235. userJSONBytes, _ := json.Marshal(respJSON)
  37236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37237. utils.ErrorLog("解析失败:%v", err)
  37238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37239. return
  37240. }
  37241. }
  37242. if miConfig.MdtrtareaAdmvs == "420200" {
  37243. client := &http.Client{}
  37244. bytesData, _ := json.Marshal(data)
  37245. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37246. resp, _ := client.Do(req)
  37247. defer resp.Body.Close()
  37248. body, ioErr := ioutil.ReadAll(resp.Body)
  37249. if ioErr != nil {
  37250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37252. return
  37253. }
  37254. var respJSON map[string]interface{}
  37255. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37258. return
  37259. }
  37260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37261. userJSONBytes, _ := json.Marshal(respJSON)
  37262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37263. utils.ErrorLog("解析失败:%v", err)
  37264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37265. return
  37266. }
  37267. }
  37268. if miConfig.MdtrtareaAdmvs == "421182" {
  37269. client := &http.Client{}
  37270. bytesData, _ := json.Marshal(data)
  37271. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37272. resp, _ := client.Do(req)
  37273. defer resp.Body.Close()
  37274. body, ioErr := ioutil.ReadAll(resp.Body)
  37275. if ioErr != nil {
  37276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37278. return
  37279. }
  37280. var respJSON map[string]interface{}
  37281. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37284. return
  37285. }
  37286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37287. userJSONBytes, _ := json.Marshal(respJSON)
  37288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37289. utils.ErrorLog("解析失败:%v", err)
  37290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37291. return
  37292. }
  37293. }
  37294. if miConfig.MdtrtareaAdmvs == "420902" {
  37295. client := &http.Client{}
  37296. bytesData, _ := json.Marshal(data)
  37297. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37298. resp, _ := client.Do(req)
  37299. defer resp.Body.Close()
  37300. body, ioErr := ioutil.ReadAll(resp.Body)
  37301. if ioErr != nil {
  37302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37304. return
  37305. }
  37306. var respJSON map[string]interface{}
  37307. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37310. return
  37311. }
  37312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37313. userJSONBytes, _ := json.Marshal(respJSON)
  37314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37315. utils.ErrorLog("解析失败:%v", err)
  37316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37317. return
  37318. }
  37319. }
  37320. if res.Infcode == 0 {
  37321. c.ServeSuccessJSON(map[string]interface{}{
  37322. "msg": "发起成功",
  37323. })
  37324. } else {
  37325. c.ServeSuccessJSON(map[string]interface{}{
  37326. "failed_code": -10,
  37327. "msg": res.ErrMsg,
  37328. })
  37329. }
  37330. }
  37331. }
  37332. func (c *HisApiController) Post3204a() {
  37333. start_time := c.GetString("start_time")
  37334. end_time := c.GetString("end_time")
  37335. //insutype := c.GetString("insutype")
  37336. clr_type := c.GetString("clr_type")
  37337. clr_org := c.GetString("clr_optins")
  37338. admin_user_id, _ := c.GetInt64("admin_user_id")
  37339. adminUser := c.GetAdminUserInfo()
  37340. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37341. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37342. if len(clr_org) == 0 {
  37343. clr_org = miConfig.MdtrtareaAdmvs
  37344. }
  37345. timeLayout := "2006-01-02"
  37346. loc, _ := time.LoadLocation("Local")
  37347. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37348. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37349. var orders []*models.HisOrder
  37350. if clr_org == "421300" {
  37351. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37352. } else if clr_org == "420902" {
  37353. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37354. } else {
  37355. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37356. }
  37357. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37358. //fixmedins_setl_cnt := int64(len(orders))
  37359. var medfee_sumamt float64
  37360. var acct_pay float64
  37361. var fund_pay_sumamt float64
  37362. for _, item := range orders {
  37363. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37364. acct_pay = acct_pay + item.AcctPay
  37365. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37366. }
  37367. //var medfee_sumamt_two float64
  37368. //var acct_pay_two float64
  37369. //var fund_pay_sumamt_two float64
  37370. //for _, item := range orders_two {
  37371. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37372. // acct_pay_two = acct_pay_two + item.AcctPay
  37373. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37374. //}
  37375. //var user_name string
  37376. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37377. //if role.ID == 0 {
  37378. // user_name = "xxx"
  37379. //} else {
  37380. // user_name = role.UserName
  37381. //}
  37382. var res ResultSix
  37383. if config.IsOpen == 1 {
  37384. var bps []*models.BusinessParamsTwo
  37385. var bp models.BusinessParamsTwo
  37386. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37387. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37388. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37389. bp.MedfeeSumamt = medfee_sumamt_str
  37390. bp.AcctPay = acct_pay_str
  37391. bp.FundPaySumamt = fund_pay_sumamt_str
  37392. bp.Insutype = ""
  37393. bp.StmtBegndate = start_time
  37394. bp.ClrType = clr_type
  37395. bp.SetlOptins = clr_org
  37396. bp.StmtEnddate = end_time
  37397. bps = append(bps, &bp)
  37398. data := make(map[string]interface{})
  37399. data["bps"] = bps
  37400. data["org_name"] = miConfig.OrgName
  37401. data["doctor"] = role.UserName
  37402. data["fixmedins_code"] = miConfig.Code
  37403. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37404. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37405. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37406. if miConfig.MdtrtareaAdmvs == "421300" {
  37407. client := &http.Client{}
  37408. bytesData, _ := json.Marshal(data)
  37409. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37410. resp, _ := client.Do(req)
  37411. defer resp.Body.Close()
  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(body), &respJSON); err != nil {
  37420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37422. return
  37423. }
  37424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37425. userJSONBytes, _ := json.Marshal(respJSON)
  37426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37427. utils.ErrorLog("解析失败:%v", err)
  37428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37429. return
  37430. }
  37431. }
  37432. if miConfig.MdtrtareaAdmvs == "420200" {
  37433. client := &http.Client{}
  37434. bytesData, _ := json.Marshal(data)
  37435. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37436. resp, _ := client.Do(req)
  37437. defer resp.Body.Close()
  37438. body, ioErr := ioutil.ReadAll(resp.Body)
  37439. if ioErr != nil {
  37440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37442. return
  37443. }
  37444. var respJSON map[string]interface{}
  37445. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37448. return
  37449. }
  37450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37451. userJSONBytes, _ := json.Marshal(respJSON)
  37452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37453. utils.ErrorLog("解析失败:%v", err)
  37454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37455. return
  37456. }
  37457. }
  37458. if miConfig.MdtrtareaAdmvs == "421182" {
  37459. client := &http.Client{}
  37460. bytesData, _ := json.Marshal(data)
  37461. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37462. resp, _ := client.Do(req)
  37463. defer resp.Body.Close()
  37464. body, ioErr := ioutil.ReadAll(resp.Body)
  37465. if ioErr != nil {
  37466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37468. return
  37469. }
  37470. var respJSON map[string]interface{}
  37471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37474. return
  37475. }
  37476. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37477. userJSONBytes, _ := json.Marshal(respJSON)
  37478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37479. utils.ErrorLog("解析失败:%v", err)
  37480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37481. return
  37482. }
  37483. }
  37484. if miConfig.MdtrtareaAdmvs == "420902" {
  37485. client := &http.Client{}
  37486. bytesData, _ := json.Marshal(data)
  37487. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37488. resp, _ := client.Do(req)
  37489. defer resp.Body.Close()
  37490. body, ioErr := ioutil.ReadAll(resp.Body)
  37491. if ioErr != nil {
  37492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37494. return
  37495. }
  37496. var respJSON map[string]interface{}
  37497. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37500. return
  37501. }
  37502. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37503. userJSONBytes, _ := json.Marshal(respJSON)
  37504. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37505. utils.ErrorLog("解析失败:%v", err)
  37506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37507. return
  37508. }
  37509. }
  37510. if res.Infcode == 0 {
  37511. c.ServeSuccessJSON(map[string]interface{}{
  37512. "msg": "撤销成功",
  37513. })
  37514. } else {
  37515. c.ServeSuccessJSON(map[string]interface{}{
  37516. "failed_code": -10,
  37517. "msg": res.ErrMsg,
  37518. })
  37519. }
  37520. }
  37521. }
  37522. func (c *HisApiController) Post3204() {
  37523. admin_user_id, _ := c.GetInt64("admin_user_id")
  37524. id := c.GetString("id")
  37525. adminUser := c.GetAdminUserInfo()
  37526. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37527. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37528. //clr_org := miConfig.MdtrtareaAdmvs
  37529. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37530. var res ResultSix
  37531. if config.IsOpen == 1 {
  37532. data := make(map[string]interface{})
  37533. data["id"] = id
  37534. data["org_name"] = miConfig.OrgName
  37535. data["doctor"] = role.UserName
  37536. data["fixmedins_code"] = miConfig.Code
  37537. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37538. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37539. client := &http.Client{}
  37540. bytesData, _ := json.Marshal(data)
  37541. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  37542. resp, _ := client.Do(req)
  37543. defer resp.Body.Close()
  37544. body, ioErr := ioutil.ReadAll(resp.Body)
  37545. if ioErr != nil {
  37546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37548. return
  37549. }
  37550. var respJSON map[string]interface{}
  37551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37554. return
  37555. }
  37556. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37557. userJSONBytes, _ := json.Marshal(respJSON)
  37558. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37559. utils.ErrorLog("解析失败:%v", err)
  37560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37561. return
  37562. }
  37563. if res.Infcode == 0 {
  37564. c.ServeSuccessJSON(map[string]interface{}{
  37565. "msg": "发起成功",
  37566. })
  37567. } else {
  37568. c.ServeSuccessJSON(map[string]interface{}{
  37569. "failed_code": -10,
  37570. "msg": res.ErrMsg,
  37571. })
  37572. }
  37573. }
  37574. }
  37575. func (c *HisApiController) Post8404() {
  37576. admin_user_id, _ := c.GetInt64("admin_user_id")
  37577. month := c.GetString("month")
  37578. adminUser := c.GetAdminUserInfo()
  37579. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37580. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37581. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37582. var res ResultSix
  37583. if config.IsOpen == 1 {
  37584. data := make(map[string]interface{})
  37585. data["month"] = month
  37586. data["org_name"] = miConfig.OrgName
  37587. data["doctor"] = role.UserName
  37588. data["fixmedins_code"] = miConfig.Code
  37589. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37590. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37591. client := &http.Client{}
  37592. bytesData, _ := json.Marshal(data)
  37593. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  37594. resp, _ := client.Do(req)
  37595. defer resp.Body.Close()
  37596. body, ioErr := ioutil.ReadAll(resp.Body)
  37597. if ioErr != nil {
  37598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37600. return
  37601. }
  37602. var respJSON map[string]interface{}
  37603. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37606. return
  37607. }
  37608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37609. userJSONBytes, _ := json.Marshal(respJSON)
  37610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37611. utils.ErrorLog("解析失败:%v", err)
  37612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37613. return
  37614. }
  37615. if res.Infcode == 0 {
  37616. c.ServeSuccessJSON(map[string]interface{}{
  37617. "msg": "查询成功",
  37618. })
  37619. } else {
  37620. c.ServeSuccessJSON(map[string]interface{}{
  37621. "failed_code": -10,
  37622. "msg": res.ErrMsg,
  37623. })
  37624. }
  37625. }
  37626. }
  37627. func (c *HisApiController) Post3202b() {
  37628. start_time := c.GetString("start_time")
  37629. end_time := c.GetString("end_time")
  37630. //insutype := c.GetString("insutype")
  37631. clr_type := c.GetString("clr_type")
  37632. clr_org := c.GetString("clr_optins")
  37633. admin_user_id, _ := c.GetInt64("admin_user_id")
  37634. adminUser := c.GetAdminUserInfo()
  37635. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37636. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37637. if len(clr_org) == 0 {
  37638. clr_org = miConfig.MdtrtareaAdmvs
  37639. }
  37640. timeLayout := "2006-01-02"
  37641. loc, _ := time.LoadLocation("Local")
  37642. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37643. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37644. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37645. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37646. //fixmedins_setl_cnt := int64(len(orders))
  37647. var medfee_sumamt float64
  37648. var acct_pay float64
  37649. var fund_pay_sumamt float64
  37650. for _, item := range orders {
  37651. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37652. acct_pay = acct_pay + item.AcctPay
  37653. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37654. }
  37655. //var medfee_sumamt_two float64
  37656. //var acct_pay_two float64
  37657. //var fund_pay_sumamt_two float64
  37658. //for _, item := range orders_two {
  37659. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37660. // acct_pay_two = acct_pay_two + item.AcctPay
  37661. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37662. //}
  37663. //var user_name string
  37664. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37665. //if role.ID == 0 {
  37666. // user_name = "xxx"
  37667. //} else {
  37668. // user_name = role.UserName
  37669. //}
  37670. var res ResultSix
  37671. if config.IsOpen == 1 {
  37672. var bps []*models.BusinessParamsTwo
  37673. var bp models.BusinessParamsTwo
  37674. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37675. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37676. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37677. bp.MedfeeSumamt = medfee_sumamt_str
  37678. bp.AcctPay = acct_pay_str
  37679. bp.FundPaySumamt = fund_pay_sumamt_str
  37680. bp.Insutype = "390"
  37681. bp.StmtBegndate = start_time
  37682. bp.ClrType = clr_type
  37683. bp.SetlOptins = clr_org
  37684. bp.StmtEnddate = end_time
  37685. bps = append(bps, &bp)
  37686. data := make(map[string]interface{})
  37687. data["bps"] = bps
  37688. data["org_name"] = miConfig.OrgName
  37689. data["doctor"] = role.UserName
  37690. data["fixmedins_code"] = miConfig.Code
  37691. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37692. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37693. if miConfig.MdtrtareaAdmvs == "421300" {
  37694. client := &http.Client{}
  37695. bytesData, _ := json.Marshal(data)
  37696. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  37697. resp, _ := client.Do(req)
  37698. defer resp.Body.Close()
  37699. body, ioErr := ioutil.ReadAll(resp.Body)
  37700. if ioErr != nil {
  37701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37703. return
  37704. }
  37705. var respJSON map[string]interface{}
  37706. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37709. return
  37710. }
  37711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37712. userJSONBytes, _ := json.Marshal(respJSON)
  37713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37714. utils.ErrorLog("解析失败:%v", err)
  37715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37716. return
  37717. }
  37718. }
  37719. if miConfig.MdtrtareaAdmvs == "420200" {
  37720. client := &http.Client{}
  37721. bytesData, _ := json.Marshal(data)
  37722. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  37723. resp, _ := client.Do(req)
  37724. defer resp.Body.Close()
  37725. body, ioErr := ioutil.ReadAll(resp.Body)
  37726. if ioErr != nil {
  37727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37729. return
  37730. }
  37731. var respJSON map[string]interface{}
  37732. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37735. return
  37736. }
  37737. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37738. userJSONBytes, _ := json.Marshal(respJSON)
  37739. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37740. utils.ErrorLog("解析失败:%v", err)
  37741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37742. return
  37743. }
  37744. }
  37745. if miConfig.MdtrtareaAdmvs == "421182" {
  37746. client := &http.Client{}
  37747. bytesData, _ := json.Marshal(data)
  37748. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  37749. resp, _ := client.Do(req)
  37750. defer resp.Body.Close()
  37751. body, ioErr := ioutil.ReadAll(resp.Body)
  37752. if ioErr != nil {
  37753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37755. return
  37756. }
  37757. var respJSON map[string]interface{}
  37758. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37761. return
  37762. }
  37763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37764. userJSONBytes, _ := json.Marshal(respJSON)
  37765. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37766. utils.ErrorLog("解析失败:%v", err)
  37767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37768. return
  37769. }
  37770. }
  37771. if res.Infcode == 0 {
  37772. c.ServeSuccessJSON(map[string]interface{}{
  37773. "msg": "发起成功",
  37774. })
  37775. } else {
  37776. c.ServeSuccessJSON(map[string]interface{}{
  37777. "failed_code": -10,
  37778. "msg": res.ErrMsg,
  37779. })
  37780. }
  37781. }
  37782. }
  37783. func (c *HisApiController) Post1608() {
  37784. start_time := c.GetString("start_time")
  37785. end_time := c.GetString("end_time")
  37786. admin_user_id, _ := c.GetInt64("admin_user_id")
  37787. adminUser := c.GetAdminUserInfo()
  37788. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37789. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37790. timeLayout := "2006-01-02"
  37791. loc, _ := time.LoadLocation("Local")
  37792. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37793. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37794. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37795. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37796. fixmedins_setl_cnt := int64(len(orders))
  37797. var medfee_sumamt float64
  37798. var func_smamt float64
  37799. for _, item := range orders {
  37800. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37801. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  37802. }
  37803. times := strings.Split(start_time, "-")
  37804. time_tows := strings.Split(end_time, "-")
  37805. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37806. var res ResultSix
  37807. if config.IsOpen == 1 {
  37808. //var bps []*models.BusinessParamsTwo
  37809. //var bp models.BusinessParamsTwo
  37810. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37811. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  37812. data := make(map[string]interface{})
  37813. data["org_name"] = miConfig.OrgName
  37814. data["doctor"] = role.UserName
  37815. data["func_smamt"] = func_smamt_str
  37816. data["fixmedins_code"] = miConfig.Code
  37817. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37818. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37819. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  37820. data["medfee_sumamt"] = medfee_sumamt_str
  37821. data["start_time"] = times[0] + times[1] + times[2]
  37822. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  37823. if miConfig.MdtrtareaAdmvs == "421300" {
  37824. client := &http.Client{}
  37825. bytesData, _ := json.Marshal(data)
  37826. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  37827. resp, _ := client.Do(req)
  37828. defer resp.Body.Close()
  37829. body, ioErr := ioutil.ReadAll(resp.Body)
  37830. if ioErr != nil {
  37831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37833. return
  37834. }
  37835. var respJSON map[string]interface{}
  37836. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37839. return
  37840. }
  37841. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37842. userJSONBytes, _ := json.Marshal(respJSON)
  37843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37844. utils.ErrorLog("解析失败:%v", err)
  37845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37846. return
  37847. }
  37848. }
  37849. if miConfig.MdtrtareaAdmvs == "420200" {
  37850. client := &http.Client{}
  37851. bytesData, _ := json.Marshal(data)
  37852. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  37853. resp, _ := client.Do(req)
  37854. defer resp.Body.Close()
  37855. body, ioErr := ioutil.ReadAll(resp.Body)
  37856. if ioErr != nil {
  37857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37859. return
  37860. }
  37861. var respJSON map[string]interface{}
  37862. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37865. return
  37866. }
  37867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37868. userJSONBytes, _ := json.Marshal(respJSON)
  37869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37870. utils.ErrorLog("解析失败:%v", err)
  37871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37872. return
  37873. }
  37874. }
  37875. if miConfig.MdtrtareaAdmvs == "421182" {
  37876. client := &http.Client{}
  37877. bytesData, _ := json.Marshal(data)
  37878. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  37879. resp, _ := client.Do(req)
  37880. defer resp.Body.Close()
  37881. body, ioErr := ioutil.ReadAll(resp.Body)
  37882. if ioErr != nil {
  37883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37885. return
  37886. }
  37887. var respJSON map[string]interface{}
  37888. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37891. return
  37892. }
  37893. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37894. userJSONBytes, _ := json.Marshal(respJSON)
  37895. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37896. utils.ErrorLog("解析失败:%v", err)
  37897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37898. return
  37899. }
  37900. }
  37901. if res.Infcode == 0 {
  37902. c.ServeSuccessJSON(map[string]interface{}{
  37903. "msg": "发起成功",
  37904. })
  37905. } else {
  37906. c.ServeSuccessJSON(map[string]interface{}{
  37907. "failed_code": -10,
  37908. "msg": res.ErrMsg,
  37909. })
  37910. }
  37911. }
  37912. }
  37913. // 5.11.1.1【5262】结算信息按时间段查询
  37914. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  37915. admin_user_id, _ := c.GetInt64("admin_user_id")
  37916. adminUser := c.GetAdminUserInfo()
  37917. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37918. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37919. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37920. var res Result5262
  37921. if config.IsOpen == 1 {
  37922. if miConfig.MdtrtareaAdmvs == "421300" {
  37923. data := make(map[string]interface{})
  37924. data["bps"] = bp
  37925. data["org_name"] = miConfig.OrgName
  37926. data["doctor"] = role.UserName
  37927. data["fixmedins_code"] = miConfig.Code
  37928. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37929. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37930. data["page"] = strconv.FormatInt(page, 10)
  37931. data["limit"] = strconv.FormatInt(limit, 10)
  37932. fmt.Println(data)
  37933. client := &http.Client{}
  37934. bytesData, _ := json.Marshal(data)
  37935. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  37936. resp, _ := client.Do(req)
  37937. defer resp.Body.Close()
  37938. body, ioErr := ioutil.ReadAll(resp.Body)
  37939. if ioErr != nil {
  37940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37942. return
  37943. }
  37944. var respJSON map[string]interface{}
  37945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37948. return
  37949. }
  37950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37951. userJSONBytes, _ := json.Marshal(respJSON)
  37952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37953. utils.ErrorLog("解析失败:%v", err)
  37954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37955. return
  37956. }
  37957. }
  37958. if miConfig.MdtrtareaAdmvs == "420200" {
  37959. data := make(map[string]interface{})
  37960. data["bps"] = bp
  37961. data["org_name"] = miConfig.OrgName
  37962. data["doctor"] = role.UserName
  37963. data["fixmedins_code"] = miConfig.Code
  37964. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37965. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37966. data["page"] = strconv.FormatInt(page, 10)
  37967. data["limit"] = strconv.FormatInt(limit, 10)
  37968. fmt.Println(data)
  37969. client := &http.Client{}
  37970. bytesData, _ := json.Marshal(data)
  37971. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  37972. resp, _ := client.Do(req)
  37973. defer resp.Body.Close()
  37974. body, ioErr := ioutil.ReadAll(resp.Body)
  37975. if ioErr != nil {
  37976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37978. return
  37979. }
  37980. var respJSON map[string]interface{}
  37981. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37984. return
  37985. }
  37986. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37987. userJSONBytes, _ := json.Marshal(respJSON)
  37988. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37989. utils.ErrorLog("解析失败:%v", err)
  37990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37991. return
  37992. }
  37993. }
  37994. if miConfig.MdtrtareaAdmvs == "421182" {
  37995. data := make(map[string]interface{})
  37996. data["bps"] = bp
  37997. data["org_name"] = miConfig.OrgName
  37998. data["doctor"] = role.UserName
  37999. data["fixmedins_code"] = miConfig.Code
  38000. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38001. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38002. data["page"] = strconv.FormatInt(page, 10)
  38003. data["limit"] = strconv.FormatInt(limit, 10)
  38004. fmt.Println(data)
  38005. client := &http.Client{}
  38006. bytesData, _ := json.Marshal(data)
  38007. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38008. resp, _ := client.Do(req)
  38009. defer resp.Body.Close()
  38010. body, ioErr := ioutil.ReadAll(resp.Body)
  38011. if ioErr != nil {
  38012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38014. return
  38015. }
  38016. var respJSON map[string]interface{}
  38017. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38020. return
  38021. }
  38022. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38023. userJSONBytes, _ := json.Marshal(respJSON)
  38024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38025. utils.ErrorLog("解析失败:%v", err)
  38026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38027. return
  38028. }
  38029. }
  38030. if miConfig.MdtrtareaAdmvs == "420902" {
  38031. data := make(map[string]interface{})
  38032. data["bps"] = bp
  38033. data["org_name"] = miConfig.OrgName
  38034. data["doctor"] = role.UserName
  38035. data["fixmedins_code"] = miConfig.Code
  38036. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38037. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38038. data["page"] = strconv.FormatInt(page, 10)
  38039. data["limit"] = strconv.FormatInt(limit, 10)
  38040. fmt.Println(data)
  38041. client := &http.Client{}
  38042. bytesData, _ := json.Marshal(data)
  38043. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38044. resp, _ := client.Do(req)
  38045. defer resp.Body.Close()
  38046. body, ioErr := ioutil.ReadAll(resp.Body)
  38047. if ioErr != nil {
  38048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38050. return
  38051. }
  38052. var respJSON map[string]interface{}
  38053. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38056. return
  38057. }
  38058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38059. userJSONBytes, _ := json.Marshal(respJSON)
  38060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38061. utils.ErrorLog("解析失败:%v", err)
  38062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38063. return
  38064. }
  38065. }
  38066. if res.Infcode == 0 {
  38067. c.ServeSuccessJSON(map[string]interface{}{
  38068. "order": res.Output.Result,
  38069. "total": res.Output.PageInfo.RecordCounts,
  38070. })
  38071. } else {
  38072. c.ServeSuccessJSON(map[string]interface{}{
  38073. "failed_code": -10,
  38074. "msg": res.ErrMsg,
  38075. })
  38076. }
  38077. }
  38078. }
  38079. // 5.11.1.2【5267】异地结算信息时间段查询
  38080. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38081. admin_user_id, _ := c.GetInt64("admin_user_id")
  38082. adminUser := c.GetAdminUserInfo()
  38083. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38084. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38085. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38086. var res Result5267
  38087. if config.IsOpen == 1 {
  38088. if miConfig.MdtrtareaAdmvs == "421300" {
  38089. data := make(map[string]interface{})
  38090. data["bps"] = bp
  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. data["page"] = page
  38097. data["limit"] = limit
  38098. fmt.Println(data)
  38099. client := &http.Client{}
  38100. bytesData, _ := json.Marshal(data)
  38101. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38102. resp, _ := client.Do(req)
  38103. defer resp.Body.Close()
  38104. body, ioErr := ioutil.ReadAll(resp.Body)
  38105. if ioErr != nil {
  38106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38108. return
  38109. }
  38110. var respJSON map[string]interface{}
  38111. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38114. return
  38115. }
  38116. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38117. userJSONBytes, _ := json.Marshal(respJSON)
  38118. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38119. utils.ErrorLog("解析失败:%v", err)
  38120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38121. return
  38122. }
  38123. }
  38124. if miConfig.MdtrtareaAdmvs == "420200" {
  38125. data := make(map[string]interface{})
  38126. data["bps"] = bp
  38127. data["org_name"] = miConfig.OrgName
  38128. data["doctor"] = role.UserName
  38129. data["fixmedins_code"] = miConfig.Code
  38130. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38131. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38132. data["page"] = page
  38133. data["limit"] = limit
  38134. fmt.Println(data)
  38135. client := &http.Client{}
  38136. bytesData, _ := json.Marshal(data)
  38137. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38138. resp, _ := client.Do(req)
  38139. defer resp.Body.Close()
  38140. body, ioErr := ioutil.ReadAll(resp.Body)
  38141. if ioErr != nil {
  38142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38144. return
  38145. }
  38146. var respJSON map[string]interface{}
  38147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38150. return
  38151. }
  38152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38153. userJSONBytes, _ := json.Marshal(respJSON)
  38154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38155. utils.ErrorLog("解析失败:%v", err)
  38156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38157. return
  38158. }
  38159. }
  38160. if miConfig.MdtrtareaAdmvs == "421182" {
  38161. data := make(map[string]interface{})
  38162. data["bps"] = bp
  38163. data["org_name"] = miConfig.OrgName
  38164. data["doctor"] = role.UserName
  38165. data["fixmedins_code"] = miConfig.Code
  38166. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38167. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38168. data["page"] = page
  38169. data["limit"] = limit
  38170. fmt.Println(data)
  38171. client := &http.Client{}
  38172. bytesData, _ := json.Marshal(data)
  38173. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38174. resp, _ := client.Do(req)
  38175. defer resp.Body.Close()
  38176. body, ioErr := ioutil.ReadAll(resp.Body)
  38177. if ioErr != nil {
  38178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38180. return
  38181. }
  38182. var respJSON map[string]interface{}
  38183. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38186. return
  38187. }
  38188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38189. userJSONBytes, _ := json.Marshal(respJSON)
  38190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38191. utils.ErrorLog("解析失败:%v", err)
  38192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38193. return
  38194. }
  38195. }
  38196. if res.Infcode == 0 {
  38197. c.ServeSuccessJSON(map[string]interface{}{
  38198. "order": res.Output.Result,
  38199. "total": res.Output.PageInfo.RecordCounts,
  38200. })
  38201. } else {
  38202. c.ServeSuccessJSON(map[string]interface{}{
  38203. "failed_code": -10,
  38204. "msg": res.ErrMsg,
  38205. })
  38206. }
  38207. }
  38208. }
  38209. func (c *HisApiController) Post3501() {
  38210. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38211. data := make(map[string]interface{})
  38212. var struct3501s []models.Struct3501
  38213. var struct3501 models.Struct3501
  38214. struct3501.OrgName = miConfig.OrgName
  38215. struct3501.AccessKey = miConfig.AccessKey
  38216. struct3501.RequestUrl = miConfig.Url
  38217. struct3501.SecretKey = miConfig.SecretKey
  38218. struct3501.ManuDate = "2022-08-17"
  38219. struct3501.FixmedinsBchno = ""
  38220. struct3501.ManuLotnum = ""
  38221. struct3501.RxFlag = "0"
  38222. struct3501.ExpyEnd = "2022-08-17"
  38223. struct3501.Invdate = "2022-08-17"
  38224. struct3501.InvCnt = "20.25"
  38225. struct3501.Memo = ""
  38226. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38227. struct3501.FixmedinsHilistId = miConfig.Code
  38228. struct3501.FixmedinsHilistName = miConfig.OrgName
  38229. struct3501s = append(struct3501s, struct3501)
  38230. data["struct_3501s"] = struct3501s
  38231. client := &http.Client{}
  38232. bytesData, _ := json.Marshal(data)
  38233. var req *http.Request
  38234. if miConfig.MdtrtareaAdmvs == "320921" {
  38235. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38236. } else {
  38237. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38238. }
  38239. resp, _ := client.Do(req)
  38240. defer resp.Body.Close()
  38241. body, ioErr := ioutil.ReadAll(resp.Body)
  38242. if ioErr != nil {
  38243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38245. return
  38246. }
  38247. var respJSON map[string]interface{}
  38248. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38251. return
  38252. }
  38253. var res ResultSix
  38254. var resSix10265 ResultSix10265 //1101结果
  38255. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38256. result, _ := json.Marshal(respJSON)
  38257. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38258. utils.ErrorLog("解析失败:%v", err)
  38259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38260. return
  38261. }
  38262. res.InfRefmsgid = resSix10265.InfRefmsgid
  38263. res.Output = resSix10265.Output
  38264. res.ErrMsg = resSix10265.ErrMsg
  38265. res.Cainfo = resSix10265.Cainfo
  38266. res.WarnMsg = resSix10265.WarnMsg
  38267. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38268. res.Infcode = infocode
  38269. if infocode == 0 {
  38270. c.ServeSuccessJSON(map[string]interface{}{
  38271. "msg": "上传成功",
  38272. })
  38273. return
  38274. } else {
  38275. c.ServeSuccessJSON(map[string]interface{}{
  38276. "failed_code": -10,
  38277. "msg": res.ErrMsg,
  38278. })
  38279. return
  38280. }
  38281. }
  38282. func (c *HisApiController) Post3502() {
  38283. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38284. data := make(map[string]interface{})
  38285. var struct3502s []models.Struct3502
  38286. var struct3502 models.Struct3502
  38287. struct3502.OrgName = miConfig.OrgName
  38288. struct3502.AccessKey = miConfig.AccessKey
  38289. struct3502.RequestUrl = miConfig.Url
  38290. struct3502.SecretKey = miConfig.SecretKey
  38291. struct3502.ManuDate = "2022-08-15"
  38292. struct3502.FixmedinsBchno = ""
  38293. struct3502.ManuLotnum = ""
  38294. struct3502.RxFlag = "0"
  38295. struct3502.ExpyEnd = "2022-08-15"
  38296. struct3502.Invdate = "2022-08-15"
  38297. struct3502.InvCnt = "20.25"
  38298. struct3502.Memo = ""
  38299. struct3502.MedListCodg = "XB01ABD056B002020200517"
  38300. struct3502.FixmedinsHilistId = miConfig.Code
  38301. struct3502.FixmedinsHilistName = miConfig.OrgName
  38302. struct3502s = append(struct3502s, struct3502)
  38303. data["struct_3502s"] = struct3502s
  38304. client := &http.Client{}
  38305. bytesData, _ := json.Marshal(data)
  38306. var req *http.Request
  38307. if miConfig.MdtrtareaAdmvs == "320921" {
  38308. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38309. } else {
  38310. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38311. }
  38312. resp, _ := client.Do(req)
  38313. defer resp.Body.Close()
  38314. body, ioErr := ioutil.ReadAll(resp.Body)
  38315. if ioErr != nil {
  38316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38318. return
  38319. }
  38320. var respJSON map[string]interface{}
  38321. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38324. return
  38325. }
  38326. var res ResultSix
  38327. var resSix10265 ResultSix10265 //1101结果
  38328. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38329. result, _ := json.Marshal(respJSON)
  38330. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38331. utils.ErrorLog("解析失败:%v", err)
  38332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38333. return
  38334. }
  38335. res.InfRefmsgid = resSix10265.InfRefmsgid
  38336. res.Output = resSix10265.Output
  38337. res.ErrMsg = resSix10265.ErrMsg
  38338. res.Cainfo = resSix10265.Cainfo
  38339. res.WarnMsg = resSix10265.WarnMsg
  38340. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38341. res.Infcode = infocode
  38342. if infocode == 0 {
  38343. c.ServeSuccessJSON(map[string]interface{}{
  38344. "msg": "上传成功",
  38345. })
  38346. return
  38347. } else {
  38348. c.ServeSuccessJSON(map[string]interface{}{
  38349. "failed_code": -10,
  38350. "msg": res.ErrMsg,
  38351. })
  38352. return
  38353. }
  38354. }
  38355. func (c *HisApiController) Post3503() {
  38356. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38357. data := make(map[string]interface{})
  38358. var struct3501s []models.Struct3501
  38359. var struct3501 models.Struct3501
  38360. struct3501.OrgName = miConfig.OrgName
  38361. struct3501.AccessKey = miConfig.AccessKey
  38362. struct3501.RequestUrl = miConfig.Url
  38363. struct3501.SecretKey = miConfig.SecretKey
  38364. struct3501.ManuDate = "2022-08-15"
  38365. struct3501.FixmedinsBchno = ""
  38366. struct3501.ManuLotnum = ""
  38367. struct3501.RxFlag = "0"
  38368. struct3501.ExpyEnd = "2022-08-15"
  38369. struct3501.Invdate = "2022-08-15"
  38370. struct3501.InvCnt = "20.25"
  38371. struct3501.Memo = ""
  38372. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38373. struct3501.FixmedinsHilistId = miConfig.Code
  38374. struct3501.FixmedinsHilistName = miConfig.OrgName
  38375. struct3501s = append(struct3501s, struct3501)
  38376. data["struct_3501s"] = struct3501s
  38377. client := &http.Client{}
  38378. bytesData, _ := json.Marshal(data)
  38379. var req *http.Request
  38380. if miConfig.MdtrtareaAdmvs == "320921" {
  38381. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38382. } else {
  38383. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38384. }
  38385. resp, _ := client.Do(req)
  38386. defer resp.Body.Close()
  38387. body, ioErr := ioutil.ReadAll(resp.Body)
  38388. if ioErr != nil {
  38389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38391. return
  38392. }
  38393. var respJSON map[string]interface{}
  38394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38397. return
  38398. }
  38399. var res ResultSix
  38400. var resSix10265 ResultSix10265 //1101结果
  38401. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38402. result, _ := json.Marshal(respJSON)
  38403. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38404. utils.ErrorLog("解析失败:%v", err)
  38405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38406. return
  38407. }
  38408. res.InfRefmsgid = resSix10265.InfRefmsgid
  38409. res.Output = resSix10265.Output
  38410. res.ErrMsg = resSix10265.ErrMsg
  38411. res.Cainfo = resSix10265.Cainfo
  38412. res.WarnMsg = resSix10265.WarnMsg
  38413. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38414. res.Infcode = infocode
  38415. if infocode == 0 {
  38416. c.ServeSuccessJSON(map[string]interface{}{
  38417. "msg": "上传成功",
  38418. })
  38419. return
  38420. } else {
  38421. c.ServeSuccessJSON(map[string]interface{}{
  38422. "failed_code": -10,
  38423. "msg": res.ErrMsg,
  38424. })
  38425. return
  38426. }
  38427. }
  38428. func (c *HisApiController) Post3504() {
  38429. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38430. data := make(map[string]interface{})
  38431. var struct3501s []models.Struct3501
  38432. var struct3501 models.Struct3501
  38433. struct3501.OrgName = miConfig.OrgName
  38434. struct3501.AccessKey = miConfig.AccessKey
  38435. struct3501.RequestUrl = miConfig.Url
  38436. struct3501.SecretKey = miConfig.SecretKey
  38437. struct3501.ManuDate = "2022-08-15"
  38438. struct3501.FixmedinsBchno = ""
  38439. struct3501.ManuLotnum = ""
  38440. struct3501.RxFlag = "0"
  38441. struct3501.ExpyEnd = "2022-08-15"
  38442. struct3501.Invdate = "2022-08-15"
  38443. struct3501.InvCnt = "20.25"
  38444. struct3501.Memo = ""
  38445. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38446. struct3501.FixmedinsHilistId = miConfig.Code
  38447. struct3501.FixmedinsHilistName = miConfig.OrgName
  38448. struct3501s = append(struct3501s, struct3501)
  38449. data["struct_3501s"] = struct3501s
  38450. client := &http.Client{}
  38451. bytesData, _ := json.Marshal(data)
  38452. var req *http.Request
  38453. if miConfig.MdtrtareaAdmvs == "320921" {
  38454. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38455. } else {
  38456. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38457. }
  38458. resp, _ := client.Do(req)
  38459. defer resp.Body.Close()
  38460. body, ioErr := ioutil.ReadAll(resp.Body)
  38461. if ioErr != nil {
  38462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38464. return
  38465. }
  38466. var respJSON map[string]interface{}
  38467. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38470. return
  38471. }
  38472. var res ResultSix
  38473. var resSix10265 ResultSix10265 //1101结果
  38474. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38475. result, _ := json.Marshal(respJSON)
  38476. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38477. utils.ErrorLog("解析失败:%v", err)
  38478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38479. return
  38480. }
  38481. res.InfRefmsgid = resSix10265.InfRefmsgid
  38482. res.Output = resSix10265.Output
  38483. res.ErrMsg = resSix10265.ErrMsg
  38484. res.Cainfo = resSix10265.Cainfo
  38485. res.WarnMsg = resSix10265.WarnMsg
  38486. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38487. res.Infcode = infocode
  38488. if infocode == 0 {
  38489. c.ServeSuccessJSON(map[string]interface{}{
  38490. "msg": "上传成功",
  38491. })
  38492. return
  38493. } else {
  38494. c.ServeSuccessJSON(map[string]interface{}{
  38495. "failed_code": -10,
  38496. "msg": res.ErrMsg,
  38497. })
  38498. return
  38499. }
  38500. }
  38501. func (c *HisApiController) Post3505() {
  38502. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38503. data := make(map[string]interface{})
  38504. var struct3501s []models.Struct3501
  38505. var struct3501 models.Struct3501
  38506. struct3501.OrgName = miConfig.OrgName
  38507. struct3501.AccessKey = miConfig.AccessKey
  38508. struct3501.RequestUrl = miConfig.Url
  38509. struct3501.SecretKey = miConfig.SecretKey
  38510. struct3501.ManuDate = "2022-08-15"
  38511. struct3501.FixmedinsBchno = ""
  38512. struct3501.ManuLotnum = ""
  38513. struct3501.RxFlag = "0"
  38514. struct3501.ExpyEnd = "2022-08-15"
  38515. struct3501.Invdate = "2022-08-15"
  38516. struct3501.InvCnt = "20.25"
  38517. struct3501.Memo = ""
  38518. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38519. struct3501.FixmedinsHilistId = miConfig.Code
  38520. struct3501.FixmedinsHilistName = miConfig.OrgName
  38521. struct3501s = append(struct3501s, struct3501)
  38522. data["struct_3501s"] = struct3501s
  38523. client := &http.Client{}
  38524. bytesData, _ := json.Marshal(data)
  38525. var req *http.Request
  38526. if miConfig.MdtrtareaAdmvs == "320921" {
  38527. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38528. } else {
  38529. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38530. }
  38531. resp, _ := client.Do(req)
  38532. defer resp.Body.Close()
  38533. body, ioErr := ioutil.ReadAll(resp.Body)
  38534. if ioErr != nil {
  38535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38537. return
  38538. }
  38539. var respJSON map[string]interface{}
  38540. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38543. return
  38544. }
  38545. var res ResultSix
  38546. var resSix10265 ResultSix10265 //1101结果
  38547. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38548. result, _ := json.Marshal(respJSON)
  38549. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38550. utils.ErrorLog("解析失败:%v", err)
  38551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38552. return
  38553. }
  38554. res.InfRefmsgid = resSix10265.InfRefmsgid
  38555. res.Output = resSix10265.Output
  38556. res.ErrMsg = resSix10265.ErrMsg
  38557. res.Cainfo = resSix10265.Cainfo
  38558. res.WarnMsg = resSix10265.WarnMsg
  38559. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38560. res.Infcode = infocode
  38561. if infocode == 0 {
  38562. c.ServeSuccessJSON(map[string]interface{}{
  38563. "msg": "上传成功",
  38564. })
  38565. return
  38566. } else {
  38567. c.ServeSuccessJSON(map[string]interface{}{
  38568. "failed_code": -10,
  38569. "msg": res.ErrMsg,
  38570. })
  38571. return
  38572. }
  38573. }
  38574. func (c *HisApiController) Post3506() {
  38575. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38576. data := make(map[string]interface{})
  38577. var struct3501s []models.Struct3501
  38578. var struct3501 models.Struct3501
  38579. struct3501.OrgName = miConfig.OrgName
  38580. struct3501.AccessKey = miConfig.AccessKey
  38581. struct3501.RequestUrl = miConfig.Url
  38582. struct3501.SecretKey = miConfig.SecretKey
  38583. struct3501.ManuDate = "2022-08-15"
  38584. struct3501.FixmedinsBchno = ""
  38585. struct3501.ManuLotnum = ""
  38586. struct3501.RxFlag = "0"
  38587. struct3501.ExpyEnd = "2022-08-15"
  38588. struct3501.Invdate = "2022-08-15"
  38589. struct3501.InvCnt = "20.25"
  38590. struct3501.Memo = ""
  38591. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38592. struct3501.FixmedinsHilistId = miConfig.Code
  38593. struct3501.FixmedinsHilistName = miConfig.OrgName
  38594. struct3501s = append(struct3501s, struct3501)
  38595. data["struct_3501s"] = struct3501s
  38596. client := &http.Client{}
  38597. bytesData, _ := json.Marshal(data)
  38598. var req *http.Request
  38599. if miConfig.MdtrtareaAdmvs == "320921" {
  38600. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38601. } else {
  38602. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38603. }
  38604. resp, _ := client.Do(req)
  38605. defer resp.Body.Close()
  38606. body, ioErr := ioutil.ReadAll(resp.Body)
  38607. if ioErr != nil {
  38608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38610. return
  38611. }
  38612. var respJSON map[string]interface{}
  38613. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38616. return
  38617. }
  38618. var res ResultSix
  38619. var resSix10265 ResultSix10265 //1101结果
  38620. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38621. result, _ := json.Marshal(respJSON)
  38622. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38623. utils.ErrorLog("解析失败:%v", err)
  38624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38625. return
  38626. }
  38627. res.InfRefmsgid = resSix10265.InfRefmsgid
  38628. res.Output = resSix10265.Output
  38629. res.ErrMsg = resSix10265.ErrMsg
  38630. res.Cainfo = resSix10265.Cainfo
  38631. res.WarnMsg = resSix10265.WarnMsg
  38632. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38633. res.Infcode = infocode
  38634. if infocode == 0 {
  38635. c.ServeSuccessJSON(map[string]interface{}{
  38636. "msg": "上传成功",
  38637. })
  38638. return
  38639. } else {
  38640. c.ServeSuccessJSON(map[string]interface{}{
  38641. "failed_code": -10,
  38642. "msg": res.ErrMsg,
  38643. })
  38644. return
  38645. }
  38646. }
  38647. func (c *HisApiController) Post3507() {
  38648. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38649. data := make(map[string]interface{})
  38650. var struct3501s []models.Struct3501
  38651. var struct3501 models.Struct3501
  38652. struct3501.OrgName = miConfig.OrgName
  38653. struct3501.AccessKey = miConfig.AccessKey
  38654. struct3501.RequestUrl = miConfig.Url
  38655. struct3501.SecretKey = miConfig.SecretKey
  38656. struct3501.ManuDate = "2022-08-15"
  38657. struct3501.FixmedinsBchno = ""
  38658. struct3501.ManuLotnum = ""
  38659. struct3501.RxFlag = "0"
  38660. struct3501.ExpyEnd = "2022-08-15"
  38661. struct3501.Invdate = "2022-08-15"
  38662. struct3501.InvCnt = "20.25"
  38663. struct3501.Memo = ""
  38664. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38665. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  38666. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  38667. struct3501s = append(struct3501s, struct3501)
  38668. data["struct_3501s"] = struct3501s
  38669. client := &http.Client{}
  38670. bytesData, _ := json.Marshal(data)
  38671. var req *http.Request
  38672. if miConfig.MdtrtareaAdmvs == "320921" {
  38673. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38674. } else {
  38675. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38676. }
  38677. resp, _ := client.Do(req)
  38678. defer resp.Body.Close()
  38679. body, ioErr := ioutil.ReadAll(resp.Body)
  38680. if ioErr != nil {
  38681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38683. return
  38684. }
  38685. var respJSON map[string]interface{}
  38686. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38689. return
  38690. }
  38691. var res ResultSix
  38692. var resSix10265 ResultSix10265 //1101结果
  38693. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38694. result, _ := json.Marshal(respJSON)
  38695. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38696. utils.ErrorLog("解析失败:%v", err)
  38697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38698. return
  38699. }
  38700. res.InfRefmsgid = resSix10265.InfRefmsgid
  38701. res.Output = resSix10265.Output
  38702. res.ErrMsg = resSix10265.ErrMsg
  38703. res.Cainfo = resSix10265.Cainfo
  38704. res.WarnMsg = resSix10265.WarnMsg
  38705. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38706. res.Infcode = infocode
  38707. if infocode == 0 {
  38708. c.ServeSuccessJSON(map[string]interface{}{
  38709. "msg": "上传成功",
  38710. })
  38711. return
  38712. } else {
  38713. c.ServeSuccessJSON(map[string]interface{}{
  38714. "failed_code": -10,
  38715. "msg": res.ErrMsg,
  38716. })
  38717. return
  38718. }
  38719. }
  38720. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  38721. // WebSocket服务器地址
  38722. serverURL := "ws://127.0.0.1:8899"
  38723. // 解析WebSocket服务器地址
  38724. u, err := url.Parse(serverURL)
  38725. if err != nil {
  38726. }
  38727. // 建立WebSocket连接
  38728. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38729. if err != nil {
  38730. }
  38731. defer conn.Close()
  38732. input2 := make(map[string]interface{})
  38733. input := make(map[string]interface{})
  38734. inputData := make(map[string]interface{})
  38735. inputData["orgId"] = code
  38736. inputData["businessType"] = "01101"
  38737. inputData["operatorId"] = operator_id
  38738. inputData["operatorName"] = operator_name
  38739. inputData["officeId"] = "001"
  38740. inputData["officeName"] = "血透室"
  38741. inputData["deviceType"] = ""
  38742. input["data"] = inputData
  38743. input["orgId"] = code
  38744. input["transType"] = "ec.query"
  38745. //if md == ""
  38746. if md[:4] == "4403" {
  38747. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38748. } else if md[:4] == "4401" {
  38749. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38750. } else {
  38751. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38752. }
  38753. input2["indata"] = input
  38754. fmt.Println(input2)
  38755. bytesData, _ := json.Marshal(input2)
  38756. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38757. if err != nil {
  38758. fmt.Println(err)
  38759. }
  38760. // 接收消息
  38761. _, receivedMessage, err := conn.ReadMessage()
  38762. if err != nil {
  38763. fmt.Println(err)
  38764. }
  38765. return "", string(receivedMessage)
  38766. }
  38767. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  38768. // WebSocket服务器地址
  38769. serverURL := "ws://127.0.0.1:8899"
  38770. // 解析WebSocket服务器地址
  38771. u, err := url.Parse(serverURL)
  38772. if err != nil {
  38773. }
  38774. // 建立WebSocket连接
  38775. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38776. if err != nil {
  38777. }
  38778. defer conn.Close()
  38779. input2 := make(map[string]interface{})
  38780. input := make(map[string]interface{})
  38781. inputData := make(map[string]interface{})
  38782. inputData["orgId"] = code
  38783. inputData["businessType"] = "01101"
  38784. inputData["operatorId"] = operator_id
  38785. inputData["operatorName"] = operator_name
  38786. inputData["officeId"] = "001"
  38787. inputData["officeName"] = "血透室"
  38788. inputData["deviceType"] = ""
  38789. input["data"] = inputData
  38790. input["orgId"] = code
  38791. input["transType"] = "ec.query"
  38792. //if md == ""
  38793. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  38794. input2["indata"] = input
  38795. fmt.Println(input2)
  38796. bytesData, _ := json.Marshal(input2)
  38797. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38798. if err != nil {
  38799. fmt.Println(err)
  38800. }
  38801. // 接收消息
  38802. _, receivedMessage, err := conn.ReadMessage()
  38803. if err != nil {
  38804. fmt.Println(err)
  38805. }
  38806. return "", string(receivedMessage)
  38807. }
  38808. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  38809. // WebSocket服务器地址
  38810. serverURL := "ws://127.0.0.1:8899"
  38811. // 解析WebSocket服务器地址
  38812. u, err := url.Parse(serverURL)
  38813. if err != nil {
  38814. }
  38815. // 建立WebSocket连接
  38816. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38817. if err != nil {
  38818. }
  38819. defer conn.Close()
  38820. input2 := make(map[string]interface{})
  38821. input := make(map[string]interface{})
  38822. inputData := make(map[string]interface{})
  38823. inputData["orgId"] = code
  38824. inputData["businessType"] = "01301"
  38825. inputData["operatorId"] = operator_id
  38826. inputData["operatorName"] = operator_name
  38827. inputData["officeId"] = "001"
  38828. inputData["officeName"] = "血透室"
  38829. inputData["deviceType"] = ""
  38830. input["data"] = inputData
  38831. input["orgId"] = code
  38832. input["transType"] = "ec.query"
  38833. //if md == ""
  38834. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  38835. input2["indata"] = input
  38836. fmt.Println(input2)
  38837. bytesData, _ := json.Marshal(input2)
  38838. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38839. if err != nil {
  38840. fmt.Println(err)
  38841. }
  38842. // 接收消息
  38843. _, receivedMessage, err := conn.ReadMessage()
  38844. if err != nil {
  38845. fmt.Println(err)
  38846. }
  38847. return "", string(receivedMessage)
  38848. }
  38849. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  38850. // WebSocket服务器地址
  38851. serverURL := "ws://127.0.0.1:8899"
  38852. // 解析WebSocket服务器地址
  38853. u, err := url.Parse(serverURL)
  38854. if err != nil {
  38855. }
  38856. // 建立WebSocket连接
  38857. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38858. if err != nil {
  38859. }
  38860. defer conn.Close()
  38861. input2 := make(map[string]interface{})
  38862. input := make(map[string]interface{})
  38863. inputData := make(map[string]interface{})
  38864. inputData["orgId"] = code
  38865. inputData["businessType"] = "01103"
  38866. inputData["operatorId"] = operator_id
  38867. inputData["operatorName"] = operator_name
  38868. inputData["officeId"] = "001"
  38869. inputData["officeName"] = "血透室"
  38870. inputData["deviceType"] = ""
  38871. input["data"] = inputData
  38872. input["orgId"] = code
  38873. input["transType"] = "ec.query"
  38874. //if md ==
  38875. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  38876. input2["indata"] = input
  38877. fmt.Println(input2)
  38878. bytesData, _ := json.Marshal(input2)
  38879. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38880. if err != nil {
  38881. fmt.Println(err)
  38882. }
  38883. // 接收消息
  38884. _, receivedMessage, err := conn.ReadMessage()
  38885. if err != nil {
  38886. fmt.Println(err)
  38887. }
  38888. return "", string(receivedMessage)
  38889. }
  38890. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  38891. // WebSocket服务器地址
  38892. serverURL := "ws://127.0.0.1:8899"
  38893. // 解析WebSocket服务器地址
  38894. u, err := url.Parse(serverURL)
  38895. if err != nil {
  38896. }
  38897. // 建立WebSocket连接
  38898. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38899. if err != nil {
  38900. }
  38901. defer conn.Close()
  38902. input2 := make(map[string]interface{})
  38903. input := make(map[string]interface{})
  38904. inputData := make(map[string]interface{})
  38905. inputData["orgId"] = code
  38906. inputData["businessType"] = "01101"
  38907. inputData["operatorId"] = operator_id
  38908. inputData["operatorName"] = operator_name
  38909. inputData["officeId"] = "001"
  38910. inputData["officeName"] = "血透室"
  38911. inputData["deviceType"] = ""
  38912. input["data"] = inputData
  38913. input["orgId"] = code
  38914. input["transType"] = "ec.query"
  38915. //if md == ""
  38916. if md[:4] == "4403" {
  38917. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38918. } else if md[:4] == "4401" {
  38919. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38920. } else {
  38921. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38922. }
  38923. input2["indata"] = input
  38924. fmt.Println(input2)
  38925. bytesData, _ := json.Marshal(input2)
  38926. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38927. if err != nil {
  38928. fmt.Println(err)
  38929. }
  38930. // 接收消息
  38931. _, receivedMessage, err := conn.ReadMessage()
  38932. if err != nil {
  38933. fmt.Println(err)
  38934. }
  38935. return "", string(receivedMessage)
  38936. }
  38937. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  38938. // WebSocket服务器地址
  38939. serverURL := "ws://127.0.0.1:8899"
  38940. // 解析WebSocket服务器地址
  38941. u, err := url.Parse(serverURL)
  38942. if err != nil {
  38943. }
  38944. // 建立WebSocket连接
  38945. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38946. if err != nil {
  38947. }
  38948. defer conn.Close()
  38949. input2 := make(map[string]interface{})
  38950. input := make(map[string]interface{})
  38951. inputData := make(map[string]interface{})
  38952. inputData["orgId"] = code
  38953. inputData["businessType"] = "01301"
  38954. inputData["operatorId"] = operator_id
  38955. inputData["operatorName"] = operator_name
  38956. inputData["officeId"] = "001"
  38957. inputData["officeName"] = "血透室"
  38958. inputData["deviceType"] = ""
  38959. input["data"] = inputData
  38960. input["orgId"] = code
  38961. input["transType"] = "ec.query"
  38962. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38963. input2["indata"] = input
  38964. bytesData, _ := json.Marshal(input2)
  38965. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38966. if err != nil {
  38967. fmt.Println(err)
  38968. }
  38969. // 接收消息
  38970. _, receivedMessage, err := conn.ReadMessage()
  38971. if err != nil {
  38972. fmt.Println(err)
  38973. }
  38974. return "", string(receivedMessage)
  38975. }
  38976. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  38977. newArr = make([]string, 0)
  38978. for i := 0; i < len(arr); i++ {
  38979. repeat := false
  38980. for j := i + 1; j < len(arr); j++ {
  38981. if arr[i] == arr[j] {
  38982. repeat = true
  38983. break
  38984. }
  38985. }
  38986. if !repeat {
  38987. newArr = append(newArr, arr[i])
  38988. }
  38989. }
  38990. return
  38991. }
  38992. func getBirthdateAndAge(idNumber string) (string, int, error) {
  38993. if len(idNumber) != 18 {
  38994. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  38995. }
  38996. // 提取出生日期
  38997. year, err := strconv.Atoi(idNumber[6:10])
  38998. if err != nil {
  38999. return "", 0, err
  39000. }
  39001. month, err := strconv.Atoi(idNumber[10:12])
  39002. if err != nil {
  39003. return "", 0, err
  39004. }
  39005. day, err := strconv.Atoi(idNumber[12:14])
  39006. if err != nil {
  39007. return "", 0, err
  39008. }
  39009. // 格式化生日字符串
  39010. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39011. birthdateFormatted := birthdate.Format("2006-01-02")
  39012. // 计算年龄
  39013. today := time.Now()
  39014. age := today.Year() - birthdate.Year()
  39015. if today.YearDay() < birthdate.YearDay() {
  39016. age--
  39017. }
  39018. return birthdateFormatted, age, nil
  39019. }
  39020. // 从身份证号码中提取出生年月日
  39021. func getBirthDateFromIDCard(idCard string) (string, error) {
  39022. // 身份证号码长度应为18位
  39023. if len(idCard) != 18 {
  39024. return "", fmt.Errorf("身份证号码长度应为18位")
  39025. }
  39026. // 提取出生日期部分 (YYYYMMDD)
  39027. birthDateStr := idCard[6:14]
  39028. // 解析出生日期
  39029. birthDate, err := time.Parse("20060102", birthDateStr)
  39030. if err != nil {
  39031. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39032. }
  39033. // 格式化出生日期为 YYYY-MM-DD
  39034. formattedDate := birthDate.Format("2006-01-02")
  39035. return formattedDate, nil
  39036. }